I see, that's possible.
Please choose, which way you prefer:
1. The driver is not really handled as driver, but it's components are called
(like the last one I made:
DRV_Generic_Init() calls CLOCK_Init();
DRV_AppendInformationToHTTPIndexPage() calls CLOCK_AppendInformationToHTTPIndexPage();
DRV_OnEverySecond() calls CLOCK_OnEverySecond();
)
2. "Extend" the drivers to generally allow for "hidden" drivers (running, but not shown) or, a completely new idea
3. Distinguish between started and auto-started drivers (e.g. BL0937 is also started without an explicit "startdriver BL0937").
While thinking of it, it needs another name like "started by system" to avoid mixing with "automatically started" by startup cmd or autoexec.
Added after 9 [hours] 38 [minutes]:
Since I got my MAX7219 display this weekend, I tried your project (on a W800).
Maybe you would like to use some of my changes, too?!?
I missed "seconds" on display, but the numbers wouldn't fit on the display. So I made some changes and additions to the font used.
Here is the changed part of the "font" in drv_max72xx_single.c
- small digits in unused chars 10 to 19 (allows for seconds and a (two digit) year on 4 8x8 displays)
- made "." smaller (46)
- made digits smaller (4 columns) but same width for all (no "jump" e.g. from "0" to "1" or "1" to "2")
to use the "small" numbers, the string needs to be "transposed" by -38, so e.g. digit 0 is not using 48 but 10.
In drv_max72xx_clock.c an additional function:
and this output (no temperature here atm), so, just for testing, I display only time and date.
I used sprintf to print the data, to "seperate" two chars by another empty columns, I used char "127" (this has 0 columns, so only the one after this empty char is written).
Seconds and year are first printed to a string, which is transposed to use the small numbers I added to the font.
Here's how it looks (demonstrating also the setting of the clock):
Please choose, which way you prefer:
1. The driver is not really handled as driver, but it's components are called
(like the last one I made:
DRV_Generic_Init() calls CLOCK_Init();
DRV_AppendInformationToHTTPIndexPage() calls CLOCK_AppendInformationToHTTPIndexPage();
DRV_OnEverySecond() calls CLOCK_OnEverySecond();
)
2. "Extend" the drivers to generally allow for "hidden" drivers (running, but not shown) or, a completely new idea
3. Distinguish between started and auto-started drivers (e.g. BL0937 is also started without an explicit "startdriver BL0937").
While thinking of it, it needs another name like "started by system" to avoid mixing with "automatically started" by startup cmd or autoexec.
Added after 9 [hours] 38 [minutes]:
Since I got my MAX7219 display this weekend, I tried your project (on a W800).
Maybe you would like to use some of my changes, too?!?
I missed "seconds" on display, but the numbers wouldn't fit on the display. So I made some changes and additions to the font used.
Here is the changed part of the "font" in drv_max72xx_single.c
- small digits in unused chars 10 to 19 (allows for seconds and a (two digit) year on 4 8x8 displays)
- made "." smaller (46)
- made digits smaller (4 columns) but same width for all (no "jump" e.g. from "0" to "1" or "1" to "2")
Spoiler:
0, // 6 - Unused
0, // 7 - Unused
0, // 8 - Unused
0, // 9 - Unused
3, 124, 68, 124, // 10 - 0 mini
3, 0, 124, 0, // 11 - 1 mini
3, 116, 84, 92, // 12 - 2 mini
3, 84, 84, 124, // 13 - 3 mini
3, 28, 16, 124, // 14 - 4 mini
3, 92, 84, 116, // 15 - 5 mini
3, 124, 84, 116, // 16 - 6 mini
3, 4, 116, 12, // 17 - 7 mini
3, 124, 84, 124, // 18 - 8 mini
3, 92, 84, 124, // 19 - 9 mini
0, // 20 - Unused
0, // 21 - Unused
0, // 22 - Unused
0, // 23 - Unused
0, // 24 - Unused
0, // 25 - Unused
0, // 26 - Unused
0, // 27 - Unused
0, // 28 - Unused
0, // 29 - Unused
0, // 30 - Unused
0, // 31 - Unused
2, 0, 0, // 32 - Space
1, 95, // 33 - !
3, 7, 0, 7, // 34 - "
5, 20, 127, 20, 127, 20, // 35 - #
5, 36, 42, 127, 42, 18, // 36 - $
5, 35, 19, 8, 100, 98, // 37 - %
5, 54, 73, 86, 32, 80, // 38 - &
2, 4, 3, // 39
3, 28, 34, 65, // 40 - (
3, 65, 34, 28, // 41 - )
5, 42, 28, 127, 28, 42, // 42 - *
5, 8, 8, 62, 8, 8, // 43 - +
2, 128, 96, // 44 - ,
5, 8, 8, 8, 8, 8, // 45 - -
// 2, 96, 96, // 46 - .
1, 64, // 46 - . (smaller . )
5, 32, 16, 8, 4, 2, // 47 - /
4, 62, 65, 65, 62, // 48 - 0 (4-column small)
4, 0, 66, 127, 64, // 49 - 1 (4-column small)
4, 114, 73, 73, 70, // 50 - 2 (4-column small)
4, 34, 73, 73, 62, // 51 - 3 (4-column small)
4, 12, 10, 127, 8, // 52 - 4 (4-column small)
4, 39, 73, 73, 49, // 53 - 5 (4-column small)
4, 62, 73, 73, 50, // 54 - 6 (4-column small)
4, 1, 121, 5, 3, // 55 - 7 (4-column small)
4, 54, 73, 73, 54, // 56 - 8 (4-column small)
4, 38, 73, 73, 62, // 57 - 9 (4-column small)
1, 20, // 58 - :
2, 128, 104, // 59 - ;
4, 8, 20, 34, 65, // 60 - <
5, 20, 20, 20, 20, 20, // 61 - =
to use the "small" numbers, the string needs to be "transposed" by -38, so e.g. digit 0 is not using 48 but 10.
In drv_max72xx_clock.c an additional function:
void transposeString(char *input, int shift) {
for (int i = 0; i < strlen(input); i++) {
input[i] += shift; // Shift each character by the specified amount
}
}
and this output (no temperature here atm), so, just for testing, I display only time and date.
I used sprintf to print the data, to "seperate" two chars by another empty columns, I used char "127" (this has 0 columns, so only the one after this empty char is written).
Seconds and year are first printed to a string, which is transposed to use the small numbers I added to the font.
void Clock_Send(int type) {
char time[64];
TimeComponents tc;
float val;
char *p;
time_t ntpTime;
ntpTime=(time_t)TIME_GetCurrentTime();
// NOTE: on windows, you need _USE_32BIT_TIME_T
tc=calculateComponents((uint32_t)ntpTime);
time[0] = 0;
p = time;
char tempstr[5]; // temp string for seconds or year -> converted to "small" digits
if (type == CLOCK_TIME) {
/*
// p = my_strcat(p, " ");
p = add_padded(p, tc.hour);
p = my_strcat(p, " ");
// p = my_strcat(p, ":");
p = add_padded(p, tc.minute);
p = my_strcat(p, " ");
// p = my_strcat(p, ":");
p = add_padded(p, tc.second);
strcat(p, " ");
*/
sprintf(tempstr,"%02i",tc.second);
transposeString(tempstr, -38); // move second digits from 48 - 57 --> 10 - 19 (small numbers)
sprintf(time,"%02i:%02i%c%s", tc.hour,tc.minute, 127, tempstr);
}
else if (type == CLOCK_DATE) {
/*
// p = my_strcat(p, " ");
p = add_padded(p, tc.day);
p = my_strcat(p, ".");
p = add_padded(p, tc.month);
p = my_strcat(p, ".");
//p = add_padded(p, tc.year);
strcat(p, " ");
*/
sprintf(tempstr,"%02i",(tc.year%100));
transposeString(tempstr, -38); // move year digits from 48 - 57 --> 10 - 19 (small numbers)
sprintf(time,"%02i.%02i.%c%s", tc.day,tc.month, 127, tempstr);
}
else if (type == CLOCK_HUMIDITY) {
if (false==CHANNEL_GetGenericHumidity(&val)) {
// failed - exit early, do not change string
return;
}
sprintf(time, "H: %i%% ", (int)val);
}
else if (type == CLOCK_TEMPERATURE) {
if (false == CHANNEL_GetGenericTemperature(&val)) {
// failed - exit early, do not change string
return;
}
sprintf(time, "T: %iC ", (int)val);
}
CMD_ExecuteCommandArgs("MAX72XX_Print", time, 0);
}
...
// no temperature, so only show date (shorter) and time (longer)
void Run_NoAnimation() {
cycle+=4;
if (cycle < 10) {
Clock_SendDate();
}
// else if(cycle < 20) {
else {
Clock_SendTime();
}
/*
else if (cycle < 30) {
Clock_SendHumidity();
}
else {
Clock_SendTemperature();
}
*/
CMD_ExecuteCommandArgs("MAX72XX_refresh", "", 0);
cycle %= 40;
}Here's how it looks (demonstrating also the setting of the clock):