本帖最后由 Isabella_J 于 2025-1-22 00:20 编辑
代码
| /*! |
| * MindPlus |
| * esp32s3bit |
| * |
| */ |
| #include "unihiker_k10.h" |
| // 创建对象 |
| UNIHIKER_K10 k10; |
| uint8_t screen_dir=2; |
| |
| |
| // 主程序开始 |
| void setup() { |
| k10.begin(); |
| k10.initScreen(screen_dir); |
| k10.creatCanvas(); |
| k10.rgb->brightness(round(9)); |
| k10.setScreenBackground(0xFFFFFF); |
| } |
| void loop() { |
| if (((k10.getAccelerometerX())<=-150)) { |
| k10.canvas->canvasText("左转", 100, 150, 0x000000, k10.canvas->eCNAndENFont24, 50, true); |
| k10.canvas->updateCanvas(); |
| k10.rgb->write(0, 0xFF0000); |
| delay(300); |
| k10.rgb->write(0, 0x000000); |
| delay(300); |
| } |
| else if (((k10.getAccelerometerX())>=150)) { |
| k10.canvas->canvasText("右转", 100, 150, 0x000000, k10.canvas->eCNAndENFont24, 50, true); |
| k10.canvas->updateCanvas(); |
| k10.rgb->write(2, 0xFF0000); |
| delay(300); |
| k10.rgb->write(2, 0x000000); |
| delay(300); |
| } |
| else { |
| k10.canvas->canvasText("直行", 100, 150, 0x000000, k10.canvas->eCNAndENFont24, 50, true); |
| k10.canvas->updateCanvas(); |
| k10.rgb->write(-1, 0x000000); |
| } |
| }
|
|
|
|
|
|
|