initial gps ttn mapper code

This commit is contained in:
felixerdy
2020-10-30 12:25:03 +01:00
parent 4601439ae3
commit 7b89897e54
6 changed files with 195 additions and 16 deletions
@@ -295,4 +295,50 @@ Blockly.Arduino.sensebox_scd30 = function () {
}
return [code, Blockly.Arduino.ORDER_ATOMIC];
}
/**
* GPS Module
*
*/
Blockly.Arduino.sensebox_gps = function () {
var dropdown = this.getFieldValue('dropdown');
Blockly.Arduino.libraries_['gps_library'] = '#include "SparkFun_Ublox_Arduino_Library.h"'
Blockly.Arduino.libraries_['wire'] = '#include <Wire.h>'
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
Blockly.Arduino.definitions_['GPS'] = 'SFE_UBLOX_GPS myGPS;';
Blockly.Arduino.setupCode_['init_gps'] = ` Wire.begin();
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
myGPS.saveConfiguration(); //Save the current settings to flash and BBR`;
var code = '';
switch (dropdown) {
case 'latitude':
code = 'myGPS.getLatitude()';
break;
case 'longitude':
code = 'myGPS.getLongitude()';
break;
case 'altitude':
code = 'myGPS.getAltitudeMSL()';
break;
case 'pDOP':
code = 'myGPS.getPDOP()';
break;
case 'fixType':
code = 'myGPS.getFixType()';
break;
default:
code = ''
}
return [code, Blockly.Arduino.ORDER_ATOMIC];
}