Re work directory structure to support new architecture
Still need to get the Sim building
This commit is contained in:
parent
cf9430ca7c
commit
17f751a08a
13 changed files with 353 additions and 6 deletions
|
@ -2,7 +2,7 @@
|
||||||
#include "SparkFunLIS3DH.h"
|
#include "SparkFunLIS3DH.h"
|
||||||
|
|
||||||
#include "HardwareInterface.h"
|
#include "HardwareInterface.h"
|
||||||
#include "WiFi.h"
|
#include <WiFi.h>
|
||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include <Adafruit_FT6206.h>
|
#include <Adafruit_FT6206.h>
|
55
Platformio/HAL/Targets/ESP32/omoteconfig.h
Normal file
55
Platformio/HAL/Targets/ESP32/omoteconfig.h
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define IS_SIMULATOR false
|
||||||
|
|
||||||
|
// Comment out to disable connected features
|
||||||
|
#define ENABLE_WIFI
|
||||||
|
#define WIFI_SSID "YOUR_WIFI_SSID"
|
||||||
|
#define WIFI_PASSWORD "YOUR_WIFI_PASSWORD"
|
||||||
|
#define MQTT_SERVER "YOUR_MQTT_SERVER_IP"
|
||||||
|
|
||||||
|
// time until device enters sleep mode in milliseconds
|
||||||
|
#define SLEEP_TIMEOUT 20000
|
||||||
|
|
||||||
|
// motion above threshold keeps device awake
|
||||||
|
#define MOTION_THRESHOLD 50
|
||||||
|
|
||||||
|
// IO34+IO35+IO37+IO38+IO39(+IO13)
|
||||||
|
#define BUTTON_PIN_BITMASK 0b1110110000000000000000000010000000000000
|
||||||
|
|
||||||
|
#define SCREEN_WIDTH 240
|
||||||
|
#define SCREEN_HEIGHT 360
|
||||||
|
|
||||||
|
// Pin assignment
|
||||||
|
// -----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define LCD_DC 9 // defined in TFT_eSPI User_Setup.h
|
||||||
|
#define LCD_CS 5
|
||||||
|
#define LCD_MOSI 23
|
||||||
|
#define LCD_SCK 18
|
||||||
|
#define LCD_BL 4
|
||||||
|
#define LCD_EN 10
|
||||||
|
|
||||||
|
#define USER_LED 2
|
||||||
|
|
||||||
|
#define SW_1 32 // 1...5: Output
|
||||||
|
#define SW_2 26
|
||||||
|
#define SW_3 27
|
||||||
|
#define SW_4 14
|
||||||
|
#define SW_5 12
|
||||||
|
#define SW_A 37 // A...E: Input
|
||||||
|
#define SW_B 38
|
||||||
|
#define SW_C 39
|
||||||
|
#define SW_D 34
|
||||||
|
#define SW_E 35
|
||||||
|
|
||||||
|
#define IR_RX 15 // IR receiver input
|
||||||
|
#define ADC_BAT 36 // Battery voltage sense input (1/2 divider)
|
||||||
|
#define IR_VCC 25 // IR receiver power
|
||||||
|
#define IR_LED 33 // IR LED output
|
||||||
|
|
||||||
|
#define SCL 22
|
||||||
|
#define SDA 19
|
||||||
|
#define ACC_INT 20
|
||||||
|
|
||||||
|
#define CRG_STAT 21 // battery charger feedback
|
1
Platformio/HAL/Targets/Simulator/HardwareSimulator.cpp
Normal file
1
Platformio/HAL/Targets/Simulator/HardwareSimulator.cpp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "HardwareSimulator.hpp"
|
29
Platformio/HAL/Targets/Simulator/HardwareSimulator.hpp
Normal file
29
Platformio/HAL/Targets/Simulator/HardwareSimulator.hpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#pragma once
|
||||||
|
#include "HardwareInterface.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class HardwareSimulator : public HardwareInterface {
|
||||||
|
public:
|
||||||
|
HardwareSimulator() = default;
|
||||||
|
|
||||||
|
virtual void debugPrint(std::string message) override {
|
||||||
|
std::cout << message;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void sendIR() override {}
|
||||||
|
|
||||||
|
virtual void MQTTPublish(const char *topic, const char *payload) override{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void init() override { lv_init(); }
|
||||||
|
|
||||||
|
virtual batteryStatus getBatteryPercentage() {
|
||||||
|
batteryStatus fakeStatus;
|
||||||
|
fakeStatus.isCharging = false;
|
||||||
|
fakeStatus.percentage = 100;
|
||||||
|
fakeStatus.voltage = 4200;
|
||||||
|
return fakeStatus;
|
||||||
|
}
|
||||||
|
};
|
6
Platformio/HAL/Targets/Simulator/omoteconfig.h
Normal file
6
Platformio/HAL/Targets/Simulator/omoteconfig.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define IS_SIMULATOR true
|
||||||
|
|
||||||
|
#define SCREEN_WIDTH 240
|
||||||
|
#define SCREEN_HEIGHT 360
|
|
@ -8,6 +8,27 @@
|
||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[platformio]
|
||||||
|
default_envs = esp32
|
||||||
|
|
||||||
|
|
||||||
|
; ; Shared options
|
||||||
|
; [env]
|
||||||
|
; build_flags =
|
||||||
|
; ; Don't use lv_conf.h. Tweak params via platfom.ini.
|
||||||
|
; -D LV_CONF_SKIP
|
||||||
|
; -D LV_CONF_INCLUDE_SIMPLE
|
||||||
|
; ; Enable LVGL demo, remove when working on your own project
|
||||||
|
; -D LV_USE_DEMO_WIDGETS=1
|
||||||
|
; ; Add more defines below to overide lvgl:/src/lv_conf_simple.h
|
||||||
|
; lib_deps =
|
||||||
|
; ; Use direct URL, because package registry is unstable
|
||||||
|
; ;lvgl@~7.11.0
|
||||||
|
; lvgl=https://github.com/lvgl/lvgl/archive/refs/tags/v8.2.0.zip
|
||||||
|
; lib_archive = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[env:esp32]
|
[env:esp32]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
|
@ -23,13 +44,21 @@ lib_deps =
|
||||||
lvgl/lvgl@^8.3.4
|
lvgl/lvgl@^8.3.4
|
||||||
bodmer/TFT_eSPI@^2.5.23
|
bodmer/TFT_eSPI@^2.5.23
|
||||||
knolleary/PubSubClient@^2.8
|
knolleary/PubSubClient@^2.8
|
||||||
|
Wire
|
||||||
|
WiFi
|
||||||
|
SPI
|
||||||
|
Keypad
|
||||||
|
Preferences
|
||||||
build_flags =
|
build_flags =
|
||||||
-std=c++17
|
-std=c++17
|
||||||
-std=gnu++17
|
-std=gnu++17
|
||||||
-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||||
-I include
|
-I include
|
||||||
-I include/OmoteUI
|
-I OmoteUI
|
||||||
; Include the folder containing lv_conf.h
|
-I HAL
|
||||||
|
-I HAL/Interface
|
||||||
|
-I HAL/Targets/ESP32
|
||||||
|
|
||||||
; The following lines replace the TFT_eSPI User_setup.h-file
|
; The following lines replace the TFT_eSPI User_setup.h-file
|
||||||
-D USER_SETUP_LOADED=1
|
-D USER_SETUP_LOADED=1
|
||||||
-D ILI9341_DRIVER=1
|
-D ILI9341_DRIVER=1
|
||||||
|
@ -40,7 +69,7 @@ build_flags =
|
||||||
-D TFT_CS=5
|
-D TFT_CS=5
|
||||||
-D TFT_DC=9
|
-D TFT_DC=9
|
||||||
-D TFT_RST=-1
|
-D TFT_RST=-1
|
||||||
-D SPI_FREQUENCY=80000000
|
-D SPI_FREQUENCY=40000000 ; 40MHz default, some displays might support 80MHz
|
||||||
-D SPI_TOUCH_FREQUENCY=2500000
|
-D SPI_TOUCH_FREQUENCY=2500000
|
||||||
; TFT_eSPI fonts are disabled by default
|
; TFT_eSPI fonts are disabled by default
|
||||||
;-D LOAD_GLCD=1
|
;-D LOAD_GLCD=1
|
||||||
|
@ -52,4 +81,48 @@ build_flags =
|
||||||
;-D LOAD_GFXFF=1
|
;-D LOAD_GFXFF=1
|
||||||
;-D SMOOTH_FONT=1
|
;-D SMOOTH_FONT=1
|
||||||
build_unflags =
|
build_unflags =
|
||||||
-std=gnu++11
|
-std=gnu++11
|
||||||
|
build_src_filter =
|
||||||
|
+<main.cpp>
|
||||||
|
+<../HAL/Targets/ESP32/*>
|
||||||
|
+<../OmoteUI/*>
|
||||||
|
|
||||||
|
|
||||||
|
[env:emulator_64bits]
|
||||||
|
platform = native@^1.1.3
|
||||||
|
build_flags =
|
||||||
|
${env.build_flags}
|
||||||
|
; -D LV_LOG_LEVEL=LV_LOG_LEVEL_INFO
|
||||||
|
-D LV_LOG_PRINTF=1
|
||||||
|
;-lSDL2
|
||||||
|
; SDL drivers options
|
||||||
|
-D LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
-D LV_DRV_NO_CONF
|
||||||
|
; -D USE_SDL
|
||||||
|
; -D SDL_HOR_RES=480
|
||||||
|
; -D SDL_VER_RES=320
|
||||||
|
; -D SDL_ZOOM=1
|
||||||
|
|
||||||
|
; LVGL memory options, setup for the demo to run properly
|
||||||
|
-D LV_MEM_CUSTOM=1
|
||||||
|
-D LV_MEM_SIZE="(128U * 1024U)"
|
||||||
|
|
||||||
|
lib_deps =
|
||||||
|
${env.lib_deps}
|
||||||
|
; Use direct URL, because package registry is unstable
|
||||||
|
;lv_drivers@~7.9.0
|
||||||
|
lv_drivers=https://github.com/lvgl/lv_drivers/archive/refs/tags/v8.2.0.zip
|
||||||
|
build_src_filter =
|
||||||
|
+<*>
|
||||||
|
; Force compile LVGL demo, remove when working on your own project
|
||||||
|
|
||||||
|
|
||||||
|
[env:emulator_32bits]
|
||||||
|
extends = env:emulator_64bits
|
||||||
|
build_flags =
|
||||||
|
${env:emulator_64bits.build_flags}
|
||||||
|
-m32
|
||||||
|
build_src_filter =
|
||||||
|
+<*>
|
||||||
|
+<../hal/sdl2>
|
||||||
|
+<../.pio/libdeps/emulator_32bits/lvgl/demos>
|
||||||
|
|
183
Platformio/src/LVGL.Simulator.cpp
Normal file
183
Platformio/src/LVGL.Simulator.cpp
Normal file
|
@ -0,0 +1,183 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: LVGL PC Simulator using Visual Studio
|
||||||
|
* FILE: LVGL.Simulator.cpp
|
||||||
|
* PURPOSE: Implementation for LVGL ported to Windows Desktop
|
||||||
|
*
|
||||||
|
* LICENSE: The MIT License
|
||||||
|
*
|
||||||
|
* DEVELOPER: Mouri_Naruto (Mouri_Naruto AT Outlook.com)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <string>
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#include "omoteconfig.h"
|
||||||
|
#include "HardwareSimulator.hpp"
|
||||||
|
#include "OmoteUI.hpp"
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1200
|
||||||
|
// Disable compilation warnings.
|
||||||
|
#pragma warning(push)
|
||||||
|
// nonstandard extension used : bit field types other than int
|
||||||
|
#pragma warning(disable : 4214)
|
||||||
|
// 'conversion' conversion from 'type1' to 'type2', possible loss of data
|
||||||
|
#pragma warning(disable : 4244)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "lvgl/lvgl.h"
|
||||||
|
#include "lv_drivers/win32drv/win32drv.h"
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1200
|
||||||
|
// Restore compilation warnings.
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
bool single_display_mode_initialization()
|
||||||
|
{
|
||||||
|
if (!lv_win32_init(
|
||||||
|
GetModuleHandleW(NULL),
|
||||||
|
SW_SHOW,
|
||||||
|
240,
|
||||||
|
320,
|
||||||
|
LoadIconW(GetModuleHandleW(NULL), MAKEINTRESOURCE(IDI_LVGL))))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
lv_win32_add_all_input_devices_to_group(NULL);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <process.h>
|
||||||
|
|
||||||
|
HANDLE g_window_mutex = NULL;
|
||||||
|
bool g_initialization_status = false;
|
||||||
|
|
||||||
|
#define LVGL_SIMULATOR_MAXIMUM_DISPLAYS 16
|
||||||
|
HWND g_display_window_handles[LVGL_SIMULATOR_MAXIMUM_DISPLAYS];
|
||||||
|
|
||||||
|
unsigned int __stdcall lv_win32_window_thread_entrypoint(
|
||||||
|
void *raw_parameter)
|
||||||
|
{
|
||||||
|
size_t display_id = *(size_t *)(raw_parameter);
|
||||||
|
|
||||||
|
HINSTANCE instance_handle = GetModuleHandleW(NULL);
|
||||||
|
int show_window_mode = SW_SHOW;
|
||||||
|
HICON icon_handle = LoadIconW(instance_handle, MAKEINTRESOURCE(IDI_LVGL));
|
||||||
|
lv_coord_t hor_res = 240;
|
||||||
|
lv_coord_t ver_res = 320;
|
||||||
|
|
||||||
|
wchar_t window_title[256];
|
||||||
|
memset(window_title, 0, sizeof(window_title));
|
||||||
|
_snwprintf(
|
||||||
|
window_title,
|
||||||
|
256,
|
||||||
|
L"LVGL Simulator for Windows Desktop (Display %d)",
|
||||||
|
display_id);
|
||||||
|
|
||||||
|
g_display_window_handles[display_id] = lv_win32_create_display_window(
|
||||||
|
window_title,
|
||||||
|
hor_res,
|
||||||
|
ver_res,
|
||||||
|
instance_handle,
|
||||||
|
icon_handle,
|
||||||
|
show_window_mode);
|
||||||
|
if (!g_display_window_handles[display_id])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_initialization_status = true;
|
||||||
|
|
||||||
|
SetEvent(g_window_mutex);
|
||||||
|
|
||||||
|
MSG message;
|
||||||
|
while (GetMessageW(&message, NULL, 0, 0))
|
||||||
|
{
|
||||||
|
TranslateMessage(&message);
|
||||||
|
DispatchMessageW(&message);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_win32_quit_signal = true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool multiple_display_mode_initialization()
|
||||||
|
{
|
||||||
|
if (!lv_win32_init_window_class())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < LVGL_SIMULATOR_MAXIMUM_DISPLAYS; ++i)
|
||||||
|
{
|
||||||
|
g_initialization_status = false;
|
||||||
|
|
||||||
|
g_window_mutex = CreateEventExW(NULL, NULL, 0, EVENT_ALL_ACCESS);
|
||||||
|
|
||||||
|
_beginthreadex(
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
lv_win32_window_thread_entrypoint,
|
||||||
|
&i,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
WaitForSingleObjectEx(g_window_mutex, INFINITE, FALSE);
|
||||||
|
|
||||||
|
CloseHandle(g_window_mutex);
|
||||||
|
|
||||||
|
if (!g_initialization_status)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_win32_window_context_t *context = (lv_win32_window_context_t *)(lv_win32_get_window_context(g_display_window_handles[0]));
|
||||||
|
if (context)
|
||||||
|
{
|
||||||
|
lv_win32_pointer_device_object = context->mouse_device_object;
|
||||||
|
lv_win32_keypad_device_object = context->keyboard_device_object;
|
||||||
|
lv_win32_encoder_device_object = context->mousewheel_device_object;
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_win32_add_all_input_devices_to_group(NULL);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
auto hal = std::make_shared<HardwareSimulator>();
|
||||||
|
hal->init();
|
||||||
|
|
||||||
|
auto ui = OmoteUI::getInstance(hal);
|
||||||
|
|
||||||
|
if (!single_display_mode_initialization())
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->layout_UI();
|
||||||
|
|
||||||
|
while (!lv_win32_quit_signal)
|
||||||
|
{
|
||||||
|
lv_task_handler();
|
||||||
|
// std::string strng = std::to_string(scroll_value);
|
||||||
|
// const char* pchar = strng.c_str();
|
||||||
|
// OutputDebugStringW();
|
||||||
|
// lv_label_set_text_fmt(scrollPos, "%d %d", lv_obj_get_scroll_x(lv_tabview_get_content(tabview)), lv_obj_get_scroll_x(panel));
|
||||||
|
|
||||||
|
Sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <lvgl.h>
|
#include <lvgl.h>
|
||||||
#include "HardwareRevX.hpp"
|
#include "HardwareRevX.hpp"
|
||||||
#include "OmoteUI/OmoteUI.hpp"
|
#include "OmoteUI.hpp"
|
||||||
#include "omoteconfig.h"
|
#include "omoteconfig.h"
|
||||||
|
|
||||||
std::shared_ptr<HardwareRevX> hal = nullptr;
|
std::shared_ptr<HardwareRevX> hal = nullptr;
|
||||||
|
|
Loading…
Add table
Reference in a new issue