Changes between Version 1 and Version 2 of gpio


Ignore:
Timestamp:
03/05/2018 02:30:51 PM (10 months ago)
Author:
Tim Harvey
Comment:

updated gpio.c example

Legend:

Unmodified
Added
Removed
Modified
  • gpio

    v1 v2  
    223223#include <stdlib.h>
    224224#include <string.h>
     225#include <time.h>
    225226#include <unistd.h>
    226227#ifdef __ANDROID__
     
    236237 */
    237238#define BLOCK_TIME 5
     239/* seconds held for reboot */
     240#define REBOOT_TIME 15
    238241/* seconds before press-and-release count is cleared */
    239242#define MIN_REST_TIME 2
     
    262265                printf("held=%ld\n", held);
    263266
    264                 /* if held for more than 5 seconds */
    265                 if (held >= 5) {
     267                /* if held for more than REBOOT_TIME seconds */
     268                if (held >= REBOOT_TIME) {
    266269                        printf("Powering system down\n");
    267270#ifdef __ANDROID__
     
    282285
    283286                        /* perform something on number of presses? */
    284                 } else {
     287           
    285288                        printf("reset count\n");
    286289                        num_releases = 0;
     
    335338                fdset.events = POLLPRI;
    336339                fdset.revents = 0;
    337                 if ((c = poll(&fdset, 1, 10000)) < 0) {
     340                if ((c = poll(&fdset, 1, BLOCK_TIME*1000)) < 0) {
    338341                        perror("poll() failed");
    339342                        break;
    340343                }
    341344
    342                 if (fdset.revents & POLLPRI) {
     345                //if (fdset.revents & POLLPRI)
     346                {
    343347                        /* show gpio value */
    344348                        /* Note that both an lseek and read are necessary
     
    355359        return 0;
    356360}
     361
    357362}}}
    358363