micrOSDevToolKit 2.13.1__py3-none-any.whl → 2.17.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 (220) hide show
  1. micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +125 -121
  2. micrOS/source/Common.py +48 -26
  3. micrOS/source/Config.py +13 -5
  4. micrOS/source/Espnow.py +100 -58
  5. micrOS/source/Files.py +77 -41
  6. micrOS/source/Hooks.py +18 -34
  7. micrOS/source/Logger.py +2 -7
  8. micrOS/source/Network.py +36 -16
  9. micrOS/source/Server.py +22 -8
  10. micrOS/source/Shell.py +9 -6
  11. micrOS/source/Tasks.py +34 -13
  12. micrOS/source/Web.py +69 -31
  13. micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
  14. micrOS/source/__pycache__/Files.cpython-312.pyc +0 -0
  15. micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
  16. micrOS/source/__pycache__/Server.cpython-312.pyc +0 -0
  17. micrOS/source/config/_git.keep +0 -0
  18. micrOS/source/micrOS.py +7 -0
  19. micrOS/source/micrOSloader.py +2 -10
  20. micrOS/source/microIO.py +2 -2
  21. micrOS/source/modules/IO_esp32c6.py +38 -0
  22. micrOS/source/modules/LM_L298N.py +161 -0
  23. micrOS/source/modules/LM_cluster.py +250 -0
  24. {toolkit/workspace/precompiled → micrOS/source/modules}/LM_esp32.py +5 -0
  25. micrOS/source/modules/LM_espnow.py +36 -0
  26. micrOS/source/{LM_i2c.py → modules/LM_i2c.py} +1 -1
  27. micrOS/source/{LM_light_sensor.py → modules/LM_light_sensor.py} +2 -2
  28. micrOS/source/modules/LM_mqtt_client.py +246 -0
  29. micrOS/source/{LM_neoeffects.py → modules/LM_neoeffects.py} +14 -4
  30. micrOS/source/{LM_neomatrix.py → modules/LM_neomatrix.py} +140 -38
  31. micrOS/source/{LM_oled_ui.py → modules/LM_oled_ui.py} +2 -2
  32. micrOS/source/{LM_oledui.py → modules/LM_oledui.py} +2 -2
  33. micrOS/source/{LM_pacman.py → modules/LM_pacman.py} +74 -29
  34. micrOS/source/{LM_presence.py → modules/LM_presence.py} +2 -2
  35. micrOS/source/{LM_robustness.py → modules/LM_robustness.py} +49 -2
  36. micrOS/source/{LM_tcs3472.py → modules/LM_tcs3472.py} +4 -6
  37. micrOS/source/web/dashboard.html +2 -0
  38. micrOS/source/web/matrix_draw.html +390 -0
  39. micrOS/source/web/uapi.js +9 -6
  40. {microsdevtoolkit-2.13.1.dist-info → microsdevtoolkit-2.17.0.dist-info}/METADATA +30 -37
  41. {microsdevtoolkit-2.13.1.dist-info → microsdevtoolkit-2.17.0.dist-info}/RECORD +200 -190
  42. toolkit/DevEnvCompile.py +21 -12
  43. toolkit/DevEnvOTA.py +27 -16
  44. toolkit/DevEnvUSB.py +35 -21
  45. toolkit/LM_to_compile.dat +3 -1
  46. toolkit/MicrOSDevEnv.py +37 -21
  47. toolkit/dashboard_apps/QMI8685_GYRO.py +1 -1
  48. toolkit/dashboard_apps/SystemTest.py +8 -5
  49. toolkit/{MicrosFiles.py → lib/MicrosFiles.py} +24 -4
  50. toolkit/micrOSdashboard.py +2 -2
  51. toolkit/micrOSlint.py +17 -7
  52. toolkit/simulator_lib/__pycache__/simulator.cpython-312.pyc +0 -0
  53. toolkit/simulator_lib/__pycache__/uos.cpython-312.pyc +0 -0
  54. toolkit/simulator_lib/mqtt_as/Note.md +15 -0
  55. toolkit/simulator_lib/mqtt_as/__init__.py +950 -0
  56. toolkit/simulator_lib/mqtt_as/__pycache__/__init__.cpython-312.pyc +0 -0
  57. toolkit/simulator_lib/mqtt_as/clean.py +69 -0
  58. toolkit/simulator_lib/mqtt_as/mqtt_v5_properties.py +239 -0
  59. toolkit/simulator_lib/mqtt_as/range.py +90 -0
  60. toolkit/simulator_lib/mqtt_as/range_ex.py +119 -0
  61. toolkit/simulator_lib/simulator.py +14 -1
  62. toolkit/simulator_lib/uos.py +2 -0
  63. toolkit/workspace/precompiled/Common.mpy +0 -0
  64. toolkit/workspace/precompiled/Config.mpy +0 -0
  65. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  66. toolkit/workspace/precompiled/Files.mpy +0 -0
  67. toolkit/workspace/precompiled/Hooks.mpy +0 -0
  68. toolkit/workspace/precompiled/Logger.mpy +0 -0
  69. toolkit/workspace/precompiled/Network.mpy +0 -0
  70. toolkit/workspace/precompiled/Server.mpy +0 -0
  71. toolkit/workspace/precompiled/Shell.mpy +0 -0
  72. toolkit/workspace/precompiled/Tasks.mpy +0 -0
  73. toolkit/workspace/precompiled/Web.mpy +0 -0
  74. toolkit/workspace/precompiled/config/_git.keep +0 -0
  75. toolkit/workspace/precompiled/micrOS.mpy +0 -0
  76. toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
  77. toolkit/workspace/precompiled/microIO.mpy +0 -0
  78. toolkit/workspace/precompiled/{IO_esp32.mpy → modules/IO_esp32.mpy} +0 -0
  79. toolkit/workspace/precompiled/{IO_esp32c3.mpy → modules/IO_esp32c3.mpy} +0 -0
  80. toolkit/workspace/precompiled/modules/IO_esp32c6.mpy +0 -0
  81. toolkit/workspace/precompiled/{IO_esp32s2.mpy → modules/IO_esp32s2.mpy} +0 -0
  82. toolkit/workspace/precompiled/{IO_esp32s3.mpy → modules/IO_esp32s3.mpy} +0 -0
  83. toolkit/workspace/precompiled/{IO_m5stamp.mpy → modules/IO_m5stamp.mpy} +0 -0
  84. toolkit/workspace/precompiled/{IO_qtpy.mpy → modules/IO_qtpy.mpy} +0 -0
  85. toolkit/workspace/precompiled/modules/IO_rp2.mpy +0 -0
  86. toolkit/workspace/precompiled/modules/IO_s3matrix.mpy +0 -0
  87. toolkit/workspace/precompiled/{IO_tinypico.mpy → modules/IO_tinypico.mpy} +0 -0
  88. toolkit/workspace/precompiled/modules/LM_L298N.mpy +0 -0
  89. toolkit/workspace/precompiled/{LM_OV2640.mpy → modules/LM_OV2640.mpy} +0 -0
  90. toolkit/workspace/precompiled/{LM_aht10.mpy → modules/LM_aht10.mpy} +0 -0
  91. toolkit/workspace/precompiled/{LM_bme280.mpy → modules/LM_bme280.mpy} +0 -0
  92. toolkit/workspace/precompiled/{LM_buzzer.mpy → modules/LM_buzzer.mpy} +0 -0
  93. toolkit/workspace/precompiled/{LM_cct.mpy → modules/LM_cct.mpy} +0 -0
  94. toolkit/workspace/precompiled/modules/LM_cluster.mpy +0 -0
  95. toolkit/workspace/precompiled/{LM_co2.mpy → modules/LM_co2.mpy} +0 -0
  96. toolkit/workspace/precompiled/{LM_dht11.mpy → modules/LM_dht11.mpy} +0 -0
  97. toolkit/workspace/precompiled/{LM_dht22.mpy → modules/LM_dht22.mpy} +0 -0
  98. toolkit/workspace/precompiled/{LM_dimmer.mpy → modules/LM_dimmer.mpy} +0 -0
  99. toolkit/workspace/precompiled/{LM_distance.mpy → modules/LM_distance.mpy} +0 -0
  100. toolkit/workspace/precompiled/{LM_ds18.mpy → modules/LM_ds18.mpy} +0 -0
  101. {micrOS/source → toolkit/workspace/precompiled/modules}/LM_esp32.py +5 -0
  102. toolkit/workspace/precompiled/modules/LM_espnow.py +36 -0
  103. toolkit/workspace/precompiled/{LM_gameOfLife.mpy → modules/LM_gameOfLife.mpy} +0 -0
  104. toolkit/workspace/precompiled/{LM_genIO.mpy → modules/LM_genIO.mpy} +0 -0
  105. toolkit/workspace/precompiled/{LM_haptic.mpy → modules/LM_haptic.mpy} +0 -0
  106. toolkit/workspace/precompiled/{LM_i2c.py → modules/LM_i2c.py} +1 -1
  107. toolkit/workspace/precompiled/{LM_i2s_mic.mpy → modules/LM_i2s_mic.mpy} +0 -0
  108. toolkit/workspace/precompiled/{LM_keychain.mpy → modules/LM_keychain.mpy} +0 -0
  109. toolkit/workspace/precompiled/{LM_ld2410.mpy → modules/LM_ld2410.mpy} +0 -0
  110. toolkit/workspace/precompiled/modules/LM_light_sensor.mpy +0 -0
  111. toolkit/workspace/precompiled/modules/LM_mqtt_client.mpy +0 -0
  112. toolkit/workspace/precompiled/{LM_neoeffects.mpy → modules/LM_neoeffects.mpy} +0 -0
  113. toolkit/workspace/precompiled/modules/LM_neomatrix.mpy +0 -0
  114. toolkit/workspace/precompiled/{LM_neopixel.mpy → modules/LM_neopixel.mpy} +0 -0
  115. toolkit/workspace/precompiled/{LM_oled.mpy → modules/LM_oled.mpy} +0 -0
  116. toolkit/workspace/precompiled/{LM_oled_sh1106.mpy → modules/LM_oled_sh1106.mpy} +0 -0
  117. toolkit/workspace/precompiled/modules/LM_oled_ui.mpy +0 -0
  118. toolkit/workspace/precompiled/modules/LM_oledui.mpy +0 -0
  119. toolkit/workspace/precompiled/modules/LM_pacman.mpy +0 -0
  120. toolkit/workspace/precompiled/modules/LM_presence.mpy +0 -0
  121. toolkit/workspace/precompiled/{LM_rest.mpy → modules/LM_rest.mpy} +0 -0
  122. toolkit/workspace/precompiled/{LM_rgb.mpy → modules/LM_rgb.mpy} +0 -0
  123. toolkit/workspace/precompiled/{LM_rgbcct.mpy → modules/LM_rgbcct.mpy} +0 -0
  124. toolkit/workspace/precompiled/{LM_roboarm.mpy → modules/LM_roboarm.mpy} +0 -0
  125. toolkit/workspace/precompiled/{LM_robustness.py → modules/LM_robustness.py} +49 -2
  126. toolkit/workspace/precompiled/{LM_servo.mpy → modules/LM_servo.mpy} +0 -0
  127. toolkit/workspace/precompiled/{LM_sound_event.mpy → modules/LM_sound_event.mpy} +0 -0
  128. toolkit/workspace/precompiled/{LM_stepper.mpy → modules/LM_stepper.mpy} +0 -0
  129. toolkit/workspace/precompiled/{LM_switch.mpy → modules/LM_switch.mpy} +0 -0
  130. toolkit/workspace/precompiled/{LM_system.mpy → modules/LM_system.mpy} +0 -0
  131. toolkit/workspace/precompiled/{LM_tcs3472.py → modules/LM_tcs3472.py} +4 -6
  132. toolkit/workspace/precompiled/{LM_telegram.mpy → modules/LM_telegram.mpy} +0 -0
  133. toolkit/workspace/precompiled/{LM_tinyrgb.mpy → modules/LM_tinyrgb.mpy} +0 -0
  134. toolkit/workspace/precompiled/{LM_trackball.mpy → modules/LM_trackball.mpy} +0 -0
  135. toolkit/workspace/precompiled/{LM_veml7700.mpy → modules/LM_veml7700.mpy} +0 -0
  136. toolkit/workspace/precompiled/web/dashboard.html +2 -0
  137. toolkit/workspace/precompiled/web/matrix_draw.html +390 -0
  138. toolkit/workspace/precompiled/web/uapi.js +9 -6
  139. micrOS/source/IO_esp32c6.py +0 -16
  140. micrOS/source/LM_L298N_DCmotor.py +0 -86
  141. micrOS/source/LM_espnow.py +0 -57
  142. micrOS/source/LM_mqtt_pro.py +0 -211
  143. toolkit/lib/file_extensions.py +0 -22
  144. toolkit/workspace/precompiled/Common.cpython-312.pyc +0 -0
  145. toolkit/workspace/precompiled/IO_esp32c6.mpy +0 -0
  146. toolkit/workspace/precompiled/IO_rp2.mpy +0 -0
  147. toolkit/workspace/precompiled/IO_s3matrix.mpy +0 -0
  148. toolkit/workspace/precompiled/LM_L298N_DCmotor.mpy +0 -0
  149. toolkit/workspace/precompiled/LM_espnow.py +0 -57
  150. toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
  151. toolkit/workspace/precompiled/LM_mqtt_pro.py +0 -211
  152. toolkit/workspace/precompiled/LM_neomatrix.mpy +0 -0
  153. toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
  154. toolkit/workspace/precompiled/LM_oledui.mpy +0 -0
  155. toolkit/workspace/precompiled/LM_pacman.mpy +0 -0
  156. toolkit/workspace/precompiled/LM_presence.mpy +0 -0
  157. toolkit/workspace/precompiled/Logger.cpython-312.pyc +0 -0
  158. toolkit/workspace/precompiled/Server.cpython-312.pyc +0 -0
  159. /micrOS/source/{IO_esp32.py → modules/IO_esp32.py} +0 -0
  160. /micrOS/source/{IO_esp32c3.py → modules/IO_esp32c3.py} +0 -0
  161. /micrOS/source/{IO_esp32s2.py → modules/IO_esp32s2.py} +0 -0
  162. /micrOS/source/{IO_esp32s3.py → modules/IO_esp32s3.py} +0 -0
  163. /micrOS/source/{IO_m5stamp.py → modules/IO_m5stamp.py} +0 -0
  164. /micrOS/source/{IO_qtpy.py → modules/IO_qtpy.py} +0 -0
  165. /micrOS/source/{IO_rp2.py → modules/IO_rp2.py} +0 -0
  166. /micrOS/source/{IO_s3matrix.py → modules/IO_s3matrix.py} +0 -0
  167. /micrOS/source/{IO_tinypico.py → modules/IO_tinypico.py} +0 -0
  168. /micrOS/source/{LM_L9110_DCmotor.py → modules/LM_L9110_DCmotor.py} +0 -0
  169. /micrOS/source/{LM_OV2640.py → modules/LM_OV2640.py} +0 -0
  170. /micrOS/source/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +0 -0
  171. /micrOS/source/{LM_aht10.py → modules/LM_aht10.py} +0 -0
  172. /micrOS/source/{LM_bme280.py → modules/LM_bme280.py} +0 -0
  173. /micrOS/source/{LM_buzzer.py → modules/LM_buzzer.py} +0 -0
  174. /micrOS/source/{LM_cct.py → modules/LM_cct.py} +0 -0
  175. /micrOS/source/{LM_co2.py → modules/LM_co2.py} +0 -0
  176. /micrOS/source/{LM_dashboard_be.py → modules/LM_dashboard_be.py} +0 -0
  177. /micrOS/source/{LM_dht11.py → modules/LM_dht11.py} +0 -0
  178. /micrOS/source/{LM_dht22.py → modules/LM_dht22.py} +0 -0
  179. /micrOS/source/{LM_dimmer.py → modules/LM_dimmer.py} +0 -0
  180. /micrOS/source/{LM_distance.py → modules/LM_distance.py} +0 -0
  181. /micrOS/source/{LM_ds18.py → modules/LM_ds18.py} +0 -0
  182. /micrOS/source/{LM_gameOfLife.py → modules/LM_gameOfLife.py} +0 -0
  183. /micrOS/source/{LM_genIO.py → modules/LM_genIO.py} +0 -0
  184. /micrOS/source/{LM_haptic.py → modules/LM_haptic.py} +0 -0
  185. /micrOS/source/{LM_i2s_mic.py → modules/LM_i2s_mic.py} +0 -0
  186. /micrOS/source/{LM_keychain.py → modules/LM_keychain.py} +0 -0
  187. /micrOS/source/{LM_ld2410.py → modules/LM_ld2410.py} +0 -0
  188. /micrOS/source/{LM_neopixel.py → modules/LM_neopixel.py} +0 -0
  189. /micrOS/source/{LM_oled.py → modules/LM_oled.py} +0 -0
  190. /micrOS/source/{LM_oled_sh1106.py → modules/LM_oled_sh1106.py} +0 -0
  191. /micrOS/source/{LM_pet_feeder.py → modules/LM_pet_feeder.py} +0 -0
  192. /micrOS/source/{LM_qmi8658.py → modules/LM_qmi8658.py} +0 -0
  193. /micrOS/source/{LM_rencoder.py → modules/LM_rencoder.py} +0 -0
  194. /micrOS/source/{LM_rest.py → modules/LM_rest.py} +0 -0
  195. /micrOS/source/{LM_rgb.py → modules/LM_rgb.py} +0 -0
  196. /micrOS/source/{LM_rgbcct.py → modules/LM_rgbcct.py} +0 -0
  197. /micrOS/source/{LM_roboarm.py → modules/LM_roboarm.py} +0 -0
  198. /micrOS/source/{LM_rp2w.py → modules/LM_rp2w.py} +0 -0
  199. /micrOS/source/{LM_sdcard.py → modules/LM_sdcard.py} +0 -0
  200. /micrOS/source/{LM_servo.py → modules/LM_servo.py} +0 -0
  201. /micrOS/source/{LM_sound_event.py → modules/LM_sound_event.py} +0 -0
  202. /micrOS/source/{LM_stepper.py → modules/LM_stepper.py} +0 -0
  203. /micrOS/source/{LM_switch.py → modules/LM_switch.py} +0 -0
  204. /micrOS/source/{LM_system.py → modules/LM_system.py} +0 -0
  205. /micrOS/source/{LM_telegram.py → modules/LM_telegram.py} +0 -0
  206. /micrOS/source/{LM_tinyrgb.py → modules/LM_tinyrgb.py} +0 -0
  207. /micrOS/source/{LM_trackball.py → modules/LM_trackball.py} +0 -0
  208. /micrOS/source/{LM_veml7700.py → modules/LM_veml7700.py} +0 -0
  209. {microsdevtoolkit-2.13.1.data → microsdevtoolkit-2.17.0.data}/scripts/devToolKit.py +0 -0
  210. {microsdevtoolkit-2.13.1.dist-info → microsdevtoolkit-2.17.0.dist-info}/WHEEL +0 -0
  211. {microsdevtoolkit-2.13.1.dist-info → microsdevtoolkit-2.17.0.dist-info}/licenses/LICENSE +0 -0
  212. {microsdevtoolkit-2.13.1.dist-info → microsdevtoolkit-2.17.0.dist-info}/top_level.txt +0 -0
  213. /toolkit/workspace/precompiled/{LM_L9110_DCmotor.py → modules/LM_L9110_DCmotor.py} +0 -0
  214. /toolkit/workspace/precompiled/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +0 -0
  215. /toolkit/workspace/precompiled/{LM_dashboard_be.py → modules/LM_dashboard_be.py} +0 -0
  216. /toolkit/workspace/precompiled/{LM_pet_feeder.py → modules/LM_pet_feeder.py} +0 -0
  217. /toolkit/workspace/precompiled/{LM_qmi8658.py → modules/LM_qmi8658.py} +0 -0
  218. /toolkit/workspace/precompiled/{LM_rencoder.py → modules/LM_rencoder.py} +0 -0
  219. /toolkit/workspace/precompiled/{LM_rp2w.py → modules/LM_rp2w.py} +0 -0
  220. /toolkit/workspace/precompiled/{LM_sdcard.py → modules/LM_sdcard.py} +0 -0
