Move Config back to tactility project (#15)
This commit is contained in:
parent
e2209ccba8
commit
18a5c5aa45
@ -1,6 +1,5 @@
|
|||||||
#include "board_config.h"
|
#include "board_config.h"
|
||||||
#include "tactility-esp.h"
|
#include "tactility-esp.h"
|
||||||
#include "services/loader/loader.h"
|
|
||||||
|
|
||||||
// Apps
|
// Apps
|
||||||
#include "hello_world/hello_world.h"
|
#include "hello_world/hello_world.h"
|
||||||
@ -13,11 +12,6 @@ extern const AppManifest wifi_manage_app;
|
|||||||
|
|
||||||
TT_UNUSED void app_main(void) {
|
TT_UNUSED void app_main(void) {
|
||||||
static const Config config = {
|
static const Config config = {
|
||||||
/**
|
|
||||||
* Auto-select a board based on the ./sdkconfig.board.* file
|
|
||||||
* that you copied to ./sdkconfig before you opened this project.
|
|
||||||
*/
|
|
||||||
.hardware = TT_BOARD_HARDWARE,
|
|
||||||
.apps = {
|
.apps = {
|
||||||
&hello_world_app,
|
&hello_world_app,
|
||||||
&wifi_connect_app,
|
&wifi_connect_app,
|
||||||
@ -29,10 +23,13 @@ TT_UNUSED void app_main(void) {
|
|||||||
.auto_start_app_id = NULL
|
.auto_start_app_id = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
tt_esp_init(&config);
|
/**
|
||||||
tt_init(&config.apps, CONFIG_APPS_LIMIT, &config.services, CONFIG_SERVICES_LIMIT);
|
* Auto-select a board based on the ./sdkconfig.board.* file
|
||||||
|
* that you copied to ./sdkconfig before you opened this project.
|
||||||
|
*/
|
||||||
|
tt_esp_init(TT_BOARD_HARDWARE);
|
||||||
|
|
||||||
loader_start_app("desktop", true, NULL);
|
tt_init(&config);
|
||||||
|
|
||||||
wifi_main(NULL);
|
wifi_main(NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,6 @@ void vAssertCalled(TT_UNUSED unsigned long line, TT_UNUSED const char* const fil
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
// static const Config config = {
|
// static const Config config = {
|
||||||
// .hardware = NULL,
|
|
||||||
// .apps = {
|
// .apps = {
|
||||||
// &hello_world_app
|
// &hello_world_app
|
||||||
// },
|
// },
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "devices.h"
|
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
|
#include "hardare.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#include "check.h"
|
#include "check.h"
|
||||||
#include "devices_i.h"
|
#include "hardware_i.h"
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
|
|
||||||
#define TAG "hardware"
|
#define TAG "hardware"
|
||||||
@ -1,16 +1,15 @@
|
|||||||
#include "tactility.h"
|
#include "tactility.h"
|
||||||
|
|
||||||
|
#include "esp_event.h"
|
||||||
|
#include "esp_lvgl_port.h"
|
||||||
|
#include "esp_netif.h"
|
||||||
#include "graphics_i.h"
|
#include "graphics_i.h"
|
||||||
#include "devices_i.h" // TODO: Rename to hardware*.*
|
#include "hardware_i.h" // TODO: Rename to hardware*.*
|
||||||
#include "nvs_flash.h"
|
#include "nvs_flash.h"
|
||||||
#include "partitions.h"
|
#include "partitions.h"
|
||||||
#include "esp_lvgl_port.h"
|
|
||||||
#include "ui/lvgl_sync.h"
|
|
||||||
#include "services/wifi/wifi_credentials.h"
|
|
||||||
#include "services/loader/loader.h"
|
#include "services/loader/loader.h"
|
||||||
#include <sys/cdefs.h>
|
#include "services/wifi/wifi_credentials.h"
|
||||||
#include "esp_netif.h"
|
#include "ui/lvgl_sync.h"
|
||||||
#include "esp_event.h"
|
|
||||||
|
|
||||||
#define TAG "tactility"
|
#define TAG "tactility"
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ static void lvgl_unlock_impl() {
|
|||||||
lvgl_port_unlock();
|
lvgl_port_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tt_esp_init(const Config* _Nonnull config) {
|
void tt_esp_init(const HardwareConfig* hardware_config) {
|
||||||
// Initialize NVS
|
// Initialize NVS
|
||||||
esp_err_t ret = nvs_flash_init();
|
esp_err_t ret = nvs_flash_init();
|
||||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||||
@ -36,14 +35,13 @@ void tt_esp_init(const Config* _Nonnull config) {
|
|||||||
// Network interface
|
// Network interface
|
||||||
ESP_ERROR_CHECK(esp_netif_init());
|
ESP_ERROR_CHECK(esp_netif_init());
|
||||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||||
|
|
||||||
tt_partitions_init();
|
|
||||||
|
|
||||||
tt_wifi_credentials_init();
|
|
||||||
|
|
||||||
tt_lvgl_sync_set(&lvgl_lock_impl, &lvgl_unlock_impl);
|
|
||||||
|
|
||||||
Hardware hardware = tt_hardware_init(config->hardware);
|
|
||||||
/*NbLvgl lvgl =*/tt_graphics_init(&hardware);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
tt_partitions_init();
|
||||||
|
|
||||||
|
tt_wifi_credentials_init();
|
||||||
|
|
||||||
|
tt_lvgl_sync_set(&lvgl_lock_impl, &lvgl_unlock_impl);
|
||||||
|
|
||||||
|
Hardware hardware = tt_hardware_init(hardware_config);
|
||||||
|
/*Lvgl lvgl =*/tt_graphics_init(&hardware);
|
||||||
|
}
|
||||||
|
|||||||
@ -1,23 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "hardare.h"
|
||||||
#include "tactility.h"
|
#include "tactility.h"
|
||||||
#include "devices.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CONFIG_APPS_LIMIT 32
|
|
||||||
#define CONFIG_SERVICES_LIMIT 32
|
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
typedef void* ThreadId;
|
|
||||||
typedef void (*Bootstrap)();
|
typedef void (*Bootstrap)();
|
||||||
typedef TouchDriver (*CreateTouchDriver)();
|
typedef TouchDriver (*CreateTouchDriver)();
|
||||||
typedef DisplayDriver (*CreateDisplayDriver)();
|
typedef DisplayDriver (*CreateDisplayDriver)();
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// Optional bootstrapping method
|
// Optional bootstrapping method (e.g. to turn peripherals on)
|
||||||
const Bootstrap _Nullable bootstrap;
|
const Bootstrap _Nullable bootstrap;
|
||||||
// Required driver for display
|
// Required driver for display
|
||||||
const CreateDisplayDriver _Nonnull display_driver;
|
const CreateDisplayDriver _Nonnull display_driver;
|
||||||
@ -25,15 +21,8 @@ typedef struct {
|
|||||||
const CreateTouchDriver _Nullable touch_driver;
|
const CreateTouchDriver _Nullable touch_driver;
|
||||||
} HardwareConfig;
|
} HardwareConfig;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const HardwareConfig* hardware;
|
|
||||||
// List of user applications
|
|
||||||
const AppManifest* const apps[CONFIG_APPS_LIMIT];
|
|
||||||
const ServiceManifest* const services[CONFIG_SERVICES_LIMIT];
|
|
||||||
const char* auto_start_app_id;
|
|
||||||
} Config;
|
|
||||||
|
|
||||||
void tt_esp_init(const Config* _Nonnull config);
|
void tt_esp_init(const HardwareConfig* hardware_config);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "app_manifest_registry.h"
|
#include "app_manifest_registry.h"
|
||||||
#include "service_registry.h"
|
#include "service_registry.h"
|
||||||
|
#include "services/loader/loader.h"
|
||||||
|
|
||||||
#define TAG "tactility"
|
#define TAG "tactility"
|
||||||
|
|
||||||
@ -19,12 +20,9 @@ static void register_system_apps() {
|
|||||||
tt_app_manifest_registry_add(&system_info_app);
|
tt_app_manifest_registry_add(&system_info_app);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void register_user_apps(
|
static void register_user_apps(const AppManifest* const apps[CONFIG_APPS_LIMIT]) {
|
||||||
const AppManifest* const* _Nonnull apps,
|
|
||||||
size_t apps_count
|
|
||||||
) {
|
|
||||||
TT_LOG_I(TAG, "Registering user apps");
|
TT_LOG_I(TAG, "Registering user apps");
|
||||||
for (size_t i = 0; i < apps_count; i++) {
|
for (size_t i = 0; i < CONFIG_APPS_LIMIT; i++) {
|
||||||
const AppManifest* manifest = apps[i];
|
const AppManifest* manifest = apps[i];
|
||||||
if (manifest != NULL) {
|
if (manifest != NULL) {
|
||||||
tt_app_manifest_registry_add(manifest);
|
tt_app_manifest_registry_add(manifest);
|
||||||
@ -47,12 +45,9 @@ static void start_system_services() {
|
|||||||
tt_service_registry_start(loader_service.id);
|
tt_service_registry_start(loader_service.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void register_and_start_user_services(
|
static void register_and_start_user_services(const ServiceManifest* const services[CONFIG_SERVICES_LIMIT]) {
|
||||||
const ServiceManifest* const* services,
|
|
||||||
size_t servics_count
|
|
||||||
) {
|
|
||||||
TT_LOG_I(TAG, "Registering and starting user services");
|
TT_LOG_I(TAG, "Registering and starting user services");
|
||||||
for (size_t i = 0; i < servics_count; i++) {
|
for (size_t i = 0; i < CONFIG_SERVICES_LIMIT; i++) {
|
||||||
const ServiceManifest* manifest = services[i];
|
const ServiceManifest* manifest = services[i];
|
||||||
if (manifest != NULL) {
|
if (manifest != NULL) {
|
||||||
tt_service_registry_add(manifest);
|
tt_service_registry_add(manifest);
|
||||||
@ -64,12 +59,7 @@ static void register_and_start_user_services(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TT_UNUSED void tt_init(
|
TT_UNUSED void tt_init(const Config* config) {
|
||||||
const AppManifest* const* _Nonnull apps,
|
|
||||||
size_t apps_count,
|
|
||||||
const ServiceManifest* const* services,
|
|
||||||
size_t services_count
|
|
||||||
) {
|
|
||||||
tt_service_registry_init();
|
tt_service_registry_init();
|
||||||
tt_app_manifest_registry_init();
|
tt_app_manifest_registry_init();
|
||||||
|
|
||||||
@ -78,10 +68,20 @@ TT_UNUSED void tt_init(
|
|||||||
register_system_services();
|
register_system_services();
|
||||||
register_system_apps();
|
register_system_apps();
|
||||||
// TODO: move this after start_system_services, but desktop must subscribe to app registry events first.
|
// TODO: move this after start_system_services, but desktop must subscribe to app registry events first.
|
||||||
register_user_apps(apps, apps_count);
|
register_user_apps(config->apps);
|
||||||
|
|
||||||
// Start all services
|
// Start all services
|
||||||
start_system_services();
|
start_system_services();
|
||||||
register_and_start_user_services(services, services_count);
|
register_and_start_user_services(config->services);
|
||||||
|
|
||||||
|
|
||||||
|
TT_LOG_I(TAG, "tt_init starting desktop app");
|
||||||
|
loader_start_app(desktop_app.id, true, NULL);
|
||||||
|
|
||||||
|
if (config->auto_start_app_id) {
|
||||||
|
TT_LOG_I(TAG, "tt_init aut-starting %s", config->auto_start_app_id);
|
||||||
|
loader_start_app(config->auto_start_app_id, true, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
TT_LOG_I(TAG, "tt_init complete");
|
TT_LOG_I(TAG, "tt_init complete");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,12 +7,17 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TT_UNUSED void tt_init(
|
#define CONFIG_APPS_LIMIT 32
|
||||||
const AppManifest* const* apps,
|
#define CONFIG_SERVICES_LIMIT 32
|
||||||
size_t apps_count,
|
|
||||||
const ServiceManifest* const* services,
|
typedef struct {
|
||||||
size_t services_count
|
// List of user applications
|
||||||
);
|
const AppManifest* const apps[CONFIG_APPS_LIMIT];
|
||||||
|
const ServiceManifest* const services[CONFIG_SERVICES_LIMIT];
|
||||||
|
const char* auto_start_app_id;
|
||||||
|
} Config;
|
||||||
|
|
||||||
|
TT_UNUSED void tt_init(const Config* config);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user