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

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

Potentially problematic release.


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

Files changed (151) hide show
  1. env/driver_cp210x/macOS_VCP_Driver/SiLabsUSBDriverDisk.dmg +0 -0
  2. env/driver_cp210x/macOS_VCP_Driver/macOS_VCP_Driver_Release_Notes.txt +17 -1
  3. micrOS/micropython/esp32c6-GENERIC-20250415-v1.25.0.bin +0 -0
  4. micrOS/micropython/esp32s3-4MBflash-20241129-v1.24.1.bin +0 -0
  5. micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +57 -61
  6. micrOS/source/Common.py +286 -91
  7. micrOS/source/Config.py +7 -7
  8. micrOS/source/Debug.py +50 -94
  9. micrOS/source/Espnow.py +7 -7
  10. micrOS/source/Files.py +23 -2
  11. micrOS/source/Hooks.py +62 -19
  12. micrOS/source/IO_esp32c6.py +16 -0
  13. micrOS/source/IO_esp32s3.py +37 -1
  14. micrOS/source/IO_m5stamp.py +35 -1
  15. micrOS/source/IO_qtpy.py +22 -17
  16. micrOS/source/IO_s3matrix.py +21 -0
  17. micrOS/source/IO_tinypico.py +38 -0
  18. micrOS/source/InterConnect.py +5 -5
  19. micrOS/source/Interrupts.py +2 -2
  20. micrOS/source/LM_VL53L0X.py +1 -1
  21. micrOS/source/LM_buzzer.py +6 -7
  22. micrOS/source/LM_cct.py +6 -5
  23. micrOS/source/LM_dashboard_be.py +2 -2
  24. micrOS/source/LM_dimmer.py +6 -5
  25. micrOS/source/LM_espnow.py +15 -10
  26. micrOS/source/LM_i2c.py +3 -2
  27. micrOS/source/LM_neoeffects.py +173 -230
  28. micrOS/source/LM_neomatrix.py +335 -0
  29. micrOS/source/LM_neopixel.py +10 -10
  30. micrOS/source/LM_pacman.py +40 -23
  31. micrOS/source/LM_qmi8658.py +204 -0
  32. micrOS/source/LM_rgb.py +6 -6
  33. micrOS/source/LM_roboarm.py +5 -4
  34. micrOS/source/LM_switch.py +6 -4
  35. micrOS/source/LM_tcs3472.py +75 -0
  36. micrOS/source/LM_telegram.py +5 -4
  37. micrOS/source/Logger.py +47 -33
  38. micrOS/source/Network.py +6 -6
  39. micrOS/source/Notify.py +2 -2
  40. micrOS/source/Scheduler.py +5 -5
  41. micrOS/source/Server.py +6 -6
  42. micrOS/source/Shell.py +4 -4
  43. micrOS/source/Tasks.py +20 -17
  44. micrOS/source/Time.py +12 -10
  45. micrOS/source/Types.py +2 -2
  46. micrOS/source/Web.py +20 -13
  47. micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
  48. micrOS/source/__pycache__/Debug.cpython-312.pyc +0 -0
  49. micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
  50. micrOS/source/__pycache__/Server.cpython-312.pyc +0 -0
  51. micrOS/source/micrOS.py +10 -7
  52. micrOS/source/micrOSloader.py +6 -6
  53. micrOS/source/microIO.py +8 -6
  54. micrOS/source/urequests.py +4 -4
  55. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.13.0.dist-info}/METADATA +24 -22
  56. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.13.0.dist-info}/RECORD +142 -132
  57. toolkit/DevEnvCompile.py +20 -15
  58. toolkit/DevEnvOTA.py +29 -8
  59. toolkit/DevEnvUSB.py +52 -10
  60. toolkit/LM_to_compile.dat +1 -0
  61. toolkit/MicrOSDevEnv.py +10 -2
  62. toolkit/MicrosFiles.py +26 -0
  63. toolkit/dashboard_apps/NeoEffectsDemo.py +8 -15
  64. toolkit/dashboard_apps/QMI8685_GYRO.py +68 -0
  65. toolkit/dashboard_apps/_app_base.py +2 -2
  66. toolkit/dashboard_apps/_gyro_visualizer.py +78 -0
  67. toolkit/lib/LocalMachine.py +6 -1
  68. toolkit/lib/file_extensions.py +9 -3
  69. toolkit/micrOSlint.py +3 -1
  70. toolkit/simulator_lib/__pycache__/IO_darwin.cpython-312.pyc +0 -0
  71. toolkit/simulator_lib/__pycache__/machine.cpython-312.pyc +0 -0
  72. toolkit/simulator_lib/__pycache__/neopixel.cpython-312.pyc +0 -0
  73. toolkit/simulator_lib/machine.py +0 -1
  74. toolkit/simulator_lib/neopixel.py +3 -2
  75. toolkit/socketClient.py +3 -2
  76. toolkit/workspace/precompiled/Common.cpython-312.pyc +0 -0
  77. toolkit/workspace/precompiled/Common.mpy +0 -0
  78. toolkit/workspace/precompiled/Config.mpy +0 -0
  79. toolkit/workspace/precompiled/Debug.mpy +0 -0
  80. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  81. toolkit/workspace/precompiled/Files.mpy +0 -0
  82. toolkit/workspace/precompiled/Hooks.mpy +0 -0
  83. toolkit/workspace/precompiled/IO_esp32c6.mpy +0 -0
  84. toolkit/workspace/precompiled/IO_esp32s3.mpy +0 -0
  85. toolkit/workspace/precompiled/IO_m5stamp.mpy +0 -0
  86. toolkit/workspace/precompiled/IO_qtpy.mpy +0 -0
  87. toolkit/workspace/precompiled/IO_s3matrix.mpy +0 -0
  88. toolkit/workspace/precompiled/IO_tinypico.mpy +0 -0
  89. toolkit/workspace/precompiled/InterConnect.mpy +0 -0
  90. toolkit/workspace/precompiled/Interrupts.mpy +0 -0
  91. toolkit/workspace/precompiled/LM_VL53L0X.py +1 -1
  92. toolkit/workspace/precompiled/LM_buzzer.mpy +0 -0
  93. toolkit/workspace/precompiled/LM_cct.mpy +0 -0
  94. toolkit/workspace/precompiled/LM_dashboard_be.py +2 -2
  95. toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
  96. toolkit/workspace/precompiled/LM_espnow.py +15 -10
  97. toolkit/workspace/precompiled/LM_i2c.py +3 -2
  98. toolkit/workspace/precompiled/LM_neoeffects.mpy +0 -0
  99. toolkit/workspace/precompiled/LM_neomatrix.mpy +0 -0
  100. toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
  101. toolkit/workspace/precompiled/LM_pacman.mpy +0 -0
  102. toolkit/workspace/precompiled/LM_qmi8658.py +204 -0
  103. toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
  104. toolkit/workspace/precompiled/LM_roboarm.mpy +0 -0
  105. toolkit/workspace/precompiled/LM_switch.mpy +0 -0
  106. toolkit/workspace/precompiled/LM_tcs3472.py +75 -0
  107. toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
  108. toolkit/workspace/precompiled/Logger.cpython-312.pyc +0 -0
  109. toolkit/workspace/precompiled/Logger.mpy +0 -0
  110. toolkit/workspace/precompiled/Network.mpy +0 -0
  111. toolkit/workspace/precompiled/Notify.mpy +0 -0
  112. toolkit/workspace/precompiled/Scheduler.mpy +0 -0
  113. toolkit/workspace/precompiled/Server.cpython-312.pyc +0 -0
  114. toolkit/workspace/precompiled/Server.mpy +0 -0
  115. toolkit/workspace/precompiled/Shell.mpy +0 -0
  116. toolkit/workspace/precompiled/Tasks.mpy +0 -0
  117. toolkit/workspace/precompiled/Time.mpy +0 -0
  118. toolkit/workspace/precompiled/Types.mpy +0 -0
  119. toolkit/workspace/precompiled/Web.mpy +0 -0
  120. toolkit/workspace/precompiled/micrOS.mpy +0 -0
  121. toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
  122. toolkit/workspace/precompiled/microIO.mpy +0 -0
  123. toolkit/workspace/precompiled/urequests.mpy +0 -0
  124. micrOS/micropython/esp32s3-20240105-v1.22.1.bin +0 -0
  125. micrOS/source/LM_catgame.py +0 -75
  126. micrOS/source/LM_demo.py +0 -97
  127. micrOS/source/LM_intercon.py +0 -60
  128. micrOS/source/LM_ph_sensor.py +0 -51
  129. toolkit/workspace/precompiled/LM_catgame.py +0 -75
  130. toolkit/workspace/precompiled/LM_demo.py +0 -97
  131. toolkit/workspace/precompiled/LM_intercon.mpy +0 -0
  132. toolkit/workspace/precompiled/LM_ph_sensor.py +0 -51
  133. /micrOS/micropython/{esp32s3-20241129-v1.24.1.bin → esp32s3-8MBflash-20241129-v1.24.1.bin} +0 -0
  134. /micrOS/source/{dashboard.html → web/dashboard.html} +0 -0
  135. /micrOS/source/{index.html → web/index.html} +0 -0
  136. /micrOS/source/{uapi.js → web/uapi.js} +0 -0
  137. /micrOS/source/{udashboard.js → web/udashboard.js} +0 -0
  138. /micrOS/source/{ustyle.css → web/ustyle.css} +0 -0
  139. /micrOS/source/{uwidgets.js → web/uwidgets.js} +0 -0
  140. /micrOS/source/{uwidgets_pro.js → web/uwidgets_pro.js} +0 -0
  141. {microsdevtoolkit-2.10.6.data → microsdevtoolkit-2.13.0.data}/scripts/devToolKit.py +0 -0
  142. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.13.0.dist-info}/WHEEL +0 -0
  143. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.13.0.dist-info}/licenses/LICENSE +0 -0
  144. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.13.0.dist-info}/top_level.txt +0 -0
  145. /toolkit/workspace/precompiled/{dashboard.html → web/dashboard.html} +0 -0
  146. /toolkit/workspace/precompiled/{index.html → web/index.html} +0 -0
  147. /toolkit/workspace/precompiled/{uapi.js → web/uapi.js} +0 -0
  148. /toolkit/workspace/precompiled/{udashboard.js → web/udashboard.js} +0 -0
  149. /toolkit/workspace/precompiled/{ustyle.css → web/ustyle.css} +0 -0
  150. /toolkit/workspace/precompiled/{uwidgets.js → web/uwidgets.js} +0 -0
  151. /toolkit/workspace/precompiled/{uwidgets_pro.js → web/uwidgets_pro.js} +0 -0
