Scrolling text now in function and with a 'slide in' from right
This commit is contained in:
parent
8261c3ecef
commit
ad5eff49be
|
@ -22,7 +22,10 @@
|
|||
int fd;
|
||||
int screensaver;
|
||||
int brightness = 4;
|
||||
int offset = 0;
|
||||
char *fifo;
|
||||
char *pausemsg = NULL;
|
||||
|
||||
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_t thread1;
|
||||
|
||||
|
@ -105,17 +108,17 @@ char display_set_timer[] = { 0x1F, 0x54 };
|
|||
#define TIME_BASE 200000
|
||||
#define TB_TO_SECS(x) (x*1000000/TIME_BASE)
|
||||
|
||||
#define TIME_CLOCK TB_TO_SECS(25)
|
||||
#define TIME_CLOCK TB_TO_SECS(5)
|
||||
#define TIME_DIM TB_TO_SECS(90)
|
||||
#define TIME_OFF TB_TO_SECS(320)
|
||||
|
||||
#define DEVICE "/dev/ttyUSB0"
|
||||
|
||||
#define PAUSEMSG "Hallo, bitte melde Dich am Barcodereader an, um das Kassensystem zu benutzen *** "
|
||||
|
||||
// chars per line in our display:
|
||||
#define LINELEN 20
|
||||
|
||||
|
||||
void
|
||||
display_write (const void *buf, size_t count)
|
||||
{
|
||||
|
@ -252,6 +255,36 @@ sighandler (int sig)
|
|||
//signal(sig, sighandler);
|
||||
}
|
||||
|
||||
void scrolltext(){
|
||||
|
||||
if (pausemsg){
|
||||
char *message = calloc (LINELEN + 1, sizeof (char));
|
||||
|
||||
int spaces=0;
|
||||
|
||||
if (offset<LINELEN){
|
||||
spaces = LINELEN-offset; //anzahl spaces im ersten durchgang
|
||||
memset(message , ' ', spaces);
|
||||
}
|
||||
|
||||
strncpy (message+spaces, pausemsg + offset - LINELEN, LINELEN-spaces);
|
||||
|
||||
offset=(offset + 1) % (strlen(pausemsg)+LINELEN);
|
||||
if (offset==0){
|
||||
offset=LINELEN;
|
||||
}
|
||||
|
||||
int l = strlen (message);
|
||||
if (l < LINELEN)
|
||||
{
|
||||
message = strncat (message, pausemsg, LINELEN - l);
|
||||
}
|
||||
|
||||
SEND_TEXT ("\x0b");
|
||||
SEND_TEXT (message);
|
||||
free (message);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
@ -260,6 +293,7 @@ main (int argc, char **argv)
|
|||
|
||||
//TODO: arg parser!
|
||||
fifo = strdup ("/tmp/display");
|
||||
pausemsg = strdup("Bitte scanne Deine ID-Karte um Dich anzumelden *** ");
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
|
@ -307,6 +341,7 @@ main (int argc, char **argv)
|
|||
sleep (3);
|
||||
|
||||
screensaver = 0;
|
||||
offset = 0; // offset for scrolltext in screensaver
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
@ -325,7 +360,6 @@ main (int argc, char **argv)
|
|||
if (screensaver < (TIME_CLOCK + TIME_OFF + TIME_DIM + 10)){
|
||||
screensaver++;
|
||||
}
|
||||
//screensaver = (screensaver + 1) % (TIME_CLOCK + TIME_OFF + TIME_DIM + 10);
|
||||
|
||||
if (screensaver == TIME_CLOCK)
|
||||
{
|
||||
|
@ -340,19 +374,7 @@ main (int argc, char **argv)
|
|||
//show a scroll text while the screensaver is active...
|
||||
if ((screensaver > (TIME_CLOCK + 10)) && (screensaver < TIME_OFF))
|
||||
{
|
||||
char *message = calloc (LINELEN + 1, sizeof (char));
|
||||
strncpy (message,
|
||||
PAUSEMSG +
|
||||
((screensaver - TIME_CLOCK - 1) % strlen (PAUSEMSG)),
|
||||
LINELEN);
|
||||
int l = strlen (message);
|
||||
if (l < LINELEN)
|
||||
{
|
||||
message = strncat (message, PAUSEMSG, LINELEN - l);
|
||||
}
|
||||
SEND_TEXT ("\x0b");
|
||||
SEND_TEXT (message);
|
||||
free (message);
|
||||
scrolltext();
|
||||
}
|
||||
|
||||
//after some more seconds of inactivity dim display and finally turn off
|
||||
|
|
Loading…
Reference in New Issue