micrOSDevToolKit 2.9.6__py3-none-any.whl → 2.9.8__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 (85) hide show
  1. micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +11 -11
  2. micrOS/source/Espnow.py +89 -56
  3. micrOS/source/LM_L298N_DCmotor.py +4 -4
  4. micrOS/source/LM_L9110_DCmotor.py +3 -3
  5. micrOS/source/LM_VL53L0X.py +2 -2
  6. micrOS/source/LM_aht10.py +2 -2
  7. micrOS/source/LM_bme280.py +2 -2
  8. micrOS/source/LM_buzzer.py +12 -15
  9. micrOS/source/LM_cct.py +10 -13
  10. micrOS/source/LM_co2.py +3 -3
  11. micrOS/source/LM_dht11.py +2 -2
  12. micrOS/source/LM_dht22.py +2 -2
  13. micrOS/source/LM_dimmer.py +2 -2
  14. micrOS/source/LM_distance.py +3 -3
  15. micrOS/source/LM_ds18.py +2 -2
  16. micrOS/source/LM_genIO.py +52 -37
  17. micrOS/source/LM_haptic.py +2 -2
  18. micrOS/source/LM_i2c.py +2 -2
  19. micrOS/source/LM_i2s_mic.py +5 -5
  20. micrOS/source/LM_keychain.py +2 -2
  21. micrOS/source/LM_ld2410.py +2 -2
  22. micrOS/source/LM_light_sensor.py +2 -2
  23. micrOS/source/LM_neopixel.py +9 -12
  24. micrOS/source/LM_oled.py +2 -2
  25. micrOS/source/LM_oled_sh1106.py +3 -3
  26. micrOS/source/LM_oled_ui.py +2 -2
  27. micrOS/source/LM_ph_sensor.py +3 -3
  28. micrOS/source/LM_presence.py +2 -2
  29. micrOS/source/LM_rencoder.py +2 -2
  30. micrOS/source/LM_rgb.py +15 -22
  31. micrOS/source/LM_servo.py +3 -3
  32. micrOS/source/LM_stepper.py +5 -5
  33. micrOS/source/LM_switch.py +5 -5
  34. micrOS/source/LM_trackball.py +3 -3
  35. micrOS/source/LM_veml7700.py +2 -2
  36. micrOS/source/Shell.py +1 -1
  37. micrOS/source/microIO.py +27 -9
  38. {micrOSDevToolKit-2.9.6.dist-info → micrOSDevToolKit-2.9.8.dist-info}/METADATA +1 -1
  39. {micrOSDevToolKit-2.9.6.dist-info → micrOSDevToolKit-2.9.8.dist-info}/RECORD +83 -84
  40. toolkit/LM_to_compile.dat +1 -1
  41. toolkit/dashboard_apps/SystemTest.py +1 -1
  42. toolkit/dashboard_apps/uLightDemo.py +1 -1
  43. toolkit/workspace/precompiled/Espnow.mpy +0 -0
  44. toolkit/workspace/precompiled/LM_L298N_DCmotor.mpy +0 -0
  45. toolkit/workspace/precompiled/LM_L9110_DCmotor.py +3 -3
  46. toolkit/workspace/precompiled/LM_VL53L0X.py +2 -2
  47. toolkit/workspace/precompiled/LM_aht10.mpy +0 -0
  48. toolkit/workspace/precompiled/LM_bme280.mpy +0 -0
  49. toolkit/workspace/precompiled/LM_buzzer.mpy +0 -0
  50. toolkit/workspace/precompiled/LM_cct.mpy +0 -0
  51. toolkit/workspace/precompiled/LM_co2.mpy +0 -0
  52. toolkit/workspace/precompiled/LM_dht11.mpy +0 -0
  53. toolkit/workspace/precompiled/LM_dht22.mpy +0 -0
  54. toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
  55. toolkit/workspace/precompiled/LM_distance.mpy +0 -0
  56. toolkit/workspace/precompiled/LM_ds18.mpy +0 -0
  57. toolkit/workspace/precompiled/LM_genIO.mpy +0 -0
  58. toolkit/workspace/precompiled/LM_haptic.mpy +0 -0
  59. toolkit/workspace/precompiled/LM_i2c.py +2 -2
  60. toolkit/workspace/precompiled/LM_i2s_mic.mpy +0 -0
  61. toolkit/workspace/precompiled/LM_keychain.mpy +0 -0
  62. toolkit/workspace/precompiled/LM_ld2410.mpy +0 -0
  63. toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
  64. toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
  65. toolkit/workspace/precompiled/LM_oled.mpy +0 -0
  66. toolkit/workspace/precompiled/LM_oled_sh1106.mpy +0 -0
  67. toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
  68. toolkit/workspace/precompiled/LM_pacman.mpy +0 -0
  69. toolkit/workspace/precompiled/LM_ph_sensor.py +3 -3
  70. toolkit/workspace/precompiled/LM_presence.mpy +0 -0
  71. toolkit/workspace/precompiled/LM_rencoder.py +2 -2
  72. toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
  73. toolkit/workspace/precompiled/LM_servo.mpy +0 -0
  74. toolkit/workspace/precompiled/LM_stepper.mpy +0 -0
  75. toolkit/workspace/precompiled/LM_switch.mpy +0 -0
  76. toolkit/workspace/precompiled/LM_trackball.mpy +0 -0
  77. toolkit/workspace/precompiled/LM_veml7700.mpy +0 -0
  78. toolkit/workspace/precompiled/Shell.mpy +0 -0
  79. toolkit/workspace/precompiled/microIO.mpy +0 -0
  80. toolkit/workspace/precompiled/LM_pacman.py +0 -248
  81. toolkit/workspace/precompiled/node_config.json +0 -1
  82. {micrOSDevToolKit-2.9.6.data → micrOSDevToolKit-2.9.8.data}/scripts/devToolKit.py +0 -0
  83. {micrOSDevToolKit-2.9.6.dist-info → micrOSDevToolKit-2.9.8.dist-info}/LICENSE +0 -0
  84. {micrOSDevToolKit-2.9.6.dist-info → micrOSDevToolKit-2.9.8.dist-info}/WHEEL +0 -0
  85. {micrOSDevToolKit-2.9.6.dist-info → micrOSDevToolKit-2.9.8.dist-info}/top_level.txt +0 -0
