micrOSDevToolKit 2.9.7__py3-none-any.whl → 2.9.9__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.
- micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +12 -12
- micrOS/source/Espnow.py +89 -56
- micrOS/source/LM_L298N_DCmotor.py +4 -4
- micrOS/source/LM_L9110_DCmotor.py +3 -3
- micrOS/source/LM_VL53L0X.py +2 -2
- micrOS/source/LM_aht10.py +2 -2
- micrOS/source/LM_bme280.py +2 -2
- micrOS/source/LM_buzzer.py +12 -15
- micrOS/source/LM_cct.py +10 -13
- micrOS/source/LM_co2.py +3 -3
- micrOS/source/LM_dht11.py +2 -2
- micrOS/source/LM_dht22.py +2 -2
- micrOS/source/LM_dimmer.py +2 -2
- micrOS/source/LM_distance.py +3 -3
- micrOS/source/LM_ds18.py +2 -2
- micrOS/source/LM_genIO.py +52 -37
- micrOS/source/LM_haptic.py +2 -2
- micrOS/source/LM_i2c.py +2 -2
- micrOS/source/LM_i2s_mic.py +5 -5
- micrOS/source/LM_keychain.py +2 -2
- micrOS/source/LM_ld2410.py +2 -2
- micrOS/source/LM_light_sensor.py +2 -2
- micrOS/source/LM_neopixel.py +9 -12
- micrOS/source/LM_oled.py +2 -2
- micrOS/source/LM_oled_sh1106.py +3 -3
- micrOS/source/LM_oled_ui.py +2 -2
- micrOS/source/LM_ph_sensor.py +3 -3
- micrOS/source/LM_presence.py +2 -2
- micrOS/source/LM_rencoder.py +2 -2
- micrOS/source/LM_rgb.py +15 -22
- micrOS/source/LM_servo.py +3 -3
- micrOS/source/LM_stepper.py +5 -5
- micrOS/source/LM_switch.py +5 -5
- micrOS/source/LM_trackball.py +3 -3
- micrOS/source/LM_veml7700.py +2 -2
- micrOS/source/Shell.py +1 -1
- micrOS/source/microIO.py +27 -9
- micrOS/source/urequests.py +6 -1
- {micrOSDevToolKit-2.9.7.dist-info → micrOSDevToolKit-2.9.9.dist-info}/METADATA +1 -1
- {micrOSDevToolKit-2.9.7.dist-info → micrOSDevToolKit-2.9.9.dist-info}/RECORD +86 -87
- toolkit/DevEnvUSB.py +6 -5
- toolkit/dashboard_apps/BackupRestore.py +0 -4
- toolkit/dashboard_apps/SystemTest.py +1 -1
- toolkit/dashboard_apps/uLightDemo.py +1 -1
- toolkit/lib/micrOSClient.py +5 -2
- toolkit/workspace/precompiled/Espnow.mpy +0 -0
- toolkit/workspace/precompiled/LM_L298N_DCmotor.mpy +0 -0
- toolkit/workspace/precompiled/LM_L9110_DCmotor.py +3 -3
- toolkit/workspace/precompiled/LM_VL53L0X.py +2 -2
- toolkit/workspace/precompiled/LM_aht10.mpy +0 -0
- toolkit/workspace/precompiled/LM_bme280.mpy +0 -0
- toolkit/workspace/precompiled/LM_buzzer.mpy +0 -0
- toolkit/workspace/precompiled/LM_cct.mpy +0 -0
- toolkit/workspace/precompiled/LM_co2.mpy +0 -0
- toolkit/workspace/precompiled/LM_dht11.mpy +0 -0
- toolkit/workspace/precompiled/LM_dht22.mpy +0 -0
- toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
- toolkit/workspace/precompiled/LM_distance.mpy +0 -0
- toolkit/workspace/precompiled/LM_ds18.mpy +0 -0
- toolkit/workspace/precompiled/LM_genIO.mpy +0 -0
- toolkit/workspace/precompiled/LM_haptic.mpy +0 -0
- toolkit/workspace/precompiled/LM_i2c.py +2 -2
- toolkit/workspace/precompiled/LM_i2s_mic.mpy +0 -0
- toolkit/workspace/precompiled/LM_keychain.mpy +0 -0
- toolkit/workspace/precompiled/LM_ld2410.mpy +0 -0
- toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
- toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
- toolkit/workspace/precompiled/LM_oled.mpy +0 -0
- toolkit/workspace/precompiled/LM_oled_sh1106.mpy +0 -0
- toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
- toolkit/workspace/precompiled/LM_ph_sensor.py +3 -3
- toolkit/workspace/precompiled/LM_presence.mpy +0 -0
- toolkit/workspace/precompiled/LM_rencoder.py +2 -2
- toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
- toolkit/workspace/precompiled/LM_servo.mpy +0 -0
- toolkit/workspace/precompiled/LM_stepper.mpy +0 -0
- toolkit/workspace/precompiled/LM_switch.mpy +0 -0
- toolkit/workspace/precompiled/LM_trackball.mpy +0 -0
- toolkit/workspace/precompiled/LM_veml7700.mpy +0 -0
- toolkit/workspace/precompiled/Shell.mpy +0 -0
- toolkit/workspace/precompiled/microIO.mpy +0 -0
- toolkit/workspace/precompiled/urequests.mpy +0 -0
- toolkit/workspace/precompiled/node_config.json +0 -1
- {micrOSDevToolKit-2.9.7.data → micrOSDevToolKit-2.9.9.data}/scripts/devToolKit.py +0 -0
- {micrOSDevToolKit-2.9.7.dist-info → micrOSDevToolKit-2.9.9.dist-info}/LICENSE +0 -0
- {micrOSDevToolKit-2.9.7.dist-info → micrOSDevToolKit-2.9.9.dist-info}/WHEEL +0 -0
- {micrOSDevToolKit-2.9.7.dist-info → micrOSDevToolKit-2.9.9.dist-info}/top_level.txt +0 -0
micrOS/source/LM_genIO.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from machine import Pin, PWM
|
|
2
|
-
from microIO import
|
|
2
|
+
from microIO import bind_pin, PinMap
|
|
3
3
|
from Common import SmartADC
|
|
4
4
|
from random import randint
|
|
5
5
|
|
|
@@ -10,15 +10,25 @@ from random import randint
|
|
|
10
10
|
|
|
11
11
|
class IObjects:
|
|
12
12
|
PIN_OBJS = {}
|
|
13
|
+
DENY_TAG_INPUT = True
|
|
13
14
|
|
|
14
15
|
@staticmethod
|
|
15
|
-
def store_obj(pin, obj):
|
|
16
|
+
def store_obj(pin:int, obj:object) -> None:
|
|
16
17
|
IObjects.PIN_OBJS[pin] = obj
|
|
17
18
|
|
|
18
19
|
@staticmethod
|
|
19
|
-
def get_obj(pin):
|
|
20
|
+
def get_obj(pin:int) -> object:
|
|
20
21
|
return IObjects.PIN_OBJS[pin]
|
|
21
22
|
|
|
23
|
+
@staticmethod
|
|
24
|
+
def is_unassigned(pin_number):
|
|
25
|
+
return IObjects.PIN_OBJS.get(pin_number, None) is None
|
|
26
|
+
|
|
27
|
+
@staticmethod
|
|
28
|
+
def protect_builtins(pin_num, tag):
|
|
29
|
+
if pin_num is None and IObjects.DENY_TAG_INPUT:
|
|
30
|
+
raise Exception(f"pin must be integer not {type(tag)}: {tag}")
|
|
31
|
+
|
|
22
32
|
|
|
23
33
|
##################################
|
|
24
34
|
# INTERNAL INIT FUNCTIONS #
|
|
@@ -28,48 +38,39 @@ def __digital_out_init(pin):
|
|
|
28
38
|
"""
|
|
29
39
|
Init Digital output
|
|
30
40
|
"""
|
|
31
|
-
if
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
pin_obj = Pin(pin, Pin.OUT)
|
|
39
|
-
IObjects.store_obj(pin, pin_obj)
|
|
40
|
-
return IObjects.get_obj(pin)
|
|
41
|
+
pin_tag, pin = (pin, None) if isinstance(pin, str) else (f"OUT{pin}", pin)
|
|
42
|
+
IObjects.protect_builtins(pin, pin_tag)
|
|
43
|
+
pin_num = bind_pin(pin_tag, pin)
|
|
44
|
+
if IObjects.is_unassigned(pin_number=pin_num):
|
|
45
|
+
pin_obj = Pin(pin_num, Pin.OUT)
|
|
46
|
+
IObjects.store_obj(pin_num, pin_obj)
|
|
47
|
+
return IObjects.get_obj(pin_num)
|
|
41
48
|
|
|
42
49
|
|
|
43
50
|
def __digital_in_init(pin):
|
|
44
51
|
"""
|
|
45
52
|
Init Digital output
|
|
46
53
|
"""
|
|
47
|
-
if
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
pin_obj = Pin(pin, Pin.IN, Pin.PULL_UP)
|
|
55
|
-
IObjects.store_obj(pin, pin_obj)
|
|
56
|
-
return IObjects.get_obj(pin)
|
|
54
|
+
pin_tag, pin = (pin, None) if isinstance(pin, str) else (f"IN{pin}", pin)
|
|
55
|
+
IObjects.protect_builtins(pin, pin_tag)
|
|
56
|
+
pin_num = bind_pin(pin_tag, pin)
|
|
57
|
+
if IObjects.is_unassigned(pin_number=pin_num):
|
|
58
|
+
pin_obj = Pin(pin_num, Pin.IN, Pin.PULL_UP)
|
|
59
|
+
IObjects.store_obj(pin_num, pin_obj)
|
|
60
|
+
return IObjects.get_obj(pin_num)
|
|
57
61
|
|
|
58
62
|
|
|
59
63
|
def __pwm_init(pin, freq):
|
|
60
64
|
"""
|
|
61
65
|
Init PWM signal
|
|
62
66
|
"""
|
|
63
|
-
if
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
pin_obj = PWM(Pin(pin), freq=freq)
|
|
71
|
-
IObjects.store_obj(pin, pin_obj)
|
|
72
|
-
return IObjects.get_obj(pin)
|
|
67
|
+
pin_tag, pin = (pin, None) if isinstance(pin, str) else (f"PWM{pin}", pin)
|
|
68
|
+
IObjects.protect_builtins(pin, pin_tag)
|
|
69
|
+
pin_num = bind_pin(pin_tag, pin)
|
|
70
|
+
if IObjects.is_unassigned(pin_number=pin_num):
|
|
71
|
+
pin_obj = PWM(Pin(pin_num), freq=freq)
|
|
72
|
+
IObjects.store_obj(pin_num, pin_obj)
|
|
73
|
+
return IObjects.get_obj(pin_num)
|
|
73
74
|
|
|
74
75
|
|
|
75
76
|
##################################
|
|
@@ -121,9 +122,9 @@ def get_adc(pin, key=None):
|
|
|
121
122
|
:param key: select adc parameter by key
|
|
122
123
|
:return dict: adc volt, percent, raw
|
|
123
124
|
"""
|
|
124
|
-
if isinstance(pin,
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
pin_tag, pin = (pin, None) if isinstance(pin, str) else (f"ADC{pin}", pin)
|
|
126
|
+
IObjects.protect_builtins(pin, pin_tag)
|
|
127
|
+
pin = bind_pin(pin_tag, pin)
|
|
127
128
|
data = SmartADC.get_instance(pin).get()
|
|
128
129
|
data["pin"] = pin
|
|
129
130
|
if key is None:
|
|
@@ -140,6 +141,19 @@ def get_in(pin):
|
|
|
140
141
|
return {'pin': pin, 'state': __digital_in_init(pin).value()}
|
|
141
142
|
|
|
142
143
|
|
|
144
|
+
def load(allow_tags=False):
|
|
145
|
+
"""
|
|
146
|
+
Optional load function to set
|
|
147
|
+
tag input besides pin numbers.
|
|
148
|
+
[WARNING] allow_tag=True can be dangerous
|
|
149
|
+
- it can overwrite existing I/O based on
|
|
150
|
+
the provided tag
|
|
151
|
+
:param allow_tag: default False
|
|
152
|
+
"""
|
|
153
|
+
IObjects.DENY_TAG_INPUT = not allow_tags
|
|
154
|
+
return "[WARNING] allow_tag=True can be dangerous, use it consciously!!!" if allow_tags else "Loaded"
|
|
155
|
+
|
|
156
|
+
|
|
143
157
|
#######################
|
|
144
158
|
# LM helper functions #
|
|
145
159
|
#######################
|
|
@@ -155,4 +169,5 @@ def help(widgets=False):
|
|
|
155
169
|
'set_random_pwm pin min_duty max_duty freq=20480)',\
|
|
156
170
|
'set_out pin=<int> state=<None/True/False>',\
|
|
157
171
|
'get_adc pin key=None',\
|
|
158
|
-
'get_in pin'
|
|
172
|
+
'get_in pin',\
|
|
173
|
+
'load allow_tags=False'
|
micrOS/source/LM_haptic.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from microIO import
|
|
1
|
+
from microIO import bind_pin, pinmap_search
|
|
2
2
|
from Types import resolve
|
|
3
3
|
from machine import Pin, PWM
|
|
4
4
|
from utime import sleep_ms
|
|
@@ -18,7 +18,7 @@ def load(intensity=None):
|
|
|
18
18
|
:param intensity: low / high / None haptic feedback intensity
|
|
19
19
|
"""
|
|
20
20
|
if Haptic.HAPTIC_OBJ is None:
|
|
21
|
-
dimmer_pin = Pin(
|
|
21
|
+
dimmer_pin = Pin(bind_pin('haptic'))
|
|
22
22
|
Haptic.HAPTIC_OBJ = PWM(dimmer_pin, freq=20480)
|
|
23
23
|
Haptic.HAPTIC_OBJ.duty(0)
|
|
24
24
|
if intensity in ("high", "low"):
|
micrOS/source/LM_i2c.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from microIO import
|
|
1
|
+
from microIO import bind_pin, pinmap_search
|
|
2
2
|
|
|
3
3
|
__I2C = None
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ def __init():
|
|
|
7
7
|
global __I2C
|
|
8
8
|
if __I2C is None:
|
|
9
9
|
from machine import Pin, I2C
|
|
10
|
-
__I2C = I2C(-1, Pin(
|
|
10
|
+
__I2C = I2C(-1, Pin(bind_pin('i2c_scl')), Pin(bind_pin('i2c_sda')))
|
|
11
11
|
return __I2C
|
|
12
12
|
|
|
13
13
|
|
micrOS/source/LM_i2s_mic.py
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
from ustruct import unpack
|
|
2
|
-
from microIO import
|
|
2
|
+
from microIO import bind_pin, pinmap_search
|
|
3
3
|
from Common import micro_task, web_endpoint, manage_task
|
|
4
4
|
from machine import I2S, Pin
|
|
5
5
|
import uasyncio as asyncio
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class Data:
|
|
9
|
-
SCK_PIN = Pin(
|
|
10
|
-
WS_PIN = Pin(
|
|
11
|
-
SD_PIN = Pin(
|
|
9
|
+
SCK_PIN = Pin(bind_pin('i2s_sck')) # Serial clock
|
|
10
|
+
WS_PIN = Pin(bind_pin('i2s_ws')) # Word select
|
|
11
|
+
SD_PIN = Pin(bind_pin('i2s_sd')) # Serial data
|
|
12
12
|
I2S_CHANNEL = 1
|
|
13
13
|
FORMAT = I2S.STEREO
|
|
14
14
|
SAMPLING_RATE = 8000
|
|
@@ -276,7 +276,7 @@ def load(buf_length=Data.BUF_LENGTH, sampling_rate=Data.SAMPLING_RATE,
|
|
|
276
276
|
|
|
277
277
|
if control_button:
|
|
278
278
|
micro_task(tag=Data.CONTROL_TASK_TAG, task=__control_task())
|
|
279
|
-
Data.CONTROL_BUTTON_PIN = Pin(
|
|
279
|
+
Data.CONTROL_BUTTON_PIN = Pin(bind_pin(control_button), Pin.IN)
|
|
280
280
|
|
|
281
281
|
Data.BUF_LENGTH = buf_length
|
|
282
282
|
Data.SAMPLING_RATE = sampling_rate
|
micrOS/source/LM_keychain.py
CHANGED
|
@@ -2,7 +2,7 @@ from utime import localtime, sleep_ms
|
|
|
2
2
|
from neopixel import NeoPixel
|
|
3
3
|
from machine import Pin
|
|
4
4
|
from Common import micro_task
|
|
5
|
-
from microIO import
|
|
5
|
+
from microIO import bind_pin, pinmap_search
|
|
6
6
|
from LM_oled import text, show, rect, pixel, clean, line, load as oled_lni
|
|
7
7
|
from LM_ds18 import measure
|
|
8
8
|
from LM_system import top, ifconfig
|
|
@@ -234,7 +234,7 @@ def color_wheel(br=None):
|
|
|
234
234
|
"""
|
|
235
235
|
def _init():
|
|
236
236
|
if KC.NEOPIXEL_OBJ is None:
|
|
237
|
-
neopixel_pin = Pin(
|
|
237
|
+
neopixel_pin = Pin(bind_pin('neop')) # Get Neopixel pin from LED PIN pool
|
|
238
238
|
KC.NEOPIXEL_OBJ = NeoPixel(neopixel_pin, n=1) # initialize for max 1 segment
|
|
239
239
|
return KC.NEOPIXEL_OBJ
|
|
240
240
|
# INIT
|
micrOS/source/LM_ld2410.py
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
|
|
18
18
|
from machine import Pin, UART
|
|
19
19
|
import utime
|
|
20
|
-
from microIO import
|
|
20
|
+
from microIO import bind_pin, pinmap_search
|
|
21
21
|
|
|
22
|
-
ser = UART(1, baudrate = 256000, tx=Pin(
|
|
22
|
+
ser = UART(1, baudrate = 256000, tx=Pin(bind_pin('tx')), rx=Pin(bind_pin('rx')), timeout = 1)
|
|
23
23
|
HEADER = bytes([0xfd, 0xfc, 0xfb, 0xfa])
|
|
24
24
|
TERMINATOR = bytes([0x04, 0x03, 0x02, 0x01])
|
|
25
25
|
NULLDATA = bytes([])
|
micrOS/source/LM_light_sensor.py
CHANGED
|
@@ -11,7 +11,7 @@ try:
|
|
|
11
11
|
import LM_intercon as InterCon
|
|
12
12
|
except:
|
|
13
13
|
InterCon = None
|
|
14
|
-
from microIO import
|
|
14
|
+
from microIO import bind_pin, pinmap_search
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
ADC = None
|
|
@@ -23,7 +23,7 @@ def __init_tempt6000():
|
|
|
23
23
|
"""
|
|
24
24
|
global ADC
|
|
25
25
|
if ADC is None:
|
|
26
|
-
ADC = SmartADC(
|
|
26
|
+
ADC = SmartADC(bind_pin('temp6000'))
|
|
27
27
|
return ADC
|
|
28
28
|
|
|
29
29
|
|
micrOS/source/LM_neopixel.py
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
-
from microIO import
|
|
6
|
+
from microIO import bind_pin, pinmap_search
|
|
7
7
|
from random import randint
|
|
8
8
|
from Types import resolve
|
|
9
9
|
|
|
@@ -26,13 +26,13 @@ class Data:
|
|
|
26
26
|
#########################################
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def __init_NEOPIXEL(n=24):
|
|
29
|
+
def __init_NEOPIXEL(pin=None, n=24):
|
|
30
30
|
"""
|
|
31
31
|
Init NeoPixel module
|
|
32
32
|
n - number of led fragments
|
|
33
33
|
"""
|
|
34
34
|
if Data.NEOPIXEL_OBJ is None:
|
|
35
|
-
neopixel_pin = Pin(
|
|
35
|
+
neopixel_pin = Pin(bind_pin('neop', number=pin)) # Get Neopixel pin from LED PIN pool
|
|
36
36
|
Data.NEOPIXEL_OBJ = NeoPixel(neopixel_pin, n) # initialize for max 8 segments
|
|
37
37
|
del neopixel_pin
|
|
38
38
|
return Data.NEOPIXEL_OBJ
|
|
@@ -72,20 +72,17 @@ def __state_machine(r, g, b):
|
|
|
72
72
|
# USER FUNCTIONS #
|
|
73
73
|
#########################################
|
|
74
74
|
|
|
75
|
-
def load(
|
|
75
|
+
def load(ledcnt=24, pin=None, cache=True):
|
|
76
76
|
"""
|
|
77
77
|
Initiate NeoPixel RGB module
|
|
78
|
-
:param
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
:param ledcnt: number of led segments
|
|
79
|
+
:param pin: optional number to overwrite default pin
|
|
80
|
+
:param cache: default True, store stages on disk + Load (.pds)
|
|
81
81
|
:return str: Cache state
|
|
82
82
|
"""
|
|
83
|
-
|
|
84
|
-
Data.PERSISTENT_CACHE = False if platform == 'esp8266' else True
|
|
85
|
-
else:
|
|
86
|
-
Data.PERSISTENT_CACHE = cache
|
|
83
|
+
Data.PERSISTENT_CACHE = cache
|
|
87
84
|
__persistent_cache_manager('r') # recover data cache
|
|
88
|
-
_ledcnt = __init_NEOPIXEL(n=ledcnt).n
|
|
85
|
+
_ledcnt = __init_NEOPIXEL(pin=pin, n=ledcnt).n
|
|
89
86
|
if Data.PERSISTENT_CACHE and Data.DCACHE[3] == 1:
|
|
90
87
|
Data.DCACHE[3] = 0 # Force ON at boot
|
|
91
88
|
toggle(True)
|
micrOS/source/LM_oled.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from micropython import const
|
|
4
4
|
import framebuf
|
|
5
5
|
from machine import Pin, SoftI2C
|
|
6
|
-
from microIO import
|
|
6
|
+
from microIO import bind_pin, pinmap_search
|
|
7
7
|
from Types import resolve
|
|
8
8
|
|
|
9
9
|
__INVERT = False
|
|
@@ -165,7 +165,7 @@ def load(width=128, height=64, brightness=50):
|
|
|
165
165
|
:param brightness: percentage
|
|
166
166
|
"""
|
|
167
167
|
if SSD1306_I2C.OLED_OBJ is None:
|
|
168
|
-
i2c = SoftI2C(Pin(
|
|
168
|
+
i2c = SoftI2C(Pin(bind_pin('i2c_scl')), Pin(bind_pin('i2c_sda')))
|
|
169
169
|
# TODO: scan device - abort if no device is available
|
|
170
170
|
SSD1306_I2C.OLED_OBJ = SSD1306_I2C(width, height, i2c)
|
|
171
171
|
SSD1306_I2C.OLED_OBJ.contrast(percent=brightness)
|
micrOS/source/LM_oled_sh1106.py
CHANGED
|
@@ -16,7 +16,7 @@ from micropython import const
|
|
|
16
16
|
import utime as time
|
|
17
17
|
import framebuf
|
|
18
18
|
from machine import Pin, I2C
|
|
19
|
-
from microIO import
|
|
19
|
+
from microIO import bind_pin, pinmap_search
|
|
20
20
|
from Types import resolve
|
|
21
21
|
|
|
22
22
|
__INVERT = False
|
|
@@ -224,8 +224,8 @@ class SH1106_I2C(SH1106):
|
|
|
224
224
|
|
|
225
225
|
def load(width=128, height=64, brightness=50, rotate=180):
|
|
226
226
|
if SH1106_I2C.OLED_OBJ is None:
|
|
227
|
-
#i2c = SoftI2C(Pin(
|
|
228
|
-
i2c = I2C(scl=Pin(
|
|
227
|
+
#i2c = SoftI2C(Pin(bind_pin('i2c_scl')), Pin(bind_pin('i2c_sda')))
|
|
228
|
+
i2c = I2C(scl=Pin(bind_pin('i2c_scl')), sda=Pin(bind_pin('i2c_sda')), freq=400000)
|
|
229
229
|
# TODO: scan device - abort if no device is available
|
|
230
230
|
SH1106_I2C.OLED_OBJ = SH1106_I2C(width, height, i2c, rotate=rotate)
|
|
231
231
|
SH1106_I2C.OLED_OBJ.contrast(percent=brightness)
|
micrOS/source/LM_oled_ui.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from Config import cfgget
|
|
2
2
|
from utime import localtime
|
|
3
3
|
from network import WLAN, STA_IF
|
|
4
|
-
from microIO import
|
|
4
|
+
from microIO import bind_pin, pinmap_search
|
|
5
5
|
from Network import ifconfig
|
|
6
6
|
from Common import syslog, exec_cmd, manage_task
|
|
7
7
|
from machine import Pin
|
|
@@ -153,7 +153,7 @@ class PageUI:
|
|
|
153
153
|
def _set(pin_tag, callback):
|
|
154
154
|
pin = None
|
|
155
155
|
try:
|
|
156
|
-
pin =
|
|
156
|
+
pin = bind_pin(pin_tag)
|
|
157
157
|
except Exception as e:
|
|
158
158
|
syslog(f'[ERR] {pin_tag} IRQ: {e}')
|
|
159
159
|
if pin:
|
micrOS/source/LM_ph_sensor.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from time import sleep
|
|
2
|
-
from microIO import
|
|
2
|
+
from microIO import bind_pin, pinmap_search
|
|
3
3
|
from Common import SmartADC
|
|
4
4
|
|
|
5
5
|
"""
|
|
@@ -12,7 +12,7 @@ ADC.ATTN_11DB — the full range voltage: 3.3V
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def __measure(samples=10):
|
|
15
|
-
adc_obj = SmartADC.get_instance(
|
|
15
|
+
adc_obj = SmartADC.get_instance(bind_pin('ph'))
|
|
16
16
|
mbuf = 0
|
|
17
17
|
for k in range(0, samples):
|
|
18
18
|
mbuf += adc_obj.get()['volt']
|
|
@@ -22,7 +22,7 @@ def __measure(samples=10):
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def measure():
|
|
25
|
-
data = SmartADC.get_instance(
|
|
25
|
+
data = SmartADC.get_instance(bind_pin('ph')).get()
|
|
26
26
|
return "ADC data: {}\nAVG V: {}".format(data, __measure())
|
|
27
27
|
|
|
28
28
|
|
micrOS/source/LM_presence.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from microIO import
|
|
1
|
+
from microIO import bind_pin, pinmap_search
|
|
2
2
|
from Common import SmartADC, micro_task, notify, syslog
|
|
3
3
|
from utime import ticks_ms
|
|
4
4
|
try:
|
|
@@ -96,7 +96,7 @@ async def __task(ms_period, buff_size):
|
|
|
96
96
|
|
|
97
97
|
if Data.MIC_TYPE == Data.MIC_TYPES['ADC']:
|
|
98
98
|
# Create ADC object
|
|
99
|
-
Data.MIC_ADC = SmartADC.get_instance(
|
|
99
|
+
Data.MIC_ADC = SmartADC.get_instance(bind_pin('mic'))
|
|
100
100
|
elif Data.MIC_TYPE == Data.MIC_TYPES['I2S']:
|
|
101
101
|
if Data.I2S_MIC is None:
|
|
102
102
|
import LM_i2s_mic
|
micrOS/source/LM_rencoder.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from machine import Pin
|
|
2
2
|
import micropython
|
|
3
3
|
from Common import socket_stream, syslog
|
|
4
|
-
from microIO import
|
|
4
|
+
from microIO import bind_pin, pinmap_search
|
|
5
5
|
from Types import resolve
|
|
6
6
|
|
|
7
7
|
# https://www.coderdojotc.org/micropython/sensors/10-rotary-encoder/
|
|
@@ -76,7 +76,7 @@ def load(min_val=0, max_val=20):
|
|
|
76
76
|
"""
|
|
77
77
|
if Data.ROTARY_OBJ is None:
|
|
78
78
|
# GPIO Pins 33 and 35 are for the encoder pins.
|
|
79
|
-
Data.ROTARY_OBJ = Rotary(
|
|
79
|
+
Data.ROTARY_OBJ = Rotary(bind_pin('rot_dt'), bind_pin('rot_clk'))
|
|
80
80
|
Data.MIN_VAL = min_val
|
|
81
81
|
Data.MAX_VAL = max_val
|
|
82
82
|
Data.VAL = min_val
|
micrOS/source/LM_rgb.py
CHANGED
|
@@ -5,7 +5,7 @@ from machine import Pin, PWM
|
|
|
5
5
|
from sys import platform
|
|
6
6
|
from Common import transition_gen, micro_task
|
|
7
7
|
from utime import sleep_ms
|
|
8
|
-
from microIO import
|
|
8
|
+
from microIO import bind_pin, pinmap_search
|
|
9
9
|
from random import randint
|
|
10
10
|
from Types import resolve
|
|
11
11
|
|
|
@@ -26,19 +26,14 @@ class Data:
|
|
|
26
26
|
# ANALOG rgb WITH 3 channel PWM #
|
|
27
27
|
#########################################
|
|
28
28
|
|
|
29
|
-
def __RGB_init():
|
|
29
|
+
def __RGB_init(red_pin=None, green_pin=None, blue_pin=None):
|
|
30
30
|
if Data.RGB_OBJS[0] is None or Data.RGB_OBJS[1] is None or Data.RGB_OBJS[2] is None:
|
|
31
|
-
red = Pin(
|
|
32
|
-
green = Pin(
|
|
33
|
-
blue = Pin(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
PWM(blue, freq=1024))
|
|
38
|
-
else:
|
|
39
|
-
Data.RGB_OBJS = (PWM(red, freq=20480),
|
|
40
|
-
PWM(green, freq=20480),
|
|
41
|
-
PWM(blue, freq=20480))
|
|
31
|
+
red = Pin(bind_pin('redgb', red_pin))
|
|
32
|
+
green = Pin(bind_pin('rgreenb', green_pin))
|
|
33
|
+
blue = Pin(bind_pin('rgbue', blue_pin))
|
|
34
|
+
Data.RGB_OBJS = (PWM(red, freq=20480),
|
|
35
|
+
PWM(green, freq=20480),
|
|
36
|
+
PWM(blue, freq=20480))
|
|
42
37
|
return Data.RGB_OBJS
|
|
43
38
|
|
|
44
39
|
|
|
@@ -73,20 +68,18 @@ def __state_machine(r, g, b):
|
|
|
73
68
|
__persistent_cache_manager('s')
|
|
74
69
|
|
|
75
70
|
|
|
76
|
-
def load(cache=
|
|
71
|
+
def load(red_pin=None, green_pin=None, blue_pin=None, cache=True):
|
|
77
72
|
"""
|
|
78
73
|
Initiate RGB module
|
|
79
|
-
:param
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
:param red_pin: optional red color pin to overwrite built-in
|
|
75
|
+
:param green_pin: optional green color pin to overwrite built-in
|
|
76
|
+
:param blue_pin: optional blue color pin to overwrite built-in
|
|
77
|
+
:param cache: file state machine cache: True/False (.pds), default=True
|
|
82
78
|
:return str: Cache state
|
|
83
79
|
"""
|
|
84
|
-
|
|
85
|
-
if cache is None:
|
|
86
|
-
Data.PERSISTENT_CACHE = False if platform == 'esp8266' else True
|
|
87
|
-
else:
|
|
88
|
-
Data.PERSISTENT_CACHE = cache
|
|
80
|
+
Data.PERSISTENT_CACHE = cache
|
|
89
81
|
__persistent_cache_manager('r') # recover data cache if enabled
|
|
82
|
+
__RGB_init(red_pin, green_pin, blue_pin)
|
|
90
83
|
if Data.RGB_CACHE[3] == 1:
|
|
91
84
|
Data.RGB_CACHE[3] = 0 # Force ON at boot
|
|
92
85
|
toggle(True)
|
micrOS/source/LM_servo.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from machine import Pin, PWM
|
|
2
|
-
from microIO import
|
|
2
|
+
from microIO import bind_pin, pinmap_search
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class Data:
|
|
@@ -16,7 +16,7 @@ class Data:
|
|
|
16
16
|
def __servo_init():
|
|
17
17
|
if Data.S_OBJ is None:
|
|
18
18
|
try:
|
|
19
|
-
pin = Pin(
|
|
19
|
+
pin = Pin(bind_pin('servo_1'))
|
|
20
20
|
Data.S_OBJ = PWM(pin, freq=50)
|
|
21
21
|
del pin
|
|
22
22
|
except Exception as e:
|
|
@@ -64,7 +64,7 @@ def sdemo():
|
|
|
64
64
|
def __servo2_init():
|
|
65
65
|
if Data.S_OBJ2 is None:
|
|
66
66
|
try:
|
|
67
|
-
pin = Pin(
|
|
67
|
+
pin = Pin(bind_pin('servo_2')) # Alternative wiring
|
|
68
68
|
Data.S_OBJ2 = PWM(pin, freq=50)
|
|
69
69
|
del pin
|
|
70
70
|
except Exception as e:
|
micrOS/source/LM_stepper.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from utime import sleep_ms
|
|
4
4
|
from machine import Pin
|
|
5
|
-
from microIO import
|
|
5
|
+
from microIO import bind_pin, pinmap_search
|
|
6
6
|
STEPPER_INST = None
|
|
7
7
|
|
|
8
8
|
|
|
@@ -30,10 +30,10 @@ class StepperULN2003:
|
|
|
30
30
|
[1, 0, 0, 1]]
|
|
31
31
|
self.delay = 2
|
|
32
32
|
# Init stepper pins
|
|
33
|
-
self.pin1 = Pin(
|
|
34
|
-
self.pin2 = Pin(
|
|
35
|
-
self.pin3 = Pin(
|
|
36
|
-
self.pin4 = Pin(
|
|
33
|
+
self.pin1 = Pin(bind_pin('stppr_1'), Pin.OUT)
|
|
34
|
+
self.pin2 = Pin(bind_pin('stppr_2'), Pin.OUT)
|
|
35
|
+
self.pin3 = Pin(bind_pin('stppr_3'), Pin.OUT)
|
|
36
|
+
self.pin4 = Pin(bind_pin('stppr_4'), Pin.OUT)
|
|
37
37
|
# Initialize all value to 0 - "OFF"
|
|
38
38
|
self.reset()
|
|
39
39
|
|
micrOS/source/LM_switch.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from machine import Pin
|
|
2
|
-
from microIO import
|
|
2
|
+
from microIO import bind_pin, pinmap_search
|
|
3
3
|
from Types import resolve
|
|
4
4
|
|
|
5
5
|
#########################################
|
|
@@ -82,7 +82,7 @@ def load(cache=None, ch_init=None):
|
|
|
82
82
|
|
|
83
83
|
def __switch_init():
|
|
84
84
|
if __SWITCH_OBJ[0] is None:
|
|
85
|
-
__SWITCH_OBJ[0] = Pin(
|
|
85
|
+
__SWITCH_OBJ[0] = Pin(bind_pin('switch_1'), Pin.OUT)
|
|
86
86
|
return __SWITCH_OBJ[0]
|
|
87
87
|
|
|
88
88
|
|
|
@@ -118,7 +118,7 @@ def toggle():
|
|
|
118
118
|
|
|
119
119
|
def __switch2_init():
|
|
120
120
|
if __SWITCH_OBJ[1] is None:
|
|
121
|
-
__SWITCH_OBJ[1] = Pin(
|
|
121
|
+
__SWITCH_OBJ[1] = Pin(bind_pin('switch_2'), Pin.OUT)
|
|
122
122
|
return __SWITCH_OBJ[1]
|
|
123
123
|
|
|
124
124
|
|
|
@@ -153,7 +153,7 @@ def toggle2():
|
|
|
153
153
|
|
|
154
154
|
def __switch3_init():
|
|
155
155
|
if __SWITCH_OBJ[2] is None:
|
|
156
|
-
__SWITCH_OBJ[2] = Pin(
|
|
156
|
+
__SWITCH_OBJ[2] = Pin(bind_pin('switch_3'), Pin.OUT)
|
|
157
157
|
return __SWITCH_OBJ[2]
|
|
158
158
|
|
|
159
159
|
|
|
@@ -188,7 +188,7 @@ def toggle3():
|
|
|
188
188
|
|
|
189
189
|
def __switch4_init():
|
|
190
190
|
if __SWITCH_OBJ[3] is None:
|
|
191
|
-
__SWITCH_OBJ[3] = Pin(
|
|
191
|
+
__SWITCH_OBJ[3] = Pin(bind_pin('switch_4'), Pin.OUT)
|
|
192
192
|
return __SWITCH_OBJ[3]
|
|
193
193
|
|
|
194
194
|
|
micrOS/source/LM_trackball.py
CHANGED
|
@@ -8,7 +8,7 @@ https://github.com/mchobby/esp8266-upy/blob/master/trackball/examples/test_color
|
|
|
8
8
|
from utime import sleep, ticks_ms, ticks_diff
|
|
9
9
|
from struct import unpack
|
|
10
10
|
from machine import SoftI2C, Pin
|
|
11
|
-
from microIO import
|
|
11
|
+
from microIO import bind_pin, pinmap_search
|
|
12
12
|
from Common import syslog
|
|
13
13
|
from micropython import schedule
|
|
14
14
|
|
|
@@ -179,7 +179,7 @@ def load(width=100, height=100, irq_sampling=50, sensitivity=5, reload=False):
|
|
|
179
179
|
"""
|
|
180
180
|
global TRACKBALL
|
|
181
181
|
if TRACKBALL is None or reload:
|
|
182
|
-
i2c = SoftI2C(scl=Pin(
|
|
182
|
+
i2c = SoftI2C(scl=Pin(bind_pin('i2c_scl')), sda=Pin(bind_pin('i2c_sda')))
|
|
183
183
|
TRACKBALL = Trackball(i2c, max_x=width, max_y=height, irq_sampling=irq_sampling, sensitivity=sensitivity)
|
|
184
184
|
_craft_event_interrupt()
|
|
185
185
|
ready_color()
|
|
@@ -253,7 +253,7 @@ def _craft_event_interrupt():
|
|
|
253
253
|
syslog(f"[ERR] Trackball user callback: {e}")
|
|
254
254
|
|
|
255
255
|
try:
|
|
256
|
-
pin =
|
|
256
|
+
pin = bind_pin("trackball_int")
|
|
257
257
|
except Exception as e:
|
|
258
258
|
pin = None
|
|
259
259
|
syslog(f'[ERR] trackball_int IRQ: {e}')
|
micrOS/source/LM_veml7700.py
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
from machine import SoftI2C, Pin
|
|
6
6
|
from time import sleep
|
|
7
7
|
from micropython import const
|
|
8
|
-
from microIO import
|
|
8
|
+
from microIO import bind_pin, pinmap_search
|
|
9
9
|
from Types import resolve
|
|
10
10
|
|
|
11
11
|
# start const
|
|
@@ -134,7 +134,7 @@ def load():
|
|
|
134
134
|
VEML7700 Digital light intensity sensor
|
|
135
135
|
"""
|
|
136
136
|
if VEML7700.INSTANCE is None:
|
|
137
|
-
i2c = SoftI2C(Pin(
|
|
137
|
+
i2c = SoftI2C(Pin(bind_pin('i2c_scl')), Pin(bind_pin('i2c_sda')))
|
|
138
138
|
VEML7700.INSTANCE = VEML7700(address=0x10, i2c=i2c, it=100, gain=1/8)
|
|
139
139
|
return VEML7700.INSTANCE
|
|
140
140
|
|