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

Function main

Software/C/Examples/leds.cpp:31–64  ·  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 uint8_t i1 = 0;
37 uint8_t i2 = BRIGHTNESS_LIMIT / 3;
38 uint8_t i3 = (BRIGHTNESS_LIMIT * 2) / 3;
39 int8_t a1 = 1;
40 int8_t a2 = 1;
41 int8_t a3 = 1;
42 while(true){
43 GPG.set_led(LED_EYE_LEFT, i1, i2, i3);
44 GPG.set_led(LED_EYE_RIGHT, i2, i3, i1);
45 GPG.set_led(LED_BLINKER_LEFT, i1);
46 GPG.set_led(LED_BLINKER_RIGHT, i2);
47
48 i1 += a1;
49 if(i1 == BRIGHTNESS_LIMIT || i1 == 0){
50 a1 *= -1;
51 }
52 i2 += a2;
53 if(i2 == BRIGHTNESS_LIMIT || i2 == 0){
54 a2 *= -1;
55 }
56 i3 += a3;
57 if(i3 == BRIGHTNESS_LIMIT || i3 == 0){
58 a3 *= -1;
59 }
60
61 // slow down
62 usleep(25000);
63 }
64}
65
66// Signal handler that will be called when Ctrl+C is pressed to stop the program
67void exit_signal_handler(int signo){

Callers

nothing calls this directly

Calls 2

detectMethod · 0.80
set_ledMethod · 0.45

Tested by

no test coverage detected