@@ -58,14 +58,14 @@
58
58
  ],
59
59
  "Debug.py": [
60
60
  8.4,
61
- 17
61
+ 18
62
62
  ],
63
63
  "Network.py": [
64
64
  9.71,
65
65
  8
66
66
  ],
67
67
  "Espnow.py": [
68
- 9.01,
68
+ 8.86,
69
69
  1
70
70
  ],
71
71
  "Scheduler.py": [
@@ -73,7 +73,7 @@
73
73
  1
74
74
  ],
75
75
  "microIO.py": [
76
- 9.38,
76
+ 9.42,
77
77
  42
78
78
  ],
79
79
  "micrOS.py": [
@@ -105,7 +105,7 @@
105
105
  0
106
106
  ],
107
107
  "LM_genIO.py": [
108
- 9.19,
108
+ 9.12,
109
109
  0
110
110
  ],
111
111
  "LM_oled_ui.py": [
@@ -149,7 +149,7 @@
149
149
  0
150
150
  ],
151
151
  "LM_buzzer.py": [
152
- 8.88,
152
+ 8.8,
153
153
  0
154
154
  ],
155
155
  "LM_switch.py": [
@@ -177,11 +177,11 @@
177
177
  0
178
178
  ],
179
179
  "LM_neopixel.py": [
180
- 7.57,
180
+ 7.54,
181
181
  2
182
182
  ],
183
183
  "LM_cct.py": [
184
- 8.82,
184
+ 9.03,
185
185
  1
186
186
  ],
187
187
  "LM_L9110_DCmotor.py": [
@@ -249,7 +249,7 @@
249
249
  0
250
250
  ],
251
251
  "LM_rgb.py": [
252
- 8.65,
252
+ 8.82,
253
253
  1
254
254
  ],
255
255
  "LM_distance.py": [
@@ -315,11 +315,11 @@
315
315
  },
