micrOSDevToolKit 2.10.6__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 (101) 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 +45 -49
  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_pacman.py +25 -21
  27. micrOS/source/LM_qmi8658.py +204 -0
  28. micrOS/source/LM_rgb.py +6 -6
  29. micrOS/source/LM_roboarm.py +5 -4
  30. micrOS/source/LM_switch.py +6 -4
  31. micrOS/source/LM_tcs3472.py +75 -0
  32. micrOS/source/LM_telegram.py +5 -4
  33. micrOS/source/Logger.py +46 -32
  34. micrOS/source/Shell.py +1 -1
  35. micrOS/source/Tasks.py +7 -4
  36. micrOS/source/Time.py +5 -3
  37. micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
  38. micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
  39. micrOS/source/micrOS.py +5 -2
  40. micrOS/source/microIO.py +8 -6
  41. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.11.0.dist-info}/METADATA +2 -1
  42. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.11.0.dist-info}/RECORD +92 -87
  43. toolkit/DevEnvUSB.py +5 -0
  44. toolkit/LM_to_compile.dat +1 -0
  45. toolkit/dashboard_apps/NeoEffectsDemo.py +8 -15
  46. toolkit/dashboard_apps/QMI8685_GYRO.py +68 -0
  47. toolkit/dashboard_apps/_app_base.py +2 -2
  48. toolkit/dashboard_apps/_gyro_visualizer.py +78 -0
  49. toolkit/simulator_lib/__pycache__/IO_darwin.cpython-312.pyc +0 -0
  50. toolkit/simulator_lib/__pycache__/machine.cpython-312.pyc +0 -0
  51. toolkit/simulator_lib/__pycache__/neopixel.cpython-312.pyc +0 -0
  52. toolkit/simulator_lib/machine.py +0 -1
  53. toolkit/simulator_lib/neopixel.py +3 -2
  54. toolkit/socketClient.py +3 -2
  55. toolkit/workspace/precompiled/Common.mpy +0 -0
  56. toolkit/workspace/precompiled/Debug.mpy +0 -0
  57. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  58. toolkit/workspace/precompiled/Files.mpy +0 -0
  59. toolkit/workspace/precompiled/Hooks.mpy +0 -0
  60. toolkit/workspace/precompiled/IO_esp32c6.mpy +0 -0
  61. toolkit/workspace/precompiled/IO_esp32s3.mpy +0 -0
  62. toolkit/workspace/precompiled/IO_m5stamp.mpy +0 -0
  63. toolkit/workspace/precompiled/IO_qtpy.mpy +0 -0
  64. toolkit/workspace/precompiled/IO_s3matrix.mpy +0 -0
  65. toolkit/workspace/precompiled/IO_tinypico.mpy +0 -0
  66. toolkit/workspace/precompiled/LM_VL53L0X.py +1 -1
  67. toolkit/workspace/precompiled/LM_buzzer.mpy +0 -0
  68. toolkit/workspace/precompiled/LM_cct.mpy +0 -0
  69. toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
  70. toolkit/workspace/precompiled/LM_espnow.py +15 -10
  71. toolkit/workspace/precompiled/LM_i2c.py +3 -2
  72. toolkit/workspace/precompiled/LM_neoeffects.mpy +0 -0
  73. toolkit/workspace/precompiled/LM_neomatrix.mpy +0 -0
  74. toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
  75. toolkit/workspace/precompiled/LM_pacman.mpy +0 -0
  76. toolkit/workspace/precompiled/LM_qmi8658.py +204 -0
  77. toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
  78. toolkit/workspace/precompiled/LM_roboarm.mpy +0 -0
  79. toolkit/workspace/precompiled/LM_switch.mpy +0 -0
  80. toolkit/workspace/precompiled/LM_tcs3472.py +75 -0
  81. toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
  82. toolkit/workspace/precompiled/Logger.mpy +0 -0
  83. toolkit/workspace/precompiled/Shell.mpy +0 -0
  84. toolkit/workspace/precompiled/Tasks.mpy +0 -0
  85. toolkit/workspace/precompiled/Time.mpy +0 -0
  86. toolkit/workspace/precompiled/micrOS.mpy +0 -0
  87. toolkit/workspace/precompiled/microIO.mpy +0 -0
  88. micrOS/micropython/esp32s3-20240105-v1.22.1.bin +0 -0
  89. micrOS/source/LM_catgame.py +0 -75
  90. micrOS/source/LM_demo.py +0 -97
  91. micrOS/source/LM_intercon.py +0 -60
  92. micrOS/source/LM_ph_sensor.py +0 -51
  93. toolkit/workspace/precompiled/LM_catgame.py +0 -75
  94. toolkit/workspace/precompiled/LM_demo.py +0 -97
  95. toolkit/workspace/precompiled/LM_intercon.mpy +0 -0
  96. toolkit/workspace/precompiled/LM_ph_sensor.py +0 -51
  97. /micrOS/micropython/{esp32s3-20241129-v1.24.1.bin → esp32s3-8MBflash-20241129-v1.24.1.bin} +0 -0
  98. {microsdevtoolkit-2.10.6.data → microsdevtoolkit-2.11.0.data}/scripts/devToolKit.py +0 -0
  99. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.11.0.dist-info}/WHEEL +0 -0
  100. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.11.0.dist-info}/licenses/LICENSE +0 -0
  101. {microsdevtoolkit-2.10.6.dist-info → microsdevtoolkit-2.11.0.dist-info}/top_level.txt +0 -0
