micrOSDevToolKit 2.10.6__py3-none-any.whl → 2.13.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of micrOSDevToolKit might be problematic. Click here for more details.

Files changed (151) hide show
  1. env/driver_cp210x/macOS_VCP_Driver/SiLabsUSBDriverDisk.dmg +0 -0
  2. env/driver_cp210x/macOS_VCP_Driver/macOS_VCP_Driver_Release_Notes.txt +17 -1
  3. micrOS/micropython/esp32c6-GENERIC-20250415-v1.25.0.bin +0 -0
  4. micrOS/micropython/esp32s3-4MBflash-20241129-v1.24.1.bin +0 -0
  5. micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +57 -61
  6. micrOS/source/Common.py +286 -91
  7. micrOS/source/Config.py +7 -7
  8. micrOS/source/Debug.py +50 -94
  9. micrOS/source/Espnow.py +7 -7
  10. micrOS/source/Files.py +23 -2
  11. micrOS/source/Hooks.py +62 -19
  12. micrOS/source/IO_esp32c6.py +16 -0
  13. micrOS/source/IO_esp32s3.py +37 -1
  14. micrOS/source/IO_m5stamp.py +35 -1
  15. micrOS/source/IO_qtpy.py +22 -17
  16. micrOS/source/IO_s3matrix.py +21 -0
  17. micrOS/source/IO_tinypico.py +38 -0
  18. micrOS/source/InterConnect.py +5 -5
  19. micrOS/source/Interrupts.py +2 -2
  20. micrOS/source/LM_VL53L0X.py +1 -1
  21. micrOS/source/LM_buzzer.py +6 -7
  22. micrOS/source/LM_cct.py +6 -5
  23. micrOS/source/LM_dashboard_be.py +2 -2
  24. micrOS/source/LM_dimmer.py +6 -5
  25. micrOS/source/LM_espnow.py +15 -10
  26. micrOS/source/LM_i2c.py +3 -2
  27. micrOS/source/LM_neoeffects.py +173 -230
  28. micrOS/source/LM_neomatrix.py +335 -0
  29. micrOS/source/LM_neopixel.py +10 -10
  30. micrOS/source/LM_pacman.py +40 -23
  31. micrOS/source/LM_qmi8658.py +204 -0
  32. micrOS/source/LM_rgb.py +6 -6
  33. micrOS/source/LM_roboarm.py +5 -4
  34. micrOS/source/LM_switch.py +6 -4
  35. micrOS/source/LM_tcs3472.py +75 -0
  36. micrOS/source/LM_telegram.py +5 -4
  37. micrOS/source/Logger.py +47 -33
  38. micrOS/source/Network.py +6 -6
  39. micrOS/source/Notify.py +2 -2
  40. micrOS/source/Scheduler.py +5 -5
  41. micrOS/source/Server.py +6 -6
  42. micrOS/source/Shell.py +4 -4
  43. micrOS/source/Tasks.py +20 -17
  44. micrOS/source/Time.py +12 -10
  45. micrOS/source/Types.py +2 -2
  46. micrOS/source/Web.py +20 -13
  47. micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
  48. micrOS/source/__pycache__/Debug.cpython-312.pyc +0 -0
  49. micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
  50. micrOS/source/__pycache__/Server.cpython-312.pyc +0 -0
  51. micrOS/source/micrOS.py +10 -7
  52. micrOS/source/micrOSloader.py +6 -6
  53. micrOS/source/microIO.py +8 -6
  54. micrOS/source/urequests.py +4 -4
  55. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.13.0.dist-info}/METADATA +24 -22
  56. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.13.0.dist-info}/RECORD +142 -132
  57. toolkit/DevEnvCompile.py +20 -15
  58. toolkit/DevEnvOTA.py +29 -8
  59. toolkit/DevEnvUSB.py +52 -10
  60. toolkit/LM_to_compile.dat +1 -0
  61. toolkit/MicrOSDevEnv.py +10 -2
  62. toolkit/MicrosFiles.py +26 -0
  63. toolkit/dashboard_apps/NeoEffectsDemo.py +8 -15
  64. toolkit/dashboard_apps/QMI8685_GYRO.py +68 -0
  65. toolkit/dashboard_apps/_app_base.py +2 -2
  66. toolkit/dashboard_apps/_gyro_visualizer.py +78 -0
  67. toolkit/lib/LocalMachine.py +6 -1
  68. toolkit/lib/file_extensions.py +9 -3
  69. toolkit/micrOSlint.py +3 -1
  70. toolkit/simulator_lib/__pycache__/IO_darwin.cpython-312.pyc +0 -0
  71. toolkit/simulator_lib/__pycache__/machine.cpython-312.pyc +0 -0
  72. toolkit/simulator_lib/__pycache__/neopixel.cpython-312.pyc +0 -0
  73. toolkit/simulator_lib/machine.py +0 -1
  74. toolkit/simulator_lib/neopixel.py +3 -2
  75. toolkit/socketClient.py +3 -2
  76. toolkit/workspace/precompiled/Common.cpython-312.pyc +0 -0
  77. toolkit/workspace/precompiled/Common.mpy +0 -0
  78. toolkit/workspace/precompiled/Config.mpy +0 -0
  79. toolkit/workspace/precompiled/Debug.mpy +0 -0
  80. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  81. toolkit/workspace/precompiled/Files.mpy +0 -0
  82. toolkit/workspace/precompiled/Hooks.mpy +0 -0
  83. toolkit/workspace/precompiled/IO_esp32c6.mpy +0 -0
  84. toolkit/workspace/precompiled/IO_esp32s3.mpy +0 -0
  85. toolkit/workspace/precompiled/IO_m5stamp.mpy +0 -0
  86. toolkit/workspace/precompiled/IO_qtpy.mpy +0 -0
  87. toolkit/workspace/precompiled/IO_s3matrix.mpy +0 -0
  88. toolkit/workspace/precompiled/IO_tinypico.mpy +0 -0
  89. toolkit/workspace/precompiled/InterConnect.mpy +0 -0
  90. toolkit/workspace/precompiled/Interrupts.mpy +0 -0
  91. toolkit/workspace/precompiled/LM_VL53L0X.py +1 -1
  92. toolkit/workspace/precompiled/LM_buzzer.mpy +0 -0
  93. toolkit/workspace/precompiled/LM_cct.mpy +0 -0
  94. toolkit/workspace/precompiled/LM_dashboard_be.py +2 -2
  95. toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
  96. toolkit/workspace/precompiled/LM_espnow.py +15 -10
  97. toolkit/workspace/precompiled/LM_i2c.py +3 -2
  98. toolkit/workspace/precompiled/LM_neoeffects.mpy +0 -0
  99. toolkit/workspace/precompiled/LM_neomatrix.mpy +0 -0
  100. toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
  101. toolkit/workspace/precompiled/LM_pacman.mpy +0 -0
  102. toolkit/workspace/precompiled/LM_qmi8658.py +204 -0
  103. toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
  104. toolkit/workspace/precompiled/LM_roboarm.mpy +0 -0
  105. toolkit/workspace/precompiled/LM_switch.mpy +0 -0
  106. toolkit/workspace/precompiled/LM_tcs3472.py +75 -0
  107. toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
  108. toolkit/workspace/precompiled/Logger.cpython-312.pyc +0 -0
  109. toolkit/workspace/precompiled/Logger.mpy +0 -0
  110. toolkit/workspace/precompiled/Network.mpy +0 -0
  111. toolkit/workspace/precompiled/Notify.mpy +0 -0
  112. toolkit/workspace/precompiled/Scheduler.mpy +0 -0
  113. toolkit/workspace/precompiled/Server.cpython-312.pyc +0 -0
  114. toolkit/workspace/precompiled/Server.mpy +0 -0
  115. toolkit/workspace/precompiled/Shell.mpy +0 -0
  116. toolkit/workspace/precompiled/Tasks.mpy +0 -0
  117. toolkit/workspace/precompiled/Time.mpy +0 -0
  118. toolkit/workspace/precompiled/Types.mpy +0 -0
  119. toolkit/workspace/precompiled/Web.mpy +0 -0
  120. toolkit/workspace/precompiled/micrOS.mpy +0 -0
  121. toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
  122. toolkit/workspace/precompiled/microIO.mpy +0 -0
  123. toolkit/workspace/precompiled/urequests.mpy +0 -0
  124. micrOS/micropython/esp32s3-20240105-v1.22.1.bin +0 -0
  125. micrOS/source/LM_catgame.py +0 -75
  126. micrOS/source/LM_demo.py +0 -97
  127. micrOS/source/LM_intercon.py +0 -60
  128. micrOS/source/LM_ph_sensor.py +0 -51
  129. toolkit/workspace/precompiled/LM_catgame.py +0 -75
  130. toolkit/workspace/precompiled/LM_demo.py +0 -97
  131. toolkit/workspace/precompiled/LM_intercon.mpy +0 -0
  132. toolkit/workspace/precompiled/LM_ph_sensor.py +0 -51
  133. /micrOS/micropython/{esp32s3-20241129-v1.24.1.bin → esp32s3-8MBflash-20241129-v1.24.1.bin} +0 -0
  134. /micrOS/source/{dashboard.html → web/dashboard.html} +0 -0
  135. /micrOS/source/{index.html → web/index.html} +0 -0
  136. /micrOS/source/{uapi.js → web/uapi.js} +0 -0
  137. /micrOS/source/{udashboard.js → web/udashboard.js} +0 -0
  138. /micrOS/source/{ustyle.css → web/ustyle.css} +0 -0
  139. /micrOS/source/{uwidgets.js → web/uwidgets.js} +0 -0
  140. /micrOS/source/{uwidgets_pro.js → web/uwidgets_pro.js} +0 -0
  141. {microsdevtoolkit-2.10.6.data → microsdevtoolkit-2.13.0.data}/scripts/devToolKit.py +0 -0
  142. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.13.0.dist-info}/WHEEL +0 -0
  143. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.13.0.dist-info}/licenses/LICENSE +0 -0
  144. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.13.0.dist-info}/top_level.txt +0 -0
  145. /toolkit/workspace/precompiled/{dashboard.html → web/dashboard.html} +0 -0
  146. /toolkit/workspace/precompiled/{index.html → web/index.html} +0 -0
  147. /toolkit/workspace/precompiled/{uapi.js → web/uapi.js} +0 -0
  148. /toolkit/workspace/precompiled/{udashboard.js → web/udashboard.js} +0 -0
  149. /toolkit/workspace/precompiled/{ustyle.css → web/ustyle.css} +0 -0
  150. /toolkit/workspace/precompiled/{uwidgets.js → web/uwidgets.js} +0 -0
  151. /toolkit/workspace/precompiled/{uwidgets_pro.js → web/uwidgets_pro.js} +0 -0
