micrOSDevToolKit 2.9.1__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 (368) 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/esp32-20251209-v1.27.0.bin +0 -0
  4. micrOS/micropython/esp32c3-20251209-v1.27.0.bin +0 -0
  5. micrOS/micropython/esp32c6-20251209-v1.27.0.bin +0 -0
  6. micrOS/micropython/esp32s2-20251209-v1.27.0.bin +0 -0
  7. micrOS/micropython/esp32s2-LOLIN_MINI-20251209-v1.27.0.bin +0 -0
  8. micrOS/micropython/{esp32s3-20241129-v1.24.1.bin → esp32s3-4MBflash-20241129-v1.24.1.bin} +0 -0
  9. micrOS/micropython/esp32s3-8MBflash-20251209-v1.27.0.bin +0 -0
  10. micrOS/micropython/esp32s3_spiram_oct-20251209-v1.27.0.bin +0 -0
  11. micrOS/micropython/rpi-pico-w-20251209-v1.27.0.uf2 +0 -0
  12. micrOS/micropython/tinypico-20251209-v1.27.0.bin +0 -0
  13. micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +167 -163
  14. micrOS/source/Auth.py +37 -0
  15. micrOS/source/Common.py +361 -116
  16. micrOS/source/Config.py +32 -22
  17. micrOS/source/Debug.py +50 -94
  18. micrOS/source/Espnow.py +377 -100
  19. micrOS/source/Files.py +207 -0
  20. micrOS/source/Hooks.py +48 -20
  21. micrOS/source/InterConnect.py +126 -42
  22. micrOS/source/Interrupts.py +6 -6
  23. micrOS/source/Logger.py +63 -26
  24. micrOS/source/Network.py +41 -21
  25. micrOS/source/Notify.py +48 -22
  26. micrOS/source/Pacman.py +326 -0
  27. micrOS/source/Scheduler.py +14 -54
  28. micrOS/source/Server.py +67 -69
  29. micrOS/source/Shell.py +99 -91
  30. micrOS/source/Tasks.py +141 -95
  31. micrOS/source/Time.py +19 -18
  32. micrOS/source/Types.py +53 -9
  33. micrOS/source/Web.py +381 -76
  34. micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
  35. micrOS/source/__pycache__/Debug.cpython-312.pyc +0 -0
  36. micrOS/source/__pycache__/Files.cpython-312.pyc +0 -0
  37. micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
  38. micrOS/source/__pycache__/Scheduler.cpython-312.pyc +0 -0
  39. micrOS/source/__pycache__/Server.cpython-312.pyc +0 -0
  40. micrOS/source/__pycache__/Shell.cpython-312.pyc +0 -0
  41. micrOS/source/__pycache__/replhelper.cpython-312.pyc +0 -0
  42. micrOS/source/config/_git.keep +0 -0
  43. micrOS/source/helpers.py +132 -0
  44. micrOS/source/micrOS.py +17 -7
  45. micrOS/source/micrOSloader.py +5 -12
  46. micrOS/source/microIO.py +44 -20
  47. micrOS/source/modules/IO_esp32c6.py +38 -0
  48. micrOS/source/{IO_esp32s3.py → modules/IO_esp32s3.py} +37 -1
  49. micrOS/source/{IO_m5stamp.py → modules/IO_m5stamp.py} +35 -1
  50. micrOS/source/{IO_qtpy.py → modules/IO_qtpy.py} +22 -17
  51. micrOS/source/{IO_tinypico.py → modules/IO_tinypico.py} +38 -0
  52. micrOS/source/modules/LM_L298N.py +161 -0
  53. {toolkit/workspace/precompiled → micrOS/source/modules}/LM_L9110_DCmotor.py +3 -3
  54. micrOS/source/{LM_OV2640.py → modules/LM_OV2640.py} +45 -27
  55. micrOS/source/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +3 -3
  56. micrOS/source/{LM_aht10.py → modules/LM_aht10.py} +2 -2
  57. micrOS/source/{LM_bme280.py → modules/LM_bme280.py} +3 -3
  58. micrOS/source/{LM_buzzer.py → modules/LM_buzzer.py} +18 -25
  59. micrOS/source/{LM_cct.py → modules/LM_cct.py} +17 -21
  60. micrOS/source/modules/LM_cluster.py +255 -0
  61. micrOS/source/{LM_co2.py → modules/LM_co2.py} +3 -3
  62. micrOS/source/{LM_dht11.py → modules/LM_dht11.py} +2 -2
  63. micrOS/source/{LM_dht22.py → modules/LM_dht22.py} +2 -2
  64. micrOS/source/{LM_dimmer.py → modules/LM_dimmer.py} +9 -9
  65. micrOS/source/{LM_distance.py → modules/LM_distance.py} +4 -6
  66. micrOS/source/{LM_ds18.py → modules/LM_ds18.py} +2 -2
  67. micrOS/source/{LM_esp32.py → modules/LM_esp32.py} +5 -0
  68. micrOS/source/modules/LM_espnow.py +53 -0
  69. micrOS/source/modules/LM_fileserver.py +265 -0
  70. micrOS/source/{LM_genIO.py → modules/LM_genIO.py} +52 -37
  71. micrOS/source/{LM_haptic.py → modules/LM_haptic.py} +2 -2
  72. {toolkit/workspace/precompiled → micrOS/source/modules}/LM_i2c.py +5 -4
  73. micrOS/source/{LM_i2s_mic.py → modules/LM_i2s_mic.py} +6 -7
  74. micrOS/source/{LM_ld2410.py → modules/LM_ld2410.py} +2 -2
  75. micrOS/source/{LM_light_sensor.py → modules/LM_light_sensor.py} +10 -21
  76. micrOS/source/modules/LM_mh_z19c.py +198 -0
  77. micrOS/source/modules/LM_neoeffects.py +284 -0
  78. micrOS/source/{LM_neopixel.py → modules/LM_neopixel.py} +19 -23
  79. micrOS/source/{LM_oled.py → modules/LM_oled.py} +2 -2
  80. micrOS/source/{LM_oled_sh1106.py → modules/LM_oled_sh1106.py} +3 -3
  81. micrOS/source/{LM_oled_ui.py → modules/LM_oled_ui.py} +72 -64
  82. micrOS/source/modules/LM_pacman.py +320 -0
  83. micrOS/source/{LM_presence.py → modules/LM_presence.py} +11 -15
  84. micrOS/source/modules/LM_qmi8658.py +204 -0
  85. micrOS/source/{LM_rencoder.py → modules/LM_rencoder.py} +2 -2
  86. micrOS/source/{LM_rest.py → modules/LM_rest.py} +4 -6
  87. micrOS/source/{LM_rgb.py → modules/LM_rgb.py} +21 -29
  88. micrOS/source/{LM_roboarm.py → modules/LM_roboarm.py} +8 -8
  89. micrOS/source/modules/LM_robustness.py +137 -0
  90. micrOS/source/{LM_servo.py → modules/LM_servo.py} +3 -3
  91. micrOS/source/{LM_stepper.py → modules/LM_stepper.py} +5 -5
  92. micrOS/source/{LM_switch.py → modules/LM_switch.py} +11 -9
  93. micrOS/source/{LM_system.py → modules/LM_system.py} +38 -32
  94. micrOS/source/modules/LM_tcs3472.py +187 -0
  95. micrOS/source/{LM_telegram.py → modules/LM_telegram.py} +164 -116
  96. micrOS/source/{LM_trackball.py → modules/LM_trackball.py} +3 -3
  97. micrOS/source/{LM_veml7700.py → modules/LM_veml7700.py} +2 -2
  98. micrOS/source/modules/LM_web.py +38 -0
  99. micrOS/source/urequests.py +39 -15
  100. {toolkit/workspace/precompiled → micrOS/source/web}/dashboard.html +4 -0
  101. micrOS/source/web/editor.js +440 -0
  102. micrOS/source/web/filesui.html +178 -0
  103. micrOS/source/web/filesui.js +338 -0
  104. {toolkit/workspace/precompiled → micrOS/source/web}/index.html +44 -2
  105. micrOS/source/{uapi.js → web/uapi.js} +48 -7
  106. micrOS/source/{ustyle.css → web/ustyle.css} +6 -3
  107. micrOS/utests/__init__.py +0 -0
  108. micrOS/utests/test_scheduler.py +435 -0
  109. {micrOSDevToolKit-2.9.1.data → microsdevtoolkit-2.26.1.data}/scripts/devToolKit.py +33 -3
  110. {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info}/METADATA +327 -268
  111. microsdevtoolkit-2.26.1.dist-info/RECORD +396 -0
  112. {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info}/WHEEL +1 -1
  113. toolkit/DevEnvCompile.py +63 -33
  114. toolkit/DevEnvOTA.py +58 -22
  115. toolkit/DevEnvUSB.py +110 -55
  116. toolkit/Gateway.py +6 -6
  117. toolkit/LM_to_compile.dat +6 -4
  118. toolkit/MicrOSDevEnv.py +127 -57
  119. toolkit/WebRepl.py +73 -0
  120. toolkit/dashboard_apps/BackupRestore.py +20 -35
  121. toolkit/dashboard_apps/CCTDemo.py +12 -17
  122. toolkit/dashboard_apps/CCTTest.py +20 -24
  123. toolkit/dashboard_apps/CamStream.py +2 -6
  124. toolkit/dashboard_apps/CatGame.py +14 -16
  125. toolkit/dashboard_apps/Dimmer.py +11 -21
  126. toolkit/dashboard_apps/GetVersion.py +11 -19
  127. toolkit/dashboard_apps/MicrophoneTest.py +1 -6
  128. toolkit/dashboard_apps/NeoEffectsDemo.py +22 -35
  129. toolkit/dashboard_apps/NeopixelTest.py +20 -25
  130. toolkit/dashboard_apps/PresenceTest.py +2 -8
  131. toolkit/dashboard_apps/QMI8685_GYRO.py +68 -0
  132. toolkit/dashboard_apps/RGBTest.py +20 -24
  133. toolkit/dashboard_apps/RoboArm.py +24 -32
  134. toolkit/dashboard_apps/SED_test.py +10 -14
  135. toolkit/dashboard_apps/SensorsTest.py +61 -0
  136. toolkit/dashboard_apps/SystemTest.py +202 -105
  137. toolkit/dashboard_apps/Template_app.py +11 -23
  138. toolkit/dashboard_apps/_app_base.py +34 -0
  139. toolkit/dashboard_apps/_gyro_visualizer.py +78 -0
  140. toolkit/dashboard_apps/uLightDemo.py +15 -24
  141. toolkit/index.html +4 -4
  142. toolkit/lib/LocalMachine.py +6 -1
  143. toolkit/lib/MicrosFiles.py +46 -0
  144. toolkit/lib/Repository.py +64 -0
  145. toolkit/lib/TerminalColors.py +4 -0
  146. toolkit/lib/macroScript.py +6 -0
  147. toolkit/lib/micrOSClient.py +123 -50
  148. toolkit/lib/micrOSClientHistory.py +156 -0
  149. toolkit/lib/pip_package_installer.py +5 -2
  150. toolkit/micrOSdashboard.py +12 -17
  151. toolkit/micrOSlint.py +20 -8
  152. toolkit/simulator_lib/__pycache__/IO_darwin.cpython-312.pyc +0 -0
  153. toolkit/simulator_lib/__pycache__/aioespnow.cpython-312.pyc +0 -0
  154. toolkit/simulator_lib/__pycache__/framebuf.cpython-312.pyc +0 -0
  155. toolkit/simulator_lib/__pycache__/machine.cpython-312.pyc +0 -0
  156. toolkit/simulator_lib/__pycache__/micropython.cpython-312.pyc +0 -0
  157. toolkit/simulator_lib/__pycache__/mip.cpython-312.pyc +0 -0
  158. toolkit/simulator_lib/__pycache__/neopixel.cpython-312.pyc +0 -0
  159. toolkit/simulator_lib/__pycache__/network.cpython-312.pyc +0 -0
  160. toolkit/simulator_lib/__pycache__/sim_common.cpython-312.pyc +0 -0
  161. toolkit/simulator_lib/__pycache__/simgc.cpython-312.pyc +0 -0
  162. toolkit/simulator_lib/__pycache__/simulator.cpython-312.pyc +0 -0
  163. toolkit/simulator_lib/__pycache__/uasyncio.cpython-312.pyc +0 -0
  164. toolkit/simulator_lib/__pycache__/uos.cpython-312.pyc +0 -0
  165. toolkit/simulator_lib/__pycache__/urandom.cpython-312.pyc +0 -0
  166. toolkit/simulator_lib/__pycache__/usocket.cpython-312.pyc +0 -0
  167. toolkit/simulator_lib/__pycache__/ussl.cpython-312.pyc +0 -0
  168. toolkit/simulator_lib/aioespnow.py +28 -0
  169. toolkit/simulator_lib/dht.py +1 -1
  170. toolkit/simulator_lib/framebuf.py +49 -1
  171. toolkit/simulator_lib/machine.py +17 -2
  172. toolkit/simulator_lib/micropython.py +3 -3
  173. toolkit/simulator_lib/mip.py +165 -0
  174. toolkit/simulator_lib/neopixel.py +3 -2
  175. toolkit/simulator_lib/network.py +2 -1
  176. toolkit/simulator_lib/node_config.json +2 -3
  177. toolkit/simulator_lib/ntptime.py +1 -1
  178. toolkit/simulator_lib/{sim_console.py → sim_common.py} +2 -3
  179. toolkit/simulator_lib/simgc.py +6 -2
  180. toolkit/simulator_lib/simulator.py +137 -59
  181. toolkit/simulator_lib/uasyncio.py +33 -2
  182. toolkit/simulator_lib/uos.py +147 -0
  183. toolkit/simulator_lib/urandom.py +4 -0
  184. toolkit/socketClient.py +43 -23
  185. toolkit/user_data/webhooks/generic.py +1 -1
  186. toolkit/user_data/webhooks/macro.py +1 -1
  187. toolkit/user_data/webhooks/template.py +1 -1
  188. toolkit/workspace/precompiled/Auth.mpy +0 -0
  189. toolkit/workspace/precompiled/Common.mpy +0 -0
  190. toolkit/workspace/precompiled/Config.mpy +0 -0
  191. toolkit/workspace/precompiled/Debug.mpy +0 -0
  192. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  193. toolkit/workspace/precompiled/Files.mpy +0 -0
  194. toolkit/workspace/precompiled/Hooks.mpy +0 -0
  195. toolkit/workspace/precompiled/InterConnect.mpy +0 -0
  196. toolkit/workspace/precompiled/Interrupts.mpy +0 -0
  197. toolkit/workspace/precompiled/Logger.mpy +0 -0
  198. toolkit/workspace/precompiled/Network.mpy +0 -0
  199. toolkit/workspace/precompiled/Notify.mpy +0 -0
  200. toolkit/workspace/precompiled/Pacman.mpy +0 -0
  201. toolkit/workspace/precompiled/Scheduler.mpy +0 -0
  202. toolkit/workspace/precompiled/Server.mpy +0 -0
  203. toolkit/workspace/precompiled/Shell.mpy +0 -0
  204. toolkit/workspace/precompiled/Tasks.mpy +0 -0
  205. toolkit/workspace/precompiled/Time.mpy +0 -0
  206. toolkit/workspace/precompiled/Types.mpy +0 -0
  207. toolkit/workspace/precompiled/Web.mpy +0 -0
  208. toolkit/workspace/precompiled/_mpy.version +1 -1
  209. toolkit/workspace/precompiled/config/_git.keep +0 -0
  210. toolkit/workspace/precompiled/helpers.mpy +0 -0
  211. toolkit/workspace/precompiled/micrOS.mpy +0 -0
  212. toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
  213. toolkit/workspace/precompiled/microIO.mpy +0 -0
  214. toolkit/workspace/precompiled/{IO_esp32.mpy → modules/IO_esp32.mpy} +0 -0
  215. toolkit/workspace/precompiled/{IO_esp32c3.mpy → modules/IO_esp32c3.mpy} +0 -0
  216. toolkit/workspace/precompiled/modules/IO_esp32c6.mpy +0 -0
  217. toolkit/workspace/precompiled/{IO_esp32s2.mpy → modules/IO_esp32s2.mpy} +0 -0
  218. toolkit/workspace/precompiled/modules/IO_esp32s3.mpy +0 -0
  219. toolkit/workspace/precompiled/modules/IO_m5stamp.mpy +0 -0
  220. toolkit/workspace/precompiled/modules/IO_qtpy.mpy +0 -0
  221. toolkit/workspace/precompiled/modules/IO_rp2.mpy +0 -0
  222. toolkit/workspace/precompiled/modules/IO_tinypico.mpy +0 -0
  223. toolkit/workspace/precompiled/modules/LM_L298N.mpy +0 -0
  224. {micrOS/source → toolkit/workspace/precompiled/modules}/LM_L9110_DCmotor.py +3 -3
  225. toolkit/workspace/precompiled/modules/LM_OV2640.mpy +0 -0
  226. toolkit/workspace/precompiled/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +3 -3
  227. toolkit/workspace/precompiled/{LM_aht10.mpy → modules/LM_aht10.mpy} +0 -0
  228. toolkit/workspace/precompiled/{LM_bme280.mpy → modules/LM_bme280.mpy} +0 -0
  229. toolkit/workspace/precompiled/{LM_buzzer.mpy → modules/LM_buzzer.mpy} +0 -0
  230. toolkit/workspace/precompiled/modules/LM_cct.mpy +0 -0
  231. toolkit/workspace/precompiled/modules/LM_cluster.mpy +0 -0
  232. toolkit/workspace/precompiled/{LM_co2.mpy → modules/LM_co2.mpy} +0 -0
  233. toolkit/workspace/precompiled/{LM_dht11.mpy → modules/LM_dht11.mpy} +0 -0
  234. toolkit/workspace/precompiled/{LM_dht22.mpy → modules/LM_dht22.mpy} +0 -0
  235. toolkit/workspace/precompiled/modules/LM_dimmer.mpy +0 -0
  236. toolkit/workspace/precompiled/modules/LM_distance.mpy +0 -0
  237. toolkit/workspace/precompiled/{LM_ds18.mpy → modules/LM_ds18.mpy} +0 -0
  238. toolkit/workspace/precompiled/{LM_esp32.py → modules/LM_esp32.py} +5 -0
  239. toolkit/workspace/precompiled/modules/LM_espnow.py +53 -0
  240. toolkit/workspace/precompiled/modules/LM_fileserver.mpy +0 -0
  241. toolkit/workspace/precompiled/{LM_gameOfLife.mpy → modules/LM_gameOfLife.mpy} +0 -0
  242. toolkit/workspace/precompiled/modules/LM_genIO.mpy +0 -0
  243. toolkit/workspace/precompiled/{LM_haptic.mpy → modules/LM_haptic.mpy} +0 -0
  244. {micrOS/source → toolkit/workspace/precompiled/modules}/LM_i2c.py +5 -4
  245. toolkit/workspace/precompiled/modules/LM_i2s_mic.mpy +0 -0
  246. toolkit/workspace/precompiled/{LM_ld2410.mpy → modules/LM_ld2410.mpy} +0 -0
  247. toolkit/workspace/precompiled/modules/LM_light_sensor.mpy +0 -0
  248. toolkit/workspace/precompiled/modules/LM_mh_z19c.py +198 -0
  249. toolkit/workspace/precompiled/modules/LM_neoeffects.mpy +0 -0
  250. toolkit/workspace/precompiled/modules/LM_neopixel.mpy +0 -0
  251. toolkit/workspace/precompiled/{LM_oled.mpy → modules/LM_oled.mpy} +0 -0
  252. toolkit/workspace/precompiled/{LM_oled_sh1106.mpy → modules/LM_oled_sh1106.mpy} +0 -0
  253. toolkit/workspace/precompiled/modules/LM_oled_ui.mpy +0 -0
  254. toolkit/workspace/precompiled/modules/LM_pacman.mpy +0 -0
  255. toolkit/workspace/precompiled/modules/LM_presence.mpy +0 -0
  256. toolkit/workspace/precompiled/modules/LM_qmi8658.py +204 -0
  257. toolkit/workspace/precompiled/{LM_rencoder.py → modules/LM_rencoder.py} +2 -2
  258. toolkit/workspace/precompiled/modules/LM_rest.mpy +0 -0
  259. toolkit/workspace/precompiled/modules/LM_rgb.mpy +0 -0
  260. toolkit/workspace/precompiled/{LM_rgbcct.mpy → modules/LM_rgbcct.mpy} +0 -0
  261. toolkit/workspace/precompiled/modules/LM_roboarm.mpy +0 -0
  262. toolkit/workspace/precompiled/modules/LM_robustness.py +137 -0
  263. toolkit/workspace/precompiled/{LM_servo.mpy → modules/LM_servo.mpy} +0 -0
  264. toolkit/workspace/precompiled/{LM_sound_event.mpy → modules/LM_sound_event.mpy} +0 -0
  265. toolkit/workspace/precompiled/{LM_stepper.mpy → modules/LM_stepper.mpy} +0 -0
  266. toolkit/workspace/precompiled/modules/LM_switch.mpy +0 -0
  267. toolkit/workspace/precompiled/modules/LM_system.mpy +0 -0
  268. toolkit/workspace/precompiled/modules/LM_tcs3472.py +187 -0
  269. toolkit/workspace/precompiled/modules/LM_telegram.mpy +0 -0
  270. toolkit/workspace/precompiled/{LM_tinyrgb.mpy → modules/LM_tinyrgb.mpy} +0 -0
  271. toolkit/workspace/precompiled/{LM_trackball.mpy → modules/LM_trackball.mpy} +0 -0
  272. toolkit/workspace/precompiled/{LM_veml7700.mpy → modules/LM_veml7700.mpy} +0 -0
  273. toolkit/workspace/precompiled/modules/LM_web.mpy +0 -0
  274. toolkit/workspace/precompiled/urequests.mpy +0 -0
  275. {micrOS/source → toolkit/workspace/precompiled/web}/dashboard.html +4 -0
  276. toolkit/workspace/precompiled/web/editor.js +440 -0
  277. toolkit/workspace/precompiled/web/filesui.html +178 -0
  278. toolkit/workspace/precompiled/web/filesui.js +338 -0
  279. {micrOS/source → toolkit/workspace/precompiled/web}/index.html +44 -2
  280. toolkit/workspace/precompiled/{uapi.js → web/uapi.js} +48 -7
  281. toolkit/workspace/precompiled/{ustyle.css → web/ustyle.css} +6 -3
  282. micrOS/micropython/esp32-20241129-v1.24.1.bin +0 -0
  283. micrOS/micropython/esp32c3-20240222-v1.22.2.bin +0 -0
  284. micrOS/micropython/esp32s2-20240602-v1.23.0.bin +0 -0
  285. micrOS/micropython/esp32s2-LOLIN_MINI-20220618-v1.19.1.bin +0 -0
  286. micrOS/micropython/esp32s2-LOLIN_MINI-20240602-v1.23.0.bin +0 -0
  287. micrOS/micropython/esp32s3-20240105-v1.22.1.bin +0 -0
  288. micrOS/micropython/esp32s3_spiram_oct-20231005-v1.21.0.bin +0 -0
  289. micrOS/micropython/esp32s3_spiram_oct-20241129-v1.24.1.bin +0 -0
  290. micrOS/micropython/rpi-pico-w-20241129-v1.24.1.uf2 +0 -0
  291. micrOS/micropython/tinypico-20241129-v1.24.1.bin +0 -0
  292. micrOS/source/LM_L298N_DCmotor.py +0 -86
  293. micrOS/source/LM_catgame.py +0 -75
  294. micrOS/source/LM_dashboard_be.py +0 -37
  295. micrOS/source/LM_demo.py +0 -97
  296. micrOS/source/LM_espnow.py +0 -23
  297. micrOS/source/LM_intercon.py +0 -57
  298. micrOS/source/LM_keychain.py +0 -322
  299. micrOS/source/LM_lmpacman.py +0 -126
  300. micrOS/source/LM_neoeffects.py +0 -331
  301. micrOS/source/LM_oledui.py +0 -972
  302. micrOS/source/LM_pet_feeder.py +0 -78
  303. micrOS/source/LM_ph_sensor.py +0 -51
  304. micrOS/source/LM_robustness.py +0 -74
  305. micrOS/source/reset.py +0 -11
  306. micrOSDevToolKit-2.9.1.dist-info/RECORD +0 -365
  307. toolkit/dashboard_apps/AirQualityBME280.py +0 -36
  308. toolkit/dashboard_apps/AirQualityDHT22_CO2.py +0 -36
  309. toolkit/lib/file_extensions.py +0 -16
  310. toolkit/simulator_lib/__pycache__/sim_console.cpython-312.pyc +0 -0
  311. toolkit/simulator_lib/__pycache__/sim_console.cpython-38.pyc +0 -0
  312. toolkit/simulator_lib/__pycache__/sim_console.cpython-39.pyc +0 -0
  313. toolkit/workspace/precompiled/IO_esp32s3.mpy +0 -0
  314. toolkit/workspace/precompiled/IO_m5stamp.mpy +0 -0
  315. toolkit/workspace/precompiled/IO_qtpy.mpy +0 -0
  316. toolkit/workspace/precompiled/IO_rp2.mpy +0 -0
  317. toolkit/workspace/precompiled/IO_tinypico.mpy +0 -0
  318. toolkit/workspace/precompiled/LM_L298N_DCmotor.mpy +0 -0
  319. toolkit/workspace/precompiled/LM_OV2640.mpy +0 -0
  320. toolkit/workspace/precompiled/LM_catgame.py +0 -75
  321. toolkit/workspace/precompiled/LM_cct.mpy +0 -0
  322. toolkit/workspace/precompiled/LM_dashboard_be.py +0 -37
  323. toolkit/workspace/precompiled/LM_demo.py +0 -97
  324. toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
  325. toolkit/workspace/precompiled/LM_distance.mpy +0 -0
  326. toolkit/workspace/precompiled/LM_espnow.py +0 -23
  327. toolkit/workspace/precompiled/LM_genIO.mpy +0 -0
  328. toolkit/workspace/precompiled/LM_i2s_mic.mpy +0 -0
  329. toolkit/workspace/precompiled/LM_intercon.mpy +0 -0
  330. toolkit/workspace/precompiled/LM_keychain.mpy +0 -0
  331. toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
  332. toolkit/workspace/precompiled/LM_lmpacman.mpy +0 -0
  333. toolkit/workspace/precompiled/LM_neoeffects.mpy +0 -0
  334. toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
  335. toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
  336. toolkit/workspace/precompiled/LM_oledui.mpy +0 -0
  337. toolkit/workspace/precompiled/LM_pet_feeder.py +0 -78
  338. toolkit/workspace/precompiled/LM_ph_sensor.py +0 -51
  339. toolkit/workspace/precompiled/LM_presence.mpy +0 -0
  340. toolkit/workspace/precompiled/LM_rest.mpy +0 -0
  341. toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
  342. toolkit/workspace/precompiled/LM_roboarm.mpy +0 -0
  343. toolkit/workspace/precompiled/LM_robustness.py +0 -74
  344. toolkit/workspace/precompiled/LM_switch.mpy +0 -0
  345. toolkit/workspace/precompiled/LM_system.mpy +0 -0
  346. toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
  347. toolkit/workspace/precompiled/node_config.json +0 -1
  348. toolkit/workspace/precompiled/reset.mpy +0 -0
  349. /micrOS/source/{IO_esp32.py → modules/IO_esp32.py} +0 -0
  350. /micrOS/source/{IO_esp32c3.py → modules/IO_esp32c3.py} +0 -0
  351. /micrOS/source/{IO_esp32s2.py → modules/IO_esp32s2.py} +0 -0
  352. /micrOS/source/{IO_rp2.py → modules/IO_rp2.py} +0 -0
  353. /micrOS/source/{LM_gameOfLife.py → modules/LM_gameOfLife.py} +0 -0
  354. /micrOS/source/{LM_rgbcct.py → modules/LM_rgbcct.py} +0 -0
  355. /micrOS/source/{LM_rp2w.py → modules/LM_rp2w.py} +0 -0
  356. /micrOS/source/{LM_sdcard.py → modules/LM_sdcard.py} +0 -0
  357. /micrOS/source/{LM_sound_event.py → modules/LM_sound_event.py} +0 -0
  358. /micrOS/source/{LM_tinyrgb.py → modules/LM_tinyrgb.py} +0 -0
  359. /micrOS/source/{udashboard.js → web/udashboard.js} +0 -0
  360. /micrOS/source/{uwidgets.js → web/uwidgets.js} +0 -0
  361. /micrOS/source/{uwidgets_pro.js → web/uwidgets_pro.js} +0 -0
  362. {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info/licenses}/LICENSE +0 -0
  363. {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info}/top_level.txt +0 -0
  364. /toolkit/workspace/precompiled/{LM_rp2w.py → modules/LM_rp2w.py} +0 -0
  365. /toolkit/workspace/precompiled/{LM_sdcard.py → modules/LM_sdcard.py} +0 -0
  366. /toolkit/workspace/precompiled/{udashboard.js → web/udashboard.js} +0 -0
  367. /toolkit/workspace/precompiled/{uwidgets.js → web/uwidgets.js} +0 -0
  368. /toolkit/workspace/precompiled/{uwidgets_pro.js → web/uwidgets_pro.js} +0 -0