@@ -1,21 +1,22 @@
1
1
  from sys import modules
2
2
  from Common import socket_stream
3
- from Files import _is_module, list_fs, ilist_fs, remove_fs, OSPath, path_join
3
+ from Files import is_protected, list_fs, ilist_fs, remove_fs, OSPath, path_join
4
4
 
5
5
 
6
6
  #############################################
7
7
  # Safe file system handler functions #
8
8
  #############################################
9
9
 
10
- def ls(path="/", content='*', raw=False, select='*'):
10
+ def ls(path="/", content='*', raw=False, select='*', core=False):
11
11
  """
12
12
  Linux like ls command - list app resources and app folders
13
13
  :param path: path to list, default: /
14
14
  :param content: content type, default all, f-file, d-dir can be selected
15
15
  :param raw: keep raw output [(is_app, type), ...]
16
16
  :param select: select specific app resource: LM or IO, default: all
17
+ :param core: include core system files
17
18
  """
18
- items = list_fs(path, content, select=select)
19
+ items = list_fs(path, content, select=select, core=core)
19
20
  if raw:
20
21
  return items
21
22
 
@@ -39,10 +40,10 @@ def rm(path, allow_dir=False):
39
40
  return remove_fs(path, allow_dir)
40
41
 
41
42
 
42
- def dirtree(path="/", raw=False):
43
+ def dirtree(path="/", raw=False, core=False):
43
44
  """Return only directories from a given path."""
