Skip to content

Commit 9f0768f

Browse files
simpler imu
1 parent 57fe3c9 commit 9f0768f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

internal_filesystem/apps/com.micropythonos.imu/META-INF/MANIFEST.JSON

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"publisher": "MicroPythonOS",
44
"short_description": "Inertial Measurement Unit Visualization",
55
"long_description": "Visualize data from the Intertial Measurement Unit, also known as the accellerometer.",
6-
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.helloworld/icons/com.micropythonos.imu.0.0.1_64x64.png",
7-
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.helloworld/mpks/com.micropythonos.mu.0.0.1.mpk",
6+
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.helloworld/icons/com.micropythonos.imu.0.0.2_64x64.png",
7+
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.helloworld/mpks/com.micropythonos.mu.0.0.2.mpk",
88
"fullname": "com.micropythonos.imu",
9-
"version": "0.0.1",
9+
"version": "0.0.2",
1010
"category": "hardware",
1111
"activities": [
1212
{

internal_filesystem/apps/com.micropythonos.imu/assets/imu.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def onStop(self, screen):
5151
print("stopping imu refresh_timer")
5252
self.refresh_timer.delete()
5353

54-
def map_nonlinear(self, value: float) -> int:
54+
def convert_percentage(self, value: float) -> int:
55+
return round(50.0 + value)
56+
# non-linear mapping isn't really useful so unused:
5557
# Preserve sign and work with absolute value
5658
sign = 1 if value >= 0 else -1
5759
abs_value = abs(value)
@@ -76,9 +78,9 @@ def refresh(self, timer):
7678
az = self.sensor.acceleration[2]
7779
azp = int((az * 100 + 100)/2)
7880
# values between -200 and 200 => /4 becomes -50 and 50 => +50 becomes 0 and 100
79-
gx = self.map_nonlinear(self.sensor.gyro[0])
80-
gy = self.map_nonlinear(self.sensor.gyro[1])
81-
gz = self.map_nonlinear(self.sensor.gyro[2])
81+
gx = self.convert_percentage(self.sensor.gyro[0])
82+
gy = self.convert_percentage(self.sensor.gyro[1])
83+
gz = self.convert_percentage(self.sensor.gyro[2])
8284
self.templabel.set_text(f"IMU chip temperature: {temp:.2f}°C")
8385
else:
8486
#temp = 12.34

0 commit comments

Comments
 (0)