316
316
  "summary": {
317
317
  "core": [
318
- 3305,
318
+ 3358,
319
319
  23
320
320
  ],
321
321
  "load": [
322
- 9060,
322
+ 9061,
323
323
  55
324
324
  ],
325
325
  "core_dep": [
@@ -332,6 +332,6 @@
332
332
  ],
333
333
  "core_score": 9.13,
334
334
  "load_score": 8.23,
335
- "version": "2.9.6-0"
335
+ "version": "2.9.8-0"
336
336
  }
337
337
  }
micrOS/source/Espnow.py CHANGED
@@ -1,112 +1,146 @@
1
- import uasyncio as asyncio
2
1
  from aioespnow import AIOESPNow
3
2
  from binascii import hexlify
4
- from Tasks import NativeTask, TaskBase
3
+ from Tasks import NativeTask, TaskBase, lm_exec, lm_is_loaded
5
4
  from Network import get_mac
6
5
  from Config import cfgget
6
+ from Debug import errlog_add
7
7
 
8
- # https://docs.micropython.org/en/latest/library/espnow.html
8
+ # Configuration values and globals
9
9
  _INSTANCE = None
10
- _DEVFID = cfgget('devfid')
11
-
10
+ _DEVFID = cfgget('devfid') # for example, "node01"
12
11
 
13
12
  async def asend(now, mac, msg):
14
- prompt = f"{_DEVFID}$"
15
- msg = f"{msg}\n{prompt}".encode("utf-8")
16
- return await now.asend(mac, msg)
17
-
13
+ """
14
+ Send a message over ESPNow. The sent message will be extended with the server prompt.
15
+ The prompt indicates the end-of-message with a '$' marker.
16
+ """
17
+ prompt = f"{_DEVFID}$" # '$' symbol is the ACK (end of message)!
18
+ # Append a newline and the server prompt to the message.
19
+ full_msg = f"{msg}\n{prompt}".encode("utf-8")
20
+ return await now.asend(mac, full_msg)
18
21
 
19
- def execute(msg, my_task):
20
- msg_in = msg.decode('utf-8')
21
- if msg_in.strip().endswith("$"):
22
- my_task.out = f"MSG-IN: {msg_in}"
23
- data = msg_in.split("\n")
24
- prompt, command = data[0], data[1]
25
- msg_out = f"RUN CMD: {command} ON {prompt.replace('$', '')}"
26
- # TODO: execute command
27
- return True, msg_out
28
- return False, ""
22
+ def _serv_execute(msg, my_task):
23
+ """
24
+ Process an incoming command and return a tuple (ready, response).
29
25
 
26
+ The function decodes the message, strips any trailing '$' (which marks the prompt),
27
+ and then interprets the message as a command. The command is split into tokens where
28
+ the first token is considered the module/command. If the module is allowed (lm_is_loaded),
29
+ the command is executed with lm_exec; otherwise, "NotAllowed" is returned.
30
+ """
31
+ try:
32
+ command_line = msg.decode('utf-8').strip()
33
+ except UnicodeError:
34
+ my_task.out = "[NOW SERVE] Invalid encoding"
35
+ return False, "Invalid encoding"
36
+
37
+ # Split the command into tokens.
38
+ tokens = command_line.split()
39
+ if not tokens:
40
+ return False, "[NOW SERVE] Empty command"
41
+ # Remove trailing prompt marker if present.
42
+ client_token = "?$"
43
+ if tokens[-1].endswith("$"):
44
+ client_token = tokens[-1]
45
+ tokens = tokens[:-1]
46
+ my_task.out = f"[NOW SERVE] {' '.join(tokens)} (from {client_token})"
47
+ # Check if the module/command is allowed.
48
+ module = tokens[0]
49
+ if lm_is_loaded(module):
50
+ try:
51
+ state, out = lm_exec(tokens)
52
+ except Exception as e:
53
+ # Optionally log the exception here.
54
+ state, out = False, f"[ERR][NOW SERVE] {tokens}: {e}"
55
+ else:
56
+ state, out = False, f"[WARN][NOW SERVE] NotAllowed {tokens[0]}"
57
+ return state, out
30
58
 
31
- # Echo any received messages back to the sender
32
59
  async def _server(now):
60
+ """
61
+ ESPNow server task that continuously waits for incoming messages and processes commands.
62
+ """
33
63
  with TaskBase.TASKS.get('espnow.server', None) as my_task:
