Files
trail-mate/tools/web_simulator/preview_board.cpp
Trail Mate Dev 7c3fcc31c6 fix(ci): refresh startup contract and format web simulator sources
Match the shell initialization call inside run() so its failure guard does not break the network-independence contract. Preserve initialization ordering and blocking-network checks. Apply clang-format 14 to the web preview sources. Verified all 2107 CI-scoped source files and seven positive/negative startup contract cases.
2026-09-16 15:01:59 +08:00

30 lines
1.4 KiB
C++

#include "board/BoardBase.h"
#include "platform/ui/device_runtime.h"
#include <emscripten.h>
EM_JS(void, preview_power_off, (), {if(Module.onPowerOff)Module.onPowerOff(); });
class BrowserBoard final : public BoardBase
{
public:
uint32_t begin(uint32_t) override { return 0; }
void wakeUp() override {}
void handlePowerButton() override {}
void softwareShutdown() override { preview_power_off(); }
void setBrightness(uint8_t value) override { platform::ui::device::set_screen_brightness(value); }
uint8_t getBrightness() override { return platform::ui::device::screen_brightness(); }
bool hasKeyboard() override { return true; }
void keyboardSetBrightness(uint8_t value) override { platform::ui::device::set_keyboard_backlight(value); }
uint8_t keyboardGetBrightness() override { return platform::ui::device::keyboard_backlight(); }
bool isRTCReady() const override { return true; }
bool isCharging() override { return false; }
int getBatteryLevel() override { return 85; }
bool isSDReady() const override { return true; }
bool isCardReady() override { return true; }
bool isGPSReady() const override { return true; }
bool hasGPSHardware() const override { return true; }
bool hasSstvAudioInput() const override { return true; }
void vibrator() override {}
void stopVibrator() override {}
};
static BrowserBoard browser_board;
BoardBase& board = browser_board;