demo.dtu/dtu_gpio.py
elian.wang d5c4007e32 1.删除offline_storage.py文件
2.将所有py文件中的'改为"
3.将透传模式从modbus中分成单独文件through_mode
4.将uart中从串口和云端接收数据处理的函数重新命名
5.将command.py文件改为command_mode.py文件、将modbus.py文件改为modbus_mode.py文件
2022-05-06 19:47:27 +08:00

32 lines
1018 B
Python

from machine import Pin
from usr.modules.logging import getLogger
from usr.modules.common import Singleton
log = getLogger(__name__)
class ProdGPIO(Singleton):
def __init__(self, pins):
# self.gpio1 = Pin(Pin.GPIO1, Pin.OUT, Pin.PULL_DISABLE, 0)
set_gpio = False
log.info("pin: ", pins)
for i in pins:
if len(i):
try:
gpio = int(i)
except:
log.error("dtu_config.json pins setting error! Only allow numbers")
continue
log.info("gpio {} set".format(gpio))
gpio_n = getattr(Pin, "GPIO%d" % gpio)
gpio_obj = Pin(gpio_n, Pin.OUT, Pin.PULL_DISABLE, 0)
setattr(self, "gpio%d" % gpio, gpio_obj)
set_gpio = True
if not set_gpio:
self.gpio1 = Pin(Pin.GPIO1, Pin.OUT, Pin.PULL_DISABLE, 0)
def status(self):
self.gpio1.read()
def show(self):
self.gpio1.write(1)