-
Notifications
You must be signed in to change notification settings - Fork 1
/
EX-Display.ino
139 lines (115 loc) · 3.64 KB
/
EX-Display.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include "AtFinder.h"
#include "Defines.h"
#include "DisplayFunctions.h"
#include "MCUFriendScreen.h"
#include "TFT_eSPIScreen.h"
#include "version.h"
#include <Arduino.h>
bool StartupPhase = true;
unsigned long timestamp = 0;
long screencount = 0;
// Chris just doing this for manual testing on my mega... so I can debug down the serial monitor
#if defined(ARDUINO_AVR_MEGA2560)
#undef CS_LISTEN
#define CS_LISTEN Serial
#endif
#if SCREEN_0_TYPE == MCU
MCUFRIEND_kbv tft;
#elif SCREEN_0_TYPE == TFT
TFT_eSPI tft = TFT_eSPI();
#endif
void setup() {
CONSOLE.begin(115200);
CS_LISTEN.begin(115200); // Start Serial1 for listening to messages
CONSOLE.print(F("EX-Display v"));
CONSOLE.println(VERSION);
// Tell AtFinder our maximum supported text length,
// and how to call back when found.
AtFinder::setup(100, updateEXDisplayRow);
// SCREEN::TFT_Startup();
// tft.invertDisplay(1);
// tft.invertDisplay(0);
// HARDWARE SETUP TODO..... Create an EXDisplay instance for each screen this ino wants to display.
// The updateEXDisplayRow will ignore messages destined for screens we dont have.
// For testing lets create some
SCREEN_0
#ifdef SCREEN_1_TYPE
SCREEN_1
#endif
#ifdef SCREEN_2_TYPE
SCREEN_2
#endif
// new EXDisplay(0, new MCUFriendScreen(8, 20), 30);
for (EXDisplay *display = EXDisplay::getFirst(); display; display = display->getNext()) {
display->getEXScreen()->setupScreen(SCREEN_ROTATION, TEXT_COLOUR, BACKGROUND_COLOUR);
CONSOLE.print(F("Display ID|Max Rows|Max Columns: "));
CONSOLE.print(display->getDisplayNumber());
CONSOLE.print(F("|"));
CONSOLE.print(display->getScreenMaxRows());
CONSOLE.print(F("|"));
CONSOLE.println(display->getScreenMaxColumns());
}
// Setup the start screen.
// if (MAX_SCREENS > 1) {
// currentScreenID = INITIAL_SCREEN;
// }
// else {
// currentScreenID = 0;
// }
timestamp = millis();
CONSOLE.println(F("End of Setup"));
}
void loop() {
// Check if we are in the startup phase
// This phase inhibits screen drawing until the startup messages are
// issued by the CS
if (StartupPhase) {
if ((millis() - timestamp) >= STARTUP_TIME) {
StartupPhase = false;
screencount = millis();
}
}
// each byte received form serial is passed to the parse
if (CS_LISTEN.available()) {
AtFinder::processInputChar(CS_LISTEN.read());
}
// you can display all rows by sending <@ 255 0 "">
// No data incoming so see if we need to display anything
// DISABLE IN STARTUPPHASE
else {
updateScreens();
/* DISABLE SO IT WILL COMPILE
if (StartupPhase==false){
// add thie following in once display is working
// for (byte x= 0; x<MAX_SCREENS; x++){
// if (ScreenChanged[x]) { setScreenRows(x); }
// }
SCREEN::CheckScreens();
// DISABLE TO START
#ifndef USE_TOUCH
//Check Page Time to see if we need to scroll
if((millis()-screencount) > SCROLLTIME) {
if (currentScreenID >= MAX_SCREENS-1) {
currentScreenID=0;
}
else {
currentScreenID++;
}
screencount=millis();
ScreenChanged[currentScreenID] = true;
}
#else
if (SCREEN::check_touch) {
if (currentScreenID >= MAX_SCREENS-1) {
currentScreenID=0;
}
else {
currentScreenID++;
}
ScreenChanged[currentScreenID] = true;
}
#endif
}
*/
}
}