@@ -0,0 +1,161 @@
1
+ from machine import Pin, PWM
2
+ from microIO import bind_pin, pinmap_search
3
+
4
+
5
+ # Cache of last set motor speeds (motor1, motor2) to ensure state() reports the latest values
6
+ # even if hardware PWM duty readout is delayed or unsupported on some boards
7
+ __MOTOR_SPEEDS = [0, 0] # motor1, motor2
8
+ __L298N_OBJS = []
9
+
10
+ PWM_FREQ = 50
11
+ # Deprecated LM_L298N_DCmotor: l298speed, l298dir_1, l298dir_2
12
+ PIN_BINDINGS = [
13
+ ('l298n_ENA', 10), ('l298n_INA', 12), ('l298n_INB', 11), # motor 1
14
+ ('l298n_ENB', 3), ('l298n_INC', 9), ('l298n_IND', 40), # motor 2
15
+ ]
16
+ STATE_MAP = {
17
+ (1, 0): 'forward',
18
+ (0, 1): 'backward',
19
+ (0, 0): 'coast',
20
+ (1, 1): 'brake'
21
+ }
22
+
23
+
24
+ def __l298n_init():
25
+ global __L298N_OBJS
26
+ if not __L298N_OBJS:
27
+ for index, (name, pin) in enumerate(PIN_BINDINGS):
28
+ if index % 3 == 0: # PWM pin
29
+ pwm = PWM(bind_pin(name, pin), freq=PWM_FREQ)
30
+ pwm.duty(0)
31
+ __L298N_OBJS.append(pwm)
32
+ else:
33
+ p = Pin(bind_pin(name, pin), Pin.OUT)
34
+ p.value(0)
35
+ __L298N_OBJS.append(p)
36
+ return __L298N_OBJS
37
+
38
+
39
+ def __get_motor_state(motor_index):
40
+ objlist = __l298n_init()
41
+ pwm_index = motor_index * 3
42
+ in1, in2 = objlist[pwm_index + 1].value(), objlist[pwm_index + 2].value()
43
+ state = STATE_MAP.get((in1, in2), 'unknown')
44
+ return {'speed': __MOTOR_SPEEDS[motor_index], 'state': state}
45
+
46
+
47
+ #########################
48
+ # Application functions #
49
+ #########################
50
+
51
+ def load(pwm_freq:int=None):
52
+ """
53
+ [i] micrOS LM naming convention
54
+ Load the L298N motor driver module
55
+ """
56
+ global PWM_FREQ
57
+ if pwm_freq is not None:
58
+ PWM_FREQ = pwm_freq
59
+ __l298n_init()
60
+ return "Motor driver loaded successfully."
61
+
62
+
63
+ def state(motor=0):
64
+ """
65
+ [i] micrOS LM naming convention
66
+ Get the current state of a motor or all motors
67
+ :param motor: Motor number (1 or 2) or None for all motors
68
+ """
69
+ if motor == 1:
70
+ return {'motor1': __get_motor_state(0)}
71
+ elif motor == 2:
72
+ return {'motor2': __get_motor_state(1)}
73
+ else:
74
+ return {
75
+ 'motor1': __get_motor_state(0),
76
+ 'motor2': __get_motor_state(1)
77
+ }
78
+
79
+
80
+ def _control_motor(motor, in1, in2):
81
+ objlist = __l298n_init()
82
+ motor_index = 0 if motor == 1 else 3
83
+ objlist[motor_index + 1].value(in1)
84
+ objlist[motor_index + 2].value(in2)
85
+
86
+
87
+ def speed(motor, speed:int=1023):
88
+ """
89
+ Set the speed of a motor
90
+ :param motor: Motor number (1 or 2)
91
+ :param speed: Speed value (0-1023)
92
+ :return: Current motor state
93
+ """
94
+ if not (0 <= speed <= 1023):
95
+ return {'speed': 'value range error'}
96
+ pwm_index = 0 if motor == 1 else 3
97
+ motor_index = 0 if motor == 1 else 1
98
+ __l298n_init()[pwm_index].duty(speed)
99
+ __MOTOR_SPEEDS[motor_index] = speed
100
+ return state(motor)
101
+
102
+
103
+ def direction(motor, forward: bool=True):
104
+ """
105
+ Set the direction of a motor
106
+ :param motor: Motor number (1 or 2)
107
+ :param forward: True if motor should move forward, False if backward
108
+ :return: Current motor state
109
+ """
110
+ _control_motor(motor, 1 if forward else 0, 0 if forward else 1)
111
+ return state(motor)
112
+
113
+
114
+ def coast(motor):
115
+ """
116
+ Coast the motor
117
+ :param motor: Motor number (1 or 2)
118
+ """
119
+ _control_motor(motor, 0, 0)
120
+ return state(motor)
121
+
122
+
123
+ def brake(motor):
124
+ """
125
+ Brake the motor
126
+ :param motor: Motor number (1 or 2)
127
+ :return: Current motor state
128
+ """
129
+ _control_motor(motor, 1, 1)
130
+ return state(motor)
131
+
132
+
133
+ #######################
134
+ # LM helper functions #
135
+ #######################
136
+
137
+ def pinmap():
138
+ """
139
+ [i] micrOS LM naming convention
140
+ Shows logical pins - pin number(s) used by this Load module
141
+ - info which pins to use for this application
142
+ :return dict: pin name (str) - pin value (int) pairs
143
+ """
144
+ return pinmap_search([name for name, _ in PIN_BINDINGS])
145
+
146
+
147
+ def help(widgets=False):
148
+ """
149
+ [i] micrOS LM naming convention - built-in help message
150
+ :return tuple:
151
+ (widgets=False) list of functions implemented by this application
152
+ (widgets=True) list of widget json for UI generation
153
+ """
154
+ return (
155
+ 'speed motor=<1/2> speed=<0-1023>',
156
+ 'direction motor=<1/2> forward=<True/False>',
157
+ 'coast motor=<1/2>',
158
+ 'brake motor=<1/2>',
159
+ 'state motor=<0/1/2>',
160
+ 'pinmap'
161
+ )
@@ -1,4 +1,4 @@
1
- from microIO import resolve_pin, pinmap_search
1
+ from microIO import bind_pin, pinmap_search
2
2
 
