Display.ino 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include <M5Stack.h>
  2. // the setup routine runs once when M5Stack starts up
  3. void setup() {
  4. // initialize the M5Stack object
  5. M5.begin();
  6. /*
  7. Power chip connected to gpio21, gpio22, I2C device
  8. Set battery charging voltage and current
  9. If used battery, please call this function in your project
  10. */
  11. M5.Power.begin();
  12. // Lcd display
  13. M5.Lcd.fillScreen(WHITE);
  14. delay(500);
  15. M5.Lcd.fillScreen(RED);
  16. delay(500);
  17. M5.Lcd.fillScreen(GREEN);
  18. delay(500);
  19. M5.Lcd.fillScreen(BLUE);
  20. delay(500);
  21. M5.Lcd.fillScreen(BLACK);
  22. delay(500);
  23. // text print
  24. M5.Lcd.fillScreen(BLACK);
  25. M5.Lcd.setCursor(10, 10);
  26. M5.Lcd.setTextColor(WHITE);
  27. M5.Lcd.setTextSize(1);
  28. M5.Lcd.printf("Display Test!");
  29. // draw graphic
  30. delay(1000);
  31. M5.Lcd.drawRect(100, 100, 50, 50, BLUE);
  32. delay(1000);
  33. M5.Lcd.fillRect(100, 100, 50, 50, BLUE);
  34. delay(1000);
  35. M5.Lcd.drawCircle(100, 100, 50, RED);
  36. delay(1000);
  37. M5.Lcd.fillCircle(100, 100, 50, RED);
  38. delay(1000);
  39. M5.Lcd.drawTriangle(30, 30, 180, 100, 80, 150, YELLOW);
  40. delay(1000);
  41. M5.Lcd.fillTriangle(30, 30, 180, 100, 80, 150, YELLOW);
  42. }
  43. // the loop routine runs over and over again forever
  44. void loop(){
  45. //rand draw
  46. M5.Lcd.fillTriangle(random(M5.Lcd.width()-1), random(M5.Lcd.height()-1), random(M5.Lcd.width()-1), random(M5.Lcd.height()-1), random(M5.Lcd.width()-1), random(M5.Lcd.height()-1), random(0xfffe));
  47. M5.update();
  48. }