parent
							
								
									6b12c501a0
								
							
						
					
					
						commit
						21d282ee1b
					
				| @ -1,4 +1,36 @@ | |||||||
|  | import * as Blockly from "blockly/core"; | ||||||
|  | import { getColour } from "../helpers/colour"; | ||||||
|  | import * as Types from "../helpers/types"; | ||||||
| 
 | 
 | ||||||
|  | Blockly.Blocks["sensebox_multiplexer_init"] = { | ||||||
|  |   init: function () { | ||||||
|  |     this.appendDummyInput().appendField(Blockly.Msg.senseBox_multiplexer_init); | ||||||
|  |     this.appendValueInput("nrChannels").setCheck( | ||||||
|  |       Types.getCompatibleTypes("int") | ||||||
|  |     ); | ||||||
|  |     this.appendDummyInput().appendField( | ||||||
|  |       Blockly.Msg.senseBox_multplexer_nchannels | ||||||
|  |     ); | ||||||
|  |     this.setPreviousStatement(true, null); | ||||||
|  |     this.setNextStatement(true, null); | ||||||
|  |     this.setInputsInline("true"); | ||||||
|  |     this.setColour(getColour().sensebox); | ||||||
|  |     this.setTooltip(Blockly.Msg.senseBox_multiplexer_init_tooltip); | ||||||
|  |     this.setHelpUrl(Blockly.Msg.senseBox_multiplexer_init_helpurl); | ||||||
|  |   }, | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| 
 | Blockly.Blocks["sensebox_multiplexer_changeChannel"] = { | ||||||
| 
 |   init: function () { | ||||||
|  |     this.appendDummyInput().appendField( | ||||||
|  |       Blockly.Msg.senseBox_multiplexer_changeChannel | ||||||
|  |     ); | ||||||
|  |     this.appendValueInput("Channel").setCheck(Types.getCompatibleTypes("int")); | ||||||
|  |     this.setInputsInline("true"); | ||||||
|  |     this.setPreviousStatement(true, null); | ||||||
|  |     this.setNextStatement(true, null); | ||||||
|  |     this.setColour(getColour().sensebox); | ||||||
|  |     this.setTooltip(Blockly.Msg.sensebox_multiplexer_changeChannel_tooltip); | ||||||
|  |     this.setHelpUrl(Blockly.Msg.sensebox_multiplexer_changeChannel_helpurl); | ||||||
|  |   }, | ||||||
|  | }; | ||||||
|  | |||||||
| @ -1,24 +1,23 @@ | |||||||
| import './generator'; | import "./generator"; | ||||||
| import './loops'; | import "./loops"; | ||||||
| import './sensebox-sensors'; | import "./sensebox-sensors"; | ||||||
| import './sensebox-telegram'; | import "./sensebox-telegram"; | ||||||
| import './sensebox-osem'; | import "./sensebox-osem"; | ||||||
| import './sensebox-web'; | import "./sensebox-web"; | ||||||
| import './sensebox-display'; | import "./sensebox-display"; | ||||||
| import './sensebox-lora'; | import "./sensebox-lora"; | ||||||
| import './sensebox-led'; | import "./sensebox-led"; | ||||||
| import './sensebox-sd'; | import "./sensebox-sd"; | ||||||
| import './mqtt'; | import "./sensebox"; | ||||||
| import './logic'; | import "./mqtt"; | ||||||
| import './text'; | import "./logic"; | ||||||
| import './math'; | import "./text"; | ||||||
| import './map'; | import "./math"; | ||||||
| import './io'; | import "./map"; | ||||||
| import './audio'; | import "./io"; | ||||||
| import './procedures'; | import "./audio"; | ||||||
| import './time'; | import "./procedures"; | ||||||
| import './variables'; | import "./time"; | ||||||
| import './lists'; | import "./variables"; | ||||||
| import './webserver'; | import "./lists"; | ||||||
| 
 | import "./webserver"; | ||||||
| 
 |  | ||||||
|  | |||||||
| @ -1,3 +1,38 @@ | |||||||
| import * as Blockly from 'blockly/core'; | import * as Blockly from "blockly/core"; | ||||||
| import { Block } from 'blockly'; |  | ||||||
| 
 | 
 | ||||||
|  | /* | ||||||
|  |  * Multiplexer | ||||||
|  |  */ | ||||||
|  | Blockly.Arduino.sensebox_multiplexer_init = function () { | ||||||
|  |   // Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>';
 | ||||||
|  |   var nrChannels = | ||||||
|  |     Blockly.Arduino.valueToCode( | ||||||
|  |       this, | ||||||
|  |       "nrChannels", | ||||||
|  |       Blockly.Arduino.ORDER_ATOMIC | ||||||
|  |     ) | 0; | ||||||
|  |   var array = []; | ||||||
|  |   for (var i = 0; i < nrChannels; i++) { | ||||||
|  |     array.push(i); | ||||||
|  |   } | ||||||
|  |   Blockly.Arduino.libraries_["library_wire"] = "#include <Wire.h>"; | ||||||
|  |   Blockly.Arduino.definitions_[ | ||||||
|  |     "define_multiplexer" | ||||||
|  |   ] = `byte multiplexAddress = 0x77;
 | ||||||
|  |     byte channels[] = {${array}};`;
 | ||||||
|  |   // Blockly.Arduino.setupCode_['sensebox_display_begin'] = 'senseBoxIO.powerI2C(true);\ndelay(2000);\ndisplay.begin(SSD1306_SWITCHCAPVCC, 0x3D);\ndisplay.display();\ndelay(100);\ndisplay.clearDisplay();';
 | ||||||
|  |   var code = ""; | ||||||
|  |   return code; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | Blockly.Arduino.sensebox_multiplexer_changeChannel = function () { | ||||||
|  |   var channel = Blockly.Arduino.valueToCode( | ||||||
|  |     this, | ||||||
|  |     "Channel", | ||||||
|  |     Blockly.Arduino.ORDER_ATOMIC | ||||||
|  |   ); | ||||||
|  |   var code = `Wire.beginTransmission(0x77);
 | ||||||
|  |   Wire.write(1 << channels[${channel - 1}]); | ||||||
|  |   Wire.endTransmission();`;
 | ||||||
|  |   return code; | ||||||
|  | }; | ||||||
|  | |||||||
| @ -1,26 +1,26 @@ | |||||||
| 
 | import { AUDIO } from "./de/audio"; | ||||||
| import { AUDIO } from './de/audio'; | import { FAQ } from "./de/faq"; | ||||||
| import { FAQ } from './de/faq'; | import { IO } from "./de/io"; | ||||||
| import { IO } from './de/io'; | import { LOGIC } from "./de/logic"; | ||||||
| import { LOGIC } from './de/logic'; | import { LOOPS } from "./de/loops"; | ||||||
| import { LOOPS } from './de/loops'; | import { MATH } from "./de/math"; | ||||||
| import { MATH } from './de/math'; | import { MQTT } from "./de/mqtt"; | ||||||
| import { MQTT } from './de/mqtt'; | import { DISPLAY } from "./de/sensebox-display"; | ||||||
| import { DISPLAY } from './de/sensebox-display'; | import { LED } from "./de/sensebox-led"; | ||||||
| import { LED } from './de/sensebox-led'; | import { LORA } from "./de/sensebox-lora"; | ||||||
| import { LORA } from './de/sensebox-lora'; | import { OSEM } from "./de/sensebox-osem"; | ||||||
| import { OSEM } from './de/sensebox-osem'; | import { SD } from "./de/sensebox-sd"; | ||||||
| import { SD } from './de/sensebox-sd'; | import { SENSORS } from "./de/sensebox-sensors"; | ||||||
| import { SENSORS } from './de/sensebox-sensors'; | import { SENSEBOX } from "./de/sensebox"; | ||||||
| import { TELEGRAM } from './de/sensebox-telegram'; | import { TELEGRAM } from "./de/sensebox-telegram"; | ||||||
| import { WEB } from './de/sensebox-web'; | import { WEB } from "./de/sensebox-web"; | ||||||
| import { TEXT } from './de/text'; | import { TEXT } from "./de/text"; | ||||||
| import { TIME } from './de/time'; | import { TIME } from "./de/time"; | ||||||
| import { TOURS } from './de/tours'; | import { TOURS } from "./de/tours"; | ||||||
| import { TRANSLATIONS } from './de/translations'; | import { TRANSLATIONS } from "./de/translations"; | ||||||
| import { UI } from './de/ui'; | import { UI } from "./de/ui"; | ||||||
| import { VARIABLES } from './de/variables'; | import { VARIABLES } from "./de/variables"; | ||||||
| import { WEBSERVER } from './de/webserver'; | import { WEBSERVER } from "./de/webserver"; | ||||||
| 
 | 
 | ||||||
| export const De = { | export const De = { | ||||||
|   ...AUDIO, |   ...AUDIO, | ||||||
| @ -36,6 +36,7 @@ export const De = { | |||||||
|   ...OSEM, |   ...OSEM, | ||||||
|   ...SD, |   ...SD, | ||||||
|   ...SENSORS, |   ...SENSORS, | ||||||
|  |   ...SENSEBOX, | ||||||
|   ...TELEGRAM, |   ...TELEGRAM, | ||||||
|   ...WEB, |   ...WEB, | ||||||
|   ...TEXT, |   ...TEXT, | ||||||
| @ -44,5 +45,5 @@ export const De = { | |||||||
|   ...TRANSLATIONS, |   ...TRANSLATIONS, | ||||||
|   ...UI, |   ...UI, | ||||||
|   ...VARIABLES, |   ...VARIABLES, | ||||||
|     ...WEBSERVER |   ...WEBSERVER, | ||||||
| } | }; | ||||||
|  | |||||||
							
								
								
									
										16
									
								
								src/components/Blockly/msg/de/sensebox.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/components/Blockly/msg/de/sensebox.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | |||||||
|  | export const SENSEBOX = { | ||||||
|  |   /** | ||||||
|  |    * Multiplexer | ||||||
|  |    */ | ||||||
|  |   senseBox_multiplexer_init: "Initialisiere Multiplexer mit ", | ||||||
|  |   senseBox_multiplexer_init_tooltip: | ||||||
|  |     "Schließe den Multiplexer mit einem JST-JST Kabel an einen der 5 I2C-Ports an. Nun kannst du bis zu 8 gleiche Sensoren verwenden über die entsprechenden Kanäle ansprechen. Gib im Block die Anzahl der verwendeten Kanäle an", | ||||||
|  |   senseBox_multiplexer_init_helpurl: | ||||||
|  |     "https://docs.sensebox.de/hardware/zubehoer-multiplexer/", | ||||||
|  |   senseBox_multplexer_nchannels: "Kanälen", | ||||||
|  |   senseBox_multiplexer_changeChannel: "Wechsel Kanal auf:", | ||||||
|  |   sensebox_multiplexer_changeChannel_tooltip: | ||||||
|  |     "Wähle den entsprechenden Kanal aus", | ||||||
|  |   sensebox_multiplexer_changeChannel_helpurl: | ||||||
|  |     "https://docs.sensebox.de/hardware/zubehoer-multiplexer/", | ||||||
|  | }; | ||||||
| @ -1,25 +1,26 @@ | |||||||
| import { AUDIO } from './en/audio'; | import { AUDIO } from "./en/audio"; | ||||||
| import { FAQ } from './en/faq'; | import { FAQ } from "./en/faq"; | ||||||
| import { IO } from './en/io'; | import { IO } from "./en/io"; | ||||||
| import { LOGIC } from './en/logic'; | import { LOGIC } from "./en/logic"; | ||||||
| import { LOOPS } from './en/loops'; | import { LOOPS } from "./en/loops"; | ||||||
| import { MATH } from './en/math'; | import { MATH } from "./en/math"; | ||||||
| import { MQTT } from './en/mqtt'; | import { MQTT } from "./en/mqtt"; | ||||||
| import { DISPLAY } from './en/sensebox-display'; | import { SENSEBOX } from "./en/sensebox"; | ||||||
| import { LED } from './en/sensebox-led'; | import { DISPLAY } from "./en/sensebox-display"; | ||||||
| import { LORA } from './en/sensebox-lora'; | import { LED } from "./en/sensebox-led"; | ||||||
| import { OSEM } from './en/sensebox-osem'; | import { LORA } from "./en/sensebox-lora"; | ||||||
| import { SD } from './en/sensebox-sd'; | import { OSEM } from "./en/sensebox-osem"; | ||||||
| import { SENSORS } from './en/sensebox-sensors'; | import { SD } from "./en/sensebox-sd"; | ||||||
| import { TELEGRAM } from './en/sensebox-telegram'; | import { SENSORS } from "./en/sensebox-sensors"; | ||||||
| import { WEB } from './en/sensebox-web'; | import { TELEGRAM } from "./en/sensebox-telegram"; | ||||||
| import { TEXT } from './en/text'; | import { WEB } from "./en/sensebox-web"; | ||||||
| import { TIME } from './en/time'; | import { TEXT } from "./en/text"; | ||||||
| import { TOURS } from './en/tours'; | import { TIME } from "./en/time"; | ||||||
| import { TRANSLATIONS } from './en/translations'; | import { TOURS } from "./en/tours"; | ||||||
| import { UI } from './en/ui'; | import { TRANSLATIONS } from "./en/translations"; | ||||||
| import { VARIABLES } from './en/variables'; | import { UI } from "./en/ui"; | ||||||
| import { WEBSERVER } from './en/webserver'; | import { VARIABLES } from "./en/variables"; | ||||||
|  | import { WEBSERVER } from "./en/webserver"; | ||||||
| 
 | 
 | ||||||
| export const En = { | export const En = { | ||||||
|   ...AUDIO, |   ...AUDIO, | ||||||
| @ -35,6 +36,7 @@ export const En = { | |||||||
|   ...OSEM, |   ...OSEM, | ||||||
|   ...SD, |   ...SD, | ||||||
|   ...SENSORS, |   ...SENSORS, | ||||||
|  |   ...SENSEBOX, | ||||||
|   ...TELEGRAM, |   ...TELEGRAM, | ||||||
|   ...WEB, |   ...WEB, | ||||||
|   ...TEXT, |   ...TEXT, | ||||||
| @ -43,5 +45,5 @@ export const En = { | |||||||
|   ...TRANSLATIONS, |   ...TRANSLATIONS, | ||||||
|   ...UI, |   ...UI, | ||||||
|   ...VARIABLES, |   ...VARIABLES, | ||||||
|     ...WEBSERVER |   ...WEBSERVER, | ||||||
| } | }; | ||||||
|  | |||||||
							
								
								
									
										16
									
								
								src/components/Blockly/msg/en/sensebox.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/components/Blockly/msg/en/sensebox.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | |||||||
|  | export const SENSEBOX = { | ||||||
|  |   /** | ||||||
|  |    * Multiplexer | ||||||
|  |    */ | ||||||
|  |   senseBox_multiplexer_init: "Initialise Multiplexer with ", | ||||||
|  |   senseBox_multiplexer_init_tooltip: | ||||||
|  |     "Connect the multiplexer with a JST-JST cable to one of the 5 I2C ports. Now you can use up to 8 sensors of the same type and address them via the corresponding channels. Enter the number of used channels in the block", | ||||||
|  |   senseBox_multiplexer_init_helpurl: | ||||||
|  |     "https://en.docs.sensebox.de/hardware/zubehoer-multiplexer/", | ||||||
|  |   senseBox_multplexer_nchannels: "Channels", | ||||||
|  |   senseBox_multiplexer_changeChannel: "Change active channel to:", | ||||||
|  |   sensebox_multiplexer_changeChannel_tooltip: | ||||||
|  |     "Changes the active channel to the selected number", | ||||||
|  |   sensebox_multiplexer_changeChannel_helpurl: | ||||||
|  |     "https://en.docs.sensebox.de/hardware/zubehoer-multiplexer/", | ||||||
|  | }; | ||||||
| @ -75,6 +75,20 @@ class Toolbox extends React.Component { | |||||||
|           <Block type="sensebox_sensor_watertemperature" /> |           <Block type="sensebox_sensor_watertemperature" /> | ||||||
|           {/* <Block type="sensebox_windspeed" /> */} |           {/* <Block type="sensebox_windspeed" /> */} | ||||||
|           <Block type="sensebox_soundsensor_dfrobot" /> |           <Block type="sensebox_soundsensor_dfrobot" /> | ||||||
|  |           <Block type="sensebox_multiplexer_init"> | ||||||
|  |             <Value name="nrChannels"> | ||||||
|  |               <Block type="math_number"> | ||||||
|  |                 <Field name="NUM">1</Field> | ||||||
|  |               </Block> | ||||||
|  |             </Value> | ||||||
|  |           </Block> | ||||||
|  |           <Block type="sensebox_multiplexer_changeChannel"> | ||||||
|  |             <Value name="Channel"> | ||||||
|  |               <Block type="math_number"> | ||||||
|  |                 <Field name="NUM">1</Field> | ||||||
|  |               </Block> | ||||||
|  |             </Value> | ||||||
|  |           </Block> | ||||||
|         </Category> |         </Category> | ||||||
|         <Category name="WIFI" colour={getColour().sensebox}> |         <Category name="WIFI" colour={getColour().sensebox}> | ||||||
|           <Block type="sensebox_wifi" /> |           <Block type="sensebox_wifi" /> | ||||||
|  | |||||||
| @ -50,6 +50,7 @@ export class Login extends Component { | |||||||
|       } |       } | ||||||
|       // Check for login error
 |       // Check for login error
 | ||||||
|       else if (message.id === "LOGIN_FAIL") { |       else if (message.id === "LOGIN_FAIL") { | ||||||
|  |         console.log("login fail"); | ||||||
|         this.setState({ |         this.setState({ | ||||||
|           email: "", |           email: "", | ||||||
|           password: "", |           password: "", | ||||||
|  | |||||||
| @ -1,59 +1,69 @@ | |||||||
| import { MYBADGES_CONNECT, MYBADGES_DISCONNECT, USER_LOADED, USER_LOADING, AUTH_ERROR, LOGIN_SUCCESS, LOGIN_FAIL, LOGOUT_SUCCESS, LOGOUT_FAIL, REFRESH_TOKEN_SUCCESS } from '../actions/types'; | import { | ||||||
| 
 |   MYBADGES_CONNECT, | ||||||
|  |   MYBADGES_DISCONNECT, | ||||||
|  |   USER_LOADED, | ||||||
|  |   USER_LOADING, | ||||||
|  |   AUTH_ERROR, | ||||||
|  |   LOGIN_SUCCESS, | ||||||
|  |   LOGIN_FAIL, | ||||||
|  |   LOGOUT_SUCCESS, | ||||||
|  |   LOGOUT_FAIL, | ||||||
|  |   REFRESH_TOKEN_SUCCESS, | ||||||
|  | } from "../actions/types"; | ||||||
| 
 | 
 | ||||||
| const initialState = { | const initialState = { | ||||||
|   token: localStorage.getItem('token'), |   token: localStorage.getItem("token"), | ||||||
|   refreshToken: localStorage.getItem('refreshToken'), |   refreshToken: localStorage.getItem("refreshToken"), | ||||||
|   isAuthenticated: null, |   isAuthenticated: null, | ||||||
|   progress: true, |   progress: true, | ||||||
|   user: null |   user: null, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export default function foo(state = initialState, action){ | export default function foo(state = initialState, action) { | ||||||
|   switch(action.type){ |   switch (action.type) { | ||||||
|     case USER_LOADING: |     case USER_LOADING: | ||||||
|       return { |       return { | ||||||
|         ...state, |         ...state, | ||||||
|         progress: true |         progress: true, | ||||||
|       }; |       }; | ||||||
|     case USER_LOADED: |     case USER_LOADED: | ||||||
|       return { |       return { | ||||||
|         ...state, |         ...state, | ||||||
|         isAuthenticated: true, |         isAuthenticated: true, | ||||||
|         progress: false, |         progress: false, | ||||||
|         user: action.payload |         user: action.payload, | ||||||
|       }; |       }; | ||||||
|     case LOGIN_SUCCESS: |     case LOGIN_SUCCESS: | ||||||
|     case REFRESH_TOKEN_SUCCESS: |     case REFRESH_TOKEN_SUCCESS: | ||||||
|       localStorage.setItem('token', action.payload.token); |       localStorage.setItem("token", action.payload.token); | ||||||
|       localStorage.setItem('refreshToken', action.payload.refreshToken); |       localStorage.setItem("refreshToken", action.payload.refreshToken); | ||||||
|       return { |       return { | ||||||
|         ...state, |         ...state, | ||||||
|         user: action.payload.user, |         user: action.payload.user, | ||||||
|         token: action.payload.token, |         token: action.payload.token, | ||||||
|         refreshToken: action.payload.refreshToken, |         refreshToken: action.payload.refreshToken, | ||||||
|         isAuthenticated: true, |         isAuthenticated: true, | ||||||
|         progress: false |         progress: false, | ||||||
|       }; |       }; | ||||||
|     case MYBADGES_CONNECT: |     case MYBADGES_CONNECT: | ||||||
|     case MYBADGES_DISCONNECT: |     case MYBADGES_DISCONNECT: | ||||||
|       return { |       return { | ||||||
|         ...state, |         ...state, | ||||||
|         user: action.payload |         user: action.payload, | ||||||
|       }; |       }; | ||||||
|     case AUTH_ERROR: |     case AUTH_ERROR: | ||||||
|     case LOGIN_FAIL: |     case LOGIN_FAIL: | ||||||
|     case LOGOUT_SUCCESS: |     case LOGOUT_SUCCESS: | ||||||
|     case LOGOUT_FAIL: |     case LOGOUT_FAIL: | ||||||
|       localStorage.removeItem('token'); |       localStorage.removeItem("token"); | ||||||
|       localStorage.removeItem('refreshToken'); |       localStorage.removeItem("refreshToken"); | ||||||
|       return { |       return { | ||||||
|         ...state, |         ...state, | ||||||
|         token: null, |         token: null, | ||||||
|         refreshToken: null, |         refreshToken: null, | ||||||
|         user: null, |         user: null, | ||||||
|         isAuthenticated: false, |         isAuthenticated: false, | ||||||
|         progress: false |         progress: false, | ||||||
|       }; |       }; | ||||||
|     default: |     default: | ||||||
|       return state; |       return state; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user