44
45
  path = path if path.endswith('/') else f"{path}/"
45
- folders = [path_join(path, item) for item in ilist_fs(path, type_filter='d')]
46
+ folders = [path_join(path, item) for item in ilist_fs(path, type_filter='d', core=core)]
46
47
  folder_contents = {folder:list_fs(folder) for folder in folders}
47
48
  if raw:
48
49
  return folder_contents
@@ -54,15 +55,40 @@ def dirtree(path="/", raw=False):
54
55
  return formatted_output
55
56
 
56
57
 
58
+ def cat(path):
59
+ """
60
+ Dump any file content
61
+ """
62
+ with open(path, 'r') as f:
63
+ content = f.read()
64
+ return content
65
+
66
+
57
67
  def download(url=None, package=None):
58
68
  """
59
69
  [BETA] Load Module downloader with mip
60
70
  :param url: github url path, ex. BxNxM/micrOS/master/toolkit/workspace/precompiled/LM_robustness.py
61
71
  :param package: mip package name or raw url (hack)
62
72
  """
73
+ def _install(target=None):
74
+ nonlocal url, verdict
75
+ try:
76
+ verdict += f"Install {url}\n"
77
+ if target is None:
78
+ install(url) # Default download: /lib
79
+ else:
80
+ install(url, target=target) # Custom target
81
+ verdict += "\n|- Done"
82
+ except Exception as e:
83
+ verdict += f"|- Cannot install: {url}\n{e}"
84
+ return verdict
85
+
86
+ from mip import install
87
+ verdict = ""
63
88
  if url is None and package is None:
