21
21
#define GREEN 0x0200 // 0 64 0
22
22
#define RED 0xF800 // 255 0 0
23
23
#define maxTextSize 5 // larger sourceName text
24
-
24
+ #define startBrightness 11
25
+ #define maxBrightness 100
25
26
// Name of the device - the 3 last bytes of the mac address will be appended to create a unique identifier for the server.
26
27
String listenerDeviceName = " m5StickC-" ;
27
28
@@ -70,7 +71,7 @@ String LastMessage = "";
70
71
// General Variables
71
72
bool networkConnected = false ;
72
73
int currentScreen = 0 ; // 0 = Tally Screen, 1 = Settings Screen
73
- int currentBrightness = 11 ; // 12 is Max level on m5stickC but 100 on m5stickC-Plus
74
+ int currentBrightness = startBrightness ; // 12 is Max level on m5stickC but 100 on m5stickC-Plus
74
75
75
76
WiFiManager wm; // global wm instance
76
77
bool portalRunning = false ;
@@ -104,10 +105,14 @@ void setup() {
104
105
105
106
M5.begin ();
106
107
M5.Lcd .setRotation (3 );
107
- M5.Lcd .setCursor (0 , 20 );
108
108
M5.Lcd .fillScreen (TFT_BLACK);
109
+ #if C_PLUS == 1
110
+ M5.Lcd .setCursor (0 , 20 );
109
111
M5.Lcd .setFreeFont (FSS9);
110
- // M5.Lcd.setTextSize(2);
112
+ #else
113
+ M5.Lcd .setCursor (0 , 0 );
114
+ M5.Lcd .setTextSize (1 );
115
+ #endif
111
116
M5.Lcd .setTextColor (WHITE, BLACK);
112
117
M5.Lcd .println (" booting..." );
113
118
logger (" Tally Arbiter M5StickC Listener Client booting." , " info" );
@@ -226,6 +231,7 @@ void loop() {
226
231
}
227
232
}
228
233
234
+ //
229
235
void showSettings () {
230
236
currentScreen = 1 ;
231
237
logger (" showSettings()" , " info-quiet" );
@@ -234,10 +240,14 @@ void showSettings() {
234
240
portalRunning = true ;
235
241
236
242
// displays the current network connection and Tally Arbiter server data
237
- M5.Lcd .setCursor (0 , 20 );
238
243
M5.Lcd .fillScreen (TFT_BLACK);
244
+ #if C_PLUS == 1
245
+ M5.Lcd .setCursor (0 , 20 );
239
246
M5.Lcd .setFreeFont (FSS9);
240
- // M5.Lcd.setTextSize(1);
247
+ #else
248
+ M5.Lcd .setCursor (0 , 0 );
249
+ M5.Lcd .setTextSize (1 );
250
+ #endif
241
251
M5.Lcd .setTextColor (WHITE, BLACK);
242
252
M5.Lcd .println (" SSID: " + String (WiFi.SSID ()));
243
253
M5.Lcd .println (WiFi.localIP ());
@@ -265,30 +275,28 @@ void showDeviceInfo() {
265
275
}
266
276
267
277
M5.Lcd .fillScreen (TFT_BLACK);
278
+ #if C_PLUS == 1
268
279
M5.Lcd .setCursor (4 , 82 );
269
280
M5.Lcd .setFreeFont (FSS24);
270
- M5.Lcd .setTextColor (GREY, BLACK);
281
+ #else
282
+ M5.Lcd .setCursor (4 , 30 );
283
+ M5.Lcd .setTextSize (2 );
284
+ #endif
285
+ M5.Lcd .setTextColor (DARKGREY, BLACK);
271
286
M5.Lcd .println (DeviceName);
272
287
273
288
// displays the currently assigned device and tally data
274
289
evaluateMode ();
275
290
}
276
291
277
292
void updateBrightness () {
278
- #if C_PLUS == 1
279
- if (currentBrightness >= 100 ) {
280
- currentBrightness = 7 ;
293
+ if (currentBrightness >= maxBrightness) {
294
+ currentBrightness = startBrightness;
281
295
} else {
282
296
currentBrightness = currentBrightness + 10 ;
283
297
}
284
- #else
285
- if (currentBrightness >= 12 ) {
286
- currentBrightness = 7 ;
287
- } else {
288
- currentBrightness++;
289
- }
290
- #endif
291
- logger (" Set currentBrightness: " + String (currentBrightness), " info-quiet" );
298
+
299
+ logger (" Set brightness: " + String (currentBrightness), " info-quiet" );
292
300
M5.Axp .ScreenBreath (currentBrightness);
293
301
}
294
302
@@ -644,13 +652,19 @@ void SetDeviceName() {
644
652
preferences.putString (" devicename" , DeviceName);
645
653
preferences.end ();
646
654
evaluateMode ();
655
+ logger (" DeviceName: " + DeviceName, " info" );
647
656
}
648
657
649
658
void evaluateMode () {
650
659
if (actualType != prevType) {
660
+ #if C_PLUS == 1
651
661
M5.Lcd .setCursor (4 , 82 );
652
662
M5.Lcd .setFreeFont (FSS24);
663
+ #else
664
+ M5.Lcd .setCursor (4 , 30 );
653
665
// M5.Lcd.setTextSize(maxTextSize);
666
+ M5.Lcd .setTextSize (2 );
667
+ #endif
654
668
actualColor.replace (" #" , " " );
655
669
String hexstring = actualColor;
656
670
long number = (long ) strtol ( &hexstring[1 ], NULL , 16 );
@@ -663,7 +677,7 @@ void evaluateMode() {
663
677
M5.Lcd .fillScreen (M5.Lcd .color565 (r, g, b));
664
678
M5.Lcd .println (DeviceName);
665
679
} else {
666
- M5.Lcd .setTextColor (GREY , BLACK);
680
+ M5.Lcd .setTextColor (DARKGREY , BLACK);
667
681
M5.Lcd .fillScreen (TFT_BLACK);
668
682
M5.Lcd .println (DeviceName);
669
683
}
@@ -706,10 +720,14 @@ void checkReset() {
706
720
// poor mans debounce/press-hold, code not ideal for production
707
721
delay (50 );
708
722
if ( digitalRead (TRIGGER_PIN) == LOW ) {
709
- M5.Lcd .setCursor (0 , 40 );
710
723
M5.Lcd .fillScreen (TFT_BLACK);
724
+ #if C_PLUS == 1
725
+ M5.Lcd .setCursor (0 , 40 );
711
726
M5.Lcd .setFreeFont (FSS9);
712
- // M5.Lcd.setTextSize(1);
727
+ #else
728
+ M5.Lcd .setCursor (0 , 0 );
729
+ M5.Lcd .setTextSize (1 );
730
+ #endif
713
731
M5.Lcd .setTextColor (WHITE, BLACK);
714
732
M5.Lcd .println (" Reset button pushed...." );
715
733
logger (" Button Pressed" , " info" );
0 commit comments