3
3
  #########################################
4
4
  # ANALOG DIMMER CONTROLLER PARAMS #
@@ -15,8 +15,8 @@ def __l9110_init():
15
15
  global __L9110_OBJS
16
16
  if len(__L9110_OBJS) == 0:
17
17
  from machine import Pin, PWM
18
- __L9110_OBJS.append(PWM(Pin(resolve_pin('l9110dir_1')), freq=1024))
19
- __L9110_OBJS.append(PWM(Pin(resolve_pin('l9110dir_2')), freq=1024))
18
+ __L9110_OBJS.append(PWM(Pin(bind_pin('l9110dir_1')), freq=1024))
19
+ __L9110_OBJS.append(PWM(Pin(bind_pin('l9110dir_2')), freq=1024))
20
20
  __L9110_OBJS[0].duty(0) # Set default speed (PWM)
21
21
  __L9110_OBJS[1].duty(0) # Set default speed (PWM)
22
22
  return __L9110_OBJS
@@ -2,8 +2,9 @@ try:
2
2
  import camera
3
3
  except Exception as e:
4
4
  camera = None
5
- import time
6
- from Common import web_endpoint, syslog
5
+ from time import localtime, sleep
6
+ from json import loads
7
+ from Common import web_endpoint, syslog, exec_cmd
7
8
  from Types import resolve
