1+ /*
2+ *******************************************************************************
3+ * Copyright (c) 2021 by M5Stack
4+ * Equipped with M5Core sample source code
5+ * Visit the website for more information:https://docs.m5stack.com/en/products
6+ *
7+ * describe:Display Example
8+ * date:2021/7/15
9+ *******************************************************************************
10+ */
111#include < M5Stack.h>
212
3- // the setup routine runs once when M5Stack starts up
13+ // After M5Core is started or reset
14+ // the program in the setUp () function will be run, and this part will only be run once.
415void setup () {
5-
6- // initialize the M5Stack object
7- M5.begin ();
16+ M5.begin (); // Init M5Core
17+ M5.Power .begin (); // Init Power module
818
9- /*
10- Power chip connected to gpio21, gpio22, I2C device
11- Set battery charging voltage and current
12- If used battery, please call this function in your project
13- */
14- M5.Power .begin ();
15-
16- // Lcd display
17- M5.Lcd .fillScreen (WHITE);
18- delay (500 );
19+ M5.Lcd .fillScreen (WHITE); // Set the screen background color to white
20+ delay (500 ); // Delay 500ms
1921 M5.Lcd .fillScreen (RED);
2022 delay (500 );
2123 M5.Lcd .fillScreen (GREEN);
@@ -25,34 +27,31 @@ void setup() {
2527 M5.Lcd .fillScreen (BLACK);
2628 delay (500 );
2729
28- // text print
29- M5.Lcd .fillScreen (BLACK);
30- M5.Lcd .setCursor (10 , 10 );
31- M5.Lcd .setTextColor (WHITE);
32- M5.Lcd .setTextSize (1 );
33- M5.Lcd .printf (" Display Test!" );
30+ M5.Lcd .setCursor (10 , 10 ); // Move the cursor position to (x,y)
31+ M5.Lcd .setTextColor (WHITE); // Set the font color to white,
32+ M5.Lcd .setTextSize (1 ); // Set the font size
33+ M5.Lcd .printf (" Display Test!" ); // Serial output format string
3434
3535 // draw graphic
3636 delay (1000 );
37- M5.Lcd .drawRect (100 , 100 , 50 , 50 , BLUE);
37+ M5.Lcd .drawRect (100 , 100 , 50 , 50 , BLUE); // Draw a 50x50 blue rectangle wireframe at (x,y)
3838 delay (1000 );
39- M5.Lcd .fillRect (100 , 100 , 50 , 50 , BLUE);
39+ M5.Lcd .fillRect (100 , 100 , 50 , 50 , BLUE); // Draw a blue rectangle 50x50 at (x,y)
4040 delay (1000 );
41- M5.Lcd .drawCircle (100 , 100 , 50 , RED);
41+ M5.Lcd .drawCircle (100 , 100 , 50 , RED); // Draw a red circle of radius 50 at (x,y)
4242 delay (1000 );
43- M5.Lcd .fillCircle (100 , 100 , 50 , RED);
43+ M5.Lcd .fillCircle (100 , 100 , 50 , RED); // Draw a red circle of radius 50 at (x,y)
4444 delay (1000 );
45- M5.Lcd .drawTriangle (30 , 30 , 180 , 100 , 80 , 150 , YELLOW);
45+ M5.Lcd .drawTriangle (30 , 30 , 180 , 100 , 80 , 150 , YELLOW); // Make a triangle wireframe with (x1,y1) (x2,y2) (x3,y3) as the vertices
4646 delay (1000 );
47- M5.Lcd .fillTriangle (30 , 30 , 180 , 100 , 80 , 150 , YELLOW);
48-
47+ M5.Lcd .fillTriangle (30 , 30 , 180 , 100 , 80 , 150 , YELLOW); // Construct a triangle with (x1,y1) (x2,y2) (x3,y3) as its vertices
4948}
5049
51- // the loop routine runs over and over again forever
50+ // After the program in setup() runs, it runs the program in loop()
51+ // The loop() function is an infinite loop in which the program runs repeatedly
5252void loop (){
5353
54- // rand draw
5554 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 ));
5655
57- M5.update ();
56+ M5.update (); // Read the press state of the key
5857}
0 commit comments