@@ -343,7 +343,7 @@ class VL53L0X:
343
343
 
344
344
  def measure():
345
345
  """
346
- Experimental
346
+ Experimental - Time of Flight Distance Sensor
347
347
  """
348
348
  global __TOF_OBJ
349
349
  if __TOF_OBJ is None:
Binary file
Binary file
@@ -1,4 +1,4 @@
1
- from Common import web_endpoint, syslog
1
+ from Common import web_dir, web_endpoint, syslog
2
2
 
3
3
  ENDPOINT_INITED = False
4
4
 
@@ -8,7 +8,7 @@ def load():
8
8
 
9
9
  def _dashboard_clb():
10
10
  try:
11
- with open('dashboard.html', 'r') as html:
11
+ with open(web_dir('dashboard.html'), 'r') as html:
12
12
  html_content = html.read()
13
13
  return 'text/html', html_content
14
14
  except Exception as e:
Binary file
@@ -2,10 +2,24 @@ import Espnow
2
2
 
3
3
  def load():
4
4
  """
5
- Initialize ESPNOW protocal
5
+ OBSOLETE - remove
6
+ [DEBUG ONLY] ENABLE ESPNOW IN NODE CONFIG INSTEAD OF HERE!
7
+ Initialize ESPNOW protocal
6
8
  """
