def init_qwiic():
    global prox, bme, ccs, oled
    # Qwiic Board define
    prox = qwiic.QwiicProximity()
    bme = qwiic.QwiicBme280()
    ccs = qwiic.QwiicCcs811()
    oled = qwiic.QwiicMicroOled()

    # Begin statements
    prox.begin()
    bme.begin()
    #ccs.begin()
    oled.begin()

    # Used for debugging CCS811
    try:
        ccs.begin()

    except Exception as e:
        print(e)

    # Setup OLED
    oled.clear(oled.ALL)
    oled.display()
    oled.set_font_type(1)
    def __init__(self):
        self.oled = qwiic.QwiicMicroOled()
        self.oled.begin()
        self.oled.clear(self.oled.ALL)

        # Subscribers
        rospy.Subscriber("/rpi_io/oled_input", OledInput, self.request_handler)
Beispiel #3
0
def run():
    # Define oled screen and initialize
    oled = qwiic.QwiicMicroOled()
    oled.begin()

    # clear the screen
    oled.clear(oled.PAGE)
    oled.display()

    # set the font size
    oled.set_font_type(1)

    mpu.MPU_Init()

    print(" Reading Data of Gyroscope and Accelerometer")

    while True:

        # Read Accelerometer raw value
        acc_x = mpu.read_raw_data(mpu.ACCEL_XOUT_H)
        acc_y = mpu.read_raw_data(mpu.ACCEL_YOUT_H)
        acc_z = mpu.read_raw_data(mpu.ACCEL_ZOUT_H)

        # Read Gyroscope raw value
        gyro_x = mpu.read_raw_data(mpu.GYRO_XOUT_H)
        gyro_y = mpu.read_raw_data(mpu.GYRO_YOUT_H)
        gyro_z = mpu.read_raw_data(mpu.GYRO_ZOUT_H)

        # Full scale range +/- 250 degree/C as per sensitivity scale factor
        Ax = round(acc_x / 16384.0, 2)
        Ay = round(acc_y / 16384.0, 2)
        Az = round(acc_z / 16384.0, 2)

        Gx = gyro_x / 131.0
        Gy = gyro_y / 131.0
        Gz = gyro_z / 131.0

        # print("Gx=%.2f" % Gx, u'\u00b0' + "/s", "\tGy=%.2f" % Gy, u'\u00b0' + "/s", "\tGz=%.2f" %
        #       Gz, u'\u00b0' + "/s", "\tAx=%.2f g" % Ax, "\tAy=%.2f g" % Ay, "\tAz=%.2f g" % Az)
        # sleep(1)

        # now = datetime.now()
        # currentTime = now.strftime("%H:%M")

        # set cursor position
        oled.set_cursor(2, 5)  # top left of screen
        oled.print('Ax:' + str(Ax))

        oled.set_cursor(2, 20)
        oled.print('Ay:' + str(Ay))

        oled.set_cursor(2, 35)
        oled.print('Az:' + str(Az))

        print(Ax, Ay, Az)

        # display screen
        oled.display()

        time.sleep(.5)
        oled.clear(oled.PAGE)
Beispiel #4
0
#! /usr/bin/python3

from __future__ import print_function
from datetime import datetime
import qwiic_py
import qwiic
import time
import sys

# Define oled screen and initialize
oled = qwiic.QwiicMicroOled()
oled.begin()

# clear the screen
oled.clear(oled.PAGE)
oled.display()

# set the font size
oled.set_font_type(1)

while True:

    now = datetime.now()
    currentTime = now.strftime("%H:%M")

    # set cursor position
    oled.set_cursor(10, 8)  # top left of screen
    oled.print("Hello")

    # oled.set_cursor(0,22)
    # oled.print("TA!")
Beispiel #5
0
def run():
    # Define oled screen and initialize
    oled = qwiic.QwiicMicroOled()
    oled.begin()

    # clear the screen
    oled.clear(oled.PAGE)
    oled.display()

    # set the font size
    oled.set_font_type(1)

    mpu.MPU_Init()

    #display code version
    oled.set_cursor(2, 5)  # top left of screen
    oled.print('V-0.1.3')
    oled.display()
    time.sleep(2)
    oled.clear(oled.PAGE)

    accel = {'x':[], 'y':[], 'z':[]}
    speed = {'x':[], 'y':[], 'z':[]}

    while True:
        # Read Accelerometer raw value
        acc_x = mpu.read_raw_data(mpu.ACCEL_XOUT_H)
        acc_y = mpu.read_raw_data(mpu.ACCEL_YOUT_H)
        acc_z = mpu.read_raw_data(mpu.ACCEL_ZOUT_H)

        # Read Gyroscope raw value
        gyro_x = mpu.read_raw_data(mpu.GYRO_XOUT_H)
        gyro_y = mpu.read_raw_data(mpu.GYRO_YOUT_H)
        gyro_z = mpu.read_raw_data(mpu.GYRO_ZOUT_H)

        # Full scale range +/- 250 degree/C as per sensitivity scale factor
        #Accelerometer returns values in g (multiply by 9.8 to get m/s^2)
        Ax = (acc_x/16384.0) * 9.8
        Ay = (acc_y/16384.0) * 9.8
        Az = (acc_z/16384.0) * 9.8

        Gx = gyro_x/131.0
        Gy = gyro_y/131.0
        Gz = gyro_z/131.0

        #add accel
        accel['x'].append(Ax)
        accel['y'].append(Ay)
        accel['z'].append(Az)

        #get_speed from accel
        Vx, Vy, Vz = integrate(accel)

        #add speed
        speed['x'].append(Vx)
        speed['y'].append(Vy)
        speed['z'].append(Vz)

        #get distance from speed
        Dx, Dy, Dz = integrate(speed)

        oled.set_cursor(2, 5)  # top left of screen
        oled.print('X:' + o_str(Ax))

        oled.set_cursor(2, 20)
        oled.print('Y:' + o_str(Ay))

        oled.set_cursor(2, 35)
        oled.print('Z:' + o_str(Az))

        oled.display()
        time.sleep(0.25)
        oled.clear(oled.PAGE)
Beispiel #6
0
        top = padding
        bottom = height - padding
        # Move left to right keeping track of the current x position for drawing shapes.
        x = 0

        # Load default font.
        font = ImageFont.load_default()

        # Draw a black filled box to clear the image.
        draw.rectangle((0, 0, width, height), outline=0, fill=0)
    except OSError as err:
        print("OS error: {0}".format(err))
        time.sleep(5)
# 48 x 64 display------------------------------------------------------
elif 61 in addresses:
    disp2 = qwiic.QwiicMicroOled()
    try:
        # Initiallize Display
        disp2.begin()

        # Display Flame (set to buffer in begin function)
        disp2.display()
        time.sleep(5)  # Pause 5 sec

        # Clear Display
        disp2.clear(disp2.PAGE)
        disp2.clear(disp2.ALL)

        # Set Font
        disp2.set_font_type(0)
        # Could replace line spacing with disp2.getFontHeight, but doesn't scale properly