Fix imu data among other things, start at wifi fix
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { ModeData, ModesEnum } from '$lib/platform_shared/websocket_message'
|
||||||
import { mode, modes } from '$lib/stores'
|
import { mode, modes } from '$lib/stores'
|
||||||
|
|
||||||
const deactivate = async () => {
|
const deactivate = async () => {
|
||||||
mode.set(modes.indexOf('deactivated'))
|
mode.set(ModeData.create({ mode: ModesEnum.DEACTIVATED }))
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,10 @@ export interface IMUData {
|
|||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
z: number;
|
z: number;
|
||||||
temp: number;
|
heading: number;
|
||||||
|
altitude: number;
|
||||||
|
bmpTemp: number;
|
||||||
|
pressure: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StaticSystemInformation {
|
export interface StaticSystemInformation {
|
||||||
@@ -741,7 +744,7 @@ export const KnownNetworkItem: MessageFns<KnownNetworkItem> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function createBaseIMUData(): IMUData {
|
function createBaseIMUData(): IMUData {
|
||||||
return { x: 0, y: 0, z: 0, temp: 0 };
|
return { x: 0, y: 0, z: 0, heading: 0, altitude: 0, bmpTemp: 0, pressure: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IMUData: MessageFns<IMUData> = {
|
export const IMUData: MessageFns<IMUData> = {
|
||||||
@@ -755,8 +758,17 @@ export const IMUData: MessageFns<IMUData> = {
|
|||||||
if (message.z !== 0) {
|
if (message.z !== 0) {
|
||||||
writer.uint32(29).float(message.z);
|
writer.uint32(29).float(message.z);
|
||||||
}
|
}
|
||||||
if (message.temp !== 0) {
|
if (message.heading !== 0) {
|
||||||
writer.uint32(37).float(message.temp);
|
writer.uint32(37).float(message.heading);
|
||||||
|
}
|
||||||
|
if (message.altitude !== 0) {
|
||||||
|
writer.uint32(45).float(message.altitude);
|
||||||
|
}
|
||||||
|
if (message.bmpTemp !== 0) {
|
||||||
|
writer.uint32(53).float(message.bmpTemp);
|
||||||
|
}
|
||||||
|
if (message.pressure !== 0) {
|
||||||
|
writer.uint32(61).float(message.pressure);
|
||||||
}
|
}
|
||||||
return writer;
|
return writer;
|
||||||
},
|
},
|
||||||
@@ -797,7 +809,31 @@ export const IMUData: MessageFns<IMUData> = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.temp = reader.float();
|
message.heading = reader.float();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case 5: {
|
||||||
|
if (tag !== 45) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.altitude = reader.float();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case 6: {
|
||||||
|
if (tag !== 53) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.bmpTemp = reader.float();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case 7: {
|
||||||
|
if (tag !== 61) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.pressure = reader.float();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -814,7 +850,10 @@ export const IMUData: MessageFns<IMUData> = {
|
|||||||
x: isSet(object.x) ? globalThis.Number(object.x) : 0,
|
x: isSet(object.x) ? globalThis.Number(object.x) : 0,
|
||||||
y: isSet(object.y) ? globalThis.Number(object.y) : 0,
|
y: isSet(object.y) ? globalThis.Number(object.y) : 0,
|
||||||
z: isSet(object.z) ? globalThis.Number(object.z) : 0,
|
z: isSet(object.z) ? globalThis.Number(object.z) : 0,
|
||||||
temp: isSet(object.temp) ? globalThis.Number(object.temp) : 0,
|
heading: isSet(object.heading) ? globalThis.Number(object.heading) : 0,
|
||||||
|
altitude: isSet(object.altitude) ? globalThis.Number(object.altitude) : 0,
|
||||||
|
bmpTemp: isSet(object.bmpTemp) ? globalThis.Number(object.bmpTemp) : 0,
|
||||||
|
pressure: isSet(object.pressure) ? globalThis.Number(object.pressure) : 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -829,8 +868,17 @@ export const IMUData: MessageFns<IMUData> = {
|
|||||||
if (message.z !== 0) {
|
if (message.z !== 0) {
|
||||||
obj.z = message.z;
|
obj.z = message.z;
|
||||||
}
|
}
|
||||||
if (message.temp !== 0) {
|
if (message.heading !== 0) {
|
||||||
obj.temp = message.temp;
|
obj.heading = message.heading;
|
||||||
|
}
|
||||||
|
if (message.altitude !== 0) {
|
||||||
|
obj.altitude = message.altitude;
|
||||||
|
}
|
||||||
|
if (message.bmpTemp !== 0) {
|
||||||
|
obj.bmpTemp = message.bmpTemp;
|
||||||
|
}
|
||||||
|
if (message.pressure !== 0) {
|
||||||
|
obj.pressure = message.pressure;
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
@@ -843,7 +891,10 @@ export const IMUData: MessageFns<IMUData> = {
|
|||||||
message.x = object.x ?? 0;
|
message.x = object.x ?? 0;
|
||||||
message.y = object.y ?? 0;
|
message.y = object.y ?? 0;
|
||||||
message.z = object.z ?? 0;
|
message.z = object.z ?? 0;
|
||||||
message.temp = object.temp ?? 0;
|
message.heading = object.heading ?? 0;
|
||||||
|
message.altitude = object.altitude ?? 0;
|
||||||
|
message.bmpTemp = object.bmpTemp ?? 0;
|
||||||
|
message.pressure = object.pressure ?? 0;
|
||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -3444,7 +3495,7 @@ export const protoMetadata: ProtoMetadata = {
|
|||||||
"options": undefined,
|
"options": undefined,
|
||||||
"proto3Optional": false,
|
"proto3Optional": false,
|
||||||
}, {
|
}, {
|
||||||
"name": "temp",
|
"name": "heading",
|
||||||
"number": 4,
|
"number": 4,
|
||||||
"label": 1,
|
"label": 1,
|
||||||
"type": 2,
|
"type": 2,
|
||||||
@@ -3452,7 +3503,43 @@ export const protoMetadata: ProtoMetadata = {
|
|||||||
"extendee": "",
|
"extendee": "",
|
||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"oneofIndex": 0,
|
"oneofIndex": 0,
|
||||||
"jsonName": "temp",
|
"jsonName": "heading",
|
||||||
|
"options": undefined,
|
||||||
|
"proto3Optional": false,
|
||||||
|
}, {
|
||||||
|
"name": "altitude",
|
||||||
|
"number": 5,
|
||||||
|
"label": 1,
|
||||||
|
"type": 2,
|
||||||
|
"typeName": "",
|
||||||
|
"extendee": "",
|
||||||
|
"defaultValue": "",
|
||||||
|
"oneofIndex": 0,
|
||||||
|
"jsonName": "altitude",
|
||||||
|
"options": undefined,
|
||||||
|
"proto3Optional": false,
|
||||||
|
}, {
|
||||||
|
"name": "bmp_temp",
|
||||||
|
"number": 6,
|
||||||
|
"label": 1,
|
||||||
|
"type": 2,
|
||||||
|
"typeName": "",
|
||||||
|
"extendee": "",
|
||||||
|
"defaultValue": "",
|
||||||
|
"oneofIndex": 0,
|
||||||
|
"jsonName": "bmpTemp",
|
||||||
|
"options": undefined,
|
||||||
|
"proto3Optional": false,
|
||||||
|
}, {
|
||||||
|
"name": "pressure",
|
||||||
|
"number": 7,
|
||||||
|
"label": 1,
|
||||||
|
"type": 2,
|
||||||
|
"typeName": "",
|
||||||
|
"extendee": "",
|
||||||
|
"defaultValue": "",
|
||||||
|
"oneofIndex": 0,
|
||||||
|
"jsonName": "pressure",
|
||||||
"options": undefined,
|
"options": undefined,
|
||||||
"proto3Optional": false,
|
"proto3Optional": false,
|
||||||
}],
|
}],
|
||||||
@@ -4698,13 +4785,13 @@ export const protoMetadata: ProtoMetadata = {
|
|||||||
"sourceCodeInfo": {
|
"sourceCodeInfo": {
|
||||||
"location": [{
|
"location": [{
|
||||||
"path": [4, 4],
|
"path": [4, 4],
|
||||||
"span": [8, 0, 13, 1],
|
"span": [8, 0, 16, 1],
|
||||||
"leadingComments": " Individual message data types\n",
|
"leadingComments": " Individual message data types\n",
|
||||||
"trailingComments": "",
|
"trailingComments": "",
|
||||||
"leadingDetachedComments": [],
|
"leadingDetachedComments": [],
|
||||||
}, {
|
}, {
|
||||||
"path": [4, 25],
|
"path": [4, 25],
|
||||||
"span": [102, 0, 121, 1],
|
"span": [105, 0, 124, 1],
|
||||||
"leadingComments": " WebSocket message wrapper\n Only ONE field will be set at a time (oneof ensures this)\n",
|
"leadingComments": " WebSocket message wrapper\n Only ONE field will be set at a time (oneof ensures this)\n",
|
||||||
"trailingComments": "",
|
"trailingComments": "",
|
||||||
"leadingDetachedComments": [],
|
"leadingDetachedComments": [],
|
||||||
|
|||||||
+11
-34
@@ -1,42 +1,19 @@
|
|||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
import type { IMUMsg } from '$lib/types/models'
|
import { IMUData } from '$lib/platform_shared/websocket_message'
|
||||||
import type { IMUReport } from '$lib/platform_shared/imu_report'
|
|
||||||
|
|
||||||
|
const imu_data: IMUData[] = [];
|
||||||
const maxIMUData = 100
|
const maxIMUData = 100
|
||||||
|
|
||||||
|
|
||||||
export const imu = (() => {
|
export const imu = (() => {
|
||||||
const { subscribe, update } = writable({
|
const { subscribe, update } = writable(imu_data)
|
||||||
x: [] as number[],
|
|
||||||
y: [] as number[],
|
|
||||||
z: [] as number[],
|
|
||||||
heading: [] as number[],
|
|
||||||
altitude: [] as number[],
|
|
||||||
pressure: [] as number[],
|
|
||||||
bmp_temp: [] as number[]
|
|
||||||
})
|
|
||||||
|
|
||||||
const addData = (content: IMUReport) => {
|
return {
|
||||||
update(data => {
|
subscribe,
|
||||||
if (content.success) {
|
addData: (content: IMUData) => {
|
||||||
data.x = [...data.x, content.x].slice(-maxIMUData)
|
update(imu_data => {
|
||||||
data.y = [...data.y, content.y].slice(-maxIMUData)
|
return [...imu_data, content].slice(-maxIMUData)
|
||||||
data.z = [...data.z, content.z].slice(-maxIMUData)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Temporarily disabled
|
|
||||||
// if (content.mag && content.mag[4]) {
|
|
||||||
// data.heading = [...data.heading, content.mag[3]].slice(-maxIMUData)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (content.bmp && content.bmp[3]) {
|
|
||||||
// data.pressure = [...data.pressure, content.bmp[0]].slice(-maxIMUData)
|
|
||||||
// data.altitude = [...data.altitude, content.bmp[1]].slice(-maxIMUData)
|
|
||||||
// data.bmp_temp = [...data.bmp_temp, content.bmp[2]].slice(-maxIMUData)
|
|
||||||
// }
|
|
||||||
|
|
||||||
return data
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { subscribe, addData }
|
|
||||||
})()
|
})()
|
||||||
|
|||||||
@@ -13,20 +13,6 @@ export type GithubRelease = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export type WifiStatus = {
|
|
||||||
status: number
|
|
||||||
local_ip: string
|
|
||||||
mac_address: string
|
|
||||||
rssi: number
|
|
||||||
ssid: string
|
|
||||||
bssid: string
|
|
||||||
channel: number
|
|
||||||
subnet_mask: string
|
|
||||||
gateway_ip: string
|
|
||||||
dns_ip_1: string
|
|
||||||
dns_ip_2?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export type NetworkList = {
|
export type NetworkList = {
|
||||||
networks: NetworkItem[]
|
networks: NetworkItem[]
|
||||||
@@ -67,22 +53,6 @@ export type Rssi = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export type IMU = {
|
|
||||||
x: number
|
|
||||||
y: number
|
|
||||||
z: number
|
|
||||||
heading: number
|
|
||||||
altitude: number
|
|
||||||
bmp_temp: number
|
|
||||||
pressure: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export type IMUMsg = {
|
|
||||||
imu: [number, number, number, number, boolean]
|
|
||||||
mag: [number, number, number, number, boolean]
|
|
||||||
bmp: [number, number, number, boolean]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export interface I2CDevice {
|
export interface I2CDevice {
|
||||||
address: number
|
address: number
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import { mpu, socket } from '$lib/stores'
|
import { mpu, socket } from '$lib/stores'
|
||||||
import { imu } from '$lib/stores/imu'
|
import { imu } from '$lib/stores/imu'
|
||||||
import { MessageTopic, type IMU } from '$lib/types/models'
|
import type { IMUData } from '$lib/platform_shared/websocket_message'
|
||||||
|
|
||||||
let layout = $derived($views.find(v => v.name === $selectedView)!)
|
let layout = $derived($views.find(v => v.name === $selectedView)!)
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
socket.on(MessageTopic.imu, (data: IMU) => {
|
socket.on(IMUData, (data: IMUData) => {
|
||||||
imu.addData(data)
|
imu.addData(data)
|
||||||
if (data.heading)
|
if (data.heading)
|
||||||
mpu.update(mpuData => {
|
mpu.update(mpuData => {
|
||||||
|
|||||||
@@ -11,12 +11,6 @@
|
|||||||
import ScanNetworks from './Scan.svelte'
|
import ScanNetworks from './Scan.svelte'
|
||||||
import Spinner from '$lib/components/Spinner.svelte'
|
import Spinner from '$lib/components/Spinner.svelte'
|
||||||
import InfoDialog from '$lib/components/InfoDialog.svelte'
|
import InfoDialog from '$lib/components/InfoDialog.svelte'
|
||||||
import {
|
|
||||||
MessageTopic,
|
|
||||||
type KnownNetworkItem,
|
|
||||||
type WifiSettings,
|
|
||||||
type WifiStatus
|
|
||||||
} from '$lib/types/models'
|
|
||||||
import { socket } from '$lib/stores'
|
import { socket } from '$lib/stores'
|
||||||
import { api } from '$lib/api'
|
import { api } from '$lib/api'
|
||||||
import {
|
import {
|
||||||
@@ -39,17 +33,9 @@
|
|||||||
Edit
|
Edit
|
||||||
} from '$lib/components/icons'
|
} from '$lib/components/icons'
|
||||||
import StatusItem from '$lib/components/StatusItem.svelte'
|
import StatusItem from '$lib/components/StatusItem.svelte'
|
||||||
|
import { KnownNetworkItem } from '$lib/platform_shared/websocket_message'
|
||||||
|
|
||||||
let networkEditable: KnownNetworkItem = $state({
|
let networkEditable: KnownNetworkItem = $state( KnownNetworkItem.create() )
|
||||||
ssid: '',
|
|
||||||
password: '',
|
|
||||||
static_ip_config: false,
|
|
||||||
local_ip: undefined,
|
|
||||||
subnet_mask: undefined,
|
|
||||||
gateway_ip: undefined,
|
|
||||||
dns_ip_1: undefined,
|
|
||||||
dns_ip_2: undefined
|
|
||||||
})
|
|
||||||
|
|
||||||
let static_ip_config = $state(false)
|
let static_ip_config = $state(false)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
|
|
||||||
|
// REST MESSAGE TYPES
|
||||||
|
// TODO: i am too lazy to create a new file and compile it manually, so move this to a new proto before merging
|
||||||
|
|
||||||
|
|
||||||
|
// END REST MESSAGE TYPES
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
message Vector { float x = 1; float y = 2; }
|
message Vector { float x = 1; float y = 2; }
|
||||||
message I2CDevice { int32 address = 1; string part_number = 2; string name = 3; }
|
message I2CDevice { int32 address = 1; string part_number = 2; string name = 3; }
|
||||||
message PinConfig { int32 pin = 1; string mode = 2; string type = 3; string role = 4; }
|
message PinConfig { int32 pin = 1; string mode = 2; string type = 3; string role = 4; }
|
||||||
@@ -10,7 +22,10 @@ message IMUData {
|
|||||||
float x = 1;
|
float x = 1;
|
||||||
float y = 2;
|
float y = 2;
|
||||||
float z = 3;
|
float z = 3;
|
||||||
float temp = 4;
|
float heading = 4;
|
||||||
|
float altitude = 5;
|
||||||
|
float bmp_temp = 6;
|
||||||
|
float pressure = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ModesEnum {
|
enum ModesEnum {
|
||||||
|
|||||||
Reference in New Issue
Block a user