64
89
  return "Nothing to download, url=None package=None"
65
90
  if package is None:
91
+ verdict += "Install from GitHub URL"
66
92
  base_url = "https://raw.githubusercontent.com/"
67
93
  file_name = url.split("/")[-1]
68
94
  if not(file_name.endswith("py") and file_name.startswith("LM_")):
@@ -72,26 +98,19 @@ def download(url=None, package=None):
72
98
  url = url.replace("https://github.com/", base_url).replace("/blob", "")
73
99
  else:
74
100
  url = f"{base_url}{url}"
75
- else:
76
- url = package
77
- from mip import install
78
- verdict = ""
79
- try:
80
- verdict += f"Install {url}\n"
81
- install(url)
82
- verdict += "\n|- Done"
83
- except Exception as e:
84
- verdict += f"|- Cannot install: {url}\n{e}"
85
- return verdict
101
+ return _install(target=OSPath.MODULES) # Install module from Github URL
102
+ url = package
103
+ return _install() # Install official package
86
104
 
87
105
 
88
- def del_duplicates():
106
+ def del_duplicates(migrate=True):
89
107
  """
90
108
  Load module package manager (Not just load modules)
91
109
  - delete duplicated .mpy and .py resources, keep .mpy resource!
92
110
  """
111
+ modules_path = OSPath.MODULES
93
112
  msg_buf = []