8
9
 
9
10
  IN_CAPTURE = False # Make sure single capture in progress in the same time
@@ -44,7 +45,7 @@ def load(quality='medium', freq='default', effect="NONE"):
44
45
  except Exception as e:
45
46
  syslog(f"[ERR] OV2640: {e}")
46
47
  camera.deinit()
47
- time.sleep(1)
48
+ sleep(1)
48
49
  if not CAM_INIT:
49
50
  return "Cannot init OV2640 cam"
50
51
 
@@ -57,6 +58,8 @@ def _set_web_endpoints():
57
58
  # Register rest endpoint
58
59
  web_endpoint('cam/snapshot', _snapshot_clb)
59
60
  web_endpoint('cam/stream', _image_stream_clb)
61
+ web_endpoint('cam/photo', lambda: ('text/plain', photo()))
62
+ return "Endpoint created: /cam/snapshot, /cam/stream, /cam/photo"
60
63
 
61
64
 
62
65
  def settings(quality=None, flip=None, mirror=None, effect=None, saturation=None, brightness=None, contrast=None, whitebalace=None, q=None):
@@ -152,24 +155,54 @@ def capture():
152
155
  if buf:
153
156
  break
154
157
  n_try += 1
155
- time.sleep(0.1)
158
+ sleep(0.1)
156
159
  except Exception as e:
