Removed superfluous function, moved temperature encoding to function

master
jeffyactive 2021-12-10 11:36:32 -05:00
parent 7fe88fd02c
commit 57f6b2a8bb
1 changed files with 9 additions and 15 deletions

View File

@ -103,26 +103,12 @@ let magMenu = {
}; };
// Transmit the app name under the Espruino company code to facilitate discovery
function transmitAppName() {
let options = {
showName: false,
manufacturer: ESPRUINO_COMPANY_CODE,
manufacturerData: JSON.stringify({ name: APP_ID }),
interval: 2000
}
NRF.setAdvertising({}, options);
}
// Check for new sensor data and update the advertising sequence // Check for new sensor data and update the advertising sequence
function transmitUpdatedSensorData() { function transmitUpdatedSensorData() {
let data = []; let data = [];
if(isNewBarData) { if(isNewBarData) {
let encT = Math.round(bar.temperature * 100); // TODO: signed int16 data.push({ 0x2a6e: encodeTemperature(bar.temperature) });
data.push({ 0x2a6e: [ encT & 0xff, (encT >> 8) & 0xff ] });
isNewBarData = false; isNewBarData = false;
} }
@ -139,6 +125,14 @@ function transmitUpdatedSensorData() {
} }
// Convert temperature to signed 16-bit integer byte array
// TODO: implement negative temperature as signed int
function encodeTemperature(temperature) {
return [ Math.round(bar.temperature * 100) & 0xff,
(Math.round(bar.temperature * 100) >> 8) & 0xff ];
}
// Update acceleration // Update acceleration
Bangle.on('accel', function(newAcc) { Bangle.on('accel', function(newAcc) {
acc = newAcc; acc = newAcc;