Add led manager with support for Babble boards

This commit is contained in:
Lorow
2024-09-21 17:07:41 +02:00
parent 05e643a5de
commit e4daa62bb7
7 changed files with 238 additions and 28 deletions

View File

@@ -12,7 +12,6 @@
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "led_strip.h"
#include "sdkconfig.h"
#include "usb_device_uvc.h"
#include "esp_camera.h"
@@ -22,29 +21,11 @@
#include <openiris_logo.hpp>
#include <wifiManager.hpp>
#include <ProjectConfig.hpp>
#include <LEDManager.hpp>
static const char *TAG = "[MAIN]";
/* Use project configuration menu (idf.py menuconfig) to choose the GPIO to blink,
or you can edit the following line and set a number here.
*/
#define BLINK_GPIO (gpio_num_t) CONFIG_BLINK_GPIO
static uint8_t s_led_state = 0;
static void blink_led(void)
{
/* Set the GPIO level according to the state (LOW or HIGH)*/
gpio_set_level(BLINK_GPIO, s_led_state);
}
static void configure_led(void)
{
ESP_LOGI(TAG, "Example configured to blink GPIO LED!");
gpio_reset_pin(BLINK_GPIO);
/* Set the GPIO as a push/pull output */
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
}
static const char *TAG = "[MAIN]";
static void initNVSStorage()
{
@@ -80,21 +61,23 @@ extern "C" void app_main(void)
ProjectConfig deviceConfig("openiris", "openiristracker");
WiFiManager wifiManager;
#ifdef USE_ILLUMNATIOR_PIN
// LEDManager ledManager(BLINK_GPIO, ILLUMINATOR_PIN);
LEDManager ledManager(BLINK_GPIO, 1);
#else
LEDManager ledManager(BLINK_GPIO);
#endif
Logo::printASCII();
initNVSStorage();
ledManager.setup();
deviceConfig.load();
wifiManager.Begin();
/* Configure the peripheral according to the LED type */
configure_led();
while (1)
{
ESP_LOGI(TAG, "Turning the LED on pin %d %s!", BLINK_GPIO, s_led_state == true ? "ON" : "OFF");
blink_led();
/* Toggle the LED state */
s_led_state = !s_led_state;
ledManager.handleLED();
vTaskDelay(CONFIG_BLINK_PERIOD / portTICK_PERIOD_MS);
}
}