micrOSDevToolKit 2.1.5__py3-none-any.whl → 2.26.1__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.
Files changed (400) hide show
  1. env/driver_cp210x/.DS_Store +0 -0
  2. env/driver_cp210x/macOS_VCP_Driver/SiLabsUSBDriverDisk.dmg +0 -0
  3. env/driver_cp210x/macOS_VCP_Driver/macOS_VCP_Driver_Release_Notes.txt +17 -1
  4. micrOS/micropython/esp32-20251209-v1.27.0.bin +0 -0
  5. micrOS/micropython/esp32c3-20251209-v1.27.0.bin +0 -0
  6. micrOS/micropython/esp32c6-20251209-v1.27.0.bin +0 -0
  7. micrOS/micropython/esp32s2-20251209-v1.27.0.bin +0 -0
  8. micrOS/micropython/esp32s2-LOLIN_MINI-20251209-v1.27.0.bin +0 -0
  9. micrOS/micropython/esp32s3-4MBflash-20241129-v1.24.1.bin +0 -0
  10. micrOS/micropython/esp32s3-8MBflash-20251209-v1.27.0.bin +0 -0
  11. micrOS/micropython/esp32s3_spiram_oct-20251209-v1.27.0.bin +0 -0
  12. micrOS/micropython/rpi-pico-w-20251209-v1.27.0.uf2 +0 -0
  13. micrOS/micropython/tinypico-20251209-v1.27.0.bin +0 -0
  14. micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +191 -151
  15. micrOS/source/Auth.py +37 -0
  16. micrOS/source/Common.py +376 -102
  17. micrOS/source/Config.py +55 -25
  18. micrOS/source/Debug.py +54 -193
  19. micrOS/source/Espnow.py +404 -0
  20. micrOS/source/Files.py +207 -0
  21. micrOS/source/Hooks.py +88 -16
  22. micrOS/source/InterConnect.py +130 -46
  23. micrOS/source/Interrupts.py +8 -8
  24. micrOS/source/Logger.py +131 -0
  25. micrOS/source/Network.py +41 -21
  26. micrOS/source/Notify.py +74 -198
  27. micrOS/source/Pacman.py +326 -0
  28. micrOS/source/Scheduler.py +18 -55
  29. micrOS/source/Server.py +84 -217
  30. micrOS/source/Shell.py +103 -93
  31. micrOS/source/Tasks.py +239 -173
  32. micrOS/source/Time.py +21 -22
  33. micrOS/source/Types.py +89 -54
  34. micrOS/source/Web.py +485 -0
  35. micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
  36. micrOS/source/__pycache__/Debug.cpython-312.pyc +0 -0
  37. micrOS/source/__pycache__/Files.cpython-312.pyc +0 -0
  38. micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
  39. micrOS/source/__pycache__/Scheduler.cpython-312.pyc +0 -0
  40. micrOS/source/__pycache__/Server.cpython-312.pyc +0 -0
  41. micrOS/source/__pycache__/Shell.cpython-312.pyc +0 -0
  42. micrOS/source/__pycache__/replhelper.cpython-312.pyc +0 -0
  43. micrOS/source/helpers.py +132 -0
  44. micrOS/source/micrOS.py +25 -21
  45. micrOS/source/micrOSloader.py +14 -23
  46. micrOS/source/microIO.py +94 -57
  47. toolkit/simulator_lib/LP_darwin.py → micrOS/source/modules/IO_esp32.py +22 -11
  48. micrOS/source/{IO_esp32c3.py → modules/IO_esp32c3.py} +6 -1
  49. micrOS/source/modules/IO_esp32c6.py +38 -0
  50. micrOS/source/{IO_esp32s2.py → modules/IO_esp32s2.py} +6 -1
  51. micrOS/source/{IO_esp32s3.py → modules/IO_esp32s3.py} +43 -2
  52. micrOS/source/modules/IO_m5stamp.py +86 -0
  53. micrOS/source/{IO_qtpy.py → modules/IO_qtpy.py} +28 -18
  54. micrOS/source/{IO_tinypico.py → modules/IO_tinypico.py} +48 -3
  55. micrOS/source/modules/LM_L298N.py +161 -0
  56. {toolkit/workspace/precompiled → micrOS/source/modules}/LM_L9110_DCmotor.py +4 -4
  57. micrOS/source/{LM_OV2640.py → modules/LM_OV2640.py} +53 -42
  58. micrOS/source/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +5 -5
  59. micrOS/source/{LM_aht10.py → modules/LM_aht10.py} +12 -4
  60. micrOS/source/{LM_bme280.py → modules/LM_bme280.py} +13 -25
  61. micrOS/source/{LM_buzzer.py → modules/LM_buzzer.py} +42 -40
  62. micrOS/source/{LM_cct.py → modules/LM_cct.py} +22 -27
  63. micrOS/source/modules/LM_cluster.py +255 -0
  64. micrOS/source/{LM_co2.py → modules/LM_co2.py} +13 -6
  65. micrOS/source/{LM_dht11.py → modules/LM_dht11.py} +13 -29
  66. micrOS/source/{LM_dht22.py → modules/LM_dht22.py} +13 -28
  67. micrOS/source/{LM_dimmer.py → modules/LM_dimmer.py} +19 -16
  68. micrOS/source/modules/LM_distance.py +135 -0
  69. micrOS/source/{LM_ds18.py → modules/LM_ds18.py} +12 -4
  70. micrOS/source/{LM_esp32.py → modules/LM_esp32.py} +16 -4
  71. micrOS/source/modules/LM_espnow.py +53 -0
  72. micrOS/source/modules/LM_fileserver.py +265 -0
  73. micrOS/source/{LM_gameOfLife.py → modules/LM_gameOfLife.py} +5 -5
  74. micrOS/source/{LM_genIO.py → modules/LM_genIO.py} +49 -35
  75. micrOS/source/modules/LM_haptic.py +111 -0
  76. micrOS/source/modules/LM_i2c.py +61 -0
  77. micrOS/source/{LM_i2s_mic.py → modules/LM_i2s_mic.py} +20 -23
  78. micrOS/source/{LM_ld2410.py → modules/LM_ld2410.py} +3 -3
  79. micrOS/source/{LM_light_sensor.py → modules/LM_light_sensor.py} +22 -26
  80. micrOS/source/modules/LM_mh_z19c.py +198 -0
  81. micrOS/source/modules/LM_neoeffects.py +284 -0
  82. micrOS/source/{LM_neopixel.py → modules/LM_neopixel.py} +26 -31
  83. micrOS/source/{LM_oled.py → modules/LM_oled.py} +28 -20
  84. micrOS/source/{LM_oled_sh1106.py → modules/LM_oled_sh1106.py} +28 -24
  85. micrOS/source/{LM_oled_ui.py → modules/LM_oled_ui.py} +132 -174
  86. micrOS/source/modules/LM_pacman.py +320 -0
  87. micrOS/source/{LM_presence.py → modules/LM_presence.py} +24 -36
  88. micrOS/source/modules/LM_qmi8658.py +204 -0
  89. micrOS/source/{LM_rencoder.py → modules/LM_rencoder.py} +40 -11
  90. micrOS/source/modules/LM_rest.py +81 -0
  91. micrOS/source/{LM_rgb.py → modules/LM_rgb.py} +25 -34
  92. micrOS/source/{LM_rgbcct.py → modules/LM_rgbcct.py} +5 -5
  93. micrOS/source/{LM_roboarm.py → modules/LM_roboarm.py} +37 -45
  94. micrOS/source/modules/LM_robustness.py +137 -0
  95. micrOS/source/{LM_rp2w.py → modules/LM_rp2w.py} +3 -0
  96. micrOS/source/{LM_sdcard.py → modules/LM_sdcard.py} +3 -0
  97. micrOS/source/{LM_servo.py → modules/LM_servo.py} +4 -4
  98. micrOS/source/modules/LM_sound_event.py +751 -0
  99. micrOS/source/{LM_stepper.py → modules/LM_stepper.py} +8 -8
  100. micrOS/source/{LM_switch.py → modules/LM_switch.py} +21 -18
  101. micrOS/source/{LM_system.py → modules/LM_system.py} +96 -59
  102. micrOS/source/modules/LM_tcs3472.py +187 -0
  103. micrOS/source/modules/LM_telegram.py +388 -0
  104. micrOS/source/modules/LM_trackball.py +287 -0
  105. micrOS/source/modules/LM_veml7700.py +159 -0
  106. micrOS/source/modules/LM_web.py +38 -0
  107. micrOS/source/urequests.py +204 -91
  108. {toolkit/workspace/precompiled → micrOS/source/web}/dashboard.html +9 -4
  109. micrOS/source/web/editor.js +440 -0
  110. micrOS/source/web/filesui.html +178 -0
  111. micrOS/source/web/filesui.js +338 -0
  112. micrOS/source/{index.html → web/index.html} +44 -2
  113. micrOS/source/web/uapi.js +103 -0
  114. micrOS/source/web/udashboard.js +129 -0
  115. micrOS/source/web/ustyle.css +55 -0
  116. micrOS/source/web/uwidgets.js +172 -0
  117. micrOS/source/web/uwidgets_pro.js +99 -0
  118. micrOS/utests/__init__.py +0 -0
  119. micrOS/utests/test_scheduler.py +435 -0
  120. {micrOSDevToolKit-2.1.5.data → microsdevtoolkit-2.26.1.data}/scripts/devToolKit.py +47 -4
  121. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/METADATA +392 -279
  122. microsdevtoolkit-2.26.1.dist-info/RECORD +396 -0
  123. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/WHEEL +1 -1
  124. toolkit/DevEnvCompile.py +63 -33
  125. toolkit/DevEnvOTA.py +72 -22
  126. toolkit/DevEnvUSB.py +147 -77
  127. toolkit/Gateway.py +9 -9
  128. toolkit/LM_to_compile.dat +12 -4
  129. toolkit/MicrOSDevEnv.py +129 -51
  130. toolkit/WebRepl.py +73 -0
  131. toolkit/dashboard_apps/BackupRestore.py +171 -0
  132. toolkit/dashboard_apps/CCTDemo.py +12 -17
  133. toolkit/dashboard_apps/CCTTest.py +20 -24
  134. toolkit/dashboard_apps/CamStream.py +2 -6
  135. toolkit/dashboard_apps/CatGame.py +14 -16
  136. toolkit/dashboard_apps/Dimmer.py +11 -21
  137. toolkit/dashboard_apps/GetVersion.py +11 -19
  138. toolkit/dashboard_apps/MicrophoneTest.py +2 -7
  139. toolkit/dashboard_apps/NeoEffectsDemo.py +22 -35
  140. toolkit/dashboard_apps/NeopixelTest.py +20 -25
  141. toolkit/dashboard_apps/PresenceTest.py +2 -8
  142. toolkit/dashboard_apps/QMI8685_GYRO.py +68 -0
  143. toolkit/dashboard_apps/RGBTest.py +20 -24
  144. toolkit/dashboard_apps/RoboArm.py +24 -32
  145. toolkit/dashboard_apps/SED_test.py +10 -14
  146. toolkit/dashboard_apps/SensorsTest.py +61 -0
  147. toolkit/dashboard_apps/SystemTest.py +219 -117
  148. toolkit/dashboard_apps/Template_app.py +12 -19
  149. toolkit/dashboard_apps/_app_base.py +34 -0
  150. toolkit/dashboard_apps/_gyro_visualizer.py +78 -0
  151. toolkit/dashboard_apps/uLightDemo.py +15 -24
  152. toolkit/index.html +6 -5
  153. toolkit/lib/LocalMachine.py +6 -1
  154. toolkit/lib/MicrosFiles.py +46 -0
  155. toolkit/lib/Repository.py +64 -0
  156. toolkit/lib/TerminalColors.py +4 -0
  157. toolkit/lib/macroScript.py +371 -0
  158. toolkit/lib/micrOSClient.py +124 -51
  159. toolkit/lib/micrOSClientHistory.py +156 -0
  160. toolkit/lib/pip_package_installer.py +31 -4
  161. toolkit/micrOSdashboard.py +16 -21
  162. toolkit/micrOSlint.py +28 -10
  163. toolkit/simulator_lib/.DS_Store +0 -0
  164. micrOS/source/IO_esp32.py → toolkit/simulator_lib/IO_darwin.py +3 -0
  165. toolkit/simulator_lib/__pycache__/IO_darwin.cpython-312.pyc +0 -0
  166. toolkit/simulator_lib/__pycache__/aioespnow.cpython-312.pyc +0 -0
  167. toolkit/simulator_lib/__pycache__/camera.cpython-312.pyc +0 -0
  168. toolkit/simulator_lib/__pycache__/framebuf.cpython-312.pyc +0 -0
  169. toolkit/simulator_lib/__pycache__/machine.cpython-312.pyc +0 -0
  170. toolkit/simulator_lib/__pycache__/micropython.cpython-312.pyc +0 -0
  171. toolkit/simulator_lib/__pycache__/mip.cpython-312.pyc +0 -0
  172. toolkit/simulator_lib/__pycache__/neopixel.cpython-312.pyc +0 -0
  173. toolkit/simulator_lib/__pycache__/network.cpython-312.pyc +0 -0
  174. toolkit/simulator_lib/__pycache__/sim_common.cpython-312.pyc +0 -0
  175. toolkit/simulator_lib/__pycache__/simgc.cpython-312.pyc +0 -0
  176. toolkit/simulator_lib/__pycache__/simulator.cpython-312.pyc +0 -0
  177. toolkit/simulator_lib/__pycache__/uasyncio.cpython-312.pyc +0 -0
  178. toolkit/simulator_lib/__pycache__/uos.cpython-312.pyc +0 -0
  179. toolkit/simulator_lib/__pycache__/urandom.cpython-312.pyc +0 -0
  180. toolkit/simulator_lib/__pycache__/usocket.cpython-312.pyc +0 -0
  181. toolkit/simulator_lib/__pycache__/ussl.cpython-312.pyc +0 -0
  182. toolkit/simulator_lib/aioespnow.py +28 -0
  183. toolkit/simulator_lib/camera.py +84 -0
  184. toolkit/simulator_lib/dht.py +1 -1
  185. toolkit/simulator_lib/framebuf.py +49 -1
  186. toolkit/simulator_lib/machine.py +32 -2
  187. toolkit/simulator_lib/micropython.py +3 -3
  188. toolkit/simulator_lib/mip.py +165 -0
  189. toolkit/simulator_lib/neopixel.py +3 -2
  190. toolkit/simulator_lib/network.py +2 -1
  191. toolkit/simulator_lib/node_config.json +2 -3
  192. toolkit/simulator_lib/ntptime.py +1 -1
  193. toolkit/simulator_lib/{sim_console.py → sim_common.py} +2 -3
  194. toolkit/simulator_lib/simgc.py +6 -2
  195. toolkit/simulator_lib/simulator.py +138 -46
  196. toolkit/simulator_lib/uasyncio.py +34 -3
  197. toolkit/simulator_lib/uos.py +147 -0
  198. toolkit/simulator_lib/urandom.py +4 -0
  199. toolkit/simulator_lib/usocket.py +5 -1
  200. toolkit/simulator_lib/view01.jpg +0 -0
  201. toolkit/simulator_lib/view02.jpg +0 -0
  202. toolkit/socketClient.py +43 -23
  203. toolkit/user_data/webhooks/generic.py +1 -1
  204. toolkit/user_data/webhooks/macro.py +44 -0
  205. toolkit/user_data/webhooks/template.macro +20 -0
  206. toolkit/user_data/webhooks/template.py +1 -1
  207. toolkit/workspace/precompiled/Auth.mpy +0 -0
  208. toolkit/workspace/precompiled/Common.mpy +0 -0
  209. toolkit/workspace/precompiled/Config.mpy +0 -0
  210. toolkit/workspace/precompiled/Debug.mpy +0 -0
  211. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  212. toolkit/workspace/precompiled/Files.mpy +0 -0
  213. toolkit/workspace/precompiled/Hooks.mpy +0 -0
  214. toolkit/workspace/precompiled/InterConnect.mpy +0 -0
  215. toolkit/workspace/precompiled/Interrupts.mpy +0 -0
  216. toolkit/workspace/precompiled/Logger.mpy +0 -0
  217. toolkit/workspace/precompiled/Network.mpy +0 -0
  218. toolkit/workspace/precompiled/Notify.mpy +0 -0
  219. toolkit/workspace/precompiled/Pacman.mpy +0 -0
  220. toolkit/workspace/precompiled/Scheduler.mpy +0 -0
  221. toolkit/workspace/precompiled/Server.mpy +0 -0
  222. toolkit/workspace/precompiled/Shell.mpy +0 -0
  223. toolkit/workspace/precompiled/Tasks.mpy +0 -0
  224. toolkit/workspace/precompiled/Time.mpy +0 -0
  225. toolkit/workspace/precompiled/Types.mpy +0 -0
  226. toolkit/workspace/precompiled/Web.mpy +0 -0
  227. toolkit/workspace/precompiled/_mpy.version +1 -1
  228. toolkit/workspace/precompiled/config/_git.keep +0 -0
  229. toolkit/workspace/precompiled/helpers.mpy +0 -0
  230. toolkit/workspace/precompiled/micrOS.mpy +0 -0
  231. toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
  232. toolkit/workspace/precompiled/microIO.mpy +0 -0
  233. toolkit/workspace/precompiled/modules/IO_esp32.mpy +0 -0
  234. toolkit/workspace/precompiled/modules/IO_esp32c3.mpy +0 -0
  235. toolkit/workspace/precompiled/modules/IO_esp32c6.mpy +0 -0
  236. toolkit/workspace/precompiled/modules/IO_esp32s2.mpy +0 -0
  237. toolkit/workspace/precompiled/modules/IO_esp32s3.mpy +0 -0
  238. toolkit/workspace/precompiled/modules/IO_m5stamp.mpy +0 -0
  239. toolkit/workspace/precompiled/modules/IO_qtpy.mpy +0 -0
  240. toolkit/workspace/precompiled/modules/IO_rp2.mpy +0 -0
  241. toolkit/workspace/precompiled/modules/IO_tinypico.mpy +0 -0
  242. toolkit/workspace/precompiled/modules/LM_L298N.mpy +0 -0
  243. {micrOS/source → toolkit/workspace/precompiled/modules}/LM_L9110_DCmotor.py +4 -4
  244. toolkit/workspace/precompiled/modules/LM_OV2640.mpy +0 -0
  245. toolkit/workspace/precompiled/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +5 -5
  246. toolkit/workspace/precompiled/modules/LM_aht10.mpy +0 -0
  247. toolkit/workspace/precompiled/modules/LM_bme280.mpy +0 -0
  248. toolkit/workspace/precompiled/{LM_buzzer.mpy → modules/LM_buzzer.mpy} +0 -0
  249. toolkit/workspace/precompiled/modules/LM_cct.mpy +0 -0
  250. toolkit/workspace/precompiled/modules/LM_cluster.mpy +0 -0
  251. toolkit/workspace/precompiled/modules/LM_co2.mpy +0 -0
  252. toolkit/workspace/precompiled/modules/LM_dht11.mpy +0 -0
  253. toolkit/workspace/precompiled/modules/LM_dht22.mpy +0 -0
  254. toolkit/workspace/precompiled/modules/LM_dimmer.mpy +0 -0
  255. toolkit/workspace/precompiled/modules/LM_distance.mpy +0 -0
  256. toolkit/workspace/precompiled/modules/LM_ds18.mpy +0 -0
  257. toolkit/workspace/precompiled/{LM_esp32.py → modules/LM_esp32.py} +16 -4
  258. toolkit/workspace/precompiled/modules/LM_espnow.py +53 -0
  259. toolkit/workspace/precompiled/modules/LM_fileserver.mpy +0 -0
  260. toolkit/workspace/precompiled/{LM_gameOfLife.mpy → modules/LM_gameOfLife.mpy} +0 -0
  261. toolkit/workspace/precompiled/modules/LM_genIO.mpy +0 -0
  262. toolkit/workspace/precompiled/modules/LM_haptic.mpy +0 -0
  263. toolkit/workspace/precompiled/modules/LM_i2c.py +61 -0
  264. toolkit/workspace/precompiled/modules/LM_i2s_mic.mpy +0 -0
  265. toolkit/workspace/precompiled/{LM_ld2410.mpy → modules/LM_ld2410.mpy} +0 -0
  266. toolkit/workspace/precompiled/modules/LM_light_sensor.mpy +0 -0
  267. toolkit/workspace/precompiled/modules/LM_mh_z19c.py +198 -0
  268. toolkit/workspace/precompiled/modules/LM_neoeffects.mpy +0 -0
  269. toolkit/workspace/precompiled/modules/LM_neopixel.mpy +0 -0
  270. toolkit/workspace/precompiled/modules/LM_oled.mpy +0 -0
  271. toolkit/workspace/precompiled/modules/LM_oled_sh1106.mpy +0 -0
  272. toolkit/workspace/precompiled/modules/LM_oled_ui.mpy +0 -0
  273. toolkit/workspace/precompiled/modules/LM_pacman.mpy +0 -0
  274. toolkit/workspace/precompiled/modules/LM_presence.mpy +0 -0
  275. toolkit/workspace/precompiled/modules/LM_qmi8658.py +204 -0
  276. toolkit/workspace/precompiled/{LM_rencoder.py → modules/LM_rencoder.py} +40 -11
  277. toolkit/workspace/precompiled/modules/LM_rest.mpy +0 -0
  278. toolkit/workspace/precompiled/modules/LM_rgb.mpy +0 -0
  279. toolkit/workspace/precompiled/{LM_rgbcct.mpy → modules/LM_rgbcct.mpy} +0 -0
  280. toolkit/workspace/precompiled/modules/LM_roboarm.mpy +0 -0
  281. toolkit/workspace/precompiled/modules/LM_robustness.py +137 -0
  282. toolkit/workspace/precompiled/{LM_rp2w.py → modules/LM_rp2w.py} +3 -0
  283. toolkit/workspace/precompiled/{LM_sdcard.py → modules/LM_sdcard.py} +3 -0
  284. toolkit/workspace/precompiled/{LM_servo.mpy → modules/LM_servo.mpy} +0 -0
  285. toolkit/workspace/precompiled/modules/LM_sound_event.mpy +0 -0
  286. toolkit/workspace/precompiled/{LM_stepper.mpy → modules/LM_stepper.mpy} +0 -0
  287. toolkit/workspace/precompiled/modules/LM_switch.mpy +0 -0
  288. toolkit/workspace/precompiled/modules/LM_system.mpy +0 -0
  289. toolkit/workspace/precompiled/modules/LM_tcs3472.py +187 -0
  290. toolkit/workspace/precompiled/modules/LM_telegram.mpy +0 -0
  291. toolkit/workspace/precompiled/{LM_tinyrgb.mpy → modules/LM_tinyrgb.mpy} +0 -0
  292. toolkit/workspace/precompiled/modules/LM_trackball.mpy +0 -0
  293. toolkit/workspace/precompiled/modules/LM_veml7700.mpy +0 -0
  294. toolkit/workspace/precompiled/modules/LM_web.mpy +0 -0
  295. toolkit/workspace/precompiled/urequests.mpy +0 -0
  296. {micrOS/source → toolkit/workspace/precompiled/web}/dashboard.html +9 -4
  297. toolkit/workspace/precompiled/web/editor.js +440 -0
  298. toolkit/workspace/precompiled/web/filesui.html +178 -0
  299. toolkit/workspace/precompiled/web/filesui.js +338 -0
  300. toolkit/workspace/precompiled/{index.html → web/index.html} +44 -2
  301. toolkit/workspace/precompiled/web/uapi.js +103 -0
  302. toolkit/workspace/precompiled/web/udashboard.js +129 -0
  303. toolkit/workspace/precompiled/web/ustyle.css +55 -0
  304. toolkit/workspace/precompiled/web/uwidgets.js +172 -0
  305. toolkit/workspace/precompiled/web/uwidgets_pro.js +99 -0
  306. env/driver_cp210x/CH34XSER_MAC/CH34X_DRV_INSTALL_INSTRUCTIONS.pdf +0 -0
  307. env/driver_cp210x/CH34XSER_MAC/CH34xVCPDriver.pkg +0 -0
  308. micrOS/micropython/esp32-20231005-v1.21.0.bin +0 -0
  309. micrOS/micropython/esp32c3-GENERIC-20240105-v1.22.1.bin +0 -0
  310. micrOS/micropython/esp32c3-GENERIC-20240222-v1.22.2.bin +0 -0
  311. micrOS/micropython/esp32s2-GENERIC-20240105-v1.22.1.bin +0 -0
  312. micrOS/micropython/esp32s2-LOLIN_MINI-20220618-v1.19.1.bin +0 -0
  313. micrOS/micropython/esp32s3-GENERIC-20240105-v1.22.1.bin +0 -0
  314. micrOS/micropython/esp32s3_spiram_oct-20231005-v1.21.0.bin +0 -0
  315. micrOS/micropython/rpi-pico-w-20231005-v1.21.0.uf2 +0 -0
  316. micrOS/micropython/tinypico-20231005-v1.21.0.bin +0 -0
  317. micrOS/micropython/tinypico-usbc-UM-20240105-v1.22.1.bin +0 -0
  318. micrOS/source/LM_L298N_DCmotor.py +0 -86
  319. micrOS/source/LM_catgame.py +0 -74
  320. micrOS/source/LM_dashboard_be.py +0 -37
  321. micrOS/source/LM_demo.py +0 -85
  322. micrOS/source/LM_distance.py +0 -88
  323. micrOS/source/LM_i2c.py +0 -44
  324. micrOS/source/LM_intercon.py +0 -57
  325. micrOS/source/LM_keychain.py +0 -318
  326. micrOS/source/LM_lmpacman.py +0 -126
  327. micrOS/source/LM_neoeffects.py +0 -327
  328. micrOS/source/LM_pet_feeder.py +0 -76
  329. micrOS/source/LM_ph_sensor.py +0 -51
  330. micrOS/source/LM_rest.py +0 -40
  331. micrOS/source/LM_robustness.py +0 -73
  332. micrOS/source/LM_telegram.py +0 -96
  333. micrOS/source/reset.py +0 -11
  334. micrOS/source/uapi.js +0 -76
  335. micrOS/source/udashboard.js +0 -137
  336. micrOS/source/ustyle.css +0 -28
  337. micrOS/source/uwidgets.js +0 -179
  338. micrOSDevToolKit-2.1.5.dist-info/RECORD +0 -337
  339. toolkit/dashboard_apps/AirQualityBME280.py +0 -36
  340. toolkit/dashboard_apps/AirQualityDHT22_CO2.py +0 -36
  341. toolkit/lib/file_extensions.py +0 -16
  342. toolkit/simulator_lib/__pycache__/LP_darwin.cpython-312.pyc +0 -0
  343. toolkit/simulator_lib/__pycache__/LP_darwin.cpython-38.pyc +0 -0
  344. toolkit/simulator_lib/__pycache__/LP_darwin.cpython-39.pyc +0 -0
  345. toolkit/simulator_lib/__pycache__/sim_console.cpython-312.pyc +0 -0
  346. toolkit/simulator_lib/__pycache__/sim_console.cpython-38.pyc +0 -0
  347. toolkit/simulator_lib/__pycache__/sim_console.cpython-39.pyc +0 -0
  348. toolkit/workspace/precompiled/IO_esp32.mpy +0 -0
  349. toolkit/workspace/precompiled/IO_esp32c3.mpy +0 -0
  350. toolkit/workspace/precompiled/IO_esp32s2.mpy +0 -0
  351. toolkit/workspace/precompiled/IO_esp32s3.mpy +0 -0
  352. toolkit/workspace/precompiled/IO_qtpy.mpy +0 -0
  353. toolkit/workspace/precompiled/IO_rp2.mpy +0 -0
  354. toolkit/workspace/precompiled/IO_tinypico.mpy +0 -0
  355. toolkit/workspace/precompiled/LM_L298N_DCmotor.mpy +0 -0
  356. toolkit/workspace/precompiled/LM_OV2640.mpy +0 -0
  357. toolkit/workspace/precompiled/LM_aht10.mpy +0 -0
  358. toolkit/workspace/precompiled/LM_bme280.mpy +0 -0
  359. toolkit/workspace/precompiled/LM_catgame.py +0 -74
  360. toolkit/workspace/precompiled/LM_cct.mpy +0 -0
  361. toolkit/workspace/precompiled/LM_co2.mpy +0 -0
  362. toolkit/workspace/precompiled/LM_dashboard_be.py +0 -37
  363. toolkit/workspace/precompiled/LM_demo.py +0 -85
  364. toolkit/workspace/precompiled/LM_dht11.mpy +0 -0
  365. toolkit/workspace/precompiled/LM_dht22.mpy +0 -0
  366. toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
  367. toolkit/workspace/precompiled/LM_distance.py +0 -88
  368. toolkit/workspace/precompiled/LM_ds18.mpy +0 -0
  369. toolkit/workspace/precompiled/LM_genIO.mpy +0 -0
  370. toolkit/workspace/precompiled/LM_i2c.py +0 -44
  371. toolkit/workspace/precompiled/LM_i2s_mic.mpy +0 -0
  372. toolkit/workspace/precompiled/LM_intercon.mpy +0 -0
  373. toolkit/workspace/precompiled/LM_keychain.mpy +0 -0
  374. toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
  375. toolkit/workspace/precompiled/LM_lmpacman.mpy +0 -0
  376. toolkit/workspace/precompiled/LM_neoeffects.mpy +0 -0
  377. toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
  378. toolkit/workspace/precompiled/LM_oled.mpy +0 -0
  379. toolkit/workspace/precompiled/LM_oled_sh1106.mpy +0 -0
  380. toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
  381. toolkit/workspace/precompiled/LM_pet_feeder.py +0 -76
  382. toolkit/workspace/precompiled/LM_ph_sensor.py +0 -51
  383. toolkit/workspace/precompiled/LM_presence.mpy +0 -0
  384. toolkit/workspace/precompiled/LM_rest.mpy +0 -0
  385. toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
  386. toolkit/workspace/precompiled/LM_roboarm.mpy +0 -0
  387. toolkit/workspace/precompiled/LM_robustness.py +0 -73
  388. toolkit/workspace/precompiled/LM_switch.mpy +0 -0
  389. toolkit/workspace/precompiled/LM_system.mpy +0 -0
  390. toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
  391. toolkit/workspace/precompiled/reset.mpy +0 -0
  392. toolkit/workspace/precompiled/uapi.js +0 -76
  393. toolkit/workspace/precompiled/udashboard.js +0 -137
  394. toolkit/workspace/precompiled/ustyle.css +0 -28
  395. toolkit/workspace/precompiled/uwidgets.js +0 -179
  396. /toolkit/user_data/node_config_archive/.include → /micrOS/source/config/_git.keep +0 -0
  397. /micrOS/source/{IO_rp2.py → modules/IO_rp2.py} +0 -0
  398. /micrOS/source/{LM_tinyrgb.py → modules/LM_tinyrgb.py} +0 -0
  399. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info/licenses}/LICENSE +0 -0
  400. {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,320 @@
1
+ from sys import modules
2
+ from Common import socket_stream
3
+ from Files import list_fs, ilist_fs, remove_file, remove_dir, OSPath, path_join, is_protected
4
+ from Auth import sudo
5
+
6
+
7
+ #############################################
8
+ # Safe file system handler functions #
9
+ #############################################
10
+
11
+ def ls(path="/", content='*', raw=False, select='*', core=False):
12
+ """
13
+ Linux like ls command - list app resources and app folders
14
+ :param path: path to list, default: /
15
+ :param content: content type, default all, f-file, d-dir can be selected
16
+ :param raw: keep raw output [(is_app, type), ...]
17
+ :param select: select specific app resource: LM or IO, default: all
18
+ :param core: include core system files
19
+ """
20
+ items = list_fs(path, content, select=select, core=core)
21
+ if raw:
22
+ return items
23
+
24
+ # Build a formatted output (just like `ls -l` style index)
25
+ lines = ""
26
+ for i, f in enumerate(items):
27
+ spacer = " " * (4 - len(str(i+1)))
28
+ if content == "*":
29
+ lines += f"{i+1}{spacer}{f[0]} {f[1]}\n"
30
+ else:
31
+ lines += f"{i + 1}{spacer}{f}\n"
32
+ return lines
33
+
34
+
35
+ @sudo(_force_only=(True, 1))
36
+ def rm(path, force=False):
37
+ """
38
+ Linux like rm command - delete app resources and folders
39
+ :param path: app resource name/path, ex.: LM_robustness.py
40
+ :param force: bypasses protection check - sudo mode
41
+ """
42
+ return remove_file(path, force)
43
+
44
+
45
+ @sudo(_force_only=(True, 1))
46
+ def rmdir(path, force=False):
47
+ """
48
+ Linux like rmdir command for directory deletion
49
+ :param path: app resource folder path, ex.: /lib/myapp
50
+ :param force: bypasses protection check - sudo mode
51
+ """
52
+ return remove_dir(path, force)
53
+
54
+
55
+ def dirtree(path="/", raw=False, core=False):
56
+ """Return only directories from a given path."""
57
+ path = path if path.endswith('/') else f"{path}/"
58
+ folders = [path_join(path, item) for item in ilist_fs(path, type_filter='d', core=core)]
59
+ folder_contents = {folder:list_fs(folder) for folder in folders}
60
+ if raw:
61
+ return folder_contents
62
+ formatted_output = ""
63
+ for k, v in folder_contents.items():
64
+ formatted_output += f"{k}\n"
65
+ for val in v:
66
+ formatted_output += f"\t{val[0]} {val[1]}\n"
67
+ return formatted_output
68
+
69
+
70
+ def cat(path):
71
+ """
72
+ Dump any file content
73
+ """
74
+ if is_protected(path):
75
+ return f'Read not allowed'
76
+ with open(path, 'r') as f:
77
+ content = f.read()
78
+ return content
79
+
80
+
81
+ def install(ref=None):
82
+ """
83
+ Unified mip-based installer for micrOS.
84
+ Automatically detects:
85
+ 1. Official MicroPython packages (from https://micropython.org/pi/v2)
86
+ Example: pacman install "umqtt.simple"
87
+ 2. Single-file load modules (LM_/IO_ names or URLs)
88
+ Example: pacman install "https://github.com/BxNxM/micrOS/blob/master/toolkit/workspace/precompiled/modules/LM_rgb.mpy"
89
+ pacman install "github.com/BxNxM/micrOS/blob/master/toolkit/workspace/precompiled/modules/LM_rgb.mpy"
90
+ 3. GitHub packages (folders via tree/blob URLs or github: form)
91
+ Example: pacman install "github:peterhinch/micropython-mqtt"
92
+ pacman install "https://github.com/peterhinch/micropython-mqtt/tree/master"
93
+ pacman install "https://github.com/peterhinch/micropython-mqtt/blob/master/package.json"
94
+ pacman install "https://github.com/peterhinch/micropython-mqtt"
95
+ [NOK] pacman install "https://github.com/basanovase/sim7600/tree/main/sim7600" -> Package not found: github:basanovase/sim7600/package.json
96
+ 4. Install from local /config/requirements.txt file
97
+ Example: pacman install "requirements.txt"
98
+ """
99
+ from Pacman import install as pm_install
100
+ return pm_install(ref)
101
+
102
+
103
+ @sudo
104
+ def uninstall(name=None):
105
+ """
106
+ Delete package by name from /lib
107
+ :param name: None (default) show installed package name
108
+ OR package name to delete (str)
109
+ """
110
+ if name is None:
111
+ return list_fs(path=OSPath.LIB, type_filter='d')
112
+ from Pacman import uninstall as pm_uninstall
113
+ return pm_uninstall(name)
114
+
115
+
116
+ def upgrade(name=None, force=False):
117
+ """
118
+ Upgrade package by name from /lib
119
+ :param name: None (default) show installed package name
120
+ OR package name to upgrade (str)
121
+ :param force: skip version check
122
+ """
123
+ if name is None:
124
+ return list_fs(path=OSPath.LIB, type_filter='d')
125
+ from Pacman import upgrade as pm_upgrade
126
+ return pm_upgrade(name, force)
127
+
128
+
129
+ def del_duplicates(migrate=True):
130
+ """
131
+ Load module package manager (Not just load modules)
132
+ - delete duplicated .mpy and .py resources, keep .mpy resource!
133
+ """
134
+ modules_path = OSPath.MODULES
135
+ msg_buf = []
136
+ files = list_fs(path=modules_path, type_filter='f', select='LM')
137
+ py = list((res.split('.')[0] for res in files if res.endswith('.py'))) # Normally smaller list
138
+ mpy = (res.split('.')[0] for res in files if res.endswith('.mpy'))
139
+ for m in mpy:
140
+ # Iterate over mpy resources
141
+ state = True
142
+ if m in py and m != 'main':
143
+ to_delete = f'{m}.py'
144
+ try:
145
+ verdict = remove_file(path_join(modules_path, to_delete))
146
+ except:
147
+ verdict = "n/a"
148
+ state = False
149
+ msg_buf.append(f' Delete {to_delete} {state} - {verdict}')
150
+
151
+
152
+ # MIGRATE /ROOT/LMs & IOs -> /modules
153
+ def _migrate_from_root(_rf):
154
+ nonlocal _deleted, files
155
+ if _rf in files:
156
+ remove_file(path_join(OSPath._ROOT, _rf))
157
+ if _rf in ("LM_pacman.mpy", "LM_system.mpy"):
158
+ # Delete protected LMs from root
159
+ remove(path_join(OSPath._ROOT, _rf))
160
+ _deleted += 1
161
+ else:
162
+ rename(path_join(OSPath._ROOT, _rf), path_join(modules_path, _rf))
163
+ msg_buf.append(f' Move /{_rf} -> modules/{_rf}')
164
+ if migrate:
165
+ from uos import rename, remove
166
+ _deleted = 0
167
+ files = files + list_fs(path=OSPath._ROOT, type_filter='f', select='IO')
168
+ for rf in ilist_fs(path=OSPath._ROOT, type_filter='f', select='LM'):
169
+ _migrate_from_root(rf)
170
+ for rf in ilist_fs(path=OSPath._ROOT, type_filter='f', select='IO'):
171
+ _migrate_from_root(rf)
172
+ if _deleted > 0:
173
+ msg_buf.append(f' Purged (/): {_deleted}')
174
+
175
+ return '\n'.join(msg_buf) if len(msg_buf) > 0 else 'Nothing to delete.'
176
+
177
+
178
+ def moduls(unload=None):
179
+ """
180
+ List / unload loaded upython Load Modules
181
+ :param unload: module name to unload
182
+ :param unload: None - list active modules
183
+ :return str: verdict
184
+ """
185
+ if unload is None:
186
+ return list(modules.keys())
187
+ if unload in modules.keys():
188
+ del modules[unload]
189
+ return f"Module unload {unload} done."
190
+ return f"Module unload {unload} failed."
191
+
192
+
193
+ @socket_stream
194
+ def cachedump(delete=None, ext="cache", msgobj=None):
195
+ """
196
+ Cache system persistent data storage files (.cache)
197
+ :param delete: cache name to delete
198
+ :param ext: cache file extension (default: cache)
199
+ """
200
+ data_dir = OSPath.DATA
201
+ if delete is None:
202
+ # List cache files aka application cache
203
+ msg_buf = []
204
+ for cache in (c for c in ilist_fs(data_dir, type_filter='f') if c.endswith('.cache')):
205
+ _path = path_join(data_dir, cache)
206
+ with open(_path, 'r') as f:
207
+ if msgobj is None:
208
+ msg_buf.append(f'{_path}: {f.read()}')
209
+ else:
210
+ msgobj(f'{_path}: {f.read()}')
211
+ return msg_buf if len(msg_buf) > 0 else ''
212
+ # Remove given cache file
213
+ try:
214
+ delete_cache = path_join(data_dir, f"{delete}.cache")
215
+ verdict = remove_file(delete_cache)
216
+ return f'{delete_cache} delete done.: {verdict}'
217
+ except:
218
+ return f'{delete}.{ext} not exists'
219
+
220
+
221
+ def datdump():
222
+ """
223
+ Generic .dat file dump
224
+ - logged data from LMs, sensor data, etc...
225
+ """
226
+ data_dir = OSPath.DATA
227
+ dats = (f for f in ilist_fs(data_dir, type_filter='f') if f.endswith('.dat'))
228
+ out = {}
229
+ for dat in dats:
230
+ with open(path_join(data_dir, dat), 'r') as f:
231
+ out[dat] = f.read()
232
+ return out
233
+
234
+
235
+ def makedir(path):
236
+ """
237
+ Create directory command
238
+ """
239
+ from uos import mkdir
240
+ try:
241
+ mkdir(path)
242
+ return f"{path} dir created."
243
+ except Exception as e:
244
+ return f"{path} failed to create: {e}"
245
+
246
+ #############################################
247
+ # Legacy features #
248
+ #############################################
249
+
250
+
251
+ @socket_stream
252
+ def listmods(msgobj=None):
253
+ """
254
+ Load module package manager
255
+ - list all load modules
256
+ """
257
+ # Dump available LMs
258
+ msg_buf = []
259
+ for k in (res.replace('LM_', '') for res in ilist_fs(path=OSPath.MODULES, type_filter='f', select='LM')):
260
+ if msgobj is None:
261
+ msg_buf.append(f' {k}')
262
+ else:
263
+ msgobj(f' {k}')
264
+ return msg_buf if len(msg_buf) > 0 else ''
265
+
266
+
267
+ @sudo
268
+ def delmod(mod):
269
+ """
270
+ Module package manager
271
+ :param mod:
272
+ Delete Load Module with full name: module.py or module.mpy
273
+ OR delete any web resource: *.js, *.css, *.html
274
+ """
275
+ if mod.endswith('py'):
276
+ to_remove = f'LM_{mod}'
277
+ else:
278
+ return f'Invalid {mod}, must ends with .py or .mpy'
279
+ try:
280
+ return remove_file(path_join(OSPath.MODULES, to_remove))
281
+ except Exception as e:
282
+ return f'Cannot delete: {mod}: {e}'
283
+
284
+
285
+ @socket_stream
286
+ def micros_checksum(msgobj=None):
287
+ from hashlib import sha1
288
+ from binascii import hexlify
289
+ from Config import cfgget
290
+
291
+ for f_name in ilist_fs(path=OSPath.MODULES, type_filter='f', select='LM'):
292
+ with open(f_name, 'rb') as f:
293
+ cs = hexlify(sha1(f.read()).digest()).decode('utf-8')
294
+ msgobj(f"{cs} {f_name}")
295
+ # GC collect?
296
+ return f"micrOS version: {cfgget('version')}"
297
+
298
+
299
+ def help(widgets=False):
300
+ """
301
+ [i] micrOS LM naming convention - built-in help message
302
+ :return tuple:
303
+ (widgets=False) list of functions implemented by this application
304
+ (widgets=True) list of widget json for UI generation
305
+ """
306
+ return ('listmods', 'delmod mod=<module>.py/.mpy', 'del_duplicates',
307
+ 'moduls unload="LM_rgb/None"',
308
+ 'cachedump delete=None',
309
+ 'datdump',
310
+ # Package commands
311
+ 'install url="BxNxM/micrOS/master/toolkit/workspace/precompiled/LM_robustness.py"',
312
+ 'uninstall name=None',
313
+ 'upgrade name=None',
314
+ # File system commands
315
+ 'micros_checksum',
316
+ 'ls path="/" content="*/f/d" select="*/LM/IO"',
317
+ 'rm <path>',
318
+ 'rmdir <path>',
319
+ 'dirtree path="/"',
320
+ 'makedir <path>')
@@ -1,16 +1,12 @@
1
- from microIO import physical_pin, pinmap_dump
2
- from Common import SmartADC, micro_task, notify, syslog
3
- import uasyncio as asyncio
1
+ from microIO import bind_pin, pinmap_search
2
+ from Common import SmartADC, micro_task, notify, syslog, exec_cmd
4
3
  from utime import ticks_ms
5
- try:
6
- import LM_intercon as InterCon
7
- except:
8
- InterCon = None
4
+
9
5
 
10
6
  class Data:
11
7
  TASK_TAG = 'presence._capture'
12
8
 
13
- MIC_TYPES={'NONE': 0, 'ADC':1, 'I2S': 2}
9
+ MIC_TYPES = {'NONE':0, 'ADC':1, 'I2S':2}
14
10
  MIC_TYPE = MIC_TYPES['NONE'] # Enable/Disable MIC periphery ('ADC', 'I2S', None)
15
11
  RAW_DATA = [] # format [[<time>, <amplitude>, <trigger>],...]
16
12
  MIC_ADC = None # Initialized by micro task if sampled by ADC
@@ -26,7 +22,8 @@ class Data:
26
22
  OFF_INTERCON_CLBK = None # Intercon OFF callback
27
23
 
28
24
  I2S_MIC = None # Optional LM_i2s_mic import
29
- NOTIFY = False
25
+
26
+ ENABLE_NOTIFY = False
30
27
 
31
28
 
32
29
  #######################################
@@ -68,9 +65,9 @@ def __run_intercon(state):
68
65
  try:
69
66
  cmd = Data.ON_INTERCON_CLBK.split()
70
67
  host = cmd[0]
71
- cmd = ' '.join(cmd[1:])
72
- # Send CMD to other device & show result
73
- InterCon.send_cmd(host, cmd)
68
+ cmd = cmd[1:]
69
+ # Send CMD to other device
70
+ state, _ = exec_cmd(cmd + [f">>{host}"], jsonify=True)
74
71
  except Exception as e:
75
72
  syslog(f"__run_intercon error: {e}")
76
73
  if state.lower() == "off":
@@ -79,9 +76,9 @@ def __run_intercon(state):
79
76
  try:
80
77
  cmd = Data.OFF_INTERCON_CLBK.split()
81
78
  host = cmd[0]
82
- cmd = ' '.join(cmd[1:])
83
- # Send CMD to other device & show result
84
- InterCon.send_cmd(host, cmd)
79
+ cmd = cmd[1:]
80
+ # Send CMD to other device
81
+ state, _ = exec_cmd(cmd + [f">>{host}"], jsonify=True)
85
82
  except Exception as e:
86
83
  syslog(f"__run_intercon error: {e}")
87
84
 
@@ -91,18 +88,17 @@ def __run_intercon(state):
91
88
  ####################################
92
89
 
93
90
  async def __task(ms_period, buff_size):
94
- if Data.NOTIFY:
95
- if not notify("Motion detected"):
96
- syslog("Motion detect. notify, error...")
91
+ if Data.ENABLE_NOTIFY and not notify("Motion detected"):
92
+ syslog("Motion detect. notify, error...")
97
93
 
98
94
  if Data.MIC_TYPE == Data.MIC_TYPES['ADC']:
99
95
  # Create ADC object
100
- Data.MIC_ADC = SmartADC.get_singleton(physical_pin('mic'))
96
+ Data.MIC_ADC = SmartADC.get_instance(bind_pin('mic'))
101
97
  elif Data.MIC_TYPE == Data.MIC_TYPES['I2S']:
102
98
  if Data.I2S_MIC is None:
103
99
  import LM_i2s_mic
104
100
  Data.I2S_MIC = LM_i2s_mic
105
- Data.I2S_MIC.load_n_init(sampling_rate=2000) # High frequencies can result in slow performance
101
+ Data.I2S_MIC.load(sampling_rate=2000) # High frequencies can result in slow performance
106
102
  Data.I2S_MIC.background_capture()
107
103
 
108
104
  # ASYNC TASK ADAPTER [*2] with automatic state management
@@ -115,7 +111,7 @@ async def __task(ms_period, buff_size):
115
111
  my_task.out = f"{int(Data.OFF_EV_TIMER)-1} sec until off event"
116
112
  Data.OFF_EV_TIMER -= round(ms_period / 1000, 3)
117
113
  # Async sleep - feed event loop
118
- await asyncio.sleep_ms(ms_period)
114
+ await my_task.feed(sleep_ms=ms_period)
119
115
 
120
116
  # RUN OFF CALLBACK (local + remote)
121
117
  __exec_local_callbacks(Data.OFF_CALLBACKS)
@@ -186,18 +182,20 @@ def __mic_sample(buff_size, mytask):
186
182
  # PRESENCE PUBLIC FUNCTIONS #
187
183
  ##############################
188
184
 
189
- def load_n_init(threshold=Data.TRIG_THRESHOLD, timer=Data.TIMER_VALUE, mic=Data.MIC_TYPE):
185
+ def load(threshold=Data.TRIG_THRESHOLD, timer=Data.TIMER_VALUE, mic=Data.MIC_TYPE, enable_notify=False):
190
186
  """
191
187
  Initialize presence module
192
188
  :param threshold: trigger on relative noice change in percent
193
189
  :param timer: off timer in sec
194
190
  :param mic: enable / disable mic sampling (bool)
191
+ :param enable_notify: enable (True) / disable (False) telegram notifications
195
192
  """
196
193
  threshold = threshold if threshold > 1 else 1
197
194
  Data.TRIG_THRESHOLD = threshold
198
195
  Data.TIMER_VALUE = timer
199
196
  Data.MIC_TYPE = mic
200
- return f"Init presence module: th: {threshold} timer: {timer} mic: {mic}"
197
+ Data.ENABLE_NOTIFY = enable_notify
198
+ return f"Init presence module: th: {threshold} timer: {timer} mic: {mic} notify: {enable_notify}"
201
199
 
202
200
 
203
201
  def motion_trig(sample_ms=15, buff_size=10):
@@ -215,8 +213,7 @@ def motion_trig(sample_ms=15, buff_size=10):
215
213
 
216
214
  # [3] Start mic sampling in async task
217
215
  # [!] ASYNC TASK CREATION [1*] with async task callback + taskID (TAG) handling
218
- state = micro_task(tag=Data.TASK_TAG, task=__task(ms_period=sample_ms, buff_size=buff_size))
219
- return "Starting" if state else "Already running"
216
+ return micro_task(tag=Data.TASK_TAG, task=__task(ms_period=sample_ms, buff_size=buff_size))
220
217
 
221
218
 
222
219
  def subscribe_intercon(on, off):
@@ -231,14 +228,6 @@ def subscribe_intercon(on, off):
231
228
  return {'on': Data.ON_INTERCON_CLBK, 'off': Data.OFF_INTERCON_CLBK}
232
229
 
233
230
 
234
- def notification(state=None):
235
- """Enable/Disable motion detection notifications"""
236
- if state is None:
237
- return f"Notifications: {'enabled' if Data.NOTIFY else 'disabled'}"
238
- Data.NOTIFY = True if state else False
239
- return f"Set notifications: {'ON' if Data.NOTIFY else 'OFF'}"
240
-
241
-
242
231
  def get_samples():
243
232
  """
244
233
  [DEBUG] Return measured data set
@@ -257,7 +246,7 @@ def pinmap():
257
246
  - info which pins to use for this application
258
247
  :return dict: pin name (str) - pin value (int) pairs
259
248
  """
260
- return pinmap_dump(['mic', 'irq1'])
249
+ return pinmap_search(['mic', 'irq1'])
261
250
 
262
251
 
263
252
  def help(widgets=False):
@@ -267,8 +256,7 @@ def help(widgets=False):
267
256
  (widgets=False) list of functions implemented by this application
268
257
  (widgets=True) list of widget json for UI generation
269
258
  """
270
- return 'load_n_init threshold=<percent> timer=<sec> mic=0 (0: None, 1: ADC, 2: I2S)',\
259
+ return 'load threshold=<percent> timer=<sec> mic=0 (0: None, 1: ADC, 2: I2S) enable_notify=False',\
271
260
  'motion_trig sample_ms=15 buff_size=10', 'get_samples',\
272
261
  'subscribe_intercon on="host cmd" off="host cmd"',\
273
- 'notification state=None/True/False',\
274
262
  'pinmap'
@@ -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'