#include <stdio.h>
#define QUIT_TIMEOUT_US 1500000
#define QUIT_CHECK_US 100000
static const int us_delay[] = {400000, 170000, 100000};
static int mode;
static int toggle;
static void __on_pause_release(void)
{
printf("PAUSED\n");
}
printf("RUNNING\n");
}
fflush(stdout);
return;
}
static void __on_pause_press(void)
{
int i=0;
const int samples = QUIT_TIMEOUT_US/QUIT_CHECK_US;
for(i=0;i<samples;i++){
return;
}
}
printf("long press detected, shutting down\n");
return;
}
static void __on_mode_release(void)
{
if(mode<2) mode++;
else mode=0;
printf("setting mode: %d\n", mode);
return;
}
int main()
{
fprintf(stderr,"ERROR: failed to complete rc_enable_signal_handler\n");
return -1;
}
fprintf(stderr,"ERROR: failed to init buttons\n");
return -1;
}
fprintf(stderr,"ERROR: failed to init buttons\n");
return -1;
}
fprintf(stderr, "ERROR in rc_blink, failed to set RC_LED_GREEN\n");
return -1;
}
fprintf(stderr, "ERROR in rc_blink, failed to set RC_LED_RED\n");
return -1;
}
mode = 0;
printf("\nPress mode to change blink rate\n");
printf("hold pause button to exit\n");
if(toggle){
toggle = 0;
}
else{
toggle=1;
}
}
}
return 0;
}
int rc_led_set(rc_led_t led, int value)
sets the state of an LED
void rc_led_cleanup(void)
closes file descriptors to all opened LEDs
@ RC_LED_GREEN
Definition: led.h:36
@ RC_LED_RED
Definition: led.h:37
rc_state_t rc_get_state(void)
fetches the current process state as set by the user or signal handler
int rc_remove_pid_file(void)
Removes the PID file created by rc_make_pid_file().
void rc_set_state(rc_state_t new_state)
sets the current process state.
int rc_make_pid_file(void)
Makes a PID file RC_PID_FILE (/run/shm/robotcontrol.pid) containing the current PID of your process.
int rc_enable_signal_handler(void)
Enables a generic signal handler. Optional but recommended.
int rc_kill_existing_process(float timeout_s)
This function is used to make sure any existing program using the PID file is stopped.
@ RUNNING
Definition: start_stop.h:62
@ EXITING
Definition: start_stop.h:64
@ PAUSED
Definition: start_stop.h:63
void rc_usleep(unsigned int us)
Sleep in microseconds.