micrOS/source/LM_rgb.py CHANGED
@@ -2,8 +2,7 @@
2
2
  # ANALOG rgb CONTROLLER PARAMS #
3
3
  #########################################
4
4
  from machine import Pin, PWM
5
- from sys import platform
6
- from Common import transition_gen, micro_task
5
+ from Common import transition_gen, micro_task, data_dir
7
6
  from utime import sleep_ms
8
7
  from microIO import bind_pin, pinmap_search
9
8
  from random import randint
@@ -20,6 +19,7 @@ class Data:
20
19
  CH_MAX = 1000 # maximum value per channel
21
20
  TASK_STATE = False
22
21
  RGB_TASK_TAG = "rgb._tran"
22
+ FILE_CACHE = data_dir('rgb.cache')
23
23
 
24
24
 
25
25
  #########################################
@@ -39,7 +39,7 @@ def __RGB_init(red_pin=None, green_pin=None, blue_pin=None):
39
39
 
40
40
  def __persistent_cache_manager(mode):
41
41
  """
42
- pds - persistent data structure
42
+ File state cache
43
43
  modes:
44
44
  r - recover, s - save
45
45
  """
@@ -47,12 +47,12 @@ def __persistent_cache_manager(mode):
47
47
  return
48
48
  if mode == 's':
49
49
  # SAVE CACHE
50
- with open('rgb.pds', 'w') as f:
50
+ with open(Data.FILE_CACHE, 'w') as f:
51
51
  f.write(','.join([str(k) for k in Data.RGB_CACHE]))
52
52
  return
53
53
  try:
54
54
  # RESTORE CACHE
55
- with open('rgb.pds', 'r') as f:
55
+ with open(Data.FILE_CACHE, 'r') as f:
56
56
  Data.RGB_CACHE = [float(data) for data in f.read().strip().split(',')]
57
57
  except:
58
58
  pass
@@ -74,7 +74,7 @@ def load(red_pin=None, green_pin=None, blue_pin=None, cache=True):
74
74
  :param red_pin: optional red color pin to overwrite built-in
75
75
  :param green_pin: optional green color pin to overwrite built-in
76
76
  :param blue_pin: optional blue color pin to overwrite built-in
77
- :param cache: file state machine cache: True/False (.pds), default=True
77
+ :param cache: file state machine cache: True/False (.cache), default=True
78
78
  :return str: Cache state