micrOS/source/Espnow.py CHANGED
@@ -4,7 +4,7 @@ from Tasks import NativeTask, TaskBase, lm_exec, lm_is_loaded
4
4
  import uasyncio as asyncio
5
5
  from Network import get_mac
6
6
  from Config import cfgget
7
- from Debug import errlog_add
7
+ from Debug import syslog
8
8
 
9
9
 
10
10
  # ----------- PARSE AND RENDER MSG PROTOCOL --------------
@@ -14,7 +14,7 @@ def render_response(tid, oper, data, prompt) -> str:
14
14
  Render ESPNow custom message (protocol)
15
15
  """
16
16
  if oper not in ("REQ", "RSP"):
17
- errlog_add(f"[ERR] espnow render_response, unknown oper: {oper}")
17
+ syslog(f"[ERR] espnow render_response, unknown oper: {oper}")
18
18
  tmp = "{tid}|{oper}|{data}|{prompt}$"
19
19
  tmp = tmp.replace("{tid}", str(tid))
20
20
  tmp = tmp.replace("{oper}", str(oper))
@@ -68,7 +68,7 @@ class ResponseRouter:
68
68
  # USE <tid> for proper session response mapping
69
69
  router = ResponseRouter._routes.get(mac)
70
70
  if router is None:
71
- errlog_add(f"[WARN][ESPNOW] No response route for {mac}")
71
+ syslog(f"[WARN][ESPNOW] No response route for {mac}")
72
72
  return
73
73
  router.response = response
74
74
  router._event.set()
@@ -157,7 +157,7 @@ class ESPNowSS:
157
157
  if state:
158
158
  await self.__asend_raw(mac, response)
159
159
  else:
160
- errlog_add(response)
160
+ syslog(response)
161
161
  except OSError as err:
162
162
  # If the peer is not yet added, add it and retry.
163
163
  if len(err.args) > 1 and err.args[1] == 'ESP_ERR_ESPNOW_NOT_FOUND':
@@ -166,10 +166,10 @@ class ESPNowSS:
166
166
  if state:
167
167
  await self.__asend_raw(mac, response)
168
168
  else:
169
- errlog_add(response)
169
+ syslog(response)
170
170
  else:
171
171
  # Optionally handle or log other OSErrors here.
172
- errlog_add(f"[ERR][NOW SERVER] {err}")
172
+ syslog(f"[ERR][NOW SERVER] {err}")
173
173
 
174
174
  def start_server(self):
175
175
  """
