micrOSDevToolKit 2.8.5__py3-none-any.whl → 2.8.7__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.
- env/driver_cp210x/.DS_Store +0 -0
- env/driver_cp210x/macOS_VCP_Driver/SiLabsUSBDriverDisk.dmg +0 -0
- env/driver_cp210x/macOS_VCP_Driver/macOS_VCP_Driver_Release_Notes.txt +0 -0
- micrOS/micropython/esp32-20241129-v1.24.1.bin +0 -0
- micrOS/micropython/esp32s3-20241129-v1.24.1.bin +0 -0
- micrOS/micropython/esp32s3_spiram_oct-20241129-v1.24.1.bin +0 -0
- micrOS/micropython/rpi-pico-w-20241129-v1.24.1.uf2 +0 -0
- micrOS/micropython/tinypico-20241129-v1.24.1.bin +0 -0
- micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +28 -28
- micrOS/source/Common.py +2 -2
- micrOS/source/Hooks.py +25 -15
- micrOS/source/LM_buzzer.py +1 -2
- micrOS/source/LM_cct.py +2 -3
- micrOS/source/LM_dimmer.py +1 -2
- micrOS/source/LM_distance.py +2 -4
- micrOS/source/LM_i2s_mic.py +4 -4
- micrOS/source/LM_keychain.py +2 -3
- micrOS/source/LM_light_sensor.py +1 -2
- micrOS/source/LM_neopixel.py +1 -2
- micrOS/source/LM_oledui.py +3 -4
- micrOS/source/LM_pet_feeder.py +3 -4
- micrOS/source/LM_presence.py +1 -2
- micrOS/source/LM_rest.py +52 -9
- micrOS/source/LM_rgb.py +1 -2
- micrOS/source/LM_roboarm.py +1 -2
- micrOS/source/LM_sound_event.py +2 -3
- micrOS/source/Notify.py +0 -1
- micrOS/source/Scheduler.py +7 -4
- micrOS/source/Shell.py +2 -2
- micrOS/source/Tasks.py +106 -98
- micrOS/source/Web.py +16 -5
- micrOS/source/dashboard.html +4 -4
- micrOS/source/micrOS.py +5 -10
- micrOS/source/micrOSloader.py +0 -5
- micrOS/source/uapi.js +5 -6
- micrOS/source/urequests.py +171 -85
- {micrOSDevToolKit-2.8.5.dist-info → micrOSDevToolKit-2.8.7.dist-info}/METADATA +1 -1
- {micrOSDevToolKit-2.8.5.dist-info → micrOSDevToolKit-2.8.7.dist-info}/RECORD +79 -81
- toolkit/DevEnvUSB.py +1 -6
- toolkit/lib/pip_package_installer.py +25 -7
- toolkit/simulator_lib/__pycache__/simulator.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/uasyncio.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/usocket.cpython-312.pyc +0 -0
- toolkit/simulator_lib/simulator.py +14 -0
- toolkit/simulator_lib/uasyncio.py +2 -2
- toolkit/simulator_lib/usocket.py +5 -1
- toolkit/workspace/precompiled/Common.mpy +0 -0
- toolkit/workspace/precompiled/Hooks.mpy +0 -0
- toolkit/workspace/precompiled/LM_buzzer.mpy +0 -0
- toolkit/workspace/precompiled/LM_cct.mpy +0 -0
- toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
- toolkit/workspace/precompiled/LM_distance.mpy +0 -0
- toolkit/workspace/precompiled/LM_i2s_mic.mpy +0 -0
- toolkit/workspace/precompiled/LM_keychain.mpy +0 -0
- toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
- toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
- toolkit/workspace/precompiled/LM_oledui.mpy +0 -0
- toolkit/workspace/precompiled/LM_pet_feeder.py +3 -4
- toolkit/workspace/precompiled/LM_presence.mpy +0 -0
- toolkit/workspace/precompiled/LM_rest.mpy +0 -0
- toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
- toolkit/workspace/precompiled/LM_roboarm.mpy +0 -0
- toolkit/workspace/precompiled/LM_sound_event.mpy +0 -0
- toolkit/workspace/precompiled/Notify.mpy +0 -0
- toolkit/workspace/precompiled/Scheduler.mpy +0 -0
- toolkit/workspace/precompiled/Shell.mpy +0 -0
- toolkit/workspace/precompiled/Tasks.mpy +0 -0
- toolkit/workspace/precompiled/Web.mpy +0 -0
- toolkit/workspace/precompiled/dashboard.html +4 -4
- toolkit/workspace/precompiled/micrOS.mpy +0 -0
- toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
- toolkit/workspace/precompiled/node_config.json +1 -1
- toolkit/workspace/precompiled/uapi.js +5 -6
- toolkit/workspace/precompiled/urequests.mpy +0 -0
- env/driver_cp210x/CH34XSER_MAC/CH34X_DRV_INSTALL_INSTRUCTIONS.pdf +0 -0
- env/driver_cp210x/CH34XSER_MAC/CH34xVCPDriver.pkg +0 -0
- micrOS/micropython/esp32-20231005-v1.21.0.bin +0 -0
- micrOS/micropython/esp32-GENERIC-20240602-v1.23.0.bin +0 -0
- micrOS/micropython/rpi-pico-w-20240602-v1.23.0.uf2 +0 -0
- micrOS/micropython/tinypico-20231005-v1.21.0.bin +0 -0
- micrOS/micropython/tinypico_usbc-UM-20240105-v1.22.1.bin +0 -0
- /micrOS/micropython/{esp32c3-GENERIC-20240222-v1.22.2.bin → esp32c3-20240222-v1.22.2.bin} +0 -0
- /micrOS/micropython/{esp32s2-GENERIC-20240602-v1.23.0.bin → esp32s2-20240602-v1.23.0.bin} +0 -0
- /micrOS/micropython/{esp32s3-GENERIC-20240105-v1.22.1.bin → esp32s3-20240105-v1.22.1.bin} +0 -0
- {micrOSDevToolKit-2.8.5.data → micrOSDevToolKit-2.8.7.data}/scripts/devToolKit.py +0 -0
- {micrOSDevToolKit-2.8.5.dist-info → micrOSDevToolKit-2.8.7.dist-info}/LICENSE +0 -0
- {micrOSDevToolKit-2.8.5.dist-info → micrOSDevToolKit-2.8.7.dist-info}/WHEEL +0 -0
- {micrOSDevToolKit-2.8.5.dist-info → micrOSDevToolKit-2.8.7.dist-info}/top_level.txt +0 -0
env/driver_cp210x/.DS_Store
CHANGED
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
7
|
|
6
6
|
],
|
|
7
7
|
"micrOSloader.py": [
|
|
8
|
-
7.
|
|
8
|
+
7.84,
|
|
9
9
|
1
|
|
10
10
|
],
|
|
11
11
|
"Hooks.py": [
|
|
12
|
-
9.
|
|
12
|
+
9.85,
|
|
13
13
|
1
|
|
14
14
|
],
|
|
15
15
|
"Server.py": [
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
3
|
|
18
18
|
],
|
|
19
19
|
"Web.py": [
|
|
20
|
-
9.
|
|
20
|
+
9.23,
|
|
21
21
|
1
|
|
22
22
|
],
|
|
23
23
|
"Tasks.py": [
|
|
24
|
-
9.
|
|
24
|
+
9.55,
|
|
25
25
|
12
|
|
26
26
|
],
|
|
27
27
|
"Config.py": [
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
0
|
|
34
34
|
],
|
|
35
35
|
"Shell.py": [
|
|
36
|
-
9.
|
|
36
|
+
9.33,
|
|
37
37
|
1
|
|
38
38
|
],
|
|
39
39
|
"Notify.py": [
|
|
40
|
-
9.
|
|
40
|
+
9.26,
|
|
41
41
|
2
|
|
42
42
|
],
|
|
43
43
|
"Types.py": [
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
4
|
|
50
50
|
],
|
|
51
51
|
"Common.py": [
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
8.48,
|
|
53
|
+
33
|
|
54
54
|
],
|
|
55
55
|
"InterConnect.py": [
|
|
56
56
|
9.4,
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
1
|
|
70
70
|
],
|
|
71
71
|
"Scheduler.py": [
|
|
72
|
-
9.
|
|
72
|
+
9.62,
|
|
73
73
|
1
|
|
74
74
|
],
|
|
75
75
|
"microIO.py": [
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
42
|
|
78
78
|
],
|
|
79
79
|
"micrOS.py": [
|
|
80
|
-
9.
|
|
80
|
+
9.25,
|
|
81
81
|
1
|
|
82
82
|
],
|
|
83
83
|
"Interrupts.py": [
|
|
@@ -89,11 +89,11 @@
|
|
|
89
89
|
0
|
|
90
90
|
],
|
|
91
91
|
"urequests.py": [
|
|
92
|
-
8.
|
|
93
|
-
|
|
92
|
+
8.79,
|
|
93
|
+
5
|
|
94
94
|
],
|
|
95
95
|
"LM_roboarm.py": [
|
|
96
|
-
7.
|
|
96
|
+
7.76,
|
|
97
97
|
0
|
|
98
98
|
],
|
|
99
99
|
"LM_stepper.py": [
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
0
|
|
122
122
|
],
|
|
123
123
|
"LM_rest.py": [
|
|
124
|
-
7.
|
|
124
|
+
7.78,
|
|
125
125
|
0
|
|
126
126
|
],
|
|
127
127
|
"LM_oled.py": [
|
|
@@ -173,11 +173,11 @@
|
|
|
173
173
|
0
|
|
174
174
|
],
|
|
175
175
|
"LM_neopixel.py": [
|
|
176
|
-
7.
|
|
176
|
+
7.57,
|
|
177
177
|
2
|
|
178
178
|
],
|
|
179
179
|
"LM_cct.py": [
|
|
180
|
-
8.
|
|
180
|
+
8.82,
|
|
181
181
|
1
|
|
182
182
|
],
|
|
183
183
|
"LM_L9110_DCmotor.py": [
|
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
0
|
|
210
210
|
],
|
|
211
211
|
"LM_pet_feeder.py": [
|
|
212
|
-
|
|
212
|
+
7.94,
|
|
213
213
|
0
|
|
214
214
|
],
|
|
215
215
|
"LM_rencoder.py": [
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
0
|
|
218
218
|
],
|
|
219
219
|
"LM_keychain.py": [
|
|
220
|
-
9.
|
|
220
|
+
9.17,
|
|
221
221
|
0
|
|
222
222
|
],
|
|
223
223
|
"LM_dht11.py": [
|
|
@@ -245,11 +245,11 @@
|
|
|
245
245
|
0
|
|
246
246
|
],
|
|
247
247
|
"LM_rgb.py": [
|
|
248
|
-
8.
|
|
248
|
+
8.65,
|
|
249
249
|
1
|
|
250
250
|
],
|
|
251
251
|
"LM_distance.py": [
|
|
252
|
-
8.
|
|
252
|
+
8.87,
|
|
253
253
|
0
|
|
254
254
|
],
|
|
255
255
|
"LM_VL53L0X.py": [
|
|
@@ -257,7 +257,7 @@
|
|
|
257
257
|
0
|
|
258
258
|
],
|
|
259
259
|
"LM_light_sensor.py": [
|
|
260
|
-
8.
|
|
260
|
+
8.97,
|
|
261
261
|
0
|
|
262
262
|
],
|
|
263
263
|
"LM_rp2w.py": [
|
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
0
|
|
266
266
|
],
|
|
267
267
|
"LM_presence.py": [
|
|
268
|
-
8.
|
|
268
|
+
8.77,
|
|
269
269
|
4
|
|
270
270
|
],
|
|
271
271
|
"LM_trackball.py": [
|
|
@@ -277,7 +277,7 @@
|
|
|
277
277
|
0
|
|
278
278
|
],
|
|
279
279
|
"LM_dimmer.py": [
|
|
280
|
-
8.
|
|
280
|
+
8.32,
|
|
281
281
|
1
|
|
282
282
|
],
|
|
283
283
|
"LM_demo.py": [
|
|
@@ -315,11 +315,11 @@
|
|
|
315
315
|
},
|
|
316
316
|
"summary": {
|
|
317
317
|
"core": [
|
|
318
|
-
|
|
318
|
+
3390,
|
|
319
319
|
23
|
|
320
320
|
],
|
|
321
321
|
"load": [
|
|
322
|
-
|
|
322
|
+
8732,
|
|
323
323
|
55
|
|
324
324
|
],
|
|
325
325
|
"core_dep": [
|
|
@@ -330,8 +330,8 @@
|
|
|
330
330
|
true,
|
|
331
331
|
6
|
|
332
332
|
],
|
|
333
|
-
"core_score": 9.
|
|
334
|
-
"load_score": 8.
|
|
335
|
-
"version": "2.8.
|
|
333
|
+
"core_score": 9.07,
|
|
334
|
+
"load_score": 8.2,
|
|
335
|
+
"version": "2.8.4-0"
|
|
336
336
|
}
|
|
337
337
|
}
|
micrOS/source/Common.py
CHANGED
|
@@ -141,7 +141,6 @@ def exec_cmd(cmd, skip_check=False):
|
|
|
141
141
|
return lm_exec(cmd) if isinstance(cmd, list) else False, f"Invalid type, must be list: {type(cmd)}"
|
|
142
142
|
|
|
143
143
|
|
|
144
|
-
|
|
145
144
|
def notify(text):
|
|
146
145
|
"""
|
|
147
146
|
[LM] micrOS common notification handler (Telegram)
|
|
@@ -165,6 +164,7 @@ def notify(text):
|
|
|
165
164
|
return True
|
|
166
165
|
return False
|
|
167
166
|
|
|
167
|
+
|
|
168
168
|
def web_endpoint(endpoint, function):
|
|
169
169
|
"""
|
|
170
170
|
[LM] Add test endpoint <localhost.local>/endpoint from Load Modules
|
|
@@ -215,7 +215,7 @@ def data_logger(f_name, data=None, limit=12, msgobj=None):
|
|
|
215
215
|
|
|
216
216
|
def syslog(msg):
|
|
217
217
|
""" Wrapper of errlog_add """
|
|
218
|
-
return errlog_add(f"[U]{msg}")
|
|
218
|
+
return errlog_add(f"[U] {msg}")
|
|
219
219
|
|
|
220
220
|
|
|
221
221
|
def console(msg):
|
micrOS/source/Hooks.py
CHANGED
|
@@ -19,13 +19,17 @@ 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
|
|
22
|
+
from Debug import console_write, errlog_add
|
|
23
23
|
from Tasks import exec_lm_pipe
|
|
24
24
|
from micropython import mem_info
|
|
25
25
|
from machine import freq
|
|
26
|
+
try:
|
|
27
|
+
from machine import reset_cause, PWRON_RESET, HARD_RESET, WDT_RESET, DEEPSLEEP_RESET, SOFT_RESET
|
|
28
|
+
except ImportError:
|
|
29
|
+
reset_cause = None
|
|
26
30
|
try:
|
|
27
31
|
from gc import mem_free
|
|
28
|
-
except:
|
|
32
|
+
except ImportError:
|
|
29
33
|
from simgc import mem_free
|
|
30
34
|
|
|
31
35
|
#################################################################
|
|
@@ -38,9 +42,9 @@ def bootup():
|
|
|
38
42
|
Executes when system boots up.
|
|
39
43
|
"""
|
|
40
44
|
# Execute LMs from boothook config parameter
|
|
41
|
-
console_write("[BOOT] EXECUTION
|
|
45
|
+
console_write("[BOOT] EXECUTION...")
|
|
46
|
+
boot_cause()
|
|
42
47
|
bootasks = cfgget('boothook')
|
|
43
|
-
bootasks = _migrate(bootasks) # load_n_init -> load migration (simplify)
|
|
44
48
|
if bootasks is not None and bootasks.lower() != 'n/a':
|
|
45
49
|
console_write(f"|-[BOOT] TASKS: {bootasks}")
|
|
46
50
|
if exec_lm_pipe(bootasks):
|
|
@@ -89,15 +93,21 @@ def profiling_info(label=""):
|
|
|
89
93
|
mem_info()
|
|
90
94
|
console_write("~"*30)
|
|
91
95
|
|
|
92
|
-
def _migrate(bootstr):
|
|
93
|
-
"""
|
|
94
|
-
OBSOLETE load_n_init -- REMOVE AT 2023.12
|
|
95
|
-
Use load instead
|
|
96
|
-
- auto replace in boothook param
|
|
97
|
-
"""
|
|
98
|
-
if 'load_n_init' in bootstr:
|
|
99
|
-
console_write("[MIGRATE] load_n_init -> load")
|
|
100
|
-
bootstr = bootstr.replace('load_n_init', 'load')
|
|
101
|
-
cfgput('boothook', bootstr)
|
|
102
|
-
return bootstr
|
|
103
96
|
|
|
97
|
+
def boot_cause():
|
|
98
|
+
reason = 0, "-Unknown"
|
|
99
|
+
if callable(reset_cause):
|
|
100
|
+
reason = 0, "Unknown"
|
|
101
|
+
reset_reason = reset_cause()
|
|
102
|
+
if reset_reason == PWRON_RESET:
|
|
103
|
+
reason = 1, "PowerOn"
|
|
104
|
+
elif reset_reason == HARD_RESET:
|
|
105
|
+
reason = 2, "HardReset"
|
|
106
|
+
elif reset_reason == WDT_RESET:
|
|
107
|
+
reason = 3, "WDTWakeUp"
|
|
108
|
+
elif reset_reason == DEEPSLEEP_RESET:
|
|
109
|
+
reason = 4, "DSWakeUp"
|
|
110
|
+
elif reset_reason == SOFT_RESET:
|
|
111
|
+
reason = 5, "SoftReset"
|
|
112
|
+
errlog_add(f"[BOOT] info: {reason[1]}")
|
|
113
|
+
return reason
|
micrOS/source/LM_buzzer.py
CHANGED
|
@@ -2,7 +2,6 @@ from sys import platform
|
|
|
2
2
|
from utime import sleep
|
|
3
3
|
from microIO import resolve_pin, pinmap_search
|
|
4
4
|
from Common import micro_task
|
|
5
|
-
import uasyncio as asyncio
|
|
6
5
|
from Types import resolve
|
|
7
6
|
|
|
8
7
|
|
|
@@ -254,7 +253,7 @@ async def _play(rtttlstr):
|
|
|
254
253
|
task.out = "Play song..."
|
|
255
254
|
for freq, msec in tune.notes():
|
|
256
255
|
__play_tone(freq, msec)
|
|
257
|
-
await
|
|
256
|
+
await task.feed(sleep_ms=10)
|
|
258
257
|
task.out = "Song played successfully"
|
|
259
258
|
del tune
|
|
260
259
|
|
micrOS/source/LM_cct.py
CHANGED
|
@@ -5,7 +5,6 @@ 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
|
-
import uasyncio as asyncio
|
|
9
8
|
from microIO import resolve_pin, pinmap_search
|
|
10
9
|
from random import randint
|
|
11
10
|
from Types import resolve
|
|
@@ -229,7 +228,7 @@ def transition(cw=None, ww=None, sec=1.0, wake=False):
|
|
|
229
228
|
Data.CWWW_CACHE[0] = cw_val if cw_val > 5 else 5 # SAVE VALUE TO CACHE > 5 ! because toggle
|
|
230
229
|
Data.CWWW_CACHE[1] = ww_val if ww_val > 5 else 5 # SAVE VALUE TO CACHE > 5 ! because toggle
|
|
231
230
|
my_task.out = f"Dimming: CW:{cw_val} WW:{ww_val}"
|
|
232
|
-
await
|
|
231
|
+
await my_task.feed(sleep_ms=ms_period)
|
|
233
232
|
if Data.CWWW_CACHE[2] == 1 or wake:
|
|
234
233
|
__state_machine(c=cw_val, w=ww_val)
|
|
235
234
|
my_task.out = f"Dimming DONE: CW:{cw_val} WW:{ww_val}"
|
|
@@ -278,7 +277,7 @@ def hue_transition(percent, sec=1.0, wake=False):
|
|
|
278
277
|
Data.CWWW_CACHE[1] = warm if warm > 5 else 5
|
|
279
278
|
my_task.out = f"HUE {int(hue_precent*0.1)}%w - CW:{cold} WW:{warm}"
|
|
280
279
|
# Feed async loop
|
|
281
|
-
await
|
|
280
|
+
await my_task.feed(sleep_ms=ms_period)
|
|
282
281
|
__state_machine(cold, warm)
|
|
283
282
|
my_task.out = f"HUE DONE {int(hue_precent*0.001)}%w - CW:{cold} WW:{warm}"
|
|
284
283
|
|
micrOS/source/LM_dimmer.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from sys import platform
|
|
2
2
|
from microIO import resolve_pin, pinmap_search
|
|
3
3
|
from Common import transition_gen, micro_task
|
|
4
|
-
import uasyncio as asyncio
|
|
5
4
|
from utime import sleep_ms
|
|
6
5
|
from Types import resolve
|
|
7
6
|
|
|
@@ -171,7 +170,7 @@ def transition(value, sec=1.0, wake=False):
|
|
|
171
170
|
# Update periphery cache (value check due to toggle ON value minimum)
|
|
172
171
|
Data.DIMMER_CACHE[1] = i if i > 5 else 5 # SAVE VALUE TO CACHE > 5 ! because toggle
|
|
173
172
|
my_task.out = f"Dimming: {i}"
|
|
174
|
-
await
|
|
173
|
+
await my_task.feed(sleep_ms=ms_period)
|
|
175
174
|
if Data.DIMMER_CACHE[0] == 1 or wake:
|
|
176
175
|
__state_machine(i)
|
|
177
176
|
my_task.out = f"Dimming DONE: {i}"
|
micrOS/source/LM_distance.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from machine import Pin, time_pulse_us
|
|
2
2
|
from utime import sleep_us
|
|
3
3
|
from microIO import resolve_pin, pinmap_search
|
|
4
|
-
import uasyncio as asyncio
|
|
5
4
|
from Common import micro_task
|
|
6
5
|
from Types import resolve
|
|
7
6
|
|
|
@@ -50,7 +49,7 @@ async def __task(period_ms, dimmer, idle_cm):
|
|
|
50
49
|
brightness_min_cm = 5
|
|
51
50
|
dist = int(measure_cm()["cm"])
|
|
52
51
|
if dist > idle_cm+100:
|
|
53
|
-
await
|
|
52
|
+
await my_task.feed(sleep_ms=50)
|
|
54
53
|
continue
|
|
55
54
|
dist = brightness_max_cm if dist > brightness_max_cm else dist # Limit max
|
|
56
55
|
dist = 0 if dist < brightness_min_cm else dist # Limit min
|
|
@@ -63,9 +62,8 @@ async def __task(period_ms, dimmer, idle_cm):
|
|
|
63
62
|
|
|
64
63
|
# Store data in task cache (task show mytask)
|
|
65
64
|
my_task.out = f'Dist: {dist} br: {brightness}'
|
|
66
|
-
|
|
67
65
|
# Async sleep - feed event loop
|
|
68
|
-
await
|
|
66
|
+
await my_task.feed(sleep_ms=period_ms)
|
|
69
67
|
|
|
70
68
|
|
|
71
69
|
def start_dimmer_indicator(idle_distance=180):
|
micrOS/source/LM_i2s_mic.py
CHANGED
|
@@ -49,7 +49,7 @@ async def __control_task(ms_period=50):
|
|
|
49
49
|
querying samples. Pushing the button again reinitializes the
|
|
50
50
|
microphone without having to restart dependent load modules.
|
|
51
51
|
"""
|
|
52
|
-
with micro_task(tag=Data.CONTROL_TASK_TAG):
|
|
52
|
+
with micro_task(tag=Data.CONTROL_TASK_TAG) as my_task:
|
|
53
53
|
while True:
|
|
54
54
|
if Data.CONTROL_BUTTON_PIN.value():
|
|
55
55
|
Data.MIC_ENABLED = not Data.MIC_ENABLED
|
|
@@ -59,8 +59,8 @@ async def __control_task(ms_period=50):
|
|
|
59
59
|
load()
|
|
60
60
|
|
|
61
61
|
# Debounce
|
|
62
|
-
await
|
|
63
|
-
await
|
|
62
|
+
await my_task.feed(sleep_ms=500)
|
|
63
|
+
await my_task.feed(sleep_ms=ms_period)
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
###########################
|
|
@@ -76,7 +76,7 @@ async def __task(ms_period):
|
|
|
76
76
|
recording_task.out = 'Capturing'
|
|
77
77
|
while Data.MIC_ENABLED:
|
|
78
78
|
await Data.SREADER.readinto(sample_mv)
|
|
79
|
-
await
|
|
79
|
+
await recording_task.feed(sleep_ms=ms_period)
|
|
80
80
|
recording_task.out = 'Finished'
|
|
81
81
|
|
|
82
82
|
except Exception as e:
|
micrOS/source/LM_keychain.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import uasyncio as asyncio
|
|
2
1
|
from utime import localtime, sleep_ms
|
|
3
2
|
from neopixel import NeoPixel
|
|
4
3
|
from machine import Pin
|
|
@@ -150,12 +149,12 @@ async def _ui_task(period_ms, tts_ms):
|
|
|
150
149
|
my_task.out = f'main page: {KC.DP_cnt}' #2 Update task data for (task show keychain.display)
|
|
151
150
|
KC.DP_cnt -= 1 #3 Update sleep counter
|
|
152
151
|
# Async sleep - feed event loop
|
|
153
|
-
await
|
|
152
|
+
await my_task.feed(sleep_ms=period_ms)
|
|
154
153
|
else:
|
|
155
154
|
# [SLEEP MODE] Execute screen saver page
|
|
156
155
|
await _screen_saver() # Run sleep page function
|
|
157
156
|
# Async sleep - feed event loop
|
|
158
|
-
await
|
|
157
|
+
await my_task.feed(sleep_ms=fast_period)
|
|
159
158
|
|
|
160
159
|
# Auto sleep event handler - off event - go to (sleep mode)
|
|
161
160
|
if KC.DP_cnt <= 0:
|
micrOS/source/LM_light_sensor.py
CHANGED
|
@@ -5,7 +5,6 @@ ADC.ATTN_2_5DB — the full range voltage: 1.5V
|
|
|
5
5
|
ADC.ATTN_6DB — the full range voltage: 2.0V
|
|
6
6
|
ADC.ATTN_11DB — the full range voltage: 3.3V
|
|
7
7
|
"""
|
|
8
|
-
import uasyncio as asyncio
|
|
9
8
|
from Common import SmartADC, micro_task
|
|
10
9
|
from Types import resolve
|
|
11
10
|
try:
|
|
@@ -91,7 +90,7 @@ async def _task(on, off, threshold, tolerance=2, check_ms=5000):
|
|
|
91
90
|
InterCon.send_cmd(host, cmd)
|
|
92
91
|
my_task.out = f"{percent}% > threshold: {threshold+tolerance}% - OFF"
|
|
93
92
|
last_ev = off
|
|
94
|
-
await
|
|
93
|
+
await my_task.feed(sleep_ms=check_ms) # Sample every <check_ms> sec
|
|
95
94
|
|
|
96
95
|
|
|
97
96
|
def subscribe_intercon(on, off, threshold=4, tolerance=2, sample_sec=60):
|
micrOS/source/LM_neopixel.py
CHANGED
|
@@ -3,7 +3,6 @@ from machine import Pin
|
|
|
3
3
|
from sys import platform
|
|
4
4
|
from utime import sleep_ms
|
|
5
5
|
from Common import transition_gen, micro_task
|
|
6
|
-
import uasyncio as asyncio
|
|
7
6
|
from microIO import resolve_pin, pinmap_search
|
|
8
7
|
from random import randint
|
|
9
8
|
from Types import resolve
|
|
@@ -269,7 +268,7 @@ def transition(r=None, g=None, b=None, sec=1.0, wake=False):
|
|
|
269
268
|
Data.DCACHE[1] = g_val if g_val > 5 else 5 # SAVE VALUE TO CACHE > 5 ! because toggle
|
|
270
269
|
Data.DCACHE[2] = b_val if b_val > 5 else 5 # SAVE VALUE TO CACHE > 5 ! because toggle
|
|
271
270
|
my_task.out = f"Dimming: R:{r_val} G:{g_val} B:{b_val}"
|
|
272
|
-
await
|
|
271
|
+
await my_task.feed(sleep_ms=ms_period)
|
|
273
272
|
if Data.DCACHE[3] == 1 or wake:
|
|
274
273
|
__state_machine(r=r_val, g=g_val, b=b_val)
|
|
275
274
|
my_task.out = f"Dimming DONE: R:{r_val} G:{g_val} B:{b_val}"
|
micrOS/source/LM_oledui.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from utime import localtime, ticks_ms, ticks_diff, sleep_ms
|
|
2
|
-
import uasyncio as asyncio
|
|
3
2
|
from Common import syslog, micro_task, manage_task, exec_cmd
|
|
4
3
|
from Types import resolve
|
|
5
4
|
# Core modules
|
|
@@ -106,7 +105,7 @@ class Frame(BaseFrame):
|
|
|
106
105
|
my_task.out = 'paused' if self.paused else f'refresh: {period_ms} ms'
|
|
107
106
|
s = self.paused
|
|
108
107
|
if self.paused:
|
|
109
|
-
await
|
|
108
|
+
await my_task.feed(sleep_ms=period_ms) # extra wait in paused mode
|
|
110
109
|
else:
|
|
111
110
|
# Draw/Refresh frame
|
|
112
111
|
self.draw()
|
|
@@ -115,7 +114,7 @@ class Frame(BaseFrame):
|
|
|
115
114
|
if self._fast_refresh:
|
|
116
115
|
self._fast_refresh = False
|
|
117
116
|
break
|
|
118
|
-
await
|
|
117
|
+
await my_task.feed(sleep_ms=micro_sleep_ms)
|
|
119
118
|
|
|
120
119
|
def clb_refresh(self):
|
|
121
120
|
"""Fast reload app loop callbacks"""
|
|
@@ -486,7 +485,7 @@ class ScreenSaver(BaseFrame):
|
|
|
486
485
|
# Store data in task cache (task show mytask)
|
|
487
486
|
my_task.out = f'GameOfLife: {counter}'
|
|
488
487
|
# Async sleep - feed event loop
|
|
489
|
-
await
|
|
488
|
+
await my_task.feed(sleep_ms=period_ms)
|
|
490
489
|
my_task.out = f'GameOfLife stopped: {counter}'
|
|
491
490
|
|
|
492
491
|
def run(self, fps=10):
|
micrOS/source/LM_pet_feeder.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import uasyncio as asyncio
|
|
2
1
|
from LM_servo import sduty, deinit, pinmap as servo_pinmap
|
|
3
2
|
from LM_stepper import step, pinmap as stepper_pinmap
|
|
4
3
|
from Common import micro_task
|
|
@@ -16,13 +15,13 @@ async def __portion_task(portion, posmin, posmax):
|
|
|
16
15
|
# [1]Run pos fill up
|
|
17
16
|
for pos in range(posmin, posmax):
|
|
18
17
|
sduty(pos)
|
|
19
|
-
await
|
|
18
|
+
await my_task.feed(sleep_ms=15)
|
|
20
19
|
# [2]Wait between fill up / food out
|
|
21
|
-
await
|
|
20
|
+
await my_task.feed(sleep_ms=500)
|
|
22
21
|
# [3]Run pos food out
|
|
23
22
|
for pos in range(posmax, posmin, -1):
|
|
24
23
|
sduty(pos)
|
|
25
|
-
await
|
|
24
|
+
await my_task.feed(sleep_ms=20)
|
|
26
25
|
my_task.out = "{}/{} serving".format(p+1, portion)
|
|
27
26
|
deinit()
|
|
28
27
|
my_task.out += ": {} task done".format(Data.TASK_TAG)
|
micrOS/source/LM_presence.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from microIO import resolve_pin, pinmap_search
|
|
2
2
|
from Common import SmartADC, micro_task, notify, syslog
|
|
3
|
-
import uasyncio as asyncio
|
|
4
3
|
from utime import ticks_ms
|
|
5
4
|
try:
|
|
6
5
|
import LM_intercon as InterCon
|
|
@@ -115,7 +114,7 @@ async def __task(ms_period, buff_size):
|
|
|
115
114
|
my_task.out = f"{int(Data.OFF_EV_TIMER)-1} sec until off event"
|
|
116
115
|
Data.OFF_EV_TIMER -= round(ms_period / 1000, 3)
|
|
117
116
|
# Async sleep - feed event loop
|
|
118
|
-
await
|
|
117
|
+
await my_task.feed(sleep_ms=ms_period)
|
|
119
118
|
|
|
120
119
|
# RUN OFF CALLBACK (local + remote)
|
|
121
120
|
__exec_local_callbacks(Data.OFF_CALLBACKS)
|
micrOS/source/LM_rest.py
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import uasyncio as asyncio
|
|
1
2
|
from urequests import get as http_get
|
|
3
|
+
from urequests import aget as http_aget
|
|
4
|
+
from Common import micro_task
|
|
5
|
+
|
|
2
6
|
|
|
3
7
|
class Rest:
|
|
4
8
|
GATEWAY_HOST = None
|
|
@@ -13,23 +17,60 @@ def load(gateway_url=None):
|
|
|
13
17
|
if Rest.GATEWAY_HOST is None:
|
|
14
18
|
return 'Missing Gateway url'
|
|
15
19
|
return Rest.GATEWAY_HOST
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
if gateway_url.startswith("http"):
|
|
21
|
+
Rest.GATEWAY_HOST = gateway_url
|
|
22
|
+
else:
|
|
23
|
+
return f"URL have to starts with http/https"
|
|
24
|
+
return f'Gateway url: {gateway_url}'
|
|
18
25
|
|
|
19
26
|
|
|
20
|
-
def
|
|
21
|
-
"""
|
|
22
|
-
Execute rest call with given subdomain
|
|
23
|
-
:param subdomain: command parameters of url, like: /webhooks/template
|
|
24
|
-
"""
|
|
27
|
+
def _subdomain(subdomain):
|
|
25
28
|
if Rest.GATEWAY_HOST is None:
|
|
26
|
-
|
|
29
|
+
raise Exception('Missing Gateway url')
|
|
27
30
|
if not subdomain.startswith('/'):
|
|
28
31
|
subdomain = '/' + subdomain
|
|
29
32
|
domain = f'{Rest.GATEWAY_HOST}{subdomain}'
|
|
33
|
+
return domain
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def url(subdomain):
|
|
37
|
+
"""
|
|
38
|
+
Execute rest call with given subdomain / url
|
|
39
|
+
:param subdomain: url parameter, http(s) full url or gateway subdomain like: /webhooks/template
|
|
40
|
+
"""
|
|
41
|
+
if subdomain.startswith('http'):
|
|
42
|
+
domain = subdomain
|
|
43
|
+
else:
|
|
44
|
+
domain = _subdomain(subdomain)
|
|
30
45
|
status_code, response = http_get(domain, jsonify=True)
|
|
31
46
|
return {'status': status_code, 'response': response}
|
|
32
47
|
|
|
48
|
+
|
|
49
|
+
async def __task(subdomain, tag):
|
|
50
|
+
with micro_task(tag=tag) as my_task:
|
|
51
|
+
my_task.out = f"GET {subdomain}"
|
|
52
|
+
if subdomain.startswith('http'):
|
|
53
|
+
domain = subdomain
|
|
54
|
+
else:
|
|
55
|
+
domain = _subdomain(subdomain)
|
|
56
|
+
status_code, response = await http_aget(domain, jsonify=True)
|
|
57
|
+
my_task.out = f'status: {status_code}, response: {response}'
|
|
58
|
+
return {'status': status_code, 'response': response}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def aurl(subdomain):
|
|
62
|
+
"""
|
|
63
|
+
Execute async rest call with given subdomain / url
|
|
64
|
+
:param subdomain: url parameter, http(s) full url or gateway subdomain like: /webhooks/template
|
|
65
|
+
"""
|
|
66
|
+
# [!] ASYNC TASK CREATION [1*] with async task callback + taskID (TAG) handling
|
|
67
|
+
tag = "rest." + subdomain.replace("http://", '').replace("https://", '')
|
|
68
|
+
if len(tag) > 50:
|
|
69
|
+
tag = tag[0:50]
|
|
70
|
+
state = micro_task(tag=tag, task=__task(subdomain, tag))
|
|
71
|
+
return f"Starting" if state else f"Already running"
|
|
72
|
+
|
|
73
|
+
|
|
33
74
|
def help(widgets=False):
|
|
34
75
|
"""
|
|
35
76
|
[i] micrOS LM naming convention - built-in help message
|
|
@@ -37,4 +78,6 @@ def help(widgets=False):
|
|
|
37
78
|
(widgets=False) list of functions implemented by this application
|
|
38
79
|
(widgets=True) list of widget json for UI generation
|
|
39
80
|
"""
|
|
40
|
-
return 'load gateway_url=<http://gateway.local:5000>',
|
|
81
|
+
return ('load gateway_url=<http://gateway.local:5000>',
|
|
82
|
+
'url subdomain=</webhooks/template>',
|
|
83
|
+
'aurl subdomain=</webhooks/template>')
|
micrOS/source/LM_rgb.py
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
from machine import Pin, PWM
|
|
5
5
|
from sys import platform
|
|
6
6
|
from Common import transition_gen, micro_task
|
|
7
|
-
import uasyncio as asyncio
|
|
8
7
|
from utime import sleep_ms
|
|
9
8
|
from microIO import resolve_pin, pinmap_search
|
|
10
9
|
from random import randint
|
|
@@ -240,7 +239,7 @@ def transition(r=None, g=None, b=None, sec=1.0, wake=False):
|
|
|
240
239
|
Data.RGB_CACHE[1] = _g if _g > 5 else 5 # SAVE VALUE TO CACHE > 5 ! because toggle
|
|
241
240
|
Data.RGB_CACHE[2] = _b if _b > 5 else 5 # SAVE VALUE TO CACHE > 5 ! because toggle
|
|
242
241
|
my_task.out = f"Dimming: R:{_r} G:{_g} B:{_b}"
|
|
243
|
-
await
|
|
242
|
+
await my_task.feed(sleep_ms=ms_period)
|
|
244
243
|
if Data.RGB_CACHE[3] == 1 or wake:
|
|
245
244
|
__state_machine(_r, _g, _b)
|
|
246
245
|
my_task.out = f"Dimming DONE: R:{_r} G:{_g} B:{_b}"
|
micrOS/source/LM_roboarm.py
CHANGED
|
@@ -3,7 +3,6 @@ from random import randint
|
|
|
3
3
|
import LM_servo as servo
|
|
4
4
|
from LM_switch import set_state, pinmap as switch_pinmap
|
|
5
5
|
from Common import transition, micro_task
|
|
6
|
-
import uasyncio as asyncio
|
|
7
6
|
from Types import resolve
|
|
8
7
|
|
|
9
8
|
|
|
@@ -179,7 +178,7 @@ async def _play(args, deinit, delay):
|
|
|
179
178
|
if task is not None:
|
|
180
179
|
task.out = "Roboarm X:{} Y:{}".format(x, y)
|
|
181
180
|
# Async wait between steps
|
|
182
|
-
await
|
|
181
|
+
await task.feed(sleep_ms=delay)
|
|
183
182
|
if deinit:
|
|
184
183
|
servo.deinit()
|
|
185
184
|
# OFF LASER
|