Exemple #1
0
    def __init__(self):
        """Set up the hardware we're using.

    Set orientation to non-supported value to force initialization.
    """
        self.imu = imu.IMU()
        self.ssid = None
        self.password = None
        self.orientation = lcd.PORTRAIT
        self.ButtonA = btnA
        self.ButtonB = btnB
        lcd.fill(BLACK)
        self.SetOrientation()
Exemple #2
0
  def __init__(self):
    """Set up the hardware we're using.

    Set orientation to non-supported value to force initialization.
    """
    self.imu = imu.IMU()
    self.ssid = None
    self.password = None
    self.orientation = lcd.PORTRAIT
    self.chase_index = 0
    self.old_chase = []
    self.new_chase = []
    lcd.fill(BLACK)
    self.SetOrientation()
Exemple #3
0
def gyro_start(obj):
    global _pos
    import i2c_bus

    _pos = [0, 0]
    lcd.image(0, 0, '/flash/img/3-3.jpg', type=lcd.JPG)
    obj['color']= lcd.RED
    from lib import imu
    obj['imu'] = imu.IMU()
    if obj['imu'].address == 0x68:
        if obj['imu'].whoami == 0x19:
            if get_bmm150_status():
                obj['color'] = lcd.GREEN
                lcd.print("IMU:MPU9250", 190, 20, 0xFFAAAA)
        else:
            obj['color'] = lcd.BLACK
    elif obj['imu'].address == 0x6c:
        if get_bmm150_status():
            obj['color'] = lcd.BLUE
            lcd.print("IMU:SHQ200", 190, 20, 0xFFAAAA)
    obj['buf'] = [[0, 0] for i in range(0, 6)]
    lcd.rect(65, 65, 60, 60, lcd.WHITE, lcd.WHITE)  # old pic dot clean
Exemple #4
0
 def setUp(self):
     self.imu = imu.IMU()
from m5stack import lcd

from machine import Pin

import utime as time

#from mpu9250 import MPU9250
import imu

from fusion import Fusion

from machine import I2C

i2c = I2C(sda=21, scl=22)

imu = imu.IMU()

fuse = Fusion()


def getmag():  # Return (x, y, z) tuple (blocking read)

    return imu.mag.xyz


if btnA.isPressed():

    print("Calibrating. Press switch when done.")

    fuse.calibrate(getmag, BtnB.press, lambda: time.sleep(0.1))
Exemple #6
0
      if self.y > screen_height:
         self.y = screen_height
   
   def update(self, dx, dy):
      lcd.pixel(self.x, self.y, bgcolor)
      self.x += dx
      self.y += dy
      self.checkBorders()
      lcd.pixel(self.x, self.y, self.color)

mc = object()


setScreenColor(bgcolor)

#hat_Joystick0 = hat.get(hat.JOYSTICK)
imu0 = imu.IMU()
gyroZeroX = imu0.gyro[1]
gyroZeroY = imu0.gyro[0]

label0 = M5TextBox(60, 15, "Text", lcd.FONT_Default,0xFFFFFF, rotate=180)

while True:
  #mc_dx = int(hat_Joystick0.X / sensitivity)
  #mc_dy = int(-hat_Joystick0.Y / sensitivity)
  mc_dx = int((imu0.gyro[1] - gyroZeroX) / sensitivity)
  mc_dy = int((imu0.gyro[0] - gyroZeroY) / sensitivity)
  label0.setText(str(mc_dx) + ", " + str(mc_dy))
  mc.update(mc_dx, mc_dy)
  wait_ms(2)
Exemple #7
0
#!/usr/bin/env python

import web  # web.py
import smbus

import imu as imu
from i2cutils import i2c_raspberry_pi_bus_number

urls = ('/', 'index')

bus = smbus.SMBus(i2c_raspberry_pi_bus_number())
imu_controller = imu.IMU(bus, 0x69, 0x53, 0x1e, "IMU")

imu_controller.set_compass_offsets(9, -10, -140)

app = web.application(urls, globals())


class index:
    def GET(self):
        (pitch, roll, yaw) = imu_controller.read_pitch_roll_yaw()
        result = "%.2f %.2f %.2f" % (pitch, roll, yaw)
        return result


if __name__ == "__main__":
    app.run()
Exemple #8
0
            if q[0] == 3:
                q[0] = 'forearm'
            response = {
                'id': q[0],
                'quaternion': {
                    'x': q[1],
                    'y': q[2],
                    'z': q[3],
                    'w': q[4]
                },
                'timestamp': q[5]
            }
            do_notify(response)


serial_port = serial.Serial(imu.get_port(), timeout=1, baudrate=115200)
sensor3 = imu.IMU(serial_port, 3)
sensor2 = imu.IMU(serial_port, 2)

t = thread.start_new_thread(main, ())
i = raw_input('Parar?')
running = False
sensor2.stop_streaming()
sensor3.stop_streaming()

# server()
# teste git

serial_port.close()

print 'adeus'
Exemple #9
0
import imu
import time

gyro = imu.IMU()
while True:
    print(gyro.ypr)
    time.sleep(0.1)
Exemple #10
0
        get_euler_angles(call, addr, responseData)
    elif service == 'registerListener':
        register_listener(call, addr, responseData)

    # responds
    response['responseData'] = responseData
    conn.send(json.dumps(response) + '\n')
    conn.close()

    # this is just a notify test!!! remove it!!!
    register_listener(call, addr, responseData)
    do_notify('newdata')


def server():
    s = socket.socket()
    localep = (HOST, PORT_IN)
    s.bind(localep)
    s.listen(5)
    print 'listening on: ', localep, ';'
    while True:
        conn, addr = s.accept()
        thread.start_new_thread(handle_incoming, (conn, addr))


serialPort = serial.Serial(DNG_PORT, baudrate=115200)
arm_IMU = imu.IMU(serialPort, ARM_IMU_ADDR)
foreamr_IMU = imu.IMU(serialPort, FOREARM_IMU_ADDR)
# starts listening...
server()