Added extra characters to Countdown label

This commit is contained in:
M-Factory
2025-10-30 14:58:26 +09:00
parent c7aaba6950
commit a722d2ebaf
6 changed files with 126 additions and 82 deletions

View File

@@ -392,6 +392,14 @@ void connectWiFi() {
// --- IP Display initiation ---
pendingIpToShow = WiFi.localIP().toString();
// Replace all dots with your custom font code 184
for (int i = 0; i < pendingIpToShow.length(); i++) {
if (pendingIpToShow[i] == '.') {
pendingIpToShow[i] = 184;
}
}
showingIp = true;
ipDisplayCount = 0; // Reset count for IP display
P.displayClear();
@@ -1944,11 +1952,11 @@ void loop() {
errorAltTimer = millis();
showNtpError = !showNtpError;
}
P.print(showNtpError ? F("?/") : F("?*"));
P.print(showNtpError ? F("(<") : F("(*"));
} else if (!ntpSyncSuccessful) {
P.print(F("?/"));
P.print(F("(<"));
} else if (!weatherAvailable) {
P.print(F("?*"));
P.print(F("(*"));
}
}
// --- DISPLAY CLOCK ---
@@ -2024,7 +2032,7 @@ void loop() {
} else {
P.setCharSpacing(0);
P.setTextAlignment(PA_CENTER);
P.print(F("?*"));
P.print(F("(*"));
}
}
yield();
@@ -2321,6 +2329,15 @@ void loop() {
if (strlen(countdownLabel) > 0) {
label = String(countdownLabel);
label.trim();
// Replace standard digits 09 with your custom font character codes
for (int i = 0; i < label.length(); i++) {
if (isDigit(label[i])) {
int num = label[i] - '0'; // 09
label[i] = 145 + ((num + 9) % 10); // Maps 0→154, 1→145, ... 9→153
}
}
} else {
static const char *fallbackLabels[] = {
"PARTY TIME", "SHOWTIME", "CLOCKOUT", "BLASTOFF",
@@ -2342,6 +2359,11 @@ void loop() {
String fullString = String(buf);
// --- Add a leading space only if showDayOfWeek is true ---
if (showDayOfWeek) {
fullString = " " + fullString;
}
// Display the full string and scroll it
P.setTextAlignment(PA_LEFT);
P.setCharSpacing(1);
@@ -2473,7 +2495,7 @@ void loop() {
// Build display text
String displayText = "";
if (isOutdated) displayText += "º"; // add warning first
if (isOutdated) displayText += char(186); // add warning first
displayText += String(currentGlucose) + String(arrow);
P.setTextAlignment(PA_CENTER);
@@ -2486,7 +2508,7 @@ void loop() {
} else {
P.setTextAlignment(PA_CENTER);
P.setCharSpacing(0);
P.print(F("?)"));
P.print(F("())"));
delay(2000);
advanceDisplayMode();
return;

View File

@@ -616,12 +616,12 @@ textarea::placeholder {
</div>
</div>
<div class="form-group">
<label for="countdownLabel">Countdown Label (Optional):</label>
<input type="text" id="countdownLabel" name="countdownLabel" class="form-control"
placeholder="e.g., BIRTHDAY, VACATION" maxlength="24"
pattern="[A-Z0-9 :!'.\-]*"
title="Only uppercase letters, numbers, space, and : ! ' - . allowed">
<div class="small">Only uppercase letters, numbers, space, and : ! ' - . allowed</div>
<label for="countdownLabel">Countdown Label (Optional):</label>
<input type="text" id="countdownLabel" name="countdownLabel" class="form-control"
placeholder="e.g., BIRTHDAY, VACATION" maxlength="24"
pattern="[A-Z0-9 :!'\-.,_\+%\/?]*"
title="Only uppercase letters, numbers, space, and : ! ' - . , _ + % / ? allowed">
<div class="small">Only uppercase letters, numbers, space, and : ! ' - . ? , _ + % / allowed</div>
</div>
</div>
</div>
@@ -763,11 +763,11 @@ window.onload = function () {
countdownLabelInput.addEventListener('input', function() {
// Convert to uppercase and remove any characters that are not A-Z or space
// Note: The `maxlength` attribute in HTML handles the length limit.
this.value = this.value.toUpperCase().replace(/[^A-Z0-9 :!'.\-]/g, '');
this.value = this.value.toUpperCase().replace(/[^A-Z0-9 :!'\-.,_\+%\/?]/g, '');
});
// Set initial value for countdownLabel from config.json (apply validation on load too)
if (data.countdown && data.countdown.label) {
countdownLabelInput.value = data.countdown.label.toUpperCase().replace(/[^A-Z0-9 :!'.\-]/g, '');
countdownLabelInput.value = data.countdown.label.toUpperCase().replace(/[^A-Z0-9 :!'\-.,_\+%\/?]/g, '');
} else {
countdownLabelInput.value = '';
}
@@ -882,7 +882,7 @@ async function submitConfig(event) {
// Date and Time inputs are already handled by formData if they have a 'name' attribute
// 'countdownDate' and 'countdownTime' are collected automatically
// Also apply the same validation for the label when submitting
const finalCountdownLabel = document.getElementById('countdownLabel').value.toUpperCase().replace(/[^A-Z0-9 :!'.\-]/g, '');
const finalCountdownLabel = document.getElementById('countdownLabel').value.toUpperCase().replace(/[^A-Z0-9 :!'\-.,_\+%\/?]/g, '');
formData.set('countdownLabel', finalCountdownLabel);
// --- END NEW ---

View File

@@ -40,19 +40,19 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
1, 0, // 34 - '""'
13, 63, 192, 127, 192, 63, 0, 250, 0, 255, 9, 1, 0, 250, // 35 - '#'
16, 72, 84, 36, 0, 12, 112, 12, 0, 124, 4, 120, 0, 56, 68, 68, 0, // 36 - '$'
6, 66, 37, 18, 72, 164, 66, // 37 - '%'
6, 6, 70, 48, 12, 98, 96, // 37 - '%'
1, 1, // 38 - '&'
1, 6, // 39 - ''
13, 254, 17, 17, 254, 0, 126, 129, 65, 190, 0, 129, 255, 129, // 40 - '('
7, 124, 254, 254, 162, 254, 254, 254, // 40 - '('
17, 130, 186, 198, 254, 134, 234, 134, 254, 250, 130, 250, 254, 134, 234, 134, 254, 124, // 41 - ')'
20, 250, 130, 250, 254, 130, 170, 186, 254, 130, 250, 226, 250, 134, 254, 130, 234, 234, 246, 254, 124, // 42 - '*'
1, 0, // 43 - '+'
3, 64, 0, 0, // 44 - ','
2, 8, 8, // 45 - '-'
1, 128, // 46 - '.'
15, 130, 246, 238, 130, 254, 250, 130, 250, 254, 130, 234, 234, 246, 254, 124, // 47 - '/'
5, 8, 8, 62, 8, 8, // 43 - '+'
1, 192, // 44 - ','
2, 8, 8, // 45 - '-'
1, 64, // 46 - '.'
3, 96, 24, 6, // 47 - '/'
3, 126, 129, 126, // 48 - '0'
3, 130, 255, 128, // 49 - '1'
3, 130, 255, 128, // 49 - '1'
3, 194, 177, 142, // 50 - '2'
3, 66, 137, 118, // 51 - '3'
3, 15, 8, 255, // 52 - '4'
@@ -63,10 +63,10 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
3, 78, 145, 126, // 57 - '9'
1, 36, // 58 - ':'
1, 0, // 59 - ';'
1, 0, // 60 - '<'
15, 130, 246, 238, 130, 254, 250, 130, 250, 254, 130, 234, 234, 246, 254, 124, // 60 - '<'
9, 254, 17, 17, 254, 0, 255, 17, 17, 14, // 61 - '='
1, 0, // 62 - '>'
7, 124, 254, 254, 162, 254, 254, 254, // 63 - '?'
3, 4, 82, 12, // 63 - '?'
1, 250, // 64 - '@'
3, 124, 10, 124, // 65 - 'A'
3, 126, 74, 52, // 66 - 'B'
@@ -98,7 +98,7 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
3, 6, 28, 48, // 92 - '\'
4, 255, 9, 9, 1, // 93 - ']'
1, 8, // 94 - '^'
3, 32, 32, 32, // 95 - '_'
2, 64, 64, // 95 - '_'
4, 255, 8, 20, 227, // 96 - '`'
3, 249, 21, 249, // 97 - 'a'
3, 253, 149, 105, // 98 - 'b'
@@ -187,7 +187,7 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
7, 68, 36, 20, 254, 20, 36, 68, // 181 - 'µ'
7, 168, 232, 172, 250, 172, 232, 168, // 182 - '¶'
7, 128, 136, 136, 254, 136, 136, 128, // 183 - '·'
0, // 184 - '¸'
1, 128, // 184 - '¸'
0, // 185 - '¹'
3, 4, 10, 4, // 186 - 'º'
0, // 187 - '»'
@@ -197,17 +197,17 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
0, // 191 - '¿'
0, // 192 - 'À'
0, // 193 - 'Á'
0, // 194 - 'Â'
0, // 195 - 'Ã'
0, // 196 - 'Ä'
0, // 197 - 'Å'
0, // 198 - 'Æ'
0, // 199 - 'Ç'
0, // 200 - 'È'
0, // 201 - 'É'
0, // 202 - 'Ê'
0, // 203 - 'Ë'
0, // 204 - 'Ì'
0, // 194 - 'Â'
3, 138, 255, 136, // 195 - 'Ã'
3, 202, 185, 142, // 196 - 'Ä'
3, 74, 137, 126, // 197 - 'Å'
3, 15, 8, 255, // 198 - 'Æ'
3, 79, 137, 121, // 199 - 'Ç'
3, 126, 137, 122, // 200 - 'È'
3, 9, 249, 15, // 201 - 'É'
3, 126, 137, 126, // 202 - 'Ê'
3, 78, 153, 126, // 203 - 'Ë'
3, 126, 129, 126, // 204 - 'Ì'
0, // 205 - 'Í'
0, // 206 - 'Î'
0, // 207 - 'Ï'
@@ -224,8 +224,8 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
0, // 218 - 'Ú'
0, // 219 - 'Û'
0, // 220 - 'Ü'
0, // 221 - 'Ý'
0, // 222 - 'Þ'
0, // 221 - 'Ý'
0, // 222 - 'Þ'
0, // 223 - 'ß'
0, // 224 - 'à'
0, // 225 - 'á'
@@ -258,5 +258,5 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
0, // 252 - 'ü'
0, // 253 - 'ý'
0, // 254 - 'þ'
0, // 255 - 'ÿ'
1, 8, // 255 - 'ÿ'
};

View File

@@ -394,6 +394,14 @@ void connectWiFi() {
// --- IP Display initiation ---
pendingIpToShow = WiFi.localIP().toString();
// Replace all dots with your custom font code 184
for (int i = 0; i < pendingIpToShow.length(); i++) {
if (pendingIpToShow[i] == '.') {
pendingIpToShow[i] = 184;
}
}
showingIp = true;
ipDisplayCount = 0; // Reset count for IP display
P.displayClear();
@@ -1938,11 +1946,11 @@ void loop() {
errorAltTimer = millis();
showNtpError = !showNtpError;
}
P.print(showNtpError ? F("?/") : F("?*"));
P.print(showNtpError ? F("(<") : F("(*"));
} else if (!ntpSyncSuccessful) {
P.print(F("?/"));
P.print(F("(<"));
} else if (!weatherAvailable) {
P.print(F("?*"));
P.print(F("(*"));
}
}
// --- DISPLAY CLOCK ---
@@ -2016,7 +2024,7 @@ void loop() {
} else {
P.setCharSpacing(0);
P.setTextAlignment(PA_CENTER);
P.print(F("?*"));
P.print(F("(*"));
}
}
yield();
@@ -2311,6 +2319,15 @@ void loop() {
if (strlen(countdownLabel) > 0) {
label = String(countdownLabel);
label.trim();
// Replace standard digits 09 with your custom font character codes
for (int i = 0; i < label.length(); i++) {
if (isDigit(label[i])) {
int num = label[i] - '0'; // 09
label[i] = 145 + ((num + 9) % 10); // Maps 0→154, 1→145, ... 9→153
}
}
} else {
static const char *fallbackLabels[] = {
"PARTY TIME", "SHOWTIME", "CLOCKOUT", "BLASTOFF",
@@ -2332,6 +2349,11 @@ void loop() {
String fullString = String(buf);
// --- Add a leading space only if showDayOfWeek is true ---
if (showDayOfWeek) {
fullString = " " + fullString;
}
// Display the full string and scroll it
P.setTextAlignment(PA_LEFT);
P.setCharSpacing(1);
@@ -2464,7 +2486,7 @@ void loop() {
// Build display text
String displayText = "";
if (isOutdated) displayText += "º"; // add warning first
if (isOutdated) displayText += char(186); // add warning first
displayText += String(currentGlucose) + String(arrow);
P.setTextAlignment(PA_CENTER);
@@ -2477,7 +2499,7 @@ void loop() {
} else {
P.setTextAlignment(PA_CENTER);
P.setCharSpacing(0);
P.print(F("?)"));
P.print(F("())"));
delay(2000);
advanceDisplayMode();
return;

View File

@@ -616,12 +616,12 @@ textarea::placeholder {
</div>
</div>
<div class="form-group">
<label for="countdownLabel">Countdown Label (Optional):</label>
<input type="text" id="countdownLabel" name="countdownLabel" class="form-control"
placeholder="e.g., BIRTHDAY, VACATION" maxlength="24"
pattern="[A-Z0-9 :!'.\-]*"
title="Only uppercase letters, numbers, space, and : ! ' - . allowed">
<div class="small">Only uppercase letters, numbers, space, and : ! ' - . allowed</div>
<label for="countdownLabel">Countdown Label (Optional):</label>
<input type="text" id="countdownLabel" name="countdownLabel" class="form-control"
placeholder="e.g., BIRTHDAY, VACATION" maxlength="24"
pattern="[A-Z0-9 :!'\-.,_\+%\/?]*"
title="Only uppercase letters, numbers, space, and : ! ' - . , _ + % / ? allowed">
<div class="small">Only uppercase letters, numbers, space, and : ! ' - . ? , _ + % / allowed</div>
</div>
</div>
</div>
@@ -763,11 +763,11 @@ window.onload = function () {
countdownLabelInput.addEventListener('input', function() {
// Convert to uppercase and remove any characters that are not A-Z or space
// Note: The `maxlength` attribute in HTML handles the length limit.
this.value = this.value.toUpperCase().replace(/[^A-Z0-9 :!'.\-]/g, '');
this.value = this.value.toUpperCase().replace(/[^A-Z0-9 :!'\-.,_\+%\/?]/g, '');
});
// Set initial value for countdownLabel from config.json (apply validation on load too)
if (data.countdown && data.countdown.label) {
countdownLabelInput.value = data.countdown.label.toUpperCase().replace(/[^A-Z0-9 :!'.\-]/g, '');
countdownLabelInput.value = data.countdown.label.toUpperCase().replace(/[^A-Z0-9 :!'\-.,_\+%\/?]/g, '');
} else {
countdownLabelInput.value = '';
}
@@ -882,7 +882,7 @@ async function submitConfig(event) {
// Date and Time inputs are already handled by formData if they have a 'name' attribute
// 'countdownDate' and 'countdownTime' are collected automatically
// Also apply the same validation for the label when submitting
const finalCountdownLabel = document.getElementById('countdownLabel').value.toUpperCase().replace(/[^A-Z0-9 :!'.\-]/g, '');
const finalCountdownLabel = document.getElementById('countdownLabel').value.toUpperCase().replace(/[^A-Z0-9 :!'\-.,_\+%\/?]/g, '');
formData.set('countdownLabel', finalCountdownLabel);
// --- END NEW ---

View File

@@ -40,19 +40,19 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
1, 0, // 34 - '""'
13, 63, 192, 127, 192, 63, 0, 250, 0, 255, 9, 1, 0, 250, // 35 - '#'
16, 72, 84, 36, 0, 12, 112, 12, 0, 124, 4, 120, 0, 56, 68, 68, 0, // 36 - '$'
6, 66, 37, 18, 72, 164, 66, // 37 - '%'
6, 6, 70, 48, 12, 98, 96, // 37 - '%'
1, 1, // 38 - '&'
1, 6, // 39 - ''
13, 254, 17, 17, 254, 0, 126, 129, 65, 190, 0, 129, 255, 129, // 40 - '('
7, 124, 254, 254, 162, 254, 254, 254, // 40 - '('
17, 130, 186, 198, 254, 134, 234, 134, 254, 250, 130, 250, 254, 134, 234, 134, 254, 124, // 41 - ')'
20, 250, 130, 250, 254, 130, 170, 186, 254, 130, 250, 226, 250, 134, 254, 130, 234, 234, 246, 254, 124, // 42 - '*'
1, 0, // 43 - '+'
3, 64, 0, 0, // 44 - ','
2, 8, 8, // 45 - '-'
1, 128, // 46 - '.'
15, 130, 246, 238, 130, 254, 250, 130, 250, 254, 130, 234, 234, 246, 254, 124, // 47 - '/'
5, 8, 8, 62, 8, 8, // 43 - '+'
1, 192, // 44 - ','
2, 8, 8, // 45 - '-'
1, 64, // 46 - '.'
3, 96, 24, 6, // 47 - '/'
3, 126, 129, 126, // 48 - '0'
3, 130, 255, 128, // 49 - '1'
3, 130, 255, 128, // 49 - '1'
3, 194, 177, 142, // 50 - '2'
3, 66, 137, 118, // 51 - '3'
3, 15, 8, 255, // 52 - '4'
@@ -63,10 +63,10 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
3, 78, 145, 126, // 57 - '9'
1, 36, // 58 - ':'
1, 0, // 59 - ';'
1, 0, // 60 - '<'
15, 130, 246, 238, 130, 254, 250, 130, 250, 254, 130, 234, 234, 246, 254, 124, // 60 - '<'
9, 254, 17, 17, 254, 0, 255, 17, 17, 14, // 61 - '='
1, 0, // 62 - '>'
7, 124, 254, 254, 162, 254, 254, 254, // 63 - '?'
3, 4, 82, 12, // 63 - '?'
1, 250, // 64 - '@'
3, 124, 10, 124, // 65 - 'A'
3, 126, 74, 52, // 66 - 'B'
@@ -98,7 +98,7 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
3, 6, 28, 48, // 92 - '\'
4, 255, 9, 9, 1, // 93 - ']'
1, 8, // 94 - '^'
3, 32, 32, 32, // 95 - '_'
2, 64, 64, // 95 - '_'
4, 255, 8, 20, 227, // 96 - '`'
3, 249, 21, 249, // 97 - 'a'
3, 253, 149, 105, // 98 - 'b'
@@ -187,7 +187,7 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
7, 68, 36, 20, 254, 20, 36, 68, // 181 - 'µ'
7, 168, 232, 172, 250, 172, 232, 168, // 182 - '¶'
7, 128, 136, 136, 254, 136, 136, 128, // 183 - '·'
0, // 184 - '¸'
1, 128, // 184 - '¸'
0, // 185 - '¹'
3, 4, 10, 4, // 186 - 'º'
0, // 187 - '»'
@@ -197,17 +197,17 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
0, // 191 - '¿'
0, // 192 - 'À'
0, // 193 - 'Á'
0, // 194 - 'Â'
0, // 195 - 'Ã'
0, // 196 - 'Ä'
0, // 197 - 'Å'
0, // 198 - 'Æ'
0, // 199 - 'Ç'
0, // 200 - 'È'
0, // 201 - 'É'
0, // 202 - 'Ê'
0, // 203 - 'Ë'
0, // 204 - 'Ì'
0, // 194 - 'Â'
3, 138, 255, 136, // 195 - 'Ã'
3, 202, 185, 142, // 196 - 'Ä'
3, 74, 137, 126, // 197 - 'Å'
3, 15, 8, 255, // 198 - 'Æ'
3, 79, 137, 121, // 199 - 'Ç'
3, 126, 137, 122, // 200 - 'È'
3, 9, 249, 15, // 201 - 'É'
3, 126, 137, 126, // 202 - 'Ê'
3, 78, 153, 126, // 203 - 'Ë'
3, 126, 129, 126, // 204 - 'Ì'
0, // 205 - 'Í'
0, // 206 - 'Î'
0, // 207 - 'Ï'
@@ -224,8 +224,8 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
0, // 218 - 'Ú'
0, // 219 - 'Û'
0, // 220 - 'Ü'
0, // 221 - 'Ý'
0, // 222 - 'Þ'
0, // 221 - 'Ý'
0, // 222 - 'Þ'
0, // 223 - 'ß'
0, // 224 - 'à'
0, // 225 - 'á'
@@ -258,5 +258,5 @@ MD_MAX72XX::fontType_t mFactory[] PROGMEM =
0, // 252 - 'ü'
0, // 253 - 'ý'
0, // 254 - 'þ'
0, // 255 - 'ÿ'
1, 8, // 255 - 'ÿ'
};