feat(cpn): visual and audible feedback for haptic in simulator (#7322)

This commit is contained in:
Kudzz
2026-07-20 19:09:43 +10:00
committed by GitHub
parent 8aa6ff723e
commit 14e6d6ce01
9 changed files with 89 additions and 4 deletions
+14 -2
View File
@@ -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
+2 -1
View File
@@ -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();