add bn880 gps
This commit is contained in:
		
							parent
							
								
									7524e78fc6
								
							
						
					
					
						commit
						e685724a1f
					
				
							
								
								
									
										3
									
								
								.env
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								.env
									
									
									
									
									
								
							| @ -1,4 +1,5 @@ | |||||||
| REACT_APP_COMPILER_URL=https://compiler.sensebox.de | #REACT_APP_COMPILER_URL=https://compiler.sensebox.de | ||||||
|  | REACT_APP_COMPILER_URL=http://localhost:3000 | ||||||
| REACT_APP_BOARD=sensebox-mcu | REACT_APP_BOARD=sensebox-mcu | ||||||
| REACT_APP_BLOCKLY_API=https://api.blockly.sensebox.de | REACT_APP_BLOCKLY_API=https://api.blockly.sensebox.de | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -583,3 +583,49 @@ Blockly.Blocks["sensebox_sensor_dps310"] = { | |||||||
|     this.setHelpUrl(Blockly.Msg.senseBox_sps30_helpurl); |     this.setHelpUrl(Blockly.Msg.senseBox_sps30_helpurl); | ||||||
|   }, |   }, | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * GPS Module BN880 | ||||||
|  |  * | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | Blockly.Blocks["sensebox_gps_bn880"] = { | ||||||
|  |   init: function () { | ||||||
|  |     var dropdownOptions = [ | ||||||
|  |       [Blockly.Msg.senseBox_gps_lat, "latitude"], | ||||||
|  |       [Blockly.Msg.senseBox_gps_lng, "longitude"], | ||||||
|  |       [Blockly.Msg.senseBox_gps_alt, "altitude"], | ||||||
|  |       [Blockly.Msg.senseBox_gps_timeStamp, "timestamp"], | ||||||
|  |     ]; | ||||||
|  |     this.appendDummyInput().appendField("GPS Modul BN-880"); | ||||||
|  |     this.appendDummyInput() | ||||||
|  |     .setAlign(Blockly.ALIGN_RIGHT) | ||||||
|  |     .appendField(Blockly.Msg.senseBox_value) | ||||||
|  |     .appendField(new Blockly.FieldDropdown(dropdownOptions), "dropdown"); | ||||||
|  |     this.appendDummyInput() | ||||||
|  |       .setAlign(Blockly.ALIGN_RIGHT) | ||||||
|  |       .appendField("Serial Port:") | ||||||
|  |       .appendField( | ||||||
|  |         new Blockly.FieldDropdown( | ||||||
|  |           selectedBoard().serialSensors), | ||||||
|  |         "serial" | ||||||
|  |       ); | ||||||
|  |     if (this.getFieldValue("dropdown") == "timestamp") { | ||||||
|  |       this.setOutput(true, Types.CHARACTER.typeName); | ||||||
|  |     } else { | ||||||
|  |     this.setOutput(true, Types.NUMBER.typeName); | ||||||
|  |     } | ||||||
|  |     this.setColour(getColour().sensebox); | ||||||
|  |     this.setTooltip(Blockly.Msg.senseBox_gps_tooltip); | ||||||
|  |   }, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | Blockly.Blocks["sensebox_gps_isValid"] = { | ||||||
|  |   init: function () { | ||||||
|  |     this.appendDummyInput().appendField("GPS Modul is valid"); | ||||||
|  |     this.setOutput(true, Types.BOOLEAN.typeName); | ||||||
|  |     this.setColour(getColour().sensebox); | ||||||
|  |     this.setTooltip(Blockly.Msg.senseBox_gps_tooltip); | ||||||
|  |   }, | ||||||
|  | }; | ||||||
|  | |||||||
| @ -753,3 +753,58 @@ if (time_startsps > time_actualsps + intervalsps) { | |||||||
|   var code = `m.mc_${dropdown_name}`; |   var code = `m.mc_${dropdown_name}`; | ||||||
|   return [code, Blockly.Arduino.ORDER_ATOMIC]; |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * GPS Module | ||||||
|  |  * | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | Blockly.Arduino.sensebox_gps_bn880 = function () { | ||||||
|  |   var dropdown = this.getFieldValue("dropdown"); | ||||||
|  |   var serial = this.getFieldValue("serial"); | ||||||
|  |   Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>"; | ||||||
|  |   Blockly.Arduino.libraries_["tinygps_library"] = | ||||||
|  |     "#include <TinyGPSPlus.h> // http://librarymanager/All#SparkFun_u-blox_GNSS_Arduino_Library"; | ||||||
|  |   Blockly.Arduino.definitions_["TinyGPS"] = "TinyGPSPlus gps;"; | ||||||
|  |   Blockly.Arduino.setupCode_["init_tinygps"] = ` | ||||||
|  | ${serial}.begin(9600);  // BN880
 | ||||||
|  | while (gps.location.lat() == 0.0 && gps.location.lng() == 0.0); | ||||||
|  |   ` | ||||||
|  |   var code = ""; | ||||||
|  |   switch (dropdown) { | ||||||
|  |     case "latitude": | ||||||
|  |       code = "gps.location.lat()"; | ||||||
|  |       break; | ||||||
|  |     case "longitude": | ||||||
|  |       code = "gps.location.lng()"; | ||||||
|  |       break; | ||||||
|  |     case "altitude": | ||||||
|  |       code = "gps.altitude.meters()"; | ||||||
|  |       break; | ||||||
|  |     case "timestamp": | ||||||
|  |       Blockly.Arduino.variables_["define_tsBuffer"] = `char tsBuffer[21];` | ||||||
|  |       Blockly.Arduino.codeFunctions_["getTimeStamp()"] = ` | ||||||
|  |       char *getTimeStamp() | ||||||
|  |       { | ||||||
|  |         memset(tsBuffer, 0, sizeof(tsBuffer)); | ||||||
|  |         if ((gps.date.isValid() == true) && (gps.time.isValid() == true)) | ||||||
|  |         { | ||||||
|  |           sprintf(tsBuffer, "%04d-%02d-%02dT%02d:%02d:%02dZ", | ||||||
|  |                   gps.date.year(), gps.date.month(), gps.date.day(), gps.time.hour(), gps.time.minute(), gps.time.second()); | ||||||
|  |         } | ||||||
|  |         return tsBuffer; | ||||||
|  |       } | ||||||
|  |       `;
 | ||||||
|  |       code = "getTimeStamp()"; | ||||||
|  |       break; | ||||||
|  |     default: | ||||||
|  |       code = ""; | ||||||
|  |   } | ||||||
|  |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | Blockly.Arduino.sensebox_gps_isValid = function () { | ||||||
|  |   var code ="gps.location.isValid()"; | ||||||
|  |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
|  | }; | ||||||
|  | |||||||
| @ -104,4 +104,4 @@ export const getCompatibleTypes = (type) => { | |||||||
|     return compatibleTypes[type]; |     return compatibleTypes[type]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const VARIABLE_TYPES = [['SHORT_NUMBER', 'char'], ['NUMBER', 'int'], ['DECIMAL', 'long'], ['TEXT', 'String'], ['CHARACTER', 'char'], ['BOOLEAN', 'boolean'], ['NULL', 'void'], ['UNDEF', 'undefined']]; | export const VARIABLE_TYPES = [['NUMBER', 'int'], ['DECIMAL', 'long'], ['TEXT', 'String'], ['CHARACTER', 'char'], ['BOOLEAN', 'boolean'], ['NULL', 'void'], ['UNDEF', 'undefined']]; | ||||||
|  | |||||||
| @ -640,6 +640,8 @@ class Toolbox extends React.Component { | |||||||
|           > |           > | ||||||
|             <Block type="init_serial_monitor"></Block> |             <Block type="init_serial_monitor"></Block> | ||||||
|             <Block type="print_serial_monitor"></Block> |             <Block type="print_serial_monitor"></Block> | ||||||
|  |             <Block type="sensebox_gps_bn880" /> | ||||||
|  |             <Block type="sensebox_gps_isValid" /> | ||||||
|           </Category> |           </Category> | ||||||
|           <Category name={Blockly.Msg.toolbox_io} colour={getColour().io}> |           <Category name={Blockly.Msg.toolbox_io} colour={getColour().io}> | ||||||
|             <Block type="io_digitalwrite"></Block> |             <Block type="io_digitalwrite"></Block> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user