Advertisement
MagnusArias

AVR | Baza pod ekran

Oct 12th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. #define F_CPU 1000000UL
  2. #include <avr/io.h>
  3. #include <util/delay.h>
  4. #include <stdlib.h>
  5. #include "HD44780.c"
  6.  
  7. #define SW_L (1<<PA4)
  8. #define SW_L_ON !(PINA & SW_L)
  9.  
  10. #define SW_P (1<<PA5)
  11. #define SW_P_ON !(PINA & SW_P)
  12.  
  13. void Draw_Main(char src[2][16][1]){
  14.    
  15.     for (short int row = 0; row < 2; row++)
  16.     {
  17.         for (short int col = 0; col < 16; col++)
  18.         {
  19.             LCD_GoTo(col, row); // x, y
  20.             LCD_WriteText(&src[row][col]);
  21.         }
  22.     }
  23. }
  24.        
  25. int main(void)
  26. {  
  27. // 2 - wiersze, 16 - kolumny, 1- dlugosc znaku (czyli maksymalnie 1)
  28.     char ekran[2][16][1] =  {
  29.         {   '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6'},
  30.         {   'a', 'b', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F', 'T', 'E', 'S', 'T'}
  31.                             };
  32.  
  33.     LCD_Initalize();
  34.     LCD_Clear();
  35.    
  36.     DDRA &= ~(SW_L | SW_P);
  37.     PORTA |= (SW_L | SW_P);
  38.    
  39.    
  40.    
  41.     while(1)
  42.     {
  43.         Draw_Main(ekran);
  44.     }  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement