demo.dtu/dtu_gpio.py
elian.wang e81aa3792c 1.修改dtu_mqtt、dtu_request、tcp_udpsocket.py的文件名
2.文件头增加软件版权信息
3.移植tracker最新移远云
4.修复阿里云中set_ota_info函数bug
2022-05-17 11:12:12 +08:00

55 lines
1.8 KiB
Python

# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import utime
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)
def LED_blink(self, sta, cnt):
while(sta == 0 and cnt > 0):
self.gpio1.write(1)
utime.sleep(1)
self.gpio1.write(0)
utime.sleep(1)
cnt -= 1