94
- files = list_fs(type_filter='f', select='LM')
113
+ files = list_fs(path=modules_path, type_filter='f', select='LM')
95
114
  py = list((res.split('.')[0] for res in files if res.endswith('.py'))) # Normally smaller list
96
115
  mpy = (res.split('.')[0] for res in files if res.endswith('.mpy'))
97
116
  for m in mpy:
@@ -100,11 +119,36 @@ def del_duplicates():
100
119
  if m in py and m != 'main':
101
120
  to_delete = f'{m}.py'
102
121
  try:
103
- verdict = remove_fs(to_delete)
122
+ verdict = remove_fs(path_join(modules_path, to_delete))
104
123
  except:
105
124
  verdict = "n/a"
106
125
  state = False
107
126
  msg_buf.append(f' Delete {to_delete} {state} - {verdict}')
127
+
128
+
129
+ # MIGRATE /ROOT/LMs & IOs -> /modules
130
+ def _migrate_from_root(_rf):
131
+ nonlocal _deleted, files
132
+ if _rf in files:
133
+ remove_fs(path_join(OSPath._ROOT, _rf))
134
+ if _rf in ("LM_pacman.mpy", "LM_system.mpy"):
135
+ # Delete protected LMs from root
136
+ remove(path_join(OSPath._ROOT, _rf))
137
+ _deleted += 1
138
+ else:
139
+ rename(path_join(OSPath._ROOT, _rf), path_join(modules_path, _rf))
140
+ msg_buf.append(f' Move /{_rf} -> modules/{_rf}')
141
+ if migrate:
142
+ from uos import rename, remove
143
+ _deleted = 0
144
+ files = files + list_fs(path=OSPath._ROOT, type_filter='f', select='IO')
145
+ for rf in ilist_fs(path=OSPath._ROOT, type_filter='f', select='LM'):
146
+ _migrate_from_root(rf)
147
+ for rf in ilist_fs(path=OSPath._ROOT, type_filter='f', select='IO'):
148
+ _migrate_from_root(rf)
149
+ if _deleted > 0:
150
+ msg_buf.append(f' Purged (/): {_deleted}')
151
+
108
152
  return '\n'.join(msg_buf) if len(msg_buf) > 0 else 'Nothing to delete.'
