63 lines
2.1 KiB
C++
63 lines
2.1 KiB
C++
#include <stdio.h>
|
|
#include <inttypes.h>
|
|
#include "sdkconfig.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "esp_chip_info.h"
|
|
#include "esp_flash.h"
|
|
#include "esp_system.h"
|
|
#include "blk_box.h"
|
|
#include "blk_box_drivers/i2c.h"
|
|
#include "blk_box_drivers/inputs.hpp"
|
|
#include "blk_box_drivers/leds.hpp"
|
|
#include "blk_box_drivers/char_lcd.hpp"
|
|
#include "blk_box_drivers/helpers.hpp"
|
|
|
|
extern "C" void app_main(void) {
|
|
BlkBoxInitConfig blk_box_cfg = {};
|
|
init_blk_box(blk_box_cfg);
|
|
|
|
LCDController::set_backlight(true);
|
|
|
|
lcd_do_splash();
|
|
|
|
LCDController::set_resting_cursor_mode(CursorMode::Show);
|
|
LCDController::set_resting_cursor_pos(0, 0);
|
|
|
|
uint32_t i = 0;
|
|
|
|
while (1) {
|
|
if (InputsController::has_button_press()) {
|
|
Button b = InputsController::wait_button_press();
|
|
printf("Button pressed: %d\n", raw_value(b));
|
|
if (b == Button::GREEN) {
|
|
LEDController::set_indicator(static_cast<IndicatorLED>(i + LED_SHAPE_COUNT), LEDColor::GREEN);
|
|
LEDController::flush();
|
|
} else if (b == Button::YELLOW) {
|
|
LEDController::set_indicator(static_cast<IndicatorLED>(i + LED_SHAPE_COUNT), LEDColor::YELLOW);
|
|
LEDController::flush();
|
|
} else if (b == Button::RED) {
|
|
i = (i + 1) % LED_INDICATOR_COUNT;
|
|
LCDController::set_resting_cursor_pos(0, i % 20);
|
|
} else if (b == Button::BLUE) {
|
|
i = (i + LED_INDICATOR_COUNT - 1) % LED_INDICATOR_COUNT;
|
|
LCDController::set_resting_cursor_pos(0, i % 20);
|
|
}
|
|
}
|
|
|
|
if (InputsController::has_switch_flip()) {
|
|
SwitchFlip flip = InputsController::wait_switch_flip();
|
|
printf("Switch flipped: %d, new state: %d\n", raw_value(flip.get_switch()), flip.is_up());
|
|
}
|
|
|
|
if (InputsController::has_keypad_press()) {
|
|
KeypadKey k = InputsController::wait_keypad_press();
|
|
printf("Keypad key pressed: %c\n", keypad_key_to_char(k));
|
|
LEDController::flush();
|
|
}
|
|
|
|
vTaskDelay(10 / portTICK_PERIOD_MS);
|
|
}
|
|
|
|
}
|