Display.h 730 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Display.h
  3. *
  4. * Created on: 03.12.2020
  5. * Author: willy
  6. */
  7. #ifndef DISPLAY_H_
  8. #define DISPLAY_H_
  9. #define COLS 12
  10. #define ROWS 8
  11. int screen[ROWS];
  12. void bin(unsigned n)
  13. {
  14. if (n > 1)
  15. bin(n >> 1);
  16. printf("%d", n & 1);
  17. }
  18. void draw() {
  19. int row,i,j;
  20. for (i=0 ; i<ROWS ; i++) {
  21. row = screen[i] | ((i+1)<<12); //send format: (4bits row indicator,12bits data)
  22. IOWR_ALTERA_AVALON_PIO_DATA(PIO_MATRIX_BASE, row);
  23. }
  24. }
  25. void draw_console() {
  26. int i;
  27. for (i = 0 ; i < ROWS ; i++) {
  28. bin(screen[i]);
  29. printf("\n");
  30. }
  31. }
  32. void set_pixel(int x, int y) {
  33. screen[y] = screen[y] & ~(1<<x) | (1<<x);
  34. }
  35. void reset_screen() {
  36. int i;
  37. for (i=0;i<ROWS;i++) {
  38. screen[i] = 0;
  39. }
  40. }
  41. #endif /* DISPLAY_H_ */