-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
projects/01drv_rgbled_pwm: add example application for rgbled pwm lib…
…rary
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* @file 01bsp_rgbled_pwm.c | ||
* @author Alexandre Abadie <[email protected]> | ||
* @brief This is a short example of how to interface with the RGB LED in the DotBot shield. | ||
* | ||
* Load this program on your board. The LEDs should start blinking different colors. | ||
* | ||
* @copyright Inria, 2023 | ||
* | ||
*/ | ||
#include <nrf.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "board.h" | ||
#include "rgbled_pwm.h" | ||
#include "timer.h" | ||
#include "board_config.h" | ||
|
||
//=========================== variables ======================================== | ||
|
||
#ifdef DB_RGB_LED_PWM_RED_PORT | ||
static const db_rgbled_pwm_conf_t rgbled_pwm_conf = { | ||
.pins = { | ||
{ .port = DB_RGB_LED_PWM_RED_PORT, .pin = DB_RGB_LED_PWM_RED_PIN }, | ||
{ .port = DB_RGB_LED_PWM_GREEN_PORT, .pin = DB_RGB_LED_PWM_GREEN_PIN }, | ||
{ .port = DB_RGB_LED_PWM_BLUE_PORT, .pin = DB_RGB_LED_PWM_BLUE_PIN }, | ||
} | ||
}; | ||
#endif | ||
|
||
//=========================== main ============================================= | ||
|
||
int main(void) { | ||
db_board_init(); | ||
db_timer_init(); | ||
#ifdef DB_RGB_LED_PWM_RED_PORT | ||
db_rgbled_pwm_init(&rgbled_pwm_conf); | ||
#endif | ||
|
||
/* Change RGB colors in a loop */ | ||
while (1) { | ||
#ifdef DB_RGB_LED_PWM_RED_PORT | ||
db_rgbled_pwm_set_color(255, 0, 0); | ||
db_timer_delay_s(2); | ||
db_rgbled_pwm_set_color(0, 255, 0); | ||
db_timer_delay_s(2); | ||
db_rgbled_pwm_set_color(0, 0, 255); | ||
db_timer_delay_s(2); | ||
db_rgbled_pwm_set_color(255, 255, 0); | ||
db_timer_delay_s(2); | ||
db_rgbled_pwm_set_color(0, 255, 255); | ||
db_timer_delay_s(2); | ||
db_rgbled_pwm_set_color(255, 0, 255); | ||
#else | ||
puts("RGB LED pwm not supported!"); | ||
#endif | ||
db_timer_delay_s(2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# RGB LED board support package usage example | ||
|
||
Loading this app onto the DotBot board will change the RGB LED color every 2 | ||
seconds in a loop. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters