2022-03-24 16:01:12 +08:00
|
|
|
# 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.
|
|
|
|
|
2022-03-11 09:49:24 +08:00
|
|
|
# from machine import Pin
|
|
|
|
from usr.logging import getLogger
|
|
|
|
|
|
|
|
log = getLogger(__name__)
|
|
|
|
|
|
|
|
|
2022-03-11 14:05:06 +08:00
|
|
|
class LED(object):
|
|
|
|
def __init__(self, period=None):
|
|
|
|
self.period = None
|
2022-03-11 17:18:18 +08:00
|
|
|
self.led_status = None
|
2022-03-11 09:49:24 +08:00
|
|
|
|
2022-03-11 14:05:06 +08:00
|
|
|
def switch(self, flag=None):
|
|
|
|
# TODO:
|
|
|
|
# 1. flag is None Auto Check LED Status ON To OFF or OFF To ON.
|
|
|
|
# 2. flag is 1 LED ON.
|
|
|
|
# 3. flag is 0 LED OFF.
|
2022-03-11 17:18:18 +08:00
|
|
|
if flag is None:
|
|
|
|
if self.led_status == 1:
|
2022-04-06 09:31:11 +08:00
|
|
|
# TODO: LED SET OFF
|
2022-03-11 17:18:18 +08:00
|
|
|
self.led_status = 0
|
|
|
|
else:
|
2022-04-06 09:31:11 +08:00
|
|
|
# TODO: LED SET ON
|
2022-03-11 17:18:18 +08:00
|
|
|
self.led_status = 1
|
|
|
|
elif flag == 0:
|
|
|
|
if self.led_status == 0:
|
2022-04-06 09:31:11 +08:00
|
|
|
# TODO: LED ALREADY OFF
|
2022-03-11 17:18:18 +08:00
|
|
|
pass
|
|
|
|
else:
|
2022-04-06 09:31:11 +08:00
|
|
|
# TODO: LED SET OFF
|
2022-03-11 17:18:18 +08:00
|
|
|
self.led_status = 0
|
|
|
|
elif flag == 1:
|
|
|
|
if self.led_status == 1:
|
2022-04-06 09:31:11 +08:00
|
|
|
# TODO: LED ALREADY ON
|
2022-03-11 17:18:18 +08:00
|
|
|
pass
|
|
|
|
else:
|
2022-04-06 09:31:11 +08:00
|
|
|
# TODO: LED SET ON
|
2022-03-11 17:18:18 +08:00
|
|
|
self.led_status = 1
|
2022-03-11 14:05:06 +08:00
|
|
|
pass
|