4 digit LED Display Driver

I am sure I ordered some of these but i just got more just in case.
Will make nice addition to a RockPi case.
Thanks so much for making useful software.

So a kernel module or a character device in userspace.
What would be the best approach to send date to the display?
Lets say I want to see the current system time on the LED.(4 digit)
Hour and Minutes (24:H;00:M)
A dignified digital clock.

Doing my homework here I see this is the proper date command.
date '+%H:%M'
Looking at C code methods now.
 
Whittling down some stackoverflow code to get localtime...

Code:
#include <time.h>
#include <stdio.h>

int main(void)
{
    time_t t = time(NULL);
    printf("%s",asctime(localtime(&t)));
}

Did a tutorial based on time:
Code:
#include <stdio.h>
#include <time.h>

int main(void)
{
    time_t     now;
    struct tm *ts;
    char       buf[80];

    /* Get the current time */
    now = time(NULL);

    ts = localtime(&now);
    strftime(buf, sizeof(buf), "%H:%M", ts);
    puts(buf);

    return 0;
}
 
So from the above code I would need to write a program that checks time every second and updates the display every minute.
A time check daemon and then write output to device every minute.

Is that correct?
 
I am not a software architect so I have to ponder things.

One of my first instincts is to use a sleep 60 loop. Get time and Put time.
But for that to work you would want to sync with top of minute to keep display current.
 
Thanks for taking the time to document your work.
/examples/clock.sh
This seems like what I was looking for.
 
So a kernel module or a character device in userspace.
What would be the best approach to send date to the display?
They are the same in capabilities, but the cuse driver is more straightforward in the formation of bit sequences (by that time I was somehow tired of experimenting)
They both work well but the cuse one is newer, I like it better.
I am not a software architect so I have to ponder things.

One of my first instincts is to use a sleep 60 loop. Get time and Put time.
But for that to work you would want to sync with top of minute to keep display current.
Yes, and for blinking clockpoints.

And even more, for synchronously blinking the clockpoints with a GPS led if any.
The non-synchronization of that blinking was so annoying for me that I wrote a timer :)
 
So from the above code I would need to write a program that checks time every second and updates the display every minute.
A time check daemon and then write output to device every minute.

Is that correct?
In fact, every second and even twice per second, but most often you can only send one digit (second one, with clockpoints). After the minutes value has changed, you need to send all four.
 
For an example of how to make a user space clock in C, have a look at wmCalClock as an example, from here:-


See the while(1) loop in Src/wmCalClock.c. You can strip it down to the bare minimum to get the values you would need to send ot your device.
 
Back
Top