34
64
  async for mac, msg in now:
35
65
  try:
36
- msg_ready, msg = execute(msg, my_task)
37
- if msg_ready:
38
- await asend(now, mac, msg)
66
+ state, response = _serv_execute(msg, my_task)
67
+ if state:
68
+ await asend(now, mac, response)
69
+ else:
70
+ errlog_add(response)
39
71
  except OSError as err:
72
+ # If the peer is not yet added, add it and retry.
40
73
  if len(err.args) > 1 and err.args[1] == 'ESP_ERR_ESPNOW_NOT_FOUND':
41
74
  now.add_peer(mac)
42
- msg_ready, msg = execute(msg, my_task)
43
- if msg_ready:
44
- await asend(now, mac, msg)
75
+ state, response = _serv_execute(msg, my_task)
76
+ if state:
77
+ await asend(now, mac, response)
78
+ else:
79
+ errlog_add(response)
80
+ else:
81
+ # Optionally handle or log other OSErrors here.
82
+ errlog_add(f"[ERR][NOW SERVER] {err}")
45
83
 
46
-
47
- # Send a periodic ping to a peer
48
84
  async def _send(now, peer, tag, msg):
49
- with TaskBase.TASKS.get(tag) as my_task:
85
+ """
86
+ ESPNow client task: send a command to a peer and update task status.
87
+ """
88
+ with TaskBase.TASKS.get(tag, None) as my_task:
50
89
  if not await asend(now, peer, msg):
51
- my_task.out = "Peer not responding"
90
+ my_task.out = "[NOW SEND] Peer not responding"
52
91
  else:
53
- my_task.out = f"send msg: {msg}"
54
-
92
+ my_task.out = f"[NOW SEND] {msg}"
55
93
 
56
94
  ###################################################
57
95
  # Control functions #
58
96
  ###################################################
59
97
  def initialize():
60
98
  """
61
- Initialize ESPNow protocol
99
+ Initialize the ESPNow protocol. (WLAN must be active.)
62
100
  """
63
- # Network module: WLAN interface must be active to send()/recv()
64
101
  global _INSTANCE
65
102
  if _INSTANCE is None:
66
- now = AIOESPNow() # Returns AIOESPNow enhanced with async support
103
+ now = AIOESPNow() # Instance with async support
67
104
  now.active(True)
68
105
  _INSTANCE = now
69
106
  return _INSTANCE
70
107
 
71
-
72
108
  def add_peer(now, peer):
73
109
  """
74
- Add peer by mac address
75
- :param now: espnow instance
76
- :param peer: binary mac address of a peer, like b'\xbb\xbb\xbb\xbb\xbb\xbb'
110
+ Add a peer given its MAC address.
111
+ :param now: ESPNow instance.
112
+ :param peer: Binary MAC address of a peer (e.g. b'\xbb\xbb\xbb\xbb\xbb\xbb').
77
113
  """
78
- return now.add_peer(peer)
79
-
114
+ now.add_peer(peer)
115
+ return "Peer register done"
80
116
 
81
117
  def espnow_server():
82
118
  """
83
- Start async ESPNow receiver server
119
+ Start the async ESPNow receiver server.
84
120
  """
85
121
  now = initialize()
86
- # [!] ASYNC TASK CREATION [1*] with async task callback + taskID (TAG) handling
122
+ # Create an asynchronous task with tag 'espnow.server'
87
123
  state = NativeTask().create(callback=_server(now), tag='espnow.server')
88
124
  return "Starting" if state else "Already running"
89
125
 
90
-
91
126
  def espnow_send(peer, msg):
92
127
  """
93
- Send message/command over ESPNow protocol
94
- :param peer: binary mac address of another device
95
- :param msg: string message to send
128
+ Send a command over ESPNow.
129
+ :param peer: Binary MAC address of another device.
130
+ :param msg: String command message to send.
96
131
  """
97
132
  now = initialize()
98
- mac = hexlify(peer, ':').decode()
99
- task_id = f"espnow.cli.{mac}"
100
- # [!] ASYNC TASK CREATION [1*] with async task callback + taskID (TAG) handling
133
+ mac_str = hexlify(peer, ':').decode()
134
+ task_id = f"espnow.cli.{mac_str}"
135
+ # Create an asynchronous sending task.
101
136
  state = NativeTask().create(callback=_send(now, peer, task_id, msg), tag=task_id)