@@ -225,7 +225,7 @@ class ESPNowSS:
225
225
  peer_name = hexlify(peer, ':').decode() if peer_name is None else peer_name
226
226
  task_id = f"con.espnow.{peer_name}"
227
227
  # Create an asynchronous sending task.
228
- state = NativeTask().create(callback=INSTANCE._asend_task(peer, task_id, msg), tag=task_id)
228
+ state = NativeTask().create(callback=self._asend_task(peer, task_id, msg), tag=task_id)
229
229
  return "Starting" if state else "Already running"
230
230
 
231
231
  # ----------- OTHER METHODS --------------
micrOS/source/Files.py CHANGED
@@ -1,4 +1,4 @@
1
- from uos import ilistdir, remove, stat
1
+ from uos import ilistdir, remove, stat, getcwd
2
2
 
3
3
  ################################ Helper functions #####################################
4
4
 
@@ -9,7 +9,7 @@ def _is_module(path:str='/', pyprefix:str='*') -> bool:
9
9
  :param pyprefix: python resource filter prefix, default: * (all: LM and IO)
10
10
  """
11
11
  # micrOS file types
12
- allowed_exts = ('html', 'js', 'css', 'log', 'pds', 'dat')
12
+ allowed_exts = ('html', 'js', 'css', 'log', 'cache', 'dat')
13
13
  mod_prefixes = ('LM', "IO")
14
14
  fname = path.split("/")[-1]
15
15
  if fname.split("_")[0] in mod_prefixes or fname.split('.')[-1] in allowed_exts:
@@ -99,3 +99,24 @@ def is_file(path):
99
99
  return stat(path)[0] & 0x8000
100
100
  except OSError:
101
101
  return False
102
+
103
+
104
+ def path_join(*parts):
105
+ path = "/".join(part.strip("/") for part in parts if part)
106
+ if parts and parts[0].startswith("/"):
107
+ path = "/" + path
108
+ return path
109
+
110
+
111
+ # micrOS system file structure
112
+ class OSPath:
113
+ _ROOT = getcwd()
114
+ LOGS = path_join(_ROOT, '/logs') # Logs (.log)
115
+ DATA = path_join(_ROOT,'/data') # Application data (.dat, .cache, etc.)
116
+ WEB = path_join(_ROOT,'/web') # Web resources (.html, .css, .js, .json, etc.)
117
+ MODULES = path_join(_ROOT, '/modules') # Application modules (.mpy, .py) (todo)
118
+ CONFIG = path_join(_ROOT, '/config') # System configuration files (node_config.json, etc.)(todo)
119
+
120
+ @property
121
+ def ROOT(self):
122
+ return self._ROOT
micrOS/source/Hooks.py CHANGED
@@ -19,8 +19,10 @@ Designed by Marcell Ban aka BxNxM
19
19
  #################################################################
20
20
  from Config import cfgget, cfgput
21
21
  from microIO import detect_platform
22
- from Debug import console_write, errlog_add
22
+ from Debug import console_write, syslog
23
23
  from Tasks import exec_lm_pipe
24
+ from Files import OSPath, is_dir
25
+ from uos import mkdir
24
26
  from micropython import mem_info
25
27
  from machine import freq
26
28
  try:
@@ -43,7 +45,7 @@ def bootup():
43
45
  """