109
153
 
110
154
 
@@ -188,7 +232,7 @@ def listmods(msgobj=None):
188
232
  """
189
233
  # Dump available LMs
190
234
  msg_buf = []
191
- for k in (res.replace('LM_', '') for res in ilist_fs(type_filter='f', select='LM')):
235
+ for k in (res.replace('LM_', '') for res in ilist_fs(path=OSPath.MODULES, type_filter='f', select='LM')):
192
236
  if msgobj is None:
193
237
  msg_buf.append(f' {k}')
194
238
  else:
@@ -203,13 +247,14 @@ def delmod(mod):
203
247
  Delete Load Module with full name: module.py or module.mpy
204
248
  OR delete any web resource: *.js, *.css, *.html
205
249
  """
206
- if mod.endswith('py') or _is_module(mod):
207
- try:
208
- to_remove = f'LM_{mod}' if mod.endswith('py') else mod
209
- return remove_fs(to_remove)
210
- except Exception as e:
211
- return f'Cannot delete: {mod}: {e}'
212
- return f'Invalid value: {mod}'
250
+ if mod.endswith('py'):
251
+ to_remove = f'LM_{mod}'
252
+ else:
253
+ return f'Invalid {mod}, must ends with .py or .mpy'
254
+ try:
255
+ return remove_fs(path_join(OSPath.MODULES, to_remove))
256
+ except Exception as e:
257
+ return f'Cannot delete: {mod}: {e}'
213
258
 
