from machine import Pin, ADC, I2C
from utime import sleep, sleep_ms
from ssd1306 import SSD1306_I2C
from MPU6050 import MPU6050
ancho = 128
alto = 64
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
oled = SSD1306_I2C(ancho, alto, i2c)
mpu = MPU6050(i2c)
print("direccion: ", hex(i2c.scan()[0]),hex(i2c.scan()[1]),)
while True:
tem = mpu.read_temperature()
gyro = mpu.read_gyro_data()
acel = mpu.read_accel_data()
print(tem, gyro, acel)
oled.fill(0)
oled.pixel(64, 32, 1)
oled.hline(0, 0, 128, 1)
oled.hline(0, 20, 128, 1)
oled.vline(0, 0, 20, 1)
oled.vline(127, 0, 20, 1)
oled.text("webos", 42, 7, 1)
oled.text("T={:.1f}C".format(tem), 0, 30, 1)
oled.text("GX:{:.0f}GY:{:.0f}GZ:{:.0f}".format(gyro[0],gyro[1],gyro[2]), 0, 40, 1)
oled.show()