1import sh1106
2import utime
3from driver import SPI
4from driver import GPIO
5from mpu6050 import MPU6050
6
7mpu6050Dev = MPU6050()
8mpu6050Dev.open("mpu6050")
9mpu6050Dev.init()
10print("mpu6050 init finished")
11
12spi0 = SPI()
13spi0.open("oled_spi")
14
15gpio_dc = GPIO()
16gpio_dc.open("oled_dc")
17
18gpio_res = GPIO()
19gpio_res.open("oled_res")
20
21display = sh1106.SH1106_SPI(width=132, height=64, spi=spi0, dc = gpio_dc, res = gpio_res)
22# display.init_display()
23ac = []
24while(True):
25    ac = mpu6050Dev.get_Accelerometer()
26    #print("mpu6050 acc is: " , ac[0], ac[1], ac[2])
27    display.fill(0)
28    #display.fill_circle(50, 30, 20, 0xAF)
29    #display.draw_circle(90, 30, 20, 2, 0xAF)
30    display.draw_circle(66, 32, 10, 1, 1)
31    display.fill_circle(int(66 - ac[0] / 250), int(32 + ac[1] / 500), 8, 1)
32    display.show()
33# display.test()
34mpu6050Dev.close()
35print("test mpu6050 success!")
36