mirror of
https://github.com/vicliu624/trail-mate.git
synced 2026-09-25 13:13:37 +00:00
58 lines
2.7 KiB
C++
58 lines
2.7 KiB
C++
#include "platform/ui/device_runtime.h"
|
|
#include "platform/ui/gps_runtime.h"
|
|
#include "platform/ui/walkie_runtime.h"
|
|
#include "platform/ui/usb_support_runtime.h"
|
|
#include "platform/ui/screen_runtime.h"
|
|
#include "ui/ui_common.h"
|
|
#include "ui/widgets/top_bar_power_presenter.h"
|
|
#include "ui/runtime/ui_feedback.h"
|
|
#include <algorithm>
|
|
#include <cstdint>
|
|
|
|
namespace platform::ui::device {
|
|
bool gps_supported() { return true; }
|
|
bool card_ready() { return true; }
|
|
bool sd_ready() { return true; }
|
|
int power_tier() { return 0; }
|
|
bool gps_ready() { return true; }
|
|
void delay_ms(uint32_t) {}
|
|
}
|
|
namespace platform::ui::gps {
|
|
static bool sample_fix = true;
|
|
GpsState get_data() { GpsState s; s.lat=31.2304; s.lng=121.4737; s.alt_m=842; s.satellites=12; s.valid=sample_fix; s.has_alt=sample_fix; return s; }
|
|
bool get_gnss_snapshot(GnssSatInfo* out, std::size_t max, std::size_t* count, GnssStatus* status)
|
|
{
|
|
*count=std::min<std::size_t>(12,max);
|
|
for(std::size_t i=0;i<*count;++i) out[i]={static_cast<uint16_t>(i+1),static_cast<GnssSystem>(i%4),static_cast<uint16_t>(i*29),static_cast<uint8_t>(15+(i*13)%70),static_cast<int8_t>(25+i),sample_fix};
|
|
status->sats_in_use=sample_fix?12:0; status->sats_in_view=12; status->hdop=sample_fix?.9f:0; status->fix=sample_fix?GnssFix::FIX3D:GnssFix::NOFIX;
|
|
return true;
|
|
}
|
|
GpsDiagnosticsSnapshot diagnostics() { GpsDiagnosticsSnapshot s; s.enabled=true; s.powered=true; s.ready=true; s.has_fix=sample_fix; s.sats_in_view=12; s.sats_in_use=sample_fix?12:0; s.satellites=s.sats_in_use; s.last_rx_age_ms=100; s.chars_recent=512; return s; }
|
|
void acquire_power_lease(const char*) {}
|
|
void release_power_lease(const char*) {}
|
|
}
|
|
namespace platform::ui::walkie {
|
|
static Status status{false,false,false,0,0,433.175f};
|
|
bool is_supported(){return true;}
|
|
bool start(){status.active=true;return true;}
|
|
void stop(){status.active=false;status.tx=false;}
|
|
bool is_active(){return status.active;}
|
|
void set_ptt(bool pressed){status.tx=pressed&&status.active;status.tx_level=status.tx?65:0;}
|
|
bool set_monitor_enabled(bool enabled){status.monitor_enabled=enabled;status.active=enabled;return true;}
|
|
bool monitor_enabled(){return status.monitor_enabled;}
|
|
int volume(){return 60;}
|
|
Status get_status(){return status;}
|
|
const char* last_error(){return "";}
|
|
}
|
|
namespace platform::ui::usb_support {
|
|
static Status status{};
|
|
bool is_supported(){return true;}
|
|
bool start(){status={true,false,"USB Active"};return true;}
|
|
void stop(){status={false,false,"USB Idle"};}
|
|
Status get_status(){return status;}
|
|
bool prepare_mass_storage_mode(){return true;}
|
|
void restore_mass_storage_mode(){}
|
|
}
|
|
void ui_update_top_bar_battery(ui::widgets::TopBar&){ui::widgets::top_bar_power::refresh_now();}
|
|
void ui_set_overlay_active(bool){}
|