79
79
  """
80
80
  Data.PERSISTENT_CACHE = cache
@@ -2,7 +2,7 @@ from utime import sleep_ms
2
2
  from random import randint
3
3
  import LM_servo as servo
4
4
  from LM_switch import set_state, pinmap as switch_pinmap
5
- from Common import transition, micro_task
5
+ from Common import transition, micro_task, data_dir
6
6
  from Types import resolve
7
7
 
8
8
 
@@ -13,23 +13,24 @@ class RoboArm:
13
13
  SPEED_MS = 10 # Set default speed between steps (ms)
14
14
  MOVE_RECORD = [] # Buffer for XY move record/replay
15
15
  PLAY_TAG = 'roboarm._play'
16
+ FILE_CACHE = data_dir('rarm.cache')
16
17
 
17
18
 
18
19
  def __persistent_cache_manager(mode):
19
20
  """
20
- pds - persistent data structure
21
+ File state cache
21
22
  modes:
22
23
  r - recover, s - save
23
24
  """
24
25
 
25
26
  if mode == 's':
26
27
  # SAVE CACHE
27
- with open('rarm.pds', 'w') as f:
28
+ with open(RoboArm.FILE_CACHE, 'w') as f:
28
29
  f.write(','.join([str(k) for k in RoboArm.MOVE_RECORD]))
29
30
  return
30
31
  try:
31
32
  # RESTORE CACHE
32
- with open('rarm.pds', 'r') as f:
33
+ with open(RoboArm.FILE_CACHE, 'r') as f:
33
34
  RoboArm.MOVE_RECORD = [int(data) for data in f.read().strip().split(',')]
34
35
  except:
35
36
  pass
@@ -1,5 +1,6 @@
1
1
  from machine import Pin
2
2
  from microIO import bind_pin, pinmap_search
3
+ from Common import data_dir
3
4
  from Types import resolve
4
5
 
5
6
  #########################################
@@ -8,6 +9,7 @@ from Types import resolve
8
9
  __SWITCH_OBJ = [None, None, None, None]
9
10
  __PERSISTENT_CACHE = False
10
11
  __SWITCH_STATE = [0, 0, 0, 0]
12
+ __FILE_CACHE = data_dir('switch.cache')
11
13
 
12
14
 
13
15
  #########################################
@@ -16,7 +18,7 @@ __SWITCH_STATE = [0, 0, 0, 0]
16
18
 
17
19
  def __persistent_cache_manager(mode):
18
20
  """
19
- pds - persistent data structure
21
+ File cache
20
22
  modes:
21
23
  r - recover, s - save
22
24
  """
@@ -25,12 +27,12 @@ def __persistent_cache_manager(mode):
25
27
  global __SWITCH_STATE
26
28
  if mode == 's':
27
29
  # SAVE CACHE
28
- with open('switch.pds', 'w') as f:
30
+ with open(__FILE_CACHE, 'w') as f:
29
31
  f.write(','.join([str(k) for k in __SWITCH_STATE]))
30
32
  return
31
33
  try:
32
34
  # RESTORE CACHE
33
- with open('switch.pds', 'r') as f:
35
+ with open(__FILE_CACHE, 'r') as f:
34
36
  __SWITCH_STATE = [int(data) for data in f.read().strip().split(',')]
35
37
  except:
36
38
  pass
@@ -54,7 +56,7 @@ def load(cache=None, ch_init=None):
54
56
  """
55
57
  Initiate switch module (4 switch pack)
56
58
  :param cache bool: file state machine cache: True/False/None(default: automatic True)
57
- - Load .pds (state machine cache) for this load module
59
+ - Load .cache (state machine cache) for this load module
58
60
  - Apply loaded states to gpio pins (boot function)
59
61
  :return str: Cache state
60
62
  """
@@ -0,0 +1,75 @@
1
+ """
2
+ A MicroPython library for the TCS3472 light sensing chip
3
+ https://github.com/tti0/tcs3472-micropython
4
+
5
+ Copyright (c) 2021 tti0
6
+ Licensed under the MIT License
7
+ """
8
+
9
+ from machine import I2C, Pin
10
+ from microIO import bind_pin, pinmap_search
11
+ import struct
12
+
13
+
14
+ class TCS3472:
15
+ INSTANCE = None
16
+
17
+ def __init__(self, bus, address=0x29):
18
+ self._bus = bus
19
+ self._i2c_address = address
20
+
21
+ self._bus.start()
22
+
23
+ self._bus.writeto(self._i2c_address, b'\x80\x03')
24
+ self._bus.writeto(self._i2c_address, b'\x81\x2b')
25
+
26
+ TCS3472.INSTANCE = self
27
+
28
+ def scaled(self):
29
+ crgb = self.raw()
30
+ if crgb[0] > 0:
31
+ return tuple(float(x) / crgb[0] for x in crgb[1:])
32
+
33
+ return (0, 0, 0)
34
+
35
+ def rgb(self):
36
+ return tuple(int(x * 255) for x in self.scaled())
37
+
38
+ def light(self):
39
+ return self.raw()[0]
40
+
41
+ def brightness(self, level=65.535):
42
+ return int((self.light() / level))
43
+
44
+ def valid(self):
45
+ self._bus.writeto(self._i2c_address, b'\x93')
46
+ return self._bus.readfrom(self._i2c_address, 1)[0] & 1
47
+
48
+ def raw(self):
49
+ self._bus.writeto(self._i2c_address, b'\xb4')
50
+ return struct.unpack("<HHHH", self._bus.readfrom(self._i2c_address, 8))
51
+
52
+
53
+ ############################ Exposed functions ############################
54
+
55
+ def load():
56
+ """
57
+ Load the TCS3472 Color sensor instance.
58
+ """
59
+ if TCS3472.INSTANCE is None:
60
+ bus = I2C(sda=Pin(bind_pin('i2c_sda')), scl=Pin(bind_pin('i2c_scl')))
61
+ TCS3472.INSTANCE = TCS3472(bus)
62
+ return TCS3472.INSTANCE
63
+
64
+
65
+ def pinmap():
66
+ return pinmap_search(['i2c_scl', 'i2c_sda'])
67
+
68
+
69
+ def measure():
70
+ sensor = load()
71
+ return {"rgb": sensor.rgb(), "light": sensor.light(), "brightness": sensor.brightness()}
72
+
73
+
74
+ def help(widgest=False):
75
+ return 'load', 'measure'
@@ -2,7 +2,7 @@ from sys import modules
2
2
  import urequests
3
3
  from Notify import Notify
4
4
  from Config import cfgget
5
- from Common import micro_task, syslog, console_write
5
+ from Common import micro_task, syslog, console_write, data_dir
6
6
  from LM_system import ifconfig
7
7
  from utime import localtime
8
8
 
@@ -18,6 +18,7 @@ class Telegram(Notify):
18
18
  _CHAT_IDS = set() # Telegram bot chat IDs - multi group support - persistent caching
19
19
  _API_PARAMS = "?offset=-1&limit=1&timeout=2" # Generic API params - optimization
20
20
  _IN_MSG_ID = None
21
+ _FILE_CACHE = data_dir('telegram.cache')
21
22
 
22
23
  def __init__(self):
23
24
  # Subscribe to the notification system - provide send_msg method (over self)
@@ -26,20 +27,20 @@ class Telegram(Notify):
26
27
  @staticmethod
27
28
  def __id_cache(mode):
28
29
  """
29
- pds - persistent data structure
30
+ File cache
30
31
  modes:
31
32
  r - recover, s - save
32
33
  """
33
34
  if mode == 's':
34
35
  # SAVE CACHE
35
36
  console_write("[NTFY] Save chatIDs cache...")
36
- with open('telegram.pds', 'w') as f:
37
+ with open(Telegram._FILE_CACHE, 'w') as f:
37
38
  f.write(','.join([str(k) for k in Telegram._CHAT_IDS]))
38
39
  return
39
40
  try:
40
41
  # RESTORE CACHE
41
42
  console_write("[NTFY] Restore chatIDs cache...")
42
- with open('telegram.pds', 'r') as f:
43
+ with open(Telegram._FILE_CACHE, 'r') as f:
43
44
  # set() comprehension
44
45
  Telegram._CHAT_IDS = {int(k) for k in f.read().strip().split(',')}
45
46
  except:
micrOS/source/Logger.py CHANGED
@@ -6,48 +6,52 @@ Designed by Marcell Ban aka BxNxM
6
6
  """