157
160
  syslog(f"[OV2640] Failed to capture: {e}")
158
161
  IN_CAPTURE = False
159
162
  return buf
160
163
 
161
164
 
162
- def photo(name='photo.jpg'):
163
- buf = capture()
164
- with open(name, 'w') as f:
165
+ def photo(name='photo.jpeg'):
166
+ """
167
+ Beta feature - with storage limit
168
+ Create photo and save it under /web/<user_data>
169
+ """
170
+ def _storage_check(storage_limit=60):
171
+ _status, _usage = exec_cmd(cmd=['fileserver', '_disk_usage_clb'], jsonify=False, secure=True)
172
+ if not _status:
173
+ return False, f"Cannot get storage info: {_usage}"
174
+ # Eval hack to be able to reuse web endpoint callback for disk usage
175
+ usage = loads(str(eval(_usage)[-1]))
176
+ usage_percent = int((usage.get("used", 0) / (usage.get("free", 0) + usage.get("used", 0))) * 100)
177
+ print(usage_percent)
178
+ if usage_percent > storage_limit:
179
+ return False, f"Storage is full < {storage_limit}%"
180
+ return True, ""
181
+
182
+ status, path = exec_cmd(cmd=['fileserver', 'get_user_dir'], jsonify=False, secure=True)
183
+ if not status:
184
+ return "No shared path available: fileserver get_user_dir"
185
+ s, v = _storage_check()
186
+ if not s:
187
+ return v
188
+ t = localtime()
189
+ ts = "{:02d}{:02d}{:02d}-{:02d}{:02d}{:02d}".format(t[0] % 100, t[1], t[2], t[3], t[4], t[5])
190
+ # Create file name with time stamp
191
+ photo_path = f"{path}/{ts}-{name}"
192
+ # Take a Photo
193
+ _ = capture() # Dump current cached image
194
+ buf = capture() # Create new image
195
+ # Save the Photo
196
+ with open(photo_path, 'wb') as f:
165
197
  if buf:
