Hello,
I know that this question was here before, but I've read all of the questions and answers and still I don't know what I do wrong.
I'm using 3 PWM channels to controll RGB led, and I'm using my RGB_update function to change color by writting letters on UART. Without Softdevice it work fine, but when I'm trying to put the same code to, for example, ble_app_proximity example, the RGB color is not changing. I's using SDK 6.1 and softdevice 7.1.
Any advices?
My main.c int main(void) { // LED & PWM initialization uint8_t R=150; uint8_t G=150; uint8_t B=150;
nrf_pwm_config_t pwm_config = PWM_DEFAULT_CONFIG;
pwm_config.mode = PWM_MODE_LED_255;
pwm_config.num_channels = 4;
pwm_config.gpio_num[0] = LED_1;
pwm_config.gpio_num[1] = LED_2;
pwm_config.gpio_num[2] = LED_4;
pwm_config.gpio_num[3] = LED_3;
// Initialize the PWM library
nrf_pwm_init(&pwm_config);
simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, HWFC);
// Initialize.
app_trace_init();
leds_init();
timers_init();
gpiote_init();
buttons_init();
ble_stack_init();
device_manager_init();
gap_params_init();
advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE);
services_init();
conn_params_init();
// Start execution.
advertising_start();
// Enter main loop.
while(true)
{
uint8_t cr = 'r';
if (cr == 'R' || cr == 'r' || cr == 'G' || cr == 'g' || cr == 'B' || cr == 'b')
{
RGB_update(cr,&R,&G,&B);
}
if (cr == 's' || cr == 'S' || cr == 'H' || cr == 'h' )
{
HSV_update(cr,&R,&G,&B);
}
nrf_pwm_set_value(1, (uint32_t) R); //R
nrf_pwm_set_value(2, (uint32_t) G); //G
nrf_pwm_set_value(3, (uint32_t) B); //B
power_manage();
}
}
void RGB_update( uint8_t cr, uint8_t *R, uint8_t *G, uint8_t *B) {
if (cr == 'q' && cr == 'Q')
{
//uart_quit();
}
if (cr == 'R' && *R<220)
{
(*R)+=25;
}
if (cr == 'G' && *G<220)
{
(*G)+=25;
}
if (cr == 'B' && *B<220 )
{
(*B)+=25;
}
if (cr == 'r' && *R>30)
{
(*R)-=25;
}
if (cr== 'g' && *G>30)
{
(*G)-=25;
}
if (cr == 'b' && *B>30)
{
(*B)-=25;
}
}