* Pull out OmoteUI into its own hpp/cpp that only controls UI/UX Added HardwareAbstractionInterface to allow UI to be decoupled Add OmoteUI class/Header to visual studio solution Bump the compiler to c++17 for std::clamp * code format update visual studio solution to build all versions properly Pull pin defs into config file use config file to allow USE_SIMULATOR checks in OmoteUI this will allow the sim to compile in specific code within the UI * put pin mode config into hardwarerevX class along with some other hardware things. Still lots of work to pull everything into the HAL. Change-Id: If3cacc43d43670b0ff2233140b1cff66a4aeb48d * pull Prefrences, IMU interrupt and sleep into the hardware class Change-Id: I082ae086ed70306789df80eafce8870a5cdfd125 * pull in touch screen, IMU and slow screen wake into hardware Change-Id: I61b49a6d0551463becbc3bdf1418ac9fde9d9376 * Pull wifi and IR into Hardware RevX pull last bit of global variables into hardware rev * un public everything * clean up simulator build * rename loop handler reorder setup to better match the origional main * Add Loop Handler that updates UI * Add images to their own file to shrink OmoteUI * Allow Wifi to be turned off with the macro * Update Battery Update Task instead of a time based check and update * Clean up abstract interface move defenitions out of hardwareRevX.hpp into cpp * reorder HardwareRevX functions * Add comment blocks to top of headers --------- Co-authored-by: Matthew Colvin <35540398+Mc067415@users.noreply.github.com> Co-authored-by: Matthew Colvin <Matthew.Colvin@garmin.com>
		
			
				
	
	
		
			183 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			183 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * 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;
 | |
| }
 |