示例#1
0
def bmp_init():
   from utils.octopus import i2c_init
   # "-1" > SW for old lib:
   i2c = i2c_init(1,100000,-1)

   from bmp280 import BMP280

   bmp = BMP280(i2c)
   return bmp
示例#2
0
def bme280_init():
    i2c = i2c_init(1)
    bme = BME280(i2c=i2c)
    return bme
# from https://github.com/liske/python-apds9960/blob/master/micropython/test_prox.py
# Copyright Thomas Liske 2018
# GPLv3

from time import sleep
from utils.octopus import i2c_init
from lib.apds9960 import uAPDS9960 as APDS9960

i2c = i2c_init()

apds = APDS9960(i2c, valid_id=[0x30])

apds.setProximityIntLowThreshold(50)

print("Proximity Sensor Test")
print("=====================")
apds.enableProximitySensor(False)

oval = -1
while True:
    sleep(0.25)
    val = apds.readProximity()
    if val != oval:
        print("proximity={}".format(val))
示例#4
0
# 2 x pcf 8-bit expander
# exb.addr = 58 (010) buttons
# exl.addr = 62 (011) leds

from time import sleep
from utils.octopus import i2c_init
from utils.i2c_expander import Expander8
from utils.bits import neg, reverse, int2bin, get_bit, set_bit
# int2bin(reverse(b1))   >   '10011111'

i2c = i2c_init(True, 200)
# i2c.scan() > devices:
# [35, 58, 62]

exb = Expander8(58)
exl = Expander8(62)

while True:
    buttons = exb.read()

    sleep1 = False

    if (get_bit(neg(buttons), 0)):
        print("0")
        sleep1 = True

    if (get_bit(neg(buttons), 1)):
        print("1")
        sleep1 = True

    if (get_bit(neg(buttons), 2)):
示例#5
0
def bme280_init():
    i2c = i2c_init(1)
    bme = BME280(i2c=i2c)
    print(bme.values)
    return bme
示例#6
0
    servo.position(s, ang)
    sleep_ms(delay)

    if start < stop:
        print("a")
        while ang < stop:
            ang = ang + step
            servo.position(s, ang)
            sleep_ms(delay)

    if start > stop:
        print("b")
        while ang > stop:
            ang = ang - step
            servo.position(s, ang)
            sleep_ms(delay)


i2c = i2c_init(1)
servo = Servos(i2c)


def sweeptest():
    sweep(0, 30, 160)
    sweep(1, 30, 180)
    sweep(0, 160, 30)
    sweep(1, 180, 30)


sweeptest()