🎨 clean up
parent
cab8fc55c2
commit
5ea65b93d5
|
@ -1,13 +0,0 @@
|
|||
menu "ESP32-S3-EYE Firmware"
|
||||
choice ESP_SR_LANGUAGE
|
||||
bool "esp-sr language"
|
||||
default CN_MODEL
|
||||
help
|
||||
Select ESP-SR Language.
|
||||
|
||||
config CN_MODEL
|
||||
bool "Chinese"
|
||||
config EN_MODEL
|
||||
bool "English"
|
||||
endchoice
|
||||
endmenu
|
|
@ -1,6 +1,6 @@
|
|||
#include "driver/gpio.h"
|
||||
|
||||
#include "app_buttom.hpp"
|
||||
#include "app_button.hpp"
|
||||
#include "app_camera.hpp"
|
||||
#include "app_lcd.hpp"
|
||||
#include "app_led.hpp"
|
||||
|
@ -14,13 +14,13 @@ extern "C" void app_main()
|
|||
QueueHandle_t xQueueFrame_1 = xQueueCreate(2, sizeof(camera_fb_t *));
|
||||
QueueHandle_t xQueueFrame_2 = xQueueCreate(2, sizeof(camera_fb_t *));
|
||||
|
||||
AppButtom *key = new AppButtom();
|
||||
AppButton *key = new AppButton();
|
||||
AppSpeech *speech = new AppSpeech();
|
||||
AppCamera *camera = new AppCamera(PIXFORMAT_RGB565, FRAMESIZE_240X240, 2, xQueueFrame_0);
|
||||
AppFace *face = new AppFace(key, speech, xQueueFrame_0, xQueueFrame_1);
|
||||
AppMotion *motion = new AppMotion(key, speech, xQueueFrame_1, xQueueFrame_2);
|
||||
AppLCD *lcd = new AppLCD(key, speech, xQueueFrame_2);
|
||||
LED *led = new LED(GPIO_NUM_3, key, speech);
|
||||
AppLED *led = new AppLED(GPIO_NUM_3, key, speech);
|
||||
|
||||
key->attach(face);
|
||||
key->attach(motion);
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "__base__.hpp"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
_IDLE = 0,
|
||||
_MENU,
|
||||
_PLAY,
|
||||
_UP,
|
||||
_DOWN
|
||||
} _key_name_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_key_name_t key; /**< button index on the channel */
|
||||
int min; /**< min voltage in mv corresponding to the button */
|
||||
int max; /**< max voltage in mv corresponding to the button */
|
||||
} key_config_t;
|
||||
|
||||
class AppButtom : public Subject
|
||||
{
|
||||
public:
|
||||
std::vector<key_config_t> key_configs;
|
||||
_key_name_t pressed;
|
||||
|
||||
uint8_t menu;
|
||||
|
||||
AppButtom();
|
||||
~AppButtom();
|
||||
|
||||
void run();
|
||||
};
|
|
@ -0,0 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "__base__.hpp"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_IDLE = 0,
|
||||
BUTTON_MENU,
|
||||
BUTTON_PLAY,
|
||||
BUTTON_UP,
|
||||
BUTTON_DOWN
|
||||
} button_name_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
button_name_t key; /**< button index on the channel */
|
||||
int min; /**< min voltage in mv corresponding to the button */
|
||||
int max; /**< max voltage in mv corresponding to the button */
|
||||
} key_config_t;
|
||||
|
||||
class AppButton : public Subject
|
||||
{
|
||||
public:
|
||||
std::vector<key_config_t> key_configs;
|
||||
button_name_t pressed;
|
||||
|
||||
uint8_t menu;
|
||||
|
||||
AppButton();
|
||||
~AppButton();
|
||||
|
||||
void run();
|
||||
};
|
|
@ -2,11 +2,6 @@
|
|||
|
||||
#include <list>
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "esp_camera.h"
|
||||
|
||||
#include "__base__.hpp"
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "human_face_detect_msr01.hpp"
|
||||
#include "human_face_detect_mnp01.hpp"
|
||||
#include "face_recognition_tool.hpp"
|
||||
// #if CONFIG_MFN_V1_Q8
|
||||
// #include "face_recognition_112_v1_s8.hpp"
|
||||
// #elif CONFIG_MFN_V1_Q16
|
||||
#if CONFIG_MFN_V1
|
||||
#if CONFIG_S8
|
||||
#include "face_recognition_112_v1_s8.hpp"
|
||||
#elif CONFIG_S16
|
||||
#include "face_recognition_112_v1_s16.hpp"
|
||||
// #endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "__base__.hpp"
|
||||
#include "app_camera.hpp"
|
||||
#include "app_buttom.hpp"
|
||||
#include "app_button.hpp"
|
||||
#include "app_speech.hpp"
|
||||
|
||||
typedef enum
|
||||
|
@ -25,18 +29,20 @@ typedef enum
|
|||
class AppFace : public Observer, public Frame
|
||||
{
|
||||
private:
|
||||
AppButtom *key;
|
||||
AppButton *key;
|
||||
AppSpeech *speech;
|
||||
|
||||
public:
|
||||
HumanFaceDetectMSR01 detector;
|
||||
HumanFaceDetectMNP01 detector2;
|
||||
|
||||
// #if CONFIG_MFN_V1_Q8
|
||||
// FaceRecognition112V1S8 *recognizer;
|
||||
// #elif CONFIG_MFN_V1_Q16
|
||||
#if CONFIG_MFN_V1
|
||||
#if CONFIG_S8
|
||||
FaceRecognition112V1S8 *recognizer;
|
||||
#elif CONFIG_S16
|
||||
FaceRecognition112V1S16 *recognizer;
|
||||
// #endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
face_info_t recognize_result;
|
||||
recognizer_state_t state;
|
||||
|
@ -46,7 +52,7 @@ public:
|
|||
|
||||
uint8_t frame_count;
|
||||
|
||||
AppFace(AppButtom *key,
|
||||
AppFace(AppButton *key,
|
||||
AppSpeech *speech,
|
||||
QueueHandle_t queue_i = nullptr,
|
||||
QueueHandle_t queue_o = nullptr,
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_log.h"
|
||||
#include "screen_driver.h"
|
||||
|
||||
#include "__base__.hpp"
|
||||
#include "app_camera.hpp"
|
||||
#include "app_buttom.hpp"
|
||||
#include "app_button.hpp"
|
||||
#include "app_speech.hpp"
|
||||
|
||||
#define BOARD_LCD_MOSI 47
|
||||
|
@ -28,7 +26,7 @@
|
|||
class AppLCD : public Observer, public Frame
|
||||
{
|
||||
private:
|
||||
AppButtom *key;
|
||||
AppButton *key;
|
||||
AppSpeech *speech;
|
||||
|
||||
public:
|
||||
|
@ -36,7 +34,7 @@ public:
|
|||
bool switch_on;
|
||||
bool paper_drawn;
|
||||
|
||||
AppLCD(AppButtom *key,
|
||||
AppLCD(AppButton *key,
|
||||
AppSpeech *speech,
|
||||
QueueHandle_t xQueueFrameI = nullptr,
|
||||
QueueHandle_t xQueueFrameO = nullptr,
|
||||
|
|
|
@ -5,19 +5,18 @@
|
|||
#include "freertos/task.h"
|
||||
#include "driver/gpio.h"
|
||||
|
||||
#include "app_buttom.hpp"
|
||||
#include "app_button.hpp"
|
||||
#include "app_speech.hpp"
|
||||
|
||||
class LED : public Observer
|
||||
class AppLED : public Observer
|
||||
{
|
||||
private:
|
||||
const gpio_num_t pin;
|
||||
AppButtom *key;
|
||||
AppButton *key;
|
||||
AppSpeech *sr;
|
||||
|
||||
public:
|
||||
LED(const gpio_num_t pin, AppButtom *key, AppSpeech *sr);
|
||||
~LED();
|
||||
AppLED(const gpio_num_t pin, AppButton *key, AppSpeech *sr);
|
||||
|
||||
void update();
|
||||
};
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
#include "__base__.hpp"
|
||||
#include "app_camera.hpp"
|
||||
#include "app_buttom.hpp"
|
||||
#include "app_button.hpp"
|
||||
#include "app_speech.hpp"
|
||||
|
||||
class AppMotion : public Observer, public Frame
|
||||
{
|
||||
private:
|
||||
AppButtom *key;
|
||||
AppButton *key;
|
||||
AppSpeech *speech;
|
||||
|
||||
public:
|
||||
bool switch_on;
|
||||
|
||||
AppMotion(AppButtom *key,
|
||||
AppMotion(AppButton *key,
|
||||
AppSpeech *speech,
|
||||
QueueHandle_t queue_i = nullptr,
|
||||
QueueHandle_t queue_o = nullptr,
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "esp_afe_sr_iface.h"
|
||||
|
||||
#include "__base__.hpp"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "app_buttom.hpp"
|
||||
#include "app_button.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -26,16 +26,16 @@
|
|||
|
||||
#define PRESS_INTERVAL 500000
|
||||
|
||||
static const char *TAG = "App/Buttom";
|
||||
static const char *TAG = "App/Button";
|
||||
|
||||
AppButtom::AppButtom() : key_configs({{_MENU, 2800, 3000}, {_PLAY, 2250, 2450}, {_UP, 300, 500}, {_DOWN, 850, 1050}}),
|
||||
pressed(_IDLE)
|
||||
AppButton::AppButton() : key_configs({{BUTTON_MENU, 2800, 3000}, {BUTTON_PLAY, 2250, 2450}, {BUTTON_UP, 300, 500}, {BUTTON_DOWN, 850, 1050}}),
|
||||
pressed(BUTTON_IDLE)
|
||||
{
|
||||
ESP_ERROR_CHECK(adc1_config_width((adc_bits_width_t)ADC_WIDTH_BIT_DEFAULT));
|
||||
ESP_ERROR_CHECK(adc1_config_channel_atten(ADC1_EXAMPLE_CHAN0, ADC_EXAMPLE_ATTEN));
|
||||
}
|
||||
|
||||
static void task(AppButtom *self)
|
||||
static void task(AppButton *self)
|
||||
{
|
||||
int64_t backup_time = esp_timer_get_time();
|
||||
int64_t last_time = esp_timer_get_time();
|
||||
|
@ -52,10 +52,10 @@ static void task(AppButtom *self)
|
|||
{
|
||||
if (((backup_time - last_time) > PRESS_INTERVAL))
|
||||
{
|
||||
ESP_LOGD(TAG, "Key[%d] is pressed", self->pressed);
|
||||
self->pressed = key_config.key;
|
||||
ESP_LOGI(TAG, "Button[%d] is clicked", self->pressed);
|
||||
|
||||
if (self->pressed == _MENU)
|
||||
if (self->pressed == BUTTON_MENU)
|
||||
{
|
||||
self->menu++;
|
||||
self->menu %= (MENU_MOTION_DETECTION + 1);
|
||||
|
@ -64,7 +64,7 @@ static void task(AppButtom *self)
|
|||
last_time = backup_time;
|
||||
self->notify();
|
||||
|
||||
self->pressed = _IDLE;
|
||||
self->pressed = BUTTON_IDLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ static void task(AppButtom *self)
|
|||
}
|
||||
}
|
||||
|
||||
void AppButtom::run()
|
||||
void AppButton::run()
|
||||
{
|
||||
xTaskCreatePinnedToCore((TaskFunction_t)task, TAG, 3 * 1024, this, 5, NULL, 0);
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
#include "app_camera.hpp"
|
||||
|
||||
#include "assert.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ static int rgb_printf(camera_fb_t *fb, uint32_t color, const char *format, ...)
|
|||
return len;
|
||||
}
|
||||
|
||||
AppFace::AppFace(AppButtom *key,
|
||||
AppFace::AppFace(AppButton *key,
|
||||
AppSpeech *speech,
|
||||
QueueHandle_t queue_i,
|
||||
QueueHandle_t queue_o,
|
||||
|
@ -63,44 +63,43 @@ AppFace::AppFace(AppButtom *key,
|
|||
detector2(0.4F, 0.3F, 10),
|
||||
state(IDLE),
|
||||
switch_on(false)
|
||||
// recognizer(
|
||||
// #if CONFIG_MFN_V1_Q8
|
||||
// new FaceRecognition112V1S8()
|
||||
// #elif CONFIG_MFN_V1_Q16
|
||||
// new FaceRecognition112V1S16()
|
||||
// #endif
|
||||
// )
|
||||
{
|
||||
// this->recognizer = new FaceRecognition112V1S8();
|
||||
#if CONFIG_MFN_V1
|
||||
#if CONFIG_S8
|
||||
this->recognizer = new FaceRecognition112V1S8();
|
||||
#elif CONFIG_S16
|
||||
this->recognizer = new FaceRecognition112V1S16();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
this->recognizer->set_partition(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "fr");
|
||||
int partition_result = this->recognizer->set_ids_from_flash();
|
||||
this->recognizer->set_ids_from_flash();
|
||||
}
|
||||
|
||||
AppFace::~AppFace()
|
||||
{
|
||||
delete this->recognizer;
|
||||
}
|
||||
|
||||
void AppFace::update()
|
||||
{
|
||||
// Parse key
|
||||
if (this->key->pressed > _IDLE)
|
||||
if (this->key->pressed > BUTTON_IDLE)
|
||||
{
|
||||
if (this->key->pressed == _MENU)
|
||||
if (this->key->pressed == BUTTON_MENU)
|
||||
{
|
||||
this->switch_on = (this->key->menu == MENU_FACE_RECOGNITION) ? true : false;
|
||||
ESP_LOGD(TAG, "%s", this->switch_on ? "ON" : "OFF");
|
||||
}
|
||||
else if (this->key->pressed == _PLAY)
|
||||
else if (this->key->pressed == BUTTON_PLAY)
|
||||
{
|
||||
this->state = RECOGNIZE;
|
||||
}
|
||||
else if (this->key->pressed == _UP)
|
||||
else if (this->key->pressed == BUTTON_UP)
|
||||
{
|
||||
this->state = ENROLL;
|
||||
}
|
||||
else if (this->key->pressed == _DOWN)
|
||||
else if (this->key->pressed == BUTTON_DOWN)
|
||||
{
|
||||
this->state = DELETE;
|
||||
}
|
||||
|
@ -159,7 +158,7 @@ static void task(AppFace *self)
|
|||
{
|
||||
case ENROLL:
|
||||
self->recognizer->enroll_id((uint16_t *)frame->buf, {(int)frame->height, (int)frame->width, 3}, detect_results.front().keypoint, "", true);
|
||||
ESP_LOGW(TAG, "Enroll ID %d", self->recognizer->get_enrolled_ids().back().id);
|
||||
ESP_LOGI(TAG, "Enroll ID %d", self->recognizer->get_enrolled_ids().back().id);
|
||||
break;
|
||||
|
||||
case RECOGNIZE:
|
||||
|
@ -169,13 +168,13 @@ static void task(AppFace *self)
|
|||
if (self->recognize_result.id > 0)
|
||||
ESP_LOGI(TAG, "Match ID: %d", self->recognize_result.id);
|
||||
else
|
||||
ESP_LOGE(TAG, "Match ID: %d", self->recognize_result.id);
|
||||
ESP_LOGI(TAG, "Match ID: %d", self->recognize_result.id);
|
||||
break;
|
||||
|
||||
case DELETE:
|
||||
vTaskDelay(10);
|
||||
self->recognizer->delete_id(true);
|
||||
ESP_LOGE(TAG, "%d IDs left", self->recognizer->get_enrolled_id_num());
|
||||
ESP_LOGI(TAG, "%d IDs left", self->recognizer->get_enrolled_id_num());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_camera.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
|
@ -13,7 +14,7 @@
|
|||
|
||||
static const char TAG[] = "App/LCD";
|
||||
|
||||
AppLCD::AppLCD(AppButtom *key,
|
||||
AppLCD::AppLCD(AppButton *key,
|
||||
AppSpeech *speech,
|
||||
QueueHandle_t queue_i,
|
||||
QueueHandle_t queue_o,
|
||||
|
@ -120,9 +121,9 @@ void AppLCD::draw_color(int color)
|
|||
|
||||
void AppLCD::update()
|
||||
{
|
||||
if (this->key->pressed > _IDLE)
|
||||
if (this->key->pressed > BUTTON_IDLE)
|
||||
{
|
||||
if (this->key->pressed == _MENU)
|
||||
if (this->key->pressed == BUTTON_MENU)
|
||||
{
|
||||
this->switch_on = (this->key->menu == MENU_STOP_WORKING) ? false : true;
|
||||
ESP_LOGD(TAG, "%s", this->switch_on ? "ON" : "OFF");
|
||||
|
|
|
@ -19,7 +19,7 @@ typedef enum
|
|||
LED_BLINK_4S = 10,
|
||||
} led_mode_t;
|
||||
|
||||
LED::LED(const gpio_num_t pin, AppButtom *key, AppSpeech *sr) : pin(pin), key(key), sr(sr)
|
||||
AppLED::AppLED(const gpio_num_t pin, AppButton *key, AppSpeech *sr) : pin(pin), key(key), sr(sr)
|
||||
{
|
||||
// initialize GPIO
|
||||
gpio_config_t gpio_conf;
|
||||
|
@ -33,14 +33,14 @@ LED::LED(const gpio_num_t pin, AppButtom *key, AppSpeech *sr) : pin(pin), key(ke
|
|||
gpio_set_level(this->pin, 0);
|
||||
}
|
||||
|
||||
void LED::update()
|
||||
void AppLED::update()
|
||||
{
|
||||
led_mode_t mode = LED_ALWAYS_OFF;
|
||||
|
||||
// parse key
|
||||
if (this->key->pressed)
|
||||
{
|
||||
mode = LED_BLINK_2S;
|
||||
mode = LED_BLINK_1S;
|
||||
}
|
||||
// parse speech recognition
|
||||
else if (this->sr->detected)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "app_motion.hpp"
|
||||
|
||||
#include "assert.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_camera.h"
|
||||
|
||||
|
@ -9,7 +7,7 @@
|
|||
|
||||
static const char TAG[] = "App/Motion";
|
||||
|
||||
AppMotion::AppMotion(AppButtom *key,
|
||||
AppMotion::AppMotion(AppButton *key,
|
||||
AppSpeech *speech,
|
||||
QueueHandle_t queue_i,
|
||||
QueueHandle_t queue_o,
|
||||
|
@ -20,9 +18,9 @@ AppMotion::AppMotion(AppButtom *key,
|
|||
|
||||
void AppMotion::update()
|
||||
{
|
||||
if (this->key->pressed > _IDLE)
|
||||
if (this->key->pressed > BUTTON_IDLE)
|
||||
{
|
||||
if (this->key->pressed == _MENU)
|
||||
if (this->key->pressed == BUTTON_MENU)
|
||||
{
|
||||
this->switch_on = (this->key->menu == MENU_MOTION_DETECTION) ? true : false;
|
||||
ESP_LOGD(TAG, "%s", this->switch_on ? "ON" : "OFF");
|
||||
|
|
|
@ -162,7 +162,7 @@ static void detect_hander(AppSpeech *self)
|
|||
else
|
||||
{
|
||||
self->notify();
|
||||
ESP_LOGD(TAG, "Command: %d", self->command);
|
||||
ESP_LOGI(TAG, "Command: %d", self->command);
|
||||
|
||||
#ifndef CONFIG_SR_MN_CN_MULTINET3_CONTINUOUS_RECOGNITION
|
||||
self->afe_handle->enable_wakenet(afe_data);
|
||||
|
|
|
@ -25,7 +25,8 @@ CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y
|
|||
# Image Relation
|
||||
CONFIG_CAMERA_MODULE_ESP_S3_EYE=y
|
||||
CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ST7789=y
|
||||
CONFIG_MFN_V1_Q8=y
|
||||
CONFIG_MFN_V1=y
|
||||
CONFIG_S8=y
|
||||
|
||||
|
||||
# Speech Relation
|
||||
|
|
Loading…
Reference in New Issue