From e9c00dc481ecded4c1dce280970fc06156f471f6 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 22 Oct 2018 10:49:50 +0200 Subject: fonts.h neu --- anzeige.c | 91 +++++++++++++++++++++++++++++---------------------------------- 1 file changed, 42 insertions(+), 49 deletions(-) (limited to 'anzeige.c') diff --git a/anzeige.c b/anzeige.c index cddc0a8..55c234a 100644 --- a/anzeige.c +++ b/anzeige.c @@ -24,6 +24,8 @@ #include #include +#include "fonts.h" + #define PAGE_SIZE (4*1024) #define BLOCK_SIZE (4*1024) @@ -37,7 +39,7 @@ int mem_fd; void *gpio_map; typedef struct { - char buf[2][35]; + char buf[3][40]; int should_buf, is_buf, keep_running; } t_display_data; @@ -74,13 +76,7 @@ void printButton(int g) int main(int argc, char **argv) { pthread_t thread_id; - t_display_data display_data = { - "abcdefghijklmnopqrstuvwxyzabcdefghi", - "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI", - 0, - 0, - 1 - }; + t_display_data display_data; #ifndef SKIP_GPIO // Set up gpi pointer for direct register access @@ -110,15 +106,18 @@ int main(int argc, char **argv) INP_GPIO(SENSE_PIN); #endif + for (int i=0; i<3; i++) + memset(display_data.buf[i],0,40); + display_data.is_buf = 0; + display_data.should_buf = 0; + display_data.keep_running = 1; pthread_create(&thread_id, NULL, put_on_display, &display_data); for (int i=0; i<20; i++) { - usleep(500000); - if (display_data.should_buf == display_data.is_buf) { - for (int j=0; j<35; j++) - display_data.buf[1-display_data.is_buf][j] -= 1; - } - display_data.should_buf ^= 0x01; + usleep(2500000); + for (int j=0; j<39; j++) + display_data.buf[(display_data.should_buf+1)%3][j] = symbols[(40*i+j)%sizeof(symbols)]; + display_data.should_buf = (display_data.should_buf+1)%3; } display_data.keep_running = 0; @@ -186,51 +185,45 @@ void drop_privileges() void *put_on_display(void *param) { t_display_data *display_data = param; - char *raw_output; - int line; - - raw_output = malloc(7*(5+1)); - if (raw_output == NULL) { - perror("malloc failed"); - exit(-1); - } + int line, column; while (display_data -> keep_running) { #ifdef SKIP_GPIO - printf("\n"); + usleep(100000); + printf("=\n"); #endif display_data -> is_buf = display_data -> should_buf; +#ifdef SKIP_GPIO + for (line=6; line>=0; line--) { + for (column=0; column<40; column++) { + if ((*(display_data -> buf[display_data -> is_buf] + column)>>line) & 0x01) + printf("X"); + else + printf("."); +#else for (line=0; line<7; line++) { - raw_output[line*6] = 1< buf[display_data -> is_buf][5*line]),5); - } - for (line=0; line<7; line++) { -#ifndef SKIP_GPIO - GPIO_CLR = 1<=0; column--) { + GPIO_CLR = 1< buf[display_data -> is_buf] + column)>>line) & 0x01) = 1<>bit) & 0x01) = 1<