102
137
  return "Starting" if state else "Already running"
103
138
 
104
-
105
139
  def stats():
106
140
  """
107
- Return stats for ESPNow peers
108
- stats: tx_pkts, tx_responses, tx_failures, rx_packets, rx_dropped_packets
109
- peers: peer, rssi, time_ms
141
+ Return stats for ESPNow peers.
142
+ stats: tx_pkts, tx_responses, tx_failures, rx_packets, rx_dropped_packets.
143
+ peers: peer, rssi, time_ms.
110
144
  """
111
145
  now = initialize()
112
146
  try:
@@ -119,9 +153,8 @@ def stats():
119
153
  _peers = str(e)
120
154
  return {"stats": _stats, "peers": _peers}
121
155
 
122
-
123
156
  def mac_address():
124
157
  """
125
- Get binary mac address
158
+ Get the binary MAC address.
126
159
  """
127
160
  return get_mac()
@@ -1,5 +1,5 @@
1
1
  from machine import Pin, PWM
2
- from microIO import resolve_pin, pinmap_search
2
+ from microIO import bind_pin, pinmap_search
3
3
 
4
4
  #########################################
5
5
  # ANALOG DIMMER CONTROLLER PARAMS #
@@ -15,9 +15,9 @@ __L298N_OBJS = []
15
15
  def __l298n_init():
16
16
  global __L298N_OBJS
17
17
  if len(__L298N_OBJS) == 0:
18
- __L298N_OBJS.append(PWM(Pin(resolve_pin('l298speed')), freq=50))
19
- __L298N_OBJS.append(Pin(resolve_pin('l298dir_1'), Pin.OUT))
20
- __L298N_OBJS.append(Pin(resolve_pin('l298dir_2'), Pin.OUT))
18
+ __L298N_OBJS.append(PWM(Pin(bind_pin('l298speed')), freq=50))
19
+ __L298N_OBJS.append(Pin(bind_pin('l298dir_1'), Pin.OUT))
20
+ __L298N_OBJS.append(Pin(bind_pin('l298dir_2'), Pin.OUT))
21
21
  __L298N_OBJS[0].duty(0) # Set default speed (PWM)
22
22
  __L298N_OBJS[1].value(0) # Set default direction for dc motor1
23
23
  __L298N_OBJS[2].value(1) # Set default direction for dc motor1
@@ -1,4 +1,4 @@
1
- from microIO import resolve_pin, pinmap_search
1
+ from microIO import bind_pin, pinmap_search
2
2
 
3
3
  #########################################
4
4
  # ANALOG DIMMER CONTROLLER PARAMS #
@@ -15,8 +15,8 @@ def __l9110_init():
15
15
  global __L9110_OBJS
16
16
  if len(__L9110_OBJS) == 0:
17
17
  from machine import Pin, PWM
18
- __L9110_OBJS.append(PWM(Pin(resolve_pin('l9110dir_1')), freq=1024))
19
- __L9110_OBJS.append(PWM(Pin(resolve_pin('l9110dir_2')), freq=1024))
18
+ __L9110_OBJS.append(PWM(Pin(bind_pin('l9110dir_1')), freq=1024))
19
+ __L9110_OBJS.append(PWM(Pin(bind_pin('l9110dir_2')), freq=1024))
20
20
  __L9110_OBJS[0].duty(0) # Set default speed (PWM)
21
21
  __L9110_OBJS[1].duty(0) # Set default speed (PWM)
22
22
  return __L9110_OBJS
@@ -2,7 +2,7 @@ from micropython import const
2
2
  import ustruct
3
3
  import utime
4
4
  from machine import I2C, Pin
5
- from microIO import resolve_pin, pinmap_search
5
+ from microIO import bind_pin, pinmap_search
6
6
 
7
7
  __TOF_OBJ = None
8
8
 
@@ -31,7 +31,7 @@ class TimeoutError(RuntimeError):
31
31
 
32
32
  class VL53L0X:
33
33
  def __init__(self, address=57):
