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
# coding=utf-8 # This is a sample Python script. from aliyunIoT import Device import ujson import network import utime as time from driver import GPIO from driver import UART t1 = 30 gas_threshold = 5.0 liq_mdcn_alarm = False gas_alarm = False version = 'v0.0.1' uart1 = UART('serail1') liq_level = GPIO() gpio = GPIO()...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/air_detector/haas506/code/main.py
Python
apache-2.0
9,630
from micropython import const import ustruct import i2c_bus import utime as time # import deviceCfg _BTN_IRQ = const(0x46) def map_value(value, input_min, input_max, aims_min, aims_max): value = min(max(input_min, value), input_max) value_deal = (value - input_min) * (aims_max - aims_min) / \ (input_...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/air_pressure_detection/esp32/code/axp192.py
Python
apache-2.0
7,601
import ubluetooth import json import gc import time import network from micropython import const _wlan = network.WLAN(network.STA_IF) _ble = ubluetooth.BLE() _bleNetConfigStatus = None _ble_adv_name = 'esp-node' _ble_tx = None _ble_rx = None _ble_msg = '' BLE_CONNECTED = const(0x00) BLE_DISCONNECTED = const(0x01) BL...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/air_pressure_detection/esp32/code/bleNetConfig.py
Python
apache-2.0
4,533
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for QMP6988 Author: HaaS Date: 2021/09/14 """ from driver import I2C from utime import sleep_ms from micropython import const import math BSP280_CHIP_ID = const(0x58) BMP280_REGISTER_DIG_T1 = const(0x88) BMP280_REGISTER_D...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/air_pressure_detection/esp32/code/bmp280.py
Python
apache-2.0
6,091
from machine import I2C from machine import Pin from micropython import const import struct #import unit #PORTA = (unit.PORTA) PAHUB0 = (0, None) PAHUB1 = (1, None) PAHUB2 = (2, None) PAHUB3 = (3, None) PAHUB4 = (4, None) PAHUB5 = (5, None) M_BUS = (21, 22) UINT8LE = const((0 << 6) | (1 << 4) | 1) UINT16LE = const(...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/air_pressure_detection/esp32/code/i2c_bus.py
Python
apache-2.0
6,200
import lvgl as lv import display_driver from bmp280 import * import ujson def set_value(indic, v): meter.set_indicator_value(indic, v) # 压力值转海拔高度 def convertPressure2Altitude(p, t): height = ((1-((p/101325)**(1/5.255)))*(t+273.15)/0.0065) return height # # A simple meter # meter = lv.meter(lv.scr_act...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/air_pressure_detection/esp32/code/main.py
Python
apache-2.0
5,326
print('enable OneMinuteOnCloud') import ubluetooth import uos as os import uerrno as errno import ujson as json import uzlib import upip_utarfile as tarfile import gc import time import machine import ussl import usocket import network _wlan = network.WLAN(network.STA_IF) _ble = ubluetooth.BLE() _ble_adv_name = 'esp-...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/air_pressure_detection/esp32/code/oneMinuteOnCloud.py
Python
apache-2.0
11,221
# -*- encoding: utf-8 -*- ''' @File : Player.py @Time : 2021/12/08 20:32:10 @Author : zeta.zz @License : (C)Copyright 2015-2021, M5STACK @Desc : Player I2S driver. ''' from machine import I2S from machine import Pin from axp192 import Axp192 from micropython import const import io import math impo...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/air_pressure_detection/esp32/code/pcm.py
Python
apache-2.0
5,864
from minicv import ML AI_ENGINE_ALIYUN = 1 AI_ENGINE_NATIVE = 2 class AI: def __init__(self, type=AI_ENGINE_NATIVE, accessKey=None, accessSecret=None, ossEndpoint=None, ossBucket=None): self.type = type self.ml = ML() if (self.type == AI_ENGINE_ALIYUN): self.ml.open(self.ml.ML...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/air_pressure_detection/esp32/code/uai.py
Python
apache-2.0
2,051
from driver import ADC,GPIO from time import sleep_us class GP2Y10(object): def __init__(self, adcObj,gpioObj): self.adcObj = None self.gpioObj = None if not isinstance(adcObj, ADC): raise ValueError("parameter is not an ADC object") if not isinstance(gpioObj, GPIO): ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/air_quality_monitor/esp32/code/gp2y10.py
Python
apache-2.0
773
# -*- coding: UTF-8 -*- from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import ujson # json字串解析库 import utime # 延时API所在组件 from driver import GPIO, ADC # driver类,用于控制微处理器的输入输出功能 import gp2y10 # dsm501a 空气...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/air_quality_monitor/esp32/code/main.py
Python
apache-2.0
3,959
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/alcohol_detector/haaseduk1/code/buzzer.py
Python
apache-2.0
757
# -*- encoding: utf-8 -*- from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import netmgr as nm # Wi-Fi 功能所在库 import utime # 延时API所在组件 import ujson # json字串解析库 from driver import GPIO # ADC类 from driver import SPI # ADC类 from driver import AD...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/alcohol_detector/haaseduk1/code/main.py
Python
apache-2.0
6,744
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for MQ3 Author: HaaS Date: 2022/03/15 """ from driver import ADC from utime import sleep_ms from micropython import const import math class MQ3(object): """ This class implements mq3 chip's defs. """ def _...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/alcohol_detector/haaseduk1/code/mq3.py
Python
apache-2.0
682
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/alcohol_detector/haaseduk1/code/sh1106.py
Python
apache-2.0
7,916
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Author : 杭漂 @version : 1.0 @Description: 通过跟HaaS Cloud控制台中“升级服务-应用升级”配合,实现设备端python应用的升级。 HaaS Cloud控制台网址:https://haas.iot.aliyun.com/welcome ''' import network # 网络库 import utime # 延时函数在utime库中 ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/app_upgrade/esp32/code/main.py
Python
apache-2.0
3,883
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Author : 杭漂 @version : 1.0 @Description: 通过跟HaaS Cloud控制台中“升级服务-应用升级”配合,实现设备端python应用的升级,该文件为针对本案例测试应用升级使用。 ''' import utime import ujson as json # manifest.json文件注意事项: # 1、该文件内不要添加任何注释; # 2、关键字appName对应的值,只能使用英文字母、数字,长度不能超...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/app_upgrade/esp32/code/testUpgrade/main.py
Python
apache-2.0
1,784
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : upgrade.py @Description: python应用升级能力实现 @Author : 杭漂 @version : 1.0 ''' from aliyunIoT import Device import ujson as json class Upgrade : def compareVersion(self,oldVersion,newVersion): old_list = oldVersion.split('.') ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/app_upgrade/esp32/code/upgrade.py
Python
apache-2.0
5,433
#!/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/auto_control_door/esp32/code/irdistance.py
Python
apache-2.0
597
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Author : zhangheng @version : 1.0 @Description: 通过红外检测是否有人靠近,有人靠近则启动舵机执行开门操作,没人,则进行关门操作 board.json - 硬件资源配置文件,详情请参考:https://haas.iot.aliyun.com/haasapi/index.html#/Python/docs/zh-CN/haas_extended_api/driver/d...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/auto_control_door/esp32/code/main.py
Python
apache-2.0
5,356
""" 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/auto_control_door/esp32/code/servo.py
Python
apache-2.0
664
# 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 _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/auto_control_door/haas506/code/main.py
Python
apache-2.0
7,379
from driver import GPIO import utime class HX711(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/auto_feeder/haaseduk1/code/hx711.py
Python
apache-2.0
1,060
# -*- encoding: utf-8 -*- from driver import GPIO from driver import TIMER # 定时器类 from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import ujson # json字串解析库 import utime # 延时函数在utime库中 import hx711 # 引入hx711传感器驱动库 import uln2003 # 引入ULN2003步进电机驱动库...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/auto_feeder/haaseduk1/code/main.py
Python
apache-2.0
7,663
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for ULN2003 Author: HaaS Date: 2022/03/15 """ from driver import GPIO from utime import sleep_ms from micropython import const import math class ULN2003(object): """ This class implements uln2003 chip's defs. "...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/auto_feeder/haaseduk1/code/uln2003.py
Python
apache-2.0
2,207
import utime # 延时函数在utime库中 from driver import GPIO,I2C import sht3x from ssd1306 import SSD1306_I2C hum_s = 0 oled = None sht3xDev = None humi_gpio = None def sht3x_init(): global sht3xDev i2cDev = I2C() i2cDev.open("sht3x") sht3xDev = sht3x.SHT3X(i2cDev) def humi_ctrl_init(): global humi_gpi...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/auto_humidifier/esp32/code/main.py
Python
apache-2.0
1,858
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for CHT8305 Author: HaaS Date: 2021/09/14 """ from micropython import const import utime from driver import I2C ''' # sht3x commands definations # read serial number: CMD_READ_SERIALNBR 0x3780 # ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/auto_humidifier/esp32/code/sht3x.py
Python
apache-2.0
3,599
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/auto_humidifier/esp32/code/ssd1306.py
Python
apache-2.0
3,565
######### from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import ujson ################## import utime # 延时函数在utime库中 from driver import GPIO import relay,soil_moisture relayDev = None humiDev = None relayStatus = None ######### # 物联网平台连接标志位 iot_connected = Fals...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/auto_watering/esp32/code/main.py
Python
apache-2.0
4,821
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 != 0) and (trigger != 1): raise ValueError("parameter trigger sh...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/auto_watering/esp32/code/relay.py
Python
apache-2.0
765
from driver import GPIO from driver import ADC class SoilMoisture(object): def __init__(self, DO, AO=None): self.DO = None self.AO = None if not isinstance(DO, GPIO): raise ValueError('parameter DO is not an GPIO object') if AO is not None and not isinstance(AO, ADC): ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/auto_watering/esp32/code/soil_moisture.py
Python
apache-2.0
715
#!/usr/bin/env python3 ''' @File : main.py @Description: 播报音箱 @Date : 2021年09月28日 @Author : ethan.lcz @version : 1.0.3 ''' from aliyunIoT import Device import network import http import ujson as json from speech_utils import ( Speaker, AUDIO_HEADER ) import time # 语音播放相关的音频资源文...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/broadcast_speaker/esp32/code/main.py
Python
apache-2.0
4,523
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : speech_utils.py @Description: file description @Date : 2021/12/01 14:34:45 @Author : guoliang.wgl @version : 1.0 ''' import time import math import http import json import time import uos AUDIO_HEADER = '' from pcm imp...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/broadcast_speaker/esp32/code/speech_utils.py
Python
apache-2.0
6,971
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @File : main.py @Description: 播报音箱案例(本案例符合HaaS Python 2.0 API标准,请务必按照“HaaS EDU K1快速开始”(https://haas.iot.aliyun.com/haasapi/#/Python/docs/zh-CN/startup/HaaS_EDU_K1_startup)文章的说明烧录固件 @Date : 2022年02月11日 @Author : ethan.lcz @version : v2...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/broadcast_speaker/haaseduk1/code/main.py
Python
apache-2.0
4,519
#!/usr/bin/env python # -*- 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_c...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/broadcast_speaker/haaseduk1/code/speech_utils.py
Python
apache-2.0
7,047
#!/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/bussiness_card_recognization/m5stack/code/cloudAI.py
Python
apache-2.0
10,770
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Description: 名片识别案例 @Author : jiangyu @version : 2.0 ''' import display # 显示库 import uai # AI识别库 import network # 网络库 import ucamera # 摄像头库 import utime # 延时函数在utime库中 import _thread # 线程...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/bussiness_card_recognization/m5stack/code/main.py
Python
apache-2.0
4,587
#!/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/classifying_rubbish/esp32/code/cloudAI.py
Python
apache-2.0
10,770
#!/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): r...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/classifying_rubbish/esp32/code/irdistance.py
Python
apache-2.0
591
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Description: 垃圾分类识别案例 @Author : 杭漂 @version : 1.0 ''' from aliyunIoT import Device import display # 显示库 import network # 网络库 import ucamera # 摄像头库 import utime # 延时函数在utime库中 import sntp # 网络时间同...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/classifying_rubbish/esp32/code/main.py
Python
apache-2.0
5,360
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- from aliyunIoT import Device from driver import I2C import utime # 延时函数在utime库中 from tcs34725 import * from driver import PWM import servo import utime # 延时函数在utime库中 import sntp # 网络时间同步库 import network # 网络库 import _thread # 线程库 import ujson as js...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/color_sorter/esp32/code/main.py
Python
apache-2.0
5,590
""" 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/color_sorter/esp32/code/servo.py
Python
apache-2.0
642
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited `HaaS Python tcs34725` ==================================================== A driver for tcs34725 Color Sensor * Author(s): HaaS Group Implementation Notes -------------------- **Hardware:** * HaaS Python tcs34725: https://haas.iot.aliyun.com/solution/det...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/color_sorter/esp32/code/tcs34725.py
Python
apache-2.0
14,451
######### from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import ujson ################## import ws2812 import utime from driver import GPIO ws2812Dev = None ws2812status = None ######### # 物联网平台连接标志位 iot_connected = False wlan = None # 三元组信息 productKey = "产品密钥" ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/colorful_clock/esp32/code/main.py
Python
apache-2.0
3,875
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for ws2812 Author: HaaS Date: 2022/05/10 """ from driver import GPIO from machine import Pin from neopixel import NeoPixel import utime br = 1.0 class WS2812(object): def __init__(self,gpioObj,led_pixel=24): se...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/colorful_clock/esp32/code/ws2812.py
Python
apache-2.0
4,876
# coding=utf-8 import network import ujson import utime as time import modem from aliyunIoT import Device import ota import kv #更改产品信息 ############################### productKey = "productKey" productSecret = "productSecret" ############################### global deviceName,g_connect_status,device_dyn_resigter_suc...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/counter/haas506/code/aliyun.py
Python
apache-2.0
7,662
# 每个字符是8x16(宽x高) 点阵, F2=[ 0x10,0xF0,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20, #*"h",0*# 0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x19,0x24,0x24,0x12,0x3F,0x20,0x00, #*"a",1*# 0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x19,0x24,0x24,0x12,0x3F,0x20,0x00, #*"a",2*# 0x0...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/counter/haas506/code/codetab.py
Python
apache-2.0
21,633
from ssd1306 import SSD1306_128_64 import utime as time from driver import TIMER from driver import GPIO import aliyun disp=SSD1306_128_64() time_d = [0x32, 0x35, 0x3a, 0x30, 0x30] # 倒计时 25:00 print('time_d',time_d) #model= 0 自动连续计时; model = 1 手动重启计时 model = 0 tomato_count = 0 count_data = {} #实例化key1 key1=GPIO(10,10...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/counter/haas506/code/main.py
Python
apache-2.0
3,157
import utime as time import codetab # Constants SSD1306_I2C_ADDRESS = 0x3C # 011110+SA0+RW - 0x3C or 0x3D SSD1306_SETCONTRAST = 0x81 SSD1306_DISPLAYALLON_RESUME = 0xA4 SSD1306_DISPLAYALLON = 0xA5 SSD1306_NORMALDISPLAY = 0xA6 SSD1306_INVERTDISPLAY = 0xA7 SSD1306_DISPLAYOFF = 0xAE SSD1306_DISPLAYON = 0xAF SSD1306_SE...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/counter/haas506/code/ssd1306.py
Python
apache-2.0
13,867
import lvgl as lv isStarted = False isAnimationComplete = False arc = [None, None, None, None] anim = [None, None, None, None] timeCount = [1, 3, 5, 10] currentSelect = 0 minuteLabel = None secondLabel = None millionLabel = None anim_timeline = None startLabel = None currentValue = 0 lvglInitialized = False def setLa...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/counter/m5stack/code/countDown.py
Python
apache-2.0
13,526
from countDown import CountDown stopWatch = CountDown() # max value is 10 stopWatch.createPage(1, 10, 8, 9)
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/counter/m5stack/code/main.py
Python
apache-2.0
110
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for BMP280 Author: HaaS Date: 2022/03/15 """ from driver import I2C from utime import sleep_ms from micropython import const import math BSP280_CHIP_ID = const(0x58) BMP280_REGISTER_DIG_T1 = const(0x88) BMP280_REGISTER_DIG...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/delivery_track/esp32/code/bmp280.py
Python
apache-2.0
5,883
from driver import UART from micropyGNSS import MicropyGNSS class GNSS(object): def __init__(self, uartObj): self.uartObj = None if not isinstance(uartObj, UART): raise ValueError("parameter is not a GPIO object") # 初始化定位模组串口 self.uartObj = uartObj self.gnss = ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/delivery_track/esp32/code/gnss.py
Python
apache-2.0
912
# -*- coding: UTF-8 -*- from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import ujson # json字串解析库 import utime # 延时API所在组件 from driver import I2C # I2C类,用于控制微处理器的输入输出功能 from driver import UART # UART类,用于控制微处理器的...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/delivery_track/esp32/code/main.py
Python
apache-2.0
5,222
""" # MicropyGPS - a GPS NMEA sentence parser for Micropython/Python 3.X # Copyright (c) 2017 Michael Calvin McCoy (calvin.mccoy@protonmail.com) # The MIT License (MIT) - see LICENSE file """ """ MIT License Copyright (c) 2017 Calvin McCoy Permission is hereby granted, free of charge, to any person obtaining a copy ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/delivery_track/esp32/code/micropyGNSS.py
Python
apache-2.0
30,723
#!/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/detect_object/esp32/code/cloudAI.py
Python
apache-2.0
10,770
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Description: 物体识别案例 @Author : 杭漂 @version : 1.0 ''' from aliyunIoT import Device import display # 显示库 import network # 网络库 import ucamera # 摄像头库 import utime # 延时函数在utime库中 import sntp # 网络时间同步库...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/detect_object/esp32/code/main.py
Python
apache-2.0
5,123
import lvgl as lv RESOURCES_ROOT = "S:/data/pyamp/images/" class Airpressure: scr = None iconImg = None airpressureLable = None unityLabel = None tipLabel = None date = None def __init__(self, screen): self.scr = screen self.createAirpressureItem(self.scr, RESOURCES_ROOT +...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ele_barometer/eduk1c/code/airpressure.py
Python
apache-2.0
2,401
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- import utime import page_airpressure if __name__ == '__main__': # 初始化气压计 page_airpressure.qmp6988_init() import display_driver # 显示气压值 page_airpressure.load_page() while True: utime.sleep(2)
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ele_barometer/eduk1c/code/main.py
Python
apache-2.0
297
import lvgl as lv from driver import I2C from qmp6988 import QMP6988 from airpressure import Airpressure import _thread import utime RESOURCES_ROOT = "S:/data/pyamp/images/" # 设备实例 i2cDev = None qmp6988Dev = None # 全局变量 pressure_value = 0 def qmp6988_init(): global i2cDev, qmp6988Dev i2cDev = I2C() i2cD...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ele_barometer/eduk1c/code/page_airpressure.py
Python
apache-2.0
1,569
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for QMP6988 Author: HaaS Date: 2021/09/14 """ from driver import I2C from utime import sleep_ms from micropython import const import math QMP6988_CALC_INT = 1 QMP6988_CHIP_ID = const(0x5C) QMP6988_CHIP_ID_REG ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/ele_barometer/eduk1c/code/qmp6988.py
Python
apache-2.0
16,991
"""2.9 inch E-paper display black/red version 2.""" from math import cos, sin, pi, radians from micropython import const from framebuf import FrameBuffer, GS8, MONO_HLSB, MONO_HMSB from utime import sleep_ms class Display(object): """Serial interface for 2.9 inch E-paper display. Note: All coordinates are z...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/electronic_price_tag/esp32/code/esp2in9bv2.py
Python
apache-2.0
30,483
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Author : zeta.zz @version : 1.0 @Description: price_tag - 电子价签 board.json - 硬件资源配置文件 ''' from showPriceData import ShowData from machine import Pin from driver import GPIO import network import time import ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/electronic_price_tag/esp32/code/main.py
Python
apache-2.0
8,356
"""ESP2in9b v.2.""" from time import sleep from machine import SPI, Pin # from driver import SPI from xglcd_font import XglcdFont from esp2in9bv2 import Display # ############################################################################# # ############### HaaS Python price tag ##########################...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/electronic_price_tag/esp32/code/showPriceData.py
Python
apache-2.0
4,085
# -*- coding: utf-8 -*- """Utility to convert images to MONO_HMSB format.""" from PIL import Image from os import path import sys def error(msg): """Display error and exit.""" print (msg) sys.exit(-1) def set_bit(value, index, high=True): """Set the index:th bit of value. Args: value (in...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/electronic_price_tag/esp32/code/utils/img2monoHMSB.py
Python
apache-2.0
1,608
from os import path import sys import binascii if __name__ == '__main__': args = sys.argv if len(args) != 2: error('Please specify input file: ./img2monohmsb.py test.png') in_path = args[1] if not path.exists(in_path): error('File Not Found: ' + in_path) array_size = 85*85 wit...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/electronic_price_tag/esp32/code/utils/readMonoBuf.py
Python
apache-2.0
454
# -*- coding: utf-8 -*- """Utility to convert images to MONO_HMSB format.""" from PIL import Image from os import path import sys import binascii def error(msg): """Display error and exit.""" print (msg) sys.exit(-1) def set_bit(value, index, high=True): """Set the index:th bit of value. Args:...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/electronic_price_tag/esp32/code/utils/showMonoBuf.py
Python
apache-2.0
1,793
"""XGLCD Font Utility.""" from math import floor from framebuf import FrameBuffer, MONO_VLSB class XglcdFont(object): """Font data in X-GLCD format. Attributes: letters: A bytearray of letters (columns consist of bytes) width: Maximum pixel width of font height: Pixel height of font ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/electronic_price_tag/esp32/code/xglcd_font.py
Python
apache-2.0
7,222
#!/usr/bin/env python # -*- encoding: utf-8 -*- import utime import ujson from aliyunIoT import Device import modbus as mb import yuanda_htb485 import zzio606 import network from driver import GPIO ############# wifi连网代码 ############ def connect_wifi(ssid, pwd): wlan = network.WLAN(network.STA_IF) wlan.active...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/environment_monitor_485/haas506/code/main.py
Python
apache-2.0
3,812
import utime import modbus as mb import yuanda_htb485 import zzio606 def test_htb485(): ret = mb.init('modbus_485_4800') if ret < 0: raise ValueError("init modbus failed.") htb485Obj = yuanda_htb485.HTB485(mb, 1) humidity = htb485Obj.getHumidity() temperature = htb485Obj.getTemperatur...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/environment_monitor_485/haas506/code/test.py
Python
apache-2.0
1,506
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/environment_monitor_485/haas506/code/yuanda_htb485.py
Python
apache-2.0
1,739
class ZZIO606(object): def __init__(self, mbObj, devAddr): self.mbObj = mbObj self.devAddr = devAddr def openChannel(self, chid): if self.mbObj is None: raise ValueError("invalid modbus object.") ret = self.mbObj.writeCoil(self.devAddr, chid, 0xff00, 200) ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/environment_monitor_485/haas506/code/zzio606.py
Python
apache-2.0
880
from time import sleep_us,ticks_us from driver import GPIO class HCSR04(): def __init__(self,trigObj,echoObj): self.trig = None self.echo = None if not isinstance(trigObj, GPIO): raise ValueError("parameter is not a GPIO object") if not isinstance(echoObj, GPIO): ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/epidemic_prevention_control/esp32/code/hcsr04.py
Python
apache-2.0
1,047
# -*- coding: UTF-8 -*- from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import ujson # json字串解析库 import utime # 延时API所在组件 from driver import GPIO # GPIO类,用于控制微处理器的输入输出功能 import hcsr04 # hcsr04超声波传感器类...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/epidemic_prevention_control/esp32/code/main.py
Python
apache-2.0
4,320
# coding=utf-8 from driver import GPIO import network import ujson import utime as time import modem from aliyunIoT import Device import kv #当iot设备连接到物联网平台的时候触发'connect' 事件 def on_connect(data): global module_name,default_ver,productKey,deviceName,deviceSecret,on_trigger,on_download,on_verify,on_upgrade print...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/epidemic_prevention_control/haas506/code/main.py
Python
apache-2.0
7,004
from time import sleep_us,ticks_us from driver import GPIO class HCSR04(): def __init__(self,trigObj,echoObj): self.trig = None self.echo = None if not isinstance(trigObj, GPIO): raise ValueError("parameter is not a GPIO object") if not isinstance(echoObj, GPIO): ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/epidemic_prevention_control/stm32/code/hcsr04.py
Python
apache-2.0
1,047
# -*- coding: UTF-8 -*- from ulinksdk.aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import ujson # json字串解析库 import utime # 延时API所在组件 from driver import GPIO # GPIO类,用于控制微处理器的输入输出功能 import hcsr04 ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/epidemic_prevention_control/stm32/code/main.py
Python
apache-2.0
4,445
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' @File : main.py @Description: 人脸识别案例 @Author : luokui @version : 1.0 ''' from aliyunIoT import Device import display # 显示库 import uai # AI识别库 import network # 网络库 import ucamera # 摄像头库 import utime # 延时函数在utime...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/face_recognization/esp32/code/main.py
Python
apache-2.0
7,235
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 # 物联网平台连接标志位 io...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/fall_detection/esp32/code/main.py
Python
apache-2.0
4,299
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/fall_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/fall_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/fall_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/fall_detection/esp32/code/mpu6886/mpu6886.py
Python
apache-2.0
7,149
from driver import ADC class Fire(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: rais...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/fire_detector/esp32/code/fire.py
Python
apache-2.0
428
# -*- encoding: utf-8 -*- from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import utime # 延时API所在组件 import ujson # json字串解析库 from driver import GPIO # LED需使用GPIO进行控制 from driver import ADC # ADC类,通过微处理器的ADC模块...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/fire_detector/esp32/code/main.py
Python
apache-2.0
5,548
from driver import ADC class Fire(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 ValueEr...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/fire_detector/haas200/code/fire.py
Python
apache-2.0
409
# -*- encoding: utf-8 -*- from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import netmgr as nm # Wi-Fi 功能所在库 import utime # 延时API所在组件 import ujson # json字串解析库 from driver import GPIO # LED需使用GPIO进行控制 from driver import ADC # ADC类,通过微处理器的ADC模...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/fire_detector/haas200/code/main.py
Python
apache-2.0
5,578
# 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 #当iot设备连接到物联网平台的时候触发'connect' 事件 def on_connect(data): global module_name,default_ver,productKey,deviceName,deviceSecret,on_trigger,on_download,on_ve...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/fire_detector/haas506/code/main.py
Python
apache-2.0
5,463
from driver import ADC class Fire(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 ValueE...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/fire_detector/haaseduk1/code/fire.py
Python
apache-2.0
411
# -*- encoding: utf-8 -*- from aliyunIoT import Device # aliyunIoT组件是连接阿里云物联网平台的组件 import utime # 延时API所在组件 import ujson # json字串解析库 import fire from driver import GPIO # HaaS EDU K1 LED使用GPIO进行控制 from driver import ADC # ADC类,通过微处理器的ADC模块读取ADC通道输入电压 import netmgr as nm ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/fire_detector/haaseduk1/code/main.py
Python
apache-2.0
5,330
from driver import ADC class Fire(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 ValueEr...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/fire_detector/stm32/code/fire.py
Python
apache-2.0
409
# -*- encoding: utf-8 -*- from ulinksdk.aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network import utime # 延时API所在组件 import ujson # json字串解析库 from driver import GPIO # LED需使用GPIO进行控制 from driver import ADC # ADC类,通过微处理器的ADC模块读取ADC通道输入电压 im...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/fire_detector/stm32/code/mian.py
Python
apache-2.0
5,739
# -*- encoding: utf-8 -*- ''' @File : main.py @Description: 温湿度上云 @Author : ethan.lcz @version : 1.0 ''' from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import utime # 延时API所在组件 from driver import I2C # I2C总线...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/floriculture/ESP-C3-32S-Kit/code/main.py
Python
apache-2.0
7,134
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for CHT8305 Author: HaaS Date: 2021/09/14 """ from micropython import const import utime from driver import I2C ''' # sht3x commands definations # read serial number: CMD_READ_SERIALNBR 0x3780 # ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/floriculture/ESP-C3-32S-Kit/code/sht3x.py
Python
apache-2.0
4,279
# -*- encoding: utf-8 -*- ''' @File : main.py @Description: 温湿度上云 @Author : ethan.lcz @version : 1.0 ''' from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import utime # 延时API所在组件 from driver import I2C # I2C总线...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/floriculture/ESP-S3-12K-Kit/code/main.py
Python
apache-2.0
7,134
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for CHT8305 Author: HaaS Date: 2021/09/14 """ from micropython import const import utime from driver import I2C ''' # sht3x commands definations # read serial number: CMD_READ_SERIALNBR 0x3780 # ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/floriculture/ESP-S3-12K-Kit/code/sht3x.py
Python
apache-2.0
4,279
# -*- encoding: utf-8 -*- ''' @File : main.py @Description: 温湿度上云 @Author : ethan.lcz @version : 1.0 ''' from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import network # Wi-Fi功能所在库 import utime # 延时API所在组件 from driver import I2C # I2C总线...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/floriculture/esp32/code/main.py
Python
apache-2.0
7,134
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for CHT8305 Author: HaaS Date: 2021/09/14 """ from micropython import const import utime from driver import I2C ''' # sht3x commands definations # read serial number: CMD_READ_SERIALNBR 0x3780 # ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/floriculture/esp32/code/sht3x.py
Python
apache-2.0
4,279
# -*- encoding: utf-8 -*- ''' @File : main.py @Description: 温湿度上云 @Author : victor.wang @version : 1.0 ''' from aliyunIoT import Device # iot组件是连接阿里云物联网平台的组件 import netmgr as nm # Wi-Fi 功能所在库 import utime # 延时API所在组件 from driver import I2C # I2...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/floriculture/haas200/code/main.py
Python
apache-2.0
6,860
""" Copyright (C) 2015-2021 Alibaba Group Holding Limited MicroPython's driver for CHT8305 Author: HaaS Date: 2021/09/14 """ from micropython import const import utime from driver import I2C ''' # sht3x commands definations # read serial number: CMD_READ_SERIALNBR 0x3780 # ...
YifuLiu/AliOS-Things
haas_lib_bundles/python/docs/examples/floriculture/haas200/code/sht3x.py
Python
apache-2.0
3,599