Skip to content

Commit

Permalink
Lay the ground work for a hardware abstraction layer (#15)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Matthew Colvin <[email protected]>
  • Loading branch information
3 people authored Jul 31, 2023
1 parent be3a203 commit f1ff9ed
Show file tree
Hide file tree
Showing 18 changed files with 3,381 additions and 1,991 deletions.
1 change: 1 addition & 0 deletions LVGL Simulator/LVGL.Simulator/HardwareSimulator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "HardwareSimulator.hpp"
30 changes: 30 additions & 0 deletions LVGL Simulator/LVGL.Simulator/HardwareSimulator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once
#include "HardwareAbstractionInterface.h"
#include <string>
#include <iostream>

class HardwareSimulator :
public HardwareAbstractionInterface
{
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();
}

};

777 changes: 38 additions & 739 deletions LVGL Simulator/LVGL.Simulator/LVGL.Simulator.cpp

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion LVGL Simulator/LVGL.Simulator/LVGL.Simulator.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<MileProjectType>ConsoleApplication</MileProjectType>
<MileProjectManifestFile>LVGL.Simulator.manifest</MileProjectManifestFile>
<MileProjectEnableVCLTLSupport>true</MileProjectEnableVCLTLSupport>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)'=='Debug'">
<SupportLTL>false</SupportLTL>
Expand All @@ -18,6 +19,9 @@
<PropertyGroup>
<IncludePath>$(MSBuildThisFileDirectory);$(MSBuildThisFileDirectory)..\LvglPlatform\lvgl\;$(MSBuildThisFileDirectory)..\LvglPlatform\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<SourcePath>$(VC_SourcePath);</SourcePath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level3</WarningLevel>
Expand All @@ -32,10 +36,19 @@
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<Import Project="LVGL.Portable.vcxitems" />
<Import Project="LVGL.Drivers.vcxitems" />
<ItemGroup>
<ClInclude Include="..\..\Platformio\include\OmoteUI\HardwareAbstractionInterface.h" />
<ClInclude Include="..\..\Platformio\include\OmoteUI\Images.hpp" />
<ClInclude Include="..\..\Platformio\include\OmoteUI\OmoteUI.hpp" />
<ClInclude Include="HardwareSimulator.hpp" />
<ClInclude Include="omoteconfig.h" />
<ClInclude Include="lv_conf.h" />
</ItemGroup>
<ItemGroup>
Expand All @@ -49,7 +62,12 @@
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="LVGL.Simulator.cpp" />
<ClCompile Include="..\..\Platformio\src\HardwareAbstractionInterface.cpp" />
<ClCompile Include="..\..\Platformio\src\OmoteUI.cpp" />
<ClCompile Include="HardwareSimulator.cpp" />
<ClCompile Include="LVGL.Simulator.cpp">
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">stdcpp17</LanguageStandard>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="LVGL.Simulator.rc" />
Expand Down
23 changes: 23 additions & 0 deletions LVGL Simulator/LVGL.Simulator/LVGL.Simulator.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
<ItemGroup>
<ClInclude Include="lv_conf.h" />
<ClInclude Include="lv_drv_conf.h" />
<ClInclude Include="HardwareSimulator.hpp" />
<ClInclude Include="..\..\Platformio\include\OmoteUI\HardwareAbstractionInterface.h">
<Filter>OmoteUI</Filter>
</ClInclude>
<ClInclude Include="..\..\Platformio\include\OmoteUI\OmoteUI.hpp">
<Filter>OmoteUI</Filter>
</ClInclude>
<ClInclude Include="omoteconfig.h" />
<ClInclude Include="..\..\Platformio\include\OmoteUI\Images.hpp">
<Filter>OmoteUI</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Manifest Include="LVGL.Simulator.manifest" />
Expand All @@ -15,6 +26,13 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="LVGL.Simulator.cpp" />
<ClCompile Include="HardwareSimulator.cpp" />
<ClCompile Include="..\..\Platformio\src\HardwareAbstractionInterface.cpp">
<Filter>OmoteUI</Filter>
</ClCompile>
<ClCompile Include="..\..\Platformio\src\OmoteUI.cpp">
<Filter>OmoteUI</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="LVGL.Simulator.rc" />
Expand All @@ -25,4 +43,9 @@
<ItemGroup>
<None Include="freetype.props" />
</ItemGroup>
<ItemGroup>
<Filter Include="OmoteUI">
<UniqueIdentifier>{0b1f99aa-73cb-482d-9d62-20e17f93b890}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
6 changes: 6 additions & 0 deletions LVGL Simulator/LVGL.Simulator/omoteconfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#define IS_SIMULATOR true

#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 360
54 changes: 52 additions & 2 deletions Platformio/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,57 @@
"cmake.configureOnOpen": false,
"files.associations": {
"random": "cpp",
"array": "cpp"
"array": "cpp",
"atomic": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"set": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp"
},
"cmake.sourceDirectory": "${workspaceFolder}/.pio/libdeps/esp32/Adafruit BusIO"
"cmake.sourceDirectory": "${workspaceFolder}/.pio/libdeps/esp32/Adafruit BusIO",
"editor.formatOnSave": false,
"idf.portWin": "COM8"
}
16 changes: 16 additions & 0 deletions Platformio/include/OmoteUI/HardwareAbstractionInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// OMOTE Hardware Abstraction
// 2023 Matthew Colvin

#pragma once
#include <lvgl.h>
#include <string>

class HardwareAbstractionInterface {
public:
HardwareAbstractionInterface() = default;

virtual void init() = 0;
virtual void sendIR() = 0;
virtual void MQTTPublish(const char *topic, const char *payload) = 0;
virtual void debugPrint(std::string message) = 0;
};
Loading

0 comments on commit f1ff9ed

Please sign in to comment.