34
- self.i2c = I2C(-1, Pin(resolve_pin('i2c_scl')), Pin(resolve_pin('i2c_sda')), freq=9600)
34
+ self.i2c = I2C(-1, Pin(bind_pin('i2c_scl')), Pin(bind_pin('i2c_sda')), freq=9600)
35
35
  self.address = address
36
36
  self.init()
37
37
  self._started = False
micrOS/source/LM_aht10.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from machine import I2C, Pin
2
- from microIO import resolve_pin, pinmap_search
2
+ from microIO import bind_pin, pinmap_search
3
3
  from Common import syslog
4
4
  from time import sleep
5
5
  from binascii import hexlify
@@ -24,7 +24,7 @@ def _handle_connection_error(f):
24
24
 
25
25
  class AHT10:
26
26
  def __init__(self, address = 0x38):
27
- self.i2c = I2C(-1, Pin(resolve_pin('i2c_scl')), Pin(resolve_pin('i2c_sda')), freq = 9600)
27
+ self.i2c = I2C(-1, Pin(bind_pin('i2c_scl')), Pin(bind_pin('i2c_sda')), freq = 9600)
28
28
  self.address = address
29
29
  if not self.init_sensor():
30
30
  raise Exception("Could not initialize the sensor!")
@@ -6,7 +6,7 @@ https://randomnerdtutorials.com/micropython-bme280-esp32-esp8266/
6
6
 
7
7
  import utime as time
8
8
  from machine import Pin, I2C
9
- from microIO import resolve_pin, pinmap_search
9
+ from microIO import bind_pin, pinmap_search
10
10
  from Common import notify
11
11
  from Types import resolve
12
12
 
@@ -299,7 +299,7 @@ class BME280:
299
299
  def __init_bme280_i2c():
300
300
  global BME280_OBJ
301
301
  if BME280_OBJ is None:
302
- i2c = I2C(scl=Pin(resolve_pin('i2c_scl')), sda=Pin(resolve_pin('i2c_sda')), freq=10000)
302
+ i2c = I2C(scl=Pin(bind_pin('i2c_scl')), sda=Pin(bind_pin('i2c_sda')), freq=10000)
303
303
  BME280_OBJ = BME280(i2c=i2c)
304
304
  return BME280_OBJ
305
305
 
@@ -1,6 +1,6 @@
1
1
  from sys import platform
2
2
  from utime import sleep
3
- from microIO import resolve_pin, pinmap_search
3
+ from microIO import bind_pin, pinmap_search
4
4
  from Common import micro_task, notify
5
5
  from Types import resolve
6
6
 
@@ -175,15 +175,15 @@ def _builtin_tones(tone=None):
175
175
  #########################################
176
176
 
177
177
 
178
- def __buzzer_init():
178
+ def __buzzer_init(pin=None):
179
+ """
180
+ :param pin: optional number to overwrite default pin
181
+ """
179
182
  global __BUZZER_OBJ
180
183
  if __BUZZER_OBJ is None:
181
184
  from machine import Pin, PWM
182
- dimmer_pin = Pin(resolve_pin('buzzer'))
183
- if platform == 'esp8266':
184
- __BUZZER_OBJ = PWM(dimmer_pin, freq=600)
185
- else:
186
- __BUZZER_OBJ = PWM(dimmer_pin, freq=600)
185
+ dimmer_pin = Pin(bind_pin('buzzer', number=pin))
186
+ __BUZZER_OBJ = PWM(dimmer_pin, freq=600)
187
187
  __BUZZER_OBJ.duty(512) # 50%
188
188
  return __BUZZER_OBJ
189
189
 
@@ -283,23 +283,20 @@ def list_tones():
283
283
  return '\n'.join(list(_builtin_tones()))
284
284
 
285
285
 
286
- def load(cache=None, check_notify=False):
286
+ def load(check_notify=False, pin=None, cache=True):
287
287
  """
288
288
  Initialize buzzer module
289
- :param cache bool: file state machine cache: True/False/None(default: automatic True)
290
- - Load .pds (state machine cache) for this load module
291
- - Apply loaded states to gpio pins (boot function)
292
289
  :param check_notify: check notify enabled/disabled - make noise if enabled only
290
+ :param pin: optional number to overwrite default pin
291
+ :param cache: default True, store stages on disk (.pds)
293
292
  :return str: Verdict
294
293
  """
