Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. #include <targets/AT91SAM7.h>
  2. #include "lcd.h"
  3.  
  4. #define LCD_BACKLIGHT PIOB_SODR_P20
  5. #define SW_1 PIOB_SODR_P24 //Makrodefinicje nazw dla portów przycisków SW1 i SW2
  6. #define SW_2 PIOB_SODR_P25
  7.  
  8. __attribute__ ((section(".fast")))
  9. void delay(int n) //procedura opoznienia
  10. {
  11. volatile int i;
  12.  
  13. for(i=3000*n;i>0;i--)
  14. {
  15. __asm__("nop");
  16. }
  17. }
  18.  
  19. int main()
  20. {
  21. PMC_PCER=PMC_PCER_PIOB; //wlaczenie urzadzenia we/wy PIOB
  22. PIOB_OER=LCD_BACKLIGHT; //OUTPUT ENABLE
  23. PIOB_PER=LCD_BACKLIGHT; //PIO ENABLE
  24.  
  25. InitLCD(); //inicjalizacja LCD
  26. LCDSettings(); //ustawienie LCD
  27. LCDClearScreen(); //wyczyszczenie LCD
  28. rysujPasek();
  29.  
  30. int heigh = 122;
  31.  
  32. while(1)
  33. {
  34. if ((PIOB_PDSR & SW_1)==0) //warunek sprawdzający czy wciśnięty jest przycisk SW_1
  35. {
  36. if(heigh>32) {
  37. heigh--;
  38. LCDSetLine(heigh, 64, heigh, 69, BLUE);
  39. }
  40. }
  41. if ((PIOB_PDSR & SW_2)==0) //warunek sprawdzający czy wciśnięty jest przycisk SW_2
  42. {
  43. if (heigh<122) {
  44. heigh++;
  45. zmniejszPasek(heigh);
  46.  
  47. }
  48. }
  49.  
  50. return 0;
  51. }
  52.  
  53.  
  54. void zmniejszPasek(int heigh) {
  55. WriteSpiCommand(PASET);
  56. WriteSpiData(height);
  57. WriteSpiData(height++);
  58. // Column address set (command 0x2A)
  59. WriteSpiCommand(CASET);
  60. WriteSpiData(64);
  61. WriteSpiData(69);
  62. // set the display memory to BLACK
  63. WriteSpiCommand(RAMWR);
  64. for(i = 0; i < ((131 * 131) / 2); i++) {
  65. WriteSpiData((BLACK >> 4) & 0xFF);
  66. WriteSpiData(((BLACK & 0xF) << 4) | ((BLACK >> 8) & 0xF));
  67. WriteSpiData(BLACK & 0xFF);
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement