Connect APP shell to logic
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "APP/AppTheme.h"
|
||||
|
||||
#include <QtWidgets/QTabWidget>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
namespace APP
|
||||
@@ -29,6 +30,32 @@ App_MainWindow::App_MainWindow(QWidget* p_Parent)
|
||||
appTabWidget->addTab(appSettingsPage, QStringLiteral("Settings"));
|
||||
|
||||
p_RootLayout->addWidget(appTabWidget);
|
||||
|
||||
appPollTimer = new QTimer(this);
|
||||
connect(appPollTimer, &QTimer::timeout, this, [this]()
|
||||
{
|
||||
if (Lgc_Core_Poll(&appLogic))
|
||||
{
|
||||
App_Func_RefreshFromLogic();
|
||||
}
|
||||
});
|
||||
|
||||
App_Func_StartLogic();
|
||||
}
|
||||
|
||||
void App_MainWindow::App_Func_StartLogic()
|
||||
{
|
||||
Lgc_Core_Init(&appLogic);
|
||||
Lgc_Core_Start(&appLogic);
|
||||
App_Func_RefreshFromLogic();
|
||||
appPollTimer->start(30);
|
||||
}
|
||||
|
||||
void App_MainWindow::App_Func_RefreshFromLogic()
|
||||
{
|
||||
const Lgc_State& State = Lgc_Core_GetState(&appLogic);
|
||||
appSettingsPage->App_Func_SetConnectionText(State.ConnectionText);
|
||||
appSettingsPage->App_Func_SetLastActionText(State.LastActionText);
|
||||
}
|
||||
|
||||
App_KeyboardPage* App_MainWindow::App_Func_GetKeyboardPage() const
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "LOGIC/Lgc_Core.h"
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
class QTabWidget;
|
||||
class QTimer;
|
||||
|
||||
namespace APP
|
||||
{
|
||||
@@ -19,9 +22,14 @@ public:
|
||||
App_SettingsPage* App_Func_GetSettingsPage() const;
|
||||
|
||||
private:
|
||||
void App_Func_StartLogic();
|
||||
void App_Func_RefreshFromLogic();
|
||||
|
||||
QTabWidget* appTabWidget = nullptr;
|
||||
App_KeyboardPage* appKeyboardPage = nullptr;
|
||||
App_SettingsPage* appSettingsPage = nullptr;
|
||||
QTimer* appPollTimer = nullptr;
|
||||
Lgc_Core appLogic;
|
||||
};
|
||||
|
||||
} // namespace APP
|
||||
|
||||
@@ -37,12 +37,12 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
|
||||
<QtInstall>D:\App\Qt\5.13.1\msvc2015_64</QtInstall>
|
||||
<QtModules>core;serialport</QtModules>
|
||||
<QtModules>core;serialport;widgets</QtModules>
|
||||
<QtBuildConfig>debug</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
||||
<QtInstall>D:\App\Qt\5.13.1\msvc2015_64</QtInstall>
|
||||
<QtModules>core;serialport</QtModules>
|
||||
<QtModules>core;serialport;widgets</QtModules>
|
||||
<QtBuildConfig>release</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
|
||||
@@ -94,6 +94,14 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="APP\AppKeyButton.cpp" />
|
||||
<ClInclude Include="APP\AppKeyButton.h" />
|
||||
<ClCompile Include="APP\AppKeyboardPage.cpp" />
|
||||
<ClInclude Include="APP\AppKeyboardPage.h" />
|
||||
<ClCompile Include="APP\AppMainWindow.cpp" />
|
||||
<ClInclude Include="APP\AppMainWindow.h" />
|
||||
<ClCompile Include="APP\AppSettingsPage.cpp" />
|
||||
<ClInclude Include="APP\AppSettingsPage.h" />
|
||||
<ClInclude Include="APP\AppTheme.h" />
|
||||
<ClInclude Include="COM\Com_Cdc.h" />
|
||||
<ClCompile Include="COM\Com_ProtoCodec.cpp" />
|
||||
@@ -108,6 +116,8 @@
|
||||
<ClCompile Include="APP\AppTheme.cpp" />
|
||||
<ClCompile Include="LOGIC\Lgc_Core.cpp" />
|
||||
<ClInclude Include="LOGIC\Lgc_Core.h" />
|
||||
<ClCompile Include="LOGIC\Lgc_FunctionExecutor.cpp" />
|
||||
<ClInclude Include="LOGIC\Lgc_FunctionExecutor.h" />
|
||||
<ClCompile Include="LOGIC\Lgc_Session.cpp" />
|
||||
<ClInclude Include="LOGIC\Lgc_Session.h" />
|
||||
<ClInclude Include="LOGIC\Lgc_State.h" />
|
||||
|
||||
@@ -23,6 +23,30 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="APP\AppKeyButton.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="APP\AppKeyButton.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="APP\AppKeyboardPage.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="APP\AppKeyboardPage.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="APP\AppMainWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="APP\AppMainWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="APP\AppSettingsPage.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="APP\AppSettingsPage.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="APP\AppTheme.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -65,6 +89,12 @@
|
||||
<ClInclude Include="LOGIC\Lgc_Core.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="LOGIC\Lgc_FunctionExecutor.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="LOGIC\Lgc_FunctionExecutor.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="LOGIC\Lgc_Session.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
#include "DRI/Dri_Cdc.h"
|
||||
#include "APP/AppMainWindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
QApplication App(argc, argv);
|
||||
|
||||
Dri_Cdc_Struct_Port Port;
|
||||
Dri_Cdc_Struct_InitConfig Config;
|
||||
Config.BaudRate = 115200;
|
||||
APP::App_MainWindow Window;
|
||||
Window.show();
|
||||
|
||||
const bool IsInitOk = Dri_Cdc_Init(&Port, Config);
|
||||
qDebug() << "Dri_Cdc_Init =" << IsInitOk;
|
||||
|
||||
Dri_Cdc_Deinit(&Port);
|
||||
return 0;
|
||||
return App.exec();
|
||||
}
|
||||
|
||||
81
docs/host_app_rebuild.md
Normal file
81
docs/host_app_rebuild.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# Host APP Rebuild
|
||||
|
||||
## Goal
|
||||
|
||||
Keep the APP layer suitable for teaching from simple to complex.
|
||||
|
||||
Teaching order:
|
||||
|
||||
1. one button
|
||||
2. one keyboard page
|
||||
3. two pages
|
||||
4. one main window
|
||||
5. one shared theme
|
||||
|
||||
## Completed Nodes
|
||||
|
||||
### Node 1: theme helpers
|
||||
|
||||
Files:
|
||||
|
||||
- `KeyBorad/KeyBorad/APP/AppTheme.h`
|
||||
- `KeyBorad/KeyBorad/APP/AppTheme.cpp`
|
||||
|
||||
Design notes:
|
||||
|
||||
- centralize colors and style strings
|
||||
- keep styling readable
|
||||
- avoid mixing style text inside every widget
|
||||
|
||||
### Node 2: key button
|
||||
|
||||
Files:
|
||||
|
||||
- `KeyBorad/KeyBorad/APP/AppKeyButton.h`
|
||||
- `KeyBorad/KeyBorad/APP/AppKeyButton.cpp`
|
||||
|
||||
Design notes:
|
||||
|
||||
- teach one custom button first
|
||||
- keep state changes explicit
|
||||
- let one widget own its own text and style refresh
|
||||
|
||||
### Node 3: keyboard page
|
||||
|
||||
Files:
|
||||
|
||||
- `KeyBorad/KeyBorad/APP/AppKeyboardPage.h`
|
||||
- `KeyBorad/KeyBorad/APP/AppKeyboardPage.cpp`
|
||||
|
||||
Design notes:
|
||||
|
||||
- grow from one button to a full keypad
|
||||
- keep layout data local and explicit
|
||||
|
||||
### Node 4: settings page
|
||||
|
||||
Files:
|
||||
|
||||
- `KeyBorad/KeyBorad/APP/AppSettingsPage.h`
|
||||
- `KeyBorad/KeyBorad/APP/AppSettingsPage.cpp`
|
||||
|
||||
Design notes:
|
||||
|
||||
- use a second page early
|
||||
- give transport status and action feedback one simple home
|
||||
|
||||
### Node 5: main window integration
|
||||
|
||||
Files updated in this step:
|
||||
|
||||
- `KeyBorad/KeyBorad/APP/AppMainWindow.h`
|
||||
- `KeyBorad/KeyBorad/APP/AppMainWindow.cpp`
|
||||
- `KeyBorad/KeyBorad/main.cpp`
|
||||
|
||||
Implemented behavior:
|
||||
|
||||
- create the two-page window
|
||||
- own one `Lgc_Core`
|
||||
- start handshake on launch
|
||||
- poll the logic layer with a timer
|
||||
- refresh settings page texts from logic state
|
||||
Reference in New Issue
Block a user