add demo mode

This commit is contained in:
Leonard Gies 2025-06-26 18:00:10 +02:00
parent fce0cc587f
commit e995c0ad66
Signed by: l.gies
GPG Key ID: 6F6FB9338EE44F71
4 changed files with 25 additions and 0 deletions

1
Core/Inc/config.h Normal file
View File

@ -0,0 +1 @@
// #define DEMO_MODE

View File

@ -1,6 +1,7 @@
#include "vehicle.h"
#include "can-halal.h"
#include "config.h"
#include "main.h"
#include "stm32h7xx.h"
#include "stm32h7xx_hal.h"
@ -78,6 +79,17 @@ void vehicle_thread_entry(ULONG hfdcan_addr) {
while (1) {
tx_thread_sleep(10);
#ifdef DEMO_MODE
double tick = HAL_GetTick();
vehicle_state.speed =
(sin(tick * 0.001) * 8 + 10 + cos(tick * 0.003) * 8) * 4;
if (vehicle_state.speed <= 0) {
vehicle_state.speed = 0;
}
tx_event_flags_set(&gui_update_events, GUI_UPDATE_VEHICLE_STATE, TX_OR);
#endif
}
}

View File

@ -2,6 +2,8 @@
#include "gui/common/NamedField.hpp"
#include "../../Core/Inc/config.h"
FrontendApplication::FrontendApplication(Model &m, FrontendHeap &heap)
: FrontendApplicationBase(m, heap), canChangeFromMissionSelect(false) {
namedFieldSort();
@ -14,5 +16,8 @@ void FrontendApplication::setCanChangeFromMissionSelect(
// controls if next screen button works on mission select screen
bool FrontendApplication::getCanChangeFromMissionSelect() const {
#ifdef DEMO_MODE
return true;
#endif
return canChangeFromMissionSelect;
}

View File

@ -2,6 +2,7 @@
#include "texts/TextKeysAndLanguages.hpp"
#include <gui/missionselect_screen/MissionSelectView.hpp>
#include "config.h"
#include "stw_defines.h"
#include "vehicle.h"
#include "vehicle_state.h"
@ -54,6 +55,12 @@ void MissionSelectView::confirmMission() {
return;
}
vehicle_select_mission(selectedMission);
#ifdef DEMO_MODE
vehicle_state.active_mission = selectedMission;
presenter->vehicleStateUpdated();
#endif
#ifdef SIMULATOR
vehicle_state.active_mission = selectedMission;
#endif