7
7
  from time import localtime
8
8
  from re import match
9
- from uos import remove, mkdir, getcwd
10
- from Files import ilist_fs, is_dir
9
+ from uos import remove, mkdir
10
+ from Files import OSPath, path_join, ilist_fs, is_dir
11
11
 
12
12
  #############################################
13
13
  # LOGGING WITH DATA ROTATION #
14
14
  #############################################
15
- LOG_FOLDER = None
16
15
 
17
16
  def _init_logger():
18
17
  """ Init /logs folder """
19
- global LOG_FOLDER
20
- if LOG_FOLDER is None:
21
- LOG_FOLDER = f"{getcwd()}logs"
22
- if not is_dir(LOG_FOLDER):
23
- try:
24
- mkdir(LOG_FOLDER)
25
- syslog(f"[BOOT] log dir {LOG_FOLDER} init")
26
- except Exception as e:
27
- LOG_FOLDER = getcwd()
28
- syslog(f"[BOOT] log dir {LOG_FOLDER} fallback: {e}")
29
- return LOG_FOLDER
18
+ if not is_dir(OSPath.LOGS):
19
+ try:
20
+ mkdir(OSPath.LOGS)
21
+ syslog(f"[BOOT] log dir {OSPath.LOGS} init")
22
+ except Exception as e:
23
+ OSPath.LOGS = OSPath.ROOT
24
+ syslog(f"[BOOT] log dir {OSPath.LOGS} fallback: {e}")
25
+ return OSPath.LOGS
26
+
27
+
28
+ def _dir_select(f_name:str) -> str:
29
+ """
30
+ Select log dir based on file extension
31
+ :param f_name: filename with extension to detect target dir
32
+ """
33
+ if f_name.endswith(".log"):
34
+ return OSPath.LOGS
35
+ return OSPath.DATA
30
36
 
31
37
 
32
- def logger(data, f_name, limit):
38
+ def logger(data, f_name:str, limit:int):
33
39
  """
34
- Create generic logger function
35
- - implements log line rotation
36
- - automatic time stump
37
- :param data: input string data to log
40
+ Generic logger function with line rotation and time
41
+ :param data: data to log
38
42
  :param f_name: file name to use
39
43
  :param limit: line limit for log rotation
40
44
  return write verdict - true / false
41
45
  INFO: hardcoded max data number = 30
42
46
  """
43
47
  def _logger(f_mode='r+'):
44
- nonlocal data, f_name, limit
48
+ nonlocal data, f_path, limit
45
49
  limit = min(limit, 30) # Hardcoded max data line = 30
46
50
  # [1] GET TIME STUMP
47
51
  ts_buff = [str(k) for k in localtime()]
48
52
  ts = ".".join(ts_buff[0:3]) + "-" + ":".join(ts_buff[3:6])
49
53
  # [2] OPEN FILE - WRITE DATA WITH TS
50
- with open(f_name, f_mode) as f:
54
+ with open(f_path, f_mode) as f:
51
55
  _data = f"{ts} {data}\n"
52
56
  # read file lines and filter by time stump chunks (hack for replace truncate)
53
57
  lines = [_l for _l in f.readlines() if '-' in _l and '.' in _l]
@@ -61,7 +65,7 @@ def logger(data, f_name, limit):
61
65
  # write file
62
66
  f.write(''.join(lines))
63
67
 
64
- f_name = f"{LOG_FOLDER}/{f_name}"
68
+ f_path = path_join(_dir_select(f_name), f_name)
65
69
  # Run logger
66
70
  try:
67
71
  # There is file - append 'r+'
