#include #include #include #include #include #include #include #include #include #include #include #include #define WEWY 25 static int lcdHandle ; struct timespec tim; char buf1[50]; void wyswietl(); void Delay_ms(int microsec); /* S T A R T */ void main (argc, argv) int argc; char *argv[]; { // check wiringPi setup if (wiringPiSetup() == -1) { printf("wiringPi-Error\n"); exit(1); } pinMode (WEWY , INPUT) ; pullUpDnControl(WEWY, PUD_UP); lcdHandle = lcdInit (4, 20, 4, 10,11, 0,1,2,3,0,0,0,0) ; int stan; int licz; while (TRUE) { stan=digitalRead(WEWY); if (stan == 0) { for(licz=30;licz>0;licz--) { stan=digitalRead(WEWY); if(stan == 1) break; Delay_ms(200); } if (stan == 0) { system("killall pomiar"); sleep(1); lcdClear(lcdHandle); wyswietl(1,1,"Zamykanie systemu"); system("shutdown -h now"); exit(0); } } Delay_ms(200); } //od while(TRUE) } // od main //***************************************** void wyswietl(int x, int y, char* tresc) { lcdPosition (lcdHandle, x, y) ; strncpy(buf1, tresc, 20); lcdPuts (lcdHandle, buf1) ; } //***************************************** void Delay_ms(int milisec) { tim.tv_sec = 0; tim.tv_nsec = milisec * 1000000; while(nanosleep(&tim,&tim)==-1) continue; }