Closed turbomatte closed 3 months ago
M5GFX display; M5Canvas canvas(&display);
SONIC_I2C sensor;
void setup() { M5.begin(); // Init M5Stack. 初始化M5Stack sensor.begin(); display.begin(); canvas.setColorDepth(1); canvas.setFont(&fonts::Orbitron_Light_24); canvas.setTextSize(1); canvas.createSprite(display.width(), display.height()); canvas.setPaletteColor(1, ORANGE); }
int point = 0; int last_point = 0;
void loop() { canvas.scroll(4); float Distance = sensor.getDistance(); Serial.printf("Distance: %.2fmm\r\n", Distance); point = map((int)Distance, 20, 4500, 10, 180); canvas.drawLine(0, point, 4, last_point, 1); last_point = point; canvas.fillRect(0, 190, 320, 50, BLACK); canvas.drawString(String(Distance) + "mm", 80, 190); canvas.pushSprite(0, 0); }
Marius 12.04.2024 Flashen des neuen Codes und Funktionstest des Sensors
Besprechungsrunde 05/06/2024
Alles funktioniert
include
include
include
M5GFX display; M5Canvas canvas(&display);
SONIC_I2C sensor;
void setup() { M5.begin(); // Init M5Stack. 初始化M5Stack sensor.begin(); display.begin(); canvas.setColorDepth(1); canvas.setFont(&fonts::Orbitron_Light_24); canvas.setTextSize(1); canvas.createSprite(display.width(), display.height()); canvas.setPaletteColor(1, ORANGE); }
int point = 0; int last_point = 0;
void loop() { canvas.scroll(4); float Distance = sensor.getDistance(); Serial.printf("Distance: %.2fmm\r\n", Distance); point = map((int)Distance, 20, 4500, 10, 180); canvas.drawLine(0, point, 4, last_point, 1); last_point = point; canvas.fillRect(0, 190, 320, 50, BLACK); canvas.drawString(String(Distance) + "mm", 80, 190); canvas.pushSprite(0, 0); }