214
259
 
215
260
  @socket_stream
@@ -218,7 +263,7 @@ def micros_checksum(msgobj=None):
218
263
  from binascii import hexlify
219
264
  from Config import cfgget
220
265
 
221
- for f_name in ilist_fs(type_filter='f', select='LM'):
266
+ for f_name in ilist_fs(path=OSPath.MODULES, type_filter='f', select='LM'):
222
267
  with open(f_name, 'rb') as f:
223
268
  cs = hexlify(sha1(f.read()).digest()).decode('utf-8')
224
269
  msgobj(f"{cs} {f_name}")
@@ -233,7 +278,7 @@ def help(widgets=False):
233
278
  (widgets=False) list of functions implemented by this application
234
279
  (widgets=True) list of widget json for UI generation
235
280
  """
236
- return ('listmods', 'delmod mod=<module>.py/.mpy or .js/.html/.css', 'del_duplicates',
281
+ return ('listmods', 'delmod mod=<module>.py/.mpy', 'del_duplicates',
237
282
  'moduls unload="LM_rgb/None"',
238
283
  'cachedump delete=None',
239
284
  'datdump',
@@ -67,7 +67,7 @@ def __run_intercon(state):
67
67
  host = cmd[0]
68
68
  cmd = cmd[1:]
69
69
  # Send CMD to other device
70
- state, _ = exec_cmd(cmd + [f">>{host}"], jsonify=True, skip_check=True)
70
+ state, _ = exec_cmd(cmd + [f">>{host}"], jsonify=True)
71
71
  except Exception as e:
72
72
  syslog(f"__run_intercon error: {e}")
73
73
  if state.lower() == "off":
@@ -78,7 +78,7 @@ def __run_intercon(state):
78
78
  host = cmd[0]
79
79
  cmd = cmd[1:]
80
80
  # Send CMD to other device
81
- state, _ = exec_cmd(cmd + [f">>{host}"], jsonify=True, skip_check=True)
81
+ state, _ = exec_cmd(cmd + [f">>{host}"], jsonify=True)
82
82
  except Exception as e:
83
83
  syslog(f"__run_intercon error: {e}")
84
84
 
@@ -1,5 +1,5 @@
1
1
  from LM_system import memory_usage
2
- from Common import socket_stream, syslog
2
+ from Common import socket_stream, syslog, micro_task
3
3
 
4
4
 
5
5
  @socket_stream
@@ -61,6 +61,52 @@ def _recursion(cnt, msgobj=None):
61
61
  remain = 0
62
62
  return remain
63
63
 
64
+ ################## TEST micro_task UCs ##########################
65
+
66
+ async def __task(tag, period_ms):
67
+ counter = 0
68
+ with micro_task(tag=tag) as my_task:
69
+ while True:
70
+ # DO something here in the async loop...
71
+ counter += 1
72
+
73
+ # Store data in task cache (task show mytask)
74
+ my_task.out = f'MyTask Counter: {counter}'
75
+
76
+ # Async sleep - feed event loop
77
+ await my_task.feed(sleep_ms=period_ms)
78
+ # [i] feed same as "await asyncio.sleep_ms(period_ms)" with micrOS features (WDT)
79
+
80
+ def create_task():
81
+ """
82
+ Legacy way of task creation (with exact task tagging)
83
+ """
84
+ # [!] ASYNC TASK CREATION [1*] with async task callback + taskID (TAG) handling
85
+ task_tag = "microtask.run"
86
+ state = micro_task(tag=task_tag, task=__task(tag=task_tag, period_ms=5))
87
+ return "Starting" if state else "Already running"
88
+
89
+
90
+ @micro_task("microtask", _wrap=True)
91
+ async def mytask(tag, period_ms=30):
92
+ """
93
+ New shorter way of task creation
94
+ with decorator function
95
+ """
96
+ counter = 0
97
+ with micro_task(tag=tag) as my_task:
98
+ while True:
99
+ # DO something here in the async loop...
100
+ counter += 1
101
+
102
+ # Store data in task cache (task show mytask)
103
+ my_task.out = f'MyTask Counter: {counter}'
104
+
105
+ # Async sleep - feed event loop
106
+ await my_task.feed(sleep_ms=period_ms)
107
+ # [i] feed same as "await asyncio.sleep_ms(period_ms)" with micrOS features (WDT)
108
+
109
+ ##############################################################################
64
110
 
65
111
  def help(widgets=False):
66
112
  """
