tiny bits of cleanup here and there
This commit is contained in:
parent
aed9e9541c
commit
ad49956139
33
uPyConfig.py
33
uPyConfig.py
|
@ -1,5 +1,5 @@
|
|||
class uPyConfig:
|
||||
from machine import I2C, Pin
|
||||
from machine import Pin
|
||||
class features:
|
||||
class connectivity:
|
||||
wifi = False
|
||||
|
@ -15,27 +15,27 @@ class uPyConfig:
|
|||
temperature = False
|
||||
hall_effect = False
|
||||
|
||||
class owc:
|
||||
class _owc:
|
||||
from onewire import OneWire
|
||||
from machine import Pin
|
||||
def __init__(self, pin):
|
||||
if pin.__class__ != self.Pin: pin=self.Pin(pin)
|
||||
self.bus = self.OneWire(pin)
|
||||
|
||||
class _i2c:
|
||||
from machine import I2C, Pin
|
||||
|
||||
from machine import I2C
|
||||
def load_handle(self):
|
||||
if self.bus.__class__ == self.I2C: return
|
||||
self.bus = self.I2C(scl=self.scl, sda=self.sda)
|
||||
self.bus.init(scl=self.scl, sda=self.sda)
|
||||
|
||||
def __init__(self, scl, sda):
|
||||
self.scl=self.Pin(scl)
|
||||
self.sda=self.Pin(sda)
|
||||
if scl.__class__ != self.Pin: scl=self.Pin(scl)
|
||||
if sda.__class__ != self.Pin: sda=self.Pin(sda)
|
||||
self.scl=scl
|
||||
self.sda=sda
|
||||
self.load_handle()
|
||||
|
||||
class _oled:
|
||||
from machine import Pin
|
||||
addr = 0x0
|
||||
rst = 0
|
||||
rst_hold = False
|
||||
|
@ -55,11 +55,17 @@ class uPyConfig:
|
|||
def __init__(self, i2c):
|
||||
self.i2c = i2c
|
||||
|
||||
def onewire_init(self, pin, glob=True):
|
||||
if glob: self.owc = self._owc(pin)
|
||||
else: return self._owc(pin)
|
||||
return self.owc
|
||||
|
||||
def __init__(self, board_defs):
|
||||
self.i2c = self._i2c(board_defs['i2c_scl'], board_defs['i2c_sda'])
|
||||
if 'has_wifi' in board_defs.keys(): self.features.connectivity.wifi = True
|
||||
if 'has_bluetooth' in board_defs.keys(): self.features.connectivity.bluetooth = True
|
||||
if 'has_bluetooth_le' in board_defs.keys(): self.features.connectivity.bluetooth_le = True
|
||||
if 'has_lora' in board_defs.keys(): self.features.connectivity.lora = True
|
||||
if 'sen_capacitive' in board_defs.keys(): self.features.sensor.capacitive = True
|
||||
if 'sen_temperature' in board_defs.keys(): self.features.sensor.temperature = True
|
||||
if 'sen_hall' in board_defs.keys(): self.features.sensor.hall_effect = True
|
||||
|
@ -153,6 +159,17 @@ class esp32(uPyConfig):
|
|||
'oled_height': 64,
|
||||
'oled_width': 128,
|
||||
},
|
||||
'ttgo-1': {
|
||||
'has_oled': True,
|
||||
'oled_height': 64,
|
||||
'oled_width': 128,
|
||||
},
|
||||
'ttgo-2': {
|
||||
'has_oled': True,
|
||||
'oled_height': 64,
|
||||
'oled_width': 128,
|
||||
'has_lora': True,
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, variant='generic'):
|
||||
|
|
Loading…
Reference in New Issue