Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@
<td>{{ baro_status[baro.param] }}</td>
</tr>
<tr
v-for="sensor in celsius"
v-for="sensor in ardupilot_sensors.temperatures"
:key="sensor.param"
>
<td><b>{{ sensor.deviceName ?? 'UNKNOWN' }}</b></td>
<td v-tooltip="'Used to estimate altitude/depth'">
<td v-tooltip="'External temperature sensor'">
Temperature
</td>
<td>{{ print_bus(sensor.busType) }} {{ sensor.bus }}</td>
<td>{{ `0x${sensor.address}` }}</td>
<td>{{ celsius_temperature }} ºC</td>
<td>Detected</td>
</tr>
</tbody>
</template>
Expand All @@ -137,33 +137,12 @@ import autopilot from '@/store/autopilot_manager'
import mavlink from '@/store/mavlink'
import { printParam } from '@/types/autopilot/parameter'
import { Dictionary } from '@/types/common'
import { BUS_TYPE, deviceId } from '@/utils/deviceid_decoder'
import { BUS_TYPE } from '@/utils/deviceid_decoder'
import mavlink_store_get from '@/utils/mavlink'

export default Vue.extend({
name: 'OnboardSensors',
computed: {
// DEV_ID params do not exist yet for temperature sensors, so here we detect the incoming message instead
celsius_temperature(): number | undefined {
return mavlink_store_get(mavlink, 'SCALED_PRESSURE3.messageData.message.temperature') as number / 100.0
},
celsius(): deviceId[] {
if (!this.celsius_temperature) {
return []
}
return [
{
bus: 1,
paramValue: 0,
deviceIdNumber: 0,
devtype: 0,
busType: BUS_TYPE.I2C,
address: '77',
deviceName: 'Celsius',
param: '-',
},
]
},
compass_description(): Dictionary<string> {
const results = {} as Dictionary<string>
for (const compass of ardupilot_sensors.compasses) {
Expand Down
6 changes: 6 additions & 0 deletions core/frontend/src/store/ardupilot_sensors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class ArdupilotSensorsStore extends VuexModule {
.filter((param) => param.value !== 0)
.map((parameter) => decode(parameter.name, parameter.value))
}

get temperatures(): deviceId[] {
return autopilot_data.parameterRegex('^TEMP\\d+_DEV_ID')
.filter((param) => param.value !== 0)
.map((parameter) => decode(parameter.name, parameter.value))
}

get accelerometers_calibrated() {
const results = {} as Dictionary<boolean>
Expand Down
17 changes: 17 additions & 0 deletions core/frontend/src/utils/deviceid_decoder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// based on https://github.com/ArduPilot/ardupilot/blob/master/Tools/scripts/decode_devid.py

export enum BUS_TYPE {
UNKNOWN = 0,
I2C = 1,
SPI = 2,
UAVCAN = 3,
Expand Down Expand Up @@ -121,6 +122,19 @@ enum AIRSPEED_TYPE {
AIRSPEED_ASP5033 = 0x0A,
}

enum TEMP_TYPE {
UNKNOWN = 0x00,
TSYS01 = 0x01,
MCP9600 = 0x02,
MAX31865 = 0x03,
TSYS03 = 0x04,
ANALOG = 0x05,
DRONECAN = 0x06,
MLX90614 = 0x07,
SHT3x = 0x08,
TMP119 = 0x09,
}

function toHex(value: number): string {
return Number(value).toString(16).padStart(2, '0')
}
Expand Down Expand Up @@ -172,6 +186,9 @@ export default function decode(device: string, devid: number): deviceId {
if (device.startsWith('ARSP')) {
decodedDevname = AIRSPEED_TYPE[devtype] || 'UNKNOWN'
}
if (device.startsWith('TEMP')) {
decodedDevname = TEMP_TYPE[devtype] || 'UNKNOWN'
}
return {
param: device,
deviceName: decodedDevname,
Expand Down