import machine
import utime
from ssd1306 import SSD1306_I2C
from QMI8658 import QMI8658
WIDTH = 128
HEIGHT = 64
i2c_oled = machine.I2C(0, sda=machine.Pin(0), scl=machine.Pin(1))
oled = SSD1306_I2C(WIDTH, HEIGHT, i2c_oled)
# Ініціалізація гіроскопу QMI8658
i2c_gyro = machine.I2C(sda=machine.Pin(20), scl=machine.Pin(21))
gyro = QMI8658(i2c_gyro)
def display_data():
oled.fill(0)
oled.text("QMI8658 Data:", 0, 0)
oled.text("Acc X: {:.2f} g".format(gyro.get_acceleration()[0]), 0, 10)
oled.text("Acc Y: {:.2f} g".format(gyro.get_acceleration()[1]), 0, 20)
oled.text("Acc Z: {:.2f} g".format(gyro.get_acceleration()[2]), 0, 30)
oled.text("Gyro X: {:.2f} deg/s".format(gyro.get_rotation()[0]), 0, 40)
oled.text("Gyro Y: {:.2f} deg/s".format(gyro.get_rotation()[1]), 0, 50)
oled.show()
while True:
display_data()
utime.sleep(1)