#include "led_bar.h" #ifdef PICO #include #include #define GPIO_02 2 #endif void init_gpio(void) { #ifdef PICO #ifdef PICO_DEFAULT_LED_PIN gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); #endif gpio_init(GPIO_02); gpio_set_dir(GPIO_02, GPIO_OUT); gpio_set_function(GPIO_02, GPIO_FUNC_PWM); uint slice_num = pwm_gpio_to_slice_num(GPIO_02); pwm_set_enabled(slice_num, true); for (int i = 0; i < NB_LED_BAR_GPIO; i++) { gpio_init(LED_BAR_GPIO[i]); gpio_set_dir(LED_BAR_GPIO[i], GPIO_OUT); gpio_set_function(LED_BAR_GPIO[i], GPIO_FUNC_PWM); uint slice_num = pwm_gpio_to_slice_num(LED_BAR_GPIO[i]); pwm_set_enabled(slice_num, true); pwm_set_wrap(slice_num, MAX_DUTY_STEPS); } #endif } /** * A program to play with the LED bar (10 leds). * You have three main functions: * - run_wave: simulate waves like propagating along the LED bar. * - breath_led: one LED breathing (for manu use FreeRTOS tasks). * - run_meteor: back and forth meteor flow like. * * NOTE: for easy dev/debug you can use the following command: * `make run-debug name=beathing_led` * * It will run the program directly on your machine, displaying * a LED bar simulator on the terminal stdout. */ int main() { #ifdef PICO stdio_init_all(); init_gpio(); #endif leds l; init_leds(&l); run_wave(&l, 100); breath_led(&l, 5, 100, 1); for(;;) { run_meteor(&l, 100); switch_direction(&l); } }