steering-wheel/Core/Inc/leds.h

49 lines
1.0 KiB
C
Raw Normal View History

2023-03-24 21:12:03 +01:00
#ifndef INC_LEDS_H
#define INC_LEDS_H
#ifdef __cplusplus
extern "C" {
#endif
#include "stm32h7xx_hal.h"
2023-03-25 00:36:56 +01:00
#include "tx_port.h"
2023-03-24 21:12:03 +01:00
#define N_LEDS 9
#define PWM_CHANNEL_R TIM_CHANNEL_1
#define PWM_CHANNEL_G TIM_CHANNEL_2
#define PWM_CHANNEL_B TIM_CHANNEL_3
void led_init(SPI_HandleTypeDef *spi, TIM_HandleTypeDef *pwmtim);
void led_set(size_t idx, uint8_t r, uint8_t g, uint8_t b);
2023-03-25 00:36:56 +01:00
void led_all_off();
void led_thread_entry(ULONG child_thread_stack_addr);
typedef enum {
ANIM_TE_STARTUP,
ANIM_FT_STARTUP,
ANIM_KNIGHT_RIDER,
2023-03-25 01:22:57 +01:00
ANIM_RAINBOW,
2023-03-25 00:36:56 +01:00
} LEDAnimation;
void led_start_animation(LEDAnimation anim);
void led_anim_te_startup(ULONG _);
void led_anim_ft_startup(ULONG _);
void led_anim_knight_rider(ULONG _);
2023-03-25 01:22:57 +01:00
void led_anim_rainbow(ULONG _);
2023-03-25 00:36:56 +01:00
void led_anim_blinker(uint8_t r, uint8_t g, uint8_t b,
uint32_t brightness_steps, uint32_t next_led_steps,
uint32_t delay);
2023-03-24 21:12:03 +01:00
2023-03-25 01:22:57 +01:00
void led_hsv_to_rgb(float h, float s, float v, uint8_t *r, uint8_t *g,
uint8_t *b);
2023-03-24 21:12:03 +01:00
#ifdef __cplusplus
}
#endif
#endif // INC_LEDS_H