GY-63_MS5611/libraries/ANSI/examples/ansiDemo02/ansiDemo02.ino

96 lines
1.8 KiB
Arduino
Raw Normal View History

2021-01-29 06:31:58 -05:00
//
// FILE: ansiDemo02.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo
// URL: https://github.com/RobTillaart/ANSI
2021-10-18 10:35:48 -04:00
2021-01-29 06:31:58 -05:00
#include "ansi.h"
ANSI ansi(&Serial);
int t;
double d;
2021-12-13 10:45:59 -05:00
2021-01-29 06:31:58 -05:00
void setup()
{
Serial.begin(115200);
// SPLASH SCREEN
ansi.clearScreen();
2023-02-27 05:33:43 -05:00
ansi.gotoXY(10, 8);
2021-01-29 06:31:58 -05:00
ansi.bold();
ansi.print("DEMO ANSI TERMINAL");
ansi.normal();
delay(5000);
ansi.clearScreen();
}
2021-12-13 10:45:59 -05:00
2021-01-29 06:31:58 -05:00
void loop()
{
// DISPLAY TEMPERATURE (dummy)
2023-02-27 05:33:43 -05:00
ansi.gotoXY(10, 6);
2021-01-29 06:31:58 -05:00
ansi.print("TEMP: ");
2023-02-27 05:33:43 -05:00
ansi.gotoXY(16, 6);
2021-01-29 06:31:58 -05:00
t = random(100);
if (t > 70) ansi.foreground(ansi.red);
ansi.print(t);
ansi.foreground(ansi.white);
// DISPLAY HUMIDITY (dummy)
2023-02-27 05:33:43 -05:00
ansi.gotoXY(10, 7);
2021-01-29 06:31:58 -05:00
ansi.print(" HUM: ");
2023-02-27 05:33:43 -05:00
ansi.gotoXY(16, 7);
2021-01-29 06:31:58 -05:00
t = random(100);
if (t > 50) ansi.foreground(ansi.yellow);
ansi.print(t);
ansi.foreground(ansi.white);
// DISPLAY UV (dummy)
2023-02-27 05:33:43 -05:00
ansi.gotoXY(10, 8);
2021-01-29 06:31:58 -05:00
ansi.print(" UV: ");
2023-02-27 05:33:43 -05:00
ansi.gotoXY(16, 8);
2021-01-29 06:31:58 -05:00
d = random(10000) * 0.01;
if (d > 30) ansi.foreground(ansi.green);
if (d > 50) ansi.foreground(ansi.yellow);
if (d > 70) ansi.foreground(ansi.red);
ansi.print(d, 2);
ansi.foreground(ansi.white);
// DISPLAY bargraph (dummy)
ansi.gotoXY(10, 10);
ansi.print(" BAR:");
2023-02-27 05:33:43 -05:00
ansi.gotoXY(16, 10);
2021-01-29 06:31:58 -05:00
int x = random(10);
for (int i = 0; i < 10; i++) ansi.print(i <= x ? ">" : " ");
// DISPLAY password (dummy)
2023-02-27 05:33:43 -05:00
ansi.gotoXY(10, 12);
2021-01-29 06:31:58 -05:00
ansi.print("PASS:");
char buffer[20];
for (int i = 0; i < 16; i++)
{
int x = random(62);
if (x < 26) buffer[i] = 'A' + random(26);
if (26 <= x && x < 52) buffer[i] = 'a' + random(26);
if (52 <= x) buffer[i] = '0' + random(10);
}
buffer[16] = 0;
2023-02-27 05:33:43 -05:00
ansi.gotoXY(16, 12);
2021-01-29 06:31:58 -05:00
ansi.print(buffer);
// DISPLAY TIME (dummy)
2023-02-27 05:33:43 -05:00
ansi.gotoXY(10, 2);
2021-01-29 06:31:58 -05:00
ansi.print("TIME: ");
2023-02-27 05:33:43 -05:00
ansi.gotoXY(16, 2);
2021-01-29 06:31:58 -05:00
ansi.print(millis()/1000);
delay(1000);
}
2021-12-13 10:45:59 -05:00
2023-02-27 05:33:43 -05:00
// -- END OF FILE --
2021-12-13 10:45:59 -05:00