7
9
  return Espnow.initialize()
8
10
 
11
+ def start_server():
12
+ """
13
+ OBSOLETE - remove
14
+ [DEBUG ONLY] ENABLE ESPNOW IN NODE CONFIG INSTEAD OF HERE!
15
+ Start ESPNOW server/listener
16
+ - this can receive espnow messages
17
+ - it includes Load Module execution logic (beta)
18
+ """
19
+ now = Espnow.initialize()
20
+ return now.start_server()
21
+
22
+
9
23
  def send(peer:bytes|str, msg:str='modules'):
10
24
  """
11
25
  Send message to peer (by mac address)
@@ -15,15 +29,6 @@ def send(peer:bytes|str, msg:str='modules'):
15
29
  now = Espnow.initialize()
16
30
  return now.send(peer, msg)
17
31
 
18
- def start_server():
19
- """
20
- Start ESPNOW server/listener
21
- - this can receive espnow messages
22
- - it includes Load Module execution logic (beta)
23
- """
24
- now = Espnow.initialize()
25
- return now.start_server()
26
-
27
32
  def stats():
28
33
  """
29
34
  Get ESPNOW stats
@@ -24,8 +24,9 @@ def discover():
24
24
  """
25
25
  Discover devices
26
26
  """
27
- known_addresses = {hex(0x0A): "trackball", hex(0x3c): "oled",
28
- hex(0x76): "bme280", hex(0x10): 'veml7700'}
27
+ known_addresses = {hex(0x0A): "TRACKBALL", hex(0x3c): "OLED",
28
+ hex(0x76): "BME280", hex(0x10): 'VEML7700',
29
+ hex(0x6b): "QMI8658"}
29
30
  devices = scan()
