micrOSDevToolKit 2.10.5__py3-none-any.whl → 2.11.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 (110) 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 +47 -51
  6. micrOS/source/Common.py +262 -87
  7. micrOS/source/Debug.py +44 -88
  8. micrOS/source/Espnow.py +1 -1
  9. micrOS/source/Files.py +21 -2
  10. micrOS/source/Hooks.py +60 -17
  11. micrOS/source/IO_esp32c6.py +16 -0
  12. micrOS/source/IO_esp32s3.py +37 -1
  13. micrOS/source/IO_m5stamp.py +35 -1
  14. micrOS/source/IO_qtpy.py +22 -17
  15. micrOS/source/IO_s3matrix.py +21 -0
  16. micrOS/source/IO_tinypico.py +38 -0
  17. micrOS/source/LM_VL53L0X.py +1 -1
  18. micrOS/source/LM_buzzer.py +6 -7
  19. micrOS/source/LM_cct.py +6 -5
  20. micrOS/source/LM_dimmer.py +6 -5
  21. micrOS/source/LM_espnow.py +15 -10
  22. micrOS/source/LM_i2c.py +3 -2
  23. micrOS/source/LM_neoeffects.py +173 -230
  24. micrOS/source/LM_neomatrix.py +305 -0
  25. micrOS/source/LM_neopixel.py +10 -10
  26. micrOS/source/LM_oled_ui.py +18 -5
  27. micrOS/source/LM_pacman.py +25 -21
  28. micrOS/source/LM_qmi8658.py +204 -0
  29. micrOS/source/LM_rest.py +3 -3
  30. micrOS/source/LM_rgb.py +6 -6
  31. micrOS/source/LM_roboarm.py +5 -4
  32. micrOS/source/LM_switch.py +6 -4
  33. micrOS/source/LM_tcs3472.py +75 -0
  34. micrOS/source/LM_telegram.py +5 -4
  35. micrOS/source/Logger.py +46 -32
  36. micrOS/source/Shell.py +11 -10
  37. micrOS/source/Tasks.py +7 -4
  38. micrOS/source/Time.py +5 -3
  39. micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
  40. micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
  41. micrOS/source/micrOS.py +5 -2
  42. micrOS/source/microIO.py +8 -6
  43. {microsdevtoolkit-2.10.5.dist-info → microsdevtoolkit-2.11.0.dist-info}/METADATA +2 -1
  44. {microsdevtoolkit-2.10.5.dist-info → microsdevtoolkit-2.11.0.dist-info}/RECORD +101 -96
  45. toolkit/DevEnvUSB.py +5 -0
  46. toolkit/Gateway.py +3 -3
  47. toolkit/LM_to_compile.dat +1 -0
  48. toolkit/dashboard_apps/NeoEffectsDemo.py +8 -15
  49. toolkit/dashboard_apps/QMI8685_GYRO.py +68 -0
  50. toolkit/dashboard_apps/_app_base.py +2 -2
  51. toolkit/dashboard_apps/_gyro_visualizer.py +78 -0
  52. toolkit/simulator_lib/__pycache__/IO_darwin.cpython-312.pyc +0 -0
  53. toolkit/simulator_lib/__pycache__/machine.cpython-312.pyc +0 -0
  54. toolkit/simulator_lib/__pycache__/neopixel.cpython-312.pyc +0 -0
  55. toolkit/simulator_lib/__pycache__/sim_console.cpython-312.pyc +0 -0
  56. toolkit/simulator_lib/machine.py +0 -1
  57. toolkit/simulator_lib/neopixel.py +3 -2
  58. toolkit/socketClient.py +3 -2
  59. toolkit/user_data/webhooks/generic.py +1 -1
  60. toolkit/user_data/webhooks/macro.py +1 -1
  61. toolkit/user_data/webhooks/template.py +1 -1
  62. toolkit/workspace/precompiled/Common.mpy +0 -0
  63. toolkit/workspace/precompiled/Debug.mpy +0 -0
  64. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  65. toolkit/workspace/precompiled/Files.mpy +0 -0
  66. toolkit/workspace/precompiled/Hooks.mpy +0 -0
  67. toolkit/workspace/precompiled/IO_esp32c6.mpy +0 -0
  68. toolkit/workspace/precompiled/IO_esp32s3.mpy +0 -0
  69. toolkit/workspace/precompiled/IO_m5stamp.mpy +0 -0
  70. toolkit/workspace/precompiled/IO_qtpy.mpy +0 -0
  71. toolkit/workspace/precompiled/IO_s3matrix.mpy +0 -0
  72. toolkit/workspace/precompiled/IO_tinypico.mpy +0 -0
  73. toolkit/workspace/precompiled/LM_VL53L0X.py +1 -1
  74. toolkit/workspace/precompiled/LM_buzzer.mpy +0 -0
  75. toolkit/workspace/precompiled/LM_cct.mpy +0 -0
  76. toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
  77. toolkit/workspace/precompiled/LM_espnow.py +15 -10
  78. toolkit/workspace/precompiled/LM_i2c.py +3 -2
  79. toolkit/workspace/precompiled/LM_neoeffects.mpy +0 -0
  80. toolkit/workspace/precompiled/LM_neomatrix.mpy +0 -0
  81. toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
  82. toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
  83. toolkit/workspace/precompiled/LM_pacman.mpy +0 -0
  84. toolkit/workspace/precompiled/LM_qmi8658.py +204 -0
  85. toolkit/workspace/precompiled/LM_rest.mpy +0 -0
  86. toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
  87. toolkit/workspace/precompiled/LM_roboarm.mpy +0 -0
  88. toolkit/workspace/precompiled/LM_switch.mpy +0 -0
  89. toolkit/workspace/precompiled/LM_tcs3472.py +75 -0
  90. toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
  91. toolkit/workspace/precompiled/Logger.mpy +0 -0
  92. toolkit/workspace/precompiled/Shell.mpy +0 -0
  93. toolkit/workspace/precompiled/Tasks.mpy +0 -0
  94. toolkit/workspace/precompiled/Time.mpy +0 -0
  95. toolkit/workspace/precompiled/micrOS.mpy +0 -0
  96. toolkit/workspace/precompiled/microIO.mpy +0 -0
  97. micrOS/micropython/esp32s3-20240105-v1.22.1.bin +0 -0
  98. micrOS/source/LM_catgame.py +0 -75
  99. micrOS/source/LM_demo.py +0 -97
  100. micrOS/source/LM_intercon.py +0 -60
  101. micrOS/source/LM_ph_sensor.py +0 -51
  102. toolkit/workspace/precompiled/LM_catgame.py +0 -75
  103. toolkit/workspace/precompiled/LM_demo.py +0 -97
  104. toolkit/workspace/precompiled/LM_intercon.mpy +0 -0
  105. toolkit/workspace/precompiled/LM_ph_sensor.py +0 -51
  106. /micrOS/micropython/{esp32s3-20241129-v1.24.1.bin → esp32s3-8MBflash-20241129-v1.24.1.bin} +0 -0
  107. {microsdevtoolkit-2.10.5.data → microsdevtoolkit-2.11.0.data}/scripts/devToolKit.py +0 -0
  108. {microsdevtoolkit-2.10.5.dist-info → microsdevtoolkit-2.11.0.dist-info}/WHEEL +0 -0
  109. {microsdevtoolkit-2.10.5.dist-info → microsdevtoolkit-2.11.0.dist-info}/licenses/LICENSE +0 -0
  110. {microsdevtoolkit-2.10.5.dist-info → microsdevtoolkit-2.11.0.dist-info}/top_level.txt +0 -0