295
294
  from sys import platform
296
295
  global __PERSISTENT_CACHE, CHECK_NOTIFY
297
- if cache is None:
298
- __PERSISTENT_CACHE = False if platform == 'esp8266' else True
299
- else:
300
- __PERSISTENT_CACHE = cache
296
+ __PERSISTENT_CACHE = cache
301
297
  __persistent_cache_manager('r')
302
298
  CHECK_NOTIFY = check_notify
299
+ __buzzer_init(pin=pin)
303
300
  return f"CACHE: {__PERSISTENT_CACHE}, check notify: {CHECK_NOTIFY}"
304
301
 
305
302
 
micrOS/source/LM_cct.py CHANGED
@@ -5,7 +5,7 @@ from machine import Pin, PWM
5
5
  from sys import platform
6
6
  from utime import sleep_ms
7
7
  from Common import transition_gen, micro_task
8
- from microIO import resolve_pin, pinmap_search
8
+ from microIO import bind_pin, pinmap_search
9
9
  from random import randint
10
10
  from Types import resolve
11
11
 
@@ -24,10 +24,10 @@ class Data:
24
24
  # ANALOG CCT WITH 2 channel PWM #
25
25
  #########################################
26
26
 
27
- def __cwww_init():
27
+ def __cwww_init(pin_warm=None, pin_cold=None):
28
28
  if Data.CWWW_OBJS[0] is None or Data.CWWW_OBJS[1] is None:
29
- cw = Pin(resolve_pin('cwhite'))
30
- ww = Pin(resolve_pin('wwhite'))
29
+ cw = Pin(bind_pin('cwhite', pin_cold))
30
+ ww = Pin(bind_pin('wwhite', pin_warm))
31
31
  if platform == 'esp8266':
32
32
  Data.CWWW_OBJS = (PWM(cw, freq=1024),
33
33
  PWM(ww, freq=1024))
@@ -72,19 +72,16 @@ def __state_machine(c, w):
72
72
  # Application functions #
73
73
  #########################
74
74
 
75
- def load(cache=None):
75
+ def load(pin_warm=None, pin_cold=None, cache=True):
76
76
  """
77
77
  Initialize Cold white / Warm white LED module
78
- :param cache bool: file state machine cache: True/False/None(default: automatic True)
79
- - Load .pds (state machine cache) for this load module
80
- - Apply loaded states to gpio pins (boot function)
78
+ :param pin_warm: optional number to overwrite default pin
79
+ :param pin_cold: optional number to overwrite default pin
80
+ :param cache: save/load state machine to disk (.pds)
81
81
  :return str: Cache state
82
82
  """
83
- from sys import platform
84
- if cache is None:
85
- Data.PERSISTENT_CACHE = False if platform == 'esp8266' else True
86
- else:
87
- Data.PERSISTENT_CACHE = cache
83
+ __cwww_init(pin_warm, pin_cold)
84
+ Data.PERSISTENT_CACHE = cache
88
85
  __persistent_cache_manager('r') # recover data cache
89
86
  if Data.CWWW_CACHE[2] == 1:
90
87
  Data.CWWW_CACHE[2] = 0 # Force ON at boot
micrOS/source/LM_co2.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from math import pow
2
2
  from sys import platform
3
3
  from machine import ADC, Pin
4
- from microIO import resolve_pin, pinmap_search
4
+ from microIO import bind_pin, pinmap_search
5
5
  from Types import resolve
6
6
 
7
7
  #########################################
@@ -20,10 +20,10 @@ def __get_resistance():
20
20
  global __ADC, __ADC_PROP
21
21
  if __ADC is None:
22
22
  if 'esp8266' in platform:
23
- __ADC = ADC(resolve_pin('co2')) # 1V measure range
23
+ __ADC = ADC(bind_pin('co2')) # 1V measure range
24
24
  __ADC_PROP = (1023, 1.0)
25
25
  else:
26
- __ADC = ADC(Pin(resolve_pin('co2')))
26
+ __ADC = ADC(Pin(bind_pin('co2')))
27
27
  __ADC.atten(ADC.ATTN_11DB) # 3.6V measure range