44
46
  # Execute LMs from boothook config parameter
45
47
  console_write("[BOOT] EXECUTION...")
46
- boot_cause()
48
+ _init_micros_dirs()
47
49
  bootasks = cfgget('boothook')
48
50
  if bootasks is not None and bootasks.lower() != 'n/a':
49
51
  console_write(f"|-[BOOT] TASKS: {bootasks}")
@@ -52,25 +54,34 @@ def bootup():
52
54
  else:
53
55
  console_write("|-[BOOT] ERROR")
54
56
 
55
- # Set boostmd (boost mode)
56
- platform = detect_platform()
57
- if cfgget('boostmd') is True:
58
- console_write(f"[BOOT HOOKS] Set up CPU high Hz - boostmd: {cfgget('boostmd')}")
59
- if platform == 'esp32c3':
60
- freq(160_000_000) # 160 Mhz (max)
61
- elif 'esp32' in platform:
62
- freq(240_000_000) # 240 Mhz (max)
63
- else:
64
- console_write(f"[BOOT HOOKS] Set up CPU low Hz - boostmd: {cfgget('boostmd')}")
65
- if platform == 'esp32c3':
66
- freq(80_000_000) # 80 Mhz / Half the max CPU clock
67
- elif 'esp32' in platform:
68
- freq(160_000_000) # 160 Mhz / Half the max CPU clock
57
+ # Load and Save boot cause
58
+ boot_cause()
69
59
  # Autotune queue size
70
- tune_queue_size()
60
+ _tune_queue_size()
61
+ # Configure CPU performance
62
+ _tune_performance()
63
+
64
+
65
+ def _init_micros_dirs():
66
+ """
67
+ Init micrOS root file system directories
68
+ """
69
+ root_dirs = [
70
+ getattr(OSPath, key)
71
+ for key in dir(OSPath)
72
+ if not key.startswith("_") and isinstance(getattr(OSPath, key), str)
73
+ ]
74
+ console_write(f"|-[BOOT] rootFS validation: {root_dirs}")
75
+ for dir_path in root_dirs:
76
+ if not is_dir(dir_path):
77
+ try:
78
+ mkdir(dir_path)
79
+ syslog(f"[BOOT] init dir: {dir_path}")
80
+ except Exception as e:
81
+ syslog(f"[ERR][BOOT] cannot init dir {dir_path}: {e}")
71
82
 
72
83
 
73
- def tune_queue_size():
84
+ def _tune_queue_size():
74
85
  """
75
86
  Tune queue size based on available ram
76
87
  between 5-50
@@ -84,6 +95,23 @@ def tune_queue_size():
84
95
  cfgput('aioqueue', est_queue)
85
96
 
86
97
 
98
+ def _tune_performance():
99
+ # Set boosted (boost mode)
100
+ platform = detect_platform()
101
+ if cfgget('boostmd') is True:
102
+ console_write(f"[BOOT HOOKS] Set up CPU high Hz - boostmd: {cfgget('boostmd')}")
103
+ if platform == 'esp32c3':
104
+ freq(160_000_000) # 160 Mhz (max)
105
+ elif 'esp32' in platform:
106
+ freq(240_000_000) # 240 Mhz (max)
107
+ else:
108
+ console_write(f"[BOOT HOOKS] Set up CPU low Hz - boostmd: {cfgget('boostmd')}")
109
+ if platform == 'esp32c3':
110
+ freq(80_000_000) # 80 Mhz / Half the max CPU clock
111
+ elif 'esp32' in platform:
112
+ freq(160_000_000) # 160 Mhz / Half the max CPU clock
113
+
114
+
87
115
  def profiling_info(label=""):
88
116
  """
89
117
  Runtime memory measurements
@@ -109,5 +137,20 @@ def boot_cause():
109
137
  reason = 4, "DSWakeUp"
110
138
  elif reset_reason == SOFT_RESET:
111
139
  reason = 5, "SoftReset"
112
- errlog_add(f"[BOOT] info: {reason[1]}")
140
+ syslog(f"[BOOT] info: {reason[1]}")
113
141
  return reason
142
+
143
+
144
+ def enableESPNow() -> str:
145
+ """
146
+ Enable ESP-NOW communication
147
+ """
148
+ if cfgget('espnow'):
149
+ try:
150
+ from Espnow import ESPNowSS
151
+ verdict = ESPNowSS().start_server()
152
+ console_write(f"[TASK] Start ESPNow-InterCon server: {verdict}")
153
+ except Exception as e:
154
+ syslog(f"[ERR] Start ESPNow-InterCon server: {e}")
155
+ return str(e)
156
+ return "ESPNow disabled"
@@ -0,0 +1,16 @@
1
+ from micropython import const
2
+
3
+ # BUILTIN LED
4
+ builtin = const(-15) # BUILT IN LED - progress_led
5
+
6
+
7
+ # I2C BUS
8
+ i2c_sda = const(4) # D21 - oled - data
9
+ i2c_scl = const(5) # D22 - oled - clock
10
+
11
+
12
+ # EXTERNAL EVENT IRQ
13
+ irq1 = const(3) # D4 - event irq pin
14
+ irq2 = const(2) # D18 - event irq pin
15
+ irq3 = const(1) # D19 - event irq pin
16
+ irq4 = const(0) # D13 - event irq pin
@@ -1,7 +1,43 @@
1
1
  from micropython import const
2
2
 
3
+ #### DEFINE CUSTOM PROGRESS LED LOGIC ####
4
+ class WS2812:
5
+ NEOPIXEL = None
6
+ WHEEL = None
7
+ PIN = const(38) # BUILT IN LED - progress_led
8
+
9
+ try:
10
+ # init ws2812
11
+ from machine import Pin
12
+ from neopixel import NeoPixel
13
+ WS2812.NEOPIXEL = NeoPixel(Pin(WS2812.PIN), 1)
14
+ except Exception as e:
15
+ print(f"[Error] IO error, esp21se ws2812: {e}")
16
+
17
+
18
+ def _step_ws2812(pin=False):
19
+ if pin:
20
+ return WS2812.PIN
21
+
22
+ def _color_wheel():
23
+ while True:
24
+ yield 10, 0, 0
25
+ yield 5, 5, 0
26
+ yield 0, 10, 0
27
+ yield 0, 5, 5
28
+ yield 0, 0, 10
29
+ yield 5, 0, 5
30
+
31
+ if WS2812.WHEEL is None:
32
+ WS2812.WHEEL = _color_wheel()
33
+ WS2812.NEOPIXEL[0] = next(WS2812.WHEEL)
34
+ WS2812.NEOPIXEL.write()
35
+ return True # No double-blink
36
+
37
+ #######################################
38
+
3
39
  # BUILTIN LED
4
- builtin = const(38) # BUILT IN LED - progress_led
40
+ builtin = _step_ws2812 # BUILT IN LED - progress_led
5
41
 
6
42
  # ANALOG RGB + WW + CW
7
43
  redgb = const(37) # - rgb red channel [PWM]
@@ -1,7 +1,41 @@
1
1
  from micropython import const
2
2
 
3
+ #### DEFINE CUSTOM PROGRESS LED LOGIC ####
4
+ class WS2812:
5
+ NEOPIXEL = None
6
+ WHEEL = None
7
+ PIN = const(21) # BUILT IN LED - progress_led
8
+
9
+ try:
10
+ # init ws2812
11
+ from machine import Pin
12
+ from neopixel import NeoPixel
13
+ WS2812.NEOPIXEL = NeoPixel(Pin(WS2812.PIN), 1)
14
+ except Exception as e:
15
+ print(f"[Error] IO error, esp21se ws2812: {e}")
16
+
17
+
18
+ def _step_ws2812(pin=False):
19
+ if pin:
20
+ return WS2812.PIN
21
+
22
+ def _color_wheel():
23
+ while True:
24
+ yield 10, 0, 0
25
+ yield 5, 5, 0
26
+ yield 0, 10, 0
27
+ yield 0, 5, 5
28
+ yield 0, 0, 10
29
+ yield 5, 0, 5
30
+
31
+ if WS2812.WHEEL is None:
32
+ WS2812.WHEEL = _color_wheel()
33
+ WS2812.NEOPIXEL[0] = next(WS2812.WHEEL)
34
+ WS2812.NEOPIXEL.write()
35
+ return True # No double-blink
36
+
3
37
  # BUILTIN LED
4
- builtin = const(21) # BUILT IN LED - progress_led
38
+ builtin = _step_ws2812 # BUILT IN LED - progress_led
5
39
 
6
40
  # ANALOG RGB + WW + CW
7
41
  redgb = const(43) # - rgb red channel [PWM]
micrOS/source/IO_qtpy.py CHANGED
@@ -1,20 +1,26 @@
1
1
  from micropython import const
2
- from machine import Pin
3
-
4
2
 
5
3
  #### DEFINE CUSTOM PROGRESS LED LOGIC ####
4
+ class WS2812:
5
+ NEOPIXEL = None
6
+ WHEEL = None
7
+ PIN = const(5) # BUILT IN LED - progress_led
8
+ PIN_ENABLE = const(8) # Power ON LED
9
+
6
10
  try:
11
+ # init ws2812
7
12
  from neopixel import NeoPixel
8
- Pin(8, Pin.OUT).value(1) # Power ON LED
9
- PLED_OBJ = NeoPixel(Pin(5), 1) # Init neopixel
10
- NEO_WHEEL = None
13
+ from machine import Pin
14
+ Pin(WS2812.PIN_ENABLE, Pin.OUT).value(1) # Power ON LED
15
+ WS2812.NEOPIXEL = NeoPixel(Pin(WS2812.PIN), 1) # BUILT IN LED - progress_led
11
16
  except Exception as e:
12
- print(f"[PLED CUSTOM] ws2812 error: {e}")
13
- PLED_OBJ = None
17
+ print(f"[Error] IO error, esp21se ws2812: {e}")
18
+
14
19
 
20
+ def _step_ws2812(pin=False):
21
+ if pin:
22
+ return WS2812.PIN
15
23
 
16
- def _step_ws2812():
17
- global PLED_OBJ, NEO_WHEEL
18
24
  def _color_wheel():
19
25
  while True:
20
26
  yield 10, 0, 0
@@ -23,15 +29,14 @@ def _step_ws2812():
23
29
  yield 0, 5, 5
24
30
  yield 0, 0, 10
25
31
  yield 5, 0, 5
26
- if PLED_OBJ is None:
27
- return False
28
- if NEO_WHEEL is None:
29
- NEO_WHEEL = _color_wheel()
30
- PLED_OBJ[0] = next(NEO_WHEEL)
31
- PLED_OBJ.write()
32
- return True
33
- ###########################################
34
32
 
33
+ if WS2812.WHEEL is None:
34
+ WS2812.WHEEL = _color_wheel()
35
+ WS2812.NEOPIXEL[0] = next(WS2812.WHEEL)
36
+ WS2812.NEOPIXEL.write()
37
+ return True # No double-blink
38
+
39
+ ###########################################
35
40
 
36
41
  # BUILTIN LED
37
42
  builtin = _step_ws2812
@@ -0,0 +1,21 @@
1
+ from micropython import const
2
+
3
+ # ESP32-S3 Matrix 8x8 RGB-LED WiFi Bluetooth With QST Attitude Gyro Sensor QMI8658C
4
+ # https://spotpear.com/shop/ESP32-S3FH4R2-Matrix-8x8-RGB-LED-WiFi-Bluetooth-QST-Attitude-Gyro-Sensor-QMI8658C-Arduino-Python-ESP-IDF.html
5
+
6
+ # Progress LED (no builting available)
7
+ builtin = const(1) # LED - progress_led
8
+
9
+ # DIGITAL LED
10
+ neop = const(14) # - neopixel OneWire bus [PWM]
11
+
12
+ # I2C BUS (QMI8658C GYRO)
13
+ i2c_sda = const(11) # - data
14
+ i2c_scl = const(12) # - clock
15
+
16
+
17
+ # EXTERNAL EVENT IRQ
18
+ irq1 = const(33) # - event irq pin
19
+ irq2 = const(34) # - event irq pin
20
+ irq3 = const(35) # - event irq pin
21
+ irq4 = const(36) # - event irq pin
@@ -1,5 +1,43 @@
1
1
  from micropython import const
2
2
 
