code
stringlengths
1
1.05M
repo_name
stringlengths
6
83
path
stringlengths
3
242
language
stringclasses
222 values
license
stringclasses
20 values
size
int64
1
1.05M
import modbus import math import struct def bytes2float(bytes): ba = bytearray() ba.append(bytes[1]) ba.append(bytes[0]) ba.append(bytes[3]) ba.append(bytes[2]) return struct.unpack("!f",ba)[0] class DDS5188(object): def __init__(self, node, slave_addr): if modbus.init(node) != 0:...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/power_meter/nodemcu32s/code/dds5188.py
Python
apache-2.0
1,534
# -*- encoding: utf-8 -*- from aliyunIoT import Device # aliyunIoT组件是连接阿里云物联网平台的组件 import utime # 延时API所在组件 import ujson # json字串解析库 import network # network是Wi-Fi网络连接的组件 import dds5188 # 物联网平台连接标志位 iot_connected = False # 三元组信息 productKey = "产品密钥" deviceName = "设...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/power_meter/nodemcu32s/code/main.py
Python
apache-2.0
4,180
from driver import GPIO class IR(object): def __init__(self, gpioObj): self.gpioObj = None if not isinstance(gpioObj, GPIO): raise ValueError("parameter is not a GPIO object") self.gpioObj = gpioObj def irDetect(self): if self.gpioObj is None: raise Va...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/power_saver/esp32/code/ir.py
Python
apache-2.0
410
# -*- coding: UTF-8 -*- from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import ujson # json字串解析库 import utime # 延时API所在组件 from driver import GPIO # GPIO类,用于控制微处理器的输入输出功能 from ir import IR import modbus from micropython...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/power_saver/esp32/code/main.py
Python
apache-2.0
5,101
# coding=utf-8 from driver import GPIO import network import ujson import utime as time import modem from aliyunIoT import Device import kv import read import write import _thread import mfrc522 import ujson from driver import WDT wdt = WDT() wdt.open('wdt') wdt.feed() global g_connect_status,net,device,deviceSecr...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/rc522_write_read/haas506/code/main.py
Python
apache-2.0
5,054
from driver import SPI from driver import GPIO class MFRC522: OK = 0 NOTAGERR = 1 ERR = 2 REQIDL = 0x26 REQALL = 0x52 AUTHENT1A = 0x60 #验证A密钥 AUTHENT1B = 0x61 #验证B密钥 def __init__(self): self.spi=SPI() self.spi.open('SPI0') self.rst=GPIO() self.rst.open('rst') self.rst.write(0) self.rst....
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/rc522_write_read/haas506/code/mfrc522.py
Python
apache-2.0
4,125
import mfrc522 import utime as time def do_read(rdr): print("enter do_read()") try: (stat, tag_type) = rdr.request(rdr.REQIDL) if stat == rdr.OK: (stat, raw_uid) = rdr.anticoll() if stat == rdr.OK: print("New card detected") print(" - tag type: 0x%02x" % tag_type) print(" - uid : 0x%02x%02x...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/rc522_write_read/haas506/code/read.py
Python
apache-2.0
1,440
import mfrc522 import utime as time def do_write(): rdr = mfrc522.MFRC522() try: while True: (stat, tag_type) = rdr.request(rdr.REQIDL) if stat == rdr.OK: (stat, raw_uid) = rdr.anticoll() if stat == rdr.OK: print("New card detected") print(" - tag type: 0x%02x" % tag_type) print(" - ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/rc522_write_read/haas506/code/write.py
Python
apache-2.0
1,157
######### from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import ujson ################## from driver import SPI,GPIO,PWM import mfrc522 import utime import servo rfid_card = 0 mfrc522Dev = 0 buzzerobj = 0 servoObj = 0 ######### # 物联网平台连接标志位 iot_connected = False...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/rfid_open_door/esp32/code/main.py
Python
apache-2.0
4,896
from driver import SPI,GPIO class AuthenticationError(Exception): pass class StatusNotSuccessError(Exception): pass class MFRC522: KEY = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF] BLOCK_ADDRS = [8, 9, 10] MAX_LEN = 16 PCD_IDLE = 0x00 PCD_AUTHENT = 0x0E PCD_RECEIVE = 0x08 PCD_TRANSMIT = 0x0...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/rfid_open_door/esp32/code/mfrc522.py
Python
apache-2.0
14,351
""" HaaSPython PWM driver for servo """ from driver import PWM class SERVO(object): def __init__(self, pwmObj): self.pwmObj = None if not isinstance(pwmObj, PWM): raise ValueError("parameter is not an PWM object") self.pwmObj = pwmObj def setOptionSero(self,data): ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/rfid_open_door/esp32/code/servo.py
Python
apache-2.0
642
# coding=utf-8 from driver import GPIO from driver import PWM import network import ujson import utime as time import modem from aliyunIoT import Device import kv import mfrc522 #当iot设备连接到物联网平台的时候触发'connect' 事件 def on_connect(data): global module_name,default_ver,productKey,deviceName,deviceSecret,on_trigger,...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/rfid_open_door/haas506/code/main.py
Python
apache-2.0
6,413
from driver import SPI from driver import GPIO class MFRC522: OK = 0 NOTAGERR = 1 ERR = 2 REQIDL = 0x26 REQALL = 0x52 AUTHENT1A = 0x60 #验证A密钥 AUTHENT1B = 0x61 #验证B密钥 def __init__(self): self.spi=SPI() self.spi.open('SPI0') self.rst=GPIO() self.rst.open('rst') self.rst.write(0) self.rst.w...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/rfid_open_door/haas506/code/mfrc522.py
Python
apache-2.0
4,092
from driver import PWM class BUZZER(object): def __init__(self, pwmObj,data=None): self.pwmObj = None if not isinstance(pwmObj, PWM): raise ValueError("parameter is not an PWM object") self.pwmObj = pwmObj if data is not None: self.setOptionDuty(data) ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/security_monitoring_system/m5stack/code/buzzer.py
Python
apache-2.0
757
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : cloudAI.py @Description: 云端AI @Author : jiangyu @version : 1.0 ''' from aliyunIoT import Device import utime # 延时函数在utime库中 import ujson as json class CloudAI : def __gesture_cb(self, dict) : ''' Reply lis...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/security_monitoring_system/m5stack/code/cloudAI.py
Python
apache-2.0
12,826
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : irdistance.py @Description: 红外传感器驱动 @Author : 风裁 @version : 1.0 ''' from driver import GPIO class IRDISTANCE(object): def __init__(self, gpioObj): self.gpioObj = None if not isinstance(gpioObj, GPIO): ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/security_monitoring_system/m5stack/code/irdistance.py
Python
apache-2.0
597
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Author : aoyi @version : 1.0 @Description: security_monitoring_system案例 - 防盗报警系统 board.json - 硬件资源配置文件 ''' from buzzer import BUZZER import irdistance from driver import PWM,GPIO import time from aliyunIoT ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/security_monitoring_system/m5stack/code/main.py
Python
apache-2.0
5,945
from driver import GPIO class IR(object): def __init__(self, gpioObj): self.gpioObj = None if not isinstance(gpioObj, GPIO): raise ValueError("parameter is not a GPIO object") self.gpioObj = gpioObj def irDetect(self): if self.gpioObj is None: raise Va...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/sedentary_remind/esp32/code/ir.py
Python
apache-2.0
410
######### from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import ujson ################## from driver import I2C,GPIO,TIMER import utime from ssd1306 import SSD1306_I2C import ir import time temptimerObj = 0 time_dict = {} ######### # 物联网平台连接标志位 iot_connected = Fa...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/sedentary_remind/esp32/code/main.py
Python
apache-2.0
6,930
from micropython import const import framebuf from driver import I2C # register definitions SET_CONTRAST = const(0x81) SET_ENTIRE_ON = const(0xa4) SET_NORM_INV = const(0xa6) SET_DISP = const(0xae) SET_MEM_ADDR = const(0x20) SET_COL_ADDR = const(0x21) SET_PAGE_ADDR =...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/sedentary_remind/esp32/code/ssd1306.py
Python
apache-2.0
3,565
# coding=utf-8 from driver import GPIO import network import ujson import utime as time import modem from aliyunIoT import Device import kv import sntp #当iot设备连接到物联网平台的时候触发'connect' 事件 def on_connect(data): global module_name,default_ver,productKey,deviceName,deviceSecret,on_trigger,on_download,on_verify,on_up...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/sedentary_remind/haas506/code/main.py
Python
apache-2.0
6,018
from driver import GPIO from onewire import OneWire from machine import Pin import time class DS18B20(): def __init__(self, gpioObj, resolution=12): self.pin = None if not isinstance(gpioObj, GPIO): raise ValueError("parameter is not a GPIO object") self.pin = gpioObj.port() ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_aquarium/esp32/code/ds18b20.py
Python
apache-2.0
4,160
from driver import GPIO import utime class HX710(object): def __init__(self, clkObj, dataObj): self.clkObj = None self.dataObj = None if not isinstance(clkObj, GPIO): raise ValueError("parameter is not an GPIO object") if not isinstance(dataObj, GPIO): raise ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_aquarium/esp32/code/hx710.py
Python
apache-2.0
1,032
import hx710 # 引入HX710传感器驱动库 import tds # 引入tds传感器驱动库 import ds18b20 # 引入ds18b20传感器驱动库 import relay # 引入继电器驱动库 from driver import ADC from driver import GPIO import utime # 延时函数在utime库中 from aliyunIoT import Device # iot组件是...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_aquarium/esp32/code/main.py
Python
apache-2.0
7,504
from driver import GPIO class Relay(): def __init__(self, gpioObj, trigger): self.gpioObj = None if not isinstance(gpioObj, GPIO): raise ValueError("parameter gpioObj is not a GPIO object") if (trigger is not 0) and (trigger is not 1): raise ValueError("parameter tr...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_aquarium/esp32/code/relay.py
Python
apache-2.0
766
from driver import ADC class TDS(object): def __init__(self, adcObj, T = 25): self._adcObj = None if not isinstance(adcObj, ADC): raise ValueError("parameter is not an ADC object") self._adcObj = adcObj self.temperature = T def getTDS(self): if self._adcOb...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_aquarium/esp32/code/tds.py
Python
apache-2.0
1,171
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for CHT8305 Author: HaaS Date: 2021/09/14 """ import utime from micropython import const from driver import I2C #AHT21B_I2CADDR_DEFAULT = const(0x38) # Default I2C address AHT21B_CMD_CALIBRATE = const(0xE1) # Calibration ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_fan/esp32/code/aht21b.py
Python
apache-2.0
4,656
from driver import PWM class Fan(object): def __init__(self, pwmObj,data=None): self.pwmObj = None if not isinstance(pwmObj, PWM): raise ValueError("parameter is not an PWM object") self.pwmObj = pwmObj if data is not None: self.data = data self...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_fan/esp32/code/fan.py
Python
apache-2.0
1,028
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Author : guoliang.wgl @version : 1.0 @Description: smart_fan案例 - 智能控制小风扇 board.json - 硬件资源配置文件 ''' from fan import Fan from aht21b import AHT21B from driver import PWM, I2C import time from aliyunIoT import ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_fan/esp32/code/main.py
Python
apache-2.0
5,669
import utime as time from driver import I2C #CONSTANTS AHT10_ADDRESS = 0x38 # 0111000 (7bit address) AHT10_READ_DELAY_MS = 75 # Time it takes for AHT to collect data AHT_TEMPERATURE_CONST = 200 AHT_TEMPERATURE_OFFSET = 50 KILOBYTE_CONST = 1048576 CMD_INITIALIZE = bytearray([0xE1, 0x08, 0x00]) CMD_MEASURE = bytearr...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_fan/haas506/code/ahtx0.py
Python
apache-2.0
2,424
# coding=utf-8 from ahtx0 import AHT10 from driver import PWM import network import ujson import utime as time import modem from aliyunIoT import Device import kv # 警报开关以及时间段控制 gear1_temp = 22 gear2_temp = 27 gear3_temp = 32 FLAG_CUR_TEMP = "temp" FLAG_GEAR1 = "gear1" FLAG_GEAR2 = "gear2" FLAG_GEAR3 = "gear3" cur_ge...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_fan/haas506/code/main.py
Python
apache-2.0
7,406
import lvgl as lv # RESOURCES_ROOT = "S:/Users/liujuncheng/workspace/iot/esp32/solution/MicroPython/smart_panel/smart_panel/" RESOURCES_ROOT = "S:/data/pyamp/" compass_ttf_alive = False def compass_back_click_callback(e, win): global compass_ttf_alive if (compass_ttf_alive): from smart_panel import l...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_panel/esp32/code/compass.py
Python
apache-2.0
4,255
import lvgl as lv import utime # RESOURCES_ROOT = "S:/Users/liujuncheng/workspace/iot/esp32/solution/HaaSPython/solutions/smart_panel/" RESOURCES_ROOT = "S:/data/pyamp/" def drawOver(e): global g_clickTime if (g_clickTime != 0): currentTime = utime.ticks_ms() print("create Environment page us...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_panel/esp32/code/environment.py
Python
apache-2.0
4,623
import lvgl as lv # RESOURCES_ROOT = "S:/Users/liujuncheng/workspace/iot/esp32/solution/MicroPython/smart_panel/smart_panel/" RESOURCES_ROOT = "S:/data/pyamp/" environment_alive = False functionImage = [ RESOURCES_ROOT + "images/refrigeration.png", RESOURCES_ROOT + "images/heating.png", RESOU...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_panel/esp32/code/hvac.py
Python
apache-2.0
8,523
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Description: helloworld案例 - 周期性打印"helloworld"到console中 @Author : ethan.lcz @version : 1.0 ''' # import utime # 延时函数在utime库中 # if __name__ == '__main__': # while True: # 无限循环 # print("hellworld") #...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_panel/esp32/code/main.py
Python
apache-2.0
746
import lvgl as lv from audio import Player # RESOURCES_ROOT = "S:/Users/liujuncheng/workspace/iot/esp32/solution/MicroPython/smart_panel/smart_panel/" RESOURCES_ROOT = "S:/data/pyamp/" functionImage = [ RESOURCES_ROOT + "images/prev.png", RESOURCES_ROOT + "images/play.png", RESOURCES_ROOT + "...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_panel/esp32/code/music.py
Python
apache-2.0
12,990
# RESOURCES_ROOT = "S:/Users/liujuncheng/workspace/iot/esp32/solution/MicroPython/smart_panel/smart_panel/" RESOURCES_ROOT = "S:/data/pyamp/" from environment import Environment from hvac import Hvac from compass import Compass from music import Music from soundttf import SoundTTF from timer import Timer def init(): ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_panel/esp32/code/smart_panel.py
Python
apache-2.0
6,825
import lvgl as lv # RESOURCES_ROOT = "S:/Users/liujuncheng/workspace/iot/esp32/solution/MicroPython/smart_panel/smart_panel/" RESOURCES_ROOT = "S:/data/pyamp/" sound_ttf_alive = False def sound_ttf_back_click_callback(e, win): global sound_ttf_alive if (sound_ttf_alive): from smart_panel import load_...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_panel/esp32/code/soundttf.py
Python
apache-2.0
4,006
import lvgl as lv # RESOURCES_ROOT = "S:/Users/liujuncheng/workspace/iot/esp32/solution/MicroPython/smart_panel/smart_panel/" RESOURCES_ROOT = "S:/data/pyamp/" isStarted = False isAnimationComplete = False arc = [None, None, None, None] anim = [None, None, None, None] timeCount = [1, 3, 5, 10] currentSelect = 0 minut...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_panel/esp32/code/timer.py
Python
apache-2.0
14,706
# -*- encoding: utf-8 -*- from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import utime # 延时API所在组件 import ujson # json字串解析库 from driver import ADC # ADC类,通过微处理器的ADC模块读取ADC通道输入电压 from driver import GPIO import photore...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_public_lighting/esp32/code/main.py
Python
apache-2.0
6,006
from driver import ADC class PhotoResistor(object): def __init__(self, adcObj): self.adcObj = None if not isinstance(adcObj, ADC): raise ValueError("parameter is not an ADC object") self.adcObj = adcObj def getLightness(self): if self.adcObj is None: ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_public_lighting/esp32/code/photoresistor.py
Python
apache-2.0
438
# coding=utf-8 from driver import I2C from driver import GPIO import network import ujson import utime as time import modem from aliyunIoT import Device import kv #指令相应参数 DEVICE = 0x23 POWER_DOWN = 0x00 POWER_ON = 0x01 RESET = 0x07 CONTINUOUS_LOW_RES_MODE = 0x13 CONTINUOUS_HIGH_RES_MODE_1 = 0x10 CONTI...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_public_lighting/haas506/code/main.py
Python
apache-2.0
5,878
""" Copyright (C) 2015-2020 Alibaba Group Holding Limited The driver for AP3216C chip, The AP3216C is an integrated ALS & PS module that includes a digital ambient light sensor [ALS], a proximity sensor [PS], and an IR LED in a single package. """ from micropython import const from driver import I2C from utime import ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_public_lighting/haaseduk1/code/ap3216c.py
Python
apache-2.0
13,749
from aliyunIoT import Device # aliyunIoT组件是连接阿里云物联网平台的组件 import utime import ap3216c from driver import I2C from driver import GPIO import netmgr as nm import ujson # 三元组信息 productKey = "产品密钥" deviceName = "设备名称" deviceSecret = "设备密钥" # Wi-Fi SSID和Password设置 wifiSsid = "请填写您的路由器名称" wifiPassword = "请填写您的路由器密码" ad...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_public_lighting/haaseduk1/code/main.py
Python
apache-2.0
4,675
from driver import GPIO class IR(object): def __init__(self, gpioObj): self.gpioObj = None if not isinstance(gpioObj, GPIO): raise ValueError("parameter is not a GPIO object") self.gpioObj = gpioObj def irDetect(self): if self.gpioObj is None: raise Va...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_toilet/esp32/code/ir.py
Python
apache-2.0
410
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Author : guoliang.wgl @version : 1.0 @Description: smart_toilet案例 - 智能洗手间 board.json - 硬件资源配置文件 ''' from ir import IR from mq136 import MQ136 from driver import ADC, GPIO import time from aliyunIoT import Dev...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_toilet/esp32/code/main.py
Python
apache-2.0
4,118
from driver import ADC class MQ136(object): def __init__(self, adcObj): self.adcObj = None if not isinstance(adcObj, ADC): raise ValueError("parameter is not an ADC object") self.adcObj = adcObj def getVoltage(self): if self.adcObj is None: raise Value...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_toilet/esp32/code/mq136.py
Python
apache-2.0
412
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : cloudAI.py @Description: 云端AI @Author : jiangyu @version : 1.0 ''' from aliyunIoT import Device import utime # 延时函数在utime库中 import ujson as json class CloudAI : def __gesture_cb(self, dict) : ''' Reply lis...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_traffic_light/esp32/code/cloudAI.py
Python
apache-2.0
11,842
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Description: 交通红绿灯 @Author : zhangheng @version : 1.0 方案设计 初始红灯60秒、黄灯3秒、绿灯30秒 每4次拍摄为一组 摄像头10秒拍摄1次,连续4次拍摄的车辆数都是大于M量车,判断当前是红灯或黄灯,则将接下来的绿灯加10秒,下一次的红灯减去10秒,如果当前就是绿灯,则不处理,继续下一组拍摄 如果有一次拍摄不满足大于M量车,则下一次灯的周期恢复为原始设置周期 如果云端有强制设置红绿灯时间周期或...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_traffic_light/esp32/code/main.py
Python
apache-2.0
10,537
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : rgb.py @Description: rgb灯传感器 @Author : 风裁 @version : 1.0 ''' from driver import PWM class RgbLed(): def __init__(self, pwmRObj, pwmGObj, pwmBObj): if not isinstance(pwmRObj, PWM): raise ValueError("parameter p...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/smart_traffic_light/esp32/code/rgb.py
Python
apache-2.0
1,666
# !/usr/bin/python3 # -- coding: utf-8 -- # @Time : 2022/6/13 11:00 AM # @Author : grady from driver import ADC import utime as time from modem import sms ############################### # 需要发送短信的目标电话号码,长度为11的字符串格式 tele_phone = 'xxxxxxxxxxx' ############################### if __name__ == '__main__': # 报警次数 w...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/sms_fire_alarm/code/main.py
Python
apache-2.0
1,108
from driver import GPIO class IR(object): def __init__(self, gpioObj): self.gpioObj = None if not isinstance(gpioObj, GPIO): raise ValueError("parameter is not a GPIO object") self.gpioObj = gpioObj def irDetect(self): if self.gpioObj is None: raise Va...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/soap_dispenser/ESP-32S/code/ir.py
Python
apache-2.0
410
# -*- coding: UTF-8 -*- from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import ujson # json字串解析库 import utime # 延时API所在组件 from driver import ADC # ADC类,用ADC外设的接入 from driver import PWM # PWM类,用舵机控制 from dri...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/soap_dispenser/ESP-32S/code/main.py
Python
apache-2.0
5,612
""" HaaSPython PWM driver for servo 舵机传感器驱动 """ from driver import PWM class SERVO(object): def __init__(self, pwmObj): self.pwmObj = None if not isinstance(pwmObj, PWM): raise ValueError("parameter is not an PWM object") self.pwmObj = pwmObj def setOptionSero(self,data)...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/soap_dispenser/ESP-32S/code/servo.py
Python
apache-2.0
664
from driver import ADC class WATER4LEVEL(object): def __init__(self, adcObj): self.adcObj = None if not isinstance(adcObj, ADC): raise ValueError("parameter is not an ADC object") self.adcObj = adcObj def measureLevel(self): if self.adcObj is None: rais...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/soap_dispenser/ESP-32S/code/water4level.py
Python
apache-2.0
704
import utime from math import trunc from micropython import const from driver import I2C class INA219(object): RANGE_16V = const(0) # Range 0-16 volts RANGE_32V = const(1) # Range 0-32 volts GAIN_1_40MV = const(0) # Maximum shunt voltage 40mV GAIN_2_80MV = const(1) # Maximum shunt voltage 80mV ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/solar_monitor/haas506/code/ina219.py
Python
apache-2.0
10,616
#!/usr/bin/env python # -*- encoding: utf-8 -*- import utime import ujson from aliyunIoT import Device import modbus as mb import yuanda_htb485 import network import ina219 from driver import GPIO from driver import ADC from driver import I2C # 4G.Cat1连网代码 g_connect_status = False def on_4g_cb(args): print("4g ca...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/solar_monitor/haas506/code/main.py
Python
apache-2.0
3,399
import ustruct class HTB485(object): def __init__(self, mbObj, devAddr): self.mbObj = mbObj self.devAddr = devAddr def getHumidity(self): if self.mbObj is None: raise ValueError("invalid modbus object.") value = bytearray(4) ret = self.mbObj.readHol...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/solar_monitor/haas506/code/yuanda_htb485.py
Python
apache-2.0
1,739
#!/usr/bin/env python # -*- encoding: utf-8 -*- import utime import ujson from aliyunIoT import Device import modbus as mb import yuanda_htb485 import network from driver import GPIO from driver import ADC # 4G.Cat1连网代码 g_connect_status = False def on_4g_cb(args): print("4g callback.") global g_connect_status...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/solar_street_lamp/haas506/code/main.py
Python
apache-2.0
4,552
import ustruct class HTB485(object): def __init__(self, mbObj, devAddr): self.mbObj = mbObj self.devAddr = devAddr def getHumidity(self): if self.mbObj is None: raise ValueError("invalid modbus object.") value = bytearray(4) ret = self.mbObj.readHol...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/solar_street_lamp/haas506/code/yuanda_htb485.py
Python
apache-2.0
1,739
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @File : main.py @Author : 杭漂 @version : 1.0 @Description: 声控灯案例 ''' from aliyunIoT import Device import network # 网络库 import utime # 延时函数在utime库中 import sntp # 网络时间同步库 import _thread # 线程库 import utime # 延时函数在...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/sound_led/esp32/code/main.py
Python
apache-2.0
6,063
# coding=utf-8 from driver import ADC from driver import GPIO import network import ujson import utime as time import modem from aliyunIoT import Device import kv import _thread #当iot设备连接到物联网平台的时候触发'connect' 事件 def on_connect(data): global module_name,default_ver,productKey,deviceName,deviceSecret,on_trigger,o...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/sound_led/haas506/code/main.py
Python
apache-2.0
7,073
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @File : main.py @Author : 杭漂 @version : 1.0 @Description: 声控灯案例 ''' from ulinksdk.aliyunIoT import Device import network # 网络库 import utime # 延时函数在utime库中 import sntp # 网络时间同步库 import _thread # 线程库 import utime ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/sound_led/stm32/code/main.py
Python
apache-2.0
6,102
import utime # 命令标志(配合后面的参数传递) LCD_CLEARDISPLAY = 0x01 LCD_RETURNHOME = 0x02 LCD_ENTRYMODESET = 0x04 LCD_DISPLAYCONTROL = 0x08 LCD_CURSORSHIFT = 0x10 LCD_FUNCTIONSET = 0x20 LCD_SETCGRAMADDR = 0x40 LCD_SETDDRAMADDR = 0x80 # 打印项标志 # 光标移动模式(打印时) LCD_ENTRY_DEC = 0x00 # Decrease 模式,光标向左减少,即从右到左打印 LCD_ENTRY_INC = 0x02 # In...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/stock_alarm/esp32/code/lcd1602.py
Python
apache-2.0
7,937
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Author : Alibaba @version : 1.0 @Description: 通过连接物联网云平台,在收到股票涨停信号时,控制设备LCD显示股票代码,并控制蜂鸣器发出警报。 board.json - 硬件资源配置文件,详情请参考:https://haas.iot.aliyun.com/haasapi/index.html#/Python/docs/zh-CN/haas_extended_api/dr...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/stock_alarm/esp32/code/main.py
Python
apache-2.0
4,009
from motion import motion from mpu6886 import mpu6886 import utime # 延时函数在utime from driver import I2C # 驱动库 import network # Wi-Fi功能所在库 import ujson # json字串解析库 from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 i2cObj = None mpu6886Dev = None motionObj = None...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/tap_detection/esp32/code/main.py
Python
apache-2.0
4,232
ITER_NUM = 50 ACCELERATION_LOW_THREADHOLD = 4 # 加速度变化下限阈值,越大越灵敏 ACCELERATION_UP_THREADHOLD = 12 # 加速度变化上限阈值,越小越灵敏 ANGULAR_VELOCITY_LOW_THREADHOLD = 1 # 角速度变化下限阈值,越小越灵敏 ANGULAR_VELOCITY_UP_THREADHOLD = 40 # 角速度变化下限阈值,越大越灵敏 class fall_detection: def __init__(self, getData): self.ax_offset = 0.0 ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/tap_detection/esp32/code/motion/detections/fall_detection.py
Python
apache-2.0
4,794
import utime # 延时函数在utime ITER_NUM = 100 class tap_detection: def __init__(self, tap_detect_count, getData): self.ax_offset = 0.0 self.ay_offset = 0.0 self.az_offset = 0.0 self.triggercount = 0 self.untriggercount = 0 self.tapcount = 0 self.tap_detect_cou...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/tap_detection/esp32/code/motion/detections/tap_detection.py
Python
apache-2.0
4,356
import utime # 延时函数在utime from .detections.fall_detection import fall_detection from .detections.tap_detection import tap_detection class Motion: def __init__(self, action, getData, onActionDetected): self.action = action if (action == "fall"): self.detectAction = fall_detection(getDa...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/tap_detection/esp32/code/motion/motion.py
Python
apache-2.0
1,377
""" HaaSPython I2C driver for MPU6886 6-axis motion tracking device """ # pylint: disable=import-error import ustruct import utime # from machine import I2C, Pin from driver import I2C from micropython import const # pylint: enable=import-error _CONFIG = const(0x1a) _GYRO_CONFIG = const(0x1b) _ACCEL_CONFIG = const(0x...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/tap_detection/esp32/code/mpu6886/mpu6886.py
Python
apache-2.0
7,149
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for CHT8305 Author: HaaS Date: 2021/09/14 """ from micropython import const from utime import sleep_ms from driver import I2C CHT8305_REG_TEMP = 0x00 CHT8305_REG_HUMI = 0x01 # The register address in CHT8305 controller. c...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/temp_humidity_speaker/haaseduk1/code/cht8305.py
Python
apache-2.0
4,277
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' 基于HaaS Python框架的本地语音播报温湿度系统 ''' from aliyunIoT import Device import netmgr as nm import utime import ujson from speech_utils import ( Speaker, AUDIO_HEADER ) import time from cht8305 import CHT8305 from driver import I2C import sh1106 # SH1106 ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/temp_humidity_speaker/haaseduk1/code/main.py
Python
apache-2.0
6,069
from micropython import const import utime import framebuf from driver import SPI from driver import GPIO # register definitions SET_SCAN_DIR = const(0xc0) LOW_COLUMN_ADDRESS = const(0x00) HIGH_COLUMN_ADDRESS = const(0x10) SET_PAGE_ADDRESS = const(0xB0) SET_CONTRAST = const(0x81) SET_ENTIRE_ON = const(0xa4) SET_NORM_I...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/temp_humidity_speaker/haaseduk1/code/sh1106.py
Python
apache-2.0
7,916
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : speech_utils.py @Description: 播报音箱库 @Date : 2022/02/11 14:34:45 @Author : guoliang.wgl @version : 1.0 ''' import time import math import http import json import time AUDIO_HEADER = 'fs:' from audio import Player, Snd on_...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/temp_humidity_speaker/haaseduk1/code/speech_utils.py
Python
apache-2.0
7,198
from driver import I2C class GXHT30(object): # init i2cDev def __init__(self,i2cObj): self.i2cObj=None if not isinstance(i2cObj,I2C): raise ValueError("parameter is not an I2C object") self.i2cObj=i2cObj # write cmd to register # commands:0x2c、0x06 def writ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/temperature_humidity/haas506/code/gxht30.py
Python
apache-2.0
1,286
import utime as time from driver import I2C import gxht30 #创建并打开一个I2C实例 i2cDev=I2C() i2cDev.open('gxht30') #创建一个温湿度实例 tem_hum_dev=gxht30.GXHT30(i2cDev) #获取温湿度数据 while True : cTemp,fTemp,humidity=tem_hum_dev.measure() print ("Temperature in Celsius : %.2f C" %cTemp) print ("Temperature in Fahrenheit : %.2f ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/temperature_humidity/haas506/code/main.py
Python
apache-2.0
511
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" class Airpressure: scr = None iconImg = None airpressureLable = None unityLabel = None tipLabel = None def __init__(self, screen): self.scr = screen self.createAirpressureItem(self.scr, RESOURCES_ROOT + "airpressure.p...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/airpressure.py
Python
apache-2.0
1,977
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" class Angle: scr = None iconImg = None angleLable = None unityLabel = None tipLabel = None def __init__(self, screen): self.scr = screen self.createAngleItem(self.scr, RESOURCES_ROOT + "angle.png", "Angle") def c...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/angle.py
Python
apache-2.0
1,872
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/" compass_ttf_alive = False def compass_back_click_callback(e, win): global compass_ttf_alive if (compass_ttf_alive): from smart_panel import load_smart_panel load_smart_panel() compass_ttf_alive = False def compass_back_press_callbac...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/compass.py
Python
apache-2.0
4,147
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" class Distance: scr = None iconImg = None distanceLable = None unityLabel = None tipLabel = None def __init__(self, screen): self.scr = screen self.createDistanceItem(self.scr, RESOURCES_ROOT + "distance.png", "DST") ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/distance.py
Python
apache-2.0
1,918
import lvgl as lv import utime RESOURCES_ROOT = "S:/data/pyamp/" def drawOver(e): global g_clickTime if (g_clickTime != 0): currentTime = utime.ticks_ms() print("create Environment page use: %dms" % int((currentTime - g_clickTime))) g_clickTime = 0 environment_alive = False def envi...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/environment.py
Python
apache-2.0
4,518
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" class Fm: scr = None iconImg = None fmLable = None unityLabel = None tipLabel = None def __init__(self, screen): self.scr = screen self.createFmItem(self.scr, RESOURCES_ROOT + "FM.png", "FM") def createFmItem(sel...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/fm.py
Python
apache-2.0
1,823
import lvgl as lv font_not_load_16 = True info_16 = None style_16 = None def set_text_size_16(parent): global font_not_load_16 global info_16 global style_16 if (font_not_load_16): info_16 = lv.ft_info_t() info_16.name ="/data/pyamp/font/AlibabaPuHuiTiM_16.ttf" info_16.weight =...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/font_Alibaba_PuHuiTi.py
Python
apache-2.0
2,463
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" class Gas: scr = None iconImg = None gasLable = None unityLabel = None tipLabel = None def __init__(self, screen): self.scr = screen self.createGasItem(self.scr, RESOURCES_ROOT + "gas.png", "Nature Gas") def crea...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/gas.py
Python
apache-2.0
1,848
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" class Hcho: scr = None iconImg = None hchoLable = None unityLabel = None tipLabel = None def __init__(self, screen): self.scr = screen self.createHchoItem(self.scr, RESOURCES_ROOT + "hcho.png", "PA") def createHc...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/hcho.py
Python
apache-2.0
1,857
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" class Heartrate: scr = None iconImg = None heartrateLable = None unityLabel = None tipLabel = None def __init__(self, screen): self.scr = screen self.createHeartrateItem(self.scr, RESOURCES_ROOT + "heartrate.png", "HR...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/heartrate.py
Python
apache-2.0
1,935
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" class Humidity: scr = None iconImg = None humidityLable = None unityLabel = None tipLabel = None def __init__(self, screen): self.scr = screen self.createHumidityItem(self.scr, RESOURCES_ROOT + "humidity.png", "TDS") ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/humidity.py
Python
apache-2.0
1,920
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/" environment_alive = False functionImage = [ RESOURCES_ROOT + "images/refrigeration.png", RESOURCES_ROOT + "images/heating.png", RESOURCES_ROOT + "images/dehumidification.png", RESOURCES_ROOT + "images/ventilation.png"] functionImage...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/hvac.py
Python
apache-2.0
8,415
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" class Lux: scr = None iconImg = None luxLable = None unityLabel = None tipLabel = None def __init__(self, screen): self.scr = screen self.createLuxItem(self.scr, RESOURCES_ROOT + "lux.png", "Brightness") def crea...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/lux.py
Python
apache-2.0
1,848
import display_driver import page_welcome page_welcome.load_page()
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/main.py
Python
apache-2.0
68
import lvgl as lv from audio import Player RESOURCES_ROOT = "S:/data/pyamp/" functionImage = [ RESOURCES_ROOT + "images/prev.png", RESOURCES_ROOT + "images/play.png", RESOURCES_ROOT + "images/next.png", RESOURCES_ROOT + "images/favorite.png"] currentMusic = 0 musicData = [ { ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/music.py
Python
apache-2.0
12,889
import lvgl as lv import uos import font_Alibaba_PuHuiTi RESOURCES_ROOT = "S:/data/pyamp/images/" def environment_back_click_callback(e, win): import page_settings page_settings.load_page() def environment_back_press_callback(e, back_image): back_image.set_zoom(280) def environment_back_release_callback...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/page_about.py
Python
apache-2.0
2,407
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" def environment_back_click_callback(e, win): import page_sensors2 page_sensors2.load_page() def environment_back_press_callback(e, back_image): back_image.set_zoom(280) def environment_back_release_callback(e, back_image): back_image.set_zoo...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/page_airpressure.py
Python
apache-2.0
1,417
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" def environment_back_click_callback(e, win): import page_sensors1 page_sensors1.load_page() def environment_back_press_callback(e, back_image): back_image.set_zoom(280) def environment_back_release_callback(e, back_image): back_image.set_zoo...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/page_angle.py
Python
apache-2.0
1,367
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" def back_click_callback(e, win): import page_basic page_basic.load_page() def load_page(): scr = lv.obj() scr.set_style_bg_color(lv.color_black(), 0) backImg=lv.img(scr) backImg.set_src(RESOURCES_ROOT + "back.png") backImg.set_st...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/page_arc.py
Python
apache-2.0
736
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" def back_click_callback(e, win): import page_basic page_basic.load_page() def load_page(): scr = lv.obj() scr.set_style_bg_color(lv.color_black(), 0) backImg=lv.img(scr) backImg.set_src(RESOURCES_ROOT + "back.png") backImg.set_st...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/page_bar.py
Python
apache-2.0
743
import lvgl as lv import font_Alibaba_PuHuiTi RESOURCES_ROOT = "S:/data/pyamp/images/" titles = ["line", "label", "image", "button", "bar", "arc", "btnmatrix", "checkbox", "dropdown", "roller", "slider", "switch", "table", "keyboard", "calendar", "led", "list", "meter...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/page_basic.py
Python
apache-2.0
6,697
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" def back_click_callback(e, win): import page_basic page_basic.load_page() def event_handler(evt): code = evt.get_code() obj = evt.get_target() if code == lv.EVENT.VALUE_CHANGED : id = obj.get_selected_btn() txt = obj.get...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/page_btnmatrix.py
Python
apache-2.0
1,401
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" def event_handler(evt): code = evt.get_code() if code == lv.EVENT.CLICKED: print("Clicked event seen") elif code == lv.EVENT.VALUE_CHANGED: print("Value changed seen") def back_click_callback(e, win): import page_basic ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/page_button.py
Python
apache-2.0
1,568
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" calendar = None def back_click_callback(e, win): import page_basic page_basic.load_page() def event_handler(evt): global calendar code = evt.get_code() if code == lv.EVENT.VALUE_CHANGED: source = evt.get_current_target() ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ui_collection/page_calendar.py
Python
apache-2.0
1,623