RP6 ROBOT SYSTEM - 4. RP6 CONTROL M256 WIFI Library
4.1.2. Status LEDs
The LEDs are controlled like the ones on the main board, however only four LEDs are
available.
This function is called the same as on the main board:
void setLEDs(uint8_t leds)
Example:
setLEDs(0b0000); // This command turns off all LEDs.
setLEDs(0b0001); // This one switches LED1 on and all others off.
setLEDs(0b0010); // LED2
setLEDs(0b0100); // LED3
setLEDs(0b1010); // LED4 and LED2
The LEDs are directly linked to the I/O ports of the microcontroller (unlike the RP6-
M32 where these and the LCD are connected to an external shift register). There are
also 4 functions that set the LEDs individually:
void setLED1(uint8_t led), void setLED2(uint8_t led),
void setLED3(uint8_t led), void setLED4(uint8_t led)
setLED1(1); // LED1 on
setLED2(0); // LED2 off
4.1.3. Buttons
The two buttons on the board can be queried via the following routines.
uint8_t getPressedKeyNumber(void)
This functions finds out which button is pressed and returns 1 or 2. If no button is
pressed when it is called, it returns 0.
uint8_t checkPressedKeyEvent(void)
This function checks if a button is pressed and returns one single time the button
number - unlike getPressedKeyNumber, where the button number is sent back per-
manently. This is useful to query the buttons in the main loop without interrupting the
program flow.
Following function works in a similar way:
uint8_t checkReleasedKeyEvent(void)
It returns the button value only once and only when the button has been pressed and
also released. This function doesn't block the normal program flow, so you don't have
to wait in a loop until the button is released.
- 29 -