@@ -6,9 +6,15 @@ void printHome() {}
66void printConfig () {}
77void printBoot () {}
88void printDeleteWarning () {}
9+ void printInstaller () {}
10+ void printMenu () {}
11+ void printQrCode (String data) {}
12+ void printSettings () {}
13+ void printInfo () {}
914#else
1015#include " config.h"
1116#include < TFT_eSPI.h>
17+ #include < QRCodeGenerator.h>
1218
1319#define LINE_HEIGHT 20
1420#define PADDING_X 12
@@ -38,6 +44,7 @@ void setupTFT() {
3844 tft.setTextSize (5 );
3945 tft.setCursor (PADDING_X, 58 );
4046 tft.println (" LNbits" );
47+ delay (200 );
4148}
4249void printTFT (String message, int x, int y) {
4350 tft.setTextSize (2 );
@@ -113,18 +120,36 @@ void printHome() {
113120 tft.setCursor (VERSION_PADDING_X, FOOTER_PADDING_Y);
114121 tft.println (String (VERSION));
115122 if (wifi_connected) {
116- printTFT (" WiFi connected" , PADDING_X, PADDING_Y);
123+ // printTFT("WiFi connected", PADDING_X, PADDING_Y);
117124 int8_t quality = getWifiQuality ();
118125 drawWifiBars (196 , HEADER_PADDING_Y, quality);
119126 } else {
120- printTFT (" No WiFi" , PADDING_X, PADDING_Y);
127+ // printTFT("No WiFi", PADDING_X, PADDING_Y);
121128 drawWifiBars (196 , HEADER_PADDING_Y, 0 );
122129 }
123130 if (config_boot_lock == 1 ) {
124- printTFT (" BOOT LOCKED" , PADDING_X, PADDING_Y + LINE_HEIGHT);
131+ // printTFT("BOOT LOCKED", PADDING_X, PADDING_Y + LINE_HEIGHT);
125132 drawKey (172 , HEADER_PADDING_Y);
126133 } else {
127- printTFT (" BOOT UNLOCKED" , PADDING_X, PADDING_Y + LINE_HEIGHT);
134+ // printTFT("BOOT UNLOCKED", PADDING_X, PADDING_Y + LINE_HEIGHT);
135+ }
136+
137+ switch (currentScreen) {
138+ case SCREEN_HOME:
139+ printMenu ();
140+ break ;
141+ case SCREEN_QR:
142+ 143+ break ;
144+ case SCREEN_SETTINGS:
145+ printSettings ();
146+ break ;
147+ case SCREEN_INFO:
148+ printInfo ();
149+ break ;
150+ default :
151+ Serial.println (" Switches to screen" + String (currentScreen));
152+ break ;
128153 }
129154}
130155
@@ -136,4 +161,85 @@ void printDeleteWarning() {
136161 printTFT (" TO ERASE" , PADDING_X, 63 );
137162 printTFT (" CONFIG" , PADDING_X, 84 );
138163}
164+
165+ void printMenu () {
166+ // Draw menu items
167+ int y = PADDING_Y;
168+ tft.setTextSize (2 );
169+ tft.setCursor (PADDING_X, y);
170+ if (currentMenuItem == SCREEN_QR) tft.setTextColor (TFT_YELLOW); else tft.setTextColor (TFT_WHITE);
171+ tft.println (" Show QR Code" );
172+
173+ y += LINE_HEIGHT;
174+ tft.setCursor (PADDING_X, y);
175+ if (currentMenuItem == SCREEN_SETTINGS) tft.setTextColor (TFT_YELLOW); else tft.setTextColor (TFT_WHITE);
176+ tft.println (" Settings" );
177+
178+ y += LINE_HEIGHT;
179+ tft.setCursor (PADDING_X, y);
180+ if (currentMenuItem == SCREEN_INFO) tft.setTextColor (TFT_YELLOW); else tft.setTextColor (TFT_WHITE);
181+ tft.println (" Device Info" );
182+ }
183+
184+ void printQrCode (String data)
185+ {
186+ const int brightness = 200 ; // 0-255
187+ uint16_t qrScreenBgColour = tft.color565 (brightness, brightness, brightness);
188+ tft.fillScreen (qrScreenBgColour);
189+ const char *qrDataChar = data.c_str ();
190+
191+ QRCode qrcoded;
192+ uint8_t qrcodeData[qrcode_getBufferSize (20 )];
193+ qrcode_initText (&qrcoded, qrcodeData, 6 , 0 , qrDataChar);
194+
195+ unsigned int pixSize = 3 ;
196+ unsigned int offsetTop = 5 ;
197+ unsigned int offsetLeft = 65 ;
198+
199+ for (uint8_t y = 0 ; y < qrcoded.size ; y++)
200+ {
201+ for (uint8_t x = 0 ; x < qrcoded.size ; x++)
202+ {
203+ if (qrcode_getModule (&qrcoded, x, y))
204+ {
205+ tft.fillRect (offsetLeft + pixSize * x, offsetTop + pixSize * y, pixSize, pixSize, TFT_BLACK);
206+ }
207+ else
208+ {
209+ tft.fillRect (offsetLeft + pixSize * x, offsetTop + pixSize * y, pixSize, pixSize, qrScreenBgColour);
210+ }
211+ }
212+ }
213+ }
214+
215+ void printInfo () {
216+ tft.setTextSize (3 );
217+ tft.setTextColor (TFT_WHITE);
218+ tft.setCursor (PADDING_X, 14 );
219+ tft.println (" Info" );
220+ tft.setTextSize (2 );
221+ tft.setCursor (PADDING_X, 52 );
222+ tft.println (" WiFi: " + String (config_wifi_ssid));
223+ tft.setCursor (PADDING_X, 72 );
224+ tft.println (" IP: " + String (WiFi.localIP ().toString ()));
225+ tft.setCursor (PADDING_X, 92 );
226+ tft.println (" LED Pin: " + String (config_led_pin));
227+ }
228+
229+ void printSettings () {
230+ tft.setTextSize (3 );
231+ tft.setTextColor (TFT_WHITE);
232+ tft.setCursor (PADDING_X, 14 );
233+ tft.println (" Settings" );
234+ tft.setTextSize (2 );
235+ int y = 52 ;
236+ tft.setCursor (PADDING_X, y);
237+ if (currentSetting == SETTING_ENABLE_BLINK) tft.setTextColor (TFT_YELLOW); else tft.setTextColor (TFT_WHITE);
238+ tft.println (" Enable Blink: " + String (enable_blink ? " YES" : " NO" ));
239+ y += LINE_HEIGHT;
240+ tft.setCursor (PADDING_X, y);
241+ if (currentSetting == SETTING_BOOT_LOCK) tft.setTextColor (TFT_YELLOW); else tft.setTextColor (TFT_WHITE);
242+ tft.println (" Bootlock: " + String (config_boot_lock == 1 ? " LOCKED" : " UNLOCKED" ));
243+ }
244+
139245#endif
0 commit comments