30
31
  output = {"unknown": []}
31
32
  for k in devices:
Binary file
@@ -0,0 +1,204 @@
1
+ """
2
+ A simple driver for the QMI8658 IMU.
3
+ https://github.com/echo-lalia/qmi8658-micropython/blob/main/qmi8685.py
4
+ """
5
+
6
+ import struct
7
+ import time
8
+ from machine import Pin, I2C
9
+ from micropython import const
10
+ from microIO import bind_pin, pinmap_search
11
+
12
+
13
+ # Sensor constants
14
+ _QMI8685_PARTID = const(0x05)
15
+ _REG_PARTID = const(0x00)
16
+ _REG_REVISION = const(0x01)
17
+
18
+ _REG_CTRL1 = const(0x02) # Serial interface and sensor enable
19
+ _REG_CTRL2 = const(0x03) # Accelerometer settings
20
+ _REG_CTRL3 = const(0x04) # Gyroscope settings
21
+ _REG_CTRL4 = const(0x05) # Magnetomer settings (support not implemented in this driver yet)
22
+ _REG_CTRL5 = const(0x06) # Sensor data processing settings
23
+ _REG_CTRL6 = const(0x07) # Attitude Engine ODR and Motion on Demand
24
+ _REG_CTRL7 = const(0x08) # Enable Sensors and Configure Data Reads
25
+
26
+ _REG_TEMP = const(0x33) # Temperature sensor.
27
+
28
+ _REG_AX_L = const(0x35) # Read accelerometer
29
+ _REG_AX_H = const(0x36)
30
+ _REG_AY_L = const(0x37)
31
+ _REG_AY_H = const(0x38)
32
+ _REG_AZ_L = const(0x39)
33
+ _REG_AZ_H = const(0x3A)
34
+
35
+ _REG_GX_L = const(0x3B) # read gyro
36
+ _REG_GX_H = const(0x3C)
37
+ _REG_GY_L = const(0x3D)
38
+ _REG_GY_H = const(0x3E)
39
+ _REG_GZ_L = const(0x3F)
40
+ _REG_GZ_H = const(0x40)
41
+
42
+ _QMI8658_I2CADDR_DEFAULT = const(0X6B)
43
+
44
+
45
+ _ACCELSCALE_RANGE_2G = const(0b00)
46
+ _ACCELSCALE_RANGE_4G = const(0b01)
47
+ _ACCELSCALE_RANGE_8G = const(0b10)
48
+ _ACCELSCALE_RANGE_16G = const(0b11)
49
+
50
+ _GYROSCALE_RANGE_16DPS = const(0b000)
51
+ _GYROSCALE_RANGE_32DPS = const(0b001)
52
+ _GYROSCALE_RANGE_64DPS = const(0b010)
53
+ _GYROSCALE_RANGE_128DPS = const(0b011)
54
+ _GYROSCALE_RANGE_256DPS = const(0b100)
55
+ _GYROSCALE_RANGE_512DPS = const(0b101)
56
+ _GYROSCALE_RANGE_1024DPS = const(0b110)
57
+ _GYROSCALE_RANGE_2048DPS = const(0b111)
58
+
59
+ _ODR_8000HZ = const(0b0000)
60
+ _ODR_4000HZ = const(0b0001)
61
+ _ODR_2000HZ = const(0b0010)
62
+ _ODR_1000HZ = const(0b0011)
63
+ _ODR_500HZ = const(0b0100)
64
+ _ODR_250HZ = const(0b0101)
65
+ _ODR_125HZ = const(0b0110)
66
+ _ODR_62_5HZ = const(0b0111)
67
+
68
+
69
+ class QMI8658:
70
+ """QMI8658 inertial measurement unit."""
71
+ INSTANCE = None
72
+
73
+ def __init__(
74
+ self,
75
+ i2c_bus: I2C,
76
+ address: int = _QMI8658_I2CADDR_DEFAULT,
77
+ accel_scale: int = _ACCELSCALE_RANGE_8G,
78
+ gyro_scale: int = _GYROSCALE_RANGE_256DPS):
79
+ """Read from a sensor on the given I2C bus, at the given address."""
80
+ self.i2c = i2c_bus
81
+ self.address = address
82
+ # Cache the sensor instance globally for easy access
83
+ QMI8658.INSTANCE = self
84
+
85
+ # Verify sensor part ID
86
+ if self._read_u8(_REG_PARTID) != _QMI8685_PARTID:
87
+ raise AttributeError("Cannot find a QMI8658")
88
+
89
+ # Setup initial configuration
90
+ self._configure_sensor(accel_scale, gyro_scale)
91
+
92
+ # Configure scales/divisors for the driver
93
+ self.acc_scale_divisor = {
94
+ _ACCELSCALE_RANGE_2G: 1 << 14,
95
+ _ACCELSCALE_RANGE_4G: 1 << 13,
96
+ _ACCELSCALE_RANGE_8G: 1 << 12,
97
+ _ACCELSCALE_RANGE_16G: 1 << 11,
98
+ }[accel_scale]
99
+
100
+ self.gyro_scale_divisor = {
101
+ _GYROSCALE_RANGE_16DPS: 2048,
102
+ _GYROSCALE_RANGE_32DPS: 1024,
103
+ _GYROSCALE_RANGE_64DPS: 512,
104
+ _GYROSCALE_RANGE_128DPS: 256,
105
+ _GYROSCALE_RANGE_256DPS: 128,
106
+ _GYROSCALE_RANGE_512DPS: 64,
107
+ _GYROSCALE_RANGE_1024DPS: 32,
108
+ _GYROSCALE_RANGE_2048DPS: 16,
109
+ }[gyro_scale]
110
+
111
+
112
+ def _configure_sensor(self, accel_scale: int, gyro_scale: int):
113
+ # Initialize accelerometer and gyroscope settings
114
+ self._write_u8(_REG_CTRL1, 0x60) # Set SPI auto increment and big endian (Ctrl 1)
115
+ self._write_u8(_REG_CTRL2, (accel_scale << 4) | _ODR_1000HZ) # Accel Config
116
+ self._write_u8(_REG_CTRL3, (gyro_scale << 4) | _ODR_1000HZ) # Gyro Config
117
+ self._write_u8(_REG_CTRL5, 0x01) # Low-pass filter enable
118
+ self._write_u8(_REG_CTRL7, 0x03) # Enable accel and gyro
119
+ time.sleep_ms(100)
120
+
121
+
122
+ # Helper functions for register operations
123
+ def _read_u8(self, reg:int) -> int:
124
+ return self.i2c.readfrom_mem(self.address, reg, 1)[0]
125
+
126
+ def _read_xyz(self, reg:int) -> tuple[int, int, int]:
127
+ data = self.i2c.readfrom_mem(self.address, reg, 6)
128
+ return struct.unpack('<hhh', data)
129
+
130
+ def _write_u8(self, reg: int, value: int):
131
+ self.i2c.writeto_mem(self.address, reg, bytes([value]))
132
+
133
+
134
+ @property
135
+ def temperature(self) -> float:
136
+ """Get the device temperature."""
137
+ temp_raw = self._read_u8(_REG_TEMP)
138
+ return temp_raw / 256
139
+
140
+ @property
141
+ def acceleration(self) -> tuple[float, float, float]:
142
+ """Get current acceleration reading."""
143
+ raw_accel = self._read_xyz(_REG_AX_L)
144
+ return tuple(val / self.acc_scale_divisor for val in raw_accel)
145
+
146
+ @property
147
+ def gyro(self) -> tuple[float, float, float]:
148
+ """Get current gyroscope reading."""
149
+ raw_gyro = self._read_xyz(_REG_GX_L)
150
+ return tuple(val / self.gyro_scale_divisor for val in raw_gyro)
151
+
152
+ #######################
153
+ # Public functions #
154
+ #######################
155
+
156
+ def load():
157
+ """
158
+ Load the QMI8658 sensor instance.
159
+ The QMI8658 is a motion sensor that measures acceleration, angular velocity (gyroscope), and temperature
160
+ """
161
+ if QMI8658.INSTANCE is None:
162
+ QMI8658(I2C(0, sda=Pin(bind_pin('i2c_sda')), scl=Pin(bind_pin('i2c_scl'))))
163
+ return QMI8658.INSTANCE
164
+
165
+
166
+ def temperature():
167
+ return load().temperature
168
+
169
+
170
+ def acceleration():
171
+ return load().acceleration
172
+
173
+
174
+ def gyro():
175
+ return load().gyro
176
+
177
+
178
+ def measure():
179
+ inst = load()
180
+ return {"temp": inst.temperature, "accel": inst.acceleration, "gyro": inst.gyro}
181
+
182
+
183
+ #######################
184
+ # LM helper functions #
185
+ #######################
186
+
187
+ def pinmap():
188
+ """
189
+ [i] micrOS LM naming convention
190
+ Shows logical pins - pin number(s) used by this Load module
191
+ - info which pins to use for this application
192
+ :return dict: pin name (str) - pin value (int) pairs
193
+ """
194
+ return pinmap_search(['i2c_scl', 'i2c_sda'])
195
+
196
+
197
+ def help(widgets=False):
198
+ """
199
+ [i] micrOS LM naming convention - built-in help message
200
+ :return tuple:
201
+ (widgets=False) list of functions implemented by this application
202
+ (widgets=True) list of widget json for UI generation
203
+ """
204
+ return 'load', 'temperature', 'acceleration', 'gyro', 'measure', 'pinmap'
Binary file
Binary file
@@ -0,0 +1,75 @@
1
+ """
2
+ A MicroPython library for the TCS3472 light sensing chip
3
+ https://github.com/tti0/tcs3472-micropython
4
+
5
+ Copyright (c) 2021 tti0
6
+ Licensed under the MIT License
7
+ """
8
+
9
+ from machine import I2C, Pin
10
+ from microIO import bind_pin, pinmap_search
11
+ import struct
12
+
13
+
14
+ class TCS3472:
15
+ INSTANCE = None
16
+
17
+ def __init__(self, bus, address=0x29):
18
+ self._bus = bus
19
+ self._i2c_address = address
20
+
21
+ self._bus.start()
22
+
23
+ self._bus.writeto(self._i2c_address, b'\x80\x03')
24
+ self._bus.writeto(self._i2c_address, b'\x81\x2b')
25
+
26
+ TCS3472.INSTANCE = self
27
+
28
+ def scaled(self):
29
+ crgb = self.raw()
30
+ if crgb[0] > 0:
31
+ return tuple(float(x) / crgb[0] for x in crgb[1:])
32
+
33
+ return (0, 0, 0)
34
+
35
+ def rgb(self):
36
+ return tuple(int(x * 255) for x in self.scaled())
37
+
38
+ def light(self):
39
+ return self.raw()[0]
40
+
41
+ def brightness(self, level=65.535):
42
+ return int((self.light() / level))
43
+
44
+ def valid(self):
45
+ self._bus.writeto(self._i2c_address, b'\x93')
46
+ return self._bus.readfrom(self._i2c_address, 1)[0] & 1
47
+
48
+ def raw(self):
49
+ self._bus.writeto(self._i2c_address, b'\xb4')
50
+ return struct.unpack("<HHHH", self._bus.readfrom(self._i2c_address, 8))
51
+
52
+
53
+ ############################ Exposed functions ############################
54
+
55
+ def load():
56
+ """
57
+ Load the TCS3472 Color sensor instance.
58
+ """
59
+ if TCS3472.INSTANCE is None:
60
+ bus = I2C(sda=Pin(bind_pin('i2c_sda')), scl=Pin(bind_pin('i2c_scl')))
61
+ TCS3472.INSTANCE = TCS3472(bus)
62
+ return TCS3472.INSTANCE
63
+
64
+
65
+ def pinmap():
66
+ return pinmap_search(['i2c_scl', 'i2c_sda'])
67
+
68
+
69
+ def measure():
70
+ sensor = load()
71
+ return {"rgb": sensor.rgb(), "light": sensor.light(), "brightness": sensor.brightness()}
72
+
73
+
74
+ def help(widgest=False):
75
+ return 'load', 'measure'
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,75 +0,0 @@
1
- from random import randint
2
- from LM_servo import sduty, deinit, pinmap as pm
3
- from utime import sleep_ms
4
- from Types import resolve
5
-
6
-
7
- def load():
8
- """
9
- Initialize catgame-servo module
10
- """
11
- return "catgame-servo module - loaded"
12
-
13
-
14
- def game(repeat=10, delta=20):
15
- """
16
- Servo cat toy "mover" - left-right
17
- :param repeat int: repeat servo pos change
18
- :param delta int: center(75) +/-delta(35)
19
- :return str: verdict
20
- """
21
- sduty(75)
22
- for _ in range(0, repeat):
23
- sduty(randint(75-delta, 75+delta))
24
- sleep_ms(randint(20, 1500))
25
- sduty(75)
26
- return 'Game action'
27
-
28
-
29
- def live_game(chance=10):
30
- """
31
- Generate game
32
- :param chance int: percent value 0-100
33
- :return str: verdict (action / no action)
34
- """
35
- action = randint(1, 10)
36
- if action <= int(chance/10):
37
- return game(repeat=5)
38
- return 'No action'
39
-
40
-
41
- def stop():
42
- """
43
- Stop game - home position (75) + deinit
44
- :return str: servo verdict
45
- """
46
- out = sduty(75)
47
- deinit()
48
- return out
49
-
50
-
51
- #######################
52
- # LM helper functions #
53
- #######################
54
-
55
- def pinmap():
56
- """
57
- [i] micrOS LM naming convention
58
- Shows logical pins - pin number(s) used by this Load module
59
- - info which pins to use for this application
60
- :return dict: pin name (str) - pin value (int) pairs
61
- """
62
- return pm()
63
-
64
-
65
- def help(widgets=False):
66
- """
67
- [i] micrOS LM naming convention - built-in help message
68
- :return tuple:
69
- (widgets=False) list of functions implemented by this application
70
- (widgets=True) list of widget json for UI generation
71
- """
72
- return resolve(('BUTTON game repeat=10',
73
- 'SLIDER live_game chance=<10-90>',
74
- 'BUTTON stop', 'pinmap',
75
- 'load'), widgets=widgets)
micrOS/source/LM_demo.py DELETED
@@ -1,97 +0,0 @@
1
- from random import randint
2
- from Time import uptime
3
- from Types import resolve
4
- from microIO import detect_platform
5
- from Common import console
6
-
7
- CNT = 0
8
-
9
-
10
- def _debug(func):
11
- """
12
- Debug wrapper
13
- - console logging
14
- - handled cmd counter (exec_info to get the value)
15
- """
16
- def __wrapper(*args, **kwargs):
17
- global CNT
18
- CNT += 1
19
- console("debug module cmd executed") # + Progress LED
20
- return func(*args, **kwargs)
21
- return __wrapper
22
-
23
-
24
- def load():
25
- """
26
- Initialize demo module
27
- """
28
- return "demo module - loaded"
29
-
30
-
31
- @_debug
32
- def hello(name="MrNobody"):
33
- return f"Hello {name}! This is a micrOS smart endpoint ☁️, running on {detect_platform()}.\
34
- \nFor more info call `demo links` function :D"
35
-
36
-
37
- @_debug
38
- def calculator(a, b, op="+"):
39
- if op.strip() == "+":
40
- return f"{a} + {b} = {a + b}"
41
- if op.strip() == "-":
42
- return f"{a} - {b} = {a - b}"
43
- if op.strip() == "/":
44
- return f"{a} / {b} = {round(a / b, 3)}"
45
- if op.strip() == "*":
46
- return f"{a} * {b} = {a * b}"
47
-
48
-
49
- @_debug
50
- def dice_cube():
51
- value = randint(1, 6)
52
- return f"🎲 {value}"
53
-
54
-
55
- @_debug
56
- def yes_no():
57
- val = randint(0, 1)
58
- return 'NO👎' if val == 0 else 'YES👍'
59
-
60
-
61
- @_debug
62
- def links():
63
- descript = f"Platform: {detect_platform()}\nGITHUB: https://github.com/BxNxM/micrOS\nYOUTUBE: https://www.youtube.com/@micrOSframework\nINSTAGRAM: https://instagram.com/micros_framework"
64
- return descript
65
-
66
-
67
- @_debug
68
- def source():
69
- return 'https://github.com/BxNxM/micrOS/blob/master/micrOS/source/LM_demo.py'
70
-
71
-
72
- @_debug
73
- def exec_info():
74
- global CNT
75
- return f"Under {uptime()}: {CNT} cmd served."
76
-
77
-
78
- @_debug
79
- def help(widgets=False):
80
- """
81
- [i] micrOS LM naming convention - built-in help message
82
- :return tuple:
83
- (widgets=False) list of functions implemented by this application
84
- (widgets=True) list of widget json for UI generation
85
- """
86
- return resolve(('hello name="MrNobody"',
87
- 'calculator a b op="+"',
88
- '\t=>op: + - / *',
89
- 'BUTTON dice_cube',
90
- 'dice_cube - show number, roll a dice',
91
- 'BUTTON yes_no',
92
- 'yes_no - show random yes/no',
93
- 'links - show micrOS links',
94
- 'source - show demo module source code',
95
- 'TEXTBOX exec_info',
96
- 'exec_info - Execution info, demo module usage',
97
- 'load'), widgets=widgets)
@@ -1,60 +0,0 @@
1
- from InterConnect import send_cmd, host_cache
2
- from Common import syslog
3
-
4
-
5
- def sendcmd(*args, **kwargs):
6
- """
7
- [!!!] OBSOLETE - NEW SYNTAX: system top >>node01.local
8
- Implements send command function towards micrOS devices
9
- example: sendcmd "hello" host="IP/hostname.local") OR sendcmd host="IP/hostname.local" cmd="system rssi")
10
- :param host[0]: host IP or Hostname
11
- :param cmd[1]: command - module func arg(s)
12
- :return str: reply
13
- """
14
- def __send(_host, _cmd):
15
- try:
16
- out = send_cmd(_host, _cmd)
17
- except Exception as e:
18
- out = []
19
- syslog(f'[intercon] sendcmd: {e}')
20
- return out
21
-
22
- host = kwargs.get('host', None)
23
- cmd = kwargs.get('cmd', None)
24
-
25
- # Host correction (lm_exec) if keyword-arg 'host' was not found
26
- if host is None:
27
- host = args[0]
28
- args = args[1:]
29
-
30
- # Cmd correction (lm_exec) if keyword-arg was not found
31
- if cmd is None:
32
- cmd = ''.join(args)
33
- return __send(host, cmd)
34
-
35
-
36
- def addr_cache():
37
- """
38
- [!!!] OBSOLETE -> new command: system hosts
39
- Dump intercon connection cache
40
- :return dict: device-ip pairs
41
- """
42
- return host_cache()
43
-
44
-
45
- #######################
46
- # LM helper functions #
47
- #######################
48
-
49
- def help(widgets=False):
50
- """
51
- [!!!] OBSOLETE
52
- [i] micrOS LM naming convention - built-in help message
53
- :return tuple:
54
- (widgets=False) list of functions implemented by this application
55
- (widgets=True) list of widget json for UI generation
56
- """
57
- return 'sendcmd "hello" host="IP/hostname.local")',\
58
- 'sendcmd host="IP/hostname.local" cmd="system rssi")',\
59
- 'example: intercon sendcmd "10.0.1.84" "system rssi" OR intercon sendcmd "system rssi" host="node01.local"', \
60
- 'addr_cache'