diff options
-rw-r--r-- | anzeige.c | 91 | ||||
-rw-r--r-- | fonts.h | 99 |
2 files changed, 141 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 @@ -0,0 +1,99 @@ +char const symbols[(128-32)*5] = { + 0x00,0x00,0x00,0x00,0x00, // space + 0x00,0x00,0x7d,0x00,0x00, // ! + 0x00,0x60,0x00,0x60,0x00, // " + 0x14,0x3e,0x14,0x3e,0x14, // # + 0x12,0x7f,0x2a,0x7f,0x24, // $ + 0x62,0x64,0x08,0x13,0x23, // % + 0x06,0x39,0x55,0x62,0x05, // & + 0x00,0x00,0x60,0x00,0x00, // ' + 0x00,0x1c,0x22,0x41,0x00, // ( + 0x00,0x41,0x22,0x1c,0x00, // ) + 0x22,0x14,0x3e,0x14,0x22, // * + 0x08,0x08,0x3e,0x08,0x08, // + + 0x00,0x01,0x02,0x00,0x00, // , + 0x08,0x08,0x08,0x08,0x08, // - + 0x00,0x00,0x02,0x00,0x00, // . + 0x00,0x03,0x1c,0x60,0x00, // / + 0x3c,0x63,0x41,0x63,0x3c, // 0 + 0x00,0x21,0x7f,0x01,0x00, // 1 + 0x23,0x45,0x45,0x49,0x31, // 2 + 0x22,0x49,0x49,0x49,0x36, // 3 + 0x0c,0x34,0x7f,0x04,0x04, // 4 + 0x00,0x00,0x00,0x00,0x00, // 5 + 0x00,0x00,0x00,0x00,0x00, // 6 + 0x00,0x00,0x00,0x00,0x00, // 7 + 0x00,0x00,0x00,0x00,0x00, // 8 + 0x00,0x00,0x00,0x00,0x00, // 9 + 0x00,0x00,0x00,0x00,0x00, // : + 0x00,0x00,0x00,0x00,0x00, // ; + 0x00,0x00,0x00,0x00,0x00, // < + 0x00,0x00,0x00,0x00,0x00, // = + 0x00,0x00,0x00,0x00,0x00, // > + 0x00,0x00,0x00,0x00,0x00, // ? + 0x00,0x00,0x00,0x00,0x00, // @ + 0x00,0x00,0x00,0x00,0x00, // A + 0x00,0x00,0x00,0x00,0x00, // B + 0x00,0x00,0x00,0x00,0x00, // C + 0x00,0x00,0x00,0x00,0x00, // D + 0x00,0x00,0x00,0x00,0x00, // E + 0x00,0x00,0x00,0x00,0x00, // F + 0x00,0x00,0x00,0x00,0x00, // G + 0x00,0x00,0x00,0x00,0x00, // H + 0x00,0x00,0x00,0x00,0x00, // I + 0x00,0x00,0x00,0x00,0x00, // J + 0x00,0x00,0x00,0x00,0x00, // K + 0x00,0x00,0x00,0x00,0x00, // L + 0x00,0x00,0x00,0x00,0x00, // M + 0x00,0x00,0x00,0x00,0x00, // N + 0x00,0x00,0x00,0x00,0x00, // O + 0x00,0x00,0x00,0x00,0x00, // P + 0x00,0x00,0x00,0x00,0x00, // Q + 0x00,0x00,0x00,0x00,0x00, // R + 0x00,0x00,0x00,0x00,0x00, // S + 0x00,0x00,0x00,0x00,0x00, // T + 0x00,0x00,0x00,0x00,0x00, // U + 0x00,0x00,0x00,0x00,0x00, // V + 0x00,0x00,0x00,0x00,0x00, // W + 0x00,0x00,0x00,0x00,0x00, // X + 0x00,0x00,0x00,0x00,0x00, // Y + 0x00,0x00,0x00,0x00,0x00, // Z + 0x00,0x00,0x00,0x00,0x00, // [ + 0x00,0x00,0x00,0x00,0x00, // backslash + 0x00,0x00,0x00,0x00,0x00, // ] + 0x00,0x00,0x00,0x00,0x00, // ^ + 0x00,0x00,0x00,0x00,0x00, // _ + 0x00,0x00,0x00,0x00,0x00, // ` + 0x00,0x00,0x00,0x00,0x00, // a + 0x00,0x00,0x00,0x00,0x00, // b + 0x00,0x00,0x00,0x00,0x00, // c + 0x00,0x00,0x00,0x00,0x00, // d + 0x00,0x00,0x00,0x00,0x00, // e + 0x00,0x00,0x00,0x00,0x00, // f + 0x00,0x00,0x00,0x00,0x00, // g + 0x00,0x00,0x00,0x00,0x00, // h + 0x00,0x00,0x00,0x00,0x00, // i + 0x00,0x00,0x00,0x00,0x00, // j + 0x00,0x00,0x00,0x00,0x00, // k + 0x00,0x00,0x00,0x00,0x00, // l + 0x00,0x00,0x00,0x00,0x00, // m + 0x00,0x00,0x00,0x00,0x00, // n + 0x00,0x00,0x00,0x00,0x00, // o + 0x00,0x00,0x00,0x00,0x00, // p + 0x00,0x00,0x00,0x00,0x00, // q + 0x00,0x00,0x00,0x00,0x00, // r + 0x00,0x00,0x00,0x00,0x00, // s + 0x00,0x00,0x00,0x00,0x00, // t + 0x00,0x00,0x00,0x00,0x00, // u + 0x00,0x00,0x00,0x00,0x00, // v + 0x00,0x00,0x00,0x00,0x00, // w + 0x00,0x00,0x00,0x00,0x00, // x + 0x00,0x00,0x00,0x00,0x00, // y + 0x00,0x00,0x00,0x00,0x00, // z + 0x00,0x00,0x00,0x00,0x00, // { + 0x00,0x00,0x00,0x00,0x00, // | + 0x00,0x00,0x00,0x00,0x00, // } + 0x00,0x00,0x00,0x00,0x00, // ~ + 0x00,0x00,0x00,0x00,0x00 // DEL +}; + |