@@ -75,17 +79,17 @@ def logger(data, f_name, limit):
75
79
  return True
76
80
 
77
81
 
78
- def log_get(f_name, msgobj=None):
82
+ def log_get(f_name:str, msgobj=None):
79
83
  """
80
- Get and stream (ver osocket/stdout) .log file's content and count "critical" errors
81
- - critical error tag in log line: [ERR]
84
+ Generic file getter for .log files
85
+ - log content critical [ERR] counter
82
86
  """
83
- f_name = f"{LOG_FOLDER}/{f_name}"
87
+ f_path = path_join(_dir_select(f_name), f_name)
84
88
  err_cnt = 0
85
89
  try:
86
90
  if msgobj is not None:
87
- msgobj(f_name)
88
- with open(f_name, 'r') as f:
91
+ msgobj(f_path)
92
+ with open(f_path, 'r') as f:
89
93
  eline = f.readline().strip()
90
94
  while eline:
91
95
  # GET error from log line (tag: [ERR])
@@ -100,10 +104,16 @@ def log_get(f_name, msgobj=None):
100
104
 
101
105
 
102
106
  def syslog(data=None, msgobj=None):
107
+ """
108
+ System log setter/getter
109
+ :param data: None - read logs, str - write logs
110
+ :param msgobj: function to stream .log files
111
+ """
103
112
  if data is None:
104
- err_cnt = sum([log_get(f, msgobj) for f in ilist_fs(LOG_FOLDER, type_filter='f') if f.endswith(".sys.log")])
113
+ # READ LOGS
114
+ err_cnt = sum([log_get(f, msgobj) for f in ilist_fs(OSPath.LOGS, type_filter='f') if f.endswith(".sys.log")])
105
115
  return err_cnt
106
-
116
+ # WRITE LOGS - [target].sys.log automatic log level detection
107
117
  _match = match(r"^\[([^\[\]]+)\]", data)
108
118
  log_lvl = _match.group(1).lower() if _match else 'user'
109
119
  f_name = f"{log_lvl}.sys.log" if log_lvl in ("err", "warn", "boot") else 'user.sys.log'
@@ -111,9 +121,13 @@ def syslog(data=None, msgobj=None):
111
121
 
112
122
 
113
123
  def log_clean(msgobj=None):
114
- to_del = [file for file in ilist_fs(LOG_FOLDER, type_filter='f') if file.endswith('.log')]
124
+ """
125
+ Clean logs folder
126
+ """
127
+ logs_dir = OSPath.LOGS
128
+ to_del = [file for file in ilist_fs(logs_dir, type_filter='f') if file.endswith('.log')]
115
129
  for _del in to_del:
116
- _del = f"{LOG_FOLDER}/{_del}"
130
+ _del = path_join(logs_dir, _del)
117
131
  if msgobj is not None:
118
132
  msgobj(f" Delete: {_del}")
119
133
  remove(_del)
micrOS/source/Shell.py CHANGED
@@ -25,7 +25,7 @@ from Debug import errlog_add
25
25
 
26
26
  class Shell:
27
27
  __slots__ = ['__devfid', '__auth_mode', '__hwuid', '__auth_ok', '__conf_mode']
28
- MICROS_VERSION = '2.10.5-1'
28
+ MICROS_VERSION = '2.11.0-0'
29
29
 
30
30
  def __init__(self):
31
31
  """
micrOS/source/Tasks.py CHANGED
@@ -98,9 +98,11 @@ class TaskBase:
98
98
  async def feed(sleep_ms=1):
99
99
  """
100
100
  Feed event loop
101
- :param sleep_ms: in millisecond (min: 1)
101
+ :param sleep_ms: in millisecond
102
102
  """
103
103
  # TODO: feed WDT - preemptive cooperative multitasking aka reboot if no feed until X time period
104
+ if sleep_ms <= 0:
105
+ return await asyncio.sleep(0.000_000_1) # 0 means: 100ns (Absolute minimum)
104
106
  return await asyncio.sleep_ms(sleep_ms)
105
107
 
106
108
  def __del__(self):
@@ -116,7 +118,7 @@ class NativeTask(TaskBase):
116
118
  - could be built in function or custom code from load modules
117
119
  """