@@ -70,5 +116,6 @@ def help(widgets=False):
70
116
  (widgets=True) list of widget json for UI generation
71
117
  """
72
118
  return 'NOTE: This is a test module to validate system robustness', \
73
- 'raise_error', 'memory_leak cnt=160', 'recursion_limit cnt=14'
119
+ 'raise_error', 'memory_leak cnt=160', 'recursion_limit cnt=14', \
120
+ 'create_task', 'mytask'
74
121
 
@@ -17,20 +17,15 @@ class TCS3472:
17
17
  def __init__(self, bus, address=0x29):
18
18
  self._bus = bus
19
19
  self._i2c_address = address
20
-
21
- self._bus.start()
22
-
23
20
  self._bus.writeto(self._i2c_address, b'\x80\x03')
24
21
  self._bus.writeto(self._i2c_address, b'\x81\x2b')
25
-
26
22
  TCS3472.INSTANCE = self
27
23
 
28
24
  def scaled(self):
29
25
  crgb = self.raw()
30
26
  if crgb[0] > 0:
31
27
  return tuple(float(x) / crgb[0] for x in crgb[1:])
32
-
33
- return (0, 0, 0)
28
+ return 0, 0, 0
34
29
 
35
30
  def rgb(self):
36
31
  return tuple(int(x * 255) for x in self.scaled())
@@ -72,4 +67,7 @@ def measure():
72
67
 
73
68
 
74
69
  def help(widgest=False):
70
+ """
71
+ TCS3472 Color sensor
72
+ """
75
73
  return 'load', 'measure'
@@ -38,6 +38,7 @@
38
38
  </head>
39
39
  <body>
40
40
  <h1> micrOS dashboard </h1>
41
+ <p id="restInfo"></p>
41
42
  <!-- Container for the dynamically generated list -->
42
43
  <section id="widgets-section"></section>
43
44
  <br><br><br>
@@ -54,6 +55,7 @@
54
55
  <script>
55
56
  document.addEventListener("DOMContentLoaded", function() {
56
57
  // Init basic info from board after DOM is fully loaded
58
+ restInfo(showPages=false);
57
59
 
58
60
  // INIT DASHBOARD (load active modules -> build page)
59
61
  DynamicWidgetLoad();