Changes between Version 1 and Version 2 of gpio
- Timestamp:
- 03/05/2018 10:30:51 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
gpio
v1 v2 223 223 #include <stdlib.h> 224 224 #include <string.h> 225 #include <time.h> 225 226 #include <unistd.h> 226 227 #ifdef __ANDROID__ … … 236 237 */ 237 238 #define BLOCK_TIME 5 239 /* seconds held for reboot */ 240 #define REBOOT_TIME 15 238 241 /* seconds before press-and-release count is cleared */ 239 242 #define MIN_REST_TIME 2 … … 262 265 printf("held=%ld\n", held); 263 266 264 /* if held for more than 5seconds */265 if (held >= 5) {267 /* if held for more than REBOOT_TIME seconds */ 268 if (held >= REBOOT_TIME) { 266 269 printf("Powering system down\n"); 267 270 #ifdef __ANDROID__ … … 282 285 283 286 /* perform something on number of presses? */ 284 } else {287 285 288 printf("reset count\n"); 286 289 num_releases = 0; … … 335 338 fdset.events = POLLPRI; 336 339 fdset.revents = 0; 337 if ((c = poll(&fdset, 1, 10000)) < 0) {340 if ((c = poll(&fdset, 1, BLOCK_TIME*1000)) < 0) { 338 341 perror("poll() failed"); 339 342 break; 340 343 } 341 344 342 if (fdset.revents & POLLPRI) { 345 //if (fdset.revents & POLLPRI) 346 { 343 347 /* show gpio value */ 344 348 /* Note that both an lseek and read are necessary … … 355 359 return 0; 356 360 } 361 357 362 }}} 358 363