micrOS/source/Debug.py CHANGED
@@ -1,12 +1,18 @@
1
+ """
2
+ micrOS Console and Log write interface implementations.
3
+ - with progress led feature, simple and custom
4
+ Designed by Marcell Ban aka BxNxM
5
+ """
6
+
1
7
  from machine import Pin
2
8
  try:
3
9
  from Logger import syslog
4
10
  except:
5
11
  syslog = None
6
12
  try:
7
- from microIO import resolve_pin, pinmap_search, detect_platform
13
+ from microIO import resolve_pin, pinmap_search, register_pin
8
14
  except:
9
- detect_platform = None
15
+ pinmap_search = None
10
16
 
11
17
 
12
18
  #############################################
@@ -17,40 +23,53 @@ except:
17
23
  class DebugCfg:
18
24
  DEBUG = True # DEBUG PRINT ON/OFF - SET FROM ConfigHandler
19
25
  PLED_STEP = None # PROGRESS LED OBJECT - init in init_pled
20
- NEO_WHEEL = None # NEOPIXEL (ws2812/esp32s3) color wheel object
21
- COLOR_INDEX = 0 # APA102 TinyPico color wheel counter
22
26
 
23
27
  @staticmethod
24
28
  def init_pled():
25
29
  # CALL FROM ConfigHandler