3
+ #### DEFINE CUSTOM PROGRESS LED LOGIC ####
4
+ class APA102:
5
+ DOTSTAR = None
6
+ COLOR_WHEEL = None
7
+ COLOR_INDEX:int = 0
8
+
9
+ try:
10
+ # init apa102
11
+ from machine import Pin
12
+ from machine import SoftSPI
13
+ from dotstar import DotStar
14
+ from tinypico import DOTSTAR_CLK, DOTSTAR_DATA, SPI_MISO, set_dotstar_power, dotstar_color_wheel
15
+ spi = SoftSPI(sck=Pin(DOTSTAR_CLK), mosi=Pin(DOTSTAR_DATA), miso=Pin(SPI_MISO))
16
+ # Create a DotStar instance
17
+ APA102.DOTSTAR = DotStar(spi, 1, brightness=0.4) # Just one DotStar, half brightness
18
+ # Turn on the power to the DotStar
19
+ set_dotstar_power(True)
20
+ APA102.COLOR_WHEEL = dotstar_color_wheel
21
+ except Exception as e:
22
+ print(f"[Error] IO error, tinypico apa102: {e}")
23
+
24
+ def _step_apa102(pin=False):
25
+ if pin:
26
+ return None
27
+ # Get the R,G,B values of the next colour
28
+ r, g, b = APA102.COLOR_WHEEL(APA102.COLOR_INDEX*2)
29
+ # Set the colour on the DOTSTAR
30
+ APA102.DOTSTAR[0] = (int(r * 0.6), g, b, 0.4)
31
+ # Increase the wheel index
32
+ APA102.COLOR_INDEX = 0 if APA102.COLOR_INDEX > 1000 else APA102.COLOR_INDEX + 2
33
+ return True # No double-blink
34
+
35
+ ###################################################
36
+
37
+
38
+ # BUILTIN LED
39
+ builtin = _step_apa102
40
+
3
41
  # ANALOG RGB + WW + CW
4
42
  redgb = const(25) # D25 - rgb red channel [PWM CH1]
5
43
  rgreenb = const(26) # D26 - rgb green channel [PWM CH2]
@@ -1,7 +1,7 @@
1
1
  from socket import getaddrinfo, SOCK_STREAM
2
2
  from re import compile
3
3
  from uasyncio import open_connection
4
- from Debug import errlog_add
4
+ from Debug import syslog
5
5
  from Config import cfgget
6
6
  from Server import Server
7
7
  from Tasks import NativeTask
@@ -41,7 +41,7 @@ class InterCon:
41
41
  host = addr_info[-1][4][0]
42
42
  except OSError as e:
43
43
  Server.reply_all(f"[intercon] NoHost: {e}")
44
- errlog_add(f"[intercon] send_cmd {host} oserr: {e}")
44
+ syslog(f"[intercon] send_cmd {host} oserr: {e}")
45
45
  return ''
46
46
  else:
47
47
  # Restore IP from cache by hostname
@@ -55,7 +55,7 @@ class InterCon:
55
55
  output = await self.__run_command(cmd, hostname)
56
56
  except OSError as e:
57
57
  Server.reply_all(f"[intercon] NoHost: {e}")
58
- errlog_add(f"[intercon] send_cmd {host} oserr: {e}")
58
+ syslog(f"[intercon] send_cmd {host} oserr: {e}")
59
59
  output = None
60
60
  finally:
61
61
  if self.writer:
@@ -69,7 +69,7 @@ class InterCon:
69
69
  # None: ServerBusy(or \0) or Prompt mismatch (auto delete cached IP), STR: valid comm. output
70
70
  return output
71
71
  else:
72
- errlog_add(f"[ERR][intercon] Invalid host: {host}")
72
+ syslog(f"[ERR][intercon] Invalid host: {host}")
73
73
  return ''
74
74
 
75
75
  async def __run_command(self, cmd:list, hostname:str):
@@ -103,7 +103,7 @@ class InterCon:
103
103
  await self.writer.drain()
104
104
  data, prompt = await self.__receive_data(prompt=prompt)
105
105
  except Exception as e:
106
- errlog_add(f'[intercon][ERR] Auth: {e}')
106
+ syslog(f'[intercon][ERR] Auth: {e}')
107
107
  data = 'AuthFailed'
108
108
  if 'AuthOk' in data:
109
109
  return True # AuthOk
@@ -19,7 +19,7 @@ Reference: https://docs.micropython.org/en/latest/library/machine.Pin.html
19
19
  from machine import Pin
20
20
  from utime import ticks_ms, ticks_diff
21
21
  from Config import cfgget
22
- from Debug import console_write, errlog_add
22
+ from Debug import console_write, syslog
23
23
  from Tasks import exec_lm_pipe_schedule
24
24
  from microIO import resolve_pin
25
25
  if cfgget('cron'):
@@ -157,7 +157,7 @@ def initEventIRQs():
157
157
  try:
