Skip to content

Commit

Permalink
Temperature sensors support (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
shellixyz authored Feb 8, 2019
1 parent 9870ace commit 0a720f4
Show file tree
Hide file tree
Showing 7 changed files with 371 additions and 13 deletions.
41 changes: 37 additions & 4 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2383,6 +2383,9 @@
"osdGroupTimers": {
"message": "Timers"
},
"osdGroupTemperature": {
"message": "Temperature"
},
"osdGroupAttitude": {
"message": "Attitude"
},
Expand Down Expand Up @@ -2596,11 +2599,41 @@
"osdElement_MC_POS_XYZ_P_OUTPUTS": {
"message": "MC Position XYZ P controllers outputs"
},
"osdElement_TEMPERATURE": {
"message": "Temperature"
"osdElement_IMU_TEMPERATURE": {
"message": "IMU Temperature"
},
"osdElement_IMU_TEMPERATURE_HELP": {
"message": "Temperature of the IMU"
},
"osdElement_BARO_TEMPERATURE": {
"message": "Baro Temperature"
},
"osdElement_BARO_TEMPERATURE_HELP": {
"message": "Temperature of the barometer"
},
"osdElement_SENSOR1_TEMPERATURE": {
"message": "Temperature sensor 1"
},
"osdElement_SENSOR2_TEMPERATURE": {
"message": "Temperature sensor 2"
},
"osdElement_SENSOR3_TEMPERATURE": {
"message": "Temperature sensor 3"
},
"osdElement_SENSOR4_TEMPERATURE": {
"message": "Temperature sensor 4"
},
"osdElement_SENSOR5_TEMPERATURE": {
"message": "Temperature sensor 5"
},
"osdElement_SENSOR6_TEMPERATURE": {
"message": "Temperature sensor 6"
},
"osdElement_SENSOR7_TEMPERATURE": {
"message": "Temperature sensor 7"
},
"osdElement_TEMPERATURE_HELP": {
"message": "Temperature of the FC, obtained from the most accurate available source."
"osdElement_SENSOR8_TEMPERATURE": {
"message": "Temperature sensor 8"
},
"osdSettingMainVoltageDecimals": {
"message": "Main Voltage Decimals"
Expand Down
1 change: 1 addition & 0 deletions js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ var FC = {
sonar: 0,
air_speed: 0,
kinematics: [0.0, 0.0, 0.0],
temperature: [0, 0, 0, 0, 0, 0, 0, 0],
debug: [0, 0, 0, 0]
};

Expand Down
6 changes: 5 additions & 1 deletion js/msp/MSPCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,9 @@ var MSPCodes = {
MSP2_INAV_DEBUG: 0x2019,

MSP2_BLACKBOX_CONFIG: 0x201A,
MSP2_SET_BLACKBOX_CONFIG: 0x201B
MSP2_SET_BLACKBOX_CONFIG: 0x201B,

MSP2_INAV_TEMP_SENSOR_CONFIG: 0x201C,
MSP2_INAV_SET_TEMP_SENSOR_CONFIG: 0x201D,
MSP2_INAV_TEMPERATURES: 0x201E
};
7 changes: 7 additions & 0 deletions js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,13 @@ var mspHelper = (function (gui) {
console.log("Blackbox config saved");
break;

case MSPCodes.MSP2_INAV_TEMPERATURES:
for (i = 0; i < 8; ++i) {
temp_decidegrees = data.getInt16(i * 2, true);
SENSOR_DATA.temperature[i] = temp_decidegrees / 10; // °C
}
break;

default:
console.log('Unknown code detected: ' + dataHandler.code);
} else {
Expand Down
128 changes: 125 additions & 3 deletions tabs/osd.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,13 @@ OSD.constants = {
min_version: '1.7.4',
preview: FONT.symbol(SYM.CLOCK) + '13:37'
},
]
},
{
name: 'osdGroupTemperature',
items: [
{
name: 'TEMPERATURE',
name: 'IMU_TEMPERATURE',
id: 86,
min_version: '2.1.0',
preview: function(osd_data) {
Expand All @@ -640,6 +645,123 @@ OSD.constants = {
return '32' + FONT.symbol(SYM.TEMP_C);
}
},
{
name: 'BARO_TEMPERATURE',
id: 87,
min_version: '2.1.0',
preview: function(osd_data) {
if (OSD.data.preferences.units === 0) {
// Imperial
return '90' + FONT.symbol(SYM.TEMP_F);
}
// Metric, UK
return '32' + FONT.symbol(SYM.TEMP_C);
}
},
{
name: 'SENSOR1_TEMPERATURE',
id: 88,
min_version: '2.1.0',
preview: function(osd_data) {
if (OSD.data.preferences.units === 0) {
// Imperial
return '90' + FONT.symbol(SYM.TEMP_F);
}
// Metric, UK
return '32' + FONT.symbol(SYM.TEMP_C);
}
},
{
name: 'SENSOR2_TEMPERATURE',
id: 89,
min_version: '2.1.0',
preview: function(osd_data) {
if (OSD.data.preferences.units === 0) {
// Imperial
return '90' + FONT.symbol(SYM.TEMP_F);
}
// Metric, UK
return '32' + FONT.symbol(SYM.TEMP_C);
}
},
{
name: 'SENSOR3_TEMPERATURE',
id: 90,
min_version: '2.1.0',
preview: function(osd_data) {
if (OSD.data.preferences.units === 0) {
// Imperial
return '90' + FONT.symbol(SYM.TEMP_F);
}
// Metric, UK
return '32' + FONT.symbol(SYM.TEMP_C);
}
},
{
name: 'SENSOR4_TEMPERATURE',
id: 91,
min_version: '2.1.0',
preview: function(osd_data) {
if (OSD.data.preferences.units === 0) {
// Imperial
return '90' + FONT.symbol(SYM.TEMP_F);
}
// Metric, UK
return '32' + FONT.symbol(SYM.TEMP_C);
}
},
{
name: 'SENSOR5_TEMPERATURE',
id: 92,
min_version: '2.1.0',
preview: function(osd_data) {
if (OSD.data.preferences.units === 0) {
// Imperial
return '90' + FONT.symbol(SYM.TEMP_F);
}
// Metric, UK
return '32' + FONT.symbol(SYM.TEMP_C);
}
},
{
name: 'SENSOR6_TEMPERATURE',
id: 93,
min_version: '2.1.0',
preview: function(osd_data) {
if (OSD.data.preferences.units === 0) {
// Imperial
return '90' + FONT.symbol(SYM.TEMP_F);
}
// Metric, UK
return '32' + FONT.symbol(SYM.TEMP_C);
}
},
{
name: 'SENSOR7_TEMPERATURE',
id: 94,
min_version: '2.1.0',
preview: function(osd_data) {
if (OSD.data.preferences.units === 0) {
// Imperial
return '90' + FONT.symbol(SYM.TEMP_F);
}
// Metric, UK
return '32' + FONT.symbol(SYM.TEMP_C);
}
},
{
name: 'SENSOR8_TEMPERATURE',
id: 95,
min_version: '2.1.0',
preview: function(osd_data) {
if (OSD.data.preferences.units === 0) {
// Imperial
return '90' + FONT.symbol(SYM.TEMP_F);
}
// Metric, UK
return '32' + FONT.symbol(SYM.TEMP_C);
}
},
]
},
{
Expand Down Expand Up @@ -809,7 +931,7 @@ OSD.constants = {
},
{
name: 'MSL_ALTITUDE',
id: 87,
id: 96,
preview: function(osd_data) {
if (OSD.data.preferences.units === 0) {
// Imperial
Expand Down Expand Up @@ -850,7 +972,7 @@ OSD.constants = {
},
{
name: 'PLUS_CODE',
id: 88,
id: 97,
min_version: '2.1.0',
preview: function() {
let digits = parseInt(Settings.getInputValue('osd_plus_code_digits')) + 1;
Expand Down
131 changes: 128 additions & 3 deletions tabs/sensors.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<label><input type="checkbox" name="gyro_on" class="first" />Gyroscope</label> <label><input
type="checkbox" name="accel_on" />Accelerometer</label> <label><input type="checkbox"
name="mag_on" />Magnetometer</label> <label><input type="checkbox" name="baro_on" />Barometer</label> <label><input
type="checkbox" name="sonar_on" />Sonar</label> <label><input type="checkbox" name="airspeed_on" />Air speed</label> <label><input
type="checkbox" name="debug_on" />Debug</label>
type="checkbox" name="sonar_on" />Sonar</label> <label><input type="checkbox" name="airspeed_on" />Air speed</label> <label class="requires-v2_1_0"><input
type="checkbox" name="temperature_on" />Temperatures</label><label><input type="checkbox" name="debug_on" />Debug</label>

<a class="debug-trace" href="javascript:void(0);">Open Debug Trace</a>
</div>
Expand Down Expand Up @@ -263,6 +263,131 @@
<div class="clear-both"></div>
</div>
</div>

<div class="wrapper temperature">
<div class="gui_box grey">
<div class="plot_control">
<div class="title">Temperature 0 - °C</div>
<dl>
<dt>value:</dt>
<dd class="x">0</dd>
</dl>
</div>
<svg id="temperature1">
<g class="grid x" transform="translate(40, 120)"></g>
<g class="grid y" transform="translate(40, 10)"></g>
<g class="data" transform="translate(41, 10)"></g>
<g class="axis x" transform="translate(40, 120)"></g>
<g class="axis y" transform="translate(40, 10)"></g>
</svg>
<div class="clear-both"></div>
<div class="plot_control">
<div class="title">Temperature 1 - °C</div>
<dl>
<dt>value:</dt>
<dd class="x">0</dd>
</dl>
</div>
<svg id="temperature2">
<g class="grid x" transform="translate(40, 120)"></g>
<g class="grid y" transform="translate(40, 10)"></g>
<g class="data" transform="translate(41, 10)"></g>
<g class="axis x" transform="translate(40, 120)"></g>
<g class="axis y" transform="translate(40, 10)"></g>
</svg>
<div class="clear-both"></div>
<div class="plot_control">
<div class="title">Temperature 2 - °C</div>
<dl>
<dt>value:</dt>
<dd class="x">0</dd>
</dl>
</div>
<svg id="temperature3">
<g class="grid x" transform="translate(40, 120)"></g>
<g class="grid y" transform="translate(40, 10)"></g>
<g class="data" transform="translate(41, 10)"></g>
<g class="axis x" transform="translate(40, 120)"></g>
<g class="axis y" transform="translate(40, 10)"></g>
</svg>
<div class="clear-both"></div>
<div class="plot_control">
<div class="title">Temperature 3 - °C</div>
<dl>
<dt>value:</dt>
<dd class="x">0</dd>
</dl>
</div>
<svg id="temperature4">
<g class="grid x" transform="translate(40, 120)"></g>
<g class="grid y" transform="translate(40, 10)"></g>
<g class="data" transform="translate(41, 10)"></g>
<g class="axis x" transform="translate(40, 120)"></g>
<g class="axis y" transform="translate(40, 10)"></g>
</svg>
<div class="clear-both"></div>
<div class="plot_control">
<div class="title">Temperature 4 - °C</div>
<dl>
<dt>value:</dt>
<dd class="x">0</dd>
</dl>
</div>
<svg id="temperature5">
<g class="grid x" transform="translate(40, 120)"></g>
<g class="grid y" transform="translate(40, 10)"></g>
<g class="data" transform="translate(41, 10)"></g>
<g class="axis x" transform="translate(40, 120)"></g>
<g class="axis y" transform="translate(40, 10)"></g>
</svg>
<div class="clear-both"></div>
<div class="plot_control">
<div class="title">Temperature 5 - °C</div>
<dl>
<dt>value:</dt>
<dd class="x">0</dd>
</dl>
</div>
<svg id="temperature6">
<g class="grid x" transform="translate(40, 120)"></g>
<g class="grid y" transform="translate(40, 10)"></g>
<g class="data" transform="translate(41, 10)"></g>
<g class="axis x" transform="translate(40, 120)"></g>
<g class="axis y" transform="translate(40, 10)"></g>
</svg>
<div class="clear-both"></div>
<div class="plot_control">
<div class="title">Temperature 6 - °C</div>
<dl>
<dt>value:</dt>
<dd class="x">0</dd>
</dl>
</div>
<svg id="temperature7">
<g class="grid x" transform="translate(40, 120)"></g>
<g class="grid y" transform="translate(40, 10)"></g>
<g class="data" transform="translate(41, 10)"></g>
<g class="axis x" transform="translate(40, 120)"></g>
<g class="axis y" transform="translate(40, 10)"></g>
</svg>
<div class="clear-both"></div>
<div class="plot_control">
<div class="title">Temperature 7 - °C</div>
<dl>
<dt>value:</dt>
<dd class="x">0</dd>
</dl>
</div>
<svg id="temperature8">
<g class="grid x" transform="translate(40, 120)"></g>
<g class="grid y" transform="translate(40, 10)"></g>
<g class="data" transform="translate(41, 10)"></g>
<g class="axis x" transform="translate(40, 120)"></g>
<g class="axis y" transform="translate(40, 10)"></g>
</svg>
</div>
</div>

<div class="wrapper debug">
<div class="gui_box grey">
<div class="plot_control">
Expand Down Expand Up @@ -298,7 +423,7 @@
<div class="title">Debug 1</div>
<dl>
<dt>X:</dt>
<dd class="x">blue</dd>
<dd class="x">0</dd>
</dl>
</div>
<svg id="debug2">
Expand Down
Loading

0 comments on commit 0a720f4

Please sign in to comment.