26
- if detect_platform is None:
30
+ if pinmap_search is None:
27
31
  # Check LogicalPins module loadable (robustness...)
28
32
  return
29
- micro_platform = detect_platform()
30
- if micro_platform == "tinypico":
31
- # Progress led for TinyPico
32
- DebugCfg._init_apa102()
33
- return
34
33
  pled = pinmap_search('builtin')['builtin']
35
- if pled is not None:
36
- if isinstance(pled, int):
37
- # SET PROGRESS LED WITH BUILT-IN step FUNCTION
38
- if micro_platform == "esp32s3":
39
- # Progress led for esp32s3
40
- DebugCfg._init_ws2812()
41
- else:
42
- # Progress led for esp32/etc
43
- DebugCfg._init_simple()
44
- else:
45
- # OVERRIDE PROGRESS LED WITH CUSTOM step FUNCTION
46
- DebugCfg.PLED_STEP = pled
34
+ if pled is None:
35
+ # No available builtin pin, skip pled init...
36
+ return
37
+ # CONFIGURE PROGRESS LED
38
+ if isinstance(pled, int):
39
+ # [MODE] Simple flashing progress LED
40
+ try:
41
+ # Progress led for esp32/etc
42
+ led_obj = Pin(abs(resolve_pin('builtin')), Pin.OUT)
43
+ if resolve_pin('builtin') < 0:
44
+ # Pin number start with (-), like -8 (means inverted output)
45
+ led_obj.value(1) # Turn OFF built-in LED state invert (1:OFF)
46
+ # Set function callback for step function (simple led - blink)
47
+ DebugCfg.PLED_STEP = lambda: led_obj.value(not led_obj.value()) # # double-blink: return None
48
+ except Exception as e:
49
+ errlog_add(f"[PLED] led error: {e}")
50
+ elif callable(pled):
51
+ # [MODE] OVERRIDE PROGRESS LED WITH CUSTOM step FUNCTION
52
+ DebugCfg.PLED_STEP = pled
53
+ DebugCfg._auto_register_pin()
54
+ else:
55
+ errlog_add(f"[WARN] pled type not supported: {pled}")
56
+
57
+
58
+ @staticmethod
59
+ def _auto_register_pin():
60
+ try:
61
+ pin = DebugCfg.PLED_STEP(pin=True)
62
+ if isinstance(pin, int):
63
+ register_pin('builtin', pin)
64
+ except Exception as e:
65
+ errlog_add(f"[ERR] pled pin registration: {e}", console=False)
66
+
47
67
 
48
68
  @staticmethod
49
69
  def step():
50
70
  """
51
- DEBUG LED FEEDBACK
52
- - handle 3 types of builtin LEDs: analog, neopixel(ws2812), apa102
53
- - automatic selection based on board type + builtin logical pin number
71
+ DEBUG LED FLASHING FEEDBACK
72
+ - handle step callback function execution
54
73
  """
55
74
  try:
56
75
  if callable(DebugCfg.PLED_STEP):
@@ -59,69 +78,6 @@ class DebugCfg:
59
78
  errlog_add(f"[PLED] step error: {e}")
60
79
  return True
61
80
 
62
- @staticmethod
63
- def _init_simple():
64
- try:
65
- # Progress led for esp32/etc
66
- led_obj = Pin(abs(resolve_pin('builtin')), Pin.OUT)
67
- if resolve_pin('builtin') < 0: # Pin number start with (-), like -8 (means inverted output)
68
- led_obj.value(1) # Turn OFF built-in LED state invert (1:OFF)
69
- # Set function callback for step function (simple led - blink)
70
- DebugCfg.PLED_STEP = lambda: led_obj.value(not led_obj.value()) # # double-blink: return None
71
- except Exception as e:
72
- errlog_add(f"[PLED] led error: {e}")
73
-
74
- @staticmethod
75
- def _init_apa102():
76
- try:
77
- from machine import SoftSPI
78
- from dotstar import DotStar
79
- from tinypico import DOTSTAR_CLK, DOTSTAR_DATA, SPI_MISO, set_dotstar_power, dotstar_color_wheel
80
- spi = SoftSPI(sck=Pin(DOTSTAR_CLK), mosi=Pin(DOTSTAR_DATA), miso=Pin(SPI_MISO))
81
- # Create a DotStar instance
82
- dotstar = DotStar(spi, 1, brightness=0.4) # Just one DotStar, half brightness
83
- # Turn on the power to the DotStar
84
- set_dotstar_power(True)
85
- DebugCfg.PLED_STEP = lambda: DebugCfg._step_apa102(led_obj=dotstar, color_wheel=dotstar_color_wheel)
86
- except Exception as e:
87
- errlog_add(f"[PLED] apa102 error: {e}")
88
-
89
- @staticmethod
90
- def _step_apa102(led_obj, color_wheel):
91
- # Get the R,G,B values of the next colour
92
- r, g, b = color_wheel(DebugCfg.COLOR_INDEX*2)
93
- # Set the colour on the DOTSTAR
94
- led_obj[0] = (int(r * 0.6), g, b, 0.4)
95
- # Increase the wheel index
96
- DebugCfg.COLOR_INDEX = 0 if DebugCfg.COLOR_INDEX > 1000 else DebugCfg.COLOR_INDEX + 2
97
- return True # No double-blink
98
-
99
- @staticmethod
100
- def _init_ws2812():
101
- try:
102
- from neopixel import NeoPixel
103
- neo_pin = Pin(resolve_pin('builtin'))
104
- led_obj = NeoPixel(neo_pin, 1)
105
- DebugCfg.PLED_STEP = lambda: DebugCfg._step_ws2812(led_obj)
106
- except Exception as e:
107
- errlog_add(f"[PLED] ws2812 error: {e}")
108
-
109
- @staticmethod
110
- def _step_ws2812(led_obj):
111
- def _color_wheel():
112
- while True:
113
- yield 10, 0, 0
114
- yield 5, 5, 0
115
- yield 0, 10, 0
116
- yield 0, 5, 5
117
- yield 0, 0, 10
118
- yield 5, 0, 5
119
- if DebugCfg.NEO_WHEEL is None:
120
- DebugCfg.NEO_WHEEL = _color_wheel()
121
- led_obj[0] = next(DebugCfg.NEO_WHEEL)
122
- led_obj.write()
123
- return True # No double-blink
124
-
125
81
 
126
82
  def console_write(msg):
127
83
  if DebugCfg.DEBUG:
micrOS/source/Espnow.py CHANGED
@@ -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,22 @@ 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') # system/user logs
115
+ DATA = path_join(_ROOT,'/data') # application data
116
+ WEB = path_join(_ROOT,'/web') # web resources
117
+
118
+ @property
119
+ def ROOT(self):
120
+ return self._ROOT
micrOS/source/Hooks.py CHANGED
@@ -21,6 +21,8 @@ from Config import cfgget, cfgput
21
21
  from microIO import detect_platform
22
22
  from Debug import console_write, errlog_add
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
+ errlog_add(f"[BOOT] init dir: {dir_path}")
80
+ except Exception as e:
81
+ errlog_add(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
@@ -111,3 +139,18 @@ def boot_cause():
111
139
  reason = 5, "SoftReset"
112
140
  errlog_add(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
+ errlog_add(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]
@@ -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)