118
120
 
119
- def create(self, callback=None, tag=None):
121
+ def create(self, callback:callable=None, tag:str=None) -> bool:
120
122
  """
121
123
  Create async task with coroutine callback (no queue limit check!)
122
124
  + async socket server task
@@ -166,7 +168,7 @@ class MagicTask(TaskBase):
166
168
  self.__inloop = False # [LM] Task while loop for LM callback
167
169
  self.__sleep = 20 # [LM] Task while loop - async wait (proc feed) [ms]
168
170
 
169
- def create(self, callback=None, loop=None, sleep=None):
171
+ def create(self, callback:list=None, loop:bool=None, sleep:int=None) -> bool:
170
172
  """
171
173
  Create async task with function callback (with queue limit check)
172
174
  - wrap (sync) function into async task (task_wrapper)
@@ -295,11 +297,12 @@ class Manager:
295
297
  my_task.done.set()
296
298
 
297
299
  @staticmethod
298
- def create_task(callback, tag=None, loop=False, delay=None):
300
+ def create_task(callback, tag:str=None, loop:bool=False, delay:int=None):
299
301
  """
300
302
  Primary interface
301
303
  Generic task creator method
302
304
  Create async Task with coroutine/list(lm call) callback
305
+ :param callback: list|callable
303
306
  """
304
307
  if isinstance(callback, list):
305
308
  # Check queue if task is Load Module
micrOS/source/Time.py CHANGED
@@ -16,12 +16,14 @@ from utime import sleep_ms, time, mktime, localtime
16
16
  from Config import cfgput, cfgget
17
17
  from Debug import errlog_add, console_write
18
18
  from urequests import get as http_get
19
+ from Files import OSPath, path_join
19
20
 
20
21
 
21
22
  class Sun:
22
23
  TIME = {}
23
24
  UTC = cfgget('utc') # STORED IN MINUTE
24
25
  BOOTIME = None # Initialize BOOTIME: Not SUN, but for system uptime
26
+ FILE_CACHE = path_join(OSPath.DATA, 'sun.cache')
25
27
 
26
28
 
27
29
  def set_time(year, month, mday, hour, minute, sec):
@@ -89,14 +91,14 @@ def ntp_time():
89
91
 
90
92
  def __sun_cache(mode):
91
93
  """
92
- pds - persistent data structure
94
+ File cache
93
95
  modes:
94
96
  r - recover, s - save
95
97
  """
96
98
  if mode == 's':
97
99
  # SAVE CACHE
98
100
  try:
99
- with open('sun.pds', 'w') as f:
101
+ with open(Sun.FILE_CACHE, 'w') as f:
100
102
  cache = {k:tuple([str(t) for t in v]) for k, v in Sun.TIME.items()}
101
103
  f.write(';'.join([f'{k}:{"-".join(v)}' for k, v in cache.items()]))
102
104
  except:
@@ -104,7 +106,7 @@ def __sun_cache(mode):
104
106
  return
105
107
  try:
106
108
  # RESTORE CACHE
107
- with open('sun.pds', 'r') as f:
109
+ with open(Sun.FILE_CACHE, 'r') as f:
108
110
  buff = {data.split(':')[0]: data.split(':')[1].split('-')
109
111
  for data in f.read().strip().split(';')}
110
112
  for k, v in buff.items():
micrOS/source/micrOS.py CHANGED
@@ -9,7 +9,7 @@ Designed by Marcell Ban aka BxNxM
9
9
  #################################################################
10
10
  from Time import ntp_time, suntime
11
11
  from Tasks import Manager
12
- from Hooks import bootup, profiling_info
12
+ from Hooks import bootup, profiling_info, enableESPNow
13
13
  from Network import auto_nw_config
14
14
  from Server import Server
15
15
  from Interrupts import enableInterrupt, enableCron, initEventIRQs
