abstracting display, touch and sd

This commit is contained in:
Adolfo Reyna
2026-01-28 20:12:41 -05:00
parent 57426c6e7d
commit adfbef7228
396 changed files with 101836 additions and 272 deletions

View File

@@ -4,19 +4,45 @@
#include "ff.h"
#include "pico/stdlib.h"
#include <string.h>
// Parse compilation date/time macros
static int get_month_from_string(const char* month_str) {
const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
for (int i = 0; i < 12; i++) {
if (strncmp(month_str, months[i], 3) == 0) {
return i + 1;
}
}
return 1; // Default to January
}
/* Get current time */
DWORD get_fattime (void)
{
// Return a fixed timestamp (2024-01-01 00:00:00)
// In a real application, you would get this from an RTC
// Use compilation date/time from __DATE__ and __TIME__ macros
// __DATE__ format: "Jan 28 2026"
// __TIME__ format: "HH:MM:SS"
// Format: bit31:25=Year(0-127 +1980), bit24:21=Month(1-12), bit20:16=Day(1-31)
// bit15:11=Hour(0-23), bit10:5=Minute(0-59), bit4:0=Second/2(0-29)
return ((DWORD)(2024 - 1980) << 25) // Year: 2024
| ((DWORD)1 << 21) // Month: January
| ((DWORD)1 << 16) // Day: 1
| ((DWORD)0 << 11) // Hour: 0
| ((DWORD)0 << 5) // Minute: 0
| ((DWORD)0 >> 1); // Second: 0
// Parse __DATE__ (e.g., "Jan 28 2026")
char month_str[4] = {__DATE__[0], __DATE__[1], __DATE__[2], 0};
int day = (__DATE__[4] == ' ' ? 0 : (__DATE__[4] - '0') * 10) + (__DATE__[5] - '0');
int year = ((__DATE__[7] - '0') * 1000) + ((__DATE__[8] - '0') * 100) +
((__DATE__[9] - '0') * 10) + (__DATE__[10] - '0');
int month = get_month_from_string(month_str);
// Parse __TIME__ (e.g., "12:34:56")
int hour = ((__TIME__[0] - '0') * 10) + (__TIME__[1] - '0');
int minute = ((__TIME__[3] - '0') * 10) + (__TIME__[4] - '0');
int second = ((__TIME__[6] - '0') * 10) + (__TIME__[7] - '0');
return ((DWORD)(year - 1980) << 25)
| ((DWORD)month << 21)
| ((DWORD)day << 16)
| ((DWORD)hour << 11)
| ((DWORD)minute << 5)
| ((DWORD)(second / 2));
}