Automated update
This commit is contained in:
@@ -107,13 +107,17 @@ void update_time(int *framebuffer, struct fb_var_screeninfo vinfo) {
|
||||
time(&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
|
||||
// Correcting hour and minute hand angles
|
||||
float hour_angle = ((timeinfo->tm_hour % 12) * 30 + timeinfo->tm_min * 0.5) * (M_PI / 180.0) - M_PI / 2;
|
||||
float minute_angle = (timeinfo->tm_min * 6 + timeinfo->tm_sec * 0.1) * (M_PI / 180.0) - M_PI / 2;
|
||||
// Calculate the angle for the hour hand
|
||||
float hour_angle_degrees = (30 * timeinfo->tm_hour) + (timeinfo->tm_min * 0.5);
|
||||
float hour_angle = - hour_angle_degrees * M_PI / 180.0 + M_PI / 2; // Convert to radians and adjust to 12 o'clock start
|
||||
|
||||
// Draw both hands in black color
|
||||
draw_hand(framebuffer, vinfo, hour_angle, HOUR_HAND_LENGTH, 0x000000); // Hour hand in black
|
||||
draw_hand(framebuffer, vinfo, minute_angle, MINUTE_HAND_LENGTH, 0x000000); // Minute hand in black
|
||||
// Calculate the angle for the minute hand
|
||||
float minute_angle_degrees = 6 * timeinfo->tm_min;
|
||||
float minute_angle = - minute_angle_degrees * M_PI / 180.0 + M_PI / 2; // Convert to radians and adjust to 12 o'clock start
|
||||
|
||||
// Draw both hands in white (0xFFFFFF)
|
||||
draw_hand(framebuffer, vinfo, hour_angle, HOUR_HAND_LENGTH, 0xFFFFFF); // Hour hand is shorter
|
||||
draw_hand(framebuffer, vinfo, minute_angle, MINUTE_HAND_LENGTH, 0xFFFFFF); // Minute hand is longer
|
||||
|
||||
// Display the date
|
||||
strftime(date_buffer, sizeof(date_buffer), "%Y-%m-%d", timeinfo);
|
||||
@@ -124,7 +128,6 @@ void update_time(int *framebuffer, struct fb_var_screeninfo vinfo) {
|
||||
draw_text(framebuffer, vinfo, time_buffer, CENTER_X - 80, CENTER_Y + 350, 3, 0xFFFFFF); // Moved lower and increased size
|
||||
}
|
||||
|
||||
// Main function
|
||||
int main() {
|
||||
// Open the framebuffer device
|
||||
int fbfd = open("/dev/fb0", O_RDWR);
|
||||
|
||||
Reference in New Issue
Block a user