28
28
  __ADC.width(ADC.WIDTH_10BIT) # Default 10 bit ADC
29
29
  __ADC_PROP = (1023, 3.6)
micrOS/source/LM_dht11.py CHANGED
@@ -1,4 +1,4 @@
1
- from microIO import resolve_pin, pinmap_search
1
+ from microIO import bind_pin, pinmap_search
2
2
  from Common import data_logger
3
3
  from Types import resolve
4
4
 
@@ -14,7 +14,7 @@ def __init_DHT11():
14
14
  if __DHT_OBJ is None:
15
15
  from dht import DHT11
16
16
  from machine import Pin
17
- __DHT_OBJ = DHT11(Pin(resolve_pin('dhtpin')))
17
+ __DHT_OBJ = DHT11(Pin(bind_pin('dhtpin')))
18
18
  return __DHT_OBJ
19
19
 
20
20
 
micrOS/source/LM_dht22.py CHANGED
@@ -1,4 +1,4 @@
1
- from microIO import resolve_pin, pinmap_search
1
+ from microIO import bind_pin, pinmap_search
2
2
  from Common import data_logger
3
3
  from Types import resolve
4
4
 
@@ -14,7 +14,7 @@ def __init_DHT22():
14
14
  if __DHT_OBJ is None:
15
15
  from dht import DHT22
16
16
  from machine import Pin
17
- __DHT_OBJ = DHT22(Pin(resolve_pin('dhtpin')))
17
+ __DHT_OBJ = DHT22(Pin(bind_pin('dhtpin')))
18
18
  return __DHT_OBJ
19
19
 
20
20
 
@@ -1,5 +1,5 @@
1
1
  from sys import platform
2
- from microIO import resolve_pin, pinmap_search
2
+ from microIO import bind_pin, pinmap_search
3
3
  from Common import transition_gen, micro_task
4
4
  from utime import sleep_ms
5
5
  from Types import resolve
@@ -24,7 +24,7 @@ class Data:
24
24
  def __dimmer_init():
25
25
  if Data.DIMMER_OBJ is None:
26
26
  from machine import Pin, PWM
27
- dimmer_pin = Pin(resolve_pin('dim_1'))
27
+ dimmer_pin = Pin(bind_pin('dim_1'))
28
28
  if platform == 'esp8266':
29
29
  Data.DIMMER_OBJ = PWM(dimmer_pin, freq=1024)
30
30
  else:
@@ -1,6 +1,6 @@
1
1
  from machine import Pin, time_pulse_us
2
2
  from utime import sleep_us
3
- from microIO import resolve_pin, pinmap_search
3
+ from microIO import bind_pin, pinmap_search
4
4
  from Common import micro_task
5
5
  from Types import resolve
6
6
 
@@ -14,8 +14,8 @@ def __init_HCSR04():
14
14
  """
15
15
  global __TRIGGER_OBJ, __ECHO_OBJ
16
16
  if __TRIGGER_OBJ is None or __ECHO_OBJ is None:
17
- trigger_pin = resolve_pin('hcsrtrig')
18
- echo_pin = resolve_pin('hcsrecho')
17
+ trigger_pin = bind_pin('hcsrtrig')
18
+ echo_pin = bind_pin('hcsrecho')
19
19
  # Init trigger pin (out)
20
20
  __TRIGGER_OBJ = Pin(trigger_pin, mode=Pin.OUT, pull=None)
21
21
  __TRIGGER_OBJ.value(0)
micrOS/source/LM_ds18.py CHANGED
@@ -1,5 +1,5 @@
1
1
  import machine, onewire, ds18x20, time
2
- from microIO import resolve_pin, pinmap_search
2
+ from microIO import bind_pin, pinmap_search
3
3
  from Types import resolve
4
4
 
5
5
  DS_OBJ = None
@@ -8,7 +8,7 @@ DS_OBJ = None
8
8
  def __init_DS18():
9
9
  global DS_OBJ
10
10
  if DS_OBJ is None:
11
- ds_pin = machine.Pin(resolve_pin('ds18'))
11
+ ds_pin = machine.Pin(bind_pin('ds18'))
12
12
  DS_OBJ = ds18x20.DS18X20(onewire.OneWire(ds_pin))
13
13
  return DS_OBJ
14
14