feat(cpn): visual and audible feedback for haptic in simulator (#7322)
This commit is contained in:
@@ -22,6 +22,11 @@
|
||||
#include "edgetx.h"
|
||||
#include "haptic.h"
|
||||
|
||||
#if defined(SIMU)
|
||||
#include <stdint.h>
|
||||
extern uint32_t simuHapticValue;
|
||||
#endif
|
||||
|
||||
hapticQueue::hapticQueue()
|
||||
{
|
||||
buzzTimeLeft = 0;
|
||||
@@ -96,6 +101,10 @@ void hapticQueue::play(uint8_t tLen, uint8_t tPause, uint8_t tFlags)
|
||||
void hapticQueue::event(uint8_t e)
|
||||
{
|
||||
if (g_eeGeneral.hapticMode >= e_mode_nokeys || (g_eeGeneral.hapticMode >= e_mode_alarms && e <= AU_ERROR)) {
|
||||
#if defined(SIMU)
|
||||
simuHapticValue++;
|
||||
return;
|
||||
#endif
|
||||
if (e <= AU_ERROR)
|
||||
play(15, 3, PLAY_NOW);
|
||||
else if (e <= AU_MIX_WARNING_3)
|
||||
|
||||
@@ -47,6 +47,20 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <deque>
|
||||
#include <stdint.h>
|
||||
|
||||
// Monotonic event counter incremented each time haptic fires.
|
||||
// Host (WasmSimulatorInterface) compares against last-seen value to detect new events.
|
||||
uint32_t simuHapticValue = 0;
|
||||
|
||||
// Required stubs — called by firmware but no-ops in simulator
|
||||
void hapticOn(uint32_t pwmPercent) { (void)pwmPercent; }
|
||||
void hapticOff() {}
|
||||
|
||||
// WASM export — polled by host every 50ms to detect haptic events
|
||||
uint32_t WASM_EXPORT(simuGetHaptic)() {
|
||||
return simuHapticValue;
|
||||
}
|
||||
|
||||
int g_snapshot_idx = 0;
|
||||
|
||||
@@ -361,8 +375,6 @@ void boardOff()
|
||||
{
|
||||
}
|
||||
|
||||
void hapticOff() {}
|
||||
|
||||
#if defined(HAS_HARDWARE_OPTIONS)
|
||||
HardwareOptions hardwareOptions;
|
||||
#endif
|
||||
|
||||
@@ -95,6 +95,7 @@ uint8_t WASM_EXPORT(simuGetNumCustomSwitches)();
|
||||
uint8_t WASM_EXPORT(simuGetCustomSwitchIndex)(uint8_t cfsIdx);
|
||||
bool WASM_EXPORT(simuGetCustomSwitchState)(uint8_t idx);
|
||||
uint32_t WASM_EXPORT(simuGetCustomSwitchColor)(uint8_t idx);
|
||||
uint32_t WASM_EXPORT(simuGetHaptic)();
|
||||
|
||||
// Value-based trim setting: idx is mapped through inputMappingConvertMode.
|
||||
void WASM_EXPORT(simuSetTrimValue)(uint8_t idx, int32_t value);
|
||||
@@ -185,7 +186,7 @@ void WASM_IMPORT(simuAuxSerialStart)(uint8_t port_nr, uint32_t baudrate,
|
||||
void WASM_IMPORT(simuAuxSerialStop)(uint8_t port_nr);
|
||||
void WASM_IMPORT(simuAuxSerialSetBaudrate)(uint8_t port_nr, uint32_t baudrate);
|
||||
void WASM_IMPORT(simuAuxSerialSendBuffer)(uint8_t port_nr, const uint8_t* data,
|
||||
uint32_t len);
|
||||
uint32_t len);
|
||||
|
||||
// -- Internal (not exported) --
|
||||
void simuMain();
|
||||
|
||||
@@ -308,6 +308,7 @@ elseif(PCB STREQUAL X7)
|
||||
set(AUX_SERIAL ON)
|
||||
endif()
|
||||
elseif(PCBREV STREQUAL POCKET)
|
||||
set(HAPTIC YES)
|
||||
set(DEFAULT_INTERNAL_MODULE CROSSFIRE CACHE STRING "Default internal module")
|
||||
set(INTERNAL_MODULE_SERIAL YES)
|
||||
set(MODULE_SIZE_SML YES)
|
||||
|
||||
Reference in New Issue
Block a user