diff options
Diffstat (limited to 'anzeige.c')
-rw-r--r-- | anzeige.c | 91 |
1 files changed, 42 insertions, 49 deletions
@@ -24,6 +24,8 @@ #include <string.h> #include <pthread.h> +#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<<line; - memmove(raw_output+1+6*line,&(display_data -> buf[display_data -> is_buf][5*line]),5); - } - for (line=0; line<7; line++) { -#ifndef SKIP_GPIO - GPIO_CLR = 1<<GATE_PIN; // Licht an + GPIO_CLR = 1<<GATE_PIN; // Licht an + for (column=0; column<8; column++) { + GPIO_CLR = 1<<SER_CLK_PIN; + GPIO_ALTER(column == line) = 1<<SER_DAT_PIN; + GPIO_SET = 1<<SER_CLK_PIN; + } + for (column=39; column>=0; column--) { + GPIO_CLR = 1<<SER_CLK_PIN; + GPIO_ALTER((*(display_data -> buf[display_data -> is_buf] + column)>>line) & 0x01) = 1<<SER_DAT_PIN; + GPIO_SET = 1<<SER_CLK_PIN; #endif - for (int byte=0; byte<6; byte++) { -#ifndef SKIP_GPIO - for (int bit=0; bit<8; bit++) { - GPIO_CLR = 1<<SER_CLK_PIN; - GPIO_ALTER((*(raw_output+6*line+byte)>>bit) & 0x01) = 1<<SER_DAT_PIN; - GPIO_SET = 1<<SER_CLK_PIN; - } + } + usleep(1000); +#ifdef SKIP_GPIO + printf("\n"); #else - if (byte==0) - printf(" %02x ", *(raw_output+6*line+byte)); - else - printf("%c", *(raw_output+6*line+byte)); + GPIO_SET = 1<<GATE_PIN; // Licht aus + GPIO_CLR = 1<<PAR_CLK_PIN; + GPIO_SET = 1<<PAR_CLK_PIN; #endif - } - usleep(1000); -#ifndef SKIP_GPIO - GPIO_SET = 1<<GATE_PIN; // Licht aus - GPIO_CLR = 1<<PAR_CLK_PIN; - GPIO_SET = 1<<PAR_CLK_PIN; -#endif - } + } } - free(raw_output); return NULL; } // put_on_screen |