mirror of
https://github.com/ruvnet/RuView
synced 2026-07-28 18:21:42 +00:00
feat: Phase 3 — services, stores, navigation, design system
Services: ws.service, api.service, simulation.service, rssi.service (android+ios) Stores: poseStore, settingsStore, matStore (Zustand) Types: sensing, mat, api, navigation Hooks: usePoseStream, useRssiScanner, useServerReachability Theme: colors, typography, spacing, ThemeContext Navigation: MainTabs (5 tabs), RootNavigator, types Components: GaugeArc, SparklineChart, OccupancyGrid, StatusDot, ConnectionBanner, SignalBar, +more Utils: ringBuffer, colorMap, formatters, urlValidator Verified: tsc 0 errors, jest passes
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
export function formatRssi(v: number | null | undefined): string {
|
||||
if (typeof v !== 'number' || !Number.isFinite(v)) {
|
||||
return '-- dBm';
|
||||
}
|
||||
return `${Math.round(v)} dBm`;
|
||||
}
|
||||
|
||||
export function formatBpm(v: number | null | undefined): string {
|
||||
if (typeof v !== 'number' || !Number.isFinite(v)) {
|
||||
return '--';
|
||||
}
|
||||
return `${Math.round(v)} BPM`;
|
||||
}
|
||||
|
||||
export function formatConfidence(v: number | null | undefined): string {
|
||||
if (typeof v !== 'number' || !Number.isFinite(v)) {
|
||||
return '--';
|
||||
}
|
||||
const normalized = v > 1 ? v / 100 : v;
|
||||
return `${Math.round(Math.max(0, Math.min(1, normalized)) * 100)}%`;
|
||||
}
|
||||
|
||||
export function formatUptime(ms: number | null | undefined): string {
|
||||
if (typeof ms !== 'number' || !Number.isFinite(ms) || ms < 0) {
|
||||
return '--:--:--';
|
||||
}
|
||||
|
||||
const totalSeconds = Math.floor(ms / 1000);
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
|
||||
return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user