1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- /*
- * Display.h
- *
- * Created on: 03.12.2020
- * Author: willy
- */
- #ifndef DISPLAY_H_
- #define DISPLAY_H_
- #define COLS 12
- #define ROWS 8
- int screen[ROWS];
- void bin(unsigned n)
- {
- if (n > 1)
- bin(n >> 1);
- printf("%d", n & 1);
- }
- void draw() {
- int row,i,j;
- for (i=0 ; i<ROWS ; i++) {
- row = screen[i] | ((i+1)<<12); //send format: (4bits row indicator,12bits data)
- IOWR_ALTERA_AVALON_PIO_DATA(PIO_MATRIX_BASE, row);
- }
- }
- void draw_console() {
- int i;
- for (i = 0 ; i < ROWS ; i++) {
- bin(screen[i]);
- printf("\n");
- }
- }
- void set_pixel(int x, int y) {
- screen[y] = screen[y] & ~(1<<x) | (1<<x);
- }
- void reset_screen() {
- int i;
- for (i=0;i<ROWS;i++) {
- screen[i] = 0;
- }
- }
- #endif /* DISPLAY_H_ */
|