Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <targets/AT91SAM7.h>
- #include "lcd.h"
- #define LCD_BACKLIGHT PIOB_SODR_P20
- #define SW_1 PIOB_SODR_P24 //Makrodefinicje nazw dla portów przycisków SW1 i SW2
- #define SW_2 PIOB_SODR_P25
- __attribute__ ((section(".fast")))
- void delay(int n) //procedura opoznienia
- {
- volatile int i;
- for(i=3000*n;i>0;i--)
- {
- __asm__("nop");
- }
- }
- int main()
- {
- PMC_PCER=PMC_PCER_PIOB; //wlaczenie urzadzenia we/wy PIOB
- PIOB_OER=LCD_BACKLIGHT; //OUTPUT ENABLE
- PIOB_PER=LCD_BACKLIGHT; //PIO ENABLE
- InitLCD(); //inicjalizacja LCD
- LCDSettings(); //ustawienie LCD
- LCDClearScreen(); //wyczyszczenie LCD
- rysujPasek();
- int heigh = 122;
- while(1)
- {
- if ((PIOB_PDSR & SW_1)==0) //warunek sprawdzający czy wciśnięty jest przycisk SW_1
- {
- if(heigh>32) {
- heigh--;
- LCDSetLine(heigh, 64, heigh, 69, BLUE);
- }
- }
- if ((PIOB_PDSR & SW_2)==0) //warunek sprawdzający czy wciśnięty jest przycisk SW_2
- {
- if (heigh<122) {
- heigh++;
- zmniejszPasek(heigh);
- }
- }
- return 0;
- }
- void zmniejszPasek(int heigh) {
- WriteSpiCommand(PASET);
- WriteSpiData(height);
- WriteSpiData(height++);
- // Column address set (command 0x2A)
- WriteSpiCommand(CASET);
- WriteSpiData(64);
- WriteSpiData(69);
- // set the display memory to BLACK
- WriteSpiCommand(RAMWR);
- for(i = 0; i < ((131 * 131) / 2); i++) {
- WriteSpiData((BLACK >> 4) & 0xFF);
- WriteSpiData(((BLACK & 0xF) << 4) | ((BLACK >> 8) & 0xF));
- WriteSpiData(BLACK & 0xFF);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement