Leds bells and whistles

This commit is contained in:
DrZlo13 2021-10-28 15:03:33 +10:00
parent 141289743c
commit 31b29c0167
4 changed files with 31 additions and 11 deletions

View File

@ -10,13 +10,18 @@ void platform_gpio_set(int32_t gpio_num);
void platform_gpio_clear(int32_t gpio_num);
int platform_gpio_get_level(int32_t gpio_num);
void led_set_red(uint8_t value);
void led_set_green(uint8_t value);
void led_set_blue(uint8_t value);
#define PLATFORM_IDENT "ESP32-S2"
#define NO_USB_PLEASE
#define SET_RUN_STATE(state)
#define SET_IDLE_STATE(state)
#define SET_ERROR_STATE(state)
#define SET_RUN_STATE(state) \
{ led_set_green(255 * state); }
#define SET_IDLE_STATE(state) \
{ led_set_red(255 * state); }
#define TMS_SET_MODE() \
do { \

View File

@ -55,10 +55,22 @@ void led_init() {
}
void led_set(uint8_t red, uint8_t green, uint8_t blue) {
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LedChannelRed, 256U - red));
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LedChannelGreen, 256U - green));
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LedChannelBlue, 256U - blue));
led_set_red(red);
led_set_green(green);
led_set_blue(blue);
}
void led_set_red(uint8_t value) {
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LedChannelRed, 256U - value));
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LedChannelRed));
}
void led_set_green(uint8_t value) {
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LedChannelGreen, 256U - value));
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LedChannelGreen));
}
void led_set_blue(uint8_t value) {
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LedChannelBlue, 256U - value));
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LedChannelBlue));
}

View File

@ -3,4 +3,8 @@
void led_init();
void led_set(uint8_t red, uint8_t green, uint8_t blue);
void led_set(uint8_t red, uint8_t green, uint8_t blue);
void led_set_red(uint8_t value);
void led_set_green(uint8_t value);
void led_set_blue(uint8_t value);

View File

@ -42,6 +42,8 @@ void pins_init() {
void app_main(void) {
ESP_LOGI(TAG, "start");
led_init();
led_set_blue(255);
usb_cdc_init();
// nvs_init();
@ -49,9 +51,6 @@ void app_main(void) {
pins_init();
led_init();
led_set(0, 16, 0);
// TODO uart and i2c share the same pins, need switching mechanics
// uart_init();
// uart_print("Uart inited");
@ -60,6 +59,6 @@ void app_main(void) {
// i2c_scan();
xTaskCreate(&gdb_application_thread, "gdb_thread", 16 * 4096, NULL, 5, NULL);
led_set_blue(0);
ESP_LOGI(TAG, "end");
}