/* * Adjusts brightness of the set point LEDs */ static void adjust_setpoint_led_brightness( void ) { float up_led_brightness_level; float down_led_brightness_level; float up_led_duty_cycle; float down_led_duty_cycle; if ( setpoint.temperature > DEFAULT_SETPOINT ) { up_led_brightness_level = setpoint.temperature - DEFAULT_SETPOINT; down_led_brightness_level = 0.0f; } else { up_led_brightness_level = 0.0f; down_led_brightness_level = DEFAULT_SETPOINT - setpoint.temperature; } /* Update LED brightness */ up_led_duty_cycle = LED_BRIGHTNESS_EQUATION( up_led_brightness_level ); down_led_duty_cycle = LED_BRIGHTNESS_EQUATION( down_led_brightness_level ); wiced_pwm_init ( SETPOINT_UP_LED, SETPOINT_LED_PWM_FREQ_HZ, up_led_duty_cycle ); wiced_pwm_start( SETPOINT_UP_LED ); wiced_pwm_init ( SETPOINT_DOWN_LED, SETPOINT_LED_PWM_FREQ_HZ, down_led_duty_cycle ); wiced_pwm_start( SETPOINT_DOWN_LED ); }
void ws2812_init() { wiced_pwm_init(WICED_PWM_2, 800000, 0); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1, ENABLE); DMA_Init(DMA1_Stream7, &dma); TIM_DMACmd(TIM4, TIM_DMA_CC3, ENABLE); DMA_Cmd(DMA1_Stream7, ENABLE); wiced_pwm_start(WICED_PWM_2); }
void application_start( ) { float temp = 100; float duty = 100; float cnt = 0; wiced_bool_t rise = WICED_FALSE; /* Initialise the WICED device */ wiced_init(); // The RGB and setup button are initialized in platform.c WPRINT_APP_INFO( ( "The RGB is breathing green.\n" ) ); while ( 1 ) { wiced_pwm_init( RGB_G_PWM, 1000, duty ); wiced_pwm_start( RGB_G_PWM ); wiced_rtos_delay_milliseconds( 10 ); if(rise) { temp += cnt; cnt -= 0.005; if(temp >= 100.0) { duty = 100; cnt = 0; rise = WICED_FALSE; } else { duty = temp; } } else { cnt += 0.005; temp -= cnt; if(temp <= 0.0) { duty = 0; rise = WICED_TRUE; } else { duty = temp; } } } }