166
198
  f.write(buf)
167
- return "Image saved as photo.jpg"
168
- return "Cannot save... photo.jpg"
199
+ return f"Image saved as {photo_path}"
200
+ return f"Cannot save... {photo_path}"
169
201
 
170
202
 
171
203
  def _snapshot_clb():
172
- image = capture()
204
+ _ = capture() # Dump current cached image
205
+ image = capture() # Take new image
173
206
  if image is not None:
174
207
  return 'image/jpeg', image
175
208
  return 'text/plain', f'capture error: {image}'
@@ -179,21 +212,7 @@ def _image_stream_clb():
179
212
  return 'multipart/x-mixed-replace', {'callback': capture, 'content-type': 'image/jpeg'}
180
213
 
181
214
 
182
- def _img_clb(name="photo.jpg"):
183
- with open(name, 'rb') as f:
184
- image = f.read()
185
- return 'image/jpeg', image
186
-
187
-
188
- def set_photo_endpoint():
189
- """
190
- Set photo endpoint (rest endpoint)
191
- """
192
- web_endpoint('photo', _img_clb)
193
- return "Endpoint created: /photo"
194
-
195
-
196
- def __light_init():
215
+ def _light_init():
197
216
  global FLASH_LIGHT
198
217
  if FLASH_LIGHT is None:
199
218
  from machine import Pin
@@ -205,7 +224,7 @@ def flashlight(state=None):
205
224
  Camera flashlight
206
225
  :param state: True/False/None(automatic)
207
226
  """
208
- fl = __light_init()
227
+ fl = _light_init()
209
228
  if state is None:
210
229
  state = fl.value(not fl.value())
211
230
  else:
@@ -228,7 +247,6 @@ def help(widgets=False):
228
247
  'BUTTON settings effect=<NONE,NEG,BW,RED,GREEN,BLUE,RETRO>',
229
248
  'capture',
230
249
  'photo',
231
- 'set_photo_endpoint',
232
250
  'BUTTON flashlight state=None',
233
251
  '[Hint] after load you can access the /cam/snapshot and /cam/stream endpoints',
234
252
  'Thanks to :) https://github.com/lemariva/micropython-camera-driver'), widgets=widgets)
@@ -2,7 +2,7 @@ from micropython import const
2
2
  import ustruct
3
3
  import utime
4
4
  from machine import I2C, Pin
5
- from microIO import resolve_pin, pinmap_search
5
+ from microIO import bind_pin, pinmap_search
6
6
 
7
7
  __TOF_OBJ = None
8
8
 
@@ -31,7 +31,7 @@ class TimeoutError(RuntimeError):
31
31
 
32
32
  class VL53L0X:
33
33
  def __init__(self, address=57):
34
- self.i2c = I2C(-1, Pin(resolve_pin('i2c_scl')), Pin(resolve_pin('i2c_sda')), freq=9600)
34
+ self.i2c = I2C(-1, Pin(bind_pin('i2c_scl')), Pin(bind_pin('i2c_sda')), freq=9600)
35
35
  self.address = address
36
36
  self.init()
37
37
  self._started = False
@@ -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:
@@ -1,5 +1,5 @@
1
1
  from machine import I2C, Pin
2
- from microIO import resolve_pin, pinmap_search
2
+ from microIO import bind_pin, pinmap_search
3
3
  from Common import syslog
4
4
  from time import sleep
5
5
  from binascii import hexlify
@@ -24,7 +24,7 @@ def _handle_connection_error(f):
24
24
 
25
25
  class AHT10:
26
26
  def __init__(self, address = 0x38):
27
- self.i2c = I2C(-1, Pin(resolve_pin('i2c_scl')), Pin(resolve_pin('i2c_sda')), freq = 9600)
27
+ self.i2c = I2C(-1, Pin(bind_pin('i2c_scl')), Pin(bind_pin('i2c_sda')), freq = 9600)
28
28
  self.address = address
29
29
  if not self.init_sensor():
30
30
  raise Exception("Could not initialize the sensor!")
@@ -6,7 +6,7 @@ https://randomnerdtutorials.com/micropython-bme280-esp32-esp8266/
6
6
 
7
7
  import utime as time
8
8
  from machine import Pin, I2C
9
- from microIO import resolve_pin, pinmap_search
9
+ from microIO import bind_pin, pinmap_search
10
10
  from Common import notify
11
11
  from Types import resolve
12
12
 
@@ -299,7 +299,7 @@ class BME280:
299
299
  def __init_bme280_i2c():
300
300
  global BME280_OBJ
301
301
  if BME280_OBJ is None:
302
- i2c = I2C(scl=Pin(resolve_pin('i2c_scl')), sda=Pin(resolve_pin('i2c_sda')), freq=10000)
302
+ i2c = I2C(scl=Pin(bind_pin('i2c_scl')), sda=Pin(bind_pin('i2c_sda')), freq=10000)
303
303
  BME280_OBJ = BME280(i2c=i2c)
304
304
  return BME280_OBJ
305
305
 
@@ -349,5 +349,5 @@ def help(widgets=False):
349
349
  (widgets=False) list of functions implemented by this application
350
350
  (widgets=True) list of widget json for UI generation
351
351
  """
