initial commit
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
idf_component_register(
|
||||
SRC_DIRS "src"
|
||||
INCLUDE_DIRS "inc"
|
||||
PRIV_INCLUDE_DIRS "src"
|
||||
REQUIRES esp_lcd esp_lcd_touch driver
|
||||
)
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef NANOBAKE_H
|
||||
#define NANOBAKE_H
|
||||
|
||||
#include "nb_platform.h"
|
||||
|
||||
#endif //NANOBAKE_H
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef NANOBAKE_NB_DISPLAY_H
|
||||
#define NANOBAKE_NB_DISPLAY_H
|
||||
|
||||
#include <esp_lcd_panel_io.h>
|
||||
|
||||
typedef struct nb_display nb_display_t;
|
||||
|
||||
struct nb_display {
|
||||
bool io_initialized;
|
||||
uint16_t horizontal_resolution;
|
||||
uint16_t vertical_resolution;
|
||||
uint16_t draw_buffer_height;
|
||||
uint16_t bits_per_pixel;
|
||||
esp_lcd_panel_io_handle_t io_handle;
|
||||
esp_lcd_panel_handle_t display_handle;
|
||||
};
|
||||
|
||||
typedef struct nb_display_driver nb_display_driver_t;
|
||||
|
||||
struct nb_display_driver {
|
||||
const char name[32];
|
||||
esp_err_t (*create_display)(nb_display_t* display);
|
||||
};
|
||||
|
||||
extern esp_err_t nb_display_create(nb_display_driver_t driver, nb_display_t* display);
|
||||
|
||||
#endif // NANOBAKE_NB_DISPLAY_H
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef NANOBAKE_NB_PLATFORM_H
|
||||
#define NANOBAKE_NB_PLATFORM_H
|
||||
|
||||
#include "nb_display.h"
|
||||
#include "nb_touch.h"
|
||||
#include <esp_err.h>
|
||||
|
||||
typedef struct nb_platform_config nb_platform_config_t;
|
||||
struct nb_platform_config {
|
||||
nb_display_driver_t display_driver;
|
||||
nb_touch_driver_t touch_driver;
|
||||
};
|
||||
|
||||
typedef struct nb_platform nb_platform_t;
|
||||
struct nb_platform {
|
||||
nb_display_t display;
|
||||
nb_touch_t touch;
|
||||
};
|
||||
|
||||
esp_err_t nb_platform_create(nb_platform_config_t config, nb_platform_t* platform);
|
||||
|
||||
#endif // NANOBAKE_NB_PLATFORM_H
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef NANOBAKE_NB_TOUCH_H
|
||||
#define NANOBAKE_NB_TOUCH_H
|
||||
|
||||
#include "esp_lcd_touch.h"
|
||||
#include <esp_lcd_panel_io.h>
|
||||
|
||||
typedef struct nb_touch_driver nb_touch_driver_t;
|
||||
|
||||
struct nb_touch_driver {
|
||||
const char name[32];
|
||||
esp_err_t (*init_io)(esp_lcd_panel_io_handle_t* io_handle);
|
||||
esp_err_t (*create_touch)(esp_lcd_panel_io_handle_t io_handle, esp_lcd_touch_handle_t* touch_handle);
|
||||
};
|
||||
|
||||
typedef struct nb_touch nb_touch_t;
|
||||
|
||||
struct nb_touch {
|
||||
esp_lcd_panel_io_handle_t io_handle;
|
||||
esp_lcd_touch_handle_t touch_handle;
|
||||
};
|
||||
|
||||
esp_err_t nb_touch_create(nb_touch_driver_t driver, nb_touch_t* touch);
|
||||
|
||||
#endif // NANOBAKE_NB_TOUCH_H
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "nb_display.h"
|
||||
#include "nb_internal.h"
|
||||
#include <esp_check.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
esp_err_t nb_display_create(nb_display_driver_t driver, nb_display_t* display) {
|
||||
ESP_RETURN_ON_ERROR(driver.create_display(display), nbi_tag, "failed to create driver");
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "nb_internal.h"
|
||||
|
||||
const char* nbi_tag = "nanobake";
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef NANOBAKE_NB_INTERNAL_H
|
||||
#define NANOBAKE_NB_INTERNAL_H
|
||||
|
||||
extern const char* nbi_tag;
|
||||
|
||||
#endif // NANOBAKE_NB_INTERNAL_H
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "nb_platform.h"
|
||||
#include <esp_check.h>
|
||||
#include "nb_display.h"
|
||||
#include "nb_touch.h"
|
||||
#include "nb_internal.h"
|
||||
|
||||
static const char* TAG = "nb_platform";
|
||||
|
||||
esp_err_t nb_platform_create(nb_platform_config_t config, nb_platform_t* platform) {
|
||||
ESP_LOGI(TAG, "display with driver %s", config.display_driver.name);
|
||||
ESP_RETURN_ON_ERROR(
|
||||
nb_display_create(config.display_driver, &(platform->display)),
|
||||
nbi_tag,
|
||||
"display driver init failed"
|
||||
);
|
||||
|
||||
ESP_LOGI(TAG, "touch with driver %s", config.touch_driver.name);
|
||||
ESP_RETURN_ON_ERROR(
|
||||
nb_touch_create(config.touch_driver, &(platform->touch)),
|
||||
nbi_tag,
|
||||
"touch driver init failed"
|
||||
);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "nb_touch.h"
|
||||
#include <esp_check.h>
|
||||
#include "nb_internal.h"
|
||||
|
||||
esp_err_t nb_touch_create(nb_touch_driver_t driver, nb_touch_t* touch) {
|
||||
ESP_RETURN_ON_ERROR(driver.init_io(&(touch->io_handle)), nbi_tag, "failed to init io");
|
||||
ESP_RETURN_ON_ERROR(driver.create_touch(touch->io_handle, &(touch->touch_handle)), nbi_tag, "failed to create driver");
|
||||
return ESP_OK;
|
||||
}
|
||||
Reference in New Issue
Block a user