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 |
|---|---|---|---|---|---|
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
`HaaS Python as608`
====================================================
A driver for the AS608 finger print module
* Author(s): HaaS Group
Implementation Notes
--------------------
**Hardware:**
* HaaS Python as608
https://haas.iot.aliyun.com/solution/de... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/as608/as608.py | Python | apache-2.0 | 14,632 |
"""
Copyright (C) 2015-2022 Alibaba Group Holding Limited
MicroPython's drive for BH1750
Author: HaaS
Date: 2022/03/22
"""
import utime
from driver import I2C
class BH1750(object):
MT_HIGH_MAX = 180 # ms
MT_LOW_MAX = 24 # ms
MT_HIGH_TYP = 120 # ms
MT_LOW_TYP = 16 # ms
# Continuousl... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/bh1750/bh1750.py | Python | apache-2.0 | 3,613 |
"""
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/libraries/bmp280/bmp280.py | Python | apache-2.0 | 5,883 |
"""
HaaSPython PWM driver for buzzer
"""
from driver import PWM
class BUZZER(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 setOptionDuty(self,data):
... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/buzzer/buzzer.py | Python | apache-2.0 | 570 |
from driver import I2C
CSS811_STATUS = 0x00
CSS811_MEAS_MODE = 0x01
CSS811_ALG_RESULT_DATA = 0x02
CSS811_RAW_DATA = 0x03
CSS811_ENV_DATA = 0x05
CSS811_NTC = 0x06
CSS811_THRESHOLDS = 0x10
CSS811_BASELINE = 0x11
CSS811_HW_ID = 0x20
CSS811_HW_VERSION = 0x21
CSS811_FW_BOOT_VERSION = 0x23
CSS811_FW_APP_VERSION = 0x24
CSS81... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/ccs811/ccs811.py | Python | apache-2.0 | 4,661 |
"""
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/libraries/cht8305/cht8305.py | Python | apache-2.0 | 4,277 |
from driver import GPIO
class DCMOTOR(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 ctrl(self,value):
if self.gpioObj is None:
ra... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/dcmotor/dcmotor.py | Python | apache-2.0 | 392 |
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/libraries/dds5188/dds5188.py | Python | apache-2.0 | 1,534 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
MicroPython's driver for CHT8305
Author: HaaS
Date: 2022/05/11
"""
import lvgl as lv
import lvgl_display
print("display_driver init")
if not lv.is_initialized():
#print("lv.init")
lv.init()
if not lvgl_display.is_initialized():
#pr... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/display_driver/display_driver.py | Python | apache-2.0 | 369 |
class DRV8833():
def __init__(self, Int1x, Int2x,freq):
self.int1x = Int1x
self.int2x = Int2x
if freq == None:
self.mode = 0
else:
self.mode = 1
self.freq = freq
def run(self, status, rate):
if self.mode == 0 :
if status =... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/drv8833/drv8833.py | Python | apache-2.0 | 708 |
from driver import GPIO
DS1302_REG_SECOND = (0x80)
DS1302_REG_MINUTE = (0x82)
DS1302_REG_HOUR = (0x84)
DS1302_REG_DAY = (0x86)
DS1302_REG_MONTH = (0x88)
DS1302_REG_WEEKDAY= (0x8A)
DS1302_REG_YEAR = (0x8C)
DS1302_REG_WP = (0x8E)
DS1302_REG_CTRL = (0x90)
DS1302_REG_RAM = (0xC0)
class DS1302:
def __... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/ds1302/ds1302.py | Python | apache-2.0 | 3,977 |
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/libraries/ds18b20/ds18b20.py | Python | apache-2.0 | 3,959 |
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/libraries/ele_scale/ele_scale.py | Python | apache-2.0 | 2,032 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
HaaS Python driver for fheartbeat
Author: HaaS
Date: 2022/05/15
"""
from driver import ADC
class FHEARTBEAT(object):
"""
This class implements FHEARTBEAT chip's defs.
"""
def __init__(self, adcObj):
self._adcObj = None
... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/fheartbeat/fheartbeat.py | Python | apache-2.0 | 631 |
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/libraries/fire/fire.py | Python | apache-2.0 | 409 |
from driver import SPI, GPIO
# register address map for each GC7219 (opCodes)
OP_NOOP = 0
OP_DIGIT0 = 1 # == one row (byte)
OP_DIGIT1 = 2
OP_DIGIT2 = 3
OP_DIGIT3 = 4
OP_DIGIT4 = 5
OP_DIGIT5 = 6
OP_DIGIT6 = 7
OP_DIGIT7 = 8
OP_DECODEMODE = 9 # no decode == 0 (useful only for 7-segment display)
OP_INTENSITY = 10 # 0 - ... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/gc7219/gc7219.py | Python | apache-2.0 | 6,051 |
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/libraries/gnss/gnss.py | Python | apache-2.0 | 875 |
"""
# 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/libraries/gnss/micropyGNSS.py | Python | apache-2.0 | 30,723 |
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/libraries/gp2y10/gp2y10.py | Python | apache-2.0 | 773 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
"""
from driver import I2C
import kv
class HAASEDUK1(object):
def __init__(self):
self.i2cDev = None
# 获取版本号
# 返回值为1,代表k1c
# 返回值为0,代表k1
def getHWID(self):
hwId = -1
result = kv.geti("HAASEDU_NAME")
if (result... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/haaseduk1/code/haaseduk1.py | Python | apache-2.0 | 1,984 |
# -*- encoding: utf-8 -*-
'''
@File : main.py
@Description: 读取HaaS EDU K1硬件和固件版本号,并显示在屏幕上
@Author : ethan.lcz
@version : 1.0
'''
import uos
import utime # 延时API所在组件
from haaseduk1 import HAASEDUK1 # 引入haaseduk1库,目标用于区分K1版本
from driver import SPI
from driver import ... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/haaseduk1/code/main.py | Python | apache-2.0 | 2,222 |
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/libraries/haaseduk1/code/sh1106.py | Python | apache-2.0 | 7,941 |
from driver import ADC
class HCHO(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 getPPM(self):
if self.adcObj is None:
raise ValueError... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/hcho/hcho.py | Python | apache-2.0 | 876 |
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/libraries/hcsr04/hcsr04.py | Python | apache-2.0 | 1,046 |
# -*- encoding: utf-8 -*-
'''
@File : heartbeat.py
@Description: 心率传感器驱动
@Author : victor.wang
@version : 1.0
'''
from driver import ADC # ADC类,通过微处理器的ADC模块读取ADC通道输入电压
from driver import TIMER # 定时器类,用于定时调用心率传感器
from driver import GPIO
class HE... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/heartrate/heartbeat.py | Python | apache-2.0 | 5,894 |
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/libraries/htb485/yuanda_htb485.py | Python | apache-2.0 | 1,739 |
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/libraries/hx710/hx710.py | Python | apache-2.0 | 1,060 |
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/libraries/ina219/ina219.py | Python | apache-2.0 | 10,625 |
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/libraries/ir/ir.py | Python | apache-2.0 | 410 |
from driver import GPIO
class IRDISTANCE(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 objectDetection(self):
if self.gpioObj is None:
... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/irdistance/irdistance.py | Python | apache-2.0 | 424 |
import os
import utime
import micropython
import ujson
from driver import GPIO
micropython.alloc_emergency_exception_buf(100)
class IRREMOTE(object):
CODE = {207: "1", 231: "2", 133: "3", 239: "4", 199: "5", 165: "6", 189: "7", 181: "8", 173: "9",
151: "0", 221: "PREV", 253: "NEXT", 31: "VOL-", 87: "VO... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/irremote/irremote.py | Python | apache-2.0 | 3,177 |
class L298DC():
def __init__(self, Int1x, Int2x, en=None, freq=50, name="DCMotorX"):
self.name = name
self.int1x = Int1x
self.int2x = Int2x
self.en = en
self.freq = freq
def run(self, rate=50):
if(self.en != None):
self.en.setOption({self.freq, rate ... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/l298/l298.py | Python | apache-2.0 | 1,181 |
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/libraries/lcd1602/lcd1602.py | Python | apache-2.0 | 7,937 |
from driver import GPIO
class MagnetronSensor():
def __init__(self, gpioObj):
self.gpioObj = None
if not isinstance(gpioObj, GPIO):
raise ValueError("parameter is not a GPIO object")
self.gpioObj = gpioObj
def isMagnetic(self):
if self.gpioObj is None:
... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/magnetron_sensor/magnetronSensor.py | Python | apache-2.0 | 419 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
MicroPython's driver for MAX7219
Author: HaaS
Date: 2022/03/15
"""
from driver import GPIO
from utime import sleep_ms
from micropython import const
import math
digit_array_0 = bytearray([0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c])
digit_ar... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/max7219/max7219.py | Python | apache-2.0 | 5,646 |
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/libraries/mfrc522/mfrc522.py | Python | apache-2.0 | 14,352 |
"""
HaaSPython I2C driver for mlx90614 IR Temperature
"""
import ustruct
from driver import I2C
class SensorBase:
def read16(self, register):
data=bytearray(2)
self._i2cDev.memRead(data,register,8)
return ustruct.unpack('<H', data)[0]
def read_temp(self, register):
temp = sel... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/mlx90614/mlx90614.py | Python | apache-2.0 | 1,572 |
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/libraries/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/libraries/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
import _thread # 线程库
class Motion:
def __init__(self, action, getData, onActionDetected):
self.action = action
if (action == "fall"):
self.detectAct... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/motion/motion.py | Python | apache-2.0 | 1,974 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
HaaS Python driver for motorspeed
Author: HaaS
Date: 2022/05/15
"""
from driver import GPIO
class MOTORSPEED(object):
def __init__(self, gpioObj, func=None):
self.gpioObj = None
if not isinstance(gpioObj, GPIO):
... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/motorspeed/motorspeed.py | Python | apache-2.0 | 637 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
HaaS Python's driver for MPU6050
Author: HaaS Python Team
Date: 2022/02/02
"""
from micropython import const
from driver import I2C
from utime import sleep_ms
import math
MPU_SELF_TESTX_REG = const(0X0D) #自检寄存器X
MPU_SELF_TESTY_REG = const(0X0... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/mpu6050/mpu6050.py | Python | apache-2.0 | 10,409 |
"""
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/libraries/mpu6886/mpu6886.py | Python | apache-2.0 | 7,145 |
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/libraries/mq136/mq136.py | Python | apache-2.0 | 412 |
from driver import ADC
class MQ2(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 getMq2Value(self):
if self.adcObj is None:
raise ValueE... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/mq2/mq2.py | Python | apache-2.0 | 411 |
"""
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/libraries/mq3/mq3.py | Python | apache-2.0 | 682 |
import neopixel
import framebuf
class NeoPixelMatrix:
def __init__(self, pin, width, hight, linedir):
self.width = width
self.height = hight
self.linedir = linedir
self.buffer = bytearray(self.width * self.height * 3)
fb = framebuf.FrameBuffer(
self.buffer, self... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/neo_pixel_matrix/neoPixelMatrix.py | Python | apache-2.0 | 1,593 |
'''
Copyright (C) 2015-2022 Alibaba Group Holding Limited
MicroPython's driver for Noise
Author: HaaS
Date: 2022/03/23
'''
import utime # 延时函数在utime库中
from driver import ADC
class Noise(object):
def __init__(self, adcObj, avgSz=100):
self.adcObj = None
if not isinstance(adcObj, AD... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/noise/noise.py | Python | apache-2.0 | 1,744 |
#-*- coding: utf-8 -*-
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
MicroPython's driver for CHT8305
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.ap... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/paj7620/paj7620.py | Python | apache-2.0 | 12,177 |
import time
from ustruct import pack
from math import pi
from driver import I2C
import math
class PCA9685:
def __init__(self, i2cDev):
self._i2c = None
if not isinstance(i2cDev, I2C):
raise ValueError("parameter is not an I2C object")
self._i2c = i2cDev
self.freq = 50 #... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/pca9685/pca9685.py | Python | apache-2.0 | 1,217 |
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:
r... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/photoresistor/photoresistor.py | Python | apache-2.0 | 422 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
MicroPython's driver for QMC5883l
Author: HaaS
Date: 2021/09/09
"""
from driver import I2C
from utime import sleep_ms
import math
x_max = 0
x_min = 0
z_min = 0
y_max = 0
y_min = 0
z_max = 0
addr = 0
mode = 0
rate = 0
g_range = 0
oversampling = ... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/qmc5883/qmc5883.py | Python | apache-2.0 | 8,659 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
MicroPython's driver for QMC6310 magnetometer
Author: HaaS
Date: 2021/09/09
"""
from driver import I2C
from micropython import const
import utime
import math
# vendor chip id
QMC6308_IIC_ADDR = const(0x2C)
QMC6310U_IIC_ADDR = const(0x1c)
QMC631... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/qmc6310/qmc6310.py | Python | apache-2.0 | 8,796 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
MicroPython's driver for QMI8610
Author: HaaS
Date: 2021/09/14
"""
from micropython import const
from driver import I2C
from utime import sleep_ms
import math
M_PI = (3.14159265358979323846)
ONE_G = (9.80665)
FISIMU_STATUS1_CMD_DONE = cons... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/qmi8610/qmi8610.py | Python | apache-2.0 | 25,897 |
"""
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/libraries/qmp6988/qmp6988.py | Python | apache-2.0 | 16,991 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
MicroPython's drive for Raindrops
Author: HaaS
Date: 2022/03/29
"""
from driver import GPIO
from driver import ADC
class Raindrops(object):
def __init__(self, DO, AO=None):
self.DO = None
self.AO = None
if not isinsta... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/raindrops/raindrops.py | Python | apache-2.0 | 1,034 |
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/libraries/relay/relay.py | Python | apache-2.0 | 765 |
from driver import PWM
class RgbLed():
def __init__(self, pwmRObj, pwmGObj, pwmBObj):
if not isinstance(pwmRObj, PWM):
raise ValueError("parameter pwmRObj is not an PWM object")
if not isinstance(pwmGObj, PWM):
raise ValueError("parameter pwmGObj is not an PWM object")
... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/rgb_led/rgbLed.py | Python | apache-2.0 | 1,554 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
`HaaS Python ads1x15`
====================================================
A driver for ads1x15
* Author(s): HaaS Group
Implementation Notes
--------------------
**Hardware:**
* HaaS Python ads1x15
https://haas.iot.aliyun.com/solution/detail/hardware
**S... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/rockerkey/ads1x15.py | Python | apache-2.0 | 6,561 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
HaaS Python driver for rockerkey
Author: HaaS
Date: 2022/05/06
"""
import ads1x15 # ADS1X15 ADC传感器驱动库
from driver import I2C,GPIO
class ROCKERKEY(object):
def __init__(self, i2cObj,gpioObj,MaxVoltage=5500,XAxis=0,YAxi... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/rockerkey/rockerkey.py | Python | apache-2.0 | 1,617 |
"""
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/libraries/servo/servo.py | Python | apache-2.0 | 642 |
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/libraries/sh1106/sh1106.py | Python | apache-2.0 | 7,916 |
"""
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/libraries/sht3x/sht3x.py | Python | apache-2.0 | 4,279 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
MicroPython's drive for SI7006
Author: HaaS
Date: 2021/09/09
"""
from driver import I2C
from utime import sleep_ms
# The commands provided by SI7006
Si7006_MEAS_REL_HUMIDITY_MASTER_MODE = 0xE5
Si7006_MEAS_REL_HUMIDITY_NO_MASTER_MODE = 0xF5
... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/si7006/si7006.py | Python | apache-2.0 | 5,698 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
MicroPython's driver for SN74HC595
Author: HaaS
Date: 2022/03/15
"""
from driver import GPIO
from utime import sleep_ms
from micropython import const
import math
class SN74HC595(object):
"""
This class implements sn74hc595 chip's defs.... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/sn74hc595/sn74hc595.py | Python | apache-2.0 | 2,055 |
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/libraries/soil_moisture/soil_moisture.py | Python | apache-2.0 | 715 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
MicroPython's drive for SPL06
Author: HaaS
Date: 2021/09/09
"""
from driver import I2C
from utime import sleep_ms
import math
EEPROM_CHIP_ADDRESS = 0x77
spl06_dict = {'Ctemp': 0.0, 'Ftemp': 0.0,'pressure': 0.0, 'altitude': 0.0}
class SPL06(obj... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/spl06/spl06.py | Python | apache-2.0 | 12,801 |
"""
HaaSPython SSD1306 OLED driver, I2C interfaces
"""
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)
S... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/ssd1306/ssd1306.py | Python | apache-2.0 | 3,618 |
"""
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/libraries/tcs34725/tcs34725.py | Python | apache-2.0 | 14,385 |
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 setTemperature(self, T):
sel... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/tds/tds.py | Python | apache-2.0 | 1,234 |
import time
from driver import I2C
class TEA5767:
FREQ_RANGE = (87.5, 108.0)
ADC = (0, 5, 7, 10)
ADC_BIT = (0, 1, 2, 3)
def __init__(self, i2cDev):
self._i2c = None
if not isinstance(i2cDev, I2C):
raise ValueError("parameter is not an I2C object")
self._i2c = i2cDev
... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/tea5767/tea5767.py | Python | apache-2.0 | 2,518 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
HaaS Python driver for tracker
Author: HaaS
Date: 2022/05/13
"""
from driver import GPIO
class TRACKER(object):
def __init__(self, gpioObj):
self.gpioObj = None
if not isinstance(gpioObj, GPIO):
raise ValueError... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/tracker/tracker.py | Python | apache-2.0 | 710 |
from driver import GPIO
class TTP224:
def __init__(self,gpio1Dev=None,gpio2Dev=None,gpio3Dev=None,gpio4Dev=None):
self._gpio1Obj = None
self._gpio2Obj = None
self._gpio3Obj = None
self._gpio4Obj = None
self._cntObj = 0
if isinstance(gpio1Dev, GPIO):
self.... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/ttp224/ttp224.py | Python | apache-2.0 | 1,477 |
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/libraries/ui_lite/countDown/countDown.py | Python | apache-2.0 | 13,526 |
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/"
lvglInitialized = False
class HumiturePanel:
container = None
scr = None
humidityValue = None
humidityLable = None
def __init__(self):
self.createPage()
def createPage(self):
global lvglInitialized
if lvglInitializ... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/ui_lite/humiturePanel/humiturePanel.py | Python | apache-2.0 | 4,853 |
import lvgl as lv
from axp192 import *
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"]
... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/ui_lite/music/music.py | Python | apache-2.0 | 12,399 |
"""
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/libraries/uln2003/uln2003.py | Python | apache-2.0 | 2,207 |
from driver import UART
import utime
class URM37(object):
def __init__(self, uart_obj):
self.uart_obj = None
if not isinstance(uart_obj, UART):
raise ValueError("parameter is not a UART object")
self.uart_obj = uart_obj
def getRange(self):
tx_buf = bytearray([0x22,... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/urm37/urm37.py | Python | apache-2.0 | 1,157 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
`HaaS Python UV sensor`
====================================================
A driver for uv sensor
* Author(s): HaaS Group
Implementation Notes
--------------------
**Hardware:**
* HaaS Python uv sensor:
https://haas.iot.aliyun.com/solution/detail/hardwa... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/uv/uv.py | Python | apache-2.0 | 2,047 |
from driver import GPIO
class VibrationSensor():
def __init__(self, gpioObj):
self.gpioObj = None
if not isinstance(gpioObj, GPIO):
raise ValueError("parameter is not a GPIO object")
self.gpioObj = gpioObj
def isVibrating(self):
if self.gpioObj is None:
... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/vibration_sensor/vibrationSensor.py | Python | apache-2.0 | 420 |
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/libraries/waterlevel/water4level.py | Python | apache-2.0 | 704 |
"""
Copyright (C) 2015-2021 Alibaba Group Holding Limited
HaaS Python 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):
self... | YifuLiu/AliOS-Things | haas_lib_bundles/python/libraries/ws2812/ws2812.py | Python | apache-2.0 | 4,874 |
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/libraries/zzio606/zzio606.py | Python | apache-2.0 | 880 |
#include <k_config.h>
;******************************************************************************
; EXTERN PARAMETERS
;******************************************************************************
EXTERN g_active_task
EXTERN g_preferred_ready_task
EXTERN krhino_stack_ovf_che... | YifuLiu/AliOS-Things | hardware/arch/armv7m/armcc/m3/port_s.S | Motorola 68K Assembly | apache-2.0 | 4,801 |
#include <k_config.h>
;******************************************************************************
; EXTERN PARAMETERS
;******************************************************************************
EXTERN g_active_task
EXTERN g_preferred_ready_task
EXTERN krhino_stack_ovf_che... | YifuLiu/AliOS-Things | hardware/arch/armv7m/armcc/m4/port_s.S | Motorola 68K Assembly | apache-2.0 | 5,196 |
#include <k_config.h>
;******************************************************************************
; EXTERN PARAMETERS
;******************************************************************************
EXTERN g_active_task
EXTERN g_preferred_ready_task
EXTERN krhino_stack_ovf_che... | YifuLiu/AliOS-Things | hardware/arch/armv7m/armcc/m7/port_s.S | Motorola 68K Assembly | apache-2.0 | 5,196 |
/*
* Copyright (C) 2015-2021 Alibaba Group Holding Limited
*/
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include <stdio.h>
#include "k_api.h"
/* part of ktask_t */
typedef struct
{
void *task_stack;
}ktask_t_shadow;
//#define OS_BACKTRACE_DEBUG
extern void krhino_task_dea... | YifuLiu/AliOS-Things | hardware/arch/armv7m/common/backtrace.c | C | apache-2.0 | 15,809 |
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#ifndef MPU_H
#define MPU_H
typedef struct {
// MPU type register
unsigned int type;
// MPU control register
unsigned int ctrl;
// MPU range number register
unsigned int rnr;
// MPU region base address register
unsigned i... | YifuLiu/AliOS-Things | hardware/arch/armv7m/common/include/panic_mpu.h | C | apache-2.0 | 5,225 |
#include "k_config.h"
;******************************************************************************
; EQUATES
;******************************************************************************
CONTEXT_REGION EQU 88 ;bigger than sizeof(PANIC_CONTEXT)
;********************************... | YifuLiu/AliOS-Things | hardware/arch/armv7m/common/panic_armcc.S | Motorola 68K Assembly | apache-2.0 | 4,224 |
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#include <stdio.h>
//#include "debug_api.h"
#define REG_NAME_WIDTH 7
typedef struct
{
/* saved in assembler */
int R0;
int R1;
int R2;
int R3;
int R4;
int R5;
int R6;
int R7;
int R8;
int R9;
int R10;
... | YifuLiu/AliOS-Things | hardware/arch/armv7m/common/panic_c.c | C | apache-2.0 | 4,377 |
#include "k_config.h"
;******************************************************************************
; EQUATES
;******************************************************************************
CONTEXT_REGION EQU 88 ;bigger than sizeof(PANIC_CONTEXT)
;********************************... | YifuLiu/AliOS-Things | hardware/arch/armv7m/common/panic_iccarm.S | Motorola 68K Assembly | apache-2.0 | 4,210 |
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#if AOS_COMP_DEBUG
#include <stdio.h>
#include "panic_mpu.h"
#include "k_compiler.h"
#include "k_api.h"
typedef struct {
unsigned long start;
unsigned long size;
unsigned long mpusize;
} mem_region_t;
static void mpu_enable(void);
static vo... | YifuLiu/AliOS-Things | hardware/arch/armv7m/common/panic_mpu.c | C | apache-2.0 | 6,184 |
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#include <k_api.h>
void *cpu_task_stack_init(cpu_stack_t *stack_base, size_t stack_size,
void *arg, task_entry_t entry)
{
cpu_stack_t *stk;
uint32_t temp = (uint32_t)(stack_base + stack_size);
/* stack aligned by 8 ... | YifuLiu/AliOS-Things | hardware/arch/armv7m/common/port_c.c | C | apache-2.0 | 1,690 |
#include <k_config.h>
;******************************************************************************
; EXTERN PARAMETERS
;******************************************************************************
EXTERN g_active_task
EXTERN g_preferred_ready_task
EXTERN krhino_stack_ovf_che... | YifuLiu/AliOS-Things | hardware/arch/armv7m/iccarm/m3/port_s.S | Motorola 68K Assembly | apache-2.0 | 4,785 |
#include <k_config.h>
;******************************************************************************
; EXTERN PARAMETERS
;******************************************************************************
EXTERN g_active_task
EXTERN g_preferred_ready_task
EXTERN krhino_stack_ovf_che... | YifuLiu/AliOS-Things | hardware/arch/armv7m/iccarm/m4/port_s.S | Motorola 68K Assembly | apache-2.0 | 5,178 |
#include <k_config.h>
;******************************************************************************
; EXTERN PARAMETERS
;******************************************************************************
EXTERN g_active_task
EXTERN g_preferred_ready_task
EXTERN krhino_stack_ovf_che... | YifuLiu/AliOS-Things | hardware/arch/armv7m/iccarm/m7/port_s.S | Motorola 68K Assembly | apache-2.0 | 5,178 |
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#ifndef BACKTRACE_H
#define BACKTRACE_H
/* printf call stack
return levels of call stack */
int backtrace_now(int (*print_func)(const char *fmt, ...));
/* printf call stack for task
return levels of call stack */
int backtrace_task(char *taskname,... | YifuLiu/AliOS-Things | hardware/arch/armv7m/include/backtrace.h | C | apache-2.0 | 773 |
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#ifndef K_COMPILER_H
#define K_COMPILER_H
#if defined(__CC_ARM)
#define RHINO_INLINE static __inline
/* get the return address of the current function
unsigned int __return_address(void) */
#define RHINO_GET_RA() (void *)... | YifuLiu/AliOS-Things | hardware/arch/armv7m/include/k_compiler.h | C | apache-2.0 | 3,590 |
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#ifndef K_TYPES_H
#define K_TYPES_H
#include "k_compiler.h"
#define RHINO_TASK_STACK_OVF_MAGIC 0xdeadbeafu /* stack overflow magic value */
#define RHINO_INTRPT_STACK_OVF_MAGIC 0xdeaddeadu /* stack overflow magic value */
#define RHINO_MM_CORR... | YifuLiu/AliOS-Things | hardware/arch/armv7m/include/k_types.h | C | apache-2.0 | 538 |
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#ifndef PORT_H
#define PORT_H
cpu_cpsr_t cpu_intrpt_save(void);
void cpu_intrpt_restore(cpu_cpsr_t cpsr);
void cpu_intrpt_switch(void);
void cpu_task_switch(void);
void cpu_first_task_start(void);
void *cpu_task_stack_init(cpu_stack_t *base, siz... | YifuLiu/AliOS-Things | hardware/arch/armv7m/include/port.h | C | apache-2.0 | 643 |