352
- return resolve(('TEXTBOX measure ntfy=False',
352
+ return resolve(('TEXTBOX{"refresh": 2000} measure ntfy=False',
353
353
  'load', 'pinmap'), widgets=widgets)
@@ -1,7 +1,6 @@
1
- from sys import platform
2
1
  from utime import sleep
3
- from microIO import resolve_pin, pinmap_search
4
- from Common import micro_task, notify
2
+ from microIO import bind_pin, pinmap_search
3
+ from Common import micro_task, notify, data_dir
5
4
  from Types import resolve
6
5
 
7
6
 
@@ -13,6 +12,7 @@ __BUZZER_OBJ = None
13
12
  __BUZZER_CACHE = [600]
14
13
  __PERSISTENT_CACHE = False
15
14
  __TASK_TAG = "buzzer._play"
15
+ __FILE_CACHE = data_dir('buzzer.cache')
16
16
  CHECK_NOTIFY = False
17
17
 
18
18
  #########################################
@@ -175,22 +175,22 @@ def _builtin_tones(tone=None):
175
175
  #########################################
176
176
 
177
177
 
178
- def __buzzer_init():
178
+ def __buzzer_init(pin=None):
179
+ """
180
+ :param pin: optional number to overwrite default pin
181
+ """
179
182
  global __BUZZER_OBJ
180
183
  if __BUZZER_OBJ is None:
181
184
  from machine import Pin, PWM
182
- dimmer_pin = Pin(resolve_pin('buzzer'))
183
- if platform == 'esp8266':
184
- __BUZZER_OBJ = PWM(dimmer_pin, freq=600)
185
- else:
186
- __BUZZER_OBJ = PWM(dimmer_pin, freq=600)
185
+ dimmer_pin = Pin(bind_pin('buzzer', number=pin))
186
+ __BUZZER_OBJ = PWM(dimmer_pin, freq=600)
187
187
  __BUZZER_OBJ.duty(512) # 50%
188
188
  return __BUZZER_OBJ
189
189
 
190
190
 
191
191
  def __persistent_cache_manager(mode='r'):
192
192
  """
193
- pds - persistent data structure
193
+ File cache
194
194
  modes:
195
195
  r - recover, s - save
196
196
  """
@@ -199,12 +199,12 @@ def __persistent_cache_manager(mode='r'):
199
199
  global __BUZZER_CACHE
200
200
  if mode == 's':
201
201
  # SAVE CACHE
202
- with open('buzzer.pds', 'w') as f:
202
+ with open(__FILE_CACHE, 'w') as f:
203
203
  f.write(','.join([str(k) for k in __BUZZER_CACHE]))
204
204
  return
205
205
  try:
206
206
  # RESTORE CACHE
207
- with open('buzzer.pds', 'r') as f:
207
+ with open(__FILE_CACHE, 'r') as f:
208
208
  __BUZZER_CACHE = [int(data) for data in f.read().strip().split(',')]
209
209
  except:
210
210
  pass
@@ -270,10 +270,7 @@ def play(rtttlstr='Indiana'):
270
270
  global CHECK_NOTIFY
271
271
  if CHECK_NOTIFY and not notify():
272
272
  return "NoBipp - notify off"
273
- state = micro_task(tag=__TASK_TAG, task=_play(rtttlstr))
274
- if state:
275
- return 'Play song'
276
- return 'Song already playing'
273
+ return micro_task(tag=__TASK_TAG, task=_play(rtttlstr))
277
274
 
278
275
 
279
276
  def list_tones():
@@ -283,23 +280,19 @@ def list_tones():
283
280
  return '\n'.join(list(_builtin_tones()))
284
281
 
285
282
 
286
- def load(cache=None, check_notify=False):
283
+ def load(check_notify=False, pin=None, cache=True):
287
284
  """
288
285
  Initialize buzzer module
289
- :param cache bool: file state machine cache: True/False/None(default: automatic True)
290
- - Load .pds (state machine cache) for this load module
291
- - Apply loaded states to gpio pins (boot function)
292
286
  :param check_notify: check notify enabled/disabled - make noise if enabled only
287
+ :param pin: optional number to overwrite default pin
288
+ :param cache: default True, store stages on disk (.cache)
293
289
  :return str: Verdict
294
290
  """
295
- from sys import platform
296
291
  global __PERSISTENT_CACHE, CHECK_NOTIFY
297
- if cache is None:
298
- __PERSISTENT_CACHE = False if platform == 'esp8266' else True
299
- else:
300
- __PERSISTENT_CACHE = cache
292
+ __PERSISTENT_CACHE = cache
301
293
  __persistent_cache_manager('r')
302
294
  CHECK_NOTIFY = check_notify
295
+ __buzzer_init(pin=pin)
303
296
  return f"CACHE: {__PERSISTENT_CACHE}, check notify: {CHECK_NOTIFY}"
304
297
 
305
298
 
@@ -4,8 +4,8 @@
4
4
  from machine import Pin, PWM
5
5
  from sys import platform
6
6
  from utime import sleep_ms
7
- from Common import transition_gen, micro_task
8
- from microIO import resolve_pin, pinmap_search
7
+ from Common import transition_gen, micro_task, data_dir
8
+ from microIO import bind_pin, pinmap_search
9
9
  from random import randint
10
10
  from Types import resolve
11
11
 
@@ -18,16 +18,17 @@ class Data:
18
18
  CCT_TASK_TAG = 'cct._tran'
19
19
  HUE_TASK_TAG = 'cct._hue'
20
20
  TASK_STATE = False
21
+ FILE_CACHE = data_dir('cwww.cache')
21
22
 
22
23
 
23
24
  #########################################
24
25
  # ANALOG CCT WITH 2 channel PWM #
25
26
  #########################################
26
27
 
27
- def __cwww_init():
28
+ def __cwww_init(pin_warm=None, pin_cold=None):
28
29
  if Data.CWWW_OBJS[0] is None or Data.CWWW_OBJS[1] is None:
29
- cw = Pin(resolve_pin('cwhite'))
30
- ww = Pin(resolve_pin('wwhite'))
30
+ cw = Pin(bind_pin('cwhite', pin_cold))
31
+ ww = Pin(bind_pin('wwhite', pin_warm))
31
32
  if platform == 'esp8266':
32
33
  Data.CWWW_OBJS = (PWM(cw, freq=1024),
33
34
  PWM(ww, freq=1024))
@@ -39,7 +40,7 @@ def __cwww_init():
39
40
 
40
41
  def __persistent_cache_manager(mode):
41
42
  """
42
- pds - persistent data structure
43
+ File state cache
43
44
  modes:
44
45
  r - recover, s - save
45
46
  """
@@ -47,12 +48,12 @@ def __persistent_cache_manager(mode):
47
48
  return
48
49
  if mode == 's':
49
50
  # SAVE CACHE
50
- with open('cwww.pds', 'w') as f:
51
+ with open(Data.FILE_CACHE, 'w') as f:
51
52
  f.write(','.join([str(k) for k in Data.CWWW_CACHE]))
52
53
  return
53
54
  try:
54
55
  # RESTORE CACHE
55
- with open('cwww.pds', 'r') as f:
56
+ with open(Data.FILE_CACHE, 'r') as f:
56
57
  Data.CWWW_CACHE = [float(data) for data in f.read().strip().split(',')]
57
58
  except:
58
59
  pass
@@ -72,19 +73,16 @@ def __state_machine(c, w):
72
73
  # Application functions #
73
74
  #########################
74
75
 
75
- def load(cache=None):
76
+ def load(pin_warm=None, pin_cold=None, cache=True):
76
77
  """
77
78
  Initialize Cold white / Warm white LED module
78
- :param cache bool: file state machine cache: True/False/None(default: automatic True)
79
- - Load .pds (state machine cache) for this load module
80
- - Apply loaded states to gpio pins (boot function)
79
+ :param pin_warm: optional number to overwrite default pin
80
+ :param pin_cold: optional number to overwrite default pin
81
+ :param cache: save/load state machine to disk (.cache)
81
82
  :return str: Cache state
82
83
  """
83
- from sys import platform
84
- if cache is None:
85
- Data.PERSISTENT_CACHE = False if platform == 'esp8266' else True
86
- else:
87
- Data.PERSISTENT_CACHE = cache
84
+ __cwww_init(pin_warm, pin_cold)
85
+ Data.PERSISTENT_CACHE = cache
88
86
  __persistent_cache_manager('r') # recover data cache
89
87
  if Data.CWWW_CACHE[2] == 1:
90
88
  Data.CWWW_CACHE[2] = 0 # Force ON at boot
@@ -240,8 +238,7 @@ def transition(cw=None, ww=None, sec=1.0, wake=False):
240
238
  # Create transition generator and calculate step_ms
241
239
  cct_gen, step_ms = transition_gen(cw_from, cw_to, ww_from, ww_to, interval_sec=sec)
242
240
  # [!] ASYNC TASK CREATION [1*] with async task callback + taskID (TAG) handling
243
- state = micro_task(tag=Data.CCT_TASK_TAG, task=_task(ms_period=step_ms, iterable=cct_gen))
244
- return "Starting transition" if state else "Transition already running"
241
+ return micro_task(tag=Data.CCT_TASK_TAG, task=_task(ms_period=step_ms, iterable=cct_gen))
245
242
 
246
243
 
247
244
  def hue_transition(percent, sec=1.0, wake=False):
@@ -290,8 +287,7 @@ def hue_transition(percent, sec=1.0, wake=False):
290
287
  #print("Actual percent: {}, target percent: {}".format(actual_percent, warm_percent))
291
288
  hue_gen, step_ms = transition_gen(hue_curr_percent, percent*10, interval_sec=sec)
292
289
  # [!] ASYNC TASK CREATION [1*] with async task callback + taskID (TAG) handling
293
- state = micro_task(tag=Data.HUE_TASK_TAG, task=_task(ms_period=step_ms, iterable=hue_gen))
294
- return "Starting transition" if state else "Transition already running"
290
+ return micro_task(tag=Data.HUE_TASK_TAG, task=_task(ms_period=step_ms, iterable=hue_gen))
295
291
  else:
296
292
  return "Invalid range, percent=<0-100>"
297
293