MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / main

Function main

Software/C/Examples/sensors.cpp:31–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29void exit_signal_handler(int signo);
30
31int main(){
32 signal(SIGINT, exit_signal_handler); // register the exit function for Ctrl+C
33
34 GPG.detect(); // Make sure that the GoPiGo3 is communicating and that the firmware is compatible with the drivers.
35
36 GPG.set_grove_type(GROVE_1, GROVE_TYPE_US);
37 GPG.set_grove_type(GROVE_2, GROVE_TYPE_IR_DI_REMOTE);
38 sensor_ultrasonic_t US;
39 sensor_infrared_gobox_t IR;
40
41 while(true){
42 int USerror = GPG.get_grove_value(GROVE_1, &US);
43 int IRerror = GPG.get_grove_value(GROVE_2, &IR);
44 printf("US: Error %d %4dmm IR: Error %d button %d\n", USerror, US.mm, IRerror, IR.button);
45 usleep(20000);
46 }
47}
48
49// Signal handler that will be called when Ctrl+C is pressed to stop the program
50void exit_signal_handler(int signo){

Callers

nothing calls this directly

Calls 3

detectMethod · 0.80
set_grove_typeMethod · 0.45
get_grove_valueMethod · 0.45

Tested by

no test coverage detected