158
158
  return resolve_pin(_p)
159
159
  except Exception as e:
160
- errlog_add(f'[ERR][!] EVENT {_p} IO error: {e}')
160
+ syslog(f'[ERR][!] EVENT {_p} IO error: {e}')
161
161
  return None
162
162
 
163
163
  # Load External IRQ (1-4) execution data set from node config
@@ -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,7 +1,6 @@
1
- from sys import platform
2
1
  from utime import sleep
3
2
  from microIO import bind_pin, pinmap_search
4
- from Common import micro_task, notify
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
  #########################################
@@ -190,7 +190,7 @@ def __buzzer_init(pin=None):
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
@@ -288,10 +288,9 @@ def load(check_notify=False, pin=None, cache=True):
288
288
  Initialize buzzer module
289
289
  :param check_notify: check notify enabled/disabled - make noise if enabled only
290
290
  :param pin: optional number to overwrite default pin
291
- :param cache: default True, store stages on disk (.pds)
291
+ :param cache: default True, store stages on disk (.cache)
292
292
  :return str: Verdict
293
293
  """
294
- from sys import platform
295
294
  global __PERSISTENT_CACHE, CHECK_NOTIFY
296
295
  __PERSISTENT_CACHE = cache
297
296
  __persistent_cache_manager('r')
micrOS/source/LM_cct.py CHANGED
@@ -4,7 +4,7 @@
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
7
+ from Common import transition_gen, micro_task, data_dir
8
8
  from microIO import bind_pin, pinmap_search
9
9
  from random import randint
10
10
  from Types import resolve
@@ -18,6 +18,7 @@ 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
  #########################################
@@ -39,7 +40,7 @@ def __cwww_init(pin_warm=None, pin_cold=None):
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
@@ -77,7 +78,7 @@ def load(pin_warm=None, pin_cold=None, cache=True):
77
78
  Initialize Cold white / Warm white LED module
78
79
  :param pin_warm: optional number to overwrite default pin
79
80
  :param pin_cold: optional number to overwrite default pin
80
- :param cache: save/load state machine to disk (.pds)
81
+ :param cache: save/load state machine to disk (.cache)
81
82
  :return str: Cache state
82
83
  """
83
84
  __cwww_init(pin_warm, pin_cold)
@@ -1,4 +1,4 @@
1
- from Common import web_endpoint, syslog
1
+ from Common import web_dir, web_endpoint, syslog
2
2
 
3
3
  ENDPOINT_INITED = False
4
4
 
@@ -8,7 +8,7 @@ def load():
8
8
 
9
9
  def _dashboard_clb():
10
10
  try:
11
- with open('dashboard.html', 'r') as html:
11
+ with open(web_dir('dashboard.html'), 'r') as html:
12
12
  html_content = html.read()
13
13
  return 'text/html', html_content
14
14
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  from sys import platform
2
2
  from microIO import bind_pin, pinmap_search
3
- from Common import transition_gen, micro_task
3
+ from Common import transition_gen, micro_task, data_dir
4
4
  from utime import sleep_ms
5
5
  from Types import resolve
6
6
 
@@ -15,6 +15,7 @@ class Data:
15
15
  PERSISTENT_CACHE = False
16
16
  DIMM_TASK_TAG = "dimmer._tran"
17
17
  TASK_STATE = False
18
+ FILE_CACHE = data_dir('dimmer.cache')
18
19
 
19
20
 
20
21
  #########################################
@@ -34,7 +35,7 @@ def __dimmer_init():
34
35
 
35
36
  def __persistent_cache_manager(mode='r'):
36
37
  """
37
- pds - persistent data structure
38
+ File cache
38
39
  modes:
39
40
  r - recover, s - save
40
41
  """
@@ -42,12 +43,12 @@ def __persistent_cache_manager(mode='r'):
42
43
  return
43
44
  if mode == 's':
44
45
  # SAVE CACHE
45
- with open('dimmer.pds', 'w') as f:
46
+ with open(Data.FILE_CACHE, 'w') as f:
46
47
  f.write(','.join([str(k) for k in Data.DIMMER_CACHE]))
47
48
  return
48
49
  try:
49
50
  # RESTORE CACHE
50
- with open('dimmer.pds', 'r') as f:
51
+ with open(Data.FILE_CACHE, 'r') as f:
51
52
  Data.DIMMER_CACHE = [int(data) for data in f.read().strip().split(',')]
52
53
  except:
53
54
  pass
@@ -71,7 +72,7 @@ def load(cache=None):
71
72
  """
72
73
  Initialize dimmer module
73
74
  :param cache bool: file state machine cache: True/False/None(default: automatic True)
74
- - Load .pds (state machine cache) for this load module
75
+ - Load .cache (state machine cache) for this load module
75
76
  - Apply loaded states to gpio pins (boot function)
76
77
  :return str: Cache state
77
78
  """