Skip to content

Commit 01977e4

Browse files
authored
Merge pull request #650 from Jocke4f/fix_m5stickc_listeners_cleanup
Update m5stickc-listener.ino
2 parents bb1654e + 83a8fe7 commit 01977e4

File tree

1 file changed

+39
-21
lines changed

1 file changed

+39
-21
lines changed

listener_clients/m5stickc-listener/m5stickc-listener.ino

+39-21
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
#define GREEN 0x0200 // 0 64 0
2222
#define RED 0xF800 // 255 0 0
2323
#define maxTextSize 5 //larger sourceName text
24-
24+
#define startBrightness 11
25+
#define maxBrightness 100
2526
// Name of the device - the 3 last bytes of the mac address will be appended to create a unique identifier for the server.
2627
String listenerDeviceName = "m5StickC-";
2728

@@ -70,7 +71,7 @@ String LastMessage = "";
7071
//General Variables
7172
bool networkConnected = false;
7273
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
7475

7576
WiFiManager wm; // global wm instance
7677
bool portalRunning = false;
@@ -104,10 +105,14 @@ void setup() {
104105

105106
M5.begin();
106107
M5.Lcd.setRotation(3);
107-
M5.Lcd.setCursor(0, 20);
108108
M5.Lcd.fillScreen(TFT_BLACK);
109+
#if C_PLUS == 1
110+
M5.Lcd.setCursor(0, 20);
109111
M5.Lcd.setFreeFont(FSS9);
110-
//M5.Lcd.setTextSize(2);
112+
#else
113+
M5.Lcd.setCursor(0, 0);
114+
M5.Lcd.setTextSize(1);
115+
#endif
111116
M5.Lcd.setTextColor(WHITE, BLACK);
112117
M5.Lcd.println("booting...");
113118
logger("Tally Arbiter M5StickC Listener Client booting.", "info");
@@ -226,6 +231,7 @@ void loop() {
226231
}
227232
}
228233

234+
//
229235
void showSettings() {
230236
currentScreen = 1;
231237
logger("showSettings()", "info-quiet");
@@ -234,10 +240,14 @@ void showSettings() {
234240
portalRunning = true;
235241

236242
//displays the current network connection and Tally Arbiter server data
237-
M5.Lcd.setCursor(0, 20);
238243
M5.Lcd.fillScreen(TFT_BLACK);
244+
#if C_PLUS == 1
245+
M5.Lcd.setCursor(0, 20);
239246
M5.Lcd.setFreeFont(FSS9);
240-
//M5.Lcd.setTextSize(1);
247+
#else
248+
M5.Lcd.setCursor(0, 0);
249+
M5.Lcd.setTextSize(1);
250+
#endif
241251
M5.Lcd.setTextColor(WHITE, BLACK);
242252
M5.Lcd.println("SSID: " + String(WiFi.SSID()));
243253
M5.Lcd.println(WiFi.localIP());
@@ -265,30 +275,28 @@ void showDeviceInfo() {
265275
}
266276

267277
M5.Lcd.fillScreen(TFT_BLACK);
278+
#if C_PLUS == 1
268279
M5.Lcd.setCursor(4, 82);
269280
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);
271286
M5.Lcd.println(DeviceName);
272287

273288
//displays the currently assigned device and tally data
274289
evaluateMode();
275290
}
276291

277292
void updateBrightness() {
278-
#if C_PLUS == 1
279-
if (currentBrightness >= 100) {
280-
currentBrightness = 7;
293+
if (currentBrightness >= maxBrightness) {
294+
currentBrightness = startBrightness;
281295
} else {
282296
currentBrightness = currentBrightness + 10;
283297
}
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");
292300
M5.Axp.ScreenBreath(currentBrightness);
293301
}
294302

@@ -644,13 +652,19 @@ void SetDeviceName() {
644652
preferences.putString("devicename", DeviceName);
645653
preferences.end();
646654
evaluateMode();
655+
logger("DeviceName: " + DeviceName, "info");
647656
}
648657

649658
void evaluateMode() {
650659
if (actualType != prevType) {
660+
#if C_PLUS == 1
651661
M5.Lcd.setCursor(4, 82);
652662
M5.Lcd.setFreeFont(FSS24);
663+
#else
664+
M5.Lcd.setCursor(4, 30);
653665
//M5.Lcd.setTextSize(maxTextSize);
666+
M5.Lcd.setTextSize(2);
667+
#endif
654668
actualColor.replace("#", "");
655669
String hexstring = actualColor;
656670
long number = (long) strtol( &hexstring[1], NULL, 16);
@@ -663,7 +677,7 @@ void evaluateMode() {
663677
M5.Lcd.fillScreen(M5.Lcd.color565(r, g, b));
664678
M5.Lcd.println(DeviceName);
665679
} else {
666-
M5.Lcd.setTextColor(GREY, BLACK);
680+
M5.Lcd.setTextColor(DARKGREY, BLACK);
667681
M5.Lcd.fillScreen(TFT_BLACK);
668682
M5.Lcd.println(DeviceName);
669683
}
@@ -706,10 +720,14 @@ void checkReset() {
706720
// poor mans debounce/press-hold, code not ideal for production
707721
delay(50);
708722
if ( digitalRead(TRIGGER_PIN) == LOW ) {
709-
M5.Lcd.setCursor(0, 40);
710723
M5.Lcd.fillScreen(TFT_BLACK);
724+
#if C_PLUS == 1
725+
M5.Lcd.setCursor(0, 40);
711726
M5.Lcd.setFreeFont(FSS9);
712-
//M5.Lcd.setTextSize(1);
727+
#else
728+
M5.Lcd.setCursor(0, 0);
729+
M5.Lcd.setTextSize(1);
730+
#endif
713731
M5.Lcd.setTextColor(WHITE, BLACK);
714732
M5.Lcd.println("Reset button pushed....");
715733
logger("Button Pressed", "info");

0 commit comments

Comments
 (0)