#include <stdio.h>
#define VOLTAGE_DISCONNECT 1
int main()
{
double pack_voltage;
double cell_voltage;
double jack_voltage;
if(pack_voltage<0.0 || jack_voltage<0.0){
fprintf(stderr,"ERROR: can't read voltages\n");
return -1;
}
if(pack_voltage<VOLTAGE_DISCONNECT){
pack_voltage = 0;
}
if(jack_voltage<VOLTAGE_DISCONNECT){
jack_voltage = 0;
}
cell_voltage = pack_voltage/2;
printf("\rPack: %0.2lfV Cell: %0.2lfV DC Jack: %0.2lfV ", \
pack_voltage, cell_voltage, jack_voltage);
fflush(stdout);
}
return 0;
}
double rc_adc_dc_jack(void)
Reads the voltage of the 9-18v DC jack.
int rc_adc_init(void)
initializes the analog to digital converter for reading
int rc_adc_cleanup(void)
Cleans up the ADC subsystem.
double rc_adc_batt(void)
reads the voltage of the 2-cell Lithium battery
rc_state_t rc_get_state(void)
fetches the current process state as set by the user or signal handler
int rc_enable_signal_handler(void)
Enables a generic signal handler. Optional but recommended.
@ EXITING
Definition: start_stop.h:64
void rc_usleep(unsigned int us)
Sleep in microseconds.