@@ -74,7 +74,10 @@ def micrOS():
74
74
 
75
75
  # [Server] as async task
76
76
  aio.create_task(Server().run_server(), tag='server')
77
- profiling_info(label='[memUsage] SYSTEM IS UP')
77
+
78
+ # [ESPNow] server as async task
79
+ enableESPNow()
80
+ profiling_info(label='[memUsage] SYSTEM IS UP AND RUNNING')
78
81
 
79
82
  # [EVENT LOOP] Start async event loop
80
83
  aio.run_forever()
micrOS/source/microIO.py CHANGED
@@ -30,17 +30,19 @@ def detect_platform():
30
30
  """
31
31
  Unified platform detection for micrOS
32
32
  """
33
- if 'esp32' in platform:
33
+ if 'esp32' in platform: # esp32 family
34
34
  board = str(uname()[-1]).lower()
35
35
  if 'tinypico' in board:
36
- return 'tinypico' # esp32 family - tinypico
36
+ return 'tinypico'
37
37
  if 'esp32s2' in board:
38
- return 'esp32s2' # esp32 family - esp32S2
38
+ return 'esp32s2'
39
39
  if 'esp32s3' in board:
40
- return 'esp32s3' # esp32 family - esp32s3
40
+ return 'esp32s3'
41
41
  if 'esp32c3' in board:
42
- return 'esp32c3' # esp32 family - esp32c3
43
- return 'esp32' # esp32 family - general
42
+ return 'esp32c3'
43
+ if 'esp32c6' in board:
44
+ return 'esp32c6'
45
+ return 'esp32' # esp32 family: general
44
46
  return platform # esp8266 or something else
45
47
 
46
48
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: micrOSDevToolKit
3
- Version: 2.10.6
3
+ Version: 2.11.0
4
4
  Summary: Development and deployment environment for micrOS, the diy micropython automation OS (IoT)
5
5
  Home-page: https://github.com/BxNxM/micrOS
6
6
  Author: Marcell Ban
@@ -404,6 +404,7 @@ These parameters controlls micrOS core functionalities, so you can define an ent
404
404
  | **`appwd`** | `ADmin123` `<str>` | Yes | Device system password.: Used in AP password (access point mode) + webrepl password + micrOS auth
405
405
  | **`boothook`** | `n/a` `<str>` | Yes | Add Load Module execution(s) to the boot sequence. Separator `;`. Examples: `rgb load; cct load` but you can call any load module function here if you want to run it at boot time.
406
406
  | **`webui`** | `False` `bool` | Yes | Launch http rest server on port 80 (in parallel with micrOS shell on port 9008 aka `socport`). It has 2 endpoints: / aka main page (index.html) and /rest aka rest (json) interface for load module execution. Example: `<devfid>.local` or `<devfid>.local/rest` + optional parameters: `/rgb/toggle`. **Apple shortcuts compatible**
407
+ | **`espnow`** | `False` `bool` | Yes | Enable **ESPNow communication protocol**. It starts `espnow.server` task, that can receive espnow messages and execute Load Module commands. It is an extension for **InterCon** feature example: `system heartbeat >>target.local`.
407
408
  | | |
408
409
  | **`cron`** | `False` `<bool>` | Yes | Enable timestamp based Load Module execution aka Cron scheduler (linux terminology), Timer(1) hardware interrupt enabler.
409
410
  | **`crontasks`** | `n/a` `<str>` | Yes | Cron scheduler input, task format: `WD:H:M:S!module function` e.g.: `1:8:0:0!system heartbeat`, task separator in case of multiple tasks: `;`. [WD:0-6, H:0-23, M:0-59, S:0-59] in case of each use: `*`. Instead `WD:H:M:S` you can use suntime tags: `sunset`, `sunrise`, optional offset: `sunset+-<minutes>`, `sunrise+-<minutes>`, example: `sunset-30!system heartbeat`. Range of days: WD can be conrete day number or range like: 0-2 means Monday to Wednesday.