Compare commits
2 Commits
master
...
block/upda
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5901caa278 | ||
|
|
b74aef8167 |
3
.env
@ -2,7 +2,8 @@ REACT_APP_COMPILER_URL=https://compiler.sensebox.de
|
||||
REACT_APP_BOARD=sensebox-mcu
|
||||
REACT_APP_BLOCKLY_API=https://api.blockly.sensebox.de
|
||||
|
||||
GENERATE_SOURCEMAP=false
|
||||
REACT_APP_MYBADGES=https://mybadges.org
|
||||
REACT_APP_MYBADGES_API=https://mybadges.org/api/v1
|
||||
|
||||
# in days
|
||||
REACT_APP_SHARE_LINK_EXPIRES=30
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
name: Build and push image
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
#defaults:
|
||||
# run:
|
||||
# working-directory: /repo
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # all history for all branches and tags
|
||||
|
||||
- name: Login to gitea.simonzeyer.de Repo
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: gitea.simonzeyer.de
|
||||
username: ${{ secrets.DOCKER_REPO_USER }}
|
||||
password: ${{ secrets.DOCKER_REPO_PASSWD }}
|
||||
|
||||
- name: Get Meta
|
||||
id: meta
|
||||
run: |
|
||||
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
||||
echo REPO_VERSION=$(git describe --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
env:
|
||||
ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
gitea.simonzeyer.de/schuelerlabor-cleverlab/smarti:${{ steps.meta.outputs.REPO_VERSION }}
|
||||
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,38 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
14
.github/ISSUE_TEMPLATE/short-issue.md
vendored
@ -1,14 +0,0 @@
|
||||
---
|
||||
name: Short Issue
|
||||
about: Template for Short Issues
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Current behaviour
|
||||
Describe the current behaviour
|
||||
|
||||
### Expected behaviour
|
||||
Describe how it is supposed to work
|
||||
2
.gitignore
vendored
@ -22,4 +22,4 @@ npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
package-lock.json
|
||||
|
||||
package-lock.json
|
||||
|
||||
26
CITATION.cff
@ -1,26 +0,0 @@
|
||||
# This CITATION.cff file was generated with cffinit.
|
||||
# Visit https://bit.ly/cffinit to generate yours today!
|
||||
|
||||
cff-version: 1.2.0
|
||||
title: senseBox Learn- and Programming Environment
|
||||
message: Please cite this software using these metadata.
|
||||
type: software
|
||||
version: 1.0.0
|
||||
date-released: 2021-09-30
|
||||
url: "https://github.com/sensebox/React-Ardublockly"
|
||||
authors:
|
||||
- given-names: Mario
|
||||
family-names: Pesch
|
||||
email: mario.pesch@uni-muenster.de
|
||||
affiliation: >-
|
||||
Institute for geoinformatics University of
|
||||
Muenster
|
||||
- given-names: Luc
|
||||
family-names: Niski
|
||||
affiliation: >-
|
||||
Institute for geoinformatics University of
|
||||
Muenster
|
||||
- given-names: Felix
|
||||
family-names: Erdmann
|
||||
email: f.erdmann@reedu.de
|
||||
affiliation: Reedu GmbH & Co. KG
|
||||
12
Dockerfile
@ -1,12 +0,0 @@
|
||||
# specify the node base image with your desired version node:<version>
|
||||
FROM node:16 as build
|
||||
WORKDIR /app
|
||||
copy ./ /app
|
||||
RUN npm install --verbose
|
||||
RUN npm run build --verbose
|
||||
|
||||
FROM nginx:alpine
|
||||
COPY --from=build /app/build/ /usr/share/nginx/html
|
||||
RUN chmod 755 /usr/share/nginx/html/ -R
|
||||
EXPOSE 80
|
||||
ENTRYPOINT ["sh", "-c", "cd /usr/share/nginx/html/ && nginx -g 'daemon off;'"]
|
||||
@ -22,4 +22,7 @@ This project was created with [Create React App](https://github.com/facebook/cre
|
||||
Ensure that line 14 in [store.js](https://github.com/sensebox/React-Ardublockly/blob/master/src/store.js#L14) is commented out or otherwise you have installed [Redux DevTools Extension](http://extension.remotedev.io/).
|
||||
|
||||
## Demo
|
||||
A demo of the current status of the master branch can be accessed via [https://blockly-react.netlify.app/](https://blockly-react.netlify.app/) :rocket:.
|
||||
A demo of the current status of the master branch can be accessed via [sensebox-ardublockly.netlify.app](https://sensebox-ardublockly.netlify.app/) :rocket:.
|
||||
* [Home](https://sensebox-ardublockly.netlify.app/)
|
||||
* [Tutorial Overview](https://sensebox-ardublockly.netlify.app/tutorial)
|
||||
* [Tutorial-Builder](https://sensebox-ardublockly.netlify.app/tutorial/builder)
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
# docker-compose.yml
|
||||
services:
|
||||
smarti:
|
||||
mem_limit: 2048m
|
||||
mem_reservation: 128M
|
||||
cpus: 2
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "80"
|
||||
|
||||
44954
package-lock.json
generated
Normal file
92
package.json
@ -1,64 +1,42 @@
|
||||
{
|
||||
"name": "blockly-react",
|
||||
"version": "1.0.0",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@blockly/block-plus-minus": "^4.0.4",
|
||||
"@blockly/field-grid-dropdown": "^2.0.4",
|
||||
"@blockly/field-slider": "4.0.4",
|
||||
"@blockly/plugin-scroll-options": "^3.0.5",
|
||||
"@blockly/plugin-typed-variable-modal": "^5.0.6",
|
||||
"@blockly/workspace-backpack": "^3.0.4",
|
||||
"@blockly/zoom-to-fit": "^3.0.4",
|
||||
"@emotion/react": "^11.10.5",
|
||||
"@emotion/styled": "^11.10.5",
|
||||
"@fortawesome/fontawesome-svg-core": "^6.2.1",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.2.1",
|
||||
"@fortawesome/react-fontawesome": "^0.2.0",
|
||||
"@monaco-editor/react": "^4.3.1",
|
||||
"@mui/lab": "^5.0.0-alpha.110",
|
||||
"@mui/material": "^5.10.16",
|
||||
"@mui/styles": "^5.10.16",
|
||||
"@testing-library/jest-dom": "^5.16.1",
|
||||
"@testing-library/react": "^12.1.2",
|
||||
"@blockly/block-plus-minus": "^2.0.10",
|
||||
"@blockly/field-slider": "^2.1.1",
|
||||
"@blockly/plugin-typed-variable-modal": "^3.1.15",
|
||||
"@fortawesome/fontawesome-svg-core": "^1.2.30",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.14.0",
|
||||
"@fortawesome/react-fontawesome": "^0.1.11",
|
||||
"@material-ui/core": "^4.11.0",
|
||||
"@sentry/react": "^6.0.0",
|
||||
"@sentry/tracing": "^6.0.0",
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
"@testing-library/react": "^9.5.0",
|
||||
"@testing-library/user-event": "^7.2.1",
|
||||
"axios": "^0.22.0",
|
||||
"blockly": "^9.2.0",
|
||||
"file-saver": "^2.0.5",
|
||||
"markdown-it": "^12.3.2",
|
||||
"axios": "^0.21.0",
|
||||
"blockly": "^5.20210325.1",
|
||||
"file-saver": "^2.0.2",
|
||||
"mnemonic-id": "^3.2.7",
|
||||
"moment": "^2.29.4",
|
||||
"prismjs": "^1.27.0",
|
||||
"qrcode.react": "^3.1.0",
|
||||
"react": "^17.0.2",
|
||||
"react-cookie-consent": "^7.2.1",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-markdown": "^8.0.0",
|
||||
"react-markdown-editor-lite": "^1.3.3",
|
||||
"react-mde": "^11.5.0",
|
||||
"react-rating-stars-component": "^2.2.0",
|
||||
"react-redux": "^7.2.9",
|
||||
"react-router-dom": "^5.3.3",
|
||||
"react-scripts": "^5.0.1",
|
||||
"react-share": "^4.4.0",
|
||||
"react-spinners": "^0.13.3",
|
||||
"reactour": "^1.18.7",
|
||||
"redux": "^4.2.0",
|
||||
"redux-thunk": "^2.4.1",
|
||||
"rehype-raw": "^6.1.1",
|
||||
"remark-gemoji": "^7.0.1",
|
||||
"remark-gfm": "^3.0.1",
|
||||
"moment": "^2.28.0",
|
||||
"prismjs": "^1.23.0",
|
||||
"react": "^16.13.1",
|
||||
"react-cookie-consent": "^5.2.0",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-markdown": "^5.0.2",
|
||||
"react-redux": "^7.2.0",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-scripts": "^4.0.3",
|
||||
"reactour": "^1.18.0",
|
||||
"redux": "^4.0.5",
|
||||
"redux-thunk": "^2.3.0",
|
||||
"styled-components": "^4.4.1",
|
||||
"uuid": "^8.3.1",
|
||||
"watchpack": "^2.3.1"
|
||||
},
|
||||
"resolutions": {
|
||||
"//": "See https://github.com/facebook/create-react-app/issues/11773",
|
||||
"react-error-overlay": "6.0.9"
|
||||
"uuid": "^8.3.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node_modules/react-scripts/bin/react-scripts.js start",
|
||||
"dev": "set \"REACT_APP_BLOCKLY_API=http://localhost:8080\" && npm start",
|
||||
"start": "react-scripts start",
|
||||
"dev": "set \"REACT_APP_BLOCKLY_API=http://localhost:8080\" && set \"REACT_APP_MYBADGES_API=http://localhost:3001/api/v1\"&& npm start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
@ -66,12 +44,16 @@
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
},
|
||||
"browserslist": [
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-private-property-in-object": "7.21.11"
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,13 +24,6 @@
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<!-- Matomo Image Tracker-->
|
||||
<img
|
||||
src="https://piwik.sensebox.kaufen/matomo.php?idsite=9&rec=1"
|
||||
style="border: 0; display: none"
|
||||
alt=""
|
||||
/>
|
||||
<!-- End Matomo -->
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
|
||||
|
Before Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 777 KiB |
|
Before Width: | Height: | Size: 728 KiB |
|
Before Width: | Height: | Size: 343 KiB |
|
Before Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 472 KiB |
33
src/App.css
@ -1,17 +1,16 @@
|
||||
.wrapper {
|
||||
min-height: calc(
|
||||
100vh - 60px
|
||||
); /* will cover the 100% of viewport - height of footer (padding-bottom) */
|
||||
min-height: calc(100vh - 60px); /* will cover the 100% of viewport - height of footer (padding-bottom) */
|
||||
overflow: hidden;
|
||||
display: block;
|
||||
position: relative;
|
||||
padding-bottom: 60px; /* height of your footer + 30px*/
|
||||
}
|
||||
|
||||
|
||||
.tutorial img{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
max-height: 40vh;
|
||||
max-height: 40vH;
|
||||
max-width: 100%;
|
||||
margin: auto;
|
||||
}
|
||||
@ -19,7 +18,7 @@
|
||||
.news img{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
max-height: 40vh;
|
||||
max-height: 40vH;
|
||||
max-width: 100%;
|
||||
margin: auto;
|
||||
}
|
||||
@ -32,7 +31,7 @@
|
||||
quotes: "\201C""\201D""\2018""\2019";
|
||||
}
|
||||
blockquote:before {
|
||||
color: #4eaf47;
|
||||
color:#4EAF47;
|
||||
content: open-quote;
|
||||
font-size: 4em;
|
||||
line-height: 0.1em;
|
||||
@ -43,32 +42,10 @@ blockquote p {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.tutorial table,
|
||||
th,
|
||||
td {
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.tutorial th {
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
text-align: left;
|
||||
border-color: #4eaf47;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.overlay {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
:root {
|
||||
--url: url('./data/mcu_opacity.png');
|
||||
}
|
||||
|
||||
.blocklySvg {
|
||||
background-image: var(--url);
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
33
src/App.js
@ -1,34 +1,35 @@
|
||||
import React, { Component } from "react";
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import { Router } from "react-router-dom";
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import { createBrowserHistory } from "history";
|
||||
|
||||
import { Provider } from "react-redux";
|
||||
import store from "./store";
|
||||
import { loadUser } from "./actions/authActions";
|
||||
import { Provider } from 'react-redux';
|
||||
import store from './store';
|
||||
import { loadUser } from './actions/authActions';
|
||||
|
||||
import "./App.css";
|
||||
import './App.css';
|
||||
|
||||
import { ThemeProvider, StyledEngineProvider, createTheme } from "@mui/material/styles";
|
||||
import { ThemeProvider, createMuiTheme } from '@material-ui/core/styles';
|
||||
|
||||
import Content from "./components/Content";
|
||||
import Content from './components/Content';
|
||||
|
||||
const theme = createTheme({
|
||||
const theme = createMuiTheme({
|
||||
palette: {
|
||||
primary: {
|
||||
main: "#4EAF47",
|
||||
contrastText: "#ffffff",
|
||||
main: '#4EAF47',
|
||||
contrastText: '#ffffff'
|
||||
},
|
||||
secondary: {
|
||||
main: "#DDDDDD",
|
||||
main: '#DDDDDD'
|
||||
},
|
||||
button: {
|
||||
compile: "#e27136",
|
||||
},
|
||||
},
|
||||
compile: '#e27136'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
class App extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
store.dispatch(loadUser());
|
||||
}
|
||||
@ -36,7 +37,6 @@ class App extends Component {
|
||||
render() {
|
||||
const customHistory = createBrowserHistory();
|
||||
return (
|
||||
<StyledEngineProvider injectFirst>
|
||||
<ThemeProvider theme={theme}>
|
||||
<Provider store={store}>
|
||||
<Router history={customHistory}>
|
||||
@ -44,7 +44,6 @@ class App extends Component {
|
||||
</Router>
|
||||
</Provider>
|
||||
</ThemeProvider>
|
||||
</StyledEngineProvider>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,199 +1,242 @@
|
||||
import {
|
||||
GET_STATUS,
|
||||
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, GET_STATUS, USER_LOADED, USER_LOADING, AUTH_ERROR, LOGIN_SUCCESS, LOGIN_FAIL, LOGOUT_SUCCESS, LOGOUT_FAIL, REFRESH_TOKEN_SUCCESS } from '../actions/types';
|
||||
|
||||
import axios from "axios";
|
||||
import { returnErrors, returnSuccess } from "./messageActions";
|
||||
import { setLanguage } from "./generalActions";
|
||||
import axios from 'axios';
|
||||
import { returnErrors, returnSuccess } from './messageActions';
|
||||
import { setLanguage } from './generalActions';
|
||||
|
||||
// Check token & load user
|
||||
export const loadUser = () => (dispatch) => {
|
||||
// user loading
|
||||
dispatch({
|
||||
type: USER_LOADING,
|
||||
type: USER_LOADING
|
||||
});
|
||||
const config = {
|
||||
success: (res) => {
|
||||
success: res => {
|
||||
dispatch({
|
||||
type: GET_STATUS,
|
||||
payload: res.data.user.status,
|
||||
payload: res.data.user.status
|
||||
});
|
||||
dispatch(setLanguage(res.data.user.language));
|
||||
dispatch({
|
||||
type: USER_LOADED,
|
||||
payload: res.data.user,
|
||||
payload: res.data.user
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
error: err => {
|
||||
if(err.response){
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status));
|
||||
}
|
||||
var status = [];
|
||||
if (window.localStorage.getItem("status")) {
|
||||
status = JSON.parse(window.localStorage.getItem("status"));
|
||||
if (window.localStorage.getItem('status')) {
|
||||
status = JSON.parse(window.localStorage.getItem('status'));
|
||||
}
|
||||
dispatch({
|
||||
type: GET_STATUS,
|
||||
payload: status,
|
||||
payload: status
|
||||
});
|
||||
dispatch({
|
||||
type: AUTH_ERROR,
|
||||
type: AUTH_ERROR
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
axios
|
||||
.get(
|
||||
`${process.env.REACT_APP_BLOCKLY_API}/user`,
|
||||
config,
|
||||
dispatch(authInterceptor())
|
||||
)
|
||||
.then((res) => {
|
||||
axios.get(`${process.env.REACT_APP_BLOCKLY_API}/user`, config, dispatch(authInterceptor()))
|
||||
.then(res => {
|
||||
res.config.success(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
err.config.error(err);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var logoutTimerId;
|
||||
const timeToLogout = 14.9*60*1000; // nearly 15 minutes corresponding to the API
|
||||
|
||||
// Login user
|
||||
export const login =
|
||||
({ email, password }) =>
|
||||
(dispatch) => {
|
||||
export const login = ({ email, password }) => (dispatch) => {
|
||||
dispatch({
|
||||
type: USER_LOADING,
|
||||
type: USER_LOADING
|
||||
});
|
||||
// Headers
|
||||
const config = {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
// Request Body
|
||||
const body = JSON.stringify({ email, password });
|
||||
axios
|
||||
.post(`${process.env.REACT_APP_BLOCKLY_API}/user`, body, config)
|
||||
.then((res) => {
|
||||
axios.post(`${process.env.REACT_APP_BLOCKLY_API}/user`, body, config)
|
||||
.then(res => {
|
||||
// Logout automatically if refreshToken "expired"
|
||||
const logoutTimer = () => setTimeout(
|
||||
() => dispatch(logout()),
|
||||
timeToLogout
|
||||
);
|
||||
logoutTimerId = logoutTimer();
|
||||
dispatch(setLanguage(res.data.user.language));
|
||||
dispatch({
|
||||
type: LOGIN_SUCCESS,
|
||||
payload: res.data,
|
||||
payload: res.data
|
||||
});
|
||||
dispatch({
|
||||
type: GET_STATUS,
|
||||
payload: res.data.user.status,
|
||||
payload: res.data.user.status
|
||||
});
|
||||
dispatch(returnSuccess(res.data.message, res.status, "LOGIN_SUCCESS"));
|
||||
dispatch(returnSuccess(res.data.message, res.status, 'LOGIN_SUCCESS'));
|
||||
})
|
||||
.catch((err) => {
|
||||
dispatch(
|
||||
returnErrors(
|
||||
err.response.data.message,
|
||||
err.response.status,
|
||||
"LOGIN_FAIL"
|
||||
)
|
||||
);
|
||||
.catch(err => {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'LOGIN_FAIL'));
|
||||
dispatch({
|
||||
type: LOGIN_FAIL,
|
||||
type: LOGIN_FAIL
|
||||
});
|
||||
var status = [];
|
||||
if (window.localStorage.getItem("status")) {
|
||||
status = JSON.parse(window.localStorage.getItem("status"));
|
||||
if (window.localStorage.getItem('status')) {
|
||||
status = JSON.parse(window.localStorage.getItem('status'));
|
||||
}
|
||||
dispatch({
|
||||
type: GET_STATUS,
|
||||
payload: status,
|
||||
payload: status
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Logout User
|
||||
export const logout = () => (dispatch) => {
|
||||
|
||||
// Connect to MyBadges-Account
|
||||
export const connectMyBadges = ({ username, password }) => (dispatch, getState) => {
|
||||
const config = {
|
||||
success: (res) => {
|
||||
success: res => {
|
||||
var user = getState().auth.user;
|
||||
user.badge = res.data.account;
|
||||
user.badges = res.data.badges;
|
||||
dispatch({
|
||||
type: LOGOUT_SUCCESS,
|
||||
type: MYBADGES_CONNECT,
|
||||
payload: user
|
||||
});
|
||||
var status = [];
|
||||
if (window.localStorage.getItem("status")) {
|
||||
status = JSON.parse(window.localStorage.getItem("status"));
|
||||
}
|
||||
dispatch({
|
||||
type: GET_STATUS,
|
||||
payload: status,
|
||||
});
|
||||
var locale = "en_US";
|
||||
if (window.localStorage.getItem("locale")) {
|
||||
locale = window.localStorage.getItem("locale");
|
||||
} else if (navigator.language === "de-DE") {
|
||||
locale = "de_DE";
|
||||
}
|
||||
dispatch(setLanguage(locale));
|
||||
dispatch(returnSuccess(res.data.message, res.status, "LOGOUT_SUCCESS"));
|
||||
dispatch(returnSuccess(res.data.message, res.status, 'MYBADGES_CONNECT_SUCCESS'));
|
||||
},
|
||||
error: (err) => {
|
||||
dispatch(
|
||||
returnErrors(
|
||||
err.response.data.message,
|
||||
err.response.status,
|
||||
"LOGOUT_FAIL"
|
||||
)
|
||||
);
|
||||
dispatch({
|
||||
type: LOGOUT_FAIL,
|
||||
});
|
||||
var status = [];
|
||||
if (window.localStorage.getItem("status")) {
|
||||
status = JSON.parse(window.localStorage.getItem("status"));
|
||||
error: err => {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'MYBADGES_CONNECT_FAIL'));
|
||||
}
|
||||
dispatch({
|
||||
type: GET_STATUS,
|
||||
payload: status,
|
||||
});
|
||||
},
|
||||
};
|
||||
axios
|
||||
.post("https://api.opensensemap.org/users/sign-out", {}, config)
|
||||
.then((res) => {
|
||||
// Request Body
|
||||
const body = JSON.stringify({ username, password });
|
||||
axios.post(`${process.env.REACT_APP_BLOCKLY_API}/user/badge`, body, config)
|
||||
.then(res => {
|
||||
res.config.success(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
if(err.response && err.response.status !== 401){
|
||||
err.config.error(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Disconnect MyBadges-Account
|
||||
export const disconnectMyBadges = () => (dispatch, getState) => {
|
||||
const config = {
|
||||
success: res => {
|
||||
var user = getState().auth.user;
|
||||
user.badge = null;
|
||||
user.badges = null;
|
||||
dispatch({
|
||||
type: MYBADGES_DISCONNECT,
|
||||
payload: user
|
||||
});
|
||||
dispatch(returnSuccess(res.data.message, res.status, 'MYBADGES_DISCONNECT_SUCCESS'));
|
||||
},
|
||||
error: err => {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'MYBADGES_DISCONNECT_FAIL'));
|
||||
}
|
||||
};
|
||||
axios.put(`${process.env.REACT_APP_BLOCKLY_API}/user/badge`, {}, config)
|
||||
.then(res => {
|
||||
res.config.success(res);
|
||||
})
|
||||
.catch(err => {
|
||||
if(err.response && err.response.status !== 401){
|
||||
err.config.error(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// Logout User
|
||||
export const logout = () => (dispatch) => {
|
||||
const config = {
|
||||
success: res => {
|
||||
dispatch({
|
||||
type: LOGOUT_SUCCESS
|
||||
});
|
||||
var status = [];
|
||||
if (window.localStorage.getItem('status')) {
|
||||
status = JSON.parse(window.localStorage.getItem('status'));
|
||||
}
|
||||
dispatch({
|
||||
type: GET_STATUS,
|
||||
payload: status
|
||||
});
|
||||
var locale = 'en_US';
|
||||
if (window.localStorage.getItem('locale')) {
|
||||
locale = window.localStorage.getItem('locale');
|
||||
}
|
||||
else if (navigator.language === 'de-DE'){
|
||||
locale = 'de_DE';
|
||||
}
|
||||
dispatch(setLanguage(locale));
|
||||
dispatch(returnSuccess(res.data.message, res.status, 'LOGOUT_SUCCESS'));
|
||||
clearTimeout(logoutTimerId);
|
||||
},
|
||||
error: err => {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'LOGOUT_FAIL'));
|
||||
dispatch({
|
||||
type: LOGOUT_FAIL
|
||||
});
|
||||
var status = [];
|
||||
if (window.localStorage.getItem('status')) {
|
||||
status = JSON.parse(window.localStorage.getItem('status'));
|
||||
}
|
||||
dispatch({
|
||||
type: GET_STATUS,
|
||||
payload: status
|
||||
});
|
||||
clearTimeout(logoutTimerId);
|
||||
}
|
||||
};
|
||||
axios.post('https://api.opensensemap.org/users/sign-out', {}, config)
|
||||
.then(res => {
|
||||
res.config.success(res);
|
||||
})
|
||||
.catch(err => {
|
||||
if(err.response && err.response.status !== 401){
|
||||
err.config.error(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
export const authInterceptor = () => (dispatch, getState) => {
|
||||
// Add a request interceptor
|
||||
axios.interceptors.request.use(
|
||||
(config) => {
|
||||
config.headers["Content-Type"] = "application/json";
|
||||
config => {
|
||||
config.headers['Content-Type'] = 'application/json';
|
||||
const token = getState().auth.token;
|
||||
if (token) {
|
||||
config.headers["Authorization"] = `Bearer ${token}`;
|
||||
config.headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
error => {
|
||||
Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
// Add a response interceptor
|
||||
axios.interceptors.response.use(
|
||||
(response) => {
|
||||
response => {
|
||||
// request was successfull
|
||||
return response;
|
||||
},
|
||||
(error) => {
|
||||
error => {
|
||||
const originalRequest = error.config;
|
||||
const refreshToken = getState().auth.refreshToken;
|
||||
if(refreshToken){
|
||||
@ -207,38 +250,38 @@ export const authInterceptor = () => (dispatch, getState) => {
|
||||
originalRequest._retry = true;
|
||||
const refreshToken = getState().auth.refreshToken;
|
||||
// request to refresh the token, in request-body is the refreshToken
|
||||
axios
|
||||
.post("https://api.opensensemap.org/users/refresh-auth", {
|
||||
token: refreshToken,
|
||||
})
|
||||
.then((res) => {
|
||||
axios.post('https://api.opensensemap.org/users/refresh-auth', {"token": refreshToken})
|
||||
.then(res => {
|
||||
if (res.status === 200) {
|
||||
clearTimeout(logoutTimerId);
|
||||
const logoutTimer = () => setTimeout(
|
||||
() => dispatch(logout()),
|
||||
timeToLogout
|
||||
);
|
||||
logoutTimerId = logoutTimer();
|
||||
dispatch({
|
||||
type: REFRESH_TOKEN_SUCCESS,
|
||||
payload: res.data,
|
||||
payload: res.data
|
||||
});
|
||||
axios.defaults.headers.common["Authorization"] =
|
||||
"Bearer " + getState().auth.token;
|
||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + getState().auth.token;
|
||||
// request was successfull, new request with the old parameters and the refreshed token
|
||||
return axios(originalRequest)
|
||||
.then((res) => {
|
||||
.then(res => {
|
||||
originalRequest.success(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
originalRequest.error(err);
|
||||
});
|
||||
}
|
||||
return Promise.reject(error);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
// request failed, token could not be refreshed
|
||||
if(err.response){
|
||||
dispatch(
|
||||
returnErrors(err.response.data.message, err.response.status)
|
||||
);
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status));
|
||||
}
|
||||
dispatch({
|
||||
type: AUTH_ERROR,
|
||||
type: AUTH_ERROR
|
||||
});
|
||||
return Promise.reject(error);
|
||||
});
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
import {
|
||||
BOARD,
|
||||
} from "./types";
|
||||
import mini_opacity from "../data/mini_opacity.png"
|
||||
import mcu_opacity from "../data/mcu_opacity.png"
|
||||
|
||||
export const setBoard = (board) => (dispatch) => {
|
||||
window.sessionStorage.setItem("board", board);
|
||||
const root = document.querySelector(':root');
|
||||
root.style.setProperty('--url', `url(${board === "mcu" ? mcu_opacity : mini_opacity})`);
|
||||
dispatch({
|
||||
type: BOARD,
|
||||
payload: board,
|
||||
});
|
||||
};
|
||||
@ -1,52 +1,32 @@
|
||||
import {
|
||||
VISIT,
|
||||
LANGUAGE,
|
||||
RENDERER,
|
||||
SOUNDS,
|
||||
STATISTICS,
|
||||
PLATFORM,
|
||||
} from "./types";
|
||||
import { VISIT, LANGUAGE, RENDERER, STATISTICS } from './types';
|
||||
|
||||
|
||||
export const visitPage = () => (dispatch) => {
|
||||
dispatch({
|
||||
type: VISIT,
|
||||
});
|
||||
};
|
||||
|
||||
export const setPlatform = (platform) => (dispatch) => {
|
||||
dispatch({
|
||||
type: PLATFORM,
|
||||
payload: platform,
|
||||
type: VISIT
|
||||
});
|
||||
};
|
||||
|
||||
export const setLanguage = (language) => (dispatch, getState) => {
|
||||
if(!getState().auth.progress && !getState().auth.isAuthenticated){
|
||||
window.localStorage.setItem("locale", language);
|
||||
window.localStorage.setItem('locale', language);
|
||||
}
|
||||
dispatch({
|
||||
type: LANGUAGE,
|
||||
payload: language,
|
||||
payload: language
|
||||
});
|
||||
};
|
||||
|
||||
export const setRenderer = (renderer) => (dispatch) => {
|
||||
dispatch({
|
||||
type: RENDERER,
|
||||
payload: renderer,
|
||||
});
|
||||
};
|
||||
|
||||
export const setSounds = (sounds) => (dispatch) => {
|
||||
dispatch({
|
||||
type: SOUNDS,
|
||||
payload: sounds,
|
||||
payload: renderer
|
||||
});
|
||||
};
|
||||
|
||||
export const setStatistics = (showStatistics) => (dispatch) => {
|
||||
dispatch({
|
||||
type: STATISTICS,
|
||||
payload: showStatistics,
|
||||
payload: showStatistics
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const fetchSensorWikiSuccess = sensors => ({
|
||||
type: 'FETCH_SENSORWIKI_SUCCESS',
|
||||
payload: { sensors }
|
||||
})
|
||||
|
||||
export const fetchSensors = () => {
|
||||
return async dispatch => {
|
||||
try {
|
||||
let sensors = await axios.get('https://api.sensors.wiki/sensors/all')
|
||||
dispatch(fetchSensorWikiSuccess(sensors.data))
|
||||
}
|
||||
catch(e){
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,176 +1,109 @@
|
||||
import {
|
||||
TUTORIAL_PROGRESS,
|
||||
GET_TUTORIAL,
|
||||
GET_TUTORIALS,
|
||||
TUTORIAL_SUCCESS,
|
||||
TUTORIAL_ERROR,
|
||||
TUTORIAL_CHANGE,
|
||||
TUTORIAL_XML,
|
||||
TUTORIAL_STEP,
|
||||
} from "./types";
|
||||
import { MYBADGES_DISCONNECT, TUTORIAL_PROGRESS, GET_TUTORIAL, GET_TUTORIALS, TUTORIAL_SUCCESS, TUTORIAL_ERROR, TUTORIAL_CHANGE, TUTORIAL_XML, TUTORIAL_STEP } from './types';
|
||||
|
||||
import axios from "axios";
|
||||
import { returnErrors, returnSuccess } from "./messageActions";
|
||||
import axios from 'axios';
|
||||
import { returnErrors, returnSuccess } from './messageActions';
|
||||
|
||||
export const tutorialProgress = () => (dispatch) => {
|
||||
dispatch({type: TUTORIAL_PROGRESS});
|
||||
};
|
||||
|
||||
|
||||
export const getTutorial = (id) => (dispatch, getState) => {
|
||||
axios
|
||||
.get(`${process.env.REACT_APP_BLOCKLY_API}/tutorial/${id}`)
|
||||
.then((res) => {
|
||||
axios.get(`${process.env.REACT_APP_BLOCKLY_API}/tutorial/${id}`)
|
||||
.then(res => {
|
||||
var tutorial = res.data.tutorial;
|
||||
existingTutorial(tutorial, getState().tutorial.status).then((status) => {
|
||||
existingTutorial(tutorial, getState().tutorial.status).then(status => {
|
||||
dispatch({
|
||||
type: TUTORIAL_SUCCESS,
|
||||
payload: status,
|
||||
payload: status
|
||||
});
|
||||
dispatch(updateStatus(status));
|
||||
dispatch({
|
||||
type: GET_TUTORIAL,
|
||||
payload: tutorial,
|
||||
payload: tutorial
|
||||
});
|
||||
dispatch({type: TUTORIAL_PROGRESS});
|
||||
dispatch(returnSuccess(res.data.message, res.status));
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
if (err.response) {
|
||||
dispatch(
|
||||
returnErrors(
|
||||
err.response.data.message,
|
||||
err.response.status,
|
||||
"GET_TUTORIAL_FAIL"
|
||||
)
|
||||
);
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'GET_TUTORIAL_FAIL'));
|
||||
}
|
||||
dispatch({ type: TUTORIAL_PROGRESS });
|
||||
});
|
||||
};
|
||||
|
||||
export const getTutorials = () => (dispatch, getState) => {
|
||||
axios
|
||||
.get(`${process.env.REACT_APP_BLOCKLY_API}/tutorial`)
|
||||
.then((res) => {
|
||||
axios.get(`${process.env.REACT_APP_BLOCKLY_API}/tutorial`)
|
||||
.then(res => {
|
||||
var tutorials = res.data.tutorials;
|
||||
existingTutorials(tutorials, getState().tutorial.status).then(
|
||||
(status) => {
|
||||
console.log(tutorials);
|
||||
existingTutorials(tutorials, getState().tutorial.status).then(status => {
|
||||
dispatch({
|
||||
type: TUTORIAL_SUCCESS,
|
||||
payload: status,
|
||||
payload: status
|
||||
});
|
||||
console.log('zwei');
|
||||
dispatch(updateStatus(status));
|
||||
dispatch({
|
||||
type: GET_TUTORIALS,
|
||||
payload: tutorials,
|
||||
payload: tutorials
|
||||
});
|
||||
dispatch({ type: TUTORIAL_PROGRESS });
|
||||
dispatch(returnSuccess(res.data.message, res.status));
|
||||
}
|
||||
);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
if (err.response) {
|
||||
dispatch(
|
||||
returnErrors(
|
||||
err.response.data.message,
|
||||
err.response.status,
|
||||
"GET_TUTORIALS_FAIL"
|
||||
)
|
||||
);
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'GET_TUTORIALS_FAIL'));
|
||||
}
|
||||
dispatch({ type: TUTORIAL_PROGRESS });
|
||||
});
|
||||
};
|
||||
|
||||
export const getAllTutorials = () => (dispatch, getState) => {
|
||||
axios
|
||||
.get(`${process.env.REACT_APP_BLOCKLY_API}/tutorial/getAllTutorials`)
|
||||
.then((res) => {
|
||||
var tutorials = res.data.tutorials;
|
||||
existingTutorials(tutorials, getState().tutorial.status).then(
|
||||
(status) => {
|
||||
export const assigneBadge = (id) => (dispatch, getState) => {
|
||||
const config = {
|
||||
success: res => {
|
||||
var badge = res.data.badge;
|
||||
var user = getState().auth.user;
|
||||
user.badges.push(badge._id);
|
||||
dispatch({
|
||||
type: TUTORIAL_SUCCESS,
|
||||
payload: status,
|
||||
type: MYBADGES_DISCONNECT,
|
||||
payload: user
|
||||
});
|
||||
dispatch(updateStatus(status));
|
||||
dispatch({
|
||||
type: GET_TUTORIALS,
|
||||
payload: tutorials,
|
||||
});
|
||||
dispatch({ type: TUTORIAL_PROGRESS });
|
||||
dispatch(returnSuccess(res.data.message, res.status));
|
||||
dispatch(returnSuccess(badge, res.status, 'ASSIGNE_BADGE_SUCCESS'));
|
||||
},
|
||||
error: err => {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'ASSIGNE_BADGE_FAIL'));
|
||||
}
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err.response) {
|
||||
dispatch(
|
||||
returnErrors(
|
||||
err.response.data.message,
|
||||
err.response.status,
|
||||
"GET_TUTORIALS_FAIL"
|
||||
)
|
||||
);
|
||||
}
|
||||
dispatch({ type: TUTORIAL_PROGRESS });
|
||||
});
|
||||
};
|
||||
|
||||
export const getUserTutorials = () => (dispatch, getState) => {
|
||||
axios
|
||||
.get(`${process.env.REACT_APP_BLOCKLY_API}/tutorial/getUserTutorials`)
|
||||
.then((res) => {
|
||||
var tutorials = res.data.tutorials;
|
||||
existingTutorials(tutorials, getState().tutorial.status).then(
|
||||
(status) => {
|
||||
dispatch({
|
||||
type: TUTORIAL_SUCCESS,
|
||||
payload: status,
|
||||
});
|
||||
dispatch(updateStatus(status));
|
||||
dispatch({
|
||||
type: GET_TUTORIALS,
|
||||
payload: tutorials,
|
||||
});
|
||||
dispatch({ type: TUTORIAL_PROGRESS });
|
||||
dispatch(returnSuccess(res.data.message, res.status));
|
||||
}
|
||||
);
|
||||
axios.put(`${process.env.REACT_APP_BLOCKLY_API}/user/badge/${id}`, {}, config)
|
||||
.then(res => {
|
||||
res.config.success(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
if (err.response) {
|
||||
dispatch(
|
||||
returnErrors(
|
||||
err.response.data.message,
|
||||
err.response.status,
|
||||
"GET_TUTORIALS_FAIL"
|
||||
)
|
||||
);
|
||||
.catch(err => {
|
||||
if(err.response && err.response.status !== 401){
|
||||
err.config.error(err);
|
||||
}
|
||||
dispatch({ type: TUTORIAL_PROGRESS });
|
||||
});
|
||||
};
|
||||
|
||||
export const updateStatus = (status) => (dispatch, getState) => {
|
||||
if(getState().auth.isAuthenticated){
|
||||
// update user account in database - sync with redux store
|
||||
axios
|
||||
.put(`${process.env.REACT_APP_BLOCKLY_API}/user/status`, {
|
||||
status: status,
|
||||
axios.put(`${process.env.REACT_APP_BLOCKLY_API}/user/status`, {status: status})
|
||||
.then(res => {
|
||||
// dispatch(returnSuccess(badge, res.status, 'UPDATE_STATUS_SUCCESS'));
|
||||
})
|
||||
.then((res) => {})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
if(err.response){
|
||||
// dispatch(returnErrors(err.response.data.message, err.response.status, 'UPDATE_STATUS_FAIL'));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// update locale storage - sync with redux store
|
||||
window.localStorage.setItem("status", JSON.stringify(status));
|
||||
window.localStorage.setItem('status', JSON.stringify(status));
|
||||
}
|
||||
};
|
||||
|
||||
@ -178,77 +111,66 @@ export const deleteTutorial = (id) => (dispatch, getState) => {
|
||||
var tutorial = getState().tutorial;
|
||||
var id = getState().builder.id;
|
||||
const config = {
|
||||
success: (res) => {
|
||||
success: res => {
|
||||
var tutorials = tutorial.tutorials;
|
||||
var index = tutorials.findIndex((res) => res._id === id);
|
||||
tutorials.splice(index, 1);
|
||||
var index = tutorials.findIndex(res => res._id === id);
|
||||
tutorials.splice(index, 1)
|
||||
dispatch({
|
||||
type: GET_TUTORIALS,
|
||||
payload: tutorials,
|
||||
payload: tutorials
|
||||
});
|
||||
dispatch(
|
||||
returnSuccess(res.data.message, res.status, "TUTORIAL_DELETE_SUCCESS")
|
||||
);
|
||||
},
|
||||
error: (err) => {
|
||||
dispatch(
|
||||
returnErrors(
|
||||
err.response.data.message,
|
||||
err.response.status,
|
||||
"TUTORIAL_DELETE_FAIL"
|
||||
)
|
||||
);
|
||||
dispatch(returnSuccess(res.data.message, res.status, 'TUTORIAL_DELETE_SUCCESS'));
|
||||
},
|
||||
error: err => {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'TUTORIAL_DELETE_FAIL'));
|
||||
}
|
||||
};
|
||||
axios
|
||||
.delete(`${process.env.REACT_APP_BLOCKLY_API}/tutorial/${id}`, config)
|
||||
.then((res) => {
|
||||
axios.delete(`${process.env.REACT_APP_BLOCKLY_API}/tutorial/${id}`, config)
|
||||
.then(res => {
|
||||
res.config.success(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
if(err.response && err.response.status !== 401){
|
||||
err.config.error(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
export const resetTutorial = () => (dispatch) => {
|
||||
dispatch({
|
||||
type: GET_TUTORIALS,
|
||||
payload: [],
|
||||
payload: []
|
||||
});
|
||||
dispatch({
|
||||
type: TUTORIAL_STEP,
|
||||
payload: 0,
|
||||
payload: 0
|
||||
});
|
||||
};
|
||||
|
||||
export const tutorialChange = () => (dispatch) => {
|
||||
dispatch({
|
||||
type: TUTORIAL_CHANGE,
|
||||
type: TUTORIAL_CHANGE
|
||||
});
|
||||
};
|
||||
|
||||
export const tutorialCheck = (status, step) => (dispatch, getState) => {
|
||||
var tutorialsStatus = getState().tutorial.status;
|
||||
var id = getState().tutorial.tutorials[0]._id;
|
||||
var tutorialsStatusIndex = tutorialsStatus.findIndex(
|
||||
(tutorialStatus) => tutorialStatus._id === id
|
||||
);
|
||||
var tasksIndex = tutorialsStatus[tutorialsStatusIndex].tasks.findIndex(
|
||||
(task) => task._id === step._id
|
||||
);
|
||||
var tutorialsStatusIndex = tutorialsStatus.findIndex(tutorialStatus => tutorialStatus._id === id);
|
||||
var tasksIndex = tutorialsStatus[tutorialsStatusIndex].tasks.findIndex(task => task._id === step._id);
|
||||
tutorialsStatus[tutorialsStatusIndex].tasks[tasksIndex] = {
|
||||
...tutorialsStatus[tutorialsStatusIndex].tasks[tasksIndex],
|
||||
type: status,
|
||||
type: status
|
||||
};
|
||||
dispatch({
|
||||
type: status === "success" ? TUTORIAL_SUCCESS : TUTORIAL_ERROR,
|
||||
payload: tutorialsStatus,
|
||||
type: status === 'success' ? TUTORIAL_SUCCESS : TUTORIAL_ERROR,
|
||||
payload: tutorialsStatus
|
||||
});
|
||||
console.log('drei');
|
||||
dispatch(updateStatus(tutorialsStatus));
|
||||
dispatch(tutorialChange());
|
||||
dispatch(returnSuccess("", "", "TUTORIAL_CHECK_SUCCESS"));
|
||||
dispatch(returnSuccess('', '', 'TUTORIAL_CHECK_SUCCESS'));
|
||||
};
|
||||
|
||||
export const storeTutorialXml = (code) => (dispatch, getState) => {
|
||||
@ -257,21 +179,17 @@ export const storeTutorialXml = (code) => (dispatch, getState) => {
|
||||
var id = tutorial._id;
|
||||
var activeStep = getState().tutorial.activeStep;
|
||||
var steps = tutorial.steps;
|
||||
if (steps && steps[activeStep].type === "task") {
|
||||
if (steps && steps[activeStep].type === 'task') {
|
||||
var tutorialsStatus = getState().tutorial.status;
|
||||
var tutorialsStatusIndex = tutorialsStatus.findIndex(
|
||||
(tutorialStatus) => tutorialStatus._id === id
|
||||
);
|
||||
var tasksIndex = tutorialsStatus[tutorialsStatusIndex].tasks.findIndex(
|
||||
(task) => task._id === steps[activeStep]._id
|
||||
);
|
||||
var tutorialsStatusIndex = tutorialsStatus.findIndex(tutorialStatus => tutorialStatus._id === id);
|
||||
var tasksIndex = tutorialsStatus[tutorialsStatusIndex].tasks.findIndex(task => task._id === steps[activeStep]._id);
|
||||
tutorialsStatus[tutorialsStatusIndex].tasks[tasksIndex] = {
|
||||
...tutorialsStatus[tutorialsStatusIndex].tasks[tasksIndex],
|
||||
xml: code,
|
||||
xml: code
|
||||
};
|
||||
dispatch({
|
||||
type: TUTORIAL_XML,
|
||||
payload: tutorialsStatus,
|
||||
payload: tutorialsStatus
|
||||
});
|
||||
dispatch(updateStatus(tutorialsStatus));
|
||||
}
|
||||
@ -281,45 +199,38 @@ export const storeTutorialXml = (code) => (dispatch, getState) => {
|
||||
export const tutorialStep = (step) => (dispatch) => {
|
||||
dispatch({
|
||||
type: TUTORIAL_STEP,
|
||||
payload: step,
|
||||
payload: step
|
||||
});
|
||||
};
|
||||
|
||||
const existingTutorials = (tutorials, status) =>
|
||||
new Promise(function (resolve, reject) {
|
||||
|
||||
const existingTutorials = (tutorials, status) => new Promise(function (resolve, reject) {
|
||||
var newstatus;
|
||||
new Promise(function (resolve, reject) {
|
||||
var existingTutorialIds = tutorials.map((tutorial, i) => {
|
||||
existingTutorial(tutorial, status).then((status) => {
|
||||
existingTutorial(tutorial, status).then(status => {
|
||||
newstatus = status;
|
||||
});
|
||||
return tutorial._id;
|
||||
});
|
||||
resolve(existingTutorialIds);
|
||||
}).then((existingTutorialIds) => {
|
||||
resolve(existingTutorialIds)
|
||||
}).then(existingTutorialIds => {
|
||||
// deleting old tutorials which do not longer exist
|
||||
if (existingTutorialIds.length > 0) {
|
||||
status = newstatus.filter(
|
||||
(status) => existingTutorialIds.indexOf(status._id) > -1
|
||||
);
|
||||
status = newstatus.filter(status => existingTutorialIds.indexOf(status._id) > -1);
|
||||
}
|
||||
resolve(status);
|
||||
});
|
||||
});
|
||||
|
||||
const existingTutorial = (tutorial, status) =>
|
||||
new Promise(function (resolve, reject) {
|
||||
const existingTutorial = (tutorial, status) => new Promise(function(resolve, reject){
|
||||
var tutorialsId = tutorial._id;
|
||||
var statusIndex = status.findIndex((status) => status._id === tutorialsId);
|
||||
var statusIndex = status.findIndex(status => status._id === tutorialsId);
|
||||
if (statusIndex > -1) {
|
||||
var tasks = tutorial.steps.filter((step) => step.type === "task");
|
||||
var tasks = tutorial.steps.filter(step => step.type === 'task');
|
||||
var existingTaskIds = tasks.map((task, j) => {
|
||||
var tasksId = task._id;
|
||||
if (
|
||||
status[statusIndex].tasks.findIndex(
|
||||
(task) => task._id === tasksId
|
||||
) === -1
|
||||
) {
|
||||
if (status[statusIndex].tasks.findIndex(task => task._id === tasksId) === -1) {
|
||||
// task does not exist
|
||||
status[statusIndex].tasks.push({ _id: tasksId });
|
||||
}
|
||||
@ -327,19 +238,11 @@ const existingTutorial = (tutorial, status) =>
|
||||
});
|
||||
// deleting old tasks which do not longer exist
|
||||
if (existingTaskIds.length > 0) {
|
||||
status[statusIndex].tasks = status[statusIndex].tasks.filter(
|
||||
(task) => existingTaskIds.indexOf(task._id) > -1
|
||||
);
|
||||
status[statusIndex].tasks = status[statusIndex].tasks.filter(task => existingTaskIds.indexOf(task._id) > -1);
|
||||
}
|
||||
} else {
|
||||
status.push({
|
||||
_id: tutorialsId,
|
||||
tasks: tutorial.steps
|
||||
.filter((step) => step.type === "task")
|
||||
.map((task) => {
|
||||
return { _id: task._id };
|
||||
}),
|
||||
});
|
||||
}
|
||||
else {
|
||||
status.push({ _id: tutorialsId, tasks: tutorial.steps.filter(step => step.type === 'task').map(task => { return { _id: task._id }; }) });
|
||||
}
|
||||
resolve(status);
|
||||
});
|
||||
|
||||
@ -1,63 +1,24 @@
|
||||
import {
|
||||
PROGRESS,
|
||||
JSON_STRING,
|
||||
BUILDER_CHANGE,
|
||||
BUILDER_ERROR,
|
||||
BUILDER_TITLE,
|
||||
BUILDER_PUBLIC,
|
||||
BUILDER_DIFFICULTY,
|
||||
BUILDER_REVIEW,
|
||||
BUILDER_ID,
|
||||
BUILDER_ADD_STEP,
|
||||
BUILDER_DELETE_STEP,
|
||||
BUILDER_CHANGE_STEP,
|
||||
BUILDER_CHANGE_ORDER,
|
||||
BUILDER_DELETE_PROPERTY,
|
||||
} from "./types";
|
||||
import { PROGRESS, JSON_STRING, BUILDER_CHANGE, BUILDER_ERROR, BUILDER_TITLE, BUILDER_ID, BUILDER_BADGE, BUILDER_ADD_STEP, BUILDER_DELETE_STEP, BUILDER_CHANGE_STEP, BUILDER_CHANGE_ORDER, BUILDER_DELETE_PROPERTY } from './types';
|
||||
|
||||
import data from "../data/hardware.json";
|
||||
import data from '../data/hardware.json';
|
||||
|
||||
export const changeTutorialBuilder = () => (dispatch) => {
|
||||
dispatch({
|
||||
type: BUILDER_CHANGE,
|
||||
type: BUILDER_CHANGE
|
||||
});
|
||||
};
|
||||
|
||||
export const jsonString = (json) => (dispatch) => {
|
||||
dispatch({
|
||||
type: JSON_STRING,
|
||||
payload: json,
|
||||
payload: json
|
||||
});
|
||||
};
|
||||
|
||||
export const tutorialTitle = (title) => (dispatch) => {
|
||||
dispatch({
|
||||
type: BUILDER_TITLE,
|
||||
payload: title,
|
||||
});
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
|
||||
export const tutorialPublic = (pub) => (dispatch) => {
|
||||
dispatch({
|
||||
type: BUILDER_PUBLIC,
|
||||
payload: pub,
|
||||
});
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
|
||||
export const tutorialDifficulty = (difficulty) => (dispatch) => {
|
||||
dispatch({
|
||||
type: BUILDER_DIFFICULTY,
|
||||
payload: difficulty,
|
||||
});
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
|
||||
export const tutorialReview = (review) => (dispatch) => {
|
||||
dispatch({
|
||||
type: BUILDER_REVIEW,
|
||||
payload: review,
|
||||
payload: title
|
||||
});
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
@ -65,7 +26,7 @@ export const tutorialReview = (review) => (dispatch) => {
|
||||
export const tutorialSteps = (steps) => (dispatch) => {
|
||||
dispatch({
|
||||
type: BUILDER_ADD_STEP,
|
||||
payload: steps,
|
||||
payload: steps
|
||||
});
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
@ -73,7 +34,15 @@ export const tutorialSteps = (steps) => (dispatch) => {
|
||||
export const tutorialId = (id) => (dispatch) => {
|
||||
dispatch({
|
||||
type: BUILDER_ID,
|
||||
payload: id,
|
||||
payload: id
|
||||
});
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
|
||||
export const tutorialBadge = (badge) => (dispatch) => {
|
||||
dispatch({
|
||||
type: BUILDER_BADGE,
|
||||
payload: badge
|
||||
});
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
@ -82,14 +51,14 @@ export const addStep = (index) => (dispatch, getState) => {
|
||||
var steps = getState().builder.steps;
|
||||
var step = {
|
||||
id: index + 1,
|
||||
type: "instruction",
|
||||
headline: "",
|
||||
text: "",
|
||||
type: 'instruction',
|
||||
headline: '',
|
||||
text: ''
|
||||
};
|
||||
steps.splice(index, 0, step);
|
||||
dispatch({
|
||||
type: BUILDER_ADD_STEP,
|
||||
payload: steps,
|
||||
payload: steps
|
||||
});
|
||||
dispatch(addErrorStep(index));
|
||||
dispatch(changeTutorialBuilder());
|
||||
@ -100,7 +69,7 @@ export const addErrorStep = (index) => (dispatch, getState) => {
|
||||
error.steps.splice(index, 0, {});
|
||||
dispatch({
|
||||
type: BUILDER_ERROR,
|
||||
payload: error,
|
||||
payload: error
|
||||
});
|
||||
};
|
||||
|
||||
@ -109,7 +78,7 @@ export const removeStep = (index) => (dispatch, getState) => {
|
||||
steps.splice(index, 1);
|
||||
dispatch({
|
||||
type: BUILDER_DELETE_STEP,
|
||||
payload: steps,
|
||||
payload: steps
|
||||
});
|
||||
dispatch(removeErrorStep(index));
|
||||
dispatch(changeTutorialBuilder());
|
||||
@ -120,12 +89,11 @@ export const removeErrorStep = (index) => (dispatch, getState) => {
|
||||
error.steps.splice(index, 1);
|
||||
dispatch({
|
||||
type: BUILDER_ERROR,
|
||||
payload: error,
|
||||
payload: error
|
||||
});
|
||||
};
|
||||
|
||||
export const changeContent =
|
||||
(content, index, property1, property2) => (dispatch, getState) => {
|
||||
export const changeContent = (content, index, property1, property2) => (dispatch, getState) => {
|
||||
var steps = getState().builder.steps;
|
||||
var step = steps[index];
|
||||
if (property2) {
|
||||
@ -139,13 +107,12 @@ export const changeContent =
|
||||
}
|
||||
dispatch({
|
||||
type: BUILDER_CHANGE_STEP,
|
||||
payload: steps,
|
||||
payload: steps
|
||||
});
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
|
||||
export const deleteProperty =
|
||||
(index, property1, property2) => (dispatch, getState) => {
|
||||
export const deleteProperty = (index, property1, property2) => (dispatch, getState) => {
|
||||
var steps = getState().builder.steps;
|
||||
var step = steps[index];
|
||||
if (property2) {
|
||||
@ -157,7 +124,7 @@ export const deleteProperty =
|
||||
}
|
||||
dispatch({
|
||||
type: BUILDER_DELETE_PROPERTY,
|
||||
payload: steps,
|
||||
payload: steps
|
||||
});
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
@ -169,21 +136,20 @@ export const changeStepIndex = (fromIndex, toIndex) => (dispatch, getState) => {
|
||||
steps.splice(toIndex, 0, step);
|
||||
dispatch({
|
||||
type: BUILDER_CHANGE_ORDER,
|
||||
payload: steps,
|
||||
payload: steps
|
||||
});
|
||||
dispatch(changeErrorStepIndex(fromIndex, toIndex));
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
|
||||
export const changeErrorStepIndex =
|
||||
(fromIndex, toIndex) => (dispatch, getState) => {
|
||||
export const changeErrorStepIndex = (fromIndex, toIndex) => (dispatch, getState) => {
|
||||
var error = getState().builder.error;
|
||||
var errorStep = error.steps[fromIndex];
|
||||
error.steps.splice(fromIndex, 1);
|
||||
error.steps.splice(toIndex, 0, errorStep);
|
||||
dispatch({
|
||||
type: BUILDER_ERROR,
|
||||
payload: error,
|
||||
payload: error
|
||||
});
|
||||
};
|
||||
|
||||
@ -191,12 +157,13 @@ export const setError = (index, property) => (dispatch, getState) => {
|
||||
var error = getState().builder.error;
|
||||
if (index !== undefined) {
|
||||
error.steps[index][property] = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
error[property] = true;
|
||||
}
|
||||
dispatch({
|
||||
type: BUILDER_ERROR,
|
||||
payload: error,
|
||||
payload: error
|
||||
});
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
@ -205,12 +172,13 @@ export const deleteError = (index, property) => (dispatch, getState) => {
|
||||
var error = getState().builder.error;
|
||||
if (index !== undefined) {
|
||||
delete error.steps[index][property];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
delete error[property];
|
||||
}
|
||||
dispatch({
|
||||
type: BUILDER_ERROR,
|
||||
payload: error,
|
||||
payload: error
|
||||
});
|
||||
dispatch(changeTutorialBuilder());
|
||||
};
|
||||
@ -220,11 +188,11 @@ export const setSubmitError = () => (dispatch, getState) => {
|
||||
// if(builder.id === undefined || builder.id === ''){
|
||||
// dispatch(setError(undefined, 'id'));
|
||||
// }
|
||||
if (builder.title === "") {
|
||||
dispatch(setError(undefined, "title"));
|
||||
if (builder.title === '') {
|
||||
dispatch(setError(undefined, 'title'));
|
||||
}
|
||||
if (builder.title === null) {
|
||||
dispatch(setError(undefined, "title"));
|
||||
dispatch(setError(undefined, 'badge'));
|
||||
}
|
||||
var type = builder.steps.map((step, i) => {
|
||||
// media and xml are directly checked for errors in their components and
|
||||
@ -232,82 +200,76 @@ export const setSubmitError = () => (dispatch, getState) => {
|
||||
step.id = i + 1;
|
||||
if (i === 0) {
|
||||
if (step.requirements && step.requirements.length > 0) {
|
||||
var requirements = step.requirements.filter((requirement) =>
|
||||
/^[0-9a-fA-F]{24}$/.test(requirement)
|
||||
);
|
||||
var requirements = step.requirements.filter(requirement => /^[0-9a-fA-F]{24}$/.test(requirement));
|
||||
if (requirements.length < step.requirements.length) {
|
||||
dispatch(changeContent(requirements, i, "requirements"));
|
||||
dispatch(changeContent(requirements, i, 'requirements'));
|
||||
}
|
||||
}
|
||||
if (step.hardware === undefined || step.hardware.length < 1) {
|
||||
dispatch(setError(i, "hardware"));
|
||||
} else {
|
||||
var hardwareIds = data.map((hardware) => hardware.id);
|
||||
var hardware = step.hardware.filter((hardware) =>
|
||||
hardwareIds.includes(hardware)
|
||||
);
|
||||
dispatch(setError(i, 'hardware'));
|
||||
}
|
||||
else {
|
||||
var hardwareIds = data.map(hardware => hardware.id);
|
||||
var hardware = step.hardware.filter(hardware => hardwareIds.includes(hardware));
|
||||
if (hardware.length < step.hardware.length) {
|
||||
dispatch(changeContent(hardware, i, "hardware"));
|
||||
dispatch(changeContent(hardware, i, 'hardware'));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (step.headline === undefined || step.headline === "") {
|
||||
dispatch(setError(i, "headline"));
|
||||
if (step.headline === undefined || step.headline === '') {
|
||||
dispatch(setError(i, 'headline'));
|
||||
}
|
||||
if (step.text === undefined || step.text === "") {
|
||||
dispatch(setError(i, "text"));
|
||||
if (step.text === undefined || step.text === '') {
|
||||
dispatch(setError(i, 'text'));
|
||||
}
|
||||
return step.type;
|
||||
});
|
||||
if (
|
||||
!(
|
||||
type.filter((item) => item === "task").length > 0 &&
|
||||
type.filter((item) => item === "instruction").length > 0
|
||||
)
|
||||
) {
|
||||
dispatch(setError(undefined, "type"));
|
||||
if (!(type.filter(item => item === 'task').length > 0 && type.filter(item => item === 'instruction').length > 0)) {
|
||||
dispatch(setError(undefined, 'type'));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const checkError = () => (dispatch, getState) => {
|
||||
dispatch(setSubmitError());
|
||||
var error = getState().builder.error;
|
||||
if (error.id || error.title || error.type) {
|
||||
if (error.id || error.title || error.badge ||error.type) {
|
||||
return true;
|
||||
}
|
||||
for (var i = 0; i < error.steps.length; i++) {
|
||||
if (Object.keys(error.steps[i]).length > 0) {
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
export const progress = (inProgress) => (dispatch) => {
|
||||
dispatch({
|
||||
type: PROGRESS,
|
||||
payload: inProgress,
|
||||
});
|
||||
payload: inProgress
|
||||
})
|
||||
};
|
||||
|
||||
export const resetTutorial = () => (dispatch, getState) => {
|
||||
dispatch(jsonString(""));
|
||||
dispatch(tutorialTitle(""));
|
||||
dispatch(jsonString(''));
|
||||
dispatch(tutorialTitle(''));
|
||||
dispatch(tutorialBadge(undefined));
|
||||
var steps = [
|
||||
{
|
||||
type: "instruction",
|
||||
headline: "",
|
||||
text: "",
|
||||
type: 'instruction',
|
||||
headline: '',
|
||||
text: '',
|
||||
hardware: [],
|
||||
requirements: [],
|
||||
},
|
||||
requirements: []
|
||||
}
|
||||
];
|
||||
dispatch(tutorialSteps(steps));
|
||||
dispatch({
|
||||
type: BUILDER_ERROR,
|
||||
payload: {
|
||||
steps: [{}],
|
||||
},
|
||||
steps: [{}]
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -316,10 +278,8 @@ export const readJSON = (json) => (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: BUILDER_ERROR,
|
||||
payload: {
|
||||
steps: json.steps.map(() => {
|
||||
return {};
|
||||
}),
|
||||
},
|
||||
steps: json.steps.map(() => { return {}; })
|
||||
}
|
||||
});
|
||||
// accept only valid attributes
|
||||
var steps = json.steps.map((step, i) => {
|
||||
@ -327,7 +287,7 @@ export const readJSON = (json) => (dispatch, getState) => {
|
||||
_id: step._id,
|
||||
type: step.type,
|
||||
headline: step.headline,
|
||||
text: step.text,
|
||||
text: step.text
|
||||
};
|
||||
if (i === 0) {
|
||||
object.hardware = step.hardware;
|
||||
@ -336,18 +296,19 @@ export const readJSON = (json) => (dispatch, getState) => {
|
||||
if (step.xml) {
|
||||
object.xml = step.xml;
|
||||
}
|
||||
if (step.media && step.type === "instruction") {
|
||||
if (step.media && step.type === 'instruction') {
|
||||
object.media = {};
|
||||
if (step.media.picture) {
|
||||
object.media.picture = step.media.picture;
|
||||
} else if (step.media.youtube) {
|
||||
}
|
||||
else if (step.media.youtube) {
|
||||
object.media.youtube = step.media.youtube;
|
||||
}
|
||||
}
|
||||
return object;
|
||||
});
|
||||
dispatch(tutorialTitle(json.title));
|
||||
dispatch(tutorialDifficulty(json.difficulty));
|
||||
dispatch(tutorialBadge(json.badge));
|
||||
dispatch(tutorialSteps(steps));
|
||||
dispatch(setSubmitError());
|
||||
dispatch(progress(false));
|
||||
|
||||
@ -1,68 +1,65 @@
|
||||
// authentication
|
||||
export const USER_LOADING = "USER_LOADING";
|
||||
export const USER_LOADED = "USER_LOADED";
|
||||
export const AUTH_ERROR = "AUTH_ERROR";
|
||||
export const LOGIN_SUCCESS = "LOGIN_SUCCESS";
|
||||
export const LOGIN_FAIL = "LOGIN_FAIL";
|
||||
export const LOGOUT_SUCCESS = "LOGOUT_SUCCESS";
|
||||
export const LOGOUT_FAIL = "LOGOUT_FAIL";
|
||||
export const REFRESH_TOKEN_FAIL = "REFRESH_TOKEN_FAIL";
|
||||
export const REFRESH_TOKEN_SUCCESS = "REFRESH_TOKEN_SUCCESS";
|
||||
export const USER_LOADING = 'USER_LOADING';
|
||||
export const USER_LOADED = 'USER_LOADED';
|
||||
export const AUTH_ERROR = 'AUTH_ERROR';
|
||||
export const LOGIN_SUCCESS = 'LOGIN_SUCCESS';
|
||||
export const LOGIN_FAIL = 'LOGIN_FAIL';
|
||||
export const LOGOUT_SUCCESS = 'LOGOUT_SUCCESS';
|
||||
export const LOGOUT_FAIL = 'LOGOUT_FAIL';
|
||||
export const REFRESH_TOKEN_FAIL = 'REFRESH_TOKEN_FAIL';
|
||||
export const REFRESH_TOKEN_SUCCESS = 'REFRESH_TOKEN_SUCCESS';
|
||||
export const MYBADGES_CONNECT = 'MYBADGES_CONNECT';
|
||||
export const MYBADGES_DISCONNECT = 'MYBADGES_DISCONNECT';
|
||||
|
||||
export const NEW_CODE = "NEW_CODE";
|
||||
export const CHANGE_WORKSPACE = "CHANGE_WORKSPACE";
|
||||
export const CREATE_BLOCK = "CREATE_BLOCK";
|
||||
export const MOVE_BLOCK = "MOVE_BLOCK";
|
||||
export const CHANGE_BLOCK = "CHANGE_BLOCK";
|
||||
export const DELETE_BLOCK = "DELETE_BLOCK";
|
||||
export const CLEAR_STATS = "CLEAR_STATS";
|
||||
export const NAME = "NAME";
|
||||
export const NEW_CODE = 'NEW_CODE';
|
||||
export const CHANGE_WORKSPACE = 'CHANGE_WORKSPACE';
|
||||
export const CREATE_BLOCK = 'CREATE_BLOCK';
|
||||
export const MOVE_BLOCK = 'MOVE_BLOCK';
|
||||
export const CHANGE_BLOCK = 'CHANGE_BLOCK';
|
||||
export const DELETE_BLOCK = 'DELETE_BLOCK';
|
||||
export const CLEAR_STATS = 'CLEAR_STATS';
|
||||
export const NAME = 'NAME';
|
||||
|
||||
export const TUTORIAL_PROGRESS = "TUTORIAL_PROGRESS";
|
||||
export const GET_TUTORIAL = "GET_TUTORIAL";
|
||||
export const GET_TUTORIALS = "GET_TUTORIALS";
|
||||
export const GET_USERTUTORIALS = "GET_USERTUTORIALS";
|
||||
export const GET_STATUS = "GET_STATUS";
|
||||
export const TUTORIAL_SUCCESS = "TUTORIAL_SUCCESS";
|
||||
export const TUTORIAL_ERROR = "TUTORIAL_ERROR";
|
||||
export const TUTORIAL_CHANGE = "TUTORIAL_CHANGE";
|
||||
export const TUTORIAL_XML = "TUTORIAL_XML";
|
||||
export const TUTORIAL_ID = "TUTORIAL_ID";
|
||||
export const TUTORIAL_STEP = "TUTORIAL_STEP";
|
||||
export const JSON_STRING = "JSON_STRING";
|
||||
export const TUTORIAL_PROGRESS = 'TUTORIAL_PROGRESS';
|
||||
export const GET_TUTORIAL = 'GET_TUTORIAL';
|
||||
export const GET_TUTORIALS = 'GET_TUTORIALS';
|
||||
export const GET_STATUS = 'GET_STATUS';
|
||||
export const TUTORIAL_SUCCESS = 'TUTORIAL_SUCCESS';
|
||||
export const TUTORIAL_ERROR = 'TUTORIAL_ERROR';
|
||||
export const TUTORIAL_CHANGE = 'TUTORIAL_CHANGE';
|
||||
export const TUTORIAL_XML = 'TUTORIAL_XML';
|
||||
export const TUTORIAL_ID = 'TUTORIAL_ID';
|
||||
export const TUTORIAL_STEP = 'TUTORIAL_STEP';
|
||||
export const JSON_STRING = 'JSON_STRING';
|
||||
|
||||
export const BUILDER_CHANGE = "BUILDER_CHANGE";
|
||||
export const BUILDER_TITLE = "BUILDER_TITLE";
|
||||
export const BUILDER_DIFFICULTY = "BUILDER_DIFFICULTY";
|
||||
export const BUILDER_PUBLIC = "BUILDER_PUBLIC";
|
||||
export const BUILDER_REVIEW = "BUILDER_REVIEW";
|
||||
export const BUILDER_ID = "BUILDER_ID";
|
||||
export const BUILDER_ADD_STEP = "BUILDER_ADD_STEP";
|
||||
export const BUILDER_DELETE_STEP = "BUILDER_DELETE_STEP";
|
||||
export const BUILDER_CHANGE_STEP = "BUILDER_CHANGE_STEP";
|
||||
export const BUILDER_CHANGE_ORDER = "BUILDER_CHANGE_ORDER";
|
||||
export const BUILDER_DELETE_PROPERTY = "BUILDER_DELETE_PROPERTY";
|
||||
export const BUILDER_ERROR = "BUILDER_ERROR";
|
||||
export const PROGRESS = "PROGRESS";
|
||||
|
||||
export const VISIT = "VISIT";
|
||||
export const LANGUAGE = "LANGUAGE";
|
||||
export const PLATFORM = "PLATFORM";
|
||||
export const RENDERER = "RENDERER";
|
||||
export const SOUNDS = "SOUNDS";
|
||||
export const STATISTICS = "STATISTICS";
|
||||
export const BUILDER_CHANGE = 'BUILDER_CHANGE';
|
||||
export const BUILDER_TITLE = 'BUILDER_TITLE';
|
||||
export const BUILDER_BADGE = 'BUILDER_BADGE';
|
||||
export const BUILDER_ID = 'BUILDER_ID';
|
||||
export const BUILDER_ADD_STEP = 'BUILDER_ADD_STEP';
|
||||
export const BUILDER_DELETE_STEP = 'BUILDER_DELETE_STEP';
|
||||
export const BUILDER_CHANGE_STEP = 'BUILDER_CHANGE_STEP';
|
||||
export const BUILDER_CHANGE_ORDER = 'BUILDER_CHANGE_ORDER';
|
||||
export const BUILDER_DELETE_PROPERTY = 'BUILDER_DELETE_PROPERTY';
|
||||
export const BUILDER_ERROR = 'BUILDER_ERROR';
|
||||
export const PROGRESS = 'PROGRESS';
|
||||
|
||||
|
||||
export const VISIT = 'VISIT';
|
||||
export const LANGUAGE = 'LANGUAGE';
|
||||
export const RENDERER = 'RENDERER';
|
||||
export const STATISTICS = 'STATISTICS';
|
||||
|
||||
// messages
|
||||
export const GET_ERRORS = "GET_ERRORS";
|
||||
export const GET_SUCCESS = "GET_SUCCESS";
|
||||
export const CLEAR_MESSAGES = "CLEAR_MESSAGES";
|
||||
export const GET_ERRORS = 'GET_ERRORS';
|
||||
export const GET_SUCCESS = 'GET_SUCCESS';
|
||||
export const CLEAR_MESSAGES = 'CLEAR_MESSAGES';
|
||||
|
||||
|
||||
// projects: share, gallery, project
|
||||
export const PROJECT_PROGRESS = "PROJECT_PROGRESS";
|
||||
export const GET_PROJECT = "GET_PROJECT";
|
||||
export const GET_PROJECTS = "GET_PROJECTS";
|
||||
export const PROJECT_TYPE = "PROJECT_TYPE";
|
||||
export const PROJECT_DESCRIPTION = "PROJECT_DESCRIPTION";
|
||||
|
||||
//board
|
||||
export const BOARD = "BOARD";
|
||||
export const PROJECT_PROGRESS = 'PROJECT_PROGRESS';
|
||||
export const GET_PROJECT = 'GET_PROJECT';
|
||||
export const GET_PROJECTS = 'GET_PROJECTS';
|
||||
export const PROJECT_TYPE = 'PROJECT_TYPE';
|
||||
export const PROJECT_DESCRIPTION = 'PROJECT_DESCRIPTION';
|
||||
|
||||
@ -16,19 +16,14 @@ export const onChangeCode = () => (dispatch, getState) => {
|
||||
code.arduino = Blockly.Arduino.workspaceToCode(workspace);
|
||||
var xmlDom = Blockly.Xml.workspaceToDom(workspace);
|
||||
code.xml = Blockly.Xml.domToPrettyText(xmlDom);
|
||||
var selectedBlock = Blockly.getSelected();
|
||||
var selectedBlock = Blockly.selected
|
||||
console.log(selectedBlock)
|
||||
if (selectedBlock !== null) {
|
||||
code.helpurl = selectedBlock.helpUrl
|
||||
code.tooltip = selectedBlock.tooltip
|
||||
if (selectedBlock.data) {
|
||||
code.data = selectedBlock.data
|
||||
} else {
|
||||
code.data = null
|
||||
}
|
||||
} else if (selectedBlock === null) {
|
||||
code.tooltip = Blockly.Msg.tooltip_hint
|
||||
code.helpurl = ''
|
||||
code.data = null
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,29 +1,34 @@
|
||||
import React, { Component } from "react";
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import withStyles from '@mui/styles/withStyles';
|
||||
import { alpha } from "@mui/material/styles";
|
||||
import { withStyles } from '@material-ui/core/styles';
|
||||
import { fade } from '@material-ui/core/styles/colorManipulator';
|
||||
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
|
||||
const styles = (theme) => ({
|
||||
alert: {
|
||||
marginBottom: "20px",
|
||||
marginBottom: '20px',
|
||||
border: `1px solid ${theme.palette.primary.main}`,
|
||||
padding: "10px 20px",
|
||||
borderRadius: "4px",
|
||||
background: alpha(theme.palette.primary.main, 0.3),
|
||||
color: "rgb(70,70,70)",
|
||||
},
|
||||
padding: '10px 20px',
|
||||
borderRadius: '4px',
|
||||
background: fade(theme.palette.primary.main, 0.3),
|
||||
color: 'rgb(70,70,70)'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export class Alert extends Component {
|
||||
|
||||
render(){
|
||||
return(
|
||||
<div className={this.props.classes.alert}>
|
||||
<Typography>{this.props.children}</Typography>
|
||||
<Typography>
|
||||
{this.props.children}
|
||||
</Typography>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default withStyles(styles, { withTheme: true })(Alert);
|
||||
|
||||
@ -21,20 +21,18 @@
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
|
||||
import Blockly from 'blockly/core';
|
||||
import 'blockly/blocks';
|
||||
import Toolbox from './toolbox/Toolbox';
|
||||
|
||||
import { Card } from '@material-ui/core';
|
||||
|
||||
import Blockly from "blockly/core";
|
||||
import "blockly/blocks";
|
||||
import Toolbox from "./toolbox/Toolbox";
|
||||
|
||||
import { Card } from "@mui/material";
|
||||
import {
|
||||
ScrollOptions,
|
||||
ScrollBlockDragger,
|
||||
ScrollMetricsManager,
|
||||
} from "@blockly/plugin-scroll-options";
|
||||
|
||||
class BlocklyComponent extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.blocklyDiv = React.createRef();
|
||||
@ -44,25 +42,17 @@ class BlocklyComponent extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
const { initialXml, children, ...rest } = this.props;
|
||||
this.primaryWorkspace = Blockly.inject(this.blocklyDiv.current, {
|
||||
this.primaryWorkspace = Blockly.inject(
|
||||
this.blocklyDiv.current,
|
||||
{
|
||||
toolbox: this.toolbox.current,
|
||||
plugins: {
|
||||
// These are both required.
|
||||
blockDragger: ScrollBlockDragger,
|
||||
metricsManager: ScrollMetricsManager,
|
||||
...rest
|
||||
},
|
||||
...rest,
|
||||
});
|
||||
// Initialize plugin.
|
||||
|
||||
this.setState({ workspace: this.primaryWorkspace });
|
||||
const plugin = new ScrollOptions(this.workspace);
|
||||
plugin.init({ enableWheelScroll: true, enableEdgeScroll: false });
|
||||
if (initialXml) {
|
||||
Blockly.Xml.domToWorkspace(
|
||||
Blockly.Xml.textToDom(initialXml),
|
||||
this.primaryWorkspace
|
||||
);
|
||||
this.setState({ workspace: this.primaryWorkspace })
|
||||
|
||||
if (initialXml) {
|
||||
Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(initialXml), this.primaryWorkspace);
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,23 +61,14 @@ class BlocklyComponent extends React.Component {
|
||||
}
|
||||
|
||||
setXml(xml) {
|
||||
Blockly.Xml.domToWorkspace(
|
||||
Blockly.Xml.textToDom(xml),
|
||||
this.primaryWorkspace
|
||||
);
|
||||
Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(xml), this.primaryWorkspace);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Card
|
||||
ref={this.blocklyDiv}
|
||||
id="blocklyDiv"
|
||||
style={this.props.style ? this.props.style : {}}
|
||||
/>
|
||||
return <React.Fragment>
|
||||
<Card ref={this.blocklyDiv} id="blocklyDiv" style={this.props.style ? this.props.style : {}} />
|
||||
<Toolbox toolbox={this.toolbox} workspace={this.state.workspace} />
|
||||
</React.Fragment>
|
||||
);
|
||||
</React.Fragment>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
import React, { Component } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { connect } from "react-redux";
|
||||
import { onChangeWorkspace, clearStats } from "../../actions/workspaceActions";
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { onChangeWorkspace, clearStats } from '../../actions/workspaceActions';
|
||||
|
||||
import BlocklyComponent from "./BlocklyComponent";
|
||||
import BlocklySvg from "./BlocklySvg";
|
||||
import BlocklyComponent from './BlocklyComponent';
|
||||
import BlocklySvg from './BlocklySvg';
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
import './blocks/index';
|
||||
import './generator/index';
|
||||
|
||||
import { initialXml } from './initialXml.js';
|
||||
|
||||
import * as Blockly from "blockly/core";
|
||||
import "./blocks/index";
|
||||
import "./generator/index";
|
||||
import { ZoomToFitControl } from "@blockly/zoom-to-fit";
|
||||
import { initialXml } from "./initialXml.js";
|
||||
import { getMaxInstances } from "./helpers/maxInstances";
|
||||
import { Backpack } from "@blockly/workspace-backpack";
|
||||
|
||||
class BlocklyWindow extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.simpleWorkspace = React.createRef();
|
||||
@ -26,7 +26,6 @@ class BlocklyWindow extends Component {
|
||||
this.props.clearStats();
|
||||
workspace.addChangeListener((event) => {
|
||||
this.props.onChangeWorkspace(event);
|
||||
|
||||
// switch on that a block is displayed disabled or not depending on whether it is correctly connected
|
||||
// for SVG display, a deactivated block in the display is undesirable
|
||||
if (this.props.blockDisabled) {
|
||||
@ -34,26 +33,11 @@ class BlocklyWindow extends Component {
|
||||
}
|
||||
});
|
||||
Blockly.svgResize(workspace);
|
||||
const zoomToFit = new ZoomToFitControl(workspace);
|
||||
zoomToFit.init();
|
||||
// Initialize plugin.
|
||||
const backpack = new Backpack(workspace);
|
||||
backpack.init();
|
||||
}
|
||||
|
||||
componentDidUpdate(props) {
|
||||
const workspace = Blockly.getMainWorkspace();
|
||||
var xml = this.props.initialXml;
|
||||
if (props.selectedBoard !== this.props.selectedBoard) {
|
||||
xml = localStorage.getItem("autoSaveXML");
|
||||
// change board
|
||||
if(!xml) xml = initialXml;
|
||||
var xmlDom = Blockly.Xml.textToDom(xml);
|
||||
Blockly.Xml.clearWorkspaceAndLoadFromXml(xmlDom, workspace);
|
||||
// var toolbox = workspace.getToolbox();
|
||||
// workspace.updateToolbox(toolbox.toolboxDef_);
|
||||
}
|
||||
|
||||
// if svg is true, then the update process is done in the BlocklySvg component
|
||||
if (props.initialXml !== xml && !this.props.svg) {
|
||||
// guarantees that the current xml-code (this.props.initialXml) is rendered
|
||||
@ -63,93 +47,66 @@ class BlocklyWindow extends Component {
|
||||
}
|
||||
if (props.language !== this.props.language) {
|
||||
// change language
|
||||
xml = localStorage.getItem("autoSaveXML");
|
||||
if (!xml) xml = initialXml;
|
||||
xmlDom = Blockly.Xml.textToDom(xml);
|
||||
var xmlDom = Blockly.Xml.textToDom(xml);
|
||||
Blockly.Xml.clearWorkspaceAndLoadFromXml(xmlDom, workspace);
|
||||
// var toolbox = workspace.getToolbox();
|
||||
// console.log(toolbox);
|
||||
// workspace.updateToolbox(toolbox.toolboxDef_);
|
||||
}
|
||||
Blockly.svgResize(workspace);
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<BlocklyComponent
|
||||
ref={this.simpleWorkspace}
|
||||
<BlocklyComponent ref={this.simpleWorkspace}
|
||||
style={this.props.svg ? { height: 0 } : this.props.blocklyCSS}
|
||||
readOnly={
|
||||
this.props.readOnly !== undefined ? this.props.readOnly : false
|
||||
}
|
||||
trashcan={
|
||||
this.props.trashcan !== undefined ? this.props.trashcan : true
|
||||
}
|
||||
readOnly={this.props.readOnly !== undefined ? this.props.readOnly : false}
|
||||
trashcan={this.props.trashcan !== undefined ? this.props.trashcan : true}
|
||||
renderer={this.props.renderer}
|
||||
sounds={this.props.sounds}
|
||||
maxInstances={getMaxInstances()}
|
||||
zoom={{
|
||||
// https://developers.google.com/blockly/guides/configure/web/zoom
|
||||
controls:
|
||||
this.props.zoomControls !== undefined
|
||||
? this.props.zoomControls
|
||||
: true,
|
||||
zoom={{ // https://developers.google.com/blockly/guides/configure/web/zoom
|
||||
controls: this.props.zoomControls !== undefined ? this.props.zoomControls : true,
|
||||
wheel: false,
|
||||
startScale: 1,
|
||||
maxScale: 3,
|
||||
minScale: 0.3,
|
||||
scaleSpeed: 1.2,
|
||||
scaleSpeed: 1.2
|
||||
}}
|
||||
grid={
|
||||
this.props.grid !== undefined && !this.props.grid
|
||||
? {}
|
||||
: {
|
||||
// https://developers.google.com/blockly/guides/configure/web/grid
|
||||
grid={this.props.grid !== undefined && !this.props.grid ? {} :
|
||||
{ // https://developers.google.com/blockly/guides/configure/web/grid
|
||||
spacing: 20,
|
||||
length: 1,
|
||||
colour: "#4EAF47", // senseBox-green
|
||||
snap: false,
|
||||
}
|
||||
}
|
||||
media={"/media/blockly/"}
|
||||
move={
|
||||
this.props.move !== undefined && !this.props.move
|
||||
? {}
|
||||
: {
|
||||
// https://developers.google.com/blockly/guides/configure/web/move
|
||||
colour: '#4EAF47', // senseBox-green
|
||||
snap: false
|
||||
}}
|
||||
media={'/media/blockly/'}
|
||||
move={this.props.move !== undefined && !this.props.move ? {} :
|
||||
{ // https://developers.google.com/blockly/guides/configure/web/move
|
||||
scrollbars: true,
|
||||
drag: true,
|
||||
wheel: true,
|
||||
}
|
||||
}
|
||||
initialXml={
|
||||
this.props.initialXml ? this.props.initialXml : initialXml
|
||||
}
|
||||
></BlocklyComponent>
|
||||
{this.props.svg && this.props.initialXml ? (
|
||||
<BlocklySvg initialXml={this.props.initialXml} />
|
||||
) : null}
|
||||
wheel: false
|
||||
}}
|
||||
initialXml={this.props.initialXml ? this.props.initialXml : initialXml}
|
||||
>
|
||||
</BlocklyComponent >
|
||||
{this.props.svg && this.props.initialXml ? <BlocklySvg initialXml={this.props.initialXml} /> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
BlocklyWindow.propTypes = {
|
||||
onChangeWorkspace: PropTypes.func.isRequired,
|
||||
clearStats: PropTypes.func.isRequired,
|
||||
renderer: PropTypes.string.isRequired,
|
||||
sounds: PropTypes.bool.isRequired,
|
||||
language: PropTypes.string.isRequired,
|
||||
selectedBoard: PropTypes.string.isRequired,
|
||||
language: PropTypes.string.isRequired
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
const mapStateToProps = state => ({
|
||||
renderer: state.general.renderer,
|
||||
sounds: state.general.sounds,
|
||||
language: state.general.language,
|
||||
selectedBoard: state.board.board,
|
||||
language: state.general.language
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, { onChangeWorkspace, clearStats })(
|
||||
BlocklyWindow
|
||||
);
|
||||
export default connect(mapStateToProps, { onChangeWorkspace, clearStats })(BlocklyWindow);
|
||||
|
||||
@ -1,88 +0,0 @@
|
||||
import Blockly from "blockly";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Types from "../helpers/types";
|
||||
import { selectedBoard } from "../helpers/board";
|
||||
import { FieldGridDropdown } from "@blockly/field-grid-dropdown";
|
||||
|
||||
/**
|
||||
* DS18B20 Temperatursonde
|
||||
*
|
||||
*/
|
||||
Blockly.Blocks["CleVerLab_dummy1"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().cleverlab);
|
||||
this.appendDummyInput()
|
||||
.appendField("tut nichts")
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.data = {name: "empty"};
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Blockly.Blocks["CleVerLab_temperature"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().cleverlab);
|
||||
this.appendDummyInput()
|
||||
.appendField("Temperatur")
|
||||
.appendField("Digital Port:")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPorts), "DigitalPin");
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.data = {name: "ds18b20"};
|
||||
},
|
||||
};
|
||||
/**
|
||||
* PH Wert
|
||||
*
|
||||
*/
|
||||
Blockly.Blocks["CleVerLab_pH"] = {
|
||||
init: function () {
|
||||
|
||||
this.setColour(getColour().cleverlab);
|
||||
this.appendDummyInput()
|
||||
.appendField("pH Wert")
|
||||
.appendField("Digital Port:")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "DigitalPin");
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.data = {name: "phoderso"};
|
||||
},
|
||||
};
|
||||
Blockly.Blocks["CleVerLab_cali1"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField("Kalibriere pH Sensor");
|
||||
this.appendValueInput("VAR1", "Number")
|
||||
.appendField("Referenzlösung pH 4.00 =")
|
||||
.setAlign(Blockly.ALIGN_RIGHT);
|
||||
this.appendValueInput("VAR2", "Number2")
|
||||
.appendField("Referenzlösung pH 7.00 =")
|
||||
.setAlign(Blockly.ALIGN_RIGHT);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().cleverlab);
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.data = {name: "dsasda"};
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Pump
|
||||
*
|
||||
*/
|
||||
Blockly.Blocks['CleVerLab_pump'] = {
|
||||
init: function() {
|
||||
this.setColour(getColour().cleverlab);
|
||||
var dropdown = new Blockly.FieldDropdown([
|
||||
[ 'START','HIGH'],
|
||||
[ 'STOPP','LOW']
|
||||
]);
|
||||
this.appendDummyInput()
|
||||
.appendField(dropdown, "Mode")
|
||||
.appendField(" Pumpe ")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "DigitalPin");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
//this.setOutput(true, "Number");
|
||||
this.setTooltip('');
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
};
|
||||
@ -1,31 +1,24 @@
|
||||
import "./loops";
|
||||
import "./sensebox";
|
||||
import "./logic";
|
||||
import "./sensebox-sensors";
|
||||
import "./sensebox-telegram";
|
||||
import "./sensebox-osem";
|
||||
import "./sensebox-web";
|
||||
import "./sensebox-display";
|
||||
import "./sensebox-motors";
|
||||
import "./sensebox-lora";
|
||||
import "./sensebox-led";
|
||||
import "./sensebox-rtc";
|
||||
import "./sensebox-ntp";
|
||||
import "./sensebox-ble";
|
||||
import "./sensebox-sd";
|
||||
import "./mqtt";
|
||||
import "./text";
|
||||
import "./io";
|
||||
import "./audio";
|
||||
import "./math";
|
||||
import "./map";
|
||||
import "./procedures";
|
||||
import "./serial";
|
||||
import "./time";
|
||||
import "./variables";
|
||||
import "./lists";
|
||||
import "./watchdog";
|
||||
import "./webserver";
|
||||
import "./CleVerLab"
|
||||
import './loops';
|
||||
import './sensebox';
|
||||
import './logic';
|
||||
import './sensebox-sensors';
|
||||
import './sensebox-telegram';
|
||||
import './sensebox-osem';
|
||||
import './sensebox-web';
|
||||
import './sensebox-display';
|
||||
import './sensebox-lora';
|
||||
import './sensebox-led';
|
||||
import './sensebox-sd';
|
||||
import './mqtt';
|
||||
import './text';
|
||||
import './io';
|
||||
import './audio';
|
||||
import './math';
|
||||
import './map';
|
||||
import './procedures';
|
||||
import './time';
|
||||
import './variables';
|
||||
import './lists';
|
||||
import './webserver';
|
||||
|
||||
import "../helpers/types";
|
||||
import '../helpers/types'
|
||||
@ -10,24 +10,23 @@
|
||||
*
|
||||
* TODO: maybe change this to a "PIN" BlocklyType
|
||||
*/
|
||||
import Blockly from "blockly/core";
|
||||
import { selectedBoard } from "../helpers/board";
|
||||
import * as Types from "../helpers/types";
|
||||
import Blockly from 'blockly/core';
|
||||
import { selectedBoard } from '../helpers/board'
|
||||
import * as Types from '../helpers/types'
|
||||
|
||||
Blockly.Blocks["io_digitalwrite"] = {
|
||||
|
||||
Blockly.Blocks['io_digitalwrite'] = {
|
||||
/**
|
||||
* Block for creating a 'set pin' to a state.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/DigitalWrite");
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/DigitalWrite');
|
||||
this.setColour(250);
|
||||
this.appendValueInput("STATE")
|
||||
this.appendValueInput('STATE')
|
||||
.appendField(Blockly.Msg.ARD_DIGITALWRITE)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(selectedBoard().digitalPins),
|
||||
"PIN"
|
||||
)
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
selectedBoard().digitalPins), 'PIN')
|
||||
.appendField(Blockly.Msg.ARD_WRITE_TO)
|
||||
.setCheck(Types.BOOLEAN.checkList);
|
||||
this.setInputsInline(false);
|
||||
@ -41,28 +40,23 @@ Blockly.Blocks["io_digitalwrite"] = {
|
||||
*/
|
||||
updateFields: function () {
|
||||
Blockly.Arduino.Boards.refreshBlockFieldDropdown(
|
||||
this,
|
||||
"PIN",
|
||||
"digitalPins"
|
||||
);
|
||||
},
|
||||
this, 'PIN', 'digitalPins');
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["io_digitalread"] = {
|
||||
Blockly.Blocks['io_digitalread'] = {
|
||||
/**
|
||||
* Block for creating a 'read pin'.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/DigitalRead");
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/DigitalRead');
|
||||
this.setColour(250);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_DIGITALREAD)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(selectedBoard().digitalPins),
|
||||
"PIN"
|
||||
);
|
||||
this.setOutput(true, "boolean");
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
selectedBoard().digitalPins), 'PIN');
|
||||
this.setOutput(true, 'boolean');
|
||||
this.setTooltip(Blockly.Msg.ARD_DIGITALREAD_TIP);
|
||||
},
|
||||
/** @return {!string} The type of return value for the block, an integer. */
|
||||
@ -75,27 +69,22 @@ Blockly.Blocks["io_digitalread"] = {
|
||||
*/
|
||||
updateFields: function () {
|
||||
Blockly.Arduino.Boards.refreshBlockFieldDropdown(
|
||||
this,
|
||||
"PIN",
|
||||
"digitalPins"
|
||||
);
|
||||
},
|
||||
this, 'PIN', 'digitalPins');
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["io_builtin_led"] = {
|
||||
Blockly.Blocks['io_builtin_led'] = {
|
||||
/**
|
||||
* Block for setting built-in LED to a state.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/DigitalWrite");
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/DigitalWrite');
|
||||
this.setColour(250);
|
||||
this.appendValueInput("STATE")
|
||||
this.appendValueInput('STATE')
|
||||
.appendField(Blockly.Msg.ARD_BUILTIN_LED)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(selectedBoard().builtinLed),
|
||||
"BUILT_IN_LED"
|
||||
)
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
selectedBoard().builtinLed), 'BUILT_IN_LED')
|
||||
.appendField(Blockly.Msg.ARD_WRITE_TO)
|
||||
.setCheck(Types.BOOLEAN.compatibleTypes);
|
||||
this.setInputsInline(false);
|
||||
@ -109,10 +98,7 @@ Blockly.Blocks["io_builtin_led"] = {
|
||||
*/
|
||||
updateFields: function () {
|
||||
Blockly.Arduino.Boards.refreshBlockFieldDropdown(
|
||||
this,
|
||||
"BUILT_IN_LED",
|
||||
"builtinLed"
|
||||
);
|
||||
this, 'BUILT_IN_LED', 'builtinLed');
|
||||
},
|
||||
/** @return {!string} The type of input value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
@ -120,17 +106,18 @@ Blockly.Blocks["io_builtin_led"] = {
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["io_analogwrite"] = {
|
||||
Blockly.Blocks['io_analogwrite'] = {
|
||||
/**
|
||||
* Block for creating a 'set pin' to an analogue value.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/AnalogWrite");
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/AnalogWrite');
|
||||
this.setColour(250);
|
||||
this.appendValueInput("NUM")
|
||||
this.appendValueInput('NUM')
|
||||
.appendField(Blockly.Msg.ARD_ANALOGWRITE)
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().pwmPins), "PIN")
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
selectedBoard().pwmPins), 'PIN')
|
||||
.appendField(Blockly.Msg.ARD_WRITE_TO)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.setInputsInline(false);
|
||||
@ -143,7 +130,7 @@ Blockly.Blocks["io_analogwrite"] = {
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
updateFields: function () {
|
||||
Blockly.Arduino.Boards.refreshBlockFieldDropdown(this, "PIN", "pwmPins");
|
||||
Blockly.Arduino.Boards.refreshBlockFieldDropdown(this, 'PIN', 'pwmPins');
|
||||
},
|
||||
/** @return {!string} The type of input value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
@ -151,95 +138,88 @@ Blockly.Blocks["io_analogwrite"] = {
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["io_analogread"] = {
|
||||
Blockly.Blocks['io_analogread'] = {
|
||||
/**
|
||||
* Block for reading an analogue input.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/AnalogRead");
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/AnalogRead');
|
||||
this.setColour(250);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_ANALOGREAD)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(selectedBoard().analogPins),
|
||||
"PIN"
|
||||
);
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
selectedBoard().analogPins), 'PIN');
|
||||
this.setOutput(true, Types.NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_ANALOGREAD_TIP);
|
||||
},
|
||||
/** @return {!string} The type of return value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Types.NUMBER.typeName;
|
||||
return Types.NUMBER.typeId;
|
||||
},
|
||||
/**
|
||||
* Updates the content of the the pin related fields.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
updateFields: function () {
|
||||
Blockly.Arduino.Boards.refreshBlockFieldDropdown(this, "PIN", "analogPins");
|
||||
},
|
||||
Blockly.Arduino.Boards.refreshBlockFieldDropdown(this, 'PIN', 'analogPins');
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["io_highlow"] = {
|
||||
Blockly.Blocks['io_highlow'] = {
|
||||
/**
|
||||
* Block for creating a pin state.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/Constants");
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/Constants');
|
||||
this.setColour(250);
|
||||
this.appendDummyInput().appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.ARD_HIGH, "HIGH"],
|
||||
[Blockly.Msg.ARD_LOW, "LOW"],
|
||||
]),
|
||||
"STATE"
|
||||
);
|
||||
this.setOutput(true, Types.BOOLEAN.typeName);
|
||||
this.appendDummyInput()
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([[Blockly.Msg.ARD_HIGH, 'HIGH'], [Blockly.Msg.ARD_LOW, 'LOW']]),
|
||||
'STATE');
|
||||
this.setOutput(true, Types.BOOLEAN.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_HIGHLOW_TIP);
|
||||
},
|
||||
/** @return {!string} The type of return value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Types.BOOLEAN;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["io_pulsein"] = {
|
||||
Blockly.Blocks['io_pulsein'] = {
|
||||
/**
|
||||
* Block for measuring the duration of a pulse in an input pin.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
type: "math_foo",
|
||||
message0: Blockly.Msg.ARD_PULSE_READ,
|
||||
args0: [
|
||||
{
|
||||
type: "input_value",
|
||||
name: "PULSETYPE",
|
||||
check: Types.BOOLEAN.compatibleTypes,
|
||||
},
|
||||
{
|
||||
type: "field_dropdown",
|
||||
name: "PULSEPIN",
|
||||
options: selectedBoard().digitalPins,
|
||||
},
|
||||
"type": "math_foo",
|
||||
"message0": Blockly.Msg.ARD_PULSE_READ,
|
||||
"args0": [{
|
||||
"type": "input_value",
|
||||
"name": "PULSETYPE",
|
||||
"check": Types.BOOLEAN.compatibleTypes
|
||||
}, {
|
||||
"type": "field_dropdown",
|
||||
"name": "PULSEPIN",
|
||||
"options": selectedBoard().digitalPins,
|
||||
}
|
||||
],
|
||||
output: Types.NUMBER.typeName,
|
||||
inputsInline: true,
|
||||
colour: 250,
|
||||
tooltip: Blockly.Msg.ARD_PULSE_TIP,
|
||||
helpUrl: "https://www.arduino.cc/en/Reference/PulseIn",
|
||||
"output": Types.NUMBER.typeId,
|
||||
"inputsInline": true,
|
||||
"colour": 250,
|
||||
"tooltip": Blockly.Msg.ARD_PULSE_TIP,
|
||||
"helpUrl": 'https://www.arduino.cc/en/Reference/PulseIn'
|
||||
});
|
||||
},
|
||||
/** @return {!string} The type of input value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Types.NUMBER.typeName;
|
||||
},
|
||||
return Types.NUMBER.typeId;
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["io_pulsetimeout"] = {
|
||||
Blockly.Blocks['io_pulsetimeout'] = {
|
||||
/**
|
||||
* Block for measuring (with a time-out) the duration of a pulse in an input
|
||||
* pin.
|
||||
@ -247,34 +227,31 @@ Blockly.Blocks["io_pulsetimeout"] = {
|
||||
*/
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
type: "math_foo",
|
||||
message0: Blockly.Msg.ARD_PULSE_READ_TIMEOUT,
|
||||
args0: [
|
||||
{
|
||||
type: "input_value",
|
||||
name: "PULSETYPE",
|
||||
check: Types.BOOLEAN.compatibleTypes,
|
||||
},
|
||||
{
|
||||
type: "field_dropdown",
|
||||
name: "PULSEPIN",
|
||||
options: selectedBoard().digitalPins,
|
||||
},
|
||||
{
|
||||
type: "input_value",
|
||||
name: "TIMEOUT",
|
||||
check: Types.NUMBER.compatibleTypes,
|
||||
},
|
||||
"type": "math_foo",
|
||||
"message0": Blockly.Msg.ARD_PULSE_READ_TIMEOUT,
|
||||
"args0": [{
|
||||
"type": "input_value",
|
||||
"name": "PULSETYPE",
|
||||
"check": Types.BOOLEAN.compatibleTypes
|
||||
}, {
|
||||
"type": "field_dropdown",
|
||||
"name": "PULSEPIN",
|
||||
"options": selectedBoard().digitalPins,
|
||||
}, {
|
||||
"type": "input_value",
|
||||
"name": "TIMEOUT",
|
||||
"check": Types.NUMBER.compatibleTypes
|
||||
}
|
||||
],
|
||||
output: Types.NUMBER.typeName,
|
||||
inputsInline: true,
|
||||
colour: 250,
|
||||
tooltip: Blockly.Msg.ARD_PULSETIMEOUT_TIP,
|
||||
helpUrl: "https://www.arduino.cc/en/Reference/PulseIn",
|
||||
"output": Types.NUMBER.typeId,
|
||||
"inputsInline": true,
|
||||
"colour": 250,
|
||||
"tooltip": Blockly.Msg.ARD_PULSETIMEOUT_TIP,
|
||||
"helpUrl": 'https://www.arduino.cc/en/Reference/PulseIn'
|
||||
});
|
||||
},
|
||||
/** @return {!string} The type of input value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Types.NUMBER.typeName;
|
||||
},
|
||||
return Types.NUMBER.typeId;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,52 +1,57 @@
|
||||
import Blockly, { FieldDropdown } from "blockly/core";
|
||||
import * as Types from "../helpers/types";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import Blockly, { FieldDropdown } from 'blockly/core'
|
||||
import * as Types from '../helpers/types'
|
||||
import { getColour } from '../helpers/colour';
|
||||
|
||||
Blockly.Blocks["lists_create_empty"] = {
|
||||
Blockly.Blocks['lists_create_empty'] = {
|
||||
/**
|
||||
* Elapsed time in milliseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/Millis");
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/Millis');
|
||||
this.setColour(getColour().arrays);
|
||||
this.appendDummyInput().appendField("create List with");
|
||||
this.appendValueInput("NUMBER");
|
||||
this.appendDummyInput()
|
||||
.appendField("create List with")
|
||||
this.appendValueInput('NUMBER');
|
||||
this.appendDummyInput()
|
||||
.appendField("Items of Type")
|
||||
.appendField(new FieldDropdown(Types.VARIABLE_TYPES), "type");
|
||||
this.setOutput(true, Types.ARRAY.typeName);
|
||||
.appendField(new FieldDropdown(Types.VARIABLE_TYPES), 'type');
|
||||
this.setOutput(true, Types.ARRAY.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_MILLIS_TIP);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["array_getIndex"] = {
|
||||
|
||||
Blockly.Blocks['array_getIndex'] = {
|
||||
/**
|
||||
* Elapsed time in milliseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/Millis");
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/Millis');
|
||||
this.setColour(getColour().arrays);
|
||||
this.appendDummyInput().appendField(
|
||||
new Blockly.FieldVariable("X", null, ["Array"], "Array"),
|
||||
"FIELDNAME"
|
||||
);
|
||||
this.setOutput(true, Types.ARRAY.typeName);
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldVariable(
|
||||
'X',
|
||||
null,
|
||||
['Array'],
|
||||
'Array'
|
||||
), 'FIELDNAME');
|
||||
this.setOutput(true, Types.ARRAY.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_MILLIS_TIP);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["lists_length"] = {
|
||||
Blockly.Blocks['lists_length'] = {
|
||||
/**
|
||||
* Elapsed time in milliseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/Millis");
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/Millis');
|
||||
this.setColour(getColour().arrays);
|
||||
this.appendValueInput("ARRAY")
|
||||
.appendField("length of")
|
||||
this.appendValueInput('ARRAY')
|
||||
.appendField('length of')
|
||||
.setCheck(Types.ARRAY.compatibleTypes);
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_MILLIS_TIP);
|
||||
|
||||
@ -22,7 +22,20 @@ Blockly.Blocks["controls_if"] = {
|
||||
this.setMutator(
|
||||
new Blockly.Mutator(["controls_if_elseif", "controls_if_else"])
|
||||
);
|
||||
this.setTooltip(Blockly.Msg.CONTROLS_IF_TOOLTIP_1);
|
||||
// Assign 'this' to a variable for use in the tooltip closure below.
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
if (!thisBlock.elseifCount_ && !thisBlock.elseCount_) {
|
||||
return Blockly.Msg.CONTROLS_IF_TOOLTIP_1;
|
||||
} else if (!thisBlock.elseifCount_ && thisBlock.elseCount_) {
|
||||
return Blockly.Msg.CONTROLS_IF_TOOLTIP_2;
|
||||
} else if (thisBlock.elseifCount_ && !thisBlock.elseCount_) {
|
||||
return Blockly.Msg.CONTROLS_IF_TOOLTIP_3;
|
||||
} else if (thisBlock.elseifCount_ && thisBlock.elseCount_) {
|
||||
return Blockly.Msg.CONTROLS_IF_TOOLTIP_4;
|
||||
}
|
||||
return "";
|
||||
});
|
||||
this.elseifCount_ = 0;
|
||||
this.elseCount_ = 0;
|
||||
},
|
||||
@ -456,6 +469,7 @@ Blockly.Blocks["logic_compare"] = {
|
||||
*/
|
||||
onchange: function (e) {
|
||||
var blockA = this.getInputTargetBlock("A");
|
||||
console.log(blockA);
|
||||
var blockB = this.getInputTargetBlock("B");
|
||||
if (blockA === null && blockB === null) {
|
||||
this.getInput("A").setCheck(null);
|
||||
@ -573,8 +587,9 @@ Blockly.Blocks["switch_case"] = {
|
||||
break;
|
||||
case "case_default":
|
||||
this.defaultCount_++;
|
||||
var defaultInput =
|
||||
this.appendStatementInput("ONDEFAULT").appendField("default");
|
||||
var defaultInput = this.appendStatementInput("ONDEFAULT").appendField(
|
||||
"default"
|
||||
);
|
||||
if (caseBlock.statementConnection_) {
|
||||
defaultInput.connection.connect(caseBlock.statementConnection_);
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ Blockly.Blocks['controls_whileUntil'] = {
|
||||
this.setHelpUrl(Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL);
|
||||
this.setColour(getColour().loops);
|
||||
this.appendValueInput('BOOL')
|
||||
.setCheck(getCompatibleTypes('boolean'))
|
||||
.setCheck(getCompatibleTypes(Boolean))
|
||||
.appendField(new Blockly.FieldDropdown(OPERATORS), 'MODE');
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.CONTROLS_WHILEUNTIL_INPUT_DO);
|
||||
@ -53,19 +53,19 @@ Blockly.Blocks['controls_for'] = {
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "FROM",
|
||||
"check": getCompatibleTypes('int'),
|
||||
"check": getCompatibleTypes(Number),
|
||||
"align": "RIGHT"
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "TO",
|
||||
"check": getCompatibleTypes('int'),
|
||||
"check": getCompatibleTypes(Number),
|
||||
"align": "RIGHT"
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "BY",
|
||||
"check": getCompatibleTypes('int'),
|
||||
"check": getCompatibleTypes(Number),
|
||||
"align": "RIGHT"
|
||||
}
|
||||
],
|
||||
@ -104,7 +104,7 @@ Blockly.Blocks['controls_forEach'] = {
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "LIST",
|
||||
"check": getCompatibleTypes('Array')
|
||||
"check": getCompatibleTypes(Array)
|
||||
}
|
||||
],
|
||||
"previousStatement": null,
|
||||
@ -197,7 +197,7 @@ Blockly.Blocks['controls_repeat_ext'] = {
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "TIMES",
|
||||
"check": getCompatibleTypes('int'),
|
||||
"check": getCompatibleTypes(Number),
|
||||
}
|
||||
],
|
||||
"previousStatement": null,
|
||||
|
||||
@ -11,31 +11,32 @@
|
||||
* TODO: This block can be improved to set the new range properly.
|
||||
*/
|
||||
|
||||
import * as Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Types from "../helpers/types";
|
||||
|
||||
Blockly.Blocks["base_map"] = {
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { getColour } from '../helpers/colour';
|
||||
import * as Types from '../helpers/types'
|
||||
|
||||
Blockly.Blocks['base_map'] = {
|
||||
/**
|
||||
* Block for creating a the map function.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/map");
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/map');
|
||||
this.setColour(getColour().math);
|
||||
this.appendValueInput("NUM")
|
||||
this.appendValueInput('NUM')
|
||||
.appendField(Blockly.Msg.ARD_MAP)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput("FMIN")
|
||||
this.appendValueInput('FMIN')
|
||||
.appendField(Blockly.Msg.ARD_MAP_FROMMIN)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput("FMAX")
|
||||
this.appendValueInput('FMAX')
|
||||
.appendField(Blockly.Msg.ARD_MAP_FROMMAX)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput("DMIN")
|
||||
this.appendValueInput('DMIN')
|
||||
.appendField(Blockly.Msg.ARD_MAP_TOMIN)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput("DMAX")
|
||||
this.appendValueInput('DMAX')
|
||||
.appendField(Blockly.Msg.ARD_MAP_TOMAX)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.setOutput(true);
|
||||
@ -44,6 +45,6 @@ Blockly.Blocks["base_map"] = {
|
||||
},
|
||||
/** @return {string} The type of return value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Types.NUMBER.typeName;
|
||||
},
|
||||
return Types.NUMBER.typeId;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1148,7 +1148,9 @@ Blockly.Blocks['procedures_callnoreturn'] = {
|
||||
// This should only be possible programatically and may indicate a problem
|
||||
// with event grouping. If you see this message please investigate. If the
|
||||
// use ends up being valid we may need to reorder events in the undo stack.
|
||||
|
||||
console.log(
|
||||
'Saw an existing group while responding to a definition change'
|
||||
);
|
||||
}
|
||||
Blockly.Events.setGroup(event.group);
|
||||
if (event.newValue) {
|
||||
|
||||
@ -1,152 +0,0 @@
|
||||
import * as Blockly from "blockly";
|
||||
import { getColour } from "../helpers/colour";
|
||||
|
||||
Blockly.Blocks["sensebox_phyphox_init"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().phyphox);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_phyphox_helpurl);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_init)
|
||||
.appendField(new Blockly.FieldTextInput("Geräte Name"), "devicename");
|
||||
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.sensebox_phyphox_init_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_phyphox_experiment"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().phyphox);
|
||||
this.appendDummyInput().appendField(
|
||||
Blockly.Msg.sensebox_phyphox_createExperiment
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_experimentTitle)
|
||||
.appendField(new Blockly.FieldTextInput("Experiment Title"), "title");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_experimentDescription)
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput(
|
||||
Blockly.Msg.sensebox_phyphox_experiment_description
|
||||
),
|
||||
"description"
|
||||
);
|
||||
this.appendStatementInput("view").appendField(
|
||||
Blockly.Msg.sensebox_phyphox_createView
|
||||
);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.sensebox_phyphox_experiment_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_phyphox_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_phyphox_graph"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().phyphox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_createGraph)
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_graphLabel)
|
||||
.appendField(new Blockly.FieldTextInput("Label"), "label");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_unitx)
|
||||
.appendField(new Blockly.FieldTextInput("Unit X"), "unitx");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_unity)
|
||||
.appendField(new Blockly.FieldTextInput("Unit Y"), "unity");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_labelx)
|
||||
.appendField(new Blockly.FieldTextInput("Label X"), "labelx");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_labely)
|
||||
.appendField(new Blockly.FieldTextInput("Label Y"), "labely");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_graphStyle)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.sensebox_phyphox_style_line, "line"],
|
||||
[Blockly.Msg.sensebox_phyphox_style_dots, "dots"],
|
||||
]),
|
||||
"style"
|
||||
);
|
||||
this.appendValueInput("channel0").appendField(
|
||||
Blockly.Msg.sensebox_phyphox_channel0
|
||||
);
|
||||
this.appendValueInput("channel1").appendField(
|
||||
Blockly.Msg.sensebox_phyphox_channel1
|
||||
);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.sensebox_phyphox_graph_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_phyphox_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_phyphox_timestamp"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().phyphox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_phyphox_timestamp);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_phyphox_timestamp_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_phyphox_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_phyphox_channel"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().phyphox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_channel)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
["1", "1"],
|
||||
["2", "2"],
|
||||
["3", "3"],
|
||||
["4", "4"],
|
||||
["5", "5"],
|
||||
]),
|
||||
"channel"
|
||||
);
|
||||
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_phyphox_channel_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_phyphox_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_phyphox_sendchannel"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().phyphox);
|
||||
this.appendValueInput("value")
|
||||
.appendField(Blockly.Msg.sensebox_phyphox_sendchannel)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
["1", "1"],
|
||||
["2", "2"],
|
||||
["3", "3"],
|
||||
["4", "4"],
|
||||
["5", "5"],
|
||||
]),
|
||||
"channel"
|
||||
);
|
||||
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.sensebox_phyphox_sendchannel_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_phyphox_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_phyphox_experiment_send"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().phyphox);
|
||||
this.appendStatementInput("sendValues").appendField(
|
||||
Blockly.Msg.sensebox_phyphox_writeValues
|
||||
);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.sensebox_phyphox_experiment_send_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_phyphox_helpurl);
|
||||
},
|
||||
};
|
||||
@ -1,59 +1,51 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Types from "../helpers/types";
|
||||
import { FieldSlider } from "@blockly/field-slider";
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { getColour } from '../helpers/colour';
|
||||
import * as Types from '../helpers/types'
|
||||
import { FieldSlider } from '@blockly/field-slider';
|
||||
|
||||
Blockly.Blocks["sensebox_display_beginDisplay"] = {
|
||||
|
||||
Blockly.Blocks['sensebox_display_beginDisplay'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput().appendField(
|
||||
Blockly.Msg.senseBox_display_beginDisplay
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_display_beginDisplay)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_display_beginDisplay_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_display_clearDisplay"] = {
|
||||
Blockly.Blocks['sensebox_display_clearDisplay'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput().appendField(
|
||||
Blockly.Msg.senseBox_display_clearDisplay
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_display_clearDisplay)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_display_clearDisplay_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_display_printDisplay"] = {
|
||||
Blockly.Blocks['sensebox_display_printDisplay'] = {
|
||||
init: function (block) {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(
|
||||
Blockly.Msg.senseBox_display_printDisplay
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_display_printDisplay);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_display_color)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_display_white, "WHITE,BLACK"],
|
||||
[Blockly.Msg.senseBox_display_black, "BLACK,WHITE"],
|
||||
]),
|
||||
"COLOR"
|
||||
);
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_display_white, "WHITE,BLACK"], [Blockly.Msg.senseBox_display_black, "BLACK,WHITE"]]), "COLOR");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_display_setSize)
|
||||
.appendField(new FieldSlider(1, 1, 4), "SIZE");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_display_printDisplay_x)
|
||||
.appendField(new FieldSlider(0, 0, 127), "X");
|
||||
.appendField(new FieldSlider(0, 0, 64), "X");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_display_printDisplay_y)
|
||||
.appendField(new FieldSlider(0, 0, 63), "Y");
|
||||
this.appendValueInput("printDisplay")
|
||||
.appendField(new FieldSlider(0, 0, 128), "Y");
|
||||
this.appendValueInput('printDisplay')
|
||||
.appendField(Blockly.Msg.senseBox_display_printDisplay_value)
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
@ -84,33 +76,26 @@ Blockly.Blocks["sensebox_display_printDisplay"] = {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_display_show"],
|
||||
LOOP_TYPES: ['sensebox_display_show'],
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_display_fastPrint"] = {
|
||||
Blockly.Blocks['sensebox_display_fastPrint'] = {
|
||||
init: function (block) {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(
|
||||
Blockly.Msg.senseBox_display_fastPrint_show
|
||||
);
|
||||
this.appendValueInput("Title1", "Title1").appendField(
|
||||
Blockly.Msg.senseBox_display_fastPrint_title
|
||||
);
|
||||
this.appendValueInput("Value1", "Value1").appendField(
|
||||
Blockly.Msg.senseBox_display_fastPrint_value
|
||||
);
|
||||
this.appendValueInput("Dimension1", "Dimension1").appendField(
|
||||
Blockly.Msg.senseBox_display_fastPrint_dimension
|
||||
);
|
||||
this.appendValueInput("Title2", "Title2").appendField(
|
||||
Blockly.Msg.senseBox_display_fastPrint_title
|
||||
);
|
||||
this.appendValueInput("Value2", "Value2").appendField(
|
||||
Blockly.Msg.senseBox_display_fastPrint_value
|
||||
);
|
||||
this.appendValueInput("Dimension2", "Dimension2").appendField(
|
||||
Blockly.Msg.senseBox_display_fastPrint_dimension
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_display_fastPrint_show);
|
||||
this.appendValueInput("Title1", 'Title1')
|
||||
.appendField(Blockly.Msg.senseBox_display_fastPrint_title);
|
||||
this.appendValueInput("Value1", 'Value1')
|
||||
.appendField(Blockly.Msg.senseBox_display_fastPrint_value);
|
||||
this.appendValueInput("Dimension1", 'Dimension1')
|
||||
.appendField(Blockly.Msg.senseBox_display_fastPrint_dimension);
|
||||
this.appendValueInput("Title2", 'Title2')
|
||||
.appendField(Blockly.Msg.senseBox_display_fastPrint_title);
|
||||
this.appendValueInput("Value2", 'Value2')
|
||||
.appendField(Blockly.Msg.senseBox_display_fastPrint_value);
|
||||
this.appendValueInput("Dimension2", 'Dimension2')
|
||||
.appendField(Blockly.Msg.senseBox_display_fastPrint_dimension);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.sensebox_display_fastPrint_tooltip);
|
||||
@ -139,47 +124,37 @@ Blockly.Blocks["sensebox_display_fastPrint"] = {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_display_show"],
|
||||
LOOP_TYPES: ['sensebox_display_show'],
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_display_plotDisplay"] = {
|
||||
|
||||
Blockly.Blocks['sensebox_display_plotDisplay'] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(
|
||||
Blockly.Msg.senseBox_display_plotDisplay
|
||||
);
|
||||
this.appendValueInput("Title", "Text").appendField(
|
||||
Blockly.Msg.senseBox_display_plotTitle
|
||||
);
|
||||
this.appendValueInput("YLabel", "Text").appendField(
|
||||
Blockly.Msg.senseBox_display_plotYLabel
|
||||
);
|
||||
this.appendValueInput("XLabel", "Text").appendField(
|
||||
Blockly.Msg.senseBox_display_plotXLabel
|
||||
);
|
||||
this.appendValueInput("XRange1", "Number").appendField(
|
||||
Blockly.Msg.senseBox_display_plotXRange1
|
||||
);
|
||||
this.appendValueInput("XRange2", "Number").appendField(
|
||||
Blockly.Msg.senseBox_display_plotXRange2
|
||||
);
|
||||
this.appendValueInput("YRange1", "Number").appendField(
|
||||
Blockly.Msg.senseBox_display_plotYRange1
|
||||
);
|
||||
this.appendValueInput("YRange2", "Number").appendField(
|
||||
Blockly.Msg.senseBox_display_plotYRange2
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_display_plotDisplay)
|
||||
this.appendValueInput("Title", 'Text')
|
||||
.appendField(Blockly.Msg.senseBox_display_plotTitle);
|
||||
this.appendValueInput("YLabel", 'Text')
|
||||
.appendField(Blockly.Msg.senseBox_display_plotYLabel);
|
||||
this.appendValueInput("XLabel", 'Text')
|
||||
.appendField(Blockly.Msg.senseBox_display_plotXLabel);
|
||||
this.appendValueInput("XRange1", 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_display_plotXRange1);
|
||||
this.appendValueInput("XRange2", 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_display_plotXRange2)
|
||||
this.appendValueInput("YRange1", 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_display_plotYRange1);
|
||||
this.appendValueInput("YRange2", 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_display_plotYRange2);
|
||||
this.setInputsInline(false);
|
||||
this.appendValueInput("XTick", "Number").appendField(
|
||||
Blockly.Msg.senseBox_display_plotXTick
|
||||
);
|
||||
this.appendValueInput("YTick", "Number").appendField(
|
||||
Blockly.Msg.senseBox_display_plotYTick
|
||||
);
|
||||
this.appendValueInput("TimeFrame", "Number").appendField(
|
||||
Blockly.Msg.senseBox_display_plotTimeFrame
|
||||
);
|
||||
this.appendValueInput("plotDisplay")
|
||||
this.appendValueInput("XTick", 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_display_plotXTick);
|
||||
this.appendValueInput("YTick", 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_display_plotYTick);
|
||||
this.appendValueInput("TimeFrame", 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_display_plotTimeFrame);
|
||||
this.appendValueInput('plotDisplay')
|
||||
.appendField(Blockly.Msg.senseBox_display_printDisplay_value)
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
@ -210,42 +185,43 @@ Blockly.Blocks["sensebox_display_plotDisplay"] = {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_display_show"],
|
||||
LOOP_TYPES: ['sensebox_display_show'],
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_display_show"] = {
|
||||
Blockly.Blocks['sensebox_display_show'] = {
|
||||
init: function () {
|
||||
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_display_show);
|
||||
this.appendStatementInput("SHOW");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_display_show);
|
||||
this.appendStatementInput('SHOW');
|
||||
this.setTooltip(Blockly.Msg.sensebox_display_show_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_display_fillCircle"] = {
|
||||
Blockly.Blocks['sensebox_display_fillCircle'] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(
|
||||
Blockly.Msg.sensebox_display_fillCircle
|
||||
);
|
||||
this.appendValueInput("X")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_display_fillCircle);
|
||||
this.appendValueInput('X')
|
||||
.appendField(Blockly.Msg.senseBox_display_printDisplay_x)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput("Y")
|
||||
this.appendValueInput('Y')
|
||||
.appendField(Blockly.Msg.senseBox_display_printDisplay_y)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput("Radius")
|
||||
this.appendValueInput('Radius')
|
||||
.appendField(Blockly.Msg.sensebox_display_fillCircle_radius)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendDummyInput("fill")
|
||||
this.appendDummyInput('fill')
|
||||
.appendField(Blockly.Msg.senseBox_display_filled)
|
||||
.appendField(new Blockly.FieldCheckbox("TRUE"), "FILL");
|
||||
this.setInputsInline(false);
|
||||
this.setTooltip(Blockly.Msg.senseBox_display_fillCircle_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl);
|
||||
this.setTooltip(Blockly.Msg.senseBox_display_fillCircle_tooltip)
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
@ -272,33 +248,32 @@ Blockly.Blocks["sensebox_display_fillCircle"] = {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_display_show"],
|
||||
LOOP_TYPES: ['sensebox_display_show'],
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_display_drawRectangle"] = {
|
||||
Blockly.Blocks['sensebox_display_drawRectangle'] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(
|
||||
Blockly.Msg.sensebox_display_drawRectangle
|
||||
);
|
||||
this.appendValueInput("X")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_display_drawRectangle);
|
||||
this.appendValueInput('X')
|
||||
.appendField(Blockly.Msg.senseBox_display_printDisplay_x)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput("Y")
|
||||
this.appendValueInput('Y')
|
||||
.appendField(Blockly.Msg.senseBox_display_printDisplay_y)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput("width")
|
||||
this.appendValueInput('width')
|
||||
.appendField(Blockly.Msg.sensebox_display_drawRectangle_width)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendValueInput("height")
|
||||
this.appendValueInput('height')
|
||||
.appendField(Blockly.Msg.sensebox_display_drawRectangle_height)
|
||||
.setCheck(Types.NUMBER.compatibleTypes);
|
||||
this.appendDummyInput("fill")
|
||||
this.appendDummyInput('fill')
|
||||
.appendField(Blockly.Msg.senseBox_display_filled)
|
||||
.appendField(new Blockly.FieldCheckbox("TRUE"), "FILL");
|
||||
this.setInputsInline(false);
|
||||
this.setTooltip(Blockly.Msg.senseBox_display_drawRectangle_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl);
|
||||
this.setTooltip(Blockly.Msg.senseBox_display_drawRectangle_tooltip)
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_display_helpurl)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
@ -325,5 +300,5 @@ Blockly.Blocks["sensebox_display_drawRectangle"] = {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_display_show"],
|
||||
LOOP_TYPES: ['sensebox_display_show'],
|
||||
};
|
||||
|
||||
@ -45,11 +45,15 @@ Blockly.Blocks['sensebox_rgb_led'] = {
|
||||
|
||||
Blockly.Blocks['sensebox_ws2818_led_init'] = {
|
||||
init: function () {
|
||||
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_ultrasonic_port_A, '1'],
|
||||
[Blockly.Msg.senseBox_ultrasonic_port_B, '3'], [Blockly.Msg.senseBox_ultrasonic_port_C, '5']];
|
||||
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_ws2818_rgb_led_init)
|
||||
.appendField("Port:")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPinsRGB), "Port")
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port")
|
||||
this.appendValueInput("BRIGHTNESS", "brightness")
|
||||
.appendField((Blockly.Msg.senseBox_ws2818_rgb_led_brightness));
|
||||
this.appendValueInput("NUMBER", "number")
|
||||
@ -62,11 +66,15 @@ Blockly.Blocks['sensebox_ws2818_led_init'] = {
|
||||
|
||||
Blockly.Blocks['sensebox_ws2818_led'] = {
|
||||
init: function () {
|
||||
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_ultrasonic_port_A, '1'],
|
||||
[Blockly.Msg.senseBox_ultrasonic_port_B, '3'], [Blockly.Msg.senseBox_ultrasonic_port_C, '5']];
|
||||
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_ws2818_rgb_led)
|
||||
.appendField("Port:")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPinsRGB), "Port")
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port")
|
||||
this.appendValueInput("POSITION", "position")
|
||||
.appendField((Blockly.Msg.senseBox_ws2818_rgb_led_position));
|
||||
this.appendValueInput("COLOR", 'Number')
|
||||
|
||||
@ -1,34 +1,30 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { getColour } from '../helpers/colour';
|
||||
|
||||
|
||||
/*
|
||||
----------------------------------LoRa--------------------------------------------------
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_lora_initialize_otaa"] = {
|
||||
Blockly.Blocks['sensebox_lora_initialize_otaa'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_init_otaa_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_LoRa_init_helpurl);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField("Initialize LoRa (OTAA)");
|
||||
this.appendDummyInput()
|
||||
.appendField("Initialize LoRa (OTAA)");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_device_id)
|
||||
.appendField("{")
|
||||
.appendField(new Blockly.FieldTextInput("DEVICE ID"), "DEVICEID")
|
||||
.appendField("}");
|
||||
.appendField(new Blockly.FieldTextInput("DEVICE ID"), "DEVICEID");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_app_id)
|
||||
.appendField("{")
|
||||
.appendField(new Blockly.FieldTextInput("APP ID"), "APPID")
|
||||
.appendField("}");
|
||||
.appendField(new Blockly.FieldTextInput("APP ID"), "APPID");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_app_key)
|
||||
.appendField("{")
|
||||
.appendField(new Blockly.FieldTextInput("APP KEY"), "APPKEY")
|
||||
.appendField("}");
|
||||
.appendField(new Blockly.FieldTextInput("APP KEY"), "APPKEY");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_interval)
|
||||
@ -38,24 +34,21 @@ Blockly.Blocks["sensebox_lora_initialize_otaa"] = {
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_lora_initialize_abp"] = {
|
||||
Blockly.Blocks['sensebox_lora_initialize_abp'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_init_abp_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_LoRa_init_helpurl);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField("Initialize LoRa (ABP)");
|
||||
this.appendDummyInput()
|
||||
.appendField("Initialize LoRa (ABP)");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_nwskey_id)
|
||||
.appendField("{")
|
||||
.appendField(new Blockly.FieldTextInput("NWSKEY"), "NWSKEY")
|
||||
.appendField("}");
|
||||
.appendField(new Blockly.FieldTextInput("NWSKEY"), "NWSKEY");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_appskey_id)
|
||||
.appendField("{")
|
||||
.appendField(new Blockly.FieldTextInput("APPSKEY"), "APPSKEY")
|
||||
.appendField("}");
|
||||
.appendField(new Blockly.FieldTextInput("APPSKEY"), "APPSKEY");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_devaddr_id)
|
||||
@ -72,27 +65,26 @@ Blockly.Blocks["sensebox_lora_initialize_abp"] = {
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_lora_message_send"] = {
|
||||
Blockly.Blocks['sensebox_lora_message_send'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_message_tooltip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendStatementInput("DO")
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_send_message)
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_send_lora_sensor_value"] = {
|
||||
Blockly.Blocks['sensebox_send_lora_sensor_value'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_sensor_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_measurement
|
||||
);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_measurement)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField("Bytes")
|
||||
@ -123,66 +115,60 @@ Blockly.Blocks["sensebox_send_lora_sensor_value"] = {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_message_send"],
|
||||
LOOP_TYPES: ['sensebox_lora_message_send'],
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_lora_ttn_mapper"] = {
|
||||
Blockly.Blocks['sensebox_lora_ttn_mapper'] = {
|
||||
init: function (block) {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField("TTN Mapper");
|
||||
this.appendDummyInput()
|
||||
.appendField("TTN Mapper");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField("Fix Type Limit")
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(
|
||||
[
|
||||
["0", "0"],
|
||||
["1", "1"],
|
||||
["2", "2"],
|
||||
["3", "3"],
|
||||
].reverse()
|
||||
),
|
||||
"dropdown"
|
||||
);
|
||||
.appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]].reverse()), "dropdown");
|
||||
// reverse() because i want 3 be be at first and i'm to lazy to write the array again
|
||||
this.appendValueInput("Latitude")
|
||||
this.appendValueInput('Latitude')
|
||||
.appendField(Blockly.Msg.senseBox_gps_lat)
|
||||
.setCheck(null);
|
||||
this.appendValueInput("Longitude")
|
||||
this.appendValueInput('Longitude')
|
||||
.appendField(Blockly.Msg.senseBox_gps_lng)
|
||||
.setCheck(null);
|
||||
this.appendValueInput("Altitude")
|
||||
this.appendValueInput('Altitude')
|
||||
.appendField(Blockly.Msg.senseBox_gps_alt)
|
||||
.setCheck(null);
|
||||
this.appendValueInput("pDOP").appendField("pDOP").setCheck(null);
|
||||
this.appendValueInput("Fix Type").appendField("Fix Type").setCheck(null);
|
||||
this.appendValueInput('pDOP')
|
||||
.appendField('pDOP')
|
||||
.setCheck(null);
|
||||
this.appendValueInput('Fix Type')
|
||||
.appendField('Fix Type')
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.sensebox_lora_ttn_mapper_tip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_lora_ttn_mapper_helpurl);
|
||||
},
|
||||
this.setTooltip(Blockly.Msg.senseBox_display_printDisplay_tip);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_lora_cayenne_send"] = {
|
||||
Blockly.Blocks['sensebox_lora_cayenne_send'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendStatementInput("DO")
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_send_cayenne)
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
}
|
||||
};
|
||||
Blockly.Blocks["sensebox_lora_cayenne_temperature"] = {
|
||||
Blockly.Blocks['sensebox_lora_cayenne_temperature'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_temperature_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_temperature
|
||||
);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_temperature)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
@ -190,16 +176,15 @@ Blockly.Blocks["sensebox_lora_cayenne_temperature"] = {
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
};
|
||||
Blockly.Blocks["sensebox_lora_cayenne_humidity"] = {
|
||||
Blockly.Blocks['sensebox_lora_cayenne_humidity'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_humidity_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_humidity
|
||||
);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_humidity)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
@ -207,16 +192,15 @@ Blockly.Blocks["sensebox_lora_cayenne_humidity"] = {
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
};
|
||||
Blockly.Blocks["sensebox_lora_cayenne_pressure"] = {
|
||||
Blockly.Blocks['sensebox_lora_cayenne_pressure'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_pressure_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_pressure
|
||||
);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_pressure)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
@ -224,16 +208,15 @@ Blockly.Blocks["sensebox_lora_cayenne_pressure"] = {
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
};
|
||||
Blockly.Blocks["sensebox_lora_cayenne_luminosity"] = {
|
||||
Blockly.Blocks['sensebox_lora_cayenne_luminosity'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_luminosity_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_luminosity
|
||||
);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_luminosity)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
@ -241,16 +224,15 @@ Blockly.Blocks["sensebox_lora_cayenne_luminosity"] = {
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
};
|
||||
Blockly.Blocks["sensebox_lora_cayenne_sensor"] = {
|
||||
Blockly.Blocks['sensebox_lora_cayenne_sensor'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_analog_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_analog
|
||||
);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_analog)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
@ -258,16 +240,19 @@ Blockly.Blocks["sensebox_lora_cayenne_sensor"] = {
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
};
|
||||
Blockly.Blocks["sensebox_lora_cayenne_accelerometer"] = {
|
||||
Blockly.Blocks['sensebox_lora_cayenne_accelerometer'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_gyros_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("X").appendField(Blockly.Msg.senseBox_LoRa_cayenne_x);
|
||||
this.appendValueInput("Y").appendField(Blockly.Msg.senseBox_LoRa_cayenne_y);
|
||||
this.appendValueInput("Z").appendField(Blockly.Msg.senseBox_LoRa_cayenne_z);
|
||||
this.appendValueInput('X')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_x)
|
||||
this.appendValueInput('Y')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_y)
|
||||
this.appendValueInput('Z')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_z)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
@ -275,22 +260,19 @@ Blockly.Blocks["sensebox_lora_cayenne_accelerometer"] = {
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
};
|
||||
Blockly.Blocks["sensebox_lora_cayenne_gps"] = {
|
||||
Blockly.Blocks['sensebox_lora_cayenne_gps'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_gps_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("LAT").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_lat
|
||||
);
|
||||
this.appendValueInput("LNG").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_lng
|
||||
);
|
||||
this.appendValueInput("ALT").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_alt
|
||||
);
|
||||
this.appendValueInput('LAT')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_lat)
|
||||
this.appendValueInput('LNG')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_lng)
|
||||
this.appendValueInput('ALT')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_alt)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
@ -298,23 +280,5 @@ Blockly.Blocks["sensebox_lora_cayenne_gps"] = {
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_lora_cayenne_concentration"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_concentration_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_concentration
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
};
|
||||
|
||||
@ -1,144 +0,0 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import { selectedBoard } from "../helpers/board";
|
||||
import { FieldSlider } from "@blockly/field-slider";
|
||||
|
||||
/**
|
||||
* Servo Motor
|
||||
*
|
||||
*/
|
||||
Blockly.Blocks["sensebox_motors_beginServoMotor"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_motors_beginServoMotor);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_motors_beginServoMotor_pin)
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "pin")
|
||||
.setAlign(Blockly.ALIGN_RIGHT);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().motors);
|
||||
this.setTooltip(Blockly.Msg.sensebox_motors_beginServoMotor_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_motors_beginServoMotor_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_motors_moveServoMotor"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_motors_moveServoMotor);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_motors_moveServoMotor_pin)
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "pin")
|
||||
.setAlign(Blockly.ALIGN_RIGHT);
|
||||
this.appendValueInput("degrees", "Number")
|
||||
.appendField(Blockly.Msg.sensebox_motors_moveServoMotor_degrees)
|
||||
.setAlign(Blockly.ALIGN_RIGHT);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().motors);
|
||||
this.setTooltip(Blockly.Msg.sensebox_motors_moveServoMotor_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_motors_moveServoMotor_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* I2C Motor Board
|
||||
*
|
||||
*/
|
||||
Blockly.Blocks["sensebox_motors_I2CMotorBoard_begin"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_begin);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().motors);
|
||||
this.setTooltip(Blockly.Msg.sensebox_motors_I2CMotorBoard_begin_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_motors_I2CMotorBoard_begin_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_motors_I2CMotorBoard_moveDCMotor"] = {
|
||||
init: function () {
|
||||
var dropdownOptions = [[Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_left, '1'],
|
||||
[Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_right, '2']];
|
||||
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor)
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "motor")
|
||||
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_motor);
|
||||
this.appendValueInput("speed", "Number")
|
||||
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_speed)
|
||||
.setAlign(Blockly.ALIGN_RIGHT);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().motors);
|
||||
this.setTooltip(Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_motors_I2CMotorBoard_stopDCMotor"] = {
|
||||
init: function () {
|
||||
var dropdownOptions = [[Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor_left, '1'],
|
||||
[Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor_right, '2']];
|
||||
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor)
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "motor")
|
||||
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor_motor)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().motors);
|
||||
this.setTooltip(Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Stepper Motor
|
||||
*
|
||||
*/
|
||||
Blockly.Blocks["sensebox_motors_beginStepperMotor"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_motors_beginStepperMotor);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_motors_beginStepperMotor_pins);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "in1")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "in2")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "in3")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "in4");
|
||||
this.setFieldValue("1", "in1");
|
||||
this.setFieldValue("2", "in2");
|
||||
this.setFieldValue("3", "in3");
|
||||
this.setFieldValue("4", "in4");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_motors_beginStepperMotor_rpm)
|
||||
.appendField(new FieldSlider(3, 1, 3), "rpm");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().motors);
|
||||
this.setTooltip(Blockly.Msg.sensebox_motors_beginStepperMotor_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_motors_beginStepperMotor_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_motors_moveStepperMotor"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_motors_moveStepperMotor);
|
||||
this.appendValueInput("steps", "Number")
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.sensebox_motors_moveStepperMotor_step);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().motors);
|
||||
this.setTooltip(Blockly.Msg.sensebox_motors_moveStepperMotor_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_motors_moveStepperMotor_helpurl);
|
||||
},
|
||||
};
|
||||
@ -1,42 +0,0 @@
|
||||
import * as Blockly from "blockly";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Types from "../helpers/types";
|
||||
|
||||
Blockly.Blocks["sensebox_ntp_init"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_ntp_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_ntp_init);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_ntp_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_ntp_get"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_ntp_get_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_ntp_get)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.sensebox_ntp_epochTime, "getEpochTime"],
|
||||
[Blockly.Msg.sensebox_ntp_formattedTimeStamp, "getFormattedTime"],
|
||||
]),
|
||||
"dropdown"
|
||||
);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeName);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_get_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_ntp_get_timestamp"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_rtc_get_timestamp);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_get_timestamp_tooltip);
|
||||
},
|
||||
};
|
||||
@ -1,70 +1,56 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { getColour } from '../helpers/colour';
|
||||
|
||||
import store from "../../../store";
|
||||
import store from '../../../store';
|
||||
|
||||
var boxes = store.getState().auth.user
|
||||
? store.getState().auth.user.boxes
|
||||
: null;
|
||||
var boxes = store.getState().auth.user ? store.getState().auth.user.boxes : null;
|
||||
store.subscribe(() => {
|
||||
boxes = store.getState().auth.user ? store.getState().auth.user.boxes : null;
|
||||
});
|
||||
var selectedBox = "";
|
||||
var selectedBox = '';
|
||||
|
||||
Blockly.Blocks["sensebox_osem_connection"] = {
|
||||
|
||||
Blockly.Blocks['sensebox_osem_connection'] = {
|
||||
init: function () {
|
||||
var ssl = "TRUE";
|
||||
this.setTooltip(Blockly.Msg.senseBox_osem_connection_tip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_osem_connection_helpurl);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_osem_connection)
|
||||
.appendField("SSL")
|
||||
.appendField(new Blockly.FieldCheckbox(ssl), "SSL");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_osem_restart)
|
||||
.appendField(new Blockly.FieldCheckbox("TRUE"), "RESTART");
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_osem_host, '"ingress.opensensemap.org"'], [Blockly.Msg.senseBox_osem_host_workshop, '"ingress.workshop.opensensemap.org"']]), "host")
|
||||
.appendField('SSL')
|
||||
.appendField(new Blockly.FieldCheckbox("TRUE"), "SSL");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_osem_exposure)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_osem_stationary, "Stationary"],
|
||||
[Blockly.Msg.senseBox_osem_mobile, "Mobile"],
|
||||
]),
|
||||
"type"
|
||||
);
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_osem_stationary, 'Stationary'], [Blockly.Msg.senseBox_osem_mobile, 'Mobile']]), "type");
|
||||
if (!boxes) {
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField("senseBox ID")
|
||||
.appendField(new Blockly.FieldTextInput("senseBox ID"), "BoxID");
|
||||
} else {
|
||||
var dropdown = [];
|
||||
var dropdown = []
|
||||
for (var i = 0; i < boxes.length; i++) {
|
||||
dropdown.push([boxes[i].name, boxes[i]._id]);
|
||||
dropdown.push([boxes[i].name, boxes[i]._id])
|
||||
}
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField("senseBox ID")
|
||||
.appendField(new Blockly.FieldDropdown(dropdown), "BoxID");
|
||||
.appendField(new Blockly.FieldDropdown(dropdown), 'BoxID');
|
||||
}
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_osem_access_token)
|
||||
.appendField(new Blockly.FieldTextInput("access_token"), "access_token");
|
||||
this.appendStatementInput("DO")
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.senseBox_sensor)
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.getField("type").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "Mobile");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
onchange: function (e) {
|
||||
|
||||
var legal = false;
|
||||
// Is the block nested in a loop?
|
||||
var block = this;
|
||||
@ -86,62 +72,78 @@ Blockly.Blocks["sensebox_osem_connection"] = {
|
||||
* To add a new loop type add this to your code:
|
||||
* Blockly.Blocks['controls_flow_statements'].LOOP_TYPES.push('custom_loop');
|
||||
*/
|
||||
selectedBox = this.getFieldValue("BoxID");
|
||||
if (selectedBox !== "" && boxes) {
|
||||
var accessToken = boxes.find(
|
||||
(element) => element._id === selectedBox
|
||||
).access_token;
|
||||
selectedBox = this.getFieldValue('BoxID');
|
||||
console.log(selectedBox)
|
||||
if (selectedBox !== '' && boxes) {
|
||||
var accessToken = boxes.find(element => element._id === selectedBox).access_token
|
||||
if (accessToken !== undefined) {
|
||||
this.getField("access_token").setValue(accessToken);
|
||||
this.getField('access_token').setValue(accessToken)
|
||||
} else {
|
||||
this.getField("access_token").setValue("access_token");
|
||||
this.getField('access_token').setValue('access_token')
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
mutationToDom: function () {
|
||||
var container = document.createElement('mutation');
|
||||
var input = this.getFieldValue('type');
|
||||
this.updateShape_(input);
|
||||
container.setAttribute('type', input);
|
||||
return container;
|
||||
},
|
||||
|
||||
domToMutation: function (xmlElement) {
|
||||
var connections = xmlElement.getAttribute('connections');
|
||||
this.updateShape_(connections);
|
||||
},
|
||||
/**
|
||||
* Modify this block to have the correct number of pins available.
|
||||
* @param {boolean}
|
||||
* @private
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
updateShape_: function () {
|
||||
var extraFieldExist = this.getFieldValue('gps');
|
||||
var input = this.getFieldValue('type');
|
||||
if ((input === 'Mobile') && extraFieldExist === null) {
|
||||
this.appendValueInput('lat', 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_gps_lat, 'gps');
|
||||
this.appendValueInput('lng', 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_gps_lng);
|
||||
this.appendValueInput('altitude', 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_gps_alt);
|
||||
this.appendValueInput('timeStamp', 'Number')
|
||||
.appendField(Blockly.Msg.senseBox_gps_timeStamp);
|
||||
}
|
||||
|
||||
if (input === 'Stationary' && extraFieldExist !== null) {
|
||||
this.removeInput('lat');
|
||||
this.removeInput('lng');
|
||||
this.removeInput('altitude');
|
||||
this.removeInput('timeStamp');
|
||||
}
|
||||
},
|
||||
updateShape_(isMobile) {
|
||||
if (isMobile) {
|
||||
if (this.getInput("lat") == null) {
|
||||
this.appendValueInput("lat", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lat,
|
||||
"gps"
|
||||
);
|
||||
this.appendValueInput("lng", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lng
|
||||
);
|
||||
this.appendValueInput("altitude", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_alt
|
||||
);
|
||||
this.appendValueInput("timeStamp", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_timeStamp
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.removeInput("lat", true);
|
||||
this.removeInput("lng", true);
|
||||
this.removeInput("altitude", true);
|
||||
this.removeInput("timeStamp", true);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_interval_timer"],
|
||||
LOOP_TYPES: ['sensebox_interval_timer']
|
||||
};
|
||||
Blockly.Blocks["sensebox_send_to_osem"] = {
|
||||
Blockly.Blocks['sensebox_send_to_osem'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_send_to_osem_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_send_to_osem);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_send_to_osem);
|
||||
if (boxes) {
|
||||
this.appendValueInput("Value")
|
||||
.appendField("Phänomen")
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(this.generateOptions),
|
||||
"SensorID"
|
||||
);
|
||||
this.appendValueInput('Value')
|
||||
.appendField('Phänomen')
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
this.generateOptions), 'SensorID');
|
||||
} else {
|
||||
this.appendValueInput("Value")
|
||||
this.appendValueInput('Value')
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField("Phänomen")
|
||||
.appendField(new Blockly.FieldTextInput("sensorID"), "SensorID");
|
||||
.appendField('Phänomen')
|
||||
.appendField(new Blockly.FieldTextInput(
|
||||
'sensorID'), 'SensorID')
|
||||
}
|
||||
|
||||
this.setPreviousStatement(true, null);
|
||||
@ -149,23 +151,25 @@ Blockly.Blocks["sensebox_send_to_osem"] = {
|
||||
},
|
||||
|
||||
generateOptions: function () {
|
||||
var dropdown = [["", ""]];
|
||||
var dropdown = [['', '']];
|
||||
var boxID = selectedBox;
|
||||
if (boxID !== "" && boxes) {
|
||||
let box = boxes.find((el) => el._id === boxID);
|
||||
if (boxID !== '' && boxes) {
|
||||
|
||||
let box = boxes.find(el => el._id === boxID);
|
||||
if (box !== undefined) {
|
||||
for (var i = 0; i < box.sensors.length; i++) {
|
||||
dropdown.push([box.sensors[i].title, box.sensors[i]._id]);
|
||||
dropdown.push([box.sensors[i].title, box.sensors[i]._id])
|
||||
}
|
||||
console.log(dropdown)
|
||||
}
|
||||
if (dropdown.length > 1) {
|
||||
var options = dropdown.slice(1);
|
||||
return options;
|
||||
var options = dropdown.slice(1)
|
||||
return options
|
||||
} else {
|
||||
return dropdown;
|
||||
return dropdown
|
||||
}
|
||||
}
|
||||
return dropdown;
|
||||
return dropdown
|
||||
},
|
||||
/**
|
||||
* Called whenever anything on the workspace changes.
|
||||
@ -174,6 +178,7 @@ Blockly.Blocks["sensebox_send_to_osem"] = {
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
onchange: function () {
|
||||
|
||||
var legal = false;
|
||||
// Is the block nested in a loop?
|
||||
var block = this;
|
||||
@ -195,5 +200,5 @@ Blockly.Blocks["sensebox_send_to_osem"] = {
|
||||
* To add a new loop type add this to your code:
|
||||
* Blockly.Blocks['controls_flow_statements'].LOOP_TYPES.push('custom_loop');
|
||||
*/
|
||||
LOOP_TYPES: ["sensebox_osem_connection"],
|
||||
LOOP_TYPES: ['sensebox_osem_connection']
|
||||
};
|
||||
|
||||
@ -1,142 +0,0 @@
|
||||
import * as Blockly from "blockly";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Types from "../helpers/types";
|
||||
|
||||
Blockly.Blocks["sensebox_rtc_init"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_rtc_init);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_init_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_rtc_set"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_rtc_set);
|
||||
this.appendValueInput("second").appendField(
|
||||
Blockly.Msg.sensebox_rtc_second
|
||||
);
|
||||
this.appendValueInput("minutes").appendField(
|
||||
Blockly.Msg.sensebox_rtc_minutes
|
||||
);
|
||||
this.appendValueInput("hour").appendField(Blockly.Msg.sensebox_rtc_hour);
|
||||
this.appendValueInput("day").appendField(Blockly.Msg.sensebox_rtc_day);
|
||||
this.appendValueInput("month").appendField(Blockly.Msg.sensebox_rtc_month);
|
||||
this.appendValueInput("year").appendField(Blockly.Msg.sensebox_rtc_year);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_set_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_rtc_set_ntp"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendValueInput("time").appendField(Blockly.Msg.sensebox_rtc_set_ntp);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_set_ntp_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_rtc_get"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_rtc_get)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.sensebox_rtc_hour, "hour"],
|
||||
[Blockly.Msg.sensebox_rtc_minutes, "minutes"],
|
||||
[Blockly.Msg.sensebox_rtc_second, "seconds"],
|
||||
[Blockly.Msg.sensebox_rtc_day, "day"],
|
||||
[Blockly.Msg.sensebox_rtc_month, "month"],
|
||||
[Blockly.Msg.sensebox_rtc_year, "year"],
|
||||
]),
|
||||
"dropdown"
|
||||
);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeName);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_get_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_rtc_get_timestamp"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_rtc_get_timestamp);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_get_timestamp_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal RTC
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_internal_rtc_init"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_internal_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_internal_rtc_init);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_internal_rtc_init_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_internal_rtc_set"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendValueInput("time").appendField(
|
||||
Blockly.Msg.sensebox_internal_rtc_set
|
||||
);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_internal_rtc_set_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_internal_rtc_get"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_internal_rtc_get)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.sensebox_internal_rtc_epoch, "Epoch"],
|
||||
[Blockly.Msg.sensebox_internal_rtc_year, "Year"],
|
||||
[Blockly.Msg.sensebox_internal_rtc_month, "Month"],
|
||||
[Blockly.Msg.sensebox_internal_rtc_day, "Day"],
|
||||
[Blockly.Msg.sensebox_internal_rtc_hour, "Hours"],
|
||||
[Blockly.Msg.sensebox_internal_rtc_minutes, "Minutes"],
|
||||
[Blockly.Msg.sensebox_internal_rtc_seconds, "Seconds"],
|
||||
]),
|
||||
"dropdown"
|
||||
);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeName);
|
||||
this.setTooltip(Blockly.Msg.sensebox_internal_rtc_get_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_internal_rtc_get_timestamp"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_internal_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(
|
||||
Blockly.Msg.sensebox_internal_rtc_get_timestamp
|
||||
);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_internal_rtc_get_timestamp_tooltip);
|
||||
},
|
||||
};
|
||||
@ -32,7 +32,7 @@ Blockly.Blocks["sensebox_sd_open_file"] = {
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sd_open_file_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_sd_helpurl);
|
||||
this.setHelpUrl("https://docs.sensebox.de/hardware/bee-sd/");
|
||||
},
|
||||
};
|
||||
|
||||
@ -41,7 +41,6 @@ Blockly.Blocks["sensebox_sd_create_file"] = {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_sd_create_file)
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_output_filename)
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput("Data", checkFileName),
|
||||
"Filename"
|
||||
@ -58,7 +57,7 @@ Blockly.Blocks["sensebox_sd_create_file"] = {
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sd_create_file_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_sd_helpurl);
|
||||
this.setHelpUrl("https://docs.sensebox.de/hardware/bee-sd/");
|
||||
},
|
||||
};
|
||||
|
||||
@ -75,7 +74,7 @@ Blockly.Blocks["sensebox_sd_write_file"] = {
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sd_write_file_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_sd_helpurl);
|
||||
this.setHelpUrl("https://docs.sensebox.de/hardware/bee-sd/");
|
||||
},
|
||||
/**
|
||||
* Called whenever anything on the workspace changes.
|
||||
@ -102,73 +101,3 @@ Blockly.Blocks["sensebox_sd_write_file"] = {
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_sd_open_file"],
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_sd_osem"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.sensebox_sd_osem_tip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_sd_helpurl);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.sensebox_sd_osem);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_osem_exposure)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_osem_stationary, "Stationary"],
|
||||
[Blockly.Msg.senseBox_osem_mobile, "Mobile"],
|
||||
]),
|
||||
"type"
|
||||
);
|
||||
this.appendValueInput("timeStamp", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_timeStamp
|
||||
);
|
||||
this.appendStatementInput("DO")
|
||||
.appendField(Blockly.Msg.sensebox_sd_measurement)
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.getField("type").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "Mobile");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
|
||||
updateShape_(isMobile) {
|
||||
if (isMobile) {
|
||||
if (this.getInput("lat") == null) {
|
||||
this.appendValueInput("lat", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lat,
|
||||
"gps"
|
||||
);
|
||||
this.appendValueInput("lng", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lng
|
||||
);
|
||||
this.appendValueInput("altitude", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_alt
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.removeInput("lat", true);
|
||||
this.removeInput("lng", true);
|
||||
this.removeInput("altitude", true);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_sd_save_for_osem"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.sensebox_sd_save_for_osem_tip);
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_sd_helpurl);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_sd_save_for_osem);
|
||||
this.appendValueInput("Value")
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.sensebox_sd_save_for_osem_id)
|
||||
.appendField(new Blockly.FieldTextInput("sensorID"), "SensorID");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,33 +1,26 @@
|
||||
import Blockly from "blockly";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Types from "../helpers/types";
|
||||
import { selectedBoard } from "../helpers/board";
|
||||
import { FieldGridDropdown } from "@blockly/field-grid-dropdown";
|
||||
import Blockly from 'blockly';
|
||||
import { getColour } from '../helpers/colour'
|
||||
import * as Types from '../helpers/types'
|
||||
import { selectedBoard } from '../helpers/board'
|
||||
|
||||
/**
|
||||
* HDC1080 Temperature and Humidity Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_temp_hum"] = {
|
||||
Blockly.Blocks['sensebox_sensor_temp_hum'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_temp_hum);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_temp_hum);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_temp, "Temperature"],
|
||||
[Blockly.Msg.senseBox_hum, "Humidity"],
|
||||
]),
|
||||
"NAME"
|
||||
);
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_temp, "Temperature"], [Blockly.Msg.senseBox_hum, "Humidity"]]), "NAME");
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_temp_hum_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_temp_hum_helpurl);
|
||||
this.data = {name: "hdc1080", connection: "I2C"};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -35,66 +28,44 @@ Blockly.Blocks["sensebox_sensor_temp_hum"] = {
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_uv_light"] = {
|
||||
|
||||
|
||||
Blockly.Blocks['sensebox_sensor_uv_light'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_uv_light);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_uv_light);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_light, "Illuminance"],
|
||||
[Blockly.Msg.senseBox_uv, "UvIntensity"],
|
||||
]),
|
||||
"NAME"
|
||||
);
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_light, "Illuminance"], [Blockly.Msg.senseBox_uv, "UvIntensity"]]), "NAME");
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_uv_light_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_uv_light_helpurl);
|
||||
this.data = {name: "veml6070"};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
BMX055 Three differen Blocks for Accelerometer, Gyroscope, Compass
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_bmx055_accelerometer"] = {
|
||||
Blockly.Blocks['sensebox_sensor_bmx055_accelerometer'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput().appendField(
|
||||
Blockly.Msg.senseBox_bmx055_accelerometer
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_bmx055_accelerometer);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_bmx055_accelerometer_direction)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_bmx055_accelerometer_direction_x, "X"],
|
||||
[Blockly.Msg.senseBox_bmx055_accelerometer_direction_y, "Y"],
|
||||
[Blockly.Msg.senseBox_bmx055_accelerometer_direction_z, "Z"],
|
||||
[Blockly.Msg.senseBox_bmx055_accelerometer_direction_total, "Total"],
|
||||
]),
|
||||
"VALUE"
|
||||
);
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_bmx055_accelerometer_direction_x, "X"], [Blockly.Msg.senseBox_bmx055_accelerometer_direction_y, "Y"], [Blockly.Msg.senseBox_bmx055_accelerometer_direction_z, "Z"], [Blockly.Msg.senseBox_bmx055_accelerometer_direction_total, "Total"]]), "VALUE");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_bmx055_accelerometer_range)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_bmx055_accelerometer_range_2g, "0x3"],
|
||||
[Blockly.Msg.senseBox_bmx055_accelerometer_range_4g, "0x5"],
|
||||
[Blockly.Msg.senseBox_bmx055_accelerometer_range_8g, "0x8"],
|
||||
[Blockly.Msg.senseBox_bmx055_accelerometer_range_16g, "0x0C"],
|
||||
]),
|
||||
"RANGE"
|
||||
);
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_bmx055_accelerometer_range_2g, "0x3"], [Blockly.Msg.senseBox_bmx055_accelerometer_range_4g, "0x5"], [Blockly.Msg.senseBox_bmx055_accelerometer_range_8g, "0x8"], [Blockly.Msg.senseBox_bmx055_accelerometer_range_16g, "0x0C"]]), "RANGE");
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_bmx055_accelerometer_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_bmx055_helpurl);
|
||||
this.data = {name: "bmx055"};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -102,55 +73,38 @@ Blockly.Blocks["sensebox_sensor_bmx055_accelerometer"] = {
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_sds011"] = {
|
||||
Blockly.Blocks['sensebox_sensor_sds011'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_sds011);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_sds011);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_sds011_pm25, "pm25"],
|
||||
[Blockly.Msg.senseBox_sds011_pm10, "pm10"],
|
||||
]),
|
||||
"NAME"
|
||||
)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_sds011_pm25, "Pm25"], [Blockly.Msg.senseBox_sds011_pm10, "Pm10"]]), "NAME")
|
||||
.appendField(Blockly.Msg.senseBox_sds011_dimension)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(
|
||||
selectedBoard().serialSensors),
|
||||
"SERIAL"
|
||||
);
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_sds011_serial1, "Serial1"], [Blockly.Msg.senseBox_sds011_serial2, "Serial2"]]), "SERIAL");
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sds011_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_sds011_helpurl);
|
||||
this.data = {name: "sds011"};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* BMP280 Pressure Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_pressure"] = {
|
||||
Blockly.Blocks['sensebox_sensor_pressure'] = {
|
||||
init: function () {
|
||||
var dropdownOptions = [
|
||||
[Blockly.Msg.senseBox_pressure, "Pressure"],
|
||||
[Blockly.Msg.senseBox_temp, "Temperature"],
|
||||
[Blockly.Msg.senseBox_gps_alt, "Altitude"],
|
||||
];
|
||||
var dropdown = new Blockly.FieldDropdown(dropdownOptions, function (
|
||||
option
|
||||
) {
|
||||
var input =
|
||||
option === "Pressure" ||
|
||||
option === "Temperature" ||
|
||||
option === "Altitude";
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_pressure, "Pressure"], [Blockly.Msg.senseBox_temp, "Temperature"], [Blockly.Msg.senseBox_gps_alt, "Altitude"]];
|
||||
var dropdown = new Blockly.FieldDropdown(dropdownOptions, function (option) {
|
||||
var input = (option === 'Pressure') || (option === 'Temperature') || (option === 'Altitude');
|
||||
this.sourceBlock_.updateShape_(input);
|
||||
});
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_pressure_sensor);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_pressure_sensor);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
@ -159,55 +113,72 @@ Blockly.Blocks["sensebox_sensor_pressure"] = {
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
this.setTooltip(Blockly.Msg.senseBox_pressure_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_pressure_helpurl);
|
||||
this.data = {name: "bmp280"};
|
||||
this.getField("NAME").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "Altitude");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
updateShape_(isAltitude) {
|
||||
if (isAltitude) {
|
||||
if (this.getInput("extraField") == null) {
|
||||
this.appendDummyInput("extraField")
|
||||
/**
|
||||
* Parse XML to restore the number of pins available.
|
||||
* @param {!Element} xmlElement XML storage element.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
|
||||
domToMutation: function (xmlElement) {
|
||||
(xmlElement.getAttribute('port'));
|
||||
|
||||
},
|
||||
/**
|
||||
* Create XML to represent number of pins selection.
|
||||
* @return {!Element} XML storage element.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
mutationToDom: function () {
|
||||
var container = document.createElement('mutation');
|
||||
var input = this.getFieldValue('NAME');
|
||||
this.updateShape_(input);
|
||||
container.setAttribute('NAME', input);
|
||||
return container;
|
||||
},
|
||||
/**
|
||||
* Modify this block to have the correct number of pins available.
|
||||
* @param {boolean}
|
||||
* @private
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
updateShape_: function () {
|
||||
var extraFieldExist = this.getFieldValue('referencePressure');
|
||||
var input = this.getFieldValue('NAME');
|
||||
if (input === 'Altitude' && extraFieldExist === null) {
|
||||
this.appendDummyInput('extraField')
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure)
|
||||
.appendField(new Blockly.FieldTextInput("1013"), "referencePressure")
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure_dim);
|
||||
}
|
||||
} else {
|
||||
this.removeInput("extraField", true);
|
||||
|
||||
if ((input === 'Pressure' || input === 'Temperature') && extraFieldExist !== null) {
|
||||
this.removeInput('extraField');
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* BME680 Environmental Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_bme680_bsec"] = {
|
||||
Blockly.Blocks['sensebox_sensor_bme680_bsec'] = {
|
||||
init: function () {
|
||||
var dropdownOptions = [
|
||||
[Blockly.Msg.senseBox_temp, "temperature"],
|
||||
[Blockly.Msg.senseBox_hum, "humidity"],
|
||||
[Blockly.Msg.senseBox_bme_pressure, "pressure"],
|
||||
[Blockly.Msg.senseBox_bme_iaq, "IAQ"],
|
||||
[Blockly.Msg.senseBox_bme_iaq_accuracy, "IAQAccuracy"],
|
||||
[Blockly.Msg.senseBox_bme_co2, "CO2"],
|
||||
[Blockly.Msg.senseBox_bme_breatheVocEquivalent, "breathVocEquivalent"],
|
||||
];
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_bme680);
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_temp, "temperature"], [Blockly.Msg.senseBox_hum, "humidity"], [Blockly.Msg.senseBox_pressure, "pressure"], [Blockly.Msg.senseBox_bme_iaq, "IAQ"], [Blockly.Msg.senseBox_bme_iaq_accuracy, "IAQAccuracy"], [Blockly.Msg.senseBox_bme_co2, "CO2"], [Blockly.Msg.senseBox_bme_breatheVocEquivalent, "breathVocEquivalent"]];
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_bme680);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "dropdown");
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "dropdown")
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_bme_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_bme680_helpurl);
|
||||
this.data = {name: "bme680"};
|
||||
},
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_bme680_helpurl)
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -216,10 +187,14 @@ Blockly.Blocks["sensebox_sensor_bme680_bsec"] = {
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_ultrasonic_ranger"] = {
|
||||
|
||||
Blockly.Blocks['sensebox_sensor_ultrasonic_ranger'] = {
|
||||
init: function () {
|
||||
var dropdown = new FieldGridDropdown(selectedBoard().digitalPorts, function (option) {
|
||||
var input = option === "A" || option === "B" || option === "C";
|
||||
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_ultrasonic_port_A, 'A'],
|
||||
[Blockly.Msg.senseBox_ultrasonic_port_B, 'B'], [Blockly.Msg.senseBox_ultrasonic_port_C, 'C']];
|
||||
var dropdown = new Blockly.FieldDropdown(dropdownOptions, function (option) {
|
||||
var input = (option === 'A') || (option === 'B') || (option === 'C');
|
||||
this.sourceBlock_.updateShape_(input);
|
||||
});
|
||||
|
||||
@ -227,26 +202,17 @@ Blockly.Blocks["sensebox_sensor_ultrasonic_ranger"] = {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_ultrasonic)
|
||||
.appendField(dropdown, "port");
|
||||
this.appendDummyInput("TrigEcho")
|
||||
this.appendDummyInput('TrigEcho')
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_ultrasonic_trigger)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(selectedBoard().digitalPins),
|
||||
"ultrasonic_trigger"
|
||||
)
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
selectedBoard().digitalPins), 'ultrasonic_trigger')
|
||||
.appendField(Blockly.Msg.senseBox_ultrasonic_echo)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(selectedBoard().digitalPins),
|
||||
"ultrasonic_echo"
|
||||
);
|
||||
this.appendDummyInput("maxDistance")
|
||||
.appendField(Blockly.Msg.senseBox_ultrasonic_maxDistance)
|
||||
.appendField(new Blockly.FieldTextInput("250"), "maxDistance")
|
||||
.appendField("cm");
|
||||
.appendField(new Blockly.FieldDropdown(
|
||||
selectedBoard().digitalPins), 'ultrasonic_echo');
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.setTooltip(Blockly.Msg.senseBox_ultrasonic_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_ultrasonic_helpurl);
|
||||
this.data = {name: "hc-sr04"};
|
||||
},
|
||||
/**
|
||||
* Parse XML to restore the number of pins available.
|
||||
@ -254,7 +220,8 @@ Blockly.Blocks["sensebox_sensor_ultrasonic_ranger"] = {
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
domToMutation: function (xmlElement) {
|
||||
xmlElement.getAttribute("port");
|
||||
(xmlElement.getAttribute('port'));
|
||||
|
||||
},
|
||||
/**
|
||||
* Create XML to represent number of pins selection.
|
||||
@ -262,8 +229,8 @@ Blockly.Blocks["sensebox_sensor_ultrasonic_ranger"] = {
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
mutationToDom: function () {
|
||||
var container = document.createElement("mutation");
|
||||
var input = this.getFieldValue("port");
|
||||
var container = document.createElement('mutation');
|
||||
var input = this.getFieldValue('port');
|
||||
this.updateShape_(input);
|
||||
container.setAttribute("port", input);
|
||||
return container;
|
||||
@ -275,199 +242,159 @@ Blockly.Blocks["sensebox_sensor_ultrasonic_ranger"] = {
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
updateShape_: function () {
|
||||
var input = this.getFieldValue("port");
|
||||
var input = this.getFieldValue('port');
|
||||
switch (input) {
|
||||
case "A":
|
||||
this.setFieldValue("1", "ultrasonic_trigger");
|
||||
this.setFieldValue("2", "ultrasonic_echo");
|
||||
case 'A':
|
||||
this.setFieldValue('1', 'ultrasonic_trigger');
|
||||
this.setFieldValue('2', 'ultrasonic_echo');
|
||||
break;
|
||||
case "B":
|
||||
this.setFieldValue("3", "ultrasonic_trigger");
|
||||
this.setFieldValue("4", "ultrasonic_echo");
|
||||
case 'B':
|
||||
this.setFieldValue('3', 'ultrasonic_trigger');
|
||||
this.setFieldValue('4', 'ultrasonic_echo');
|
||||
break;
|
||||
case "C":
|
||||
this.setFieldValue("5", "ultrasonic_trigger");
|
||||
this.setFieldValue("6", "ultrasonic_echo");
|
||||
case 'C':
|
||||
this.setFieldValue('5', 'ultrasonic_trigger');
|
||||
this.setFieldValue('6', 'ultrasonic_echo');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Microphone
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_sound"] = {
|
||||
Blockly.Blocks['sensebox_sensor_sound'] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_sound)
|
||||
.appendField("Pin:")
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(selectedBoard().analogPins),
|
||||
"PIN"
|
||||
);
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().analogPins), "PIN")
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_sound_helpurl);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sound_tooltip);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Button
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_button"] = {
|
||||
Blockly.Blocks['sensebox_button'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_button)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_button_isPressed, "isPressed"],
|
||||
[Blockly.Msg.senseBox_button_wasPressed, "wasPressed"],
|
||||
[Blockly.Msg.senseBox_button_longPress, "longPress"],
|
||||
[Blockly.Msg.senseBox_button_switch,"toggleButton"]
|
||||
]),
|
||||
"FUNCTION"
|
||||
)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_button_isPressed, "isPressed"], [Blockly.Msg.senseBox_button_wasPressed, "wasPressed"], [Blockly.Msg.senseBox_button_switch, "Switch"]]), "FUNCTION")
|
||||
.appendField("Pin:")
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(selectedBoard().digitalPinsButton),
|
||||
"PIN"
|
||||
);
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPinsButton), "PIN");
|
||||
this.setOutput(true, Types.BOOLEAN.typeName);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_button_tooltip);
|
||||
this.getField("FUNCTION").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "longPress");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
updateShape_(isLongPress) {
|
||||
if (isLongPress) {
|
||||
if (this.getInput("extraField") == null) {
|
||||
this.appendDummyInput("extraField")
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_button_longPress_time)
|
||||
.appendField(new Blockly.FieldTextInput("1000"), "time")
|
||||
.appendField("ms");
|
||||
}
|
||||
} else {
|
||||
this.removeInput("extraField", true);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* SCD30 CO2 Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_scd30"] = {
|
||||
|
||||
Blockly.Blocks['sensebox_scd30'] = {
|
||||
init: function () {
|
||||
var dropdownOptions = [
|
||||
[Blockly.Msg.senseBox_scd_co2, "CO2"],
|
||||
[Blockly.Msg.senseBox_temp, "temperature"],
|
||||
[Blockly.Msg.senseBox_hum, "humidity"],
|
||||
];
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_scd30);
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_scd_co2, "CO2"], [Blockly.Msg.senseBox_temp, "temperature"], [Blockly.Msg.senseBox_hum, "humidity"]];
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_scd30);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "dropdown");
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "dropdown")
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_scd_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_scd_helpurl);
|
||||
this.data = {name: "scd30"};
|
||||
},
|
||||
onchange: function (e) {
|
||||
var dropdown = this.getFieldValue("dropdown");
|
||||
if (dropdown === "temperature" || dropdown === "humidity") {
|
||||
var dropdown = this.getFieldValue('dropdown');
|
||||
if (dropdown === 'temperature' || dropdown === 'humidity') {
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
} else if (dropdown === "CO2") {
|
||||
} else if (dropdown === 'CO2') {
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* GPS Module
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_gps"] = {
|
||||
|
||||
Blockly.Blocks['sensebox_gps'] = {
|
||||
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"],
|
||||
[Blockly.Msg.senseBox_gps_speed, "speed"],
|
||||
["pDOP", "pDOP"],
|
||||
["Fix Type", "fixType"],
|
||||
];
|
||||
this.appendDummyInput().appendField("GPS Modul");
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_gps_lat, "latitude"], [Blockly.Msg.senseBox_gps_lng, "longitude"], [Blockly.Msg.senseBox_gps_alt, "altitude"], ["pDOP", "pDOP"], ["Fix Type", "fixType"]];
|
||||
this.appendDummyInput()
|
||||
.appendField("GPS Modul");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "dropdown");
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "dropdown")
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_gps_tooltip);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Block for Truebner STM50
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_truebner_smt50"] = {
|
||||
Blockly.Blocks['sensebox_sensor_truebner_smt50'] = {
|
||||
init: function () {
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_ultrasonic_port_A, 'A'],
|
||||
[Blockly.Msg.senseBox_ultrasonic_port_B, 'B'], [Blockly.Msg.senseBox_ultrasonic_port_C, 'C']];
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_smt50);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_smt50);
|
||||
this.appendDummyInput()
|
||||
.appendField("Port:")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPorts), "Port");
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_temp, "temp"],
|
||||
[Blockly.Msg.senseBox_soil, "soil"],
|
||||
]),
|
||||
"value"
|
||||
);
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.senseBox_temp, "temp"], [Blockly.Msg.senseBox_soil, "soil"]]), 'value')
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.setTooltip(Blockly.Msg.senseBox_smt50_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_smt50_helpurl);
|
||||
this.data = {name: "smt50"};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* DS18B20 Watertemperature
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_watertemperature"] = {
|
||||
Blockly.Blocks['sensebox_sensor_watertemperature'] = {
|
||||
init: function () {
|
||||
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_ultrasonic_port_A, 'A'],
|
||||
[Blockly.Msg.senseBox_ultrasonic_port_B, 'B'], [Blockly.Msg.senseBox_ultrasonic_port_C, 'C']];
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_watertemperature)
|
||||
.appendField("Port:")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPorts), "Port");
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port")
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.setTooltip(Blockly.Msg.senseBox_watertemperature_tip);
|
||||
this.data = {name: "ds18b20"};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -491,95 +418,18 @@ Blockly.Blocks['sensebox_windspeed'] = {
|
||||
* DF Robot Soundsensor
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_soundsensor_dfrobot"] = {
|
||||
|
||||
Blockly.Blocks['sensebox_soundsensor_dfrobot'] = {
|
||||
init: function () {
|
||||
var dropdownOptions = [[Blockly.Msg.senseBox_ultrasonic_port_A, 'A'],
|
||||
[Blockly.Msg.senseBox_ultrasonic_port_B, 'B'], [Blockly.Msg.senseBox_ultrasonic_port_C, 'C']];
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_soundsensor_dfrobot)
|
||||
.appendField("Port:")
|
||||
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPorts), "Port");
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port")
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
this.setTooltip(Blockly.Msg.senseBox_soundsensor_dfrobot_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_soundsensor_dfrobot_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Infineon DPS310 Pressure Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_dps310"] = {
|
||||
init: function () {
|
||||
var dropdownOptions = [
|
||||
[Blockly.Msg.senseBox_pressure, "Pressure"],
|
||||
[Blockly.Msg.senseBox_temp, "Temperature"],
|
||||
[Blockly.Msg.senseBox_gps_alt, "Altitude"],
|
||||
];
|
||||
var dropdown = new Blockly.FieldDropdown(dropdownOptions, function (
|
||||
option
|
||||
) {
|
||||
var input =
|
||||
option === "Pressure" ||
|
||||
option === "Temperature" ||
|
||||
option === "Altitude";
|
||||
this.sourceBlock_.updateShape_(input);
|
||||
});
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_sensor_dps310);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(dropdown, "NAME");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sensor_dps310_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_sensor_dps310_helpurl);
|
||||
this.data = {name: "dps310"};
|
||||
this.getField("NAME").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "Altitude");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
updateShape_(isAltitude) {
|
||||
if (isAltitude) {
|
||||
if (this.getInput("extraField") == null) {
|
||||
this.appendDummyInput("extraField")
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure)
|
||||
.appendField(new Blockly.FieldTextInput("1013"), "referencePressure")
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure_dim);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_soundsensor_dfrobot_helpurl)
|
||||
}
|
||||
} else {
|
||||
this.removeInput("extraField", true);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Sensirion SPS30 Fine Particular Matter Sensor
|
||||
* added 02.12.2022
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_sps30"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_sps30);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_sps30_1p0, "1p0"],
|
||||
[Blockly.Msg.senseBox_sps30_2p5, "2p5"],
|
||||
[Blockly.Msg.senseBox_sps30_4p0, "4p0"],
|
||||
[Blockly.Msg.senseBox_sps30_10p0, "10p0"],
|
||||
]),
|
||||
"value"
|
||||
)
|
||||
.appendField(Blockly.Msg.senseBox_sps30_dimension);
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sps30_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_sps30_helpurl);
|
||||
},
|
||||
};
|
||||
@ -1,13 +1,13 @@
|
||||
import Blockly from "blockly";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Types from "../helpers/types";
|
||||
import Blockly from 'blockly';
|
||||
import { getColour } from '../helpers/colour'
|
||||
|
||||
Blockly.Blocks["sensebox_wifi"] = {
|
||||
Blockly.Blocks['sensebox_wifi'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_wifi_tooltip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_connect);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_wifi_connect);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_wifi_ssid)
|
||||
@ -16,7 +16,7 @@ Blockly.Blocks["sensebox_wifi"] = {
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_output_password)
|
||||
.appendField(new Blockly.FieldTextInput("Password"), "Password");
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_wifi_helpurl);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_wifi_helpurl)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
@ -33,121 +33,28 @@ Blockly.Blocks["sensebox_wifi"] = {
|
||||
} while (block);
|
||||
if (legal) {
|
||||
this.setWarningText(null);
|
||||
|
||||
} else {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ["arduino_functions"],
|
||||
LOOP_TYPES: ['arduino_functions'],
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_startap"] = {
|
||||
Blockly.Blocks['sensebox_startap'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_wifi_startap_tooltip);
|
||||
this.setHelpUrl("");
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_startap);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_wifi_startap);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_wifi_ssid)
|
||||
.appendField(new Blockly.FieldTextInput("SSID"), "SSID");
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_wifi_helpurl);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_wifi_helpurl)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_ethernet"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_ethernet_tooltip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_ethernet)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.senseBox_ethernet_dhcp, "Dhcp"],
|
||||
[Blockly.Msg.senseBox_ethernet_manuel_config, "Manual"],
|
||||
]),
|
||||
"dhcp"
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_ethernet_mac)
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput("0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED"),
|
||||
"mac"
|
||||
);
|
||||
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_ethernet_helpurl);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.getField("dhcp").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "Manual");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
|
||||
updateShape_(isManual) {
|
||||
if (isManual) {
|
||||
this.appendDummyInput("ip-field")
|
||||
.appendField(Blockly.Msg.senseBox_ethernet_ip)
|
||||
.appendField(new Blockly.FieldTextInput("192.168.1.100"), "ip");
|
||||
this.appendDummyInput("subnetmask-field")
|
||||
.appendField(Blockly.Msg.senseBox_ethernet_subnetmask)
|
||||
.appendField(new Blockly.FieldTextInput("255.255.255.0"), "subnetmask");
|
||||
this.appendDummyInput("gateway-field")
|
||||
.appendField(Blockly.Msg.senseBox_ethernet_gateway)
|
||||
.appendField(new Blockly.FieldTextInput("192.168.1.1"), "gateway");
|
||||
this.appendDummyInput("dns-field")
|
||||
.appendField(Blockly.Msg.senseBox_ethernet_dns)
|
||||
.appendField(new Blockly.FieldTextInput("8.8.8.8"), "dns");
|
||||
} else {
|
||||
this.removeInput("ip-field", true);
|
||||
this.removeInput("subnetmask-field", true);
|
||||
this.removeInput("gateway-field", true);
|
||||
this.removeInput("dns-field", true);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_ethernetIp"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_ethernet_ip);
|
||||
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_ethernetIp_helpurl);
|
||||
this.setTooltip(Blockly.Msg.senseBox_ethernet_ip_tooltip);
|
||||
this.setOutput(true, null);
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_wifi_status"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_wifi_status_tooltip);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_status);
|
||||
this.setOutput(true, Types.BOOLEAN.typeName);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_wifi_status_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_get_ip"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_wifi_ip_tooltip);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_ip);
|
||||
this.setOutput(true, Types.TEXT.typeName);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_wifi_ip_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_wifi_rssi"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_wifi_rssi_tooltip);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_rssi);
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_wifi_rssi_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -1,36 +1,4 @@
|
||||
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,47 +0,0 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import { selectedBoard } from "../helpers/board";
|
||||
|
||||
Blockly.Blocks["init_serial_monitor"] = {
|
||||
init: function () {
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setColour(getColour().serial);
|
||||
this.setHelpUrl("http://arduino.cc/en/Serial/Begin");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_SERIAL_SETUP)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(selectedBoard().serial),
|
||||
"SERIAL_ID"
|
||||
)
|
||||
.appendField(Blockly.Msg.ARD_SERIAL_SPEED)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(selectedBoard().serialSpeed),
|
||||
"SPEED"
|
||||
)
|
||||
.appendField(Blockly.Msg.ARD_SERIAL_BPS);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.ARD_SERIAL_SETUP_TIP);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["print_serial_monitor"] = {
|
||||
init: function () {
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setColour(getColour().serial);
|
||||
this.setHelpUrl("http://www.arduino.cc/en/Serial/Print");
|
||||
this.appendDummyInput()
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(selectedBoard().serial),
|
||||
"SERIAL_ID"
|
||||
)
|
||||
.appendField(Blockly.Msg.ARD_SERIAL_PRINT);
|
||||
this.appendValueInput("CONTENT");
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldCheckbox("TRUE"), "NEW_LINE")
|
||||
.appendField(Blockly.Msg.ARD_SERIAL_PRINT_NEWLINE);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.ARD_SERIAL_PRINT_TIP);
|
||||
},
|
||||
};
|
||||
@ -59,7 +59,7 @@ Blockly.Blocks["time_millis"] = {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/Millis");
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_MILLIS);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeName);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_MILLIS_TIP);
|
||||
},
|
||||
/** @return {string} The type of return value for the block, an integer. */
|
||||
@ -77,7 +77,7 @@ Blockly.Blocks["time_micros"] = {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/Micros");
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_MICROS);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeName);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_MICROS_TIP);
|
||||
},
|
||||
/**
|
||||
@ -104,23 +104,6 @@ Blockly.Blocks["infinite_loop"] = {
|
||||
},
|
||||
};
|
||||
|
||||
// Blockly.Blocks["sensebox_interval_timer"] = {
|
||||
// init: function () {
|
||||
// this.setTooltip(Blockly.Msg.senseBox_interval_timer_tip);
|
||||
// this.setInputsInline(true);
|
||||
// this.setHelpUrl("");
|
||||
// this.setColour(getColour().time);
|
||||
// this.appendDummyInput().appendField(Blockly.Msg.senseBox_interval_timer);
|
||||
// this.appendDummyInput()
|
||||
// .setAlign(Blockly.ALIGN_LEFT)
|
||||
// .appendField(new Blockly.FieldTextInput("10000"), "interval")
|
||||
// .appendField(Blockly.Msg.senseBox_interval);
|
||||
// this.appendStatementInput("DO").setCheck(null);
|
||||
// this.setPreviousStatement(true, null);
|
||||
// this.setNextStatement(true, null);
|
||||
// },
|
||||
// };
|
||||
|
||||
Blockly.Blocks["sensebox_interval_timer"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_interval_timer_tip);
|
||||
@ -129,7 +112,7 @@ Blockly.Blocks["sensebox_interval_timer"] = {
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_interval_timer)
|
||||
.appendField(new Blockly.FieldTextInput("Interval"), "name");
|
||||
.appendField(new Blockly.FieldTextInput("name"), "name");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_interval_time)
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
|
||||
@ -9,20 +9,18 @@ Blockly.Blocks["variables_set_dynamic"] = {
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.appendValueInput("VALUE")
|
||||
.appendField(Blockly.Msg.variables_set, Blockly.Msg.variables_set)
|
||||
.appendField("set", "set")
|
||||
.appendField("", "type")
|
||||
.appendField(new Blockly.FieldVariable("VAR"), "VAR")
|
||||
.appendField(Blockly.Msg.variables_to);
|
||||
.appendField("to");
|
||||
},
|
||||
onchange: function (e) {
|
||||
let variableID = this.getFieldValue("VAR");
|
||||
let variable = Blockly.getMainWorkspace()
|
||||
.getVariableMap()
|
||||
.getVariableById(variableID);
|
||||
if (variable !== null) {
|
||||
this.getField("type").setValue(variable.type);
|
||||
this.getInput("VALUE").setCheck(getCompatibleTypes(variable.type));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -39,8 +37,7 @@ Blockly.Blocks["variables_get_dynamic"] = {
|
||||
let variable = Blockly.getMainWorkspace()
|
||||
.getVariableMap()
|
||||
.getVariableById(variableID);
|
||||
if (variable !== null) {
|
||||
this.getField("type").setValue(variable.type);
|
||||
}
|
||||
this.setOutput(true, variable.type);
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
import Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
|
||||
Blockly.Blocks["watchdog_enable"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField("Watchdog aktivieren")
|
||||
.appendField(new Blockly.FieldTextInput("10000"), "TIME")
|
||||
.appendField("ms");
|
||||
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().io);
|
||||
this.setTooltip("");
|
||||
this.setHelpUrl("");
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["watchdog_reset"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput().appendField("Watchdog zurücksetzen");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().io);
|
||||
this.setTooltip("");
|
||||
this.setHelpUrl("");
|
||||
},
|
||||
};
|
||||
@ -1,61 +0,0 @@
|
||||
import Blockly from "blockly";
|
||||
|
||||
/**
|
||||
* starte/stoppe Pumpe
|
||||
*
|
||||
*/
|
||||
Blockly.Arduino.CleVerLab_pump = function (block) {
|
||||
var pin = block.getFieldValue('DigitalPin');
|
||||
var state = block.getFieldValue("Mode");
|
||||
Blockly['Arduino'].setupCode_['pinMode'] = 'pinMode(' + pin + ', OUTPUT);';
|
||||
var code = 'digitalWrite(' + pin + ', ' + state + ');\n';
|
||||
return code;
|
||||
};
|
||||
/**
|
||||
* PH wert
|
||||
*
|
||||
*/
|
||||
Blockly.Arduino.CleVerLab_temperature = function () {
|
||||
var dropdown_pin = this.getFieldValue("DigitalPort");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["library_oneWire"] =
|
||||
"#include <OneWire.h> // http://librarymanager/All#OneWire";
|
||||
Blockly.Arduino.libraries_["library_oneDallasTemperature"] =
|
||||
"#include <DallasTemperature.h> // http://librarymanager/All#DallasTemperature";
|
||||
Blockly.Arduino.definitions_["define_OneWire"] =
|
||||
"#define ONE_WIRE_BUS " +
|
||||
dropdown_pin +
|
||||
"\nOneWire oneWire(ONE_WIRE_BUS);\nDallasTemperature sensors(&oneWire);";
|
||||
Blockly.Arduino.setupCode_["sensebox_oneWireSetup"] = "sensors.begin();";
|
||||
Blockly.Arduino.codeFunctions_["sensebox_requestTemp"] =
|
||||
"float getWaterTemp(){\nsensors.requestTemperatures();\nsensors.getTempCByIndex(0);\n}";
|
||||
var code = "getWaterTemp()";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
Blockly.Arduino.CleVerLab_pH = function () {
|
||||
var dropdown_pin = this.getFieldValue("DigitalPin");
|
||||
Blockly.Arduino.definitions_["define_pHgetter"] =
|
||||
"#define SensorPin " + dropdown_pin +"\n#define samplingInterval 20\n#define printInterval 800\n#define ArrayLenth 40 //times of collection\nint pHArray[ArrayLenth]; //Store the average value of the sensor feedback\nint pHArrayIndex=0;\nfloat slope = 1.00;\nfloat b =0.00;";
|
||||
Blockly.Arduino.codeFunctions_["sensebox_requestpH"] =
|
||||
"float getpH(){\nstatic unsigned long samplingTime = millis();\nstatic unsigned long printTime = millis();\nstatic float pHValue,voltage;\n//nif(millis()-samplingTime > samplingInterval){\n//pHArray[pHArrayIndex++]=analogRead(SensorPin);\nfor (int i = 1; i <= 10; i += 1) {\nvoltage = voltage + analogRead(SensorPin);\n}\n voltage = (voltage / 10)*5.0/1024; \nsamplingTime=millis();\n\nreturn pHValue = 3.5*voltage*slope+b;\n}\n";
|
||||
Blockly.Arduino.codeFunctions_["avergearraypH"] =
|
||||
"double avergearray(int* arr, int number) {\n int i;\n int max, min;\n double avg;\n long amount = 0;\n if (number <= 0) {\n return 0;\n }\n if (number < 5) {\n for (i = 0; i < number; i++) {\n amount += arr[i];\n }\n avg = amount / number;\n return avg;\n }\n else {\n if (arr[0] < arr[1]) {\n min = arr[0];\n max = arr[1];\n }\n else {\n min = arr[1];\n max = arr[0];\n }\n for (i = 2; i < number; i++) {\n if (arr[i] < min) {\n amount += min;\n min = arr[i];\n }\n else {\n if (arr[i] > max) {\n amount += max;\n max = arr[i];\n }\n else {\n amount += arr[i];\n }\n }\n }\n avg = (double)amount / (number - 2);\n }\n return avg;\n}";
|
||||
var code = "getpH()";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.CleVerLab_cali1 = function () {
|
||||
var var1 = Blockly.Arduino.valueToCode(this, 'VAR1', Blockly.Arduino.ORDER_ATOMIC) || "4.00";
|
||||
var var2 = Blockly.Arduino.valueToCode(this, 'VAR2', Blockly.Arduino.ORDER_ATOMIC) || "7.00";
|
||||
//var var1 = this.getFieldValue("VAR1");
|
||||
//var var2 = this.getFieldValue("VAR2");
|
||||
Blockly.Arduino.definitions_["define_pHKali"] = "#define pH4 4.00\n#define pH7 7.00\nfloat pH4is = "+ var1+";\nfloat pH7is = "+ var2 +";";
|
||||
Blockly.Arduino.setupCode_["asdsadsa"] ="slope = (2.00-(4.00/3.50))/(pH7is/3.50 - pH4is/3.50);\n b = 7 - (pH7is * slope);";
|
||||
var code = "0";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -24,24 +24,13 @@
|
||||
// More on generating code:
|
||||
// https://developers.google.com/blockly/guides/create-custom-blocks/generating-code
|
||||
|
||||
import * as Blockly from "blockly/core";
|
||||
|
||||
import store from "../../../store";
|
||||
|
||||
var ota = store.getState().general.platform
|
||||
? store.getState().general.platform
|
||||
: null;
|
||||
store.subscribe(() => {
|
||||
ota = store.getState().general.platform
|
||||
? store.getState().general.platform
|
||||
: null;
|
||||
});
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
/**
|
||||
* Arduino code generator.
|
||||
* @type !Blockly.Generator
|
||||
*/
|
||||
Blockly["Arduino"] = new Blockly.Generator("Arduino");
|
||||
Blockly['Arduino'] = new Blockly.Generator('Arduino');
|
||||
|
||||
/**
|
||||
* List of illegal variable names.
|
||||
@ -50,44 +39,49 @@ Blockly["Arduino"] = new Blockly.Generator("Arduino");
|
||||
* accidentally clobbering a built-in object or function.
|
||||
* @private
|
||||
*/
|
||||
Blockly["Arduino"].addReservedWords(
|
||||
Blockly['Arduino'].addReservedWords(
|
||||
// http://arduino.cc/en/Reference/HomePage
|
||||
"setup,loop,if,else,for,switch,case,while," +
|
||||
"do,break,continue,return,goto,define,include," +
|
||||
"HIGH,LOW,INPUT,OUTPUT,INPUT_PULLUP,true,false," +
|
||||
"interger, constants,floating,point,void,boolean,char," +
|
||||
"unsigned,byte,int,word,long,float,double,string,String,array," +
|
||||
"static, volatile,const,sizeof,pinMode,digitalWrite,digitalRead," +
|
||||
"analogReference,analogRead,analogWrite,tone,noTone,shiftOut,shitIn," +
|
||||
"pulseIn,millis,micros,delay,delayMicroseconds,min,max,abs,constrain," +
|
||||
"map,pow,sqrt,sin,cos,tan,randomSeed,random,lowByte,highByte,bitRead," +
|
||||
"bitWrite,bitSet,bitClear,ultraSonicDistance,parseDouble,setNeoPixelColor," +
|
||||
"bit,attachInterrupt,detachInterrupt,interrupts,noInterrupts,short,isBtnPressed"
|
||||
'setup,loop,if,else,for,switch,case,while,' +
|
||||
'do,break,continue,return,goto,define,include,' +
|
||||
'HIGH,LOW,INPUT,OUTPUT,INPUT_PULLUP,true,false,' +
|
||||
'interger, constants,floating,point,void,boolean,char,' +
|
||||
'unsigned,byte,int,word,long,float,double,string,String,array,' +
|
||||
'static, volatile,const,sizeof,pinMode,digitalWrite,digitalRead,' +
|
||||
'analogReference,analogRead,analogWrite,tone,noTone,shiftOut,shitIn,' +
|
||||
'pulseIn,millis,micros,delay,delayMicroseconds,min,max,abs,constrain,' +
|
||||
'map,pow,sqrt,sin,cos,tan,randomSeed,random,lowByte,highByte,bitRead,' +
|
||||
'bitWrite,bitSet,bitClear,ultraSonicDistance,parseDouble,setNeoPixelColor,' +
|
||||
'bit,attachInterrupt,detachInterrupt,interrupts,noInterrupts',
|
||||
'short',
|
||||
'isBtnPressed'
|
||||
);
|
||||
|
||||
/**
|
||||
* Order of operation ENUMs.
|
||||
*
|
||||
*/
|
||||
Blockly["Arduino"].ORDER_ATOMIC = 0; // 0 "" ...
|
||||
Blockly["Arduino"].ORDER_UNARY_POSTFIX = 1; // expr++ expr-- () [] .
|
||||
Blockly["Arduino"].ORDER_UNARY_PREFIX = 2; // -expr !expr ~expr ++expr --expr
|
||||
Blockly["Arduino"].ORDER_MULTIPLICATIVE = 3; // * / % ~/
|
||||
Blockly["Arduino"].ORDER_ADDITIVE = 4; // + -
|
||||
Blockly["Arduino"].ORDER_LOGICAL_NOT = 4.4; // !
|
||||
Blockly["Arduino"].ORDER_SHIFT = 5; // << >>
|
||||
Blockly["Arduino"].ORDER_MODULUS = 5.3; // %
|
||||
Blockly["Arduino"].ORDER_RELATIONAL = 6; // is is! >= > <= <
|
||||
Blockly["Arduino"].ORDER_EQUALITY = 7; // === !== === !==
|
||||
Blockly["Arduino"].ORDER_BITWISE_AND = 8; // &
|
||||
Blockly["Arduino"].ORDER_BITWISE_XOR = 9; // ^
|
||||
Blockly["Arduino"].ORDER_BITWISE_OR = 10; // |
|
||||
Blockly["Arduino"].ORDER_LOGICAL_AND = 11; // &&
|
||||
Blockly["Arduino"].ORDER_LOGICAL_OR = 12; // ||
|
||||
Blockly["Arduino"].ORDER_CONDITIONAL = 13; // expr ? expr : expr
|
||||
Blockly["Arduino"].ORDER_ASSIGNMENT = 14; // = *= /= ~/= %= += -= <<= >>= &= ^= |=
|
||||
Blockly["Arduino"].ORDER_COMMA = 18; // ,
|
||||
Blockly["Arduino"].ORDER_NONE = 99; // (...)
|
||||
Blockly['Arduino'].ORDER_ATOMIC = 0; // 0 "" ...
|
||||
Blockly['Arduino'].ORDER_UNARY_POSTFIX = 1; // expr++ expr-- () [] .
|
||||
Blockly['Arduino'].ORDER_UNARY_PREFIX = 2; // -expr !expr ~expr ++expr --expr
|
||||
Blockly['Arduino'].ORDER_MULTIPLICATIVE = 3; // * / % ~/
|
||||
Blockly['Arduino'].ORDER_ADDITIVE = 4; // + -
|
||||
Blockly['Arduino'].ORDER_LOGICAL_NOT = 4.4; // !
|
||||
Blockly['Arduino'].ORDER_SHIFT = 5; // << >>
|
||||
Blockly['Arduino'].ORDER_MODULUS = 5.3; // %
|
||||
Blockly['Arduino'].ORDER_RELATIONAL = 6; // is is! >= > <= <
|
||||
Blockly['Arduino'].ORDER_EQUALITY = 7; // === !== === !==
|
||||
Blockly['Arduino'].ORDER_BITWISE_AND = 8; // &
|
||||
Blockly['Arduino'].ORDER_BITWISE_XOR = 9; // ^
|
||||
Blockly['Arduino'].ORDER_BITWISE_OR = 10; // |
|
||||
Blockly['Arduino'].ORDER_LOGICAL_AND = 11; // &&
|
||||
Blockly['Arduino'].ORDER_LOGICAL_OR = 12; // ||
|
||||
Blockly['Arduino'].ORDER_CONDITIONAL = 13; // expr ? expr : expr
|
||||
Blockly['Arduino'].ORDER_ASSIGNMENT = 14; // = *= /= ~/= %= += -= <<= >>= &= ^= |=
|
||||
Blockly['Arduino'].ORDER_COMMA = 18; // ,
|
||||
Blockly['Arduino'].ORDER_NONE = 99; // (...)
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@ -96,59 +90,105 @@ Blockly["Arduino"].ORDER_NONE = 99; // (...)
|
||||
* Blockly Types
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the database of variable names.
|
||||
* @param {!Blockly.Workspace} workspace Workspace to generate code from.
|
||||
*/
|
||||
Blockly["Arduino"].init = function (workspace) {
|
||||
Blockly['Arduino'].init = function (workspace) {
|
||||
// Create a dictionary of definitions to be printed before the code.
|
||||
Blockly["Arduino"].libraries_ = Object.create(null);
|
||||
Blockly['Arduino'].libraries_ = Object.create(null);
|
||||
|
||||
Blockly["Arduino"].definitions_ = Object.create(null);
|
||||
Blockly['Arduino'].definitions_ = Object.create(null);
|
||||
|
||||
// creates a list of code to be setup before the setup block
|
||||
Blockly["Arduino"].setupCode_ = Object.create(null);
|
||||
Blockly['Arduino'].setupCode_ = Object.create(null);
|
||||
|
||||
// creates a list of code to be setup before the setup block
|
||||
Blockly["Arduino"].phyphoxSetupCode_ = Object.create(null);
|
||||
|
||||
// creates a list of code to be setup before the setup block
|
||||
Blockly["Arduino"].loraSetupCode_ = Object.create(null);
|
||||
Blockly['Arduino'].loraSetupCode_ = Object.create(null);
|
||||
|
||||
// creates a list of code for the loop to be runned once
|
||||
Blockly["Arduino"].loopCodeOnce_ = Object.create(null);
|
||||
Blockly['Arduino'].loopCodeOnce_ = Object.create(null)
|
||||
|
||||
// creates a list of code for the loop to be runned once
|
||||
Blockly["Arduino"].codeFunctions_ = Object.create(null);
|
||||
Blockly['Arduino'].codeFunctions_ = Object.create(null)
|
||||
|
||||
// creates a list of code variables
|
||||
Blockly["Arduino"].variables_ = Object.create(null);
|
||||
Blockly['Arduino'].variables_ = Object.create(null)
|
||||
|
||||
// Create a dictionary mapping desired function names in definitions_
|
||||
// to actual function names (to avoid collisions with user functions).
|
||||
Blockly["Arduino"].functionNames_ = Object.create(null);
|
||||
Blockly['Arduino'].functionNames_ = Object.create(null);
|
||||
|
||||
Blockly["Arduino"].variablesInitCode_ = "";
|
||||
Blockly['Arduino'].variablesInitCode_ = '';
|
||||
|
||||
if (!Blockly["Arduino"].nameDB_) {
|
||||
Blockly["Arduino"].nameDB_ = new Blockly.Names(
|
||||
Blockly["Arduino"].RESERVED_WORDS_
|
||||
if (!Blockly['Arduino'].variableDB_) {
|
||||
Blockly['Arduino'].variableDB_ = new Blockly.Names(
|
||||
Blockly['Arduino'].RESERVED_WORDS_
|
||||
);
|
||||
} else {
|
||||
Blockly["Arduino"].nameDB_.reset();
|
||||
Blockly['Arduino'].variableDB_.reset();
|
||||
}
|
||||
|
||||
Blockly["Arduino"].nameDB_.setVariableMap(workspace.getVariableMap());
|
||||
Blockly['Arduino'].variableDB_.setVariableMap(workspace.getVariableMap());
|
||||
|
||||
// We don't have developer variables for now
|
||||
// // Add developer variables (not created or named by the user).
|
||||
// var devVarList = Blockly.Variables.allDeveloperVariables(workspace);
|
||||
// for (var i = 0; i < devVarList.length; i++) {
|
||||
// defvars.push(Blockly['Arduino'].nameDB_.getName(devVarList[i],
|
||||
// defvars.push(Blockly['Arduino'].variableDB_.getName(devVarList[i],
|
||||
// Blockly.Names.DEVELOPER_VARIABLE_TYPE));
|
||||
// }
|
||||
|
||||
const doubleVariables = workspace.getVariablesOfType('Number');
|
||||
let i = 0;
|
||||
let variableCode = '';
|
||||
for (i = 0; i < doubleVariables.length; i += 1) {
|
||||
variableCode +=
|
||||
'double ' +
|
||||
Blockly['Arduino'].variableDB_.getName(
|
||||
doubleVariables[i].getId(),
|
||||
Blockly.Variables.NAME_TYPE
|
||||
) +
|
||||
' = 0; \n\n';
|
||||
}
|
||||
|
||||
const stringVariables = workspace.getVariablesOfType('String');
|
||||
for (i = 0; i < stringVariables.length; i += 1) {
|
||||
variableCode +=
|
||||
'String ' +
|
||||
Blockly['Arduino'].variableDB_.getName(
|
||||
stringVariables[i].getId(),
|
||||
Blockly.Variables.NAME_TYPE
|
||||
) +
|
||||
' = ""; \n\n';
|
||||
}
|
||||
|
||||
const booleanVariables = workspace.getVariablesOfType('Boolean');
|
||||
for (i = 0; i < booleanVariables.length; i += 1) {
|
||||
variableCode +=
|
||||
'boolean ' +
|
||||
Blockly['Arduino'].variableDB_.getDistinctName(
|
||||
booleanVariables[i].getId(),
|
||||
Blockly.Variables.NAME_TYPE
|
||||
) +
|
||||
' = false; \n\n';
|
||||
}
|
||||
|
||||
const colourVariables = workspace.getVariablesOfType('Colour');
|
||||
for (i = 0; i < colourVariables.length; i += 1) {
|
||||
variableCode +=
|
||||
'RGB ' +
|
||||
Blockly['Arduino'].variableDB_.getName(
|
||||
colourVariables[i].getId(),
|
||||
Blockly.Variables.NAME_TYPE
|
||||
) +
|
||||
' = {0, 0, 0}; \n\n';
|
||||
}
|
||||
|
||||
Blockly['Arduino'].variablesInitCode_ = variableCode;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -156,118 +196,86 @@ Blockly["Arduino"].init = function (workspace) {
|
||||
* @param {string} code Generated code.
|
||||
* @return {string} Completed code.
|
||||
*/
|
||||
Blockly["Arduino"].finish = function (code) {
|
||||
let libraryCode = "";
|
||||
let variablesCode = "";
|
||||
let codeFunctions = "";
|
||||
let functionsCode = "";
|
||||
let definitionsCode = "";
|
||||
let phyphoxSetupCode = "";
|
||||
let loopCodeOnce = "";
|
||||
let setupCode = "";
|
||||
let preSetupCode = "";
|
||||
let loraSetupCode = "";
|
||||
let devVariables = "\n";
|
||||
Blockly['Arduino'].finish = function (code) {
|
||||
let libraryCode = '';
|
||||
let variablesCode = '';
|
||||
let codeFunctions = '';
|
||||
let functionsCode = '';
|
||||
let definitionsCode = '';
|
||||
let loopCodeOnce = '';
|
||||
let setupCode = '';
|
||||
let preSetupCode = '';
|
||||
let loraSetupCode = '';
|
||||
let devVariables = '\n';
|
||||
|
||||
for (const key in Blockly["Arduino"].libraries_) {
|
||||
libraryCode += Blockly["Arduino"].libraries_[key] + "\n";
|
||||
for (const key in Blockly['Arduino'].libraries_) {
|
||||
libraryCode += Blockly['Arduino'].libraries_[key] + '\n';
|
||||
}
|
||||
|
||||
for (const key in Blockly["Arduino"].variables_) {
|
||||
variablesCode += Blockly["Arduino"].variables_[key] + "\n";
|
||||
for (const key in Blockly['Arduino'].variables_) {
|
||||
variablesCode += Blockly['Arduino'].variables_[key] + '\n';
|
||||
}
|
||||
|
||||
for (const key in Blockly["Arduino"].definitions_) {
|
||||
definitionsCode += Blockly["Arduino"].definitions_[key] + "\n";
|
||||
for (const key in Blockly['Arduino'].definitions_) {
|
||||
definitionsCode += Blockly['Arduino'].definitions_[key] + '\n';
|
||||
}
|
||||
|
||||
for (const key in Blockly["Arduino"].loopCodeOnce_) {
|
||||
loopCodeOnce += Blockly["Arduino"].loopCodeOnce_[key] + "\n";
|
||||
for (const key in Blockly['Arduino'].loopCodeOnce_) {
|
||||
loopCodeOnce += Blockly['Arduino'].loopCodeOnce_[key] + '\n';
|
||||
}
|
||||
|
||||
for (const key in Blockly["Arduino"].codeFunctions_) {
|
||||
codeFunctions += Blockly["Arduino"].codeFunctions_[key] + "\n";
|
||||
for (const key in Blockly['Arduino'].codeFunctions_) {
|
||||
codeFunctions += Blockly['Arduino'].codeFunctions_[key] + '\n';
|
||||
}
|
||||
|
||||
for (const key in Blockly["Arduino"].functionNames_) {
|
||||
functionsCode += Blockly["Arduino"].functionNames_[key] + "\n";
|
||||
for (const key in Blockly['Arduino'].functionNames_) {
|
||||
functionsCode += Blockly['Arduino'].functionNames_[key] + '\n';
|
||||
}
|
||||
|
||||
for (const key in Blockly["Arduino"].setupCode_) {
|
||||
preSetupCode += Blockly["Arduino"].setupCode_[key] + "\n" || "";
|
||||
|
||||
|
||||
for (const key in Blockly['Arduino'].setupCode_) {
|
||||
preSetupCode += Blockly['Arduino'].setupCode_[key] || '';
|
||||
}
|
||||
|
||||
for (const key in Blockly["Arduino"].loraSetupCode_) {
|
||||
loraSetupCode += Blockly["Arduino"].loraSetupCode_[key] + "\n" || "";
|
||||
for (const key in Blockly['Arduino'].loraSetupCode_) {
|
||||
loraSetupCode += Blockly['Arduino'].loraSetupCode_[key] || '';
|
||||
}
|
||||
|
||||
setupCode =
|
||||
"\nvoid setup() { \n" + preSetupCode + "\n" + loraSetupCode + "\n}\n";
|
||||
for (const key in Blockly["Arduino"].phyphoxSetupCode_) {
|
||||
phyphoxSetupCode += Blockly["Arduino"].phyphoxSetupCode_[key] + "\n" || "";
|
||||
}
|
||||
|
||||
setupCode =
|
||||
"\nvoid setup() { \n" +
|
||||
preSetupCode +
|
||||
"\n" +
|
||||
phyphoxSetupCode +
|
||||
"\n" +
|
||||
loraSetupCode +
|
||||
"\n}\n";
|
||||
setupCode = '\nvoid setup() { \n' + preSetupCode + '\n' + loraSetupCode + '\n}\n';
|
||||
|
||||
let loopCode = '\nvoid loop() { \n' + loopCodeOnce + code + '\n}\n';
|
||||
|
||||
|
||||
let loopCode = "\nvoid loop() { \n" + loopCodeOnce + code + "\n}\n";
|
||||
// only add OTA code if tablet mode is enabled
|
||||
if (ota === true) {
|
||||
code =
|
||||
devVariables +
|
||||
"\n" +
|
||||
"#include <SenseBoxOTA.h>" +
|
||||
"\n" +
|
||||
libraryCode +
|
||||
"\n" +
|
||||
variablesCode +
|
||||
"\n" +
|
||||
definitionsCode +
|
||||
"\n" +
|
||||
codeFunctions +
|
||||
"\n" +
|
||||
Blockly["Arduino"].variablesInitCode_ +
|
||||
"\n" +
|
||||
functionsCode +
|
||||
"\n" +
|
||||
setupCode +
|
||||
"\n" +
|
||||
loopCode;
|
||||
} else {
|
||||
// Convert the definitions dictionary into a list.
|
||||
code =
|
||||
devVariables +
|
||||
"\n" +
|
||||
'\n' +
|
||||
libraryCode +
|
||||
"\n" +
|
||||
'\n' +
|
||||
variablesCode +
|
||||
"\n" +
|
||||
'\n' +
|
||||
definitionsCode +
|
||||
"\n" +
|
||||
'\n' +
|
||||
codeFunctions +
|
||||
"\n" +
|
||||
Blockly["Arduino"].variablesInitCode_ +
|
||||
"\n" +
|
||||
'\n' +
|
||||
Blockly['Arduino'].variablesInitCode_ +
|
||||
'\n' +
|
||||
functionsCode +
|
||||
"\n" +
|
||||
'\n' +
|
||||
setupCode +
|
||||
"\n" +
|
||||
loopCode;
|
||||
}
|
||||
'\n' +
|
||||
loopCode
|
||||
;
|
||||
|
||||
// Clean up temporary data.
|
||||
delete Blockly["Arduino"].definitions_;
|
||||
delete Blockly["Arduino"].functionNames_;
|
||||
delete Blockly["Arduino"].loopCodeOnce_;
|
||||
delete Blockly["Arduino"].variablesInitCode_;
|
||||
delete Blockly["Arduino"].libraries_;
|
||||
Blockly["Arduino"].nameDB_.reset();
|
||||
delete Blockly['Arduino'].definitions_;
|
||||
delete Blockly['Arduino'].functionNames_;
|
||||
delete Blockly['Arduino'].loopCodeOnce_;
|
||||
delete Blockly['Arduino'].variablesInitCode_;
|
||||
delete Blockly['Arduino'].libraries_;
|
||||
Blockly['Arduino'].variableDB_.reset();
|
||||
|
||||
return code;
|
||||
};
|
||||
@ -278,8 +286,8 @@ Blockly["Arduino"].finish = function (code) {
|
||||
* @param {string} line Line of generated code.
|
||||
* @return {string} Legal line of code.
|
||||
*/
|
||||
Blockly["Arduino"].scrubNakedValue = function (line) {
|
||||
return line + ";\n";
|
||||
Blockly['Arduino'].scrubNakedValue = function (line) {
|
||||
return line + ';\n';
|
||||
};
|
||||
|
||||
/**
|
||||
@ -289,12 +297,12 @@ Blockly["Arduino"].scrubNakedValue = function (line) {
|
||||
* @return {string} Arduino string.
|
||||
* @private
|
||||
*/
|
||||
Blockly["Arduino"].quote_ = function (string) {
|
||||
Blockly['Arduino'].quote_ = function (string) {
|
||||
// Can't use goog.string.quote since Google's style guide recommends
|
||||
// JS string literals use single quotes.
|
||||
string = string
|
||||
.replace(/\\/g, "\\\\")
|
||||
.replace(/\n/g, "\\\n")
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/\n/g, '\\\n')
|
||||
.replace(/'/g, "\\'");
|
||||
return '"' + string + '"';
|
||||
};
|
||||
@ -309,25 +317,26 @@ Blockly["Arduino"].quote_ = function (string) {
|
||||
* @return {string} Arduino code with comments and subsequent blocks added.
|
||||
* @private
|
||||
*/
|
||||
Blockly["Arduino"].scrub_ = function (block, code) {
|
||||
let commentCode = "";
|
||||
Blockly['Arduino'].scrub_ = function (block, code) {
|
||||
let commentCode = '';
|
||||
// Only collect comments for blocks that aren't inline.
|
||||
if (!block.outputConnection || !block.outputConnection.targetConnection) {
|
||||
// Collect comment for this block.
|
||||
let comment = block.getCommentText();
|
||||
//@ts-ignore
|
||||
comment = comment
|
||||
? Blockly.utils.string.wrap(comment, Blockly["Arduino"].COMMENT_WRAP - 3)
|
||||
: null;
|
||||
comment = comment ? Blockly.utils.string.wrap(
|
||||
comment,
|
||||
Blockly['Arduino'].COMMENT_WRAP - 3
|
||||
) : null;
|
||||
if (comment) {
|
||||
if (block.getProcedureDef) {
|
||||
// Use a comment block for function comments.
|
||||
commentCode +=
|
||||
"/**\n" +
|
||||
Blockly["Arduino"].prefixLines(comment + "\n", " * ") +
|
||||
" */\n";
|
||||
'/**\n' +
|
||||
Blockly['Arduino'].prefixLines(comment + '\n', ' * ') +
|
||||
' */\n';
|
||||
} else {
|
||||
commentCode += Blockly["Arduino"].prefixLines(comment + "\n", "// ");
|
||||
commentCode += Blockly['Arduino'].prefixLines(comment + '\n', '// ');
|
||||
}
|
||||
}
|
||||
// Collect comments for all value arguments.
|
||||
@ -336,15 +345,15 @@ Blockly["Arduino"].scrub_ = function (block, code) {
|
||||
if (block.inputList[i].type === Blockly.INPUT_VALUE) {
|
||||
const childBlock = block.inputList[i].connection.targetBlock();
|
||||
if (childBlock) {
|
||||
const comment = Blockly["Arduino"].allNestedComments(childBlock);
|
||||
const comment = Blockly['Arduino'].allNestedComments(childBlock);
|
||||
if (comment) {
|
||||
commentCode += Blockly["Arduino"].prefixLines(comment, "// ");
|
||||
commentCode += Blockly['Arduino'].prefixLines(comment, '// ');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const nextBlock = block.nextConnection && block.nextConnection.targetBlock();
|
||||
const nextCode = Blockly["Arduino"].blockToCode(nextBlock);
|
||||
const nextCode = Blockly['Arduino'].blockToCode(nextBlock);
|
||||
return commentCode + code + nextCode;
|
||||
};
|
||||
@ -1,30 +1,24 @@
|
||||
import "./generator";
|
||||
import "./loops";
|
||||
import "./sensebox-sensors";
|
||||
import "./sensebox-telegram";
|
||||
import "./sensebox-osem";
|
||||
import "./sensebox-web";
|
||||
import "./sensebox-display";
|
||||
import "./sensebox-motors";
|
||||
import "./sensebox-lora";
|
||||
import "./sensebox-led";
|
||||
import "./sensebox";
|
||||
import "./sensebox-rtc";
|
||||
import "./sensebox-ntp";
|
||||
import "./sensebox-ble";
|
||||
import "./sensebox-sd";
|
||||
import "./mqtt";
|
||||
import "./logic";
|
||||
import "./text";
|
||||
import "./math";
|
||||
import "./map";
|
||||
import "./io";
|
||||
import "./audio";
|
||||
import "./procedures";
|
||||
import "./serial";
|
||||
import "./time";
|
||||
import "./variables";
|
||||
import "./lists";
|
||||
import "./watchdog";
|
||||
import "./webserver";
|
||||
import "./CleVerLab"
|
||||
import './generator';
|
||||
import './loops';
|
||||
import './sensebox-sensors';
|
||||
import './sensebox-telegram';
|
||||
import './sensebox-osem';
|
||||
import './sensebox-web';
|
||||
import './sensebox-display';
|
||||
import './sensebox-lora';
|
||||
import './sensebox-led';
|
||||
import './sensebox-sd';
|
||||
import './mqtt';
|
||||
import './logic';
|
||||
import './text';
|
||||
import './math';
|
||||
import './map';
|
||||
import './io';
|
||||
import './audio';
|
||||
import './procedures';
|
||||
import './time';
|
||||
import './variables';
|
||||
import './lists';
|
||||
import './webserver';
|
||||
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
/**
|
||||
* @license Licensed under the Apache License, Version 2.0 (the "License"):
|
||||
@ -18,13 +19,13 @@ import * as Blockly from "blockly/core";
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["math_number"] = function (block) {
|
||||
Blockly.Arduino['math_number'] = function (block) {
|
||||
// Numeric value.
|
||||
var code = parseFloat(block.getFieldValue("NUM"));
|
||||
var code = parseFloat(block.getFieldValue('NUM'));
|
||||
if (code === Infinity) {
|
||||
code = "INFINITY";
|
||||
code = 'INFINITY';
|
||||
} else if (code === -Infinity) {
|
||||
code = "-INFINITY";
|
||||
code = '-INFINITY';
|
||||
}
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
@ -36,23 +37,23 @@ Blockly.Arduino["math_number"] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["math_arithmetic"] = function (block) {
|
||||
Blockly.Arduino['math_arithmetic'] = function (block) {
|
||||
var OPERATORS = {
|
||||
ADD: [" + ", Blockly.Arduino.ORDER_ADDITIVE],
|
||||
MINUS: [" - ", Blockly.Arduino.ORDER_ADDITIVE],
|
||||
MULTIPLY: [" * ", Blockly.Arduino.ORDER_MULTIPLICATIVE],
|
||||
DIVIDE: [" / ", Blockly.Arduino.ORDER_MULTIPLICATIVE],
|
||||
POWER: [null, Blockly.Arduino.ORDER_NONE], // Handle power separately.
|
||||
ADD: [' + ', Blockly.Arduino.ORDER_ADDITIVE],
|
||||
MINUS: [' - ', Blockly.Arduino.ORDER_ADDITIVE],
|
||||
MULTIPLY: [' * ', Blockly.Arduino.ORDER_MULTIPLICATIVE],
|
||||
DIVIDE: [' / ', Blockly.Arduino.ORDER_MULTIPLICATIVE],
|
||||
POWER: [null, Blockly.Arduino.ORDER_NONE] // Handle power separately.
|
||||
};
|
||||
var tuple = OPERATORS[block.getFieldValue("OP")];
|
||||
var tuple = OPERATORS[block.getFieldValue('OP')];
|
||||
var operator = tuple[0];
|
||||
var order = tuple[1];
|
||||
var argument0 = Blockly.Arduino.valueToCode(block, "A", order) || "0";
|
||||
var argument1 = Blockly.Arduino.valueToCode(block, "B", order) || "0";
|
||||
var argument0 = Blockly.Arduino.valueToCode(block, 'A', order) || '0';
|
||||
var argument1 = Blockly.Arduino.valueToCode(block, 'B', order) || '0';
|
||||
var code;
|
||||
// Power in C++ requires a special case since it has no operator.
|
||||
if (!operator) {
|
||||
code = "Math.pow(" + argument0 + ", " + argument1 + ")";
|
||||
code = 'Math.pow(' + argument0 + ', ' + argument1 + ')';
|
||||
return [code, Blockly.Arduino.ORDER_UNARY_POSTFIX];
|
||||
}
|
||||
code = argument0 + operator + argument1;
|
||||
@ -65,78 +66,65 @@ Blockly.Arduino["math_arithmetic"] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["math_single"] = function (block) {
|
||||
var operator = block.getFieldValue("OP");
|
||||
Blockly.Arduino['math_single'] = function (block) {
|
||||
var operator = block.getFieldValue('OP');
|
||||
var code;
|
||||
var arg;
|
||||
if (operator === "NEG") {
|
||||
if (operator === 'NEG') {
|
||||
// Negation is a special case given its different operator precedents.
|
||||
arg =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"NUM",
|
||||
Blockly.Arduino.ORDER_UNARY_PREFIX
|
||||
) || "0";
|
||||
if (arg[0] === "-") {
|
||||
arg = Blockly.Arduino.valueToCode(block, 'NUM',
|
||||
Blockly.Arduino.ORDER_UNARY_PREFIX) || '0';
|
||||
if (arg[0] === '-') {
|
||||
// --3 is not legal in C++ in this context.
|
||||
arg = " " + arg;
|
||||
arg = ' ' + arg;
|
||||
}
|
||||
code = "-" + arg;
|
||||
code = '-' + arg;
|
||||
return [code, Blockly.Arduino.ORDER_UNARY_PREFIX];
|
||||
}
|
||||
if (operator === "ABS" || operator.substring(0, 5) === "ROUND") {
|
||||
arg =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"NUM",
|
||||
Blockly.Arduino.ORDER_UNARY_POSTFIX
|
||||
) || "0";
|
||||
} else if (operator === "SIN" || operator === "COS" || operator === "TAN") {
|
||||
arg =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"NUM",
|
||||
Blockly.Arduino.ORDER_MULTIPLICATIVE
|
||||
) || "0";
|
||||
if (operator === 'ABS' || operator.substring(0, 5) === 'ROUND') {
|
||||
arg = Blockly.Arduino.valueToCode(block, 'NUM',
|
||||
Blockly.Arduino.ORDER_UNARY_POSTFIX) || '0';
|
||||
} else if (operator === 'SIN' || operator === 'COS' || operator === 'TAN') {
|
||||
arg = Blockly.Arduino.valueToCode(block, 'NUM',
|
||||
Blockly.Arduino.ORDER_MULTIPLICATIVE) || '0';
|
||||
} else {
|
||||
arg =
|
||||
Blockly.Arduino.valueToCode(block, "NUM", Blockly.Arduino.ORDER_NONE) ||
|
||||
"0";
|
||||
arg = Blockly.Arduino.valueToCode(block, 'NUM',
|
||||
Blockly.Arduino.ORDER_NONE) || '0';
|
||||
}
|
||||
// First, handle cases which generate values that don't need parentheses.
|
||||
switch (operator) {
|
||||
case "ABS":
|
||||
code = "abs(" + arg + ")";
|
||||
case 'ABS':
|
||||
code = 'abs(' + arg + ')';
|
||||
break;
|
||||
case "ROOT":
|
||||
code = "sqrt(" + arg + ")";
|
||||
case 'ROOT':
|
||||
code = 'sqrt(' + arg + ')';
|
||||
break;
|
||||
case "LN":
|
||||
code = "log(" + arg + ")";
|
||||
case 'LN':
|
||||
code = 'log(' + arg + ')';
|
||||
break;
|
||||
case "EXP":
|
||||
code = "exp(" + arg + ")";
|
||||
case 'EXP':
|
||||
code = 'exp(' + arg + ')';
|
||||
break;
|
||||
case "POW10":
|
||||
code = "pow(10," + arg + ")";
|
||||
case 'POW10':
|
||||
code = 'pow(10,' + arg + ')';
|
||||
break;
|
||||
case "ROUND":
|
||||
code = "round(" + arg + ")";
|
||||
case 'ROUND':
|
||||
code = 'round(' + arg + ')';
|
||||
break;
|
||||
case "ROUNDUP":
|
||||
code = "ceil(" + arg + ")";
|
||||
case 'ROUNDUP':
|
||||
code = 'ceil(' + arg + ')';
|
||||
break;
|
||||
case "ROUNDDOWN":
|
||||
code = "floor(" + arg + ")";
|
||||
case 'ROUNDDOWN':
|
||||
code = 'floor(' + arg + ')';
|
||||
break;
|
||||
case "SIN":
|
||||
code = "sin(" + arg + " / 180 * Math.PI)";
|
||||
case 'SIN':
|
||||
code = 'sin(' + arg + ' / 180 * Math.PI)';
|
||||
break;
|
||||
case "COS":
|
||||
code = "cos(" + arg + " / 180 * Math.PI)";
|
||||
case 'COS':
|
||||
code = 'cos(' + arg + ' / 180 * Math.PI)';
|
||||
break;
|
||||
case "TAN":
|
||||
code = "tan(" + arg + " / 180 * Math.PI)";
|
||||
case 'TAN':
|
||||
code = 'tan(' + arg + ' / 180 * Math.PI)';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -146,20 +134,20 @@ Blockly.Arduino["math_single"] = function (block) {
|
||||
}
|
||||
// Second, handle cases which generate values that may need parentheses.
|
||||
switch (operator) {
|
||||
case "LOG10":
|
||||
code = "log(" + arg + ") / log(10)";
|
||||
case 'LOG10':
|
||||
code = 'log(' + arg + ') / log(10)';
|
||||
break;
|
||||
case "ASIN":
|
||||
code = "asin(" + arg + ") / M_PI * 180";
|
||||
case 'ASIN':
|
||||
code = 'asin(' + arg + ') / M_PI * 180';
|
||||
break;
|
||||
case "ACOS":
|
||||
code = "acos(" + arg + ") / M_PI * 180";
|
||||
case 'ACOS':
|
||||
code = 'acos(' + arg + ') / M_PI * 180';
|
||||
break;
|
||||
case "ATAN":
|
||||
code = "atan(" + arg + ") / M_PI * 180";
|
||||
case 'ATAN':
|
||||
code = 'atan(' + arg + ') / M_PI * 180';
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unknown math operator: " + operator);
|
||||
throw new Error('Unknown math operator: ' + operator);
|
||||
}
|
||||
return [code, Blockly.Arduino.ORDER_MULTIPLICATIVE];
|
||||
};
|
||||
@ -173,16 +161,16 @@ Blockly.Arduino["math_single"] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {string} Completed code.
|
||||
*/
|
||||
Blockly.Arduino["math_constant"] = function (block) {
|
||||
Blockly.Arduino['math_constant'] = function (block) {
|
||||
var CONSTANTS = {
|
||||
PI: ["M_PI", Blockly.Arduino.ORDER_UNARY_POSTFIX],
|
||||
E: ["M_E", Blockly.Arduino.ORDER_UNARY_POSTFIX],
|
||||
GOLDEN_RATIO: ["(1 + sqrt(5)) / 2", Blockly.Arduino.ORDER_MULTIPLICATIVE],
|
||||
SQRT2: ["M_SQRT2", Blockly.Arduino.ORDER_UNARY_POSTFIX],
|
||||
SQRT1_2: ["M_SQRT1_2", Blockly.Arduino.ORDER_UNARY_POSTFIX],
|
||||
INFINITY: ["INFINITY", Blockly.Arduino.ORDER_ATOMIC],
|
||||
'PI': ['M_PI', Blockly.Arduino.ORDER_UNARY_POSTFIX],
|
||||
'E': ['M_E', Blockly.Arduino.ORDER_UNARY_POSTFIX],
|
||||
'GOLDEN_RATIO': ['(1 + sqrt(5)) / 2', Blockly.Arduino.ORDER_MULTIPLICATIVE],
|
||||
'SQRT2': ['M_SQRT2', Blockly.Arduino.ORDER_UNARY_POSTFIX],
|
||||
'SQRT1_2': ['M_SQRT1_2', Blockly.Arduino.ORDER_UNARY_POSTFIX],
|
||||
'INFINITY': ['INFINITY', Blockly.Arduino.ORDER_ATOMIC]
|
||||
};
|
||||
return CONSTANTS[block.getFieldValue("CONSTANT")];
|
||||
return CONSTANTS[block.getFieldValue('CONSTANT')];
|
||||
};
|
||||
|
||||
/**
|
||||
@ -192,67 +180,58 @@ Blockly.Arduino["math_constant"] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["math_number_property"] = function (block) {
|
||||
var number_to_check =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"NUMBER_TO_CHECK",
|
||||
Blockly.Arduino.ORDER_MULTIPLICATIVE
|
||||
) || "0";
|
||||
var dropdown_property = block.getFieldValue("PROPERTY");
|
||||
Blockly.Arduino['math_number_property'] = function (block) {
|
||||
var number_to_check = Blockly.Arduino.valueToCode(block, 'NUMBER_TO_CHECK',
|
||||
Blockly.Arduino.ORDER_MULTIPLICATIVE) || '0';
|
||||
var dropdown_property = block.getFieldValue('PROPERTY');
|
||||
var code;
|
||||
if (dropdown_property === "PRIME") {
|
||||
if (dropdown_property === 'PRIME') {
|
||||
var func = [
|
||||
"boolean " + Blockly.Arduino.DEF_FUNC_NAME + "(int n) {",
|
||||
" // https://en.wikipedia.org/wiki/Primality_test#Naive_methods",
|
||||
" if (n == 2 || n == 3) {",
|
||||
" return true;",
|
||||
" }",
|
||||
" // False if n is NaN, negative, is 1.",
|
||||
" // And false if n is divisible by 2 or 3.",
|
||||
" if (isnan(n) || (n <= 1) || (n == 1) || (n % 2 == 0) || " +
|
||||
"(n % 3 == 0)) {",
|
||||
" return false;",
|
||||
" }",
|
||||
" // Check all the numbers of form 6k +/- 1, up to sqrt(n).",
|
||||
" for (int x = 6; x <= sqrt(n) + 1; x += 6) {",
|
||||
" if (n % (x - 1) == 0 || n % (x + 1) == 0) {",
|
||||
" return false;",
|
||||
" }",
|
||||
" }",
|
||||
" return true;",
|
||||
"}",
|
||||
];
|
||||
var funcName = Blockly.Arduino.addFunction("mathIsPrime", func.join("\n"));
|
||||
Blockly.Arduino.addInclude("math", "#include <math.h>");
|
||||
code = funcName + "(" + number_to_check + ")";
|
||||
'boolean ' + Blockly.Arduino.DEF_FUNC_NAME + '(int n) {',
|
||||
' // https://en.wikipedia.org/wiki/Primality_test#Naive_methods',
|
||||
' if (n == 2 || n == 3) {',
|
||||
' return true;',
|
||||
' }',
|
||||
' // False if n is NaN, negative, is 1.',
|
||||
' // And false if n is divisible by 2 or 3.',
|
||||
' if (isnan(n) || (n <= 1) || (n == 1) || (n % 2 == 0) || ' +
|
||||
'(n % 3 == 0)) {',
|
||||
' return false;',
|
||||
' }',
|
||||
' // Check all the numbers of form 6k +/- 1, up to sqrt(n).',
|
||||
' for (int x = 6; x <= sqrt(n) + 1; x += 6) {',
|
||||
' if (n % (x - 1) == 0 || n % (x + 1) == 0) {',
|
||||
' return false;',
|
||||
' }',
|
||||
' }',
|
||||
' return true;',
|
||||
'}'];
|
||||
var funcName = Blockly.Arduino.addFunction('mathIsPrime', func.join('\n'));
|
||||
Blockly.Arduino.addInclude('math', '#include <math.h>');
|
||||
code = funcName + '(' + number_to_check + ')';
|
||||
return [code, Blockly.Arduino.ORDER_UNARY_POSTFIX];
|
||||
}
|
||||
switch (dropdown_property) {
|
||||
case "EVEN":
|
||||
code = number_to_check + " % 2 == 0";
|
||||
case 'EVEN':
|
||||
code = number_to_check + ' % 2 == 0';
|
||||
break;
|
||||
case "ODD":
|
||||
code = number_to_check + " % 2 == 1";
|
||||
case 'ODD':
|
||||
code = number_to_check + ' % 2 == 1';
|
||||
break;
|
||||
case "WHOLE":
|
||||
Blockly.Arduino.addInclude("math", "#include <math.h>");
|
||||
code = "(floor(" + number_to_check + ") == " + number_to_check + ")";
|
||||
case 'WHOLE':
|
||||
Blockly.Arduino.addInclude('math', '#include <math.h>');
|
||||
code = '(floor(' + number_to_check + ') == ' + number_to_check + ')';
|
||||
break;
|
||||
case "POSITIVE":
|
||||
code = number_to_check + " > 0";
|
||||
case 'POSITIVE':
|
||||
code = number_to_check + ' > 0';
|
||||
break;
|
||||
case "NEGATIVE":
|
||||
code = number_to_check + " < 0";
|
||||
case 'NEGATIVE':
|
||||
code = number_to_check + ' < 0';
|
||||
break;
|
||||
case "DIVISIBLE_BY":
|
||||
var divisor =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"DIVISOR",
|
||||
Blockly.Arduino.ORDER_MULTIPLICATIVE
|
||||
) || "0";
|
||||
code = number_to_check + " % " + divisor + " == 0";
|
||||
case 'DIVISIBLE_BY':
|
||||
var divisor = Blockly.Arduino.valueToCode(block, 'DIVISOR',
|
||||
Blockly.Arduino.ORDER_MULTIPLICATIVE) || '0';
|
||||
code = number_to_check + ' % ' + divisor + ' == 0';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -268,30 +247,19 @@ Blockly.Arduino["math_number_property"] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["math_change"] = function (block) {
|
||||
var argument0 =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"DELTA",
|
||||
Blockly.Arduino.ORDER_ADDITIVE
|
||||
) || "0";
|
||||
var id = block.getFieldValue("VAR")
|
||||
const varName = Blockly.Variables.getVariable(
|
||||
Blockly.getMainWorkspace(),
|
||||
id
|
||||
).name;
|
||||
// var varName = Blockly.Arduino.nameDB_.getName(
|
||||
// block.getFieldValue("VAR"),
|
||||
// Blockly.Variables.NAME_TYPE
|
||||
// );
|
||||
return varName + " += " + argument0 + ";\n";
|
||||
Blockly.Arduino['math_change'] = function (block) {
|
||||
var argument0 = Blockly.Arduino.valueToCode(block, 'DELTA',
|
||||
Blockly.Arduino.ORDER_ADDITIVE) || '0';
|
||||
var varName = Blockly.Arduino.variableDB_.getName(
|
||||
block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
|
||||
return varName + ' += ' + argument0 + ';\n';
|
||||
};
|
||||
|
||||
/** Rounding functions have a single operand. */
|
||||
Blockly.Arduino["math_round"] = Blockly.Arduino["math_single"];
|
||||
Blockly.Arduino['math_round'] = Blockly.Arduino['math_single'];
|
||||
|
||||
/** Trigonometry functions have a single operand. */
|
||||
Blockly.Arduino["math_trig"] = Blockly.Arduino["math_single"];
|
||||
Blockly.Arduino['math_trig'] = Blockly.Arduino['math_single'];
|
||||
|
||||
/**
|
||||
* Generator for the math function to a list.
|
||||
@ -300,7 +268,7 @@ Blockly.Arduino["math_trig"] = Blockly.Arduino["math_single"];
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["math_on_list"] = Blockly.Arduino.noGeneratorCodeInline;
|
||||
Blockly.Arduino['math_on_list'] = Blockly.Arduino.noGeneratorCodeInline;
|
||||
|
||||
/**
|
||||
* Generator for the math modulo function (calculates remainder of X/Y).
|
||||
@ -308,20 +276,12 @@ Blockly.Arduino["math_on_list"] = Blockly.Arduino.noGeneratorCodeInline;
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["math_modulo"] = function (block) {
|
||||
var argument0 =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"DIVIDEND",
|
||||
Blockly.Arduino.ORDER_MULTIPLICATIVE
|
||||
) || "0";
|
||||
var argument1 =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"DIVISOR",
|
||||
Blockly.Arduino.ORDER_MULTIPLICATIVE
|
||||
) || "0";
|
||||
var code = argument0 + " % " + argument1;
|
||||
Blockly.Arduino['math_modulo'] = function (block) {
|
||||
var argument0 = Blockly.Arduino.valueToCode(block, 'DIVIDEND',
|
||||
Blockly.Arduino.ORDER_MULTIPLICATIVE) || '0';
|
||||
var argument1 = Blockly.Arduino.valueToCode(block, 'DIVISOR',
|
||||
Blockly.Arduino.ORDER_MULTIPLICATIVE) || '0';
|
||||
var code = argument0 + ' % ' + argument1;
|
||||
return [code, Blockly.Arduino.ORDER_MULTIPLICATIVE];
|
||||
};
|
||||
|
||||
@ -331,33 +291,17 @@ Blockly.Arduino["math_modulo"] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["math_constrain"] = function (block) {
|
||||
Blockly.Arduino['math_constrain'] = function (block) {
|
||||
// Constrain a number between two limits.
|
||||
var argument0 =
|
||||
Blockly.Arduino.valueToCode(block, "VALUE", Blockly.Arduino.ORDER_NONE) ||
|
||||
"0";
|
||||
var argument1 =
|
||||
Blockly.Arduino.valueToCode(block, "LOW", Blockly.Arduino.ORDER_NONE) ||
|
||||
"0";
|
||||
var argument2 =
|
||||
Blockly.Arduino.valueToCode(block, "HIGH", Blockly.Arduino.ORDER_NONE) ||
|
||||
"0";
|
||||
var code =
|
||||
"(" +
|
||||
argument0 +
|
||||
" < " +
|
||||
argument1 +
|
||||
" ? " +
|
||||
argument1 +
|
||||
" : ( " +
|
||||
argument0 +
|
||||
" > " +
|
||||
argument2 +
|
||||
" ? " +
|
||||
argument2 +
|
||||
" : " +
|
||||
argument0 +
|
||||
"))";
|
||||
var argument0 = Blockly.Arduino.valueToCode(block, 'VALUE',
|
||||
Blockly.Arduino.ORDER_NONE) || '0';
|
||||
var argument1 = Blockly.Arduino.valueToCode(block, 'LOW',
|
||||
Blockly.Arduino.ORDER_NONE) || '0';
|
||||
var argument2 = Blockly.Arduino.valueToCode(block, 'HIGH',
|
||||
Blockly.Arduino.ORDER_NONE) || '0';
|
||||
var code = '(' + argument0 + ' < ' + argument1 + ' ? ' + argument1 +
|
||||
' : ( ' + argument0 + ' > ' + argument2 + ' ? ' + argument2 + ' : ' +
|
||||
argument0 + '))';
|
||||
return [code, Blockly.Arduino.ORDER_UNARY_POSTFIX];
|
||||
};
|
||||
|
||||
@ -368,26 +312,28 @@ Blockly.Arduino["math_constrain"] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["math_random_int"] = function (block) {
|
||||
var argument0 =
|
||||
Blockly.Arduino.valueToCode(block, "FROM", Blockly.Arduino.ORDER_NONE) ||
|
||||
"0";
|
||||
var argument1 =
|
||||
Blockly.Arduino.valueToCode(block, "TO", Blockly.Arduino.ORDER_NONE) || "0";
|
||||
Blockly.Arduino.setupCode_["init_rand"] = "randomSeed(analogRead(0));";
|
||||
Blockly.Arduino.functionNames_[
|
||||
"math_random_int"
|
||||
] = `int mathRandomInt (int min, int max) {\n
|
||||
if (min > max) {
|
||||
int temp = min;
|
||||
min = max;
|
||||
max = temp;
|
||||
}
|
||||
return min + (rand() % (max - min + 1));
|
||||
}
|
||||
`;
|
||||
var code = `mathRandomInt(${argument0},${argument1});`;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
Blockly.Arduino['math_random_int'] = function (block) {
|
||||
var argument0 = Blockly.Arduino.valueToCode(block, 'FROM',
|
||||
Blockly.Arduino.ORDER_NONE) || '0';
|
||||
var argument1 = Blockly.Arduino.valueToCode(block, 'TO',
|
||||
Blockly.Arduino.ORDER_NONE) || '0';
|
||||
var functionName = Blockly.Arduino.variableDB_.getDistinctName(
|
||||
'math_random_int', Blockly.Generator.NAME_TYPE);
|
||||
Blockly.Arduino.setups_['init_rand'] = 'randomSeed(analogRead(0));';
|
||||
Blockly.Arduino.math_random_int.random_function = functionName;
|
||||
var func = [
|
||||
'int ' + Blockly.Arduino.DEF_FUNC_NAME + '(int min, int max) {',
|
||||
' if (min > max) {',
|
||||
' // Swap min and max to ensure min is smaller.',
|
||||
' int temp = min;',
|
||||
' min = max;',
|
||||
' max = temp;',
|
||||
' }',
|
||||
' return min + (rand() % (max - min + 1));',
|
||||
'}'];
|
||||
var funcName = Blockly.Arduino.addFunction('mathRandomInt', func.join('\n'));
|
||||
var code = funcName + '(' + argument0 + ', ' + argument1 + ')';
|
||||
return [code, Blockly.Arduino.ORDER_UNARY_POSTFIX];
|
||||
};
|
||||
|
||||
/**
|
||||
@ -396,6 +342,6 @@ Blockly.Arduino["math_random_int"] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {string} Completed code.
|
||||
*/
|
||||
Blockly.Arduino["math_random_float"] = function (block) {
|
||||
return ["(rand() / RAND_MAX)", Blockly.Arduino.ORDER_UNARY_POSTFIX];
|
||||
Blockly.Arduino['math_random_float'] = function (block) {
|
||||
return ['(rand() / RAND_MAX)', Blockly.Arduino.ORDER_UNARY_POSTFIX];
|
||||
};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
import * as Blockly from 'blockly/core';
|
||||
/**
|
||||
* MQTT Blocks
|
||||
*/
|
||||
@ -6,72 +6,47 @@ import * as Blockly from "blockly/core";
|
||||
let service;
|
||||
|
||||
Blockly.Arduino.sensebox_mqtt_setup = function () {
|
||||
var server = this.getFieldValue("server");
|
||||
var port = this.getFieldValue("port");
|
||||
var username = this.getFieldValue("username");
|
||||
var pass = this.getFieldValue("password");
|
||||
service = this.getFieldValue("service");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["library_adafruitmqtt"] =
|
||||
'#include <Adafruit_MQTT.h> //http://librarymanager/All#Adafruit_MQTT_Library"';
|
||||
Blockly.Arduino.libraries_["library_adafruitmqttclient"] =
|
||||
'#include <Adafruit_MQTT_Client.h>';
|
||||
Blockly.Arduino.definitions_["mqtt_server"] =
|
||||
'#define SERVER "' + server + '"';
|
||||
Blockly.Arduino.definitions_["mqtt_port"] =
|
||||
"#define SERVERPORT " + port + "";
|
||||
Blockly.Arduino.definitions_["mqtt_username"] =
|
||||
'#define USERNAME "' + username + '"';
|
||||
Blockly.Arduino.definitions_["mqtt_pass"] =
|
||||
'#define PASS "' + pass + '"';
|
||||
Blockly.Arduino.definitions_["wifi_client"] = "WiFiClient client;";
|
||||
Blockly.Arduino.definitions_["mqtt_client"] =
|
||||
"Adafruit_MQTT_Client mqtt(&client, SERVER, SERVERPORT, USERNAME, PASS);";
|
||||
var code = "";
|
||||
var server = this.getFieldValue('server');
|
||||
var port = this.getFieldValue('port');
|
||||
var username = this.getFieldValue('username');
|
||||
var pass = this.getFieldValue('password');
|
||||
service = this.getFieldValue('service');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.libraries_['library_adafruitmqtt'] = '#include "Adafruit_MQTT.h"';
|
||||
Blockly.Arduino.libraries_['library_adafruitmqttclient'] = '#include "Adafruit_MQTT_Client.h"';
|
||||
Blockly.Arduino.definitions_['mqtt_server'] = '#define SERVER "' + server + '"';
|
||||
Blockly.Arduino.definitions_['mqtt_port'] = '#define SERVERPORT ' + port + '';
|
||||
Blockly.Arduino.definitions_['mqtt_username'] = '#define USERNAME "' + username + '"';
|
||||
Blockly.Arduino.definitions_['mqtt_pass'] = '#define PASS "' + pass + '"';
|
||||
Blockly.Arduino.definitions_['wifi_client'] = 'WiFiClient client;';
|
||||
Blockly.Arduino.definitions_['mqtt_client'] = 'Adafruit_MQTT_Client mqtt(&client, SERVER, SERVERPORT, USERNAME, PASS);'
|
||||
var code = '';
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_mqtt_publish = function (block) {
|
||||
var feedname = this.getFieldValue("publishfeed");
|
||||
var feedname = this.getFieldValue('publishfeed');
|
||||
var res = feedname.split("/");
|
||||
var feed_client = res[res.length - 1];
|
||||
var value =
|
||||
Blockly.Arduino.valueToCode(this, "value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
'"No Block connected"';
|
||||
var value = Blockly.Arduino.valueToCode(this, 'value', Blockly.Arduino.ORDER_ATOMIC) || '"No Block connected"';
|
||||
|
||||
switch (service) {
|
||||
case "adafruitio":
|
||||
Blockly.Arduino.definitions_["mqtt_" + feed_client + ""] =
|
||||
"Adafruit_MQTT_Publish " +
|
||||
feed_client +
|
||||
' = Adafruit_MQTT_Publish(&mqtt, USERNAME "/feeds/' +
|
||||
feedname +
|
||||
'");';
|
||||
case 'adafruitio':
|
||||
Blockly.Arduino.definitions_['mqtt_' + feed_client + ''] = 'Adafruit_MQTT_Publish ' + feed_client + ' = Adafruit_MQTT_Publish(&mqtt, USERNAME "/feeds/' + feedname + '");'
|
||||
break;
|
||||
case "dioty":
|
||||
Blockly.Arduino.definitions_["mqtt_" + feed_client + ""] =
|
||||
"Adafruit_MQTT_Publish " +
|
||||
feed_client +
|
||||
' = Adafruit_MQTT_Publish(&mqtt, "/"USERNAME"/' +
|
||||
feedname +
|
||||
'");';
|
||||
case 'dioty':
|
||||
Blockly.Arduino.definitions_['mqtt_' + feed_client + ''] = 'Adafruit_MQTT_Publish ' + feed_client + ' = Adafruit_MQTT_Publish(&mqtt, "/"USERNAME"/' + feedname + '");'
|
||||
break;
|
||||
case "custom":
|
||||
Blockly.Arduino.definitions_["mqtt_" + feed_client + ""] =
|
||||
"Adafruit_MQTT_Publish " +
|
||||
feed_client +
|
||||
' = Adafruit_MQTT_Publish(&mqtt, "' +
|
||||
feedname +
|
||||
'");';
|
||||
case 'custom':
|
||||
Blockly.Arduino.definitions_['mqtt_' + feed_client + ''] = 'Adafruit_MQTT_Publish ' + feed_client + ' = Adafruit_MQTT_Publish(&mqtt, "' + feedname + '");'
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
//Blockly.Arduino.definitions_['mqtt_' + feed_client + ''] = 'Adafruit_MQTT_Publish ' + feed_client + ' = Adafruit_MQTT_Publish(&mqtt, USERNAME "/feeds/' + feedname + '");'
|
||||
Blockly.Arduino.codeFunctions_[
|
||||
"mqtt_connect_function"
|
||||
] = `// Function to connect and reconnect as necessary to the MQTT server.
|
||||
Blockly.Arduino.codeFunctions_['mqtt_connect_function'] = `// Function to connect and reconnect as necessary to the MQTT server.
|
||||
// Should be called in the loop function and it will take care if connecting.
|
||||
void MQTT_connect() {
|
||||
int8_t ret;
|
||||
@ -84,34 +59,23 @@ void MQTT_connect() {
|
||||
delay(5000); // wait 5 seconds
|
||||
}
|
||||
}`;
|
||||
Blockly.Arduino.loopCodeOnce_["mqtt_connect"] = "MQTT_connect();";
|
||||
var code = "" + feed_client + ".publish(" + value + ");";
|
||||
return code;
|
||||
Blockly.Arduino.loopCodeOnce_['mqtt_connect'] = 'MQTT_connect();';
|
||||
var code = '' + feed_client + '.publish(' + value + ');';
|
||||
return code
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_mqtt_subscribe = function (block) {
|
||||
var feedname = this.getFieldValue("subscribefeed");
|
||||
var x = 5,
|
||||
feed_client;
|
||||
var feedname = this.getFieldValue('subscribefeed');
|
||||
var x = 5, feed_client;
|
||||
feed_client = feedname.substr(feedname.length - x, x);
|
||||
Blockly.Arduino.definitions_["mqtt_" + feed_client + ""] =
|
||||
"Adafruit_MQTT_Subscribe " +
|
||||
feed_client +
|
||||
"= Adafruit_MQTT_Subscribe(&mqtt," +
|
||||
feedname +
|
||||
");";
|
||||
Blockly.Arduino.codeFunctions_["mqtt_" + feed_client + "callbackFunction"] =
|
||||
`void ` +
|
||||
feed_client +
|
||||
`Callback (double x){
|
||||
Blockly.Arduino.definitions_['mqtt_' + feed_client + ''] = 'Adafruit_MQTT_Subscribe ' + feed_client + '= Adafruit_MQTT_Subscribe(&mqtt,' + feedname + ');';
|
||||
Blockly.Arduino.codeFunctions_['mqtt_' + feed_client + 'callbackFunction'] = `void ` + feed_client + `Callback (double x){
|
||||
Serial.println(x);
|
||||
}`;
|
||||
Blockly.Arduino.setupCode_["mqtt_" + feed_client + "_callback"] =
|
||||
"" + feed_client + ".setCallback(" + feed_client + "Callback);";
|
||||
Blockly.Arduino.setupCode_["mqtt_" + feed_client + "_subscribe"] =
|
||||
"mqtt.subscribe(&" + feed_client + ");";
|
||||
Blockly.Arduino.loopCodeOnce_["mqtt_processPackages"] =
|
||||
"mqtt.processPackets(10);";
|
||||
var code = "";
|
||||
Blockly.Arduino.setupCode_['mqtt_' + feed_client + '_callback'] = '' + feed_client + '.setCallback(' + feed_client + 'Callback);';
|
||||
Blockly.Arduino.setupCode_['mqtt_' + feed_client + '_subscribe'] = 'mqtt.subscribe(&' + feed_client + ');';
|
||||
Blockly.Arduino.loopCodeOnce_['mqtt_processPackages'] = 'mqtt.processPackets(10);';
|
||||
var code = '';
|
||||
return code;
|
||||
};
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
|
||||
/**
|
||||
* Code generator to add code into the setup() and loop() functions.
|
||||
@ -6,92 +7,92 @@ import * as Blockly from "blockly/core";
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {string} Completed code.
|
||||
*/
|
||||
Blockly.Arduino["arduino_functions"] = function (block) {
|
||||
Blockly.Arduino['arduino_functions'] = function (block) {
|
||||
// Edited version of Blockly.Generator.prototype.statementToCode
|
||||
function statementToCodeNoTab(block, name) {
|
||||
var targetBlock = block.getInputTargetBlock(name);
|
||||
var code = Blockly.Arduino.blockToCode(targetBlock);
|
||||
if (typeof code != "string") {
|
||||
throw new Error(
|
||||
'Expecting code from statement block "' + targetBlock.type + '".'
|
||||
);
|
||||
if (typeof code != 'string') {
|
||||
throw new Error('Expecting code from statement block "' + targetBlock.type + '".');
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
var setupBranch = Blockly.Arduino.statementToCode(block, "SETUP_FUNC");
|
||||
var setupBranch = Blockly.Arduino.statementToCode(block, 'SETUP_FUNC');
|
||||
// //var setupCode = Blockly.Arduino.scrub_(block, setupBranch); No comment block
|
||||
if (setupBranch) {
|
||||
Blockly.Arduino.setupCode_["mainsetup"] = setupBranch;
|
||||
Blockly.Arduino.setupCode_['mainsetup'] = setupBranch;
|
||||
}
|
||||
|
||||
var loopBranch = statementToCodeNoTab(block, "LOOP_FUNC");
|
||||
var loopBranch = statementToCodeNoTab(block, 'LOOP_FUNC');
|
||||
//var loopcode = Blockly.Arduino.scrub_(block, loopBranch); No comment block
|
||||
return loopBranch;
|
||||
};
|
||||
|
||||
Blockly.Arduino["procedures_defreturn"] = function (block) {
|
||||
Blockly.Arduino['procedures_defreturn'] = function (block) {
|
||||
// Define a procedure with a return value.
|
||||
const funcName = Blockly.Arduino.nameDB_.getName(
|
||||
block.getFieldValue("NAME"),
|
||||
const funcName = Blockly.Arduino.variableDB_.getName(
|
||||
block.getFieldValue('NAME'),
|
||||
Blockly.Procedures.NAME_TYPE
|
||||
);
|
||||
const branch = Blockly.Arduino.statementToCode(block, "STACK");
|
||||
const returnType = block.getFieldValue("RETURN TYPE") || "void";
|
||||
const branch = Blockly.Arduino.statementToCode(block, 'STACK');
|
||||
const returnType = block.getFieldValue('RETURN TYPE') || 'void';
|
||||
|
||||
let returnValue =
|
||||
Blockly.Arduino.valueToCode(block, "RETURN", Blockly.Arduino.ORDER_NONE) ||
|
||||
"";
|
||||
Blockly.Arduino.valueToCode(block, 'RETURN', Blockly.Arduino.ORDER_NONE) ||
|
||||
'';
|
||||
if (returnValue) {
|
||||
returnValue = Blockly.Arduino.INDENT + "return " + returnValue + ";\n";
|
||||
returnValue = Blockly.Arduino.INDENT + 'return ' + returnValue + ';\n';
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < block.argumentVarModels_.length; i++) {
|
||||
args[i] =
|
||||
translateType(block.argumentVarModels_[i].type) +
|
||||
" " +
|
||||
' ' +
|
||||
block.argumentVarModels_[i].name;
|
||||
}
|
||||
let code =
|
||||
translateType(returnType) +
|
||||
" " +
|
||||
' ' +
|
||||
funcName +
|
||||
"(" +
|
||||
args.join(", ") +
|
||||
") {\n" +
|
||||
'(' +
|
||||
args.join(', ') +
|
||||
') {\n' +
|
||||
branch +
|
||||
returnValue +
|
||||
"}";
|
||||
'}';
|
||||
code = Blockly.Arduino.scrub_(block, code);
|
||||
// Add % so as not to collide with helper functions in definitions list.
|
||||
Blockly.Arduino.functionNames_["%" + funcName] = code;
|
||||
Blockly.Arduino.functionNames_['%' + funcName] = code;
|
||||
return null;
|
||||
};
|
||||
|
||||
function translateType(type) {
|
||||
console.log(type);
|
||||
switch (type) {
|
||||
case "int":
|
||||
return "int";
|
||||
case "String":
|
||||
return "String";
|
||||
case "void":
|
||||
return "void";
|
||||
case "boolean":
|
||||
return "boolean";
|
||||
case "float":
|
||||
return "float";
|
||||
|
||||
case 'int':
|
||||
return 'int';
|
||||
case 'String':
|
||||
return 'String';
|
||||
case 'void':
|
||||
return 'void';
|
||||
case 'boolean':
|
||||
return 'boolean';
|
||||
case 'float':
|
||||
return 'float'
|
||||
default:
|
||||
throw new Error("Invalid Parameter Type");
|
||||
throw new Error('Invalid Parameter Type');
|
||||
}
|
||||
}
|
||||
|
||||
Blockly.Arduino["procedures_defnoreturn"] =
|
||||
Blockly.Arduino["procedures_defreturn"];
|
||||
Blockly.Arduino['procedures_defnoreturn'] =
|
||||
Blockly.Arduino['procedures_defreturn'];
|
||||
|
||||
Blockly.Arduino["procedures_callreturn"] = function (block) {
|
||||
Blockly.Arduino['procedures_callreturn'] = function (block) {
|
||||
// Call a procedure with a return value.
|
||||
const funcName = Blockly.Arduino.nameDB_.getName(
|
||||
block.getFieldValue("NAME"),
|
||||
const funcName = Blockly.Arduino.variableDB_.getName(
|
||||
block.getFieldValue('NAME'),
|
||||
Blockly.Procedures.NAME_TYPE
|
||||
);
|
||||
const args = [];
|
||||
@ -99,18 +100,18 @@ Blockly.Arduino["procedures_callreturn"] = function (block) {
|
||||
args[i] =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"ARG" + i,
|
||||
'ARG' + i,
|
||||
Blockly.Arduino.ORDER_COMMA
|
||||
) || "null";
|
||||
) || 'null';
|
||||
}
|
||||
const code = funcName + "(" + args.join(", ") + ")";
|
||||
const code = funcName + '(' + args.join(', ') + ')';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino["procedures_callnoreturn"] = function (block) {
|
||||
Blockly.Arduino['procedures_callnoreturn'] = function (block) {
|
||||
// Call a procedure with no return value.
|
||||
const funcName = Blockly.Arduino.nameDB_.getName(
|
||||
block.getFieldValue("NAME"),
|
||||
const funcName = Blockly.Arduino.variableDB_.getName(
|
||||
block.getFieldValue('NAME'),
|
||||
Blockly.Procedures.NAME_TYPE
|
||||
);
|
||||
const args = [];
|
||||
@ -118,10 +119,10 @@ Blockly.Arduino["procedures_callnoreturn"] = function (block) {
|
||||
args[i] =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"ARG" + i,
|
||||
'ARG' + i,
|
||||
Blockly.Arduino.ORDER_COMMA
|
||||
) || "null";
|
||||
) || 'null';
|
||||
}
|
||||
|
||||
return funcName + "(" + args.join(", ") + ");\n";
|
||||
return funcName + '(' + args.join(', ') + ');\n';
|
||||
};
|
||||
@ -1,126 +0,0 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
|
||||
Blockly.Arduino.sensebox_phyphox_init = function () {
|
||||
var name = this.getFieldValue("devicename");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["phyphox_library"] = `#include <phyphoxBle.h>`;
|
||||
Blockly.Arduino.phyphoxSetupCode_[
|
||||
"phyphox_start"
|
||||
] = `PhyphoxBLE::start("${name}");`;
|
||||
var code = ``;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_phyphox_experiment = function () {
|
||||
var experimentname = "experiment";
|
||||
var title = this.getFieldValue("title").replace(/[^a-zA-Z0-9]/g, "");
|
||||
var description = this.getFieldValue("description");
|
||||
var branch = Blockly.Arduino.statementToCode(this, "view");
|
||||
Blockly.Arduino.phyphoxSetupCode_[
|
||||
`PhyphoxBleExperiment_${experimentname}`
|
||||
] = `PhyphoxBleExperiment ${experimentname};`;
|
||||
Blockly.Arduino.phyphoxSetupCode_[
|
||||
`setTitle_${title}`
|
||||
] = `${experimentname}.setTitle("${title}");`;
|
||||
Blockly.Arduino.phyphoxSetupCode_[
|
||||
`setCategory_senseBoxExperiments}`
|
||||
] = `${experimentname}.setCategory("senseBox Experimente");`;
|
||||
Blockly.Arduino.phyphoxSetupCode_[
|
||||
`setDescription_${description}`
|
||||
] = `${experimentname}.setDescription("${description}");`;
|
||||
Blockly.Arduino.phyphoxSetupCode_[
|
||||
`addView_${experimentname}`
|
||||
] = `PhyphoxBleExperiment::View firstView;\nfirstView.setLabel("Messwerte"); //Create a "view"`;
|
||||
Blockly.Arduino.phyphoxSetupCode_[`addGraph`] = `${branch}`;
|
||||
Blockly.Arduino.phyphoxSetupCode_[
|
||||
`addView_firstview`
|
||||
] = `${experimentname}.addView(firstView);`; //Attach view to experiment
|
||||
Blockly.Arduino.phyphoxSetupCode_[
|
||||
`addExperiment_${experimentname}`
|
||||
] = `PhyphoxBLE::addExperiment(${experimentname});`; //Attach experiment to server
|
||||
|
||||
var code = ``;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino["sensebox_phyphox_timestamp"] = function () {
|
||||
var code = 0;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino["sensebox_phyphox_channel"] = function () {
|
||||
var channel = parseFloat(this.getFieldValue("channel"));
|
||||
var code = channel;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_phyphox_sendchannel = function (block) {
|
||||
var channel = this.getFieldValue("channel");
|
||||
var value =
|
||||
Blockly.Arduino.valueToCode(this, "value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"1";
|
||||
|
||||
var code = `float channel${channel} = ${value};\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_phyphox_graph = function () {
|
||||
var label = this.getFieldValue("label").replace(/[^a-zA-Z0-9]/g, "");
|
||||
var unitx = this.getFieldValue("unitx");
|
||||
var unity = this.getFieldValue("unity");
|
||||
var labelx = this.getFieldValue("labelx");
|
||||
var labely = this.getFieldValue("labely");
|
||||
var style = this.getFieldValue("style");
|
||||
var channelX =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"channel0",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || 0;
|
||||
var channelY =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"channel1",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || 1;
|
||||
|
||||
var code = `PhyphoxBleExperiment::Graph ${label};\n`; //Create graph which will plot random numbers over time
|
||||
code += `${label}.setLabel("${label}");\n`;
|
||||
code += `${label}.setUnitX("${unitx}");\n`;
|
||||
code += `${label}.setUnitY("${unity}");\n`;
|
||||
code += `${label}.setLabelX("${labelx}");\n`;
|
||||
code += `${label}.setLabelY("${labely}");\n`;
|
||||
if (style === "dots"){
|
||||
code += `${label}.setStyle("${style}");\n`;
|
||||
}
|
||||
code += `${label}.setChannel(${channelX}, ${channelY});\n`;
|
||||
code += `firstView.addElement(${label});\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_phyphox_experiment_send = function () {
|
||||
var branch = Blockly.Arduino.statementToCode(this, "sendValues");
|
||||
var blocks = this.getDescendants();
|
||||
var count = 0;
|
||||
if (blocks !== undefined) {
|
||||
for (var i = 0; i < blocks.length; i++) {
|
||||
if (blocks[i].type === "sensebox_phyphox_sendchannel") {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count === 5) {
|
||||
}
|
||||
var string = "";
|
||||
|
||||
for (var j = 1; j <= count; j++) {
|
||||
if (string === "") {
|
||||
string += `channel${j}`;
|
||||
} else if (string !== "") {
|
||||
string += `, channel${j}`;
|
||||
}
|
||||
}
|
||||
Blockly.Arduino.loopCodeOnce_["phyphox_poll"] = `PhyphoxBLE::poll();`;
|
||||
var code = `${branch}\nPhyphoxBLE::write(${string});`;
|
||||
return code;
|
||||
};
|
||||
@ -1,79 +1,45 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
/*Display Blocks*/
|
||||
Blockly.Arduino.sensebox_display_beginDisplay = function () {
|
||||
Blockly.Arduino.libraries_["library_spi"] = "#include <SPI.h>";
|
||||
Blockly.Arduino.libraries_["library_wire"] = "#include <Wire.h>";
|
||||
Blockly.Arduino.libraries_["library_AdafruitGFX"] =
|
||||
"#include <Adafruit_GFX.h> // http://librarymanager/All#Adafruit_GFX_Library";
|
||||
Blockly.Arduino.libraries_["library_AdafruitSSD1306"] =
|
||||
"#include <Adafruit_SSD1306.h> // http://librarymanager/All#Adafruit_SSD1306";
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.definitions_[
|
||||
"define_display_size"
|
||||
] = `#define SCREEN_WIDTH 128\n#define SCREEN_HEIGHT 64`;
|
||||
Blockly.Arduino.definitions_["define_display"] =
|
||||
"#define OLED_RESET -1\nAdafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);";
|
||||
|
||||
Blockly.Arduino.setupCode_["sensebox_display_begin"] =
|
||||
"senseBoxIO.powerI2C(true);\ndelay(2000);\ndisplay.begin(SSD1306_SWITCHCAPVCC, 0x3D);\ndisplay.display();\ndelay(100);\ndisplay.clearDisplay();";
|
||||
var code = "";
|
||||
Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>';
|
||||
Blockly.Arduino.libraries_['library_wire'] = '#include <Wire.h>';
|
||||
Blockly.Arduino.libraries_['library_AdafruitGFX'] = '#include <Adafruit_GFX.h>';
|
||||
Blockly.Arduino.libraries_['library_AdafruitSSD1306'] = '#include <Adafruit_SSD1306.h>';
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['define_display'] = '#define OLED_RESET 4\nAdafruit_SSD1306 display(OLED_RESET);';
|
||||
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_display_clearDisplay = function () {
|
||||
var code = "display.clearDisplay();\n";
|
||||
var code = 'display.clearDisplay();\n';
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_display_printDisplay = function () {
|
||||
var x = this.getFieldValue("X");
|
||||
var y = this.getFieldValue("Y");
|
||||
var printDisplay =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"printDisplay",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || '"Keine Eingabe"';
|
||||
var size = this.getFieldValue("SIZE");
|
||||
var color = this.getFieldValue("COLOR");
|
||||
var code = "display.setCursor(" + x + "," + y + ");\n";
|
||||
code += "display.setTextSize(" + size + ");\n";
|
||||
code += "display.setTextColor(" + color + ");\n";
|
||||
code += "display.println(" + printDisplay + ");\n";
|
||||
var x = this.getFieldValue('X');
|
||||
var y = this.getFieldValue('Y');
|
||||
var printDisplay = Blockly.Arduino.valueToCode(this, 'printDisplay', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"';
|
||||
var size = this.getFieldValue('SIZE');
|
||||
var color = this.getFieldValue('COLOR');
|
||||
var code = 'display.setCursor(' + x + ',' + y + ');\n';
|
||||
code += 'display.setTextSize(' + size + ');\n';
|
||||
code += 'display.setTextColor(' + color + ');\n';
|
||||
code += 'display.println(' + printDisplay + ');\n';
|
||||
return code;
|
||||
};
|
||||
|
||||
|
||||
Blockly.Arduino.sensebox_display_fastPrint = function () {
|
||||
var title1 =
|
||||
Blockly.Arduino.valueToCode(this, "Title1", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var value1 = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Value1",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var dimension1 =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Dimension1",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || "0";
|
||||
var title2 =
|
||||
Blockly.Arduino.valueToCode(this, "Title2", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var value2 = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Value2",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var dimension2 =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Dimension2",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || "0";
|
||||
Blockly.Arduino.codeFunctions_["sensebox_fastPrint"] = `
|
||||
var title1 = Blockly.Arduino.valueToCode(this, 'Title1', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var value1 = Blockly.Arduino.valueToCode(this, 'Value1', Blockly.Arduino.ORDER_ATOMIC);
|
||||
var dimension1 = Blockly.Arduino.valueToCode(this, 'Dimension1', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var title2 = Blockly.Arduino.valueToCode(this, 'Title2', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var value2 = Blockly.Arduino.valueToCode(this, 'Value2', Blockly.Arduino.ORDER_ATOMIC);
|
||||
var dimension2 = Blockly.Arduino.valueToCode(this, 'Dimension2', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
Blockly.Arduino.codeFunctions_['sensebox_fastPrint'] = `
|
||||
void printOnDisplay(String title1, String measurement1, String unit1, String title2, String measurement2, String unit2) {
|
||||
|
||||
display.setCursor(0, 0);
|
||||
@ -96,141 +62,67 @@ Blockly.Arduino.sensebox_display_fastPrint = function () {
|
||||
display.setTextSize(1);
|
||||
display.println(unit2);
|
||||
}
|
||||
`;
|
||||
`
|
||||
var code = ` printOnDisplay(${title1}, String(${value1}), ${dimension1}, ${title2}, String(${value2}), ${dimension2});\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_display_show = function (block) {
|
||||
var show = Blockly.Arduino.statementToCode(block, "SHOW");
|
||||
var code = "";
|
||||
var show = Blockly.Arduino.statementToCode(block, 'SHOW');
|
||||
var code = '';
|
||||
code += show;
|
||||
code += "display.display();\n";
|
||||
code += 'display.display();\n';
|
||||
return code;
|
||||
};
|
||||
Blockly.Arduino.sensebox_display_plotDisplay = function () {
|
||||
var YLabel =
|
||||
Blockly.Arduino.valueToCode(this, "YLabel", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"Y";
|
||||
var XLabel =
|
||||
Blockly.Arduino.valueToCode(this, "XLabel", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"X";
|
||||
var Title =
|
||||
Blockly.Arduino.valueToCode(this, "Title", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"Title";
|
||||
var XRange1 =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"XRange1",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || "0";
|
||||
var XRange2 =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"XRange2",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || "0";
|
||||
var YRange1 =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"YRange1",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || "0";
|
||||
var YRange2 =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"YRange2",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || "0";
|
||||
var XTick =
|
||||
Blockly.Arduino.valueToCode(this, "XTick", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var YTick =
|
||||
Blockly.Arduino.valueToCode(this, "YTick", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var TimeFrame =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"TimeFrame",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || "0";
|
||||
var plotDisplay =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"plotDisplay",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || '"Keine Eingabe"';
|
||||
Blockly.Arduino.libraries_["library_plot"] = "#include <Plot.h>";
|
||||
Blockly.Arduino.definitions_["define_plot_class"] =
|
||||
"Plot DataPlot(&display);\n";
|
||||
Blockly.Arduino.variables_["define_plot_class"] =
|
||||
"const double TIMEFRAME = " + TimeFrame + ";\n";
|
||||
Blockly.Arduino.setupCode_["sensebox_plot_setup"] =
|
||||
"DataPlot.setTitle(" +
|
||||
Title +
|
||||
");\nDataPlot.setXLabel(" +
|
||||
XLabel +
|
||||
");\nDataPlot.setYLabel(" +
|
||||
YLabel +
|
||||
");\nDataPlot.setXRange(" +
|
||||
XRange1 +
|
||||
"," +
|
||||
XRange2 +
|
||||
");\nDataPlot.setYRange(" +
|
||||
YRange1 +
|
||||
"," +
|
||||
YRange2 +
|
||||
");\nDataPlot.setXTick(" +
|
||||
XTick +
|
||||
");\nDataPlot.setYTick(" +
|
||||
YTick +
|
||||
");\nDataPlot.setXPrecision(0);\nDataPlot.setYPrecision(0);\n";
|
||||
var code = "DataPlot.clear();";
|
||||
code +=
|
||||
"double starttime = millis();\ndouble t = 0;\nwhile (t <= TIMEFRAME) {\nt = (millis() - starttime) / 1000.0;\nfloat value = " +
|
||||
plotDisplay +
|
||||
";\n";
|
||||
code += "DataPlot.addDataPoint(t,value);\n}\n";
|
||||
var YLabel = Blockly.Arduino.valueToCode(this, 'YLabel', Blockly.Arduino.ORDER_ATOMIC) || 'Y'
|
||||
var XLabel = Blockly.Arduino.valueToCode(this, 'XLabel', Blockly.Arduino.ORDER_ATOMIC) || 'X'
|
||||
var Title = Blockly.Arduino.valueToCode(this, 'Title', Blockly.Arduino.ORDER_ATOMIC) || 'Title'
|
||||
var XRange1 = Blockly.Arduino.valueToCode(this, 'XRange1', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var XRange2 = Blockly.Arduino.valueToCode(this, 'XRange2', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var YRange1 = Blockly.Arduino.valueToCode(this, 'YRange1', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var YRange2 = Blockly.Arduino.valueToCode(this, 'YRange2', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var XTick = Blockly.Arduino.valueToCode(this, 'XTick', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var YTick = Blockly.Arduino.valueToCode(this, 'YTick', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var TimeFrame = Blockly.Arduino.valueToCode(this, 'TimeFrame', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var plotDisplay = Blockly.Arduino.valueToCode(this, 'plotDisplay', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"';
|
||||
Blockly.Arduino.libraries_['library_plot'] = '#include <Plot.h>';
|
||||
Blockly.Arduino.definitions_['define_plot_class'] = 'Plot DataPlot(&display);\n';
|
||||
Blockly.Arduino.variables_['define_plot_class'] = 'const double TIMEFRAME = ' + TimeFrame + ';\n';
|
||||
Blockly.Arduino.setupCode_['sensebox_plot_setup'] = 'DataPlot.setTitle(' + Title + ');\nDataPlot.setXLabel(' + XLabel + ');\nDataPlot.setYLabel(' + YLabel + ');\nDataPlot.setXRange(' + XRange1 + ',' + XRange2 + ');\nDataPlot.setYRange(' + YRange1 + ',' + YRange2 + ');\nDataPlot.setXTick(' + XTick + ');\nDataPlot.setYTick(' + YTick + ');\nDataPlot.setXPrecision(0);\nDataPlot.setYPrecision(0);\n';
|
||||
var code = 'DataPlot.clear();'
|
||||
code += 'double starttime = millis();\ndouble t = 0;\nwhile (t <= TIMEFRAME) {\nt = (millis() - starttime) / 1000.0;\nfloat value = ' + plotDisplay + ';\n';
|
||||
code += 'DataPlot.addDataPoint(t,value);\n}\n';
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_display_fillCircle = function () {
|
||||
let code = "";
|
||||
var x =
|
||||
Blockly.Arduino.valueToCode(this, "X", Blockly.Arduino.ORDER_ATOMIC) || "0";
|
||||
var y =
|
||||
Blockly.Arduino.valueToCode(this, "Y", Blockly.Arduino.ORDER_ATOMIC) || "0";
|
||||
var radius =
|
||||
Blockly.Arduino.valueToCode(this, "Radius", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var fill = this.getFieldValue("FILL");
|
||||
if (fill === "TRUE") {
|
||||
code = "display.fillCircle(" + x + "," + y + "," + radius + ",1);\n";
|
||||
} else {
|
||||
code = "display.drawCircle(" + x + "," + y + "," + radius + ",1);\n";
|
||||
let code = '';
|
||||
var x = Blockly.Arduino.valueToCode(this, 'X', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var y = Blockly.Arduino.valueToCode(this, 'Y', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var radius = Blockly.Arduino.valueToCode(this, 'Radius', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var fill = this.getFieldValue('FILL');
|
||||
if (fill === 'TRUE') {
|
||||
code = 'display.fillCircle(' + x + ',' + y + ',' + radius + ',1);\n';
|
||||
}
|
||||
else {
|
||||
code = 'display.drawCircle(' + x + ',' + y + ',' + radius + ',1);\n';
|
||||
}
|
||||
return code;
|
||||
};
|
||||
}
|
||||
|
||||
Blockly.Arduino.sensebox_display_drawRectangle = function () {
|
||||
let code = "";
|
||||
var x =
|
||||
Blockly.Arduino.valueToCode(this, "X", Blockly.Arduino.ORDER_ATOMIC) || "0";
|
||||
var y =
|
||||
Blockly.Arduino.valueToCode(this, "Y", Blockly.Arduino.ORDER_ATOMIC) || "0";
|
||||
var width =
|
||||
Blockly.Arduino.valueToCode(this, "width", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var height =
|
||||
Blockly.Arduino.valueToCode(this, "height", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var fill = this.getFieldValue("FILL");
|
||||
if (fill === "TRUE") {
|
||||
code =
|
||||
"display.fillRect(" + x + "," + y + "," + width + "," + height + ",1);\n";
|
||||
} else {
|
||||
code =
|
||||
"display.drawRect(" + x + "," + y + "," + width + "," + height + ",1);\n";
|
||||
let code = '';
|
||||
var x = Blockly.Arduino.valueToCode(this, 'X', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var y = Blockly.Arduino.valueToCode(this, 'Y', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var width = Blockly.Arduino.valueToCode(this, 'width', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var height = Blockly.Arduino.valueToCode(this, 'height', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
var fill = this.getFieldValue('FILL');
|
||||
if (fill === 'TRUE') {
|
||||
code = 'display.fillRect(' + x + ',' + y + ',' + width + ',' + height + ',1);\n';
|
||||
}
|
||||
else {
|
||||
code = 'display.drawRect(' + x + ',' + y + ',' + width + ',' + height + ',1);\n';
|
||||
}
|
||||
return code;
|
||||
};
|
||||
}
|
||||
@ -3,7 +3,6 @@ import * as Blockly from 'blockly/core';
|
||||
Blockly.Arduino.sensebox_led = function () {
|
||||
var dropdown_pin = this.getFieldValue('PIN');
|
||||
var dropdown_stat = this.getFieldValue('STAT');
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.setupCode_['setup_led_' + dropdown_pin] = 'pinMode(' + dropdown_pin + ', OUTPUT);';
|
||||
var code = 'digitalWrite(' + dropdown_pin + ',' + dropdown_stat + ');\n'
|
||||
return code;
|
||||
@ -12,7 +11,6 @@ Blockly.Arduino.sensebox_led = function () {
|
||||
Blockly.Arduino.sensebox_rgb_led = function () {
|
||||
var dropdown_pin = this.getFieldValue('PIN');
|
||||
var color = Blockly.Arduino.valueToCode(this, 'COLOR', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_['define_rgb_led' + dropdown_pin] = '#include <Adafruit_NeoPixel.h>\n Adafruit_NeoPixel rgb_led_' + dropdown_pin + ' = Adafruit_NeoPixel(1,' + dropdown_pin + ',NEO_RGB + NEO_KHZ800);\n';
|
||||
Blockly.Arduino.setupCode_['setup_rgb_led' + dropdown_pin] = 'rgb_led_' + dropdown_pin + '.begin();';
|
||||
var code = 'rgb_led_' + dropdown_pin + '.setPixelColor(0,rgb_led_' + dropdown_pin + '.Color(' + color + '));\n';
|
||||
@ -25,7 +23,6 @@ Blockly.Arduino.sensebox_ws2818_led_init = function () {
|
||||
var dropdown_pin = this.getFieldValue('Port');
|
||||
var numPixel = Blockly.Arduino.valueToCode(this, 'NUMBER', Blockly.Arduino.ORDER_ATOMIC) || '1';
|
||||
var brightness = Blockly.Arduino.valueToCode(this, 'BRIGHTNESS', Blockly.Arduino.ORDER_ATOMIC) || '50'
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.definitions_['define_rgb_led' + dropdown_pin] = `#include <Adafruit_NeoPixel.h>\n Adafruit_NeoPixel rgb_led_${dropdown_pin}= Adafruit_NeoPixel(${numPixel}, ${dropdown_pin},NEO_GRB + NEO_KHZ800);\n`;
|
||||
Blockly.Arduino.setupCode_['setup_rgb_led' + dropdown_pin] = 'rgb_led_' + dropdown_pin + '.begin();\n';
|
||||
Blockly.Arduino.setupCode_['setup_rgb_led_brightness' + dropdown_pin] = `rgb_led_${dropdown_pin}.setBrightness(${brightness});\n`;
|
||||
@ -33,10 +30,10 @@ Blockly.Arduino.sensebox_ws2818_led_init = function () {
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_ws2818_led = function () {
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
var dropdown_pin = this.getFieldValue('Port');
|
||||
var position = Blockly.Arduino.valueToCode(this, 'POSITION', Blockly.Arduino.ORDER_ATOMIC) || '0';
|
||||
var color = Blockly.Arduino.valueToCode(this, 'COLOR', Blockly.Arduino.ORDER_ATOMIC) || '0'
|
||||
console.log(color)
|
||||
var code = `rgb_led_${dropdown_pin}.setPixelColor(${position},rgb_led_${dropdown_pin}.Color(${color}));\nrgb_led_${dropdown_pin}.show();\n`;
|
||||
return code;
|
||||
};
|
||||
@ -52,7 +49,6 @@ function hexToRgb(hex) {
|
||||
}
|
||||
|
||||
Blockly.Arduino['colour_picker'] = function (block) {
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
const rgb = hexToRgb(block.getFieldValue('COLOUR'));
|
||||
|
||||
return [rgb.r + ', ' + rgb.g + ', ' + rgb.b, Blockly.Arduino.ORDER_ATOMIC];
|
||||
@ -63,7 +59,6 @@ Blockly.Arduino['colour_random'] = function (block) {
|
||||
};
|
||||
|
||||
Blockly.Arduino['colour_rgb'] = function (block) {
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
const red = Blockly.Arduino.valueToCode(block, 'RED', Blockly.Arduino.ORDER_ATOMIC);
|
||||
const green = Blockly.Arduino.valueToCode(block, 'GREEN', Blockly.Arduino.ORDER_ATOMIC);
|
||||
const blue = Blockly.Arduino.valueToCode(block, 'BLUE', Blockly.Arduino.ORDER_ATOMIC);
|
||||
|
||||
@ -1,27 +1,27 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
|
||||
Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) {
|
||||
var deivceID = this.getFieldValue("DEVICEID");
|
||||
var appID = this.getFieldValue("APPID");
|
||||
var appKey = this.getFieldValue("APPKEY");
|
||||
var interval = this.getFieldValue("INTERVAL");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["library_spi"] = "#include <SPI.h>";
|
||||
Blockly.Arduino.libraries_["library_lmic"] =
|
||||
"#include <lmic.h> // http://librarymanager/All#IBM_LMIC_framework";
|
||||
Blockly.Arduino.libraries_["library_hal"] = "#include <hal/hal.h>";
|
||||
Blockly.Arduino.definitions_["define_LoRaVariablesOTAA"] = `
|
||||
static const u1_t PROGMEM APPEUI[8]= {${appID}};
|
||||
var deivceID = this.getFieldValue('DEVICEID');
|
||||
var appID = this.getFieldValue('APPID');
|
||||
var appKey = this.getFieldValue('APPKEY');
|
||||
var interval = this.getFieldValue('INTERVAL');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>';
|
||||
Blockly.Arduino.libraries_['library_lmic'] = '#include <lmic.h>';
|
||||
Blockly.Arduino.libraries_['library_hal'] = '#include <hal/hal.h>';
|
||||
Blockly.Arduino.definitions_['define_LoRaVariablesOTAA'] = `
|
||||
static const u1_t PROGMEM APPEUI[8]= `+ appID + ` ;
|
||||
void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI , 8);}
|
||||
|
||||
static const u1_t PROGMEM DEVEUI[8]= {${deivceID}};
|
||||
static const u1_t PROGMEM DEVEUI[8]= `+ deivceID + `;
|
||||
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI , 8);}
|
||||
|
||||
// This key should be in big endian format (or, since it is not really a
|
||||
// number but a block of memory, endianness does not really apply). In
|
||||
// practice, a key taken from ttnctl can be copied as-is.
|
||||
// The key shown here is the semtech default key.
|
||||
static const u1_t PROGMEM APPKEY[16] = {${appKey}};
|
||||
static const u1_t PROGMEM APPKEY[16] = `+ appKey + `;
|
||||
void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY , 16);}
|
||||
|
||||
static osjob_t sendjob;
|
||||
@ -38,7 +38,7 @@ Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) {
|
||||
.dio = {PIN_XB1_INT, PIN_XB1_INT, LMIC_UNUSED_PIN},
|
||||
};`;
|
||||
|
||||
Blockly.Arduino.codeFunctions_["functions_initLora"] = `
|
||||
Blockly.Arduino.codeFunctions_['functions_initLora'] = `
|
||||
void initLora() {
|
||||
delay(2000);
|
||||
// LMIC init
|
||||
@ -48,9 +48,9 @@ Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) {
|
||||
|
||||
// Start job (sending automatically starts OTAA too)
|
||||
do_send(&sendjob);
|
||||
}`;
|
||||
}`
|
||||
|
||||
Blockly.Arduino.codeFunctions_["functions_onEvent"] = `
|
||||
Blockly.Arduino.codeFunctions_['functions_onEvent'] = `
|
||||
void onEvent (ev_t ev) {
|
||||
Serial.print(os_getTime());
|
||||
Serial.print(": ");
|
||||
@ -120,18 +120,16 @@ Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) {
|
||||
break;
|
||||
}
|
||||
}`;
|
||||
Blockly.Arduino.loraSetupCode_["initLora"] = "initLora();\n";
|
||||
Blockly.Arduino.setupCode_["serial.begin"] =
|
||||
"Serial.begin(9600);\ndelay(1000);\n";
|
||||
var code = "";
|
||||
Blockly.Arduino.loraSetupCode_['initLora'] = 'initLora();\n';
|
||||
Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\ndelay(1000);\n';
|
||||
var code = '';
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_message_send = function (block) {
|
||||
Blockly.Arduino.libraries_["library_lora_message"] =
|
||||
"#include <LoraMessage.h>";
|
||||
var lora_sensor_values = Blockly.Arduino.statementToCode(block, "DO");
|
||||
Blockly.Arduino.functionNames_["functions_do_send"] = `
|
||||
Blockly.Arduino.libraries_['library_lora_message'] = '#include <LoraMessage.h>';
|
||||
var lora_sensor_values = Blockly.Arduino.statementToCode(block, 'DO');
|
||||
Blockly.Arduino.functionNames_['functions_do_send'] = `
|
||||
void do_send(osjob_t* j){
|
||||
// Check if there is not a current TX/RX job running
|
||||
if (LMIC.opmode & OP_TXRXPEND) {
|
||||
@ -146,42 +144,39 @@ Blockly.Arduino.sensebox_lora_message_send = function (block) {
|
||||
}
|
||||
// Next TX is scheduled after TX_COMPLETE event.
|
||||
}`;
|
||||
Blockly.Arduino.loopCodeOnce_["os_runloop"] = "os_runloop_once();";
|
||||
return "";
|
||||
};
|
||||
Blockly.Arduino.loopCodeOnce_['os_runloop'] = 'os_runloop_once();'
|
||||
return ''
|
||||
}
|
||||
|
||||
/**
|
||||
* Block send Data to TTN
|
||||
*/
|
||||
Blockly.Arduino.sensebox_send_lora_sensor_value = function (block) {
|
||||
const reading =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
'"Keine Eingabe"';
|
||||
var messageBytes = this.getFieldValue("MESSAGE_BYTES");
|
||||
var code = "";
|
||||
const reading = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"';
|
||||
var messageBytes = this.getFieldValue('MESSAGE_BYTES');
|
||||
var code = ''
|
||||
switch (Number(messageBytes)) {
|
||||
case 1:
|
||||
code = `message.addUint8(${reading});\n`;
|
||||
code = `message.addUint8(${reading});\n`
|
||||
break;
|
||||
case 2:
|
||||
code = `message.addUint16(${reading});\n`;
|
||||
code = `message.addUint16(${reading});\n`
|
||||
break;
|
||||
case 3:
|
||||
code = `message.addUint8(${reading});
|
||||
message.addUint16(${reading} >> 8);\n`;
|
||||
message.addUint16(${reading} >> 8);\n`
|
||||
break;
|
||||
default:
|
||||
code = `message.addUint16(${reading});\n`;
|
||||
code = `message.addUint16(${reading});\n`
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_send = function (block) {
|
||||
Blockly.Arduino.libraries_["library_cayene"] =
|
||||
"#include <CayenneLPP.h> // http://librarymanager/All#CayenneLPP";
|
||||
Blockly.Arduino.variables_["variable_cayenne"] = "CayenneLPP lpp(51);";
|
||||
var lora_sensor_values = Blockly.Arduino.statementToCode(block, "DO");
|
||||
Blockly.Arduino.functionNames_["functions_do_send"] = `
|
||||
Blockly.Arduino.libraries_['library_cayene'] = '#include <CayenneLPP.h>';
|
||||
Blockly.Arduino.variables_['variable_cayenne'] = 'CayenneLPP lpp(51);'
|
||||
var lora_sensor_values = Blockly.Arduino.statementToCode(block, 'DO');
|
||||
Blockly.Arduino.functionNames_['functions_do_send'] = `
|
||||
void do_send(osjob_t* j){
|
||||
// Check if there is not a current TX/RX job running
|
||||
if (LMIC.opmode & OP_TXRXPEND) {
|
||||
@ -196,38 +191,18 @@ Blockly.Arduino.sensebox_lora_cayenne_send = function (block) {
|
||||
}
|
||||
// Next TX is scheduled after TX_COMPLETE event.
|
||||
}`;
|
||||
Blockly.Arduino.loopCodeOnce_["os_runloop"] = "os_runloop_once();";
|
||||
return "";
|
||||
};
|
||||
Blockly.Arduino.loopCodeOnce_['os_runloop'] = 'os_runloop_once();'
|
||||
return '';
|
||||
}
|
||||
|
||||
Blockly.Arduino.sensebox_lora_ttn_mapper = function (block) {
|
||||
var latitude = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Latitude",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var longitude = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Longitude",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var altitude = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Altitude",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var pDOP = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"pDOP",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var fixType = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Fix Type",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var fixTypeLimit = this.getFieldValue("dropdown");
|
||||
Blockly.Arduino.functionNames_["functions_do_send"] = `
|
||||
var latitude = Blockly.Arduino.valueToCode(this, 'Latitude', Blockly.Arduino.ORDER_ATOMIC)
|
||||
var longitude = Blockly.Arduino.valueToCode(this, 'Longitude', Blockly.Arduino.ORDER_ATOMIC)
|
||||
var altitude = Blockly.Arduino.valueToCode(this, 'Altitude', Blockly.Arduino.ORDER_ATOMIC)
|
||||
var pDOP = Blockly.Arduino.valueToCode(this, 'pDOP', Blockly.Arduino.ORDER_ATOMIC)
|
||||
var fixType = Blockly.Arduino.valueToCode(this, 'Fix Type', Blockly.Arduino.ORDER_ATOMIC)
|
||||
var fixTypeLimit = this.getFieldValue('dropdown');
|
||||
Blockly.Arduino.functionNames_['functions_do_send'] = `
|
||||
void do_send(osjob_t* j){
|
||||
// Check if there is not a current TX/RX job running
|
||||
if (LMIC.opmode & OP_TXRXPEND) {
|
||||
@ -270,29 +245,29 @@ Blockly.Arduino.sensebox_lora_ttn_mapper = function (block) {
|
||||
}
|
||||
// Next TX is scheduled after TX_COMPLETE event.
|
||||
}`;
|
||||
Blockly.Arduino.loopCodeOnce_["os_runloop"] = "os_runloop_once();";
|
||||
return "";
|
||||
};
|
||||
Blockly.Arduino.loopCodeOnce_['os_runloop'] = 'os_runloop_once();'
|
||||
return '';
|
||||
}
|
||||
|
||||
Blockly.Arduino.sensebox_lora_initialize_abp = function (block) {
|
||||
var nwskey = this.getFieldValue("NWSKEY");
|
||||
var appskey = this.getFieldValue("APPSKEY");
|
||||
var devaddr = this.getFieldValue("DEVADDR");
|
||||
var interval = this.getFieldValue("INTERVAL");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["library_spi"] = "#include <SPI.h>";
|
||||
Blockly.Arduino.libraries_["library_lmic"] = "#include <lmic.h>";
|
||||
Blockly.Arduino.libraries_["library_hal"] = "#include <hal/hal.h>";
|
||||
Blockly.Arduino.definitions_["define_LoRaVariablesABP"] = `
|
||||
var nwskey = this.getFieldValue('NWSKEY');
|
||||
var appskey = this.getFieldValue('APPSKEY');
|
||||
var devaddr = this.getFieldValue('DEVADDR');
|
||||
var interval = this.getFieldValue('INTERVAL');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>';
|
||||
Blockly.Arduino.libraries_['library_lmic'] = '#include <lmic.h>';
|
||||
Blockly.Arduino.libraries_['library_hal'] = '#include <hal/hal.h>';
|
||||
Blockly.Arduino.definitions_['define_LoRaVariablesABP'] = `
|
||||
// LoRaWAN NwkSKey, network session key
|
||||
// This is the default Semtech key, which is used by the early prototype TTN
|
||||
// network.
|
||||
static const PROGMEM u1_t NWKSKEY[16] = { ${nwskey} };
|
||||
static const PROGMEM u1_t NWKSKEY[16] = ${nwskey};
|
||||
|
||||
// LoRaWAN AppSKey, application session key
|
||||
// This is the default Semtech key, which is used by the early prototype TTN
|
||||
// network.
|
||||
static const u1_t PROGMEM APPSKEY[16] = { ${appskey} };
|
||||
static const u1_t PROGMEM APPSKEY[16] = ${appskey};
|
||||
|
||||
// LoRaWAN end-device address (DevAddr)
|
||||
static const u4_t DEVADDR = 0x${devaddr};
|
||||
@ -318,7 +293,7 @@ Blockly.Arduino.sensebox_lora_initialize_abp = function (block) {
|
||||
.dio = {PIN_XB1_INT, PIN_XB1_INT, LMIC_UNUSED_PIN},
|
||||
};`;
|
||||
|
||||
Blockly.Arduino.codeFunctions_["functions_initLora"] = `
|
||||
Blockly.Arduino.codeFunctions_['functions_initLora'] = `
|
||||
void initLora() {
|
||||
delay(2000);
|
||||
// LMIC init
|
||||
@ -384,9 +359,9 @@ Blockly.Arduino.sensebox_lora_initialize_abp = function (block) {
|
||||
|
||||
// Start job
|
||||
do_send(&sendjob);
|
||||
}`;
|
||||
}`
|
||||
|
||||
Blockly.Arduino.codeFunctions_["functions_onEvent"] = `
|
||||
Blockly.Arduino.codeFunctions_['functions_onEvent'] = `
|
||||
void onEvent (ev_t ev) {
|
||||
Serial.print(os_getTime());
|
||||
Serial.print(": ");
|
||||
@ -451,86 +426,60 @@ Blockly.Arduino.sensebox_lora_initialize_abp = function (block) {
|
||||
break;
|
||||
}
|
||||
}`;
|
||||
Blockly.Arduino.loraSetupCode_["initLora"] = "initLora();\n";
|
||||
Blockly.Arduino.setupCode_["serial.begin"] =
|
||||
"Serial.begin(9600);\ndelay(1000);\n";
|
||||
return "";
|
||||
};
|
||||
Blockly.Arduino.loraSetupCode_['initLora'] = 'initLora();\n';
|
||||
Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\ndelay(1000);\n';
|
||||
return '';
|
||||
}
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_temperature = function (block) {
|
||||
var temperature =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var temperature = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addTemperature(${channel}, ${temperature});\n`;
|
||||
return code;
|
||||
};
|
||||
}
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_humidity = function (block) {
|
||||
var humidity =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var humidity = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addRelativeHumidity(${channel}, ${humidity});\n`;
|
||||
return code;
|
||||
};
|
||||
}
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_pressure = function (block) {
|
||||
var pressure =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var pressure = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addBarometricPressure(${channel}, ${pressure});\n`;
|
||||
return code;
|
||||
};
|
||||
}
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_luminosity = function (block) {
|
||||
var luminosity =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var luminosity = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addLuminosity(${channel}, ${luminosity});\n`;
|
||||
return code;
|
||||
};
|
||||
}
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_sensor = function (block) {
|
||||
var sensorValue =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var sensorValue = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addAnalogInput(${channel}, ${sensorValue});\n`;
|
||||
return code;
|
||||
};
|
||||
}
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_accelerometer = function (block) {
|
||||
var x =
|
||||
Blockly.Arduino.valueToCode(this, "X", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var y =
|
||||
Blockly.Arduino.valueToCode(this, "Y", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var z =
|
||||
Blockly.Arduino.valueToCode(this, "Z", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var x = Blockly.Arduino.valueToCode(this, 'X', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var y = Blockly.Arduino.valueToCode(this, 'Y', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var z = Blockly.Arduino.valueToCode(this, 'Z', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addAccelerometer(${channel}, ${x}, ${y}, ${z});\n`;
|
||||
return code;
|
||||
};
|
||||
}
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_gps = function (block) {
|
||||
var lat =
|
||||
Blockly.Arduino.valueToCode(this, "LAT", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var lng =
|
||||
Blockly.Arduino.valueToCode(this, "LNG", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var alt =
|
||||
Blockly.Arduino.valueToCode(this, "ALT", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var code = `lpp.addGPS(${channel}, ${lat}, ${lng}, ${alt});\n`;
|
||||
var lat = Blockly.Arduino.valueToCode(this, 'LAT', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var lng = Blockly.Arduino.valueToCode(this, 'LNG', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var alt = Blockly.Arduino.valueToCode(this, 'ALT', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addGPS(${channel}, ${lat}, ${lng}, ${alt});\n`
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_concentration = function (block) {
|
||||
var value =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var code = `lpp.addConcentration(${channel}, ${value});\n`;
|
||||
return code;
|
||||
};
|
||||
}
|
||||
@ -1,77 +0,0 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
|
||||
|
||||
/**
|
||||
* Servo Motor
|
||||
*
|
||||
*/
|
||||
Blockly.Arduino.sensebox_motors_beginServoMotor = function () {
|
||||
var pin = this.getFieldValue("pin");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["include_servo_motor"] = "#include <Servo.h>";
|
||||
Blockly.Arduino.definitions_[`define_servo_motor_${pin}`] = `Servo servo_motor_${pin}; // servo Motor`;
|
||||
Blockly.Arduino.setupCode_[`setup_servo_motor_${pin}`] = `servo_motor_${pin}.attach(${pin}); // attach servo motor to pin ${pin}`;
|
||||
var code = "";
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_motors_moveServoMotor = function () {
|
||||
var pin = this.getFieldValue("pin");
|
||||
var degrees = Blockly.Arduino.valueToCode(this, 'degrees', Blockly.Arduino.ORDER_ATOMIC) || "90";
|
||||
var code = `servo_motor_${pin}.write(${degrees}); // move servo motor to ${degrees} degrees\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
/**
|
||||
* I2C Motor Board
|
||||
*
|
||||
*/
|
||||
Blockly.Arduino.sensebox_motors_I2CMotorBoard_begin = function () {
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["include_i2c_motor_board"] = "#include <Grove_I2C_Motor_Driver.h>";
|
||||
Blockly.Arduino.definitions_["define_i2c_motor_board"] = `
|
||||
#define I2C_MOTOR_BOARD_ADDRESS 0x0f // default I2C address of I2C Motor Board`;
|
||||
Blockly.Arduino.setupCode_["setup_i2c_motor_board"] = `
|
||||
Motor.begin(I2C_MOTOR_BOARD_ADDRESS); // Initialize I2C Motor Board`;
|
||||
var code = "";
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_motors_I2CMotorBoard_moveDCMotor = function () {
|
||||
var motor = this.getFieldValue("motor");
|
||||
var speed = Blockly.Arduino.valueToCode(this, 'speed', Blockly.Arduino.ORDER_ATOMIC) || "50";
|
||||
var code = `Motor.speed(MOTOR${motor}, ${speed}); // set speed of motor\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_motors_I2CMotorBoard_stopDCMotor = function () {
|
||||
var motor = this.getFieldValue("motor");
|
||||
var code = `Motor.stop(MOTOR${motor}); // stop motor\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Stepper Motor
|
||||
*/
|
||||
Blockly.Arduino.sensebox_motors_beginStepperMotor = function () {
|
||||
var in1 = this.getFieldValue("in1");
|
||||
var in2 = this.getFieldValue("in2");
|
||||
var in3 = this.getFieldValue("in3");
|
||||
var in4 = this.getFieldValue("in4");
|
||||
var rpm = this.getFieldValue("rpm");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["include_stepper_motor"] = "#include <Stepper.h>";
|
||||
Blockly.Arduino.definitions_["define_stepper_motor"] = `
|
||||
Stepper stepper_motor(2048, ${in1}, ${in2}, ${in3}, ${in4}); // stepper Motor with 2048 steps per rotation`;
|
||||
Blockly.Arduino.setupCode_["setup_stepper_motor"] =
|
||||
`stepper_motor.setSpeed(${rpm}); // speed in rotations per minute`;
|
||||
var code = "";
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_motors_moveStepperMotor = function () {
|
||||
var steps = Blockly.Arduino.valueToCode(this, 'steps', Blockly.Arduino.ORDER_ATOMIC) || '2048';
|
||||
var code = `stepper_motor.step(${steps}); // 2048 steps correspond to one rotation\n`;
|
||||
return code;
|
||||
};
|
||||
@ -1,19 +0,0 @@
|
||||
import Blockly from "blockly";
|
||||
|
||||
Blockly.Arduino.sensebox_ntp_init = function () {
|
||||
Blockly.Arduino.libraries_["WiFiUdp"] = `#include <WiFiUdp.h>`;
|
||||
Blockly.Arduino.libraries_["NTPClient"] = `#include <NTPClient.h>`;
|
||||
Blockly.Arduino.definitions_["WiFiUDP"] = `WiFiUDP ntpUDP;`;
|
||||
Blockly.Arduino.definitions_["NTPClient"] = `NTPClient timeClient(ntpUDP);`;
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.setupCode_["timeclient.begin"] = `timeClient.begin();`;
|
||||
Blockly.Arduino.setupCode_["timeclient.update"] = `timeClient.update();`;
|
||||
var code = ``;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_ntp_get = function () {
|
||||
var format = this.getFieldValue("dropdown");
|
||||
var code = `timeClient.${format}()`;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
@ -1,125 +1,66 @@
|
||||
import Blockly from "blockly";
|
||||
import Blockly from 'blockly';
|
||||
|
||||
|
||||
/**
|
||||
* Block send Data to the openSenseMap
|
||||
*/
|
||||
Blockly.Arduino.sensebox_send_to_osem = function (block) {
|
||||
var code = "";
|
||||
var sensor_id = this.getFieldValue("SensorID");
|
||||
var code = '';
|
||||
var sensor_id = this.getFieldValue('SensorID');
|
||||
var id = sensor_id.slice(-3).toUpperCase();
|
||||
var sensor_value =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
'"Keine Eingabe"';
|
||||
Blockly.Arduino.definitions_["SENSOR_ID" + id + ""] =
|
||||
"const char SENSOR_ID" + id + '[] PROGMEM = "' + sensor_id + '";';
|
||||
code += "addMeasurement(SENSOR_ID" + id + "," + sensor_value + ");\n";
|
||||
var sensor_value = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"';
|
||||
Blockly.Arduino.definitions_['SENSOR_ID' + id + ''] = 'const char SENSOR_ID' + id + '[] PROGMEM = "' + sensor_id + '";';
|
||||
code += 'addMeasurement(SENSOR_ID' + id + ',' + sensor_value + ');\n';
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_osem_connection = function (Block) {
|
||||
var workspace = Blockly.getMainWorkspace();
|
||||
var wifi = false;
|
||||
var ethernet = false;
|
||||
if (workspace.getBlocksByType("sensebox_wifi").length > 0) {
|
||||
wifi = true;
|
||||
ethernet = false;
|
||||
} else if (workspace.getBlocksByType("sensebox_ethernet").length > 0) {
|
||||
ethernet = true;
|
||||
wifi = false;
|
||||
}
|
||||
var box_id = this.getFieldValue("BoxID");
|
||||
var branch = Blockly.Arduino.statementToCode(Block, "DO");
|
||||
var access_token = this.getFieldValue("access_token");
|
||||
var box_id = this.getFieldValue('BoxID');
|
||||
var host = this.getFieldValue('host');
|
||||
var branch = Blockly.Arduino.statementToCode(Block, 'DO');
|
||||
var access_token = this.getFieldValue('access_token');
|
||||
var blocks = this.getDescendants();
|
||||
var type = this.getFieldValue("type");
|
||||
var ssl = this.getFieldValue("SSL");
|
||||
var restart = this.getFieldValue("RESTART");
|
||||
var type = this.getFieldValue('type');
|
||||
var ssl = this.getFieldValue('SSL');
|
||||
var port = 0;
|
||||
var count = 0;
|
||||
if (blocks !== undefined) {
|
||||
for (var i = 0; i < blocks.length; i++) {
|
||||
if (blocks[i].type === "sensebox_send_to_osem") {
|
||||
if (blocks[i].type === 'sensebox_send_to_osem') {
|
||||
count++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
var num_sensors = count;
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.definitions_["num_sensors"] =
|
||||
"static const uint8_t NUM_SENSORS = " + num_sensors + ";";
|
||||
Blockly.Arduino.definitions_["SenseBoxID"] =
|
||||
'const char SENSEBOX_ID [] PROGMEM = "' + box_id + '";';
|
||||
Blockly.Arduino.definitions_["host"] =
|
||||
'const char server [] PROGMEM ="ingress.opensensemap.org";';
|
||||
if (wifi === true) {
|
||||
if (ssl === "TRUE") {
|
||||
Blockly.Arduino.libraries_["library_bearSSL"] =
|
||||
"#include <ArduinoBearSSL.h>";
|
||||
Blockly.Arduino.libraries_["library_arduinoECC08"] =
|
||||
"#include <ArduinoECCX08.h>";
|
||||
Blockly.Arduino.definitions_["WiFiClient"] = "WiFiClient wifiClient;";
|
||||
Blockly.Arduino.definitions_["BearSSLClient"] =
|
||||
"BearSSLClient client(wifiClient);";
|
||||
Blockly.Arduino.functionNames_["getTime"] = `unsigned long getTime() {
|
||||
return WiFi.getTime();
|
||||
}`;
|
||||
Blockly.Arduino.setupCode_["initBearSSL"] =
|
||||
"ArduinoBearSSL.onGetTime(getTime);";
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['num_sensors'] = 'static const uint8_t NUM_SENSORS = ' + num_sensors + ';'
|
||||
Blockly.Arduino.definitions_['SenseBoxID'] = 'const char SENSEBOX_ID [] PROGMEM = "' + box_id + '";';
|
||||
Blockly.Arduino.definitions_['host'] = 'const char server [] PROGMEM =' + host + ';';
|
||||
if (ssl === 'TRUE') {
|
||||
Blockly.Arduino.definitions_['WiFiSSLClient'] = 'WiFiSSLClient client;';
|
||||
port = 443;
|
||||
} else if (ssl === "FALSE") {
|
||||
Blockly.Arduino.definitions_["WiFiClient"] = "WiFiClient client;";
|
||||
} else if (ssl === 'FALSE') {
|
||||
Blockly.Arduino.definitions_['WiFiClient'] = 'WiFiClient client;';
|
||||
port = 80;
|
||||
}
|
||||
} else if (ethernet === true) {
|
||||
if (ssl === "TRUE") {
|
||||
Blockly.Arduino.libraries_["library_bearSSL"] =
|
||||
"#include <ArduinoBearSSL.h>";
|
||||
Blockly.Arduino.libraries_["library_arduinoECC08"] =
|
||||
"#include <ArduinoECCX08.h>";
|
||||
Blockly.Arduino.libraries_["library_ethernetUdp"] =
|
||||
"#include <EthernetUdp.h>";
|
||||
Blockly.Arduino.libraries_["library_NTPClient"] =
|
||||
"#include <NTPClient.h>";
|
||||
Blockly.Arduino.definitions_["EthernetClient"] =
|
||||
"EthernetClient eclient;";
|
||||
Blockly.Arduino.definitions_["BearSSLClient"] =
|
||||
"BearSSLClient client(eclient);";
|
||||
Blockly.Arduino.definitions_["EthernetUDP"] = "EthernetUDP Udp;";
|
||||
Blockly.Arduino.definitions_["NTPClient"] = "NTPClient timeClient(Udp);";
|
||||
Blockly.Arduino.functionNames_["getTime"] = `
|
||||
unsigned long getTime() {
|
||||
timeClient.update();
|
||||
return timeClient.getEpochTime();
|
||||
}`;
|
||||
|
||||
Blockly.Arduino.setupCode_["timeClient_begin"] = "timeClient.begin();";
|
||||
Blockly.Arduino.setupCode_["initBearSSL"] =
|
||||
"ArduinoBearSSL.onGetTime(getTime);";
|
||||
port = 443;
|
||||
} else if (ssl === "FALSE") {
|
||||
Blockly.Arduino.definitions_["EthernetClient"] = "EthernetClient client;";
|
||||
port = 80;
|
||||
}
|
||||
}
|
||||
Blockly.Arduino.definitions_["measurement"] = `typedef struct measurement {
|
||||
Blockly.Arduino.definitions_['measurement'] = `typedef struct measurement {
|
||||
const char *sensorId;
|
||||
float value;
|
||||
} measurement;`;
|
||||
Blockly.Arduino.definitions_["buffer"] = "char buffer[750];";
|
||||
Blockly.Arduino.definitions_[
|
||||
"num_measurement"
|
||||
] = `measurement measurements[NUM_SENSORS];
|
||||
Blockly.Arduino.definitions_['buffer'] = 'char buffer[750];';
|
||||
Blockly.Arduino.definitions_['num_measurement'] = `measurement measurements[NUM_SENSORS];
|
||||
uint8_t num_measurements = 0;`;
|
||||
Blockly.Arduino.definitions_["lengthMultiplikator"] =
|
||||
"const int lengthMultiplikator = 35;";
|
||||
Blockly.Arduino.functionNames_["addMeasurement"] = `
|
||||
Blockly.Arduino.definitions_['lengthMultiplikator'] = 'const int lengthMultiplikator = 35;';
|
||||
Blockly.Arduino.functionNames_['addMeasurement'] = `
|
||||
void addMeasurement(const char *sensorId, float value) {
|
||||
measurements[num_measurements].sensorId = sensorId;
|
||||
measurements[num_measurements].value = value;
|
||||
num_measurements++;
|
||||
}`;
|
||||
if (type === "Stationary") {
|
||||
Blockly.Arduino.functionNames_["writeMeasurementsToClient"] = `
|
||||
if (type === 'Stationary') {
|
||||
Blockly.Arduino.functionNames_['writeMeasurementsToClient'] = `
|
||||
void writeMeasurementsToClient() {
|
||||
// iterate throug the measurements array
|
||||
for (uint8_t i = 0; i < num_measurements; i++) {
|
||||
@ -131,26 +72,18 @@ unsigned long getTime() {
|
||||
// reset num_measurements
|
||||
num_measurements = 0;
|
||||
}`;
|
||||
Blockly.Arduino.functionNames_["submitValues"] =
|
||||
`
|
||||
Blockly.Arduino.functionNames_['submitValues'] = `
|
||||
void submitValues() {
|
||||
${
|
||||
wifi === true
|
||||
? "if (WiFi.status() != WL_CONNECTED) {\nWiFi.disconnect();\ndelay(1000); // wait 1s\nWiFi.begin(ssid, pass);\ndelay(5000); // wait 5s\n}"
|
||||
: ""
|
||||
}
|
||||
if (client.connected()) {
|
||||
client.stop();
|
||||
delay(1000);
|
||||
delay(10);
|
||||
}
|
||||
bool connected = false;
|
||||
char _server[strlen_P(server)];
|
||||
strcpy_P(_server, server);
|
||||
for (uint8_t timeout = 2; timeout != 0; timeout--) {
|
||||
Serial.println(F("connecting..."));
|
||||
connected = client.connect(_server, ` +
|
||||
port +
|
||||
`);
|
||||
connected = client.connect(_server, `+ port + `);
|
||||
if (connected == true) {
|
||||
// construct the HTTP POST request:
|
||||
sprintf_P(buffer,
|
||||
@ -172,56 +105,22 @@ ${
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (client.available()) {
|
||||
char c = client.read();
|
||||
// if the server's disconnected, stop the client:
|
||||
if (!client.connected()) {
|
||||
client.stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
num_measurements = 0;
|
||||
break;
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
${
|
||||
restart === "TRUE"
|
||||
? "if (connected == false) {\n delay(5000);\n noInterrupts();\n NVIC_SystemReset();\n while (1)\n ;\n }"
|
||||
: ""
|
||||
}
|
||||
}`;
|
||||
|
||||
var code = "";
|
||||
var code = '';
|
||||
code += branch;
|
||||
code += "submitValues();\n";
|
||||
} else if (type === "Mobile") {
|
||||
var lat = Blockly.Arduino.valueToCode(
|
||||
Block,
|
||||
"lat",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var lng = Blockly.Arduino.valueToCode(
|
||||
Block,
|
||||
"lng",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var timestamp = Blockly.Arduino.valueToCode(
|
||||
Block,
|
||||
"timeStamp",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var altitude = Blockly.Arduino.valueToCode(
|
||||
Block,
|
||||
"altitude",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
Blockly.Arduino.definitions_["lengthMultiplikator"] =
|
||||
"const int lengthMultiplikator = 77;";
|
||||
Blockly.Arduino.functionNames_["writeMeasurementsToClient"] = `
|
||||
}
|
||||
else if (type === 'Mobile') {
|
||||
var lat = Blockly.Arduino.valueToCode(Block, 'lat', Blockly.Arduino.ORDER_ATOMIC);
|
||||
var lng = Blockly.Arduino.valueToCode(Block, 'lng', Blockly.Arduino.ORDER_ATOMIC);
|
||||
var timestamp = Blockly.Arduino.valueToCode(Block, 'timeStamp', Blockly.Arduino.ORDER_ATOMIC);
|
||||
var altitude = Blockly.Arduino.valueToCode(Block, 'altitude', Blockly.Arduino.ORDER_ATOMIC);
|
||||
Blockly.Arduino.definitions_['lengthMultiplikator'] = 'const int lengthMultiplikator = 77;';
|
||||
Blockly.Arduino.functionNames_['writeMeasurementsToClient'] = `
|
||||
void writeMeasurementsToClient(float lat, float lng, float altitude, char* timeStamp) {
|
||||
// iterate throug the measurements array
|
||||
for (uint8_t i = 0; i < num_measurements; i++) {
|
||||
@ -233,10 +132,7 @@ ${
|
||||
// reset num_measurements
|
||||
num_measurements = 0;
|
||||
}`;
|
||||
Blockly.Arduino.variables_["latitude"] = "float latitude;";
|
||||
Blockly.Arduino.variables_["longitude"] = "float longitude;";
|
||||
Blockly.Arduino.functionNames_["submitValues"] =
|
||||
`
|
||||
Blockly.Arduino.functionNames_['submitValues'] = `
|
||||
void submitValues(float lat, float lng, float altitude, char* timeStamp) {
|
||||
if (client.connected()) {
|
||||
client.stop();
|
||||
@ -247,9 +143,7 @@ ${
|
||||
strcpy_P(_server, server);
|
||||
for (uint8_t timeout = 2; timeout != 0; timeout--) {
|
||||
Serial.println(F("connecting..."));
|
||||
connected = client.connect(_server, ` +
|
||||
port +
|
||||
`);
|
||||
connected = client.connect(_server, `+ port + `);
|
||||
if (connected == true) {
|
||||
// construct the HTTP POST request:
|
||||
sprintf_P(buffer,
|
||||
@ -271,40 +165,15 @@ ${
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (client.available()) {
|
||||
char c = client.read();
|
||||
// if the server's disconnected, stop the client:
|
||||
if (!client.connected()) {
|
||||
client.stop();
|
||||
break;
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
num_measurements = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
${
|
||||
restart === "TRUE"
|
||||
? "if (connected == false) {\n delay(5000);\n noInterrupts();\n NVIC_SystemReset();\n while (1)\n ;\n }"
|
||||
: ""
|
||||
}
|
||||
|
||||
}`;
|
||||
code = "";
|
||||
}`
|
||||
code = '';
|
||||
code += branch;
|
||||
code +=
|
||||
"submitValues((" +
|
||||
lat +
|
||||
"/float(10000000)),(" +
|
||||
lng +
|
||||
"/float(10000000)),(" +
|
||||
altitude +
|
||||
"/float(100))," +
|
||||
timestamp +
|
||||
");\n";
|
||||
code += 'submitValues(' + lat + ',' + lng + ',' + altitude + ',' + timestamp + ');\n';
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
@ -1,139 +0,0 @@
|
||||
import Blockly from "blockly";
|
||||
|
||||
Blockly.Arduino.sensebox_rtc_init = function () {
|
||||
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
||||
Blockly.Arduino.definitions_["RTC"] = `RV8523 rtc;`;
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.setupCode_["rtc.begin"] = `rtc.begin();`;
|
||||
var code = ``;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_rtc_set = function () {
|
||||
var second =
|
||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var minutes =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"minutes",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || "0";
|
||||
var hour =
|
||||
Blockly.Arduino.valueToCode(this, "hour", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var day =
|
||||
Blockly.Arduino.valueToCode(this, "day", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var month =
|
||||
Blockly.Arduino.valueToCode(this, "month", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var year =
|
||||
Blockly.Arduino.valueToCode(this, "year", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
||||
Blockly.Arduino.setupCode_["rtc.start"] = `rtc.start();`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.batterySwitchOver"
|
||||
] = `rtc.batterySwitchOver(1);`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.set"
|
||||
] = `rtc.set(${second}, ${minutes}, ${hour}, ${day}, ${month}, ${year});`;
|
||||
var code = ``;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_rtc_ntp = function () {
|
||||
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
||||
Blockly.Arduino.setupCode_["rtc.start"] = `rtc.start();`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.batterySwitchOver"
|
||||
] = `rtc.batterySwitchOver(1);`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.set"
|
||||
] = `rtc.set(SECOND, MINUTE, HOUR, DAY, MONTH, YEAR);`;
|
||||
var code = ``;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_rtc_get = function () {
|
||||
var dropdown = this.getFieldValue("dropdown");
|
||||
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
||||
Blockly.Arduino.setupCode_["rtc.start"] = `rtc.start();`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.batterySwitchOver"
|
||||
] = `rtc.batterySwitchOver(1);`;
|
||||
Blockly.Arduino.loopCodeOnce_[
|
||||
"rtc_variables"
|
||||
] = `uint8_t sec, min, hour, day, month;\nuint16_t year;`;
|
||||
|
||||
Blockly.Arduino.loopCodeOnce_[
|
||||
"rtc_get"
|
||||
] = `rtc.get(&sec, &min, &hour, &day, &month, &year);`;
|
||||
|
||||
var code = `${dropdown}`;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_rtc_get_timestamp = function () {
|
||||
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
||||
Blockly.Arduino.setupCode_["rtc.start"] = `rtc.start();`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.batterySwitchOver"
|
||||
] = `rtc.batterySwitchOver(1);`;
|
||||
Blockly.Arduino.variables_["rtc_timestamp"] = `char timestamp[20];`;
|
||||
Blockly.Arduino.codeFunctions_["getTimeStamp"] = `
|
||||
char* getTimeStamp() {
|
||||
uint8_t sec, min, hour, day, month;
|
||||
uint16_t year;
|
||||
rtc.get(&sec, &min, &hour, &day, &month, &year);
|
||||
sprintf(timestamp, "%02d-%02d-%02dT%02d:%02d:%02dZ", year, month, day, hour, min, sec);
|
||||
return timestamp;
|
||||
}
|
||||
`;
|
||||
var code = `getTimeStamp()`;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_internal_rtc_init = function () {
|
||||
Blockly.Arduino.libraries_["RTClib"] = `#include <RTCZero.h>`;
|
||||
Blockly.Arduino.definitions_["RTC"] = `RTCZero rtc;`;
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.setupCode_["rtc.begin"] = `rtc.begin();`;
|
||||
return "";
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_internal_rtc_set = function () {
|
||||
var branch =
|
||||
Blockly.Arduino.valueToCode(this, "time", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
Blockly.Arduino.setupCode_["rtc.setEpoch"] = `rtc.setEpoch(${branch});`;
|
||||
var code = ``;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_internal_rtc_get = function () {
|
||||
var dropdown = this.getFieldValue("dropdown");
|
||||
var code = `rtc.get${dropdown}()`;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_internal_rtc_get_timestamp = function () {
|
||||
Blockly.Arduino.variables_["rtc_timestamp"] = `char timestamp[20];`;
|
||||
Blockly.Arduino.codeFunctions_["getTimeStamp"] = `
|
||||
char* getTimeStamp() {
|
||||
uint8_t sec, min, hour, day, month;
|
||||
uint16_t year;
|
||||
sec = rtc.getSeconds();
|
||||
min = rtc.getMinutes();
|
||||
hour = rtc.getHours();
|
||||
day = rtc.getDay();
|
||||
month = rtc.getMonth();
|
||||
year = rtc.getYear();
|
||||
sprintf(timestamp, "%02d-%02d-%02dT%02d:%02d:%02dZ", year, month, day, hour, min, sec);
|
||||
return timestamp;
|
||||
}
|
||||
`;
|
||||
var code = `getTimeStamp()`;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
@ -55,153 +55,3 @@ Blockly.Arduino.sensebox_sd_write_file = function (block) {
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_sd_osem = function () {
|
||||
if (this.parentBlock_ != null) {
|
||||
var filename = this.getSurroundParent().getFieldValue("Filename");
|
||||
}
|
||||
|
||||
var type = this.getFieldValue("type");
|
||||
var blocks = this.getDescendants();
|
||||
var branch = Blockly.Arduino.statementToCode(this, "DO");
|
||||
var count = 0;
|
||||
if (blocks !== undefined) {
|
||||
for (var i = 0; i < blocks.length; i++) {
|
||||
if (blocks[i].type === "sensebox_sd_save_for_osem") {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
var num_sensors = count;
|
||||
var timestamp = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"timeStamp",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
Blockly.Arduino.definitions_["num_sensors"] =
|
||||
"static const uint8_t NUM_SENSORS = " + num_sensors + ";";
|
||||
|
||||
Blockly.Arduino.definitions_["measurement"] = `typedef struct measurement {
|
||||
const char *sensorId;
|
||||
float value;
|
||||
} measurement;`;
|
||||
Blockly.Arduino.definitions_["buffer"] = "char buffer[750];";
|
||||
Blockly.Arduino.definitions_[
|
||||
"num_measurement"
|
||||
] = `measurement measurements[NUM_SENSORS];
|
||||
uint8_t num_measurements = 0;`;
|
||||
if (type === "Stationary") {
|
||||
Blockly.Arduino.functionNames_["addMeasurement"] = `
|
||||
void addMeasurement(const char *sensorId, float value) {
|
||||
measurements[num_measurements].sensorId = sensorId;
|
||||
measurements[num_measurements].value = value;
|
||||
num_measurements++;
|
||||
}
|
||||
`;
|
||||
Blockly.Arduino.functionNames_["writeMeasurementsToSdCard"] = `
|
||||
void writeMeasurementsToSdCard(char* timeStamp) {
|
||||
// iterate throug the measurements array
|
||||
for (uint8_t i = 0; i < num_measurements; i++) {
|
||||
sprintf_P(buffer, PSTR("%s,%9.2f,%s"), measurements[i].sensorId, measurements[i].value, timeStamp);
|
||||
// transmit buffer to client
|
||||
${filename}.println(buffer);
|
||||
}
|
||||
// reset num_measurements
|
||||
num_measurements = 0;
|
||||
}
|
||||
`;
|
||||
Blockly.Arduino.functionNames_["saveValues"] = `
|
||||
void saveValues() {
|
||||
|
||||
|
||||
// send measurements
|
||||
writeMeasurementsToSdCard(${timestamp});
|
||||
num_measurements = 0;
|
||||
}
|
||||
`;
|
||||
var code = "";
|
||||
code += branch;
|
||||
code += "saveValues();";
|
||||
} else if (type === "Mobile") {
|
||||
/**
|
||||
* add mobile functions here
|
||||
*/
|
||||
Blockly.Arduino.libraries_["dtostrf.h"] = "#include <avr/dtostrf.h>";
|
||||
var lat = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"lat",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var lng = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"lng",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
// var altitude = Blockly.Arduino.valueToCode(
|
||||
// this,
|
||||
// "altitude",
|
||||
// Blockly.Arduino.ORDER_ATOMIC
|
||||
// );
|
||||
Blockly.Arduino.definitions_["num_sensors"] =
|
||||
"static const uint8_t NUM_SENSORS = " + num_sensors + ";";
|
||||
|
||||
Blockly.Arduino.definitions_["measurement"] = `typedef struct measurement {
|
||||
const char *sensorId;
|
||||
float value;
|
||||
} measurement;`;
|
||||
Blockly.Arduino.definitions_["buffer"] = "char buffer[750];";
|
||||
Blockly.Arduino.definitions_[
|
||||
"num_measurement"
|
||||
] = `measurement measurements[NUM_SENSORS];
|
||||
uint8_t num_measurements = 0;`;
|
||||
Blockly.Arduino.functionNames_["addMeasurement"] = `
|
||||
void addMeasurement(const char *sensorId, float value) {
|
||||
measurements[num_measurements].sensorId = sensorId;
|
||||
measurements[num_measurements].value = value;
|
||||
num_measurements++;
|
||||
}
|
||||
`;
|
||||
Blockly.Arduino.functionNames_["writeMeasurementsToSdCard"] = `
|
||||
void writeMeasurementsToSdCard(char* timeStamp, int32_t latitudes, int32_t longitudes) {
|
||||
// iterate throug the measurements array
|
||||
for (uint8_t i = 0; i < num_measurements; i++) {
|
||||
char lng[20];
|
||||
char lat[20];
|
||||
float longitude = longitudes / (float)10000000;
|
||||
float latitude = latitudes / (float)10000000;
|
||||
dtostrf(longitude, 8, 7, lng);
|
||||
dtostrf(latitude, 8, 7, lat);
|
||||
sprintf_P(buffer, PSTR("%s,%9.2f,%s,%02s,%02s"), measurements[i].sensorId, measurements[i].value, timeStamp, lng, lat);
|
||||
// transmit buffer to client
|
||||
${filename}.println(buffer);
|
||||
}
|
||||
// reset num_measurements
|
||||
num_measurements = 0;
|
||||
}
|
||||
`;
|
||||
Blockly.Arduino.functionNames_["saveValues"] = `
|
||||
void saveValues() {
|
||||
// send measurements
|
||||
writeMeasurementsToSdCard(${timestamp}, ${lat}, ${lng});
|
||||
num_measurements = 0;
|
||||
}
|
||||
`;
|
||||
code = "";
|
||||
code += branch;
|
||||
code += "saveValues();\n";
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_sd_save_for_osem = function (block) {
|
||||
var code = "";
|
||||
var sensor_id = this.getFieldValue("SensorID");
|
||||
var id = sensor_id.slice(-3).toUpperCase();
|
||||
var sensor_value =
|
||||
Blockly.Arduino.valueToCode(block, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
'"Keine Eingabe"';
|
||||
Blockly.Arduino.definitions_["SENSOR_ID" + id + ""] =
|
||||
"const char SENSOR_ID" + id + '[] PROGMEM = "' + sensor_id + '";';
|
||||
code += "addMeasurement(SENSOR_ID" + id + "," + sensor_value + ");\n";
|
||||
return code;
|
||||
};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import Blockly from "blockly";
|
||||
import Blockly from 'blockly';
|
||||
|
||||
/**
|
||||
* HDC1080 Temperature and Humidity Sensor
|
||||
@ -6,14 +6,11 @@ import Blockly from "blockly";
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_temp_hum = function () {
|
||||
var dropdown_name = this.getFieldValue("NAME");
|
||||
|
||||
Blockly.Arduino.libraries_["library_adafruithdc1000"] =
|
||||
"#include <Adafruit_HDC1000.h> // http://librarymanager/All#Adafruit_HDC1000_Library";
|
||||
Blockly.Arduino.definitions_["define_hdc"] =
|
||||
"Adafruit_HDC1000 hdc = Adafruit_HDC1000();";
|
||||
Blockly.Arduino.setupCode_["sensebox_sensor_temp_hum"] = "hdc.begin();";
|
||||
var code = `hdc.read${dropdown_name}()`;
|
||||
var dropdown_name = this.getFieldValue('NAME');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['define_hdc'] = 'HDC1080 hdc;';
|
||||
Blockly.Arduino.setupCode_['sensebox_sensor_temp_hum'] = 'hdc.begin();';
|
||||
var code = 'hdc.get' + dropdown_name + '()';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
@ -23,125 +20,43 @@ Blockly.Arduino.sensebox_sensor_temp_hum = function () {
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_uv_light = function () {
|
||||
var dropdown_name = this.getFieldValue("NAME");
|
||||
let code = "";
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
|
||||
if (dropdown_name === "UvIntensity") {
|
||||
Blockly.Arduino.libraries_["library_veml6070"] = "#include <VEML6070.h>";
|
||||
Blockly.Arduino.definitions_["define_veml"] = "VEML6070 veml;";
|
||||
Blockly.Arduino.setupCode_["sensebox_sensor_uv_light"] = "veml.begin();";
|
||||
code = "veml.getUV()";
|
||||
var dropdown_name = this.getFieldValue('NAME');
|
||||
let code = '';
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
if (dropdown_name === 'UvIntensity') {
|
||||
Blockly.Arduino.definitions_['define_veml'] = 'VEML6070 veml;'
|
||||
Blockly.Arduino.setupCode_['sensebox_sensor_uv_light'] = 'veml.begin();'
|
||||
code = 'veml.get' + dropdown_name + '()';
|
||||
}
|
||||
if (dropdown_name === "Illuminance") {
|
||||
Blockly.Arduino.libraries_["library_ltr329"] = `#include <LTR329.h>`;
|
||||
Blockly.Arduino.libraries_["library_wire"] = "#include <Wire.h>";
|
||||
Blockly.Arduino.codeFunctions_["read_reg"] = `
|
||||
int read_reg(byte address, uint8_t reg)
|
||||
{
|
||||
int i = 0;
|
||||
Wire.beginTransmission(address);
|
||||
Wire.write(reg);
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom((uint8_t)address, (uint8_t)1);
|
||||
delay(1);
|
||||
if(Wire.available())
|
||||
i = Wire.read();
|
||||
return i;
|
||||
}
|
||||
`;
|
||||
Blockly.Arduino.codeFunctions_["write_reg"] = `
|
||||
void write_reg(byte address, uint8_t reg, uint8_t val)
|
||||
{
|
||||
Wire.beginTransmission(address);
|
||||
Wire.write(reg);
|
||||
Wire.write(val);
|
||||
Wire.endTransmission();
|
||||
}`;
|
||||
|
||||
Blockly.Arduino.codeFunctions_["Lightsensor_begin"] = `
|
||||
void Lightsensor_begin()
|
||||
{
|
||||
Wire.begin();
|
||||
unsigned int u = 0;
|
||||
u = read_reg(0x29, 0x80 | 0x0A); //id register
|
||||
if ((u & 0xF0) == 0xA0) // TSL45315
|
||||
{
|
||||
write_reg(0x29, 0x80 | 0x00, 0x03); //control: power on
|
||||
write_reg(0x29, 0x80 | 0x01, 0x02); //config: M=4 T=100ms
|
||||
delay(120);
|
||||
lightsensortype = 0; //TSL45315
|
||||
}
|
||||
else
|
||||
{
|
||||
LTR.begin();
|
||||
LTR.setControl(gain, false, false);
|
||||
LTR.setMeasurementRate(integrationTime, measurementRate);
|
||||
LTR.setPowerUp(); //power on with default settings
|
||||
delay(10); //Wait 10 ms (max) - wakeup time from standby
|
||||
lightsensortype = 1; //
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
Blockly.Arduino.codeFunctions_["Lightsensor_getIlluminance"] = `
|
||||
unsigned int Lightsensor_getIlluminance()
|
||||
{
|
||||
unsigned int lux = 0;
|
||||
if (lightsensortype == 0) // TSL45315
|
||||
{
|
||||
unsigned int u = (read_reg(0x29, 0x80 | 0x04) << 0); //data low
|
||||
u |= (read_reg(0x29, 0x80 | 0x05) << 8); //data high
|
||||
lux = u * 4; // calc lux with M=4 and T=100ms
|
||||
}
|
||||
else if (lightsensortype == 1) //LTR-329ALS-01
|
||||
{
|
||||
delay(100);
|
||||
unsigned int data0, data1;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (LTR.getData(data0, data1)) {
|
||||
if(LTR.getLux(gain, integrationTime, data0, data1, lux));
|
||||
if(lux > 0) break;
|
||||
else delay(10);
|
||||
}
|
||||
else {
|
||||
byte error = LTR.getError();
|
||||
}
|
||||
}
|
||||
}
|
||||
return lux;
|
||||
}
|
||||
`;
|
||||
Blockly.Arduino.definitions_["define_lightsensor"] = `
|
||||
bool lightsensortype = 0; //0 for tsl - 1 for ltr
|
||||
//settings for LTR sensor
|
||||
LTR329 LTR;
|
||||
unsigned char gain = 1;
|
||||
unsigned char integrationTime = 0;
|
||||
unsigned char measurementRate = 3;
|
||||
`;
|
||||
Blockly.Arduino.setupCode_["sensebox_sensor_illuminance"] =
|
||||
"Lightsensor_begin();";
|
||||
code = "Lightsensor_getIlluminance()";
|
||||
// if (dropdown_name === 'Illuminance') {
|
||||
// Blockly.Arduino.definitions_['define_tsl'] = 'TSL45315 tsl;'
|
||||
// Blockly.Arduino.setupCode_['sensebox_sensor_illuminance'] = 'tsl.begin();'
|
||||
// code = 'tsl.get' + dropdown_name + '()';
|
||||
// }
|
||||
if (dropdown_name === 'Illuminance') {
|
||||
Blockly.Arduino.definitions_['define_lightsensor'] = 'Lightsensor lightsensor;'
|
||||
Blockly.Arduino.setupCode_['sensebox_sensor_illuminance'] = 'lightsensor.begin();'
|
||||
code = 'lightsensor.get' + dropdown_name + '()';
|
||||
}
|
||||
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* BMX055 Accelerometer
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_bmx055_accelerometer = function () {
|
||||
var dropdown_value = this.getFieldValue("VALUE");
|
||||
var range = this.getFieldValue("RANGE");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["library_bmx055"] = `#include <BMX055.h>`;
|
||||
Blockly.Arduino.definitions_["define_bmx"] = "BMX055 bmx;";
|
||||
Blockly.Arduino.setupCode_["sensebox_sensor_bmx055"] =
|
||||
"bmx.beginAcc(" + range + ");";
|
||||
var code = "bmx.getAcceleration" + dropdown_value + "()";
|
||||
var dropdown_value = this.getFieldValue('VALUE');
|
||||
var range = this.getFieldValue('RANGE');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['define_bmx'] = 'BMX055 bmx;';
|
||||
Blockly.Arduino.setupCode_['sensebox_sensor_bmx055'] = 'bmx.beginAcc(' + range + ');';
|
||||
var code = 'bmx.getAcceleration' + dropdown_value + '()';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
@ -151,21 +66,13 @@ Blockly.Arduino.sensebox_sensor_bmx055_accelerometer = function () {
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_sds011 = function () {
|
||||
var dropdown_name = this.getFieldValue("NAME");
|
||||
var serial_name = this.getFieldValue("SERIAL");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_[
|
||||
"SdsDustSensor"
|
||||
] = `#include <SdsDustSensor.h> // http://librarymanager/All#Nova_Fitness_Sds_dust_sensors_library`;
|
||||
Blockly.Arduino.definitions_["define_sds011"] =
|
||||
"SdsDustSensor sds(" + serial_name + ");";
|
||||
Blockly.Arduino.setupCode_["sds011_begin"] = "sds.begin();";
|
||||
Blockly.Arduino.setupCode_["sds011_setQueryReportingMode"] =
|
||||
"sds.setQueryReportingMode();";
|
||||
Blockly.Arduino.loopCodeOnce_[
|
||||
"sds011_getData"
|
||||
] = `PmResult pm = sds.queryPm();`;
|
||||
var code = `pm.${dropdown_name}`;
|
||||
var dropdown_name = this.getFieldValue('NAME');
|
||||
var serial_name = this.getFieldValue('SERIAL');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.codeFunctions_['define_sds011'] = 'SDS011 my_sds(' + serial_name + ');';
|
||||
Blockly.Arduino.variables_['variables_sds011'] = 'float p10,p25;\n';
|
||||
Blockly.Arduino.setupCode_['sensebox_sensor_sds011'] = serial_name + '.begin(9600);';
|
||||
var code = 'my_sds.get' + dropdown_name + '()';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
@ -175,60 +82,42 @@ Blockly.Arduino.sensebox_sensor_sds011 = function () {
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_pressure = function () {
|
||||
var dropdown_name = this.getFieldValue("NAME");
|
||||
var code = "";
|
||||
var referencePressure = this.getFieldValue("referencePressure");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_[
|
||||
"adafruit_bmp280"
|
||||
] = `#include <Adafruit_BMP280.h> // http://librarymanager/All#Adafruit_BMP280_Library`;
|
||||
Blockly.Arduino.definitions_["define_pressure"] = "Adafruit_BMP280 bmp;";
|
||||
Blockly.Arduino.setupCode_["sensebox_bmp_sensor"] = "bmp.begin(0x76);";
|
||||
Blockly.Arduino.setupCode_["bmp_setSampling"] = `
|
||||
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,
|
||||
Adafruit_BMP280::SAMPLING_X2,
|
||||
Adafruit_BMP280::SAMPLING_X16,
|
||||
Adafruit_BMP280::FILTER_X16,
|
||||
Adafruit_BMP280::STANDBY_MS_500);
|
||||
`;
|
||||
switch (dropdown_name) {
|
||||
case "Temperature":
|
||||
code = "bmp.readTemperature()";
|
||||
break;
|
||||
case "Pressure":
|
||||
code = "bmp.readPressure()/100";
|
||||
break;
|
||||
case "Altitude":
|
||||
code = "bmp.readAltitude(" + referencePressure + ")";
|
||||
break;
|
||||
default:
|
||||
code = "";
|
||||
var dropdown_name = this.getFieldValue('NAME');
|
||||
var code = '';
|
||||
var referencePressure = this.getFieldValue('referencePressure');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['define_pressure'] = 'BMP280 bmp_sensor;';
|
||||
Blockly.Arduino.setupCode_['sensebox_bmp_sensor'] = 'bmp_sensor.begin();';
|
||||
if (dropdown_name === 'Pressure' || dropdown_name === 'Temperature') {
|
||||
code = 'bmp_sensor.get' + dropdown_name + '()';
|
||||
}
|
||||
else if (dropdown_name === 'Altitude') {
|
||||
code = 'bmp_sensor.getAltitude(' + referencePressure + ')';
|
||||
}
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* BME680 Environmental Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_bme680_bsec = function () {
|
||||
var dropdown_name = this.getFieldValue("dropdown");
|
||||
let code = "";
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["library_bsec"] =
|
||||
"#include <bsec.h> // http://librarymanager/All#BSEC_Software_Library";
|
||||
Blockly.Arduino.definitions_["bsec_iaqSensor"] = "Bsec iaqSensor;";
|
||||
Blockly.Arduino.variables_["bmeTemperatur"] = "float bmeTemperatur;";
|
||||
Blockly.Arduino.variables_["bmeHumidity"] = "float bmeHumidity;";
|
||||
Blockly.Arduino.variables_["bmePressure"] = "double bmePressure;";
|
||||
Blockly.Arduino.variables_["bmeIAQ"] = "float bmeIAQ;";
|
||||
Blockly.Arduino.variables_["bmeIAQAccuracy"] = "float bmeIAQAccuracy;";
|
||||
Blockly.Arduino.variables_["bmeCO2"] = "int bmeCO2;";
|
||||
Blockly.Arduino.variables_["bmeBreathVocEquivalent"] =
|
||||
"float bmeBreathVocEquivalent;";
|
||||
|
||||
Blockly.Arduino.functionNames_["checkIaqSensorStatus"] = `
|
||||
Blockly.Arduino.sensebox_sensor_bme680_bsec = function () {
|
||||
var dropdown_name = this.getFieldValue('dropdown');
|
||||
let code = '';
|
||||
Blockly.Arduino.libraries_['library_bsec'] = '#include "bsec.h"';
|
||||
Blockly.Arduino.definitions_['bsec_iaqSensor'] = 'Bsec iaqSensor;'
|
||||
Blockly.Arduino.variables_['bmeTemperatur'] = 'float bmeTemperatur;';
|
||||
Blockly.Arduino.variables_['bmeHumidity'] = 'float bmeHumidity;';
|
||||
Blockly.Arduino.variables_['bmePressure'] = 'double bmePressure;';
|
||||
Blockly.Arduino.variables_['bmeIAQ'] = 'float bmeIAQ;';
|
||||
Blockly.Arduino.variables_['bmeIAQAccuracy'] = 'float bmeIAQAccuracy;';
|
||||
Blockly.Arduino.variables_['bmeCO2'] = 'int bmeCO2;';
|
||||
Blockly.Arduino.variables_['bmeBreathVocEquivalent'] = 'float bmeBreathVocEquivalent;'
|
||||
|
||||
Blockly.Arduino.functionNames_['checkIaqSensorStatus'] = `
|
||||
void checkIaqSensorStatus(void)
|
||||
{
|
||||
if (iaqSensor.status != BSEC_OK) {
|
||||
@ -246,7 +135,7 @@ Blockly.Arduino.sensebox_sensor_bme680_bsec = function () {
|
||||
}
|
||||
}
|
||||
`;
|
||||
Blockly.Arduino.functionNames_["errLeds"] = `
|
||||
Blockly.Arduino.functionNames_['errLeds'] = `
|
||||
void errLeds(void)
|
||||
{
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
@ -256,12 +145,10 @@ Blockly.Arduino.sensebox_sensor_bme680_bsec = function () {
|
||||
delay(100);
|
||||
}`;
|
||||
//Setup Code
|
||||
Blockly.Arduino.setupCode_["Wire.begin"] = "Wire.begin();";
|
||||
Blockly.Arduino.setupCode_["iaqSensor.begin"] =
|
||||
"iaqSensor.begin(BME680_I2C_ADDR_PRIMARY, Wire);";
|
||||
Blockly.Arduino.setupCode_["checkIaqSensorStatus"] =
|
||||
"checkIaqSensorStatus();";
|
||||
Blockly.Arduino.setupCode_["bsec_sensorlist"] = `
|
||||
Blockly.Arduino.setupCode_['Wire.begin'] = 'Wire.begin();';
|
||||
Blockly.Arduino.setupCode_['iaqSensor.begin'] = 'iaqSensor.begin(BME680_I2C_ADDR_PRIMARY, Wire);';
|
||||
Blockly.Arduino.setupCode_['checkIaqSensorStatus'] = 'checkIaqSensorStatus();';
|
||||
Blockly.Arduino.setupCode_['bsec_sensorlist'] = `
|
||||
bsec_virtual_sensor_t sensorList[10] = {
|
||||
BSEC_OUTPUT_RAW_TEMPERATURE,
|
||||
BSEC_OUTPUT_RAW_PRESSURE,
|
||||
@ -275,10 +162,9 @@ Blockly.Arduino.sensebox_sensor_bme680_bsec = function () {
|
||||
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY,
|
||||
};
|
||||
`;
|
||||
Blockly.Arduino.setupCode_["iaqSensorUpdateSubscription"] =
|
||||
"iaqSensor.updateSubscription(sensorList, 10, BSEC_SAMPLE_RATE_LP);\ncheckIaqSensorStatus();";
|
||||
Blockly.Arduino.setupCode_['iaqSensorUpdateSubscription'] = 'iaqSensor.updateSubscription(sensorList, 10, BSEC_SAMPLE_RATE_LP);\ncheckIaqSensorStatus();';
|
||||
//Loop Code
|
||||
Blockly.Arduino.loopCodeOnce_["iaqloop"] = `
|
||||
Blockly.Arduino.loopCodeOnce_['iaqloop'] = `
|
||||
if (iaqSensor.run()) {
|
||||
bmeTemperatur = iaqSensor.temperature;
|
||||
bmeHumidity = iaqSensor.humidity;
|
||||
@ -292,26 +178,26 @@ Blockly.Arduino.sensebox_sensor_bme680_bsec = function () {
|
||||
}
|
||||
`;
|
||||
switch (dropdown_name) {
|
||||
case "temperature":
|
||||
code = "bmeTemperatur";
|
||||
case 'temperature':
|
||||
code = 'bmeTemperatur';
|
||||
break;
|
||||
case "humidity":
|
||||
code = "bmeHumidity";
|
||||
case 'humidity':
|
||||
code = 'bmeHumidity';
|
||||
break;
|
||||
case "pressure":
|
||||
code = "bmePressure";
|
||||
case 'pressure':
|
||||
code = 'bmePressure'
|
||||
break;
|
||||
case "IAQ":
|
||||
code = "bmeIAQ";
|
||||
case 'IAQ':
|
||||
code = 'bmeIAQ';
|
||||
break;
|
||||
case "IAQAccuracy":
|
||||
code = "bmeIAQAccuracy";
|
||||
case 'IAQAccuracy':
|
||||
code = 'bmeIAQAccuracy';
|
||||
break;
|
||||
case "CO2":
|
||||
code = "bmeCO2";
|
||||
case 'CO2':
|
||||
code = 'bmeCO2';
|
||||
break;
|
||||
case "breathVocEquivalent":
|
||||
code = "bmeBreathVocEquivalent";
|
||||
case 'breathVocEquivalent':
|
||||
code = 'bmeBreathVocEquivalent';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -319,30 +205,20 @@ Blockly.Arduino.sensebox_sensor_bme680_bsec = function () {
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Ultrasonic Distance Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_ultrasonic_ranger = function () {
|
||||
var dropdown_pin_RX = this.getFieldValue("ultrasonic_trigger");
|
||||
var dropdown_pin_TX = this.getFieldValue("ultrasonic_echo");
|
||||
var port = this.getFieldValue("port");
|
||||
var maxDistance = this.getFieldValue("maxDistance");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_[
|
||||
"library_newPing"
|
||||
] = `#include <NewPing.h> // http://librarymanager/All#NewPing`;
|
||||
Blockly.Arduino.variables_["define_newPingVariables" + port] = `
|
||||
#define TRIGGER_PIN_${port} ${dropdown_pin_RX}
|
||||
#define ECHO_PIN_${port} ${dropdown_pin_TX}
|
||||
#define MAX_DISTANCE_${port} ${maxDistance}
|
||||
`;
|
||||
Blockly.Arduino.definitions_[
|
||||
"define_newPing" + port
|
||||
] = `NewPing sonar${port}(TRIGGER_PIN_${port}, ECHO_PIN_${port}, MAX_DISTANCE_${port});`;
|
||||
var dropdown_pin_RX = this.getFieldValue('ultrasonic_trigger');
|
||||
var dropdown_pin_TX = this.getFieldValue('ultrasonic_echo');
|
||||
var port = this.getFieldValue('port');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['var_ultrasonic' + port] = 'Ultrasonic Ultrasonic' + port + '(' + dropdown_pin_RX + ',' + dropdown_pin_TX + ');';
|
||||
var code;
|
||||
code = `sonar${port}.ping_cm()`;
|
||||
code = 'Ultrasonic' + port + '.getDistance()';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
@ -352,72 +228,35 @@ Blockly.Arduino.sensebox_sensor_ultrasonic_ranger = function () {
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_sound = function () {
|
||||
var dropdown_pin = this.getFieldValue("PIN");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.codeFunctions_["define_sound"] = `
|
||||
float getSoundValue(int pin) {
|
||||
unsigned long start = millis(); // Start des Messintervalls
|
||||
unsigned int peakToPeak = 0; // Abstand von maximalem zu minimalem Amplitudenausschlag
|
||||
unsigned int signalMax = 0;
|
||||
unsigned int signalMin = 1023;
|
||||
const int sampleTime = 100;
|
||||
unsigned int micValue;
|
||||
|
||||
// Sammle Daten für 100 Millisekunden
|
||||
while (millis() - start < sampleTime)
|
||||
{
|
||||
micValue = analogRead(pin); // Messe den aktuellen Wert
|
||||
if (micValue < 1023) // sortiere Fehlmessungen aus, deren Werte über dem max Wert 1024 liegen
|
||||
{
|
||||
if (micValue > signalMax)
|
||||
{
|
||||
signalMax = micValue; // speichere den maximal gemessenen Wert
|
||||
}
|
||||
else if (micValue < signalMin)
|
||||
{
|
||||
signalMin = micValue; // speichere den minimal gemessenen Wert
|
||||
}
|
||||
}
|
||||
}
|
||||
peakToPeak = signalMax - signalMin; // max - min = Abstand von maximalem zu minimalem Amplitudenausschlag
|
||||
double volts = (peakToPeak * 5.0) / 1023; // wandle in Volt um
|
||||
return volts;
|
||||
}`;
|
||||
var code = "getSoundValue(" + dropdown_pin + ")";
|
||||
var dropdown_pin = this.getFieldValue('PIN');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['define_microphone'] = 'Microphone microphone(' + dropdown_pin + ');'
|
||||
var code = 'microphone.getValue()';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Button
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_button = function () {
|
||||
var dropdown_pin = this.getFieldValue("PIN");
|
||||
var dropown_function = this.getFieldValue("FUNCTION");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_[
|
||||
"library_jcButtons"
|
||||
] = `#include <JC_Button.h> // http://librarymanager/All#JC_Button`;
|
||||
|
||||
Blockly.Arduino.definitions_["define_button" + dropdown_pin + ""] =
|
||||
"Button button_" + dropdown_pin + "(" + dropdown_pin + ");";
|
||||
Blockly.Arduino.setupCode_["setup_button" + dropdown_pin + ""] =
|
||||
"button_" + dropdown_pin + ".begin();";
|
||||
Blockly.Arduino.loopCodeOnce_["loop_button" + dropdown_pin + ""] =
|
||||
"button_" + dropdown_pin + ".read();";
|
||||
var code = "";
|
||||
if (dropown_function === "isPressed") {
|
||||
code = "button_" + dropdown_pin + ".isPressed()";
|
||||
} else if (dropown_function === "wasPressed") {
|
||||
code = "button_" + dropdown_pin + ".wasPressed()";
|
||||
} else if (dropown_function === "longPress") {
|
||||
var time = this.getFieldValue("time");
|
||||
code = "button_" + dropdown_pin + ".pressedFor(" + time + ")";
|
||||
} else if (dropown_function === "toggleButton") {
|
||||
code = "button_" + dropdown_pin + ".toggleState()";
|
||||
Blockly.Arduino.definitions_["define_button" + dropdown_pin + ""] =
|
||||
"ToggleButton button_" + dropdown_pin + "(" + dropdown_pin + ");";
|
||||
Blockly.Arduino.sensebox_button = function () {
|
||||
var dropdown_pin = this.getFieldValue('PIN');
|
||||
var dropown_function = this.getFieldValue('FUNCTION');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['define_button' + dropdown_pin + ''] = 'Button button_' + dropdown_pin + '(' + dropdown_pin + ');';
|
||||
Blockly.Arduino.setupCode_['setup_button' + dropdown_pin + ''] = 'button_' + dropdown_pin + '.begin();';
|
||||
var code = '';
|
||||
if (dropown_function === 'isPressed') {
|
||||
code = 'button_' + dropdown_pin + '.isPressed()';
|
||||
}
|
||||
else if (dropown_function === 'Switch') {
|
||||
code = 'button_' + dropdown_pin + '.getSwitch()';
|
||||
}
|
||||
else if (dropown_function === 'wasPressed') {
|
||||
code = 'button_' + dropdown_pin + '.wasPressed()';
|
||||
}
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
@ -428,35 +267,34 @@ Blockly.Arduino.sensebox_button = function () {
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_scd30 = function () {
|
||||
var dropdown = this.getFieldValue("dropdown");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["scd30_library"] =
|
||||
"#include <SparkFun_SCD30_Arduino_Library.h> // http://librarymanager/All#SparkFun_SCD30_Arduino_Library";
|
||||
Blockly.Arduino.definitions_["SCD30"] = "SCD30 airSensor;";
|
||||
Blockly.Arduino.setupCode_["init_scd30"] = ` Wire.begin();
|
||||
var dropdown = this.getFieldValue('dropdown');
|
||||
Blockly.Arduino.libraries_['scd30_library'] = '#include "SparkFun_SCD30_Arduino_Library.h"'
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['SCD30'] = 'SCD30 airSensor;';
|
||||
Blockly.Arduino.setupCode_['init_scd30'] = ` Wire.begin();
|
||||
if (airSensor.begin() == false)
|
||||
{
|
||||
while (1)
|
||||
;
|
||||
}`;
|
||||
Blockly.Arduino.setupCode_["scd30_staleData"] =
|
||||
"airSensor.useStaleData(true);";
|
||||
var code = "";
|
||||
var code = '';
|
||||
switch (dropdown) {
|
||||
case "temperature":
|
||||
code = "airSensor.getTemperature()";
|
||||
case 'temperature':
|
||||
code = 'airSensor.getTemperature()';
|
||||
break;
|
||||
case "humidity":
|
||||
code = "airSensor.getHumidity()";
|
||||
case 'humidity':
|
||||
code = 'airSensor.getHumiditiy()';
|
||||
break;
|
||||
case "CO2":
|
||||
code = "airSensor.getCO2()";
|
||||
case 'CO2':
|
||||
code = 'airSensor.getCO2()';
|
||||
break;
|
||||
default:
|
||||
code = "";
|
||||
code = ''
|
||||
}
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GPS Module
|
||||
@ -464,13 +302,12 @@ if (airSensor.begin() == false)
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_gps = function () {
|
||||
var dropdown = this.getFieldValue("dropdown");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["gps_library"] =
|
||||
"#include <SparkFun_u-blox_GNSS_Arduino_Library.h> // http://librarymanager/All#SparkFun_u-blox_GNSS_Arduino_Library";
|
||||
Blockly.Arduino.libraries_["library_wire"] = "#include <Wire.h>";
|
||||
Blockly.Arduino.definitions_["GPS"] = "SFE_UBLOX_GNSS myGNSS;";
|
||||
Blockly.Arduino.setupCode_["init_gps"] = ` Wire.begin();
|
||||
var dropdown = this.getFieldValue('dropdown');
|
||||
Blockly.Arduino.libraries_['gps_library'] = '#include <SparkFun_u-blox_GNSS_Arduino_Library.h>'
|
||||
Blockly.Arduino.libraries_['library_wire'] = '#include <Wire.h>';
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['GPS'] = 'SFE_UBLOX_GNSS myGNSS;';
|
||||
Blockly.Arduino.setupCode_['init_gps'] = ` Wire.begin();
|
||||
|
||||
if (myGNSS.begin() == false) //Connect to the Ublox module using Wire port
|
||||
{
|
||||
@ -480,88 +317,69 @@ Blockly.Arduino.sensebox_gps = function () {
|
||||
|
||||
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||
myGNSS.saveConfiguration(); //Save the current settings to flash and BBR`;
|
||||
var code = "";
|
||||
var code = '';
|
||||
switch (dropdown) {
|
||||
case "latitude":
|
||||
code = "myGNSS.getLatitude()";
|
||||
case 'latitude':
|
||||
code = 'myGNSS.getLatitude()';
|
||||
break;
|
||||
case "longitude":
|
||||
code = "myGNSS.getLongitude()";
|
||||
case 'longitude':
|
||||
code = 'myGNSS.getLongitude()';
|
||||
break;
|
||||
case "altitude":
|
||||
code = "myGNSS.getAltitudeMSL()";
|
||||
case 'altitude':
|
||||
code = 'myGNSS.getAltitudeMSL()';
|
||||
break;
|
||||
case "pDOP":
|
||||
code = "myGNSS.getPDOP()";
|
||||
case 'pDOP':
|
||||
code = 'myGNSS.getPDOP()';
|
||||
break;
|
||||
case "fixType":
|
||||
code = "myGNSS.getFixType()";
|
||||
break;
|
||||
case "timestamp":
|
||||
Blockly.Arduino.variables_["timestampVars"] = `
|
||||
char tsBuffer[21];
|
||||
`;
|
||||
Blockly.Arduino.codeFunctions_["getTimeStamp()"] = `
|
||||
char* getTimeStamp()
|
||||
{
|
||||
if (myGNSS.getTimeValid() == true)
|
||||
{
|
||||
sprintf(tsBuffer, "%04d-%02d-%02dT%02d:%02d:%02dZ",
|
||||
myGNSS.getYear(), myGNSS.getMonth(), myGNSS.getDay(), myGNSS.getHour(), myGNSS.getMinute(), myGNSS.getSecond());
|
||||
}
|
||||
return tsBuffer;
|
||||
}
|
||||
`;
|
||||
code = "getTimeStamp()";
|
||||
break;
|
||||
case "speed":
|
||||
code = "myGNSS.getGroundSpeed()";
|
||||
case 'fixType':
|
||||
code = 'myGNSS.getFixType()';
|
||||
break;
|
||||
default:
|
||||
code = "";
|
||||
code = ''
|
||||
}
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Block for Truebner STM50
|
||||
*/
|
||||
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_truebner_smt50 = function () {
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
var dropdown_port = this.getFieldValue("Port");
|
||||
var dropdown_value = this.getFieldValue("value");
|
||||
var dropdown_port = this.getFieldValue('Port')
|
||||
var dropdown_value = this.getFieldValue('value');
|
||||
var dropdown_pin = 1;
|
||||
var code = "";
|
||||
if (dropdown_value === "temp") {
|
||||
if (dropdown_port === "A") {
|
||||
var code = '';
|
||||
if (dropdown_value === 'temp') {
|
||||
if (dropdown_port === 'A') {
|
||||
dropdown_pin = 1;
|
||||
}
|
||||
if (dropdown_port === "B") {
|
||||
if (dropdown_port === 'B') {
|
||||
dropdown_pin = 3;
|
||||
}
|
||||
if (dropdown_port === "C") {
|
||||
if (dropdown_port === 'C') {
|
||||
dropdown_pin = 5;
|
||||
}
|
||||
Blockly.Arduino.codeFunctions_["sensebox_smt50_temp"] =
|
||||
"float getSMT50Temperature(int analogPin){\n int sensorValue = analogRead(analogPin);\n float voltage = sensorValue * (3.3 / 1024.0);\n return (voltage - 0.5) * 100;\n}";
|
||||
code = "getSMT50Temperature(" + dropdown_pin + ")";
|
||||
Blockly.Arduino.codeFunctions_['sensebox_smt50_temp'] = 'float getSMT50Temperature(int analogPin){\n int sensorValue = analogRead(analogPin);\n float voltage = sensorValue * (3.3 / 1024.0);\n return (voltage - 0.5) * 100;\n}';
|
||||
code = 'getSMT50Temperature(' + dropdown_pin + ')';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
} else if (dropdown_value === "soil") {
|
||||
if (dropdown_port === "A") {
|
||||
}
|
||||
else if (dropdown_value === 'soil') {
|
||||
if (dropdown_port === 'A') {
|
||||
dropdown_pin = 2;
|
||||
}
|
||||
if (dropdown_port === "B") {
|
||||
if (dropdown_port === 'B') {
|
||||
dropdown_pin = 4;
|
||||
}
|
||||
if (dropdown_port === "C") {
|
||||
if (dropdown_port === 'C') {
|
||||
dropdown_pin = 6;
|
||||
}
|
||||
Blockly.Arduino.codeFunctions_["sensebox_smt50_soil"] =
|
||||
"float getSMT50Moisture(int analogPin){\n int sensorValue = analogRead(analogPin);\n float voltage = sensorValue * (3.3 / 1024.0);\n return (voltage * 50) / 3;\n}";
|
||||
code = "getSMT50Moisture(" + dropdown_pin + ")";
|
||||
Blockly.Arduino.codeFunctions_['sensebox_smt50_soil'] = 'float getSMT50Moisture(int analogPin){\n int sensorValue = analogRead(analogPin);\n float voltage = sensorValue * (3.3 / 1024.0);\n return (voltage * 50) / 3;\n}';
|
||||
code = 'getSMT50Moisture(' + dropdown_pin + ')';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@ -570,30 +388,24 @@ Blockly.Arduino.sensebox_sensor_truebner_smt50 = function () {
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_watertemperature = function () {
|
||||
var dropdown_port = this.getFieldValue("Port");
|
||||
|
||||
var dropdown_port = this.getFieldValue('Port');
|
||||
var dropdown_pin = 1;
|
||||
if (dropdown_port === "A") {
|
||||
if (dropdown_port === 'A') {
|
||||
dropdown_pin = 1;
|
||||
}
|
||||
if (dropdown_port === "B") {
|
||||
if (dropdown_port === 'B') {
|
||||
dropdown_pin = 3;
|
||||
}
|
||||
if (dropdown_port === "C") {
|
||||
if (dropdown_port === 'C') {
|
||||
dropdown_pin = 5;
|
||||
}
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["library_oneWire"] =
|
||||
"#include <OneWire.h> // http://librarymanager/All#OneWire";
|
||||
Blockly.Arduino.libraries_["library_oneDallasTemperature"] =
|
||||
"#include <DallasTemperature.h> // http://librarymanager/All#DallasTemperature";
|
||||
Blockly.Arduino.definitions_["define_OneWire"] =
|
||||
"#define ONE_WIRE_BUS " +
|
||||
dropdown_pin +
|
||||
"\nOneWire oneWire(ONE_WIRE_BUS);\nDallasTemperature sensors(&oneWire);";
|
||||
Blockly.Arduino.setupCode_["sensebox_oneWireSetup"] = "sensors.begin();";
|
||||
Blockly.Arduino.codeFunctions_["sensebox_requestTemp"] =
|
||||
"float getWaterTemp(){\nsensors.requestTemperatures();\nsensors.getTempCByIndex(0);\n}";
|
||||
var code = "getWaterTemp()";
|
||||
Blockly.Arduino.libraries_['library_oneWire'] = '#include "OneWire.h"';
|
||||
Blockly.Arduino.libraries_['library_oneDallasTemperature'] = '#include "DallasTemperature.h"';
|
||||
Blockly.Arduino.definitions_['define_OneWire'] = '#define ONE_WIRE_BUS ' + dropdown_pin + '\nOneWire oneWire(ONE_WIRE_BUS);\nDallasTemperature sensors(&oneWire);';
|
||||
Blockly.Arduino.setupCode_['sensebox_oneWireSetup'] = 'sensors.begin();';
|
||||
Blockly.Arduino.codeFunctions_['sensebox_requestTemp'] = 'float getWaterTemp(){\nsensors.requestTemperatures();\nsensors.getTempCByIndex(0);\n}';
|
||||
var code = 'getWaterTemp()';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
@ -636,120 +448,23 @@ float getWindspeed(){
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_soundsensor_dfrobot = function () {
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
var dropdown_port = this.getFieldValue("Port");
|
||||
var dropdown_port = this.getFieldValue('Port');
|
||||
var dropdown_pin = 1;
|
||||
if (dropdown_port === "A") {
|
||||
if (dropdown_port === 'A') {
|
||||
dropdown_pin = 1;
|
||||
}
|
||||
if (dropdown_port === "B") {
|
||||
if (dropdown_port === 'B') {
|
||||
dropdown_pin = 3;
|
||||
}
|
||||
if (dropdown_port === "C") {
|
||||
if (dropdown_port === 'C') {
|
||||
dropdown_pin = 5;
|
||||
}
|
||||
Blockly.Arduino.codeFunctions_["soundsensor"] =
|
||||
`
|
||||
Blockly.Arduino.codeFunctions_['soundsensor'] = `
|
||||
float getSoundValue(){
|
||||
float v = analogRead(` +
|
||||
dropdown_pin +
|
||||
`) * (3.3 / 1024.0);
|
||||
float v = analogRead(`+ dropdown_pin + `) * (3.3 / 1024.0);
|
||||
float decibel = v * 50;
|
||||
return decibel;
|
||||
}`;
|
||||
var code = "getSoundValue()";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
/**
|
||||
* Infineon DPS310 Pressure Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_dps310 = function () {
|
||||
var dropdown_name = this.getFieldValue("NAME");
|
||||
var code = "";
|
||||
var referencePressure = this.getFieldValue("referencePressure");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_[
|
||||
"adafruit_dps310"
|
||||
] = `#include <Adafruit_DPS310.h> // http://librarymanager/All#Adafruit_DPS310`;
|
||||
Blockly.Arduino.definitions_["define_dps"] = "Adafruit_DPS310 dps;";
|
||||
Blockly.Arduino.setupCode_["dps_begin"] = "dps.begin_I2C(0x76);";
|
||||
Blockly.Arduino.setupCode_["dps_configuration"] = `
|
||||
dps.configurePressure(DPS310_64HZ, DPS310_64SAMPLES);
|
||||
dps.configureTemperature(DPS310_64HZ, DPS310_64SAMPLES);
|
||||
`;
|
||||
Blockly.Arduino.loopCodeOnce_["dps_events"] =
|
||||
"sensors_event_t temp_event, pressure_event;";
|
||||
Blockly.Arduino.loopCodeOnce_["dps_getEvents"] =
|
||||
"dps.getEvents(&temp_event, &pressure_event);";
|
||||
switch (dropdown_name) {
|
||||
case "Temperature":
|
||||
code = "temp_event.temperature";
|
||||
break;
|
||||
case "Pressure":
|
||||
code = "pressure_event.pressure";
|
||||
break;
|
||||
case "Altitude":
|
||||
code = "dps.readAltitude(" + referencePressure + ")";
|
||||
break;
|
||||
default:
|
||||
code = "";
|
||||
}
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
/**
|
||||
* Sensirion SPS30 Fine Particlar Matter
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sensor_sps30 = function () {
|
||||
var dropdown_name = this.getFieldValue("value");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_[
|
||||
"sps30"
|
||||
] = `#include <sps30.h> // http://librarymanager/All#`;
|
||||
Blockly.Arduino.variables_["sps30_measurement"] =
|
||||
"struct sps30_measurement m;";
|
||||
Blockly.Arduino.variables_["sps30_auto_clean_days"] =
|
||||
"uint32_t auto_clean_days = 4;";
|
||||
Blockly.Arduino.variables_["sps30_interval_intervalsps"] =
|
||||
"const long intervalsps = 1000;";
|
||||
Blockly.Arduino.variables_["sps30_time_startsps"] =
|
||||
"unsigned long time_startsps = 0;";
|
||||
Blockly.Arduino.variables_["sps30_time_actualsps"] =
|
||||
"unsigned long time_actualsps = 0;";
|
||||
Blockly.Arduino.codeFunctions_["sps30_getData"] = `
|
||||
void getSPS30Data(){
|
||||
|
||||
uint16_t data_ready;
|
||||
int16_t ret;
|
||||
|
||||
do {
|
||||
ret = sps30_read_data_ready(&data_ready);
|
||||
if (ret < 0) {
|
||||
} else if (!data_ready) {}
|
||||
else
|
||||
break;
|
||||
delay(100); /* retry in 100ms */
|
||||
} while (1);
|
||||
ret = sps30_read_measurement(&m);
|
||||
}
|
||||
`;
|
||||
|
||||
Blockly.Arduino.setupCode_["sps30_begin"] = "sensirion_i2c_init();";
|
||||
Blockly.Arduino.setupCode_["sps30_setFanCleaningInterval"] =
|
||||
"sps30_set_fan_auto_cleaning_interval_days(auto_clean_days);";
|
||||
Blockly.Arduino.setupCode_["sps30_startMeasurement"] =
|
||||
"sps30_start_measurement();";
|
||||
Blockly.Arduino.loopCodeOnce_["getSPS30Data();"] = `
|
||||
time_startsps = millis();
|
||||
if (time_startsps > time_actualsps + intervalsps) {
|
||||
time_actualsps = millis();
|
||||
getSPS30Data();
|
||||
}`;
|
||||
var code = `m.mc_${dropdown_name}`;
|
||||
}`
|
||||
var code = 'getSoundValue()';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
@ -1,40 +1,29 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
|
||||
/**
|
||||
* Telegram Bot by re:edu
|
||||
*/
|
||||
Blockly.Arduino.sensebox_telegram = function (Block) {
|
||||
let token = Block.getFieldValue("telegram_token");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly["Arduino"].libraries_[
|
||||
"library_telegram"
|
||||
] = `#include <UniversalTelegramBot.h>`;
|
||||
Blockly["Arduino"].functionNames_["WiFiSSLClient"] = "WiFiSSLClient client;";
|
||||
Blockly["Arduino"].functionNames_[
|
||||
"telegram_objects"
|
||||
] = `#define BOTtoken "${token}" // your Bot Token (Get from Botfather)
|
||||
let token = Block.getFieldValue('telegram_token');
|
||||
Blockly['Arduino'].libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly['Arduino'].libraries_['library_telegram'] = `#include <UniversalTelegramBot.h>`
|
||||
Blockly['Arduino'].functionNames_['WiFiSSLClient'] = 'WiFiSSLClient client;';
|
||||
Blockly['Arduino'].functionNames_['telegram_objects'] = `#define BOTtoken "${token}" // your Bot Token (Get from Botfather)
|
||||
|
||||
UniversalTelegramBot bot(BOTtoken, client);`;
|
||||
UniversalTelegramBot bot(BOTtoken, client);`
|
||||
|
||||
let code = "";
|
||||
let code = '';
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_telegram_do = function (block) {
|
||||
var messageProcessing = Blockly.Arduino.statementToCode(
|
||||
block,
|
||||
"telegram_do",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var messageProcessing = Blockly.Arduino.statementToCode(block, 'telegram_do', Blockly.Arduino.ORDER_ATOMIC);
|
||||
|
||||
Blockly.Arduino.definitions_[
|
||||
"telegram_variables"
|
||||
] = `int Bot_mtbs = 1000; //mean time between scan messages
|
||||
long Bot_lasttime; //last time messages' scan has been done`;
|
||||
Blockly.Arduino.definitions_['telegram_variables'] = `int Bot_mtbs = 1000; //mean time between scan messages
|
||||
long Bot_lasttime; //last time messages' scan has been done`
|
||||
|
||||
Blockly.Arduino.loopCodeOnce_[
|
||||
"sensebox_telegram_loop"
|
||||
] = `if (millis() > Bot_lasttime + Bot_mtbs) {
|
||||
Blockly.Arduino.loopCodeOnce_['sensebox_telegram_loop'] = `if (millis() > Bot_lasttime + Bot_mtbs) {
|
||||
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
|
||||
while(numNewMessages) {
|
||||
for(int i=0; i<numNewMessages; i++) {
|
||||
@ -47,17 +36,13 @@ Blockly.Arduino.sensebox_telegram_do = function (block) {
|
||||
}
|
||||
Bot_lasttime = millis();
|
||||
}`;
|
||||
var code = "";
|
||||
var code = '';
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_telegram_do_on_message = function (block) {
|
||||
var message = this.getFieldValue("telegram_message");
|
||||
var stuffToDo = Blockly.Arduino.statementToCode(
|
||||
block,
|
||||
"telegram_do_on_message",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var message = this.getFieldValue('telegram_message');
|
||||
var stuffToDo = Blockly.Arduino.statementToCode(block, 'telegram_do_on_message', Blockly.Arduino.ORDER_ATOMIC);
|
||||
var code = `
|
||||
if (text == "${message}") {
|
||||
${stuffToDo}
|
||||
@ -66,12 +51,7 @@ Blockly.Arduino.sensebox_telegram_do_on_message = function (block) {
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_telegram_send = function (block) {
|
||||
var textToSend =
|
||||
Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"telegram_text_to_send",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || '"Keine Eingabe"';
|
||||
var textToSend = Blockly.Arduino.valueToCode(this, 'telegram_text_to_send', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"';
|
||||
var code = `bot.sendMessage(chat_id, String(${textToSend}), "");\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
@ -1,122 +1,25 @@
|
||||
import Blockly from "blockly";
|
||||
//import store from "../../../store";
|
||||
|
||||
// preperations for the esp board
|
||||
// var selectedBoard = store.getState().board.board;
|
||||
// store.subscribe(() => {
|
||||
// selectedBoard = store.getState().board.board;
|
||||
// });
|
||||
import Blockly from 'blockly';
|
||||
|
||||
|
||||
/* Wifi connection and openSenseMap Blocks*/
|
||||
Blockly.Arduino.sensebox_wifi = function (block) {
|
||||
var pw = this.getFieldValue("Password");
|
||||
var ssid = this.getFieldValue("SSID");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["library_WiFi"] = "#include <WiFi101.h>";
|
||||
Blockly.Arduino.variables_["ssid"] = `char ssid[] = "${ssid}";`;
|
||||
Blockly.Arduino.variables_["pass"] = `char pass[] = "${pw}";`;
|
||||
Blockly.Arduino.variables_["wifi_Status"] = "int status = WL_IDLE_STATUS;";
|
||||
var pw = this.getFieldValue('Password');
|
||||
var ssid = this.getFieldValue('SSID');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['define_network'] = 'Bee* b = new Bee();';
|
||||
if (pw === "") {
|
||||
Blockly.Arduino.setupCode_["wifi_begin"] = `
|
||||
if (WiFi.status() == WL_NO_SHIELD) {
|
||||
while (true);
|
||||
}
|
||||
while (status != WL_CONNECTED) {
|
||||
status = WiFi.begin(ssid);
|
||||
delay(5000);
|
||||
}
|
||||
`;
|
||||
Blockly.Arduino.setupCode_['sensebox_network'] = 'b->connectToWifi("' + ssid + '");\ndelay(1000);';
|
||||
} else
|
||||
Blockly.Arduino.setupCode_["wifi_begin"] = `
|
||||
if (WiFi.status() == WL_NO_SHIELD) {
|
||||
while (true);
|
||||
}
|
||||
while (status != WL_CONNECTED) {
|
||||
status = WiFi.begin(ssid, pass);
|
||||
delay(5000);
|
||||
}
|
||||
`;
|
||||
var code = "";
|
||||
Blockly.Arduino.setupCode_['sensebox_network'] = 'b->connectToWifi("' + ssid + '","' + pw + '");\ndelay(1000);';
|
||||
var code = '';
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_wifi_status = function () {
|
||||
var code = "WiFi.status()";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_wifi_rssi = function () {
|
||||
var code = "WiFi.RSSI()";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_get_ip = function () {
|
||||
Blockly.Arduino.definitions_["define_ipadress"] = "IPAddress ip;";
|
||||
Blockly.Arduino.setupCode_["sensebox_get_ip"] = " ip = WiFi.localIP();";
|
||||
var code = "ip";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_startap = function (block) {
|
||||
var ssid = this.getFieldValue("SSID");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["library_WiFi"] = "#include <WiFi101.h>";
|
||||
Blockly.Arduino.setupCode_["wifi_startAP"] = `WiFi.beginAP(${ssid});`;
|
||||
var code = "";
|
||||
var ssid = this.getFieldValue('SSID');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.definitions_['define_network'] = 'Bee* b = new Bee();';
|
||||
Blockly.Arduino.setupCode_['sensebox_network'] = 'b->startAP("' + ssid + '");'
|
||||
var code = '';
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_ethernet = function () {
|
||||
var ip = this.getFieldValue("ip");
|
||||
var gateway = this.getFieldValue("gateway");
|
||||
var subnetmask = this.getFieldValue("subnetmask");
|
||||
var dns = this.getFieldValue("dns");
|
||||
var mac = this.getFieldValue("mac");
|
||||
var dhcp = this.getFieldValue("dhcp");
|
||||
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["library_ethernet"] =
|
||||
"#include <Ethernet.h> // http://librarymanager/All#Ethernet";
|
||||
|
||||
Blockly.Arduino.definitions_["ethernet_config"] = `
|
||||
byte mac[] = { ${mac}};`;
|
||||
if (dhcp === "Manual") {
|
||||
Blockly.Arduino.definitions_["ethernet_manual_config"] = `
|
||||
//Configure static IP setup (only needed if DHCP is disabled)
|
||||
IPAddress myIp(${ip.replaceAll(".", ", ")});
|
||||
IPAddress myDns(${dns.replaceAll(".", ",")});
|
||||
IPAddress myGateway(${gateway.replaceAll(".", ",")});
|
||||
IPAddress mySubnet(${subnetmask.replaceAll(".", ",")});
|
||||
`;
|
||||
Blockly.Arduino.setupCode_["ethernet_setup"] = `
|
||||
Ethernet.init(23);
|
||||
// start the Ethernet connection:
|
||||
if (Ethernet.begin(mac) == 0) {
|
||||
// no point in carrying on, so do nothing forevermore:
|
||||
// try to congifure using IP address instead of DHCP:
|
||||
Ethernet.begin(mac, myIp);
|
||||
}
|
||||
// give the Ethernet shield a second to initialize:
|
||||
delay(1000);
|
||||
`;
|
||||
} else {
|
||||
Blockly.Arduino.setupCode_["ethernet_setup"] = `
|
||||
Ethernet.init(23);
|
||||
// start the Ethernet connection:
|
||||
Ethernet.begin(mac);
|
||||
// give the Ethernet shield a second to initialize:
|
||||
delay(1000);
|
||||
`;
|
||||
}
|
||||
|
||||
var code = "";
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_ethernetIp = function () {
|
||||
var code = "Ethernet.localIP()";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,38 +1,3 @@
|
||||
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,35 +0,0 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
|
||||
Blockly.Arduino["print_serial_monitor"] = function (block) {
|
||||
var serialId = block.getFieldValue("SERIAL_ID");
|
||||
var content =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"CONTENT",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || "0";
|
||||
var checkbox_name = block.getFieldValue("NEW_LINE") === "TRUE";
|
||||
var code = "";
|
||||
if (checkbox_name) {
|
||||
code = serialId + ".println(" + content + ");\n";
|
||||
} else {
|
||||
code = serialId + ".print(" + content + ");\n";
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
/**
|
||||
* Code generator for block for setting the serial com speed.
|
||||
* Arduino code: setup{ Serial.begin(X); }
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code.
|
||||
*/
|
||||
Blockly.Arduino["init_serial_monitor"] = function (block) {
|
||||
var serialId = block.getFieldValue("SERIAL_ID");
|
||||
var serialSpeed = block.getFieldValue("SPEED");
|
||||
Blockly.Arduino.setupCode_[
|
||||
"init_serial"
|
||||
] = `${serialId}.begin(${serialSpeed});`;
|
||||
var code = "";
|
||||
return code;
|
||||
};
|
||||
@ -1,4 +1,5 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
|
||||
/**
|
||||
* Code generator for a literal String (X).
|
||||
@ -6,11 +7,12 @@ import * as Blockly from "blockly/core";
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["text"] = function (block) {
|
||||
var code = Blockly.Arduino.quote_(block.getFieldValue("TEXT"));
|
||||
Blockly.Arduino['text'] = function (block) {
|
||||
var code = Blockly.Arduino.quote_(block.getFieldValue('TEXT'));
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Code generator for a String concatenation (X...Y). This string can be made
|
||||
* up of any number of elements of any type.
|
||||
@ -20,35 +22,28 @@ Blockly.Arduino["text"] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["text_join"] = function (block) {
|
||||
Blockly.Arduino['text_join'] = function (block) {
|
||||
var code;
|
||||
if (block.itemCount_ === 0) {
|
||||
return ['""', Blockly.Arduino.ORDER_ATOMIC];
|
||||
} else if (block.itemCount_ === 1) {
|
||||
var argument0 =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"ADD0",
|
||||
Blockly.Arduino.ORDER_UNARY_POSTFIX
|
||||
) || '""';
|
||||
code = "String(" + argument0 + ")";
|
||||
var argument0 = Blockly.Arduino.valueToCode(block, 'ADD0',
|
||||
Blockly.Arduino.ORDER_UNARY_POSTFIX) || '""';
|
||||
code = 'String(' + argument0 + ')';
|
||||
return [code, Blockly.Arduino.ORDER_UNARY_POSTFIX];
|
||||
} else {
|
||||
var argument;
|
||||
code = [];
|
||||
for (var n = 0; n < block.itemCount_; n++) {
|
||||
argument = Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"ADD" + n,
|
||||
Blockly.Arduino.ORDER_NONE
|
||||
);
|
||||
if (argument === "") {
|
||||
block, 'ADD' + n, Blockly.Arduino.ORDER_NONE);
|
||||
if (argument === '') {
|
||||
code[n] = '""';
|
||||
} else {
|
||||
code[n] = "String(" + argument + ")";
|
||||
code[n] = 'String(' + argument + ')';
|
||||
}
|
||||
}
|
||||
code = code.join(" + ");
|
||||
code = code.join(' + ');
|
||||
return [code, Blockly.Arduino.ORDER_UNARY_POSTFIX];
|
||||
}
|
||||
};
|
||||
@ -60,23 +55,18 @@ Blockly.Arduino["text_join"] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {string} Completed code.
|
||||
*/
|
||||
Blockly.Arduino["text_append"] = function (block) {
|
||||
Blockly.Arduino['text_append'] = function (block) {
|
||||
// Append to a variable in place.
|
||||
var varName = Blockly.Arduino.nameDB_.getName(
|
||||
block.getFieldValue("VAR"),
|
||||
Blockly.Variables.NAME_TYPE
|
||||
);
|
||||
var argument0 = Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"TEXT",
|
||||
Blockly.Arduino.ORDER_UNARY_POSTFIX
|
||||
);
|
||||
if (argument0 === "") {
|
||||
var varName = Blockly.Arduino.variableDB_.getName(
|
||||
block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
|
||||
var argument0 = Blockly.Arduino.valueToCode(block, 'TEXT',
|
||||
Blockly.Arduino.ORDER_UNARY_POSTFIX);
|
||||
if (argument0 === '') {
|
||||
argument0 = '""';
|
||||
} else {
|
||||
argument0 = "String(" + argument0 + ")";
|
||||
argument0 = 'String(' + argument0 + ')';
|
||||
}
|
||||
return varName + " += " + argument0 + ";\n";
|
||||
return varName + ' += ' + argument0 + ';\n';
|
||||
};
|
||||
|
||||
/**
|
||||
@ -86,13 +76,10 @@ Blockly.Arduino["text_append"] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino["text_length"] = function (block) {
|
||||
var argument0 =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"VALUE",
|
||||
Blockly.Arduino.ORDER_UNARY_POSTFIX
|
||||
) || '""';
|
||||
var code = "String(" + argument0 + ").length()";
|
||||
Blockly.Arduino['text_length'] = function (block) {
|
||||
var argument0 = Blockly.Arduino.valueToCode(block, 'VALUE',
|
||||
Blockly.Arduino.ORDER_UNARY_POSTFIX) || '""';
|
||||
var code = 'String(' + argument0 + ').length()';
|
||||
return [code, Blockly.Arduino.ORDER_UNARY_POSTFIX];
|
||||
};
|
||||
|
||||
|
||||
@ -76,21 +76,6 @@ Blockly.Arduino["infinite_loop"] = function (block) {
|
||||
return "while(true);\n";
|
||||
};
|
||||
|
||||
// Blockly.Arduino.sensebox_interval_timer = function (block) {
|
||||
// var interval = this.getFieldValue("interval");
|
||||
// Blockly.Arduino.variables_["define_interval_variables"] =
|
||||
// "const long interval = " +
|
||||
// interval +
|
||||
// ";\nlong time_start = 0;\nlong time_actual = 0;";
|
||||
// var branch = Blockly.Arduino.statementToCode(block, "DO");
|
||||
// var code = "time_start = millis();\n";
|
||||
// code +=
|
||||
// "if (time_start > time_actual + interval) {\n time_actual = millis();\n";
|
||||
// code += branch;
|
||||
// code += "}\n";
|
||||
// return code;
|
||||
// };
|
||||
|
||||
Blockly.Arduino.sensebox_interval_timer = function (block) {
|
||||
var intervalTime = this.getFieldValue("interval");
|
||||
var intervalName = this.getFieldValue("name");
|
||||
@ -98,11 +83,9 @@ Blockly.Arduino.sensebox_interval_timer = function (block) {
|
||||
const long interval${intervalName} = ${intervalTime};
|
||||
long time_start${intervalName} = 0;
|
||||
long time_actual${intervalName} = 0;`;
|
||||
Blockly.Arduino.loopCodeOnce_[
|
||||
`interval_loop${intervalName}`
|
||||
] = `time_start${intervalName} = millis();\n`;
|
||||
var branch = Blockly.Arduino.statementToCode(block, "DO");
|
||||
var code = `
|
||||
var code = `time_start${intervalName} = millis();\n`;
|
||||
code += `
|
||||
if (time_start${intervalName} > time_actual${intervalName} + interval${intervalName}) {\n time_actual${intervalName} = millis();\n`;
|
||||
code += branch;
|
||||
code += "}\n";
|
||||
|
||||
@ -1,57 +1,52 @@
|
||||
import Blockly from "blockly";
|
||||
import Blockly from 'blockly';
|
||||
|
||||
const setVariableFunction = function (defaultValue) {
|
||||
return function (block) {
|
||||
var id = block.getFieldValue("VAR");
|
||||
|
||||
const variableName = Blockly.Variables.getVariable(
|
||||
Blockly.getMainWorkspace(),
|
||||
id
|
||||
).name;
|
||||
|
||||
// const variableName = Blockly["Arduino"].nameDB_.getName(
|
||||
// id,
|
||||
// Blockly.Variables.NAME_TYPE
|
||||
// );
|
||||
const variableValue = Blockly["Arduino"].valueToCode(
|
||||
const variableName = Blockly['Arduino'].variableDB_.getName(
|
||||
block.getFieldValue('VAR'),
|
||||
Blockly.Variables.NAME_TYPE
|
||||
);
|
||||
const variableValue = Blockly['Arduino'].valueToCode(
|
||||
block,
|
||||
"VALUE",
|
||||
Blockly["Arduino"].ORDER_ATOMIC
|
||||
'VALUE',
|
||||
Blockly['Arduino'].ORDER_ATOMIC
|
||||
);
|
||||
|
||||
const allVars = Blockly.getMainWorkspace()
|
||||
.getVariableMap()
|
||||
.getAllVariables();
|
||||
const myVar = allVars.filter((v) => v.name === variableName)[0];
|
||||
var code = "";
|
||||
if (myVar !== undefined) {
|
||||
Blockly.Arduino.variables_[variableName + myVar.type] =
|
||||
myVar.type + " " + myVar.name + ";\n";
|
||||
code = variableName + " = " + (variableValue || defaultValue) + ";\n";
|
||||
const allVars = Blockly.getMainWorkspace().getVariableMap().getAllVariables();
|
||||
const myVar = allVars.filter(v => v.name === variableName)[0]
|
||||
var code = ''
|
||||
|
||||
switch (myVar.type) {
|
||||
default:
|
||||
Blockly.Arduino.variables_[myVar + myVar.type] = myVar.type + " " + myVar.name + ';\n';
|
||||
code = variableName + ' = ' + (variableValue || defaultValue) + ';\n';
|
||||
break;
|
||||
case 'Array':
|
||||
var arrayType;
|
||||
var number;
|
||||
|
||||
if (this.getChildren().length > 0) {
|
||||
if (this.getChildren()[0].type === 'lists_create_empty') {
|
||||
|
||||
arrayType = this.getChildren()[0].getFieldValue('type');
|
||||
number = Blockly.Arduino.valueToCode(this.getChildren()[0], 'NUMBER', Blockly['Arduino'].ORDER_ATOMIC);
|
||||
Blockly.Arduino.variables_[myVar + myVar.type] = `${arrayType} ${myVar.name} [${number}];\n`;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return code;
|
||||
};
|
||||
};
|
||||
|
||||
const getVariableFunction = function (block) {
|
||||
var id = block.getFieldValue("VAR");
|
||||
|
||||
const variableName = Blockly.Variables.getVariable(
|
||||
Blockly.getMainWorkspace(),
|
||||
id
|
||||
).name;
|
||||
|
||||
const allVars = Blockly.getMainWorkspace()
|
||||
.getVariableMap()
|
||||
.getAllVariables();
|
||||
const myVar = allVars.filter((v) => v.name === variableName)[0];
|
||||
// const variableName = Blockly["Arduino"].nameDB_.getName(
|
||||
// block.getFieldValue("VAR"),
|
||||
// Blockly.Variables.NAME_TYPE
|
||||
// );
|
||||
var code = myVar.name;
|
||||
return [code, Blockly["Arduino"].ORDER_ATOMIC];
|
||||
const variableName = Blockly['Arduino'].variableDB_.getName(
|
||||
block.getFieldValue('VAR'),
|
||||
Blockly.Variables.NAME_TYPE
|
||||
);
|
||||
var code = variableName;
|
||||
return [code, Blockly['Arduino'].ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly["Arduino"]["variables_set_dynamic"] = setVariableFunction();
|
||||
Blockly["Arduino"]["variables_get_dynamic"] = getVariableFunction;
|
||||
Blockly['Arduino']['variables_set_dynamic'] = setVariableFunction()
|
||||
Blockly['Arduino']['variables_get_dynamic'] = getVariableFunction;
|
||||
@ -1,16 +0,0 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
|
||||
Blockly.Arduino.watchdog_enable = function () {
|
||||
var time = this.getFieldValue("TIME");
|
||||
|
||||
Blockly.Arduino.libraries_["Adafruit_sleepydog"] =
|
||||
"#include <Adafruit_SleepyDog.h> // http://librarymanager/All#Adafruit_SleepyDog_Library";
|
||||
Blockly.Arduino.setupCode_["watchdog_enable"] = `Watchdog.enable(${time});`;
|
||||
var code = "";
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.watchdog_reset = function () {
|
||||
var code = "Watchdog.reset();";
|
||||
return code;
|
||||
};
|
||||
@ -6,9 +6,8 @@ import Blockly from "blockly";
|
||||
|
||||
Blockly.Arduino.sensebox_initialize_http_server = function (block) {
|
||||
var box_id = this.getFieldValue("Port");
|
||||
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||
Blockly.Arduino.libraries_["library_http"] = "#include <WebUtil.h>";
|
||||
|
||||
Blockly.Arduino.libraries_["library_senseBoxMCU"] =
|
||||
'#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.codeFunctions_["define_wifi_server"] =
|
||||
"WiFiServer server(" + box_id + ");";
|
||||
Blockly.Arduino.setupCode_["sensebox_wifi_server_beging"] = "server.begin();";
|
||||
@ -113,21 +112,16 @@ Blockly.Arduino.sensebox_web_readHTML = function (block) {
|
||||
Blockly.Arduino.libraries_["library_sd"] = "#include <SD.h>";
|
||||
Blockly.Arduino.codeFunctions_["define_sd" + filename] = "File webFile;";
|
||||
Blockly.Arduino.setupCode_["sensebox_sd"] = "SD.begin(28);";
|
||||
var func = [
|
||||
"String generateHTML(){",
|
||||
' webFile = SD.open("' + filename + '", FILE_READ);',
|
||||
' String finalString ="";',
|
||||
" while (webFile.available())",
|
||||
" {",
|
||||
" finalString+=(char)webFile.read();",
|
||||
" }",
|
||||
" return finalString;",
|
||||
"}",
|
||||
];
|
||||
var functionName = Blockly.Arduino.addFunction(
|
||||
"generateHTML",
|
||||
func.join("\n")
|
||||
);
|
||||
var code = functionName + "()";
|
||||
Blockly.Arduino.codeFunctions_["generateHTML"] = `
|
||||
String generateHTML(){
|
||||
webFile = SD.open("${filename}", FILE_READ);
|
||||
String finalString ="";
|
||||
while (webFile.available())
|
||||
{
|
||||
finalString+=(char)webFile.read();
|
||||
}
|
||||
return finalString;
|
||||
}`;
|
||||
var code = `generateHTML()`;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
@ -3,266 +3,42 @@
|
||||
*
|
||||
*/
|
||||
const sensebox_mcu = {
|
||||
description: "senseBox Microcontroller Unit based on Microchip SAMD21G18A",
|
||||
compilerFlag: "arduino:samd",
|
||||
digitalPins: [
|
||||
["A1", "1"],
|
||||
["A2", "2"],
|
||||
["B3", "3"],
|
||||
["B4", "4"],
|
||||
["C5", "5"],
|
||||
["C6", "6"],
|
||||
],
|
||||
digitalPorts: [
|
||||
["A", "A"],
|
||||
["B", "B"],
|
||||
["C", "C"],
|
||||
],
|
||||
digitalPinsLED: [
|
||||
["BUILTIN_1", "7"],
|
||||
["BUILTIN_2", "8"],
|
||||
["A1", "1"],
|
||||
["A2", "2"],
|
||||
["B3", "3"],
|
||||
["B4", "4"],
|
||||
["C5", "5"],
|
||||
["C6", "6"],
|
||||
],
|
||||
digitalPinsRGB: [
|
||||
["A", "1"],
|
||||
["B", "3"],
|
||||
["C", "5"],
|
||||
],
|
||||
digitalPinsButton: [
|
||||
["on Board", "0"],
|
||||
["A1", "1"],
|
||||
["A2", "2"],
|
||||
["B3", "3"],
|
||||
["B4", "4"],
|
||||
["C5", "5"],
|
||||
["C6", "6"],
|
||||
],
|
||||
pwmPins: [
|
||||
["A1", "1"],
|
||||
["A2", "2"],
|
||||
["B3", "3"],
|
||||
["B4", "4"],
|
||||
["C5", "5"],
|
||||
["C6", "6"],
|
||||
],
|
||||
serial: [
|
||||
["SerialUSB", "SerialUSB"],
|
||||
["Serial1", "Serial1"],
|
||||
["Serial2", "Serial2"],
|
||||
],
|
||||
serialSensors: [
|
||||
["Serial1", "Serial1"],
|
||||
["Serial2", "Serial2"],
|
||||
],
|
||||
description: 'senseBox Microcontroller Unit based on Microchip SAMD21G18A',
|
||||
compilerFlag: 'arduino:samd',
|
||||
digitalPins: [['D1', '1'], ['D2', '2'], ['D3', '3'], ['D4', '4'], ['D5', '5'], ['D6', '6']],
|
||||
digitalPinsLED: [['BUILTIN_1', '7'], ['BUILTIN_2', '8'], ['D1', '1'], ['D2', '2'], ['D3', '3'], ['D4', '4'], ['D5', '5'], ['D6', '6']],
|
||||
digitalPinsButton: [['on Board', '0'], ['D1', '1'], ['D2', '2'], ['D3', '3'], ['D4', '4'], ['D5', '5'], ['D6', '6']],
|
||||
pwmPins: [['D1', '1'], ['D2', '2'], ['D3', '3'], ['D4', '4'], ['D5', '5'], ['D6', '6']],
|
||||
serial: [['serial', 'SerialUSB'], ['serial_1', 'Serial1'], ['serial_2', 'Serial2']],
|
||||
serialPins: {
|
||||
SerialUSB: [
|
||||
["RX", ""],
|
||||
["TX", ""],
|
||||
],
|
||||
Serial1: [
|
||||
["RX", "11"],
|
||||
["TX", "10"],
|
||||
],
|
||||
Serial2: [
|
||||
["RX", "13"],
|
||||
["TX", "12"],
|
||||
],
|
||||
SerialUSB: [['RX', ''], ['TX', '']],
|
||||
Serial1: [['RX', '11'], ['TX', '10']],
|
||||
Serial2: [['RX', '13'], ['TX', '12']]
|
||||
},
|
||||
serialSpeed: [
|
||||
["300", "300"],
|
||||
["600", "600"],
|
||||
["1200", "1200"],
|
||||
["2400", "2400"],
|
||||
["4800", "4800"],
|
||||
["9600", "9600"],
|
||||
["14400", "14400"],
|
||||
["19200", "19200"],
|
||||
["28800", "28800"],
|
||||
["31250", "31250"],
|
||||
["38400", "38400"],
|
||||
["57600", "57600"],
|
||||
["115200", "115200"],
|
||||
],
|
||||
spi: [["SPI", "SPI"]],
|
||||
spiPins: {
|
||||
SPI: [
|
||||
["MOSI", "19"],
|
||||
["MISO", "21"],
|
||||
["SCK", "20"],
|
||||
],
|
||||
},
|
||||
spiClockDivide: [
|
||||
["2 (8MHz)", "SPI_CLOCK_DIV2"],
|
||||
["4 (4MHz)", "SPI_CLOCK_DIV4"],
|
||||
["8 (2MHz)", "SPI_CLOCK_DIV8"],
|
||||
["16 (1MHz)", "SPI_CLOCK_DIV16"],
|
||||
["32 (500KHz)", "SPI_CLOCK_DIV32"],
|
||||
["64 (250KHz)", "SPI_CLOCK_DIV64"],
|
||||
["128 (125KHz)", "SPI_CLOCK_DIV128"],
|
||||
],
|
||||
i2c: [["I2C", "Wire"]],
|
||||
i2cPins: {
|
||||
Wire: [
|
||||
["SDA", "17"],
|
||||
["SCL", "16"],
|
||||
],
|
||||
},
|
||||
i2cSpeed: [
|
||||
["100kHz", "100000L"],
|
||||
["400kHz", "400000L"],
|
||||
],
|
||||
builtinLed: [
|
||||
["BUILTIN_1", "7"],
|
||||
["BUILTIN_2", "8"],
|
||||
],
|
||||
interrupt: [
|
||||
["interrupt1", "1"],
|
||||
["interrupt2", "2"],
|
||||
["interrupt3", "3"],
|
||||
["interrupt4", "4"],
|
||||
["interrupt5", "5"],
|
||||
["interrupt6", "6"],
|
||||
],
|
||||
analogPins: [
|
||||
["A1", "A1"],
|
||||
["A2", "A2"],
|
||||
["B3", "A3"],
|
||||
["B4", "A4"],
|
||||
["C5", "A5"],
|
||||
["C6", "A6"],
|
||||
],
|
||||
serialSpeed: [['300', '300'], ['600', '600'], ['1200', '1200'],
|
||||
['2400', '2400'], ['4800', '4800'], ['9600', '9600'],
|
||||
['14400', '14400'], ['19200', '19200'], ['28800', '28800'],
|
||||
['31250', '31250'], ['38400', '38400'], ['57600', '57600'],
|
||||
['115200', '115200']],
|
||||
spi: [['SPI', 'SPI']],
|
||||
spiPins: { SPI: [['MOSI', '19'], ['MISO', '21'], ['SCK', '20']] },
|
||||
spiClockDivide: [['2 (8MHz)', 'SPI_CLOCK_DIV2'],
|
||||
['4 (4MHz)', 'SPI_CLOCK_DIV4'],
|
||||
['8 (2MHz)', 'SPI_CLOCK_DIV8'],
|
||||
['16 (1MHz)', 'SPI_CLOCK_DIV16'],
|
||||
['32 (500KHz)', 'SPI_CLOCK_DIV32'],
|
||||
['64 (250KHz)', 'SPI_CLOCK_DIV64'],
|
||||
['128 (125KHz)', 'SPI_CLOCK_DIV128']],
|
||||
i2c: [['I2C', 'Wire']],
|
||||
i2cPins: { Wire: [['SDA', '17'], ['SCL', '16']] },
|
||||
i2cSpeed: [['100kHz', '100000L'], ['400kHz', '400000L']],
|
||||
builtinLed: [['BUILTIN_1', '7'], ['BUILTIN_2', '8']],
|
||||
interrupt: [['interrupt1', '1'], ['interrupt2', '2'], ['interrupt3', '3'], ['interrupt4', '4'], ['interrupt5', '5'], ['interrupt6', '6']],
|
||||
analogPins: [['A1', 'A1'], ['A2', 'A2'], ['A3', 'A3'], ['A4', 'A4'], ['A5', 'A5'], ['A6', 'A6']],
|
||||
serial_baud_rate: 9600,
|
||||
parseKey: "_*_",
|
||||
parseKey: '_*_'
|
||||
};
|
||||
|
||||
//senseBox MCU mini
|
||||
const sensebox_mini = {
|
||||
description: "senseBox Mini",
|
||||
compilerFlag: "arduino:samd",
|
||||
digitalPins: [
|
||||
["IO1", "1"],
|
||||
["IO2", "2"],
|
||||
],
|
||||
digitalPorts: [
|
||||
["IO1-2", "A"],
|
||||
],
|
||||
digitalPinsLED: [
|
||||
["BUILTIN_1", "7"],
|
||||
["BUILTIN_2", "8"],
|
||||
["IO1", "1"],
|
||||
["IO2", "2"],
|
||||
],
|
||||
digitalPinsRGB: [
|
||||
["on Board", "6"],
|
||||
["IO1-2", "1"],
|
||||
],
|
||||
digitalPinsButton: [
|
||||
["on Board", "0"],
|
||||
["IO1", "1"],
|
||||
["IO2", "2"],
|
||||
|
||||
],
|
||||
pwmPins: [
|
||||
["IO1", "1"],
|
||||
["IO2", "2"],
|
||||
],
|
||||
serial: [
|
||||
["SerialUSB", "SerialUSB"],
|
||||
["Serial1", "Serial1"],
|
||||
],
|
||||
serialSensors: [
|
||||
["Serial1", "Serial1"],
|
||||
],
|
||||
serialPins: {
|
||||
SerialUSB: [
|
||||
["RX", ""],
|
||||
["TX", ""],
|
||||
],
|
||||
Serial1: [
|
||||
["RX", "11"],
|
||||
["TX", "10"],
|
||||
],
|
||||
Serial2: [
|
||||
["RX", "13"],
|
||||
["TX", "12"],
|
||||
],
|
||||
},
|
||||
serialSpeed: [
|
||||
["300", "300"],
|
||||
["600", "600"],
|
||||
["1200", "1200"],
|
||||
["2400", "2400"],
|
||||
["4800", "4800"],
|
||||
["9600", "9600"],
|
||||
["14400", "14400"],
|
||||
["19200", "19200"],
|
||||
["28800", "28800"],
|
||||
["31250", "31250"],
|
||||
["38400", "38400"],
|
||||
["57600", "57600"],
|
||||
["115200", "115200"],
|
||||
],
|
||||
spi: [["SPI", "SPI"]],
|
||||
spiPins: {
|
||||
SPI: [
|
||||
["MOSI", "19"],
|
||||
["MISO", "21"],
|
||||
["SCK", "20"],
|
||||
],
|
||||
},
|
||||
spiClockDivide: [
|
||||
["2 (8MHz)", "SPI_CLOCK_DIV2"],
|
||||
["4 (4MHz)", "SPI_CLOCK_DIV4"],
|
||||
["8 (2MHz)", "SPI_CLOCK_DIV8"],
|
||||
["16 (1MHz)", "SPI_CLOCK_DIV16"],
|
||||
["32 (500KHz)", "SPI_CLOCK_DIV32"],
|
||||
["64 (250KHz)", "SPI_CLOCK_DIV64"],
|
||||
["128 (125KHz)", "SPI_CLOCK_DIV128"],
|
||||
],
|
||||
i2c: [["I2C", "Wire"]],
|
||||
i2cPins: {
|
||||
Wire: [
|
||||
["SDA", "17"],
|
||||
["SCL", "16"],
|
||||
],
|
||||
},
|
||||
i2cSpeed: [
|
||||
["100kHz", "100000L"],
|
||||
["400kHz", "400000L"],
|
||||
],
|
||||
builtinLed: [
|
||||
["BUILTIN_1", "7"],
|
||||
["BUILTIN_2", "8"],
|
||||
],
|
||||
interrupt: [
|
||||
["interrupt1", "1"],
|
||||
["interrupt2", "2"],
|
||||
],
|
||||
analogPins: [
|
||||
["A1", "A1"],
|
||||
["A2", "A2"],
|
||||
],
|
||||
serial_baud_rate: 9600,
|
||||
parseKey: "_*_",
|
||||
};
|
||||
|
||||
var board = sensebox_mcu
|
||||
|
||||
export const setBoard = (selectedBoard) => {
|
||||
if (selectedBoard === "mini"){
|
||||
board = sensebox_mini
|
||||
}
|
||||
else {
|
||||
board = sensebox_mcu
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const selectedBoard = () => {
|
||||
return board;
|
||||
return sensebox_mcu;
|
||||
};
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
const colours = {
|
||||
sensebox: 120,
|
||||
logic: 210,
|
||||
@ -11,13 +12,11 @@ const colours = {
|
||||
audio: 250,
|
||||
arrays: 33,
|
||||
mqtt: 90,
|
||||
serial: 230,
|
||||
webserver: 40,
|
||||
phyphox: 25,
|
||||
motors: 190,
|
||||
cleverlab: 185 ,
|
||||
};
|
||||
webserver: 40
|
||||
}
|
||||
|
||||
|
||||
export const getColour = () => {
|
||||
return colours;
|
||||
};
|
||||
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
/**
|
||||
* To limit number of specific blocks in the workspace add block name and number of maxInstances here.
|
||||
*
|
||||
*/
|
||||
|
||||
const maxInstances = {
|
||||
sensebox_wifi: 1,
|
||||
sensebox_startap: 1,
|
||||
sensebox_display_beginDisplay: 1,
|
||||
sensebox_telegram: 1,
|
||||
sensebox_telegram_do: 1,
|
||||
sensebox_osem_connection: 1,
|
||||
sensebox_lora_initialize_otaa: 1,
|
||||
sensebox_lora_initialize_abp: 1,
|
||||
sensebox_phyphox_init: 1,
|
||||
sensebox_phyphox_experiment: 1,
|
||||
sensebox_phyphox_experiment_send: 1,
|
||||
sensebox_ethernet: 1,
|
||||
};
|
||||
|
||||
export const getMaxInstances = () => {
|
||||
return maxInstances;
|
||||
};
|
||||
@ -8,100 +8,235 @@
|
||||
* types.
|
||||
*/
|
||||
|
||||
|
||||
/** Single character. */
|
||||
export const CHARACTER = {
|
||||
typeId: 'Character',
|
||||
typeName: 'char',
|
||||
typeMsgName: 'ARD_TYPE_CHAR',
|
||||
}
|
||||
typeId: "Character",
|
||||
typeName: "char",
|
||||
typeMsgName: "ARD_TYPE_CHAR",
|
||||
};
|
||||
|
||||
export const BOOLEAN = {
|
||||
typeId: 'Boolean',
|
||||
typeName: 'boolean',
|
||||
typeMsgName: 'ARD_TYPE_BOOL',
|
||||
}
|
||||
typeId: "Boolean",
|
||||
typeName: "boolean",
|
||||
typeMsgName: "ARD_TYPE_BOOL",
|
||||
};
|
||||
|
||||
/** Text string. */
|
||||
export const TEXT = {
|
||||
typeId: 'Text',
|
||||
typeName: 'String',
|
||||
typeMsgName: 'ARD_TYPE_TEXT',
|
||||
}
|
||||
typeId: "Text",
|
||||
typeName: "String",
|
||||
typeMsgName: "ARD_TYPE_TEXT",
|
||||
};
|
||||
|
||||
/** Short integer number. */
|
||||
export const SHORT_NUMBER = {
|
||||
typeId: 'Short_Number',
|
||||
typeName: 'int',
|
||||
typeMsgName: 'ARD_TYPE_SHORT',
|
||||
}
|
||||
typeId: "Short_Number",
|
||||
typeName: "int",
|
||||
typeMsgName: "ARD_TYPE_SHORT",
|
||||
};
|
||||
|
||||
/** Integer number. */
|
||||
export const NUMBER = {
|
||||
typeId: 'Number',
|
||||
typeName: 'int',
|
||||
typeMsgName: 'ARD_TYPE_NUMBER',
|
||||
}
|
||||
typeId: "Number",
|
||||
typeName: "int",
|
||||
typeMsgName: "ARD_TYPE_NUMBER",
|
||||
};
|
||||
|
||||
/** Large integer number. */
|
||||
export const LARGE_NUMBER = {
|
||||
typeId: 'Large Number',
|
||||
typeName: 'long',
|
||||
typeMsgName: 'ARD_TYPE_LONG',
|
||||
}
|
||||
typeId: "Large Number",
|
||||
typeName: "long",
|
||||
typeMsgName: "ARD_TYPE_LONG",
|
||||
};
|
||||
|
||||
/** Decimal/floating point number. */
|
||||
export const DECIMAL = {
|
||||
typeId: 'Decimal',
|
||||
typeName: 'float',
|
||||
typeMsgName: 'ARD_TYPE_DECIMAL',
|
||||
}
|
||||
typeId: "Decimal",
|
||||
typeName: "float",
|
||||
typeMsgName: "ARD_TYPE_DECIMAL",
|
||||
};
|
||||
|
||||
/** Array/List of items. */
|
||||
export const ARRAY = {
|
||||
typeId: 'Array',
|
||||
typeName: 'Array',
|
||||
typeMsgName: 'ARD_TYPE_ARRAY',
|
||||
compatibleTypes: []
|
||||
}
|
||||
typeId: "Array",
|
||||
typeName: "Array",
|
||||
typeMsgName: "ARD_TYPE_ARRAY",
|
||||
compatibleTypes: [],
|
||||
};
|
||||
|
||||
/** Null indicate there is no type. */
|
||||
export const NULL = {
|
||||
typeId: 'Null',
|
||||
typeName: 'void',
|
||||
typeMsgName: 'ARD_TYPE_NULL',
|
||||
}
|
||||
typeId: "Null",
|
||||
typeName: "void",
|
||||
typeMsgName: "ARD_TYPE_NULL",
|
||||
};
|
||||
|
||||
/** Type not defined, or not yet defined. */
|
||||
export const UNDEF = {
|
||||
typeId: 'Undefined',
|
||||
typeName: 'undef',
|
||||
typeMsgName: 'ARD_TYPE_UNDEF',
|
||||
}
|
||||
typeId: "Undefined",
|
||||
typeName: "undef",
|
||||
typeMsgName: "ARD_TYPE_UNDEF",
|
||||
};
|
||||
|
||||
/** Set when no child block (meant to define the variable type) is connected. */
|
||||
export const CHILD_BLOCK_MISSING = {
|
||||
typeId: 'ChildBlockMissing',
|
||||
typeMsgName: 'ARD_TYPE_CHILDBLOCKMISSING',
|
||||
compatibleTypes: []
|
||||
}
|
||||
typeId: "ChildBlockMissing",
|
||||
typeMsgName: "ARD_TYPE_CHILDBLOCKMISSING",
|
||||
compatibleTypes: [],
|
||||
};
|
||||
|
||||
const compatibleTypes = {
|
||||
Array: ['Array'],
|
||||
boolean: ['boolean'],
|
||||
int: ['int', 'long', 'double', 'float'],
|
||||
char: ['char'],
|
||||
String: ['String'],
|
||||
void: ['void'],
|
||||
long: ['int', 'long'],
|
||||
double: ['int', 'long', 'double'],
|
||||
float: ['int', 'long', 'double', 'float'],
|
||||
null: ['null']
|
||||
|
||||
}
|
||||
Array: ["Array"],
|
||||
boolean: ["boolean"],
|
||||
int: ["int", "long", "double", "float"],
|
||||
char: ["char"],
|
||||
String: ["String"],
|
||||
void: ["void"],
|
||||
long: ["int", "long"],
|
||||
double: ["int", "long", "double"],
|
||||
float: ["int", "long", "double", "float"],
|
||||
null: ["null"],
|
||||
};
|
||||
|
||||
export const getCompatibleTypes = (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 = [
|
||||
["SHORT_NUMBER", "char"],
|
||||
["NUMBER", "int"],
|
||||
["DECIMAL", "long"],
|
||||
["TEXT", "String"],
|
||||
["CHARACTER", "char"],
|
||||
["BOOLEAN", "boolean"],
|
||||
["NULL", "void"],
|
||||
["UNDEF", "undefined"],
|
||||
];
|
||||
|
||||
// /**
|
||||
// * Some Types have circular dependencies on their compatibilities, so add them
|
||||
// * after declaration.
|
||||
// */
|
||||
// Blockly.Types.NUMBER.addCompatibleTypes([
|
||||
// Blockly.Types.BOOLEAN,
|
||||
// Blockly.Types.SHORT_NUMBER,
|
||||
// Blockly.Types.LARGE_NUMBER,
|
||||
// Blockly.Types.DECIMAL]);
|
||||
|
||||
// Blockly.Types.SHORT_NUMBER.addCompatibleTypes([
|
||||
// Blockly.Types.BOOLEAN,
|
||||
// Blockly.Types.NUMBER,
|
||||
// Blockly.Types.LARGE_NUMBER,
|
||||
// Blockly.Types.DECIMAL]);
|
||||
|
||||
// Blockly.Types.LARGE_NUMBER.addCompatibleTypes([
|
||||
// Blockly.Types.BOOLEAN,
|
||||
// Blockly.Types.SHORT_NUMBER,
|
||||
// Blockly.Types.NUMBER,
|
||||
// Blockly.Types.DECIMAL]);
|
||||
|
||||
// /**
|
||||
// * Adds another type to the Blockly.Types collection.
|
||||
// * @param {string} typeId_ Identifiable name of the type.
|
||||
// * @param {string} typeMsgName_ Name of the member variable from Blockly.Msg
|
||||
// * object to identify the translateble string.for the Type name.
|
||||
// * @param {Array<Blockly.Type>} compatibleTypes_ List of types this Type is
|
||||
// * compatible with.
|
||||
// */
|
||||
// Blockly.Types.addType = function (typeId_, typeMsgName_, compatibleTypes_) {
|
||||
// // The Id is used as the key from the value pair in the BlocklyTypes object
|
||||
// var key = typeId_.toUpperCase().replace(/ /g, '_');
|
||||
// if (Blockly.Types[key] !== undefined) {
|
||||
// throw 'The Blockly type ' + key + ' already exists.';
|
||||
// }
|
||||
// Blockly.Types[key] = new Blockly.Type({
|
||||
// typeId: typeId_,
|
||||
// typeName: typeMsgName_,
|
||||
// compatibleTypes: compatibleTypes_
|
||||
// });
|
||||
// };
|
||||
|
||||
// /**
|
||||
// * Converts the static types dictionary in to a an array with 2-item arrays.
|
||||
// * This array only contains the valid types, excluding any error or temp types.
|
||||
// * @return {!Array<Array<string>>} Blockly types in the format described above.
|
||||
// */
|
||||
// Blockly.Types.getValidTypeArray = function () {
|
||||
// var typesArray = [];
|
||||
// for (var typeKey in Blockly.Types) {
|
||||
// if ((typeKey !== 'UNDEF') && (typeKey !== 'CHILD_BLOCK_MISSING') &&
|
||||
// (typeKey !== 'NULL') && (typeKey !== 'ARRAY') &&
|
||||
// (typeof Blockly.Types[typeKey] !== 'function') &&
|
||||
// !(Blockly.Types[typeKey] instanceof RegExp)) {
|
||||
// typesArray.push([Blockly.Types[typeKey].typeName, typeKey]);
|
||||
// }
|
||||
// }
|
||||
// return typesArray;
|
||||
// };
|
||||
|
||||
// /**
|
||||
// * Navigates through child blocks of the argument block to get this block type.
|
||||
// * @param {!Blockly.Block} block Block to navigate through children.
|
||||
// * @return {Blockly.Type} Type of the input block.
|
||||
// */
|
||||
// Blockly.Types.getChildBlockType = function (block) {
|
||||
// var blockType = null;
|
||||
// var nextBlock = block;
|
||||
// // Only checks first input block, so it decides the type. Incoherences amongst
|
||||
// // multiple inputs dealt at a per-block level with their own block warnings
|
||||
// while (nextBlock && (nextBlock.getBlockType === undefined) &&
|
||||
// (nextBlock.inputList.length > 0) &&
|
||||
// (nextBlock.inputList[0].connection)) {
|
||||
// nextBlock = nextBlock.inputList[0].connection.targetBlock();
|
||||
// }
|
||||
// if (nextBlock === block) {
|
||||
// // Set variable block is empty, so no type yet
|
||||
// blockType = Blockly.Types.CHILD_BLOCK_MISSING;
|
||||
// } else if (nextBlock === null) {
|
||||
// // Null return from targetBlock indicates no block connected
|
||||
// blockType = Blockly.Types.CHILD_BLOCK_MISSING;
|
||||
// } else {
|
||||
// var func = nextBlock.getBlockType;
|
||||
// if (func) {
|
||||
// blockType = nextBlock.getBlockType();
|
||||
// } else {
|
||||
// // Most inner block, supposed to define a type, is missing getBlockType()
|
||||
// blockType = Blockly.Types.NULL;
|
||||
// }
|
||||
// }
|
||||
// return blockType;
|
||||
// };
|
||||
|
||||
// /**
|
||||
// * Regular expressions to identify an integer.
|
||||
// * @private
|
||||
// */
|
||||
// Blockly.Types.regExpInt_ = new RegExp(/^-?\d+$/);
|
||||
|
||||
// /**
|
||||
// * Regular expressions to identify a decimal.
|
||||
// * @private
|
||||
// */
|
||||
// Blockly.Types.regExpFloat_ = new RegExp(/^-?[0-9]*[.][0-9]+$/);
|
||||
|
||||
// /**
|
||||
// * Uses regular expressions to identify if the input number is an integer or a
|
||||
// * floating point.
|
||||
// * @param {string} numberString String of the number to identify.
|
||||
// * @return {!Blockly.Type} Blockly type.
|
||||
// */
|
||||
// Blockly.Types.identifyNumber = function (numberString) {
|
||||
// if (Blockly.Types.regExpInt_.test(numberString)) {
|
||||
// var intValue = parseInt(numberString);
|
||||
// if (isNaN(intValue)) {
|
||||
// return Blockly.Types.NULL;
|
||||
// }
|
||||
// if (intValue > 32767 || intValue < -32768) {
|
||||
// return Blockly.Types.LARGE_NUMBER;
|
||||
// }
|
||||
// return Blockly.Types.NUMBER;
|
||||
// } else if (Blockly.Types.regExpFloat_.test(numberString)) {
|
||||
// return Blockly.Types.DECIMAL;
|
||||
// }
|
||||
// return Blockly.Types.NULL;
|
||||
// };
|
||||
|
||||
@ -21,8 +21,8 @@
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import BlocklyComponent from "./BlocklyComponent";
|
||||
import React from 'react';
|
||||
import BlocklyComponent from './BlocklyComponent';
|
||||
|
||||
export default BlocklyComponent;
|
||||
|
||||
@ -56,16 +56,4 @@ const Shadow = (p) => {
|
||||
return React.createElement("shadow", props, children);
|
||||
};
|
||||
|
||||
const Sep = (p) => {
|
||||
const { children, ...props } = p;
|
||||
props.is = "blockly";
|
||||
return React.createElement("sep", props, children);
|
||||
};
|
||||
|
||||
const Label = (p) => {
|
||||
const { children, ...props } = p;
|
||||
props.is = "blockly";
|
||||
return React.createElement("label", props, children);
|
||||
};
|
||||
|
||||
export { Block, Category, Value, Field, Shadow, Sep, Label };
|
||||
export { Block, Category, Value, Field, Shadow }
|
||||
@ -1,34 +1,29 @@
|
||||
import { AUDIO } from "./de/audio";
|
||||
import { BLE } from "./de/sensebox-ble";
|
||||
import { FAQ } from "./de/faq";
|
||||
import { IO } from "./de/io";
|
||||
import { LOGIC } from "./de/logic";
|
||||
import { LOOPS } from "./de/loops";
|
||||
import { MATH } from "./de/math";
|
||||
import { MQTT } from "./de/mqtt";
|
||||
import { DISPLAY } from "./de/sensebox-display";
|
||||
import { MOTORS } from "./de/sensebox-motors";
|
||||
import { LED } from "./de/sensebox-led";
|
||||
import { LORA } from "./de/sensebox-lora";
|
||||
import { OSEM } from "./de/sensebox-osem";
|
||||
import { RTC } from "./de/sensebox-rtc";
|
||||
import { NTP } from "./de/sensebox-ntp";
|
||||
import { SD } from "./de/sensebox-sd";
|
||||
import { SENSORS } from "./de/sensebox-sensors";
|
||||
import { SENSEBOX } from "./de/sensebox";
|
||||
import { TELEGRAM } from "./de/sensebox-telegram";
|
||||
import { WEB } from "./de/sensebox-web";
|
||||
import { TEXT } from "./de/text";
|
||||
import { TIME } from "./de/time";
|
||||
import { TOURS } from "./de/tours";
|
||||
import { TRANSLATIONS } from "./de/translations";
|
||||
import { UI } from "./de/ui";
|
||||
import { VARIABLES } from "./de/variables";
|
||||
import { WEBSERVER } from "./de/webserver";
|
||||
|
||||
import { AUDIO } from './de/audio';
|
||||
import { FAQ } from './de/faq';
|
||||
import { IO } from './de/io';
|
||||
import { LOGIC } from './de/logic';
|
||||
import { LOOPS } from './de/loops';
|
||||
import { MATH } from './de/math';
|
||||
import { MQTT } from './de/mqtt';
|
||||
import { DISPLAY } from './de/sensebox-display';
|
||||
import { LED } from './de/sensebox-led';
|
||||
import { LORA } from './de/sensebox-lora';
|
||||
import { OSEM } from './de/sensebox-osem';
|
||||
import { SD } from './de/sensebox-sd';
|
||||
import { SENSORS } from './de/sensebox-sensors';
|
||||
import { TELEGRAM } from './de/sensebox-telegram';
|
||||
import { WEB } from './de/sensebox-web';
|
||||
import { TEXT } from './de/text';
|
||||
import { TIME } from './de/time';
|
||||
import { TOURS } from './de/tours';
|
||||
import { TRANSLATIONS } from './de/translations';
|
||||
import { UI } from './de/ui';
|
||||
import { VARIABLES } from './de/variables';
|
||||
import { WEBSERVER } from './de/webserver';
|
||||
|
||||
export const De = {
|
||||
...AUDIO,
|
||||
...BLE,
|
||||
...FAQ,
|
||||
...IO,
|
||||
...LOGIC,
|
||||
@ -36,15 +31,11 @@ export const De = {
|
||||
...MATH,
|
||||
...MQTT,
|
||||
...DISPLAY,
|
||||
...MOTORS,
|
||||
...LED,
|
||||
...LORA,
|
||||
...OSEM,
|
||||
...RTC,
|
||||
...NTP,
|
||||
...SD,
|
||||
...SENSORS,
|
||||
...SENSEBOX,
|
||||
...TELEGRAM,
|
||||
...WEB,
|
||||
...TEXT,
|
||||
@ -53,5 +44,5 @@ export const De = {
|
||||
...TRANSLATIONS,
|
||||
...UI,
|
||||
...VARIABLES,
|
||||
...WEBSERVER,
|
||||
};
|
||||
...WEBSERVER
|
||||
}
|
||||
|
||||
@ -19,11 +19,9 @@ Das Kopieren der Programme unter MacOS funktioniert nicht über den Finder, es g
|
||||
Grundsätzlich kann die Programmierumgebung mit jeder senseBox mit senseBox MCU verwendet werden.
|
||||
`,
|
||||
|
||||
|
||||
faq_q3_question: `Ich habe einen Fehler gefunden oder etwas funktioniert nicht. Wo kann ich diesen melden?`,
|
||||
faq_q3_answer: `
|
||||
Am besten legst du dazu ein Issue auf [Github](https://github.com/sensebox/React-Ardublockly/issues) an. Alternativ kannst du uns auch eine Email an info(at)sensebox.de senden
|
||||
`,
|
||||
|
||||
faq_tablet_question: `Kann ich die senseBox auch über ein Tablet programmieren?`,
|
||||
faq_tablet_answer: `Ja! Installiere dazu die senseBox Connect App aus dem App Store und rufe die Learn- und Programmierumgebung in deinem Browser am Tablet auf. Genaue Informationen zur Verwendung der App findest du unter [https://sensebox.de/app](https://sensebox.de/app)`,
|
||||
};
|
||||
}
|
||||
@ -1,26 +1,23 @@
|
||||
|
||||
export const IO = {
|
||||
|
||||
ARD_ANALOGREAD: "lese analogen Pin#",
|
||||
ARD_ANALOGREAD_TIP: "Gibt einen Wert zwischen 0 und 1023 zurück",
|
||||
ARD_ANALOGREAD_TIP: "Gibt einen Wert zwischen 0 und 1024 zurüch",
|
||||
ARD_ANALOGWRITE: "setzte analogen Pin#",
|
||||
ARD_ANALOGWRITE_TIP:
|
||||
"Schreibe analogen Wert zwischen 0 und 255 an einen spezifischen PWM Port",
|
||||
ARD_ANALOGWRITE_TIP: "Schreibe analogen Wert zwischen 0 und 255 an einen spezifischen PWM Port",
|
||||
ARD_BUILTIN_LED: "eingebaute LED",
|
||||
ARD_BUILTIN_LED_TIP: "Schaltet die interne LED An oder Aus",
|
||||
ARD_COMPONENT_WARN1:
|
||||
"A %1 configuration block with the same %2 name must be added to use this block!",
|
||||
ARD_COMPONENT_WARN1: "A %1 configuration block with the same %2 name must be added to use this block!",
|
||||
ARD_DEFINE: "Definiere",
|
||||
ARD_DIGITALREAD: "lesen digitalen Pin#",
|
||||
ARD_DIGITALREAD_TIP: "Lese Wert an digitalen Pin: HIGH(1) oder LOW(0)",
|
||||
ARD_DIGITALWRITE: "setzte digitalen Pin#",
|
||||
ARD_DIGITALWRITE_TIP:
|
||||
"Schreibe digitalen Wert HIGH (1) oder LOW(0) an spezifischen Port",
|
||||
ARD_DIGITALWRITE_TIP: "Schreibe digitalen Wert HIGH (1) oder LOW(0) an spezifischen Port",
|
||||
ARD_FUN_RUN_LOOP: "Endlosschleife()",
|
||||
ARD_FUN_RUN_SETUP: "Setup()",
|
||||
ARD_FUN_RUN_TIP:
|
||||
"Definiert die setup() und loop() Funktionen. Die setup()-Funktion wird beim starten **einmal** ausgeführt. Anschließend wir die loop()-Funktion in einer **Endlosschleife** ausgeführt. Füge in die Setup()-Funktion Blöcke ein, um z.B. das Display zu initalisieren, eine Verbindung zum WiFi-Netzwerk herzustellen oder um die LoRa Verbindung zu initialsieren.",
|
||||
ARD_FUN_RUN_TIP: "Definiert die setup() und loop() Funktionen. Die setup()-Funktion wird beim starten **einmal** ausgeführt. Anschließend wir die loop()-Funktion in einer **Endlosschleife** ausgeführt. Füge in die Setup()-Funktion Blöcke ein, um z.B. das Display zu initalisieren, eine Verbindung zum WiFi-Netzwerk herzustellen oder um die LoRa Verbindung zu initialsieren.",
|
||||
ARD_HIGH: "HIGH",
|
||||
ARD_HIGHLOW_TIP:
|
||||
"Setzt einen Status auf HIGH oder LOWSet a pin state logic High or Low.",
|
||||
ARD_HIGHLOW_TIP: "Setzt einen Status auf HIGH oder LOWSet a pin state logic High or Low.",
|
||||
ARD_LOW: "LOW",
|
||||
ARD_MAP: "Verteile Wert",
|
||||
ARD_MAP_FROMMIN: "von Minimum",
|
||||
@ -33,21 +30,16 @@ export const IO = {
|
||||
ARD_NOTONE_PIN: "keinen Ton an Pin",
|
||||
ARD_NOTONE_PIN_TIP: "Stoppe die Tonerzeugung an Pin",
|
||||
ARD_NOTONE_TIP: "Schaltet den Ton am ausgewählten Pin aus",
|
||||
ARD_PIN_WARN1:
|
||||
"Pin %1 wird benötigt für %2 als Pin %3. Bereitsgenutzt als %4.",
|
||||
ARD_PULSETIMEOUT_TIP:
|
||||
"Misst die Laufzeit eines Impulses am ausgewählten Pin, wenn die Zeit ist in Microsekunden.",
|
||||
ARD_PIN_WARN1: "Pin %1 wird benötigt für %2 als Pin %3. Bereitsgenutzt als %4.",
|
||||
ARD_PULSETIMEOUT_TIP: "Misst die Laufzeit eines Impulses am ausgewählten Pin, wenn die Zeit ist in Microsekunden.",
|
||||
ARD_PULSE_READ: "Misst %1 Impuls an Pin #%2",
|
||||
ARD_PULSE_READ_TIMEOUT:
|
||||
"Misst %1 Impuls an Pin #%2 (Unterbrechung nach %3 μs)",
|
||||
ARD_PULSE_READ_TIMEOUT: "Misst %1 Impuls an Pin #%2 (Unterbrechung nach %3 μs)",
|
||||
ARD_PULSE_TIP: "Misst die Zeit eines Impulses an dem ausgewählten Pin.",
|
||||
ARD_SERIAL_BPS: "bps",
|
||||
ARD_SERIAL_PRINT: "schreibe",
|
||||
ARD_SERIAL_PRINT_NEWLINE: "neue Zeile hinzufügen",
|
||||
ARD_SERIAL_PRINT_TIP:
|
||||
"Prints data to the console/serial port as human-readable ASCII text.", // untranslated
|
||||
ARD_SERIAL_PRINT_WARN:
|
||||
"A setup block for %1 must be added to the workspace to use this block!", // untranslated
|
||||
ARD_SERIAL_PRINT_TIP: "Prints data to the console/serial port as human-readable ASCII text.", // untranslated
|
||||
ARD_SERIAL_PRINT_WARN: "A setup block for %1 must be added to the workspace to use this block!", // untranslated
|
||||
ARD_SERIAL_SETUP: "Setup",
|
||||
ARD_SERIAL_SETUP_TIP: "Selects the speed for a specific Serial peripheral", // untranslated
|
||||
ARD_SERIAL_SPEED: ": Übertragungsgeschwindigkeit zu",
|
||||
@ -70,14 +62,12 @@ export const IO = {
|
||||
ARD_SPI_SETUP_MSBFIRST: "MSBFIRST", // untranslated
|
||||
ARD_SPI_SETUP_SHIFT: "data shift", // untranslated
|
||||
ARD_SPI_SETUP_TIP: "Configures the SPI peripheral.", // untranslated
|
||||
ARD_SPI_TRANSRETURN_TIP:
|
||||
"Send a SPI message to an specified slave device and get data back.", // untranslated
|
||||
ARD_SPI_TRANSRETURN_TIP: "Send a SPI message to an specified slave device and get data back.", // untranslated
|
||||
ARD_SPI_TRANS_NONE: "none", // untranslated
|
||||
ARD_SPI_TRANS_SLAVE: "to slave pin", // untranslated
|
||||
ARD_SPI_TRANS_TIP: "Send a SPI message to an specified slave device.", // untranslated
|
||||
ARD_SPI_TRANS_VAL: "transfer", // untranslated
|
||||
ARD_SPI_TRANS_WARN1:
|
||||
"A setup block for %1 must be added to the workspace to use this block!", // untranslated
|
||||
ARD_SPI_TRANS_WARN1: "A setup block for %1 must be added to the workspace to use this block!", // untranslated
|
||||
ARD_SPI_TRANS_WARN2: "Old pin value %1 is no longer available.", // untranslated
|
||||
ARD_STEPPER_COMPONENT: "stepper", // untranslated
|
||||
ARD_STEPPER_DEFAULT_NAME: "MyStepper", // untranslated
|
||||
@ -90,8 +80,7 @@ export const IO = {
|
||||
ARD_STEPPER_PIN4: "pin4#", // untranslated
|
||||
ARD_STEPPER_REVOLVS: "how many steps per revolution", // untranslated
|
||||
ARD_STEPPER_SETUP: "Setup stepper motor", // untranslated
|
||||
ARD_STEPPER_SETUP_TIP:
|
||||
"Configures a stepper motor pinout and other settings.", // untranslated
|
||||
ARD_STEPPER_SETUP_TIP: "Configures a stepper motor pinout and other settings.", // untranslated
|
||||
ARD_STEPPER_SPEED: "set speed (rpm) to", // untranslated
|
||||
ARD_STEPPER_STEP: "move stepper", // untranslated
|
||||
ARD_STEPPER_STEPS: "steps", // untranslated
|
||||
@ -115,4 +104,5 @@ export const IO = {
|
||||
NEW_INSTANCE_TITLE: "Neue Instanz mit Name:",
|
||||
RENAME_INSTANCE: "Instanz umbenennen...",
|
||||
RENAME_INSTANCE_TITLE: "Benenne alle '%1' Instanzen zu:",
|
||||
};
|
||||
|
||||
}
|
||||
@ -1,56 +1,43 @@
|
||||
export const LOGIC = {
|
||||
|
||||
CONTROLS_IF_ELSEIF_TOOLTIP: "Eine weitere Bedingung hinzufügen.",
|
||||
CONTROLS_IF_ELSE_TOOLTIP:
|
||||
"Eine sonst-Bedingung hinzufügen, führt eine Anweisung aus, falls keine Bedingung zutrifft.",
|
||||
CONTROLS_IF_ELSE_TOOLTIP: "Eine sonst-Bedingung hinzufügen, führt eine Anweisung aus, falls keine Bedingung zutrifft.",
|
||||
CONTROLS_IF_HELPURL: "https://github.com/google/blockly/wiki/IfElse", // untranslated
|
||||
CONTROLS_IF_IF_TOOLTIP: "Hinzufügen, entfernen oder sortieren von Sektionen",
|
||||
CONTROLS_IF_MSG_ELSE: "sonst",
|
||||
CONTROLS_IF_MSG_ELSEIF: "sonst wenn",
|
||||
CONTROLS_IF_MSG_IF: "wenn",
|
||||
CONTROLS_IF_TOOLTIP_1:
|
||||
"Wenn eine Bedingung wahr (true) ist, dann führe eine Anweisung aus.",
|
||||
CONTROLS_IF_TOOLTIP_2:
|
||||
"Wenn eine Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Ansonsten führe die zweite Anweisung aus.",
|
||||
CONTROLS_IF_TOOLTIP_3:
|
||||
"Wenn die erste Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Oder wenn die zweite Bedingung wahr (true) ist, dann führe die zweite Anweisung aus.",
|
||||
CONTROLS_IF_TOOLTIP_4:
|
||||
"Wenn die erste Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Oder wenn die zweite Bedingung wahr (true) ist, dann führe die zweite Anweisung aus. Falls keine der beiden Bedingungen wahr (true) ist, dann führe die dritte Anweisung aus.",
|
||||
CONTROLS_IF_TOOLTIP_1: "Wenn eine Bedingung wahr (true) ist, dann führe eine Anweisung aus.",
|
||||
CONTROLS_IF_TOOLTIP_2: "Wenn eine Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Ansonsten führe die zweite Anweisung aus.",
|
||||
CONTROLS_IF_TOOLTIP_3: "Wenn die erste Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Oder wenn die zweite Bedingung wahr (true) ist, dann führe die zweite Anweisung aus.",
|
||||
CONTROLS_IF_TOOLTIP_4: "Wenn die erste Bedingung wahr (true) ist, dann führe die erste Anweisung aus. Oder wenn die zweite Bedingung wahr (true) ist, dann führe die zweite Anweisung aus. Falls keine der beiden Bedingungen wahr (true) ist, dann führe die dritte Anweisung aus.",
|
||||
LOGIC_BOOLEAN_HELPURL: "https://github.com/google/blockly/wiki/Logic#values", // untranslated
|
||||
LOGIC_BOOLEAN_TOOLTIP: "Ist entweder wahr (true) oder falsch (false)",
|
||||
LOGIC_BOOLEAN_TRUE: "wahr",
|
||||
LOGIC_COMPARE_HELPURL: "https://de.wikipedia.org/wiki/Vergleich_%28Zahlen%29",
|
||||
LOGIC_COMPARE_TOOLTIP_EQ: "Ist wahr (true), wenn beide Werte gleich sind.",
|
||||
LOGIC_COMPARE_TOOLTIP_GT:
|
||||
"Ist wahr (true), wenn der erste Wert größer als der zweite Wert ist.",
|
||||
LOGIC_COMPARE_TOOLTIP_GTE:
|
||||
"Ist wahr (true), wenn der erste Wert größer als oder gleich groß wie der zweite Wert ist.",
|
||||
LOGIC_COMPARE_TOOLTIP_LT:
|
||||
"Ist wahr (true), wenn der erste Wert kleiner als der zweite Wert ist.",
|
||||
LOGIC_COMPARE_TOOLTIP_LTE:
|
||||
"Ist wahr (true), wenn der erste Wert kleiner als oder gleich groß wie der zweite Wert ist.",
|
||||
LOGIC_COMPARE_TOOLTIP_NEQ:
|
||||
"Ist wahr (true), wenn beide Werte unterschiedlich sind.",
|
||||
LOGIC_COMPARE_TOOLTIP_GT: "Ist wahr (true), wenn der erste Wert größer als der zweite Wert ist.",
|
||||
LOGIC_COMPARE_TOOLTIP_GTE: "Ist wahr (true), wenn der erste Wert größer als oder gleich groß wie der zweite Wert ist.",
|
||||
LOGIC_COMPARE_TOOLTIP_LT: "Ist wahr (true), wenn der erste Wert kleiner als der zweite Wert ist.",
|
||||
LOGIC_COMPARE_TOOLTIP_LTE: "Ist wahr (true), wenn der erste Wert kleiner als oder gleich groß wie der zweite Wert ist.",
|
||||
LOGIC_COMPARE_TOOLTIP_NEQ: "Ist wahr (true), wenn beide Werte unterschiedlich sind.",
|
||||
LOGIC_NEGATE_HELPURL: "https://github.com/google/blockly/wiki/Logic#not", // untranslated
|
||||
LOGIC_NEGATE_TITLE: "nicht %1",
|
||||
LOGIC_NEGATE_TOOLTIP:
|
||||
"Ist wahr (true), wenn der Eingabewert falsch (false) ist. Ist falsch (false), wenn der Eingabewert wahr (true) ist.",
|
||||
LOGIC_NEGATE_TOOLTIP: "Ist wahr (true), wenn der Eingabewert falsch (false) ist. Ist falsch (false), wenn der Eingabewert wahr (true) ist.",
|
||||
LOGIC_NULL: "null",
|
||||
LOGIC_NULL_HELPURL: "https://de.wikipedia.org/wiki/Nullwert",
|
||||
LOGIC_NULL_TOOLTIP: "Ist NULL.",
|
||||
LOGIC_OPERATION_AND: "und",
|
||||
LOGIC_OPERATION_HELPURL:
|
||||
"https://github.com/google/blockly/wiki/Logic#logical-operations", // untranslated
|
||||
LOGIC_OPERATION_HELPURL: "https://github.com/google/blockly/wiki/Logic#logical-operations", // untranslated
|
||||
LOGIC_OPERATION_OR: "oder",
|
||||
LOGIC_OPERATION_TOOLTIP_AND:
|
||||
"Ist wahr (true), wenn beide Werte wahr (true) sind.",
|
||||
LOGIC_OPERATION_TOOLTIP_OR:
|
||||
"Ist wahr (true), wenn einer der beiden Werte wahr (true) ist.",
|
||||
LOGIC_OPERATION_TOOLTIP_AND: "Ist wahr (true), wenn beide Werte wahr (true) sind.",
|
||||
LOGIC_OPERATION_TOOLTIP_OR: "Ist wahr (true), wenn einer der beiden Werte wahr (true) ist.",
|
||||
LOGIC_TERNARY_CONDITION: "teste",
|
||||
LOGIC_TERNARY_HELPURL: "https://de.wikipedia.org/wiki/%3F:#Auswahloperator",
|
||||
LOGIC_TERNARY_IF_FALSE: "wenn falsch",
|
||||
LOGIC_TERNARY_IF_TRUE: "wenn wahr",
|
||||
LOGIC_TERNARY_TOOLTIP:
|
||||
'Überprüft eine Bedingung "teste". Wenn die Bedingung wahr ist, wird der "wenn wahr" Wert zurückgegeben, andernfalls der "wenn falsch" Wert',
|
||||
LOGIC_TERNARY_TOOLTIP: "Überprüft eine Bedingung \"teste\". Wenn die Bedingung wahr ist, wird der \"wenn wahr\" Wert zurückgegeben, andernfalls der \"wenn falsch\" Wert",
|
||||
|
||||
|
||||
/**
|
||||
* Cases
|
||||
@ -59,6 +46,5 @@ export const LOGIC = {
|
||||
cases_condition: "Fall (Variable): ",
|
||||
cases_switch: "Variable",
|
||||
cases_add: "Fall",
|
||||
cases_tooltip:
|
||||
"Führt den entsprechenden Fall aus, wenn die Überprüfung der Variable TRUE ergibt. Über das Zahnrad kannst du weitere Fälle hinzufügen. Über den 'Default' fall kannst du bestimmen, was passieren soll wenn keiner der vorher definierten Fälle eingetreten ist.",
|
||||
};
|
||||
cases_tooltip: "Führt den entsprechenden Fall aus, wenn die Überprüfung der Variable TRUE ergibt. Über das Zahnrad kannst du weitere Fälle hinzufügen. Über den 'Default' fall kannst du bestimmen, was passieren soll wenn keiner der vorher definierten Fälle eingetreten ist.",
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
export const BLE = {
|
||||
/**
|
||||
* Phyphox Blöcke
|
||||
*/
|
||||
sensebox_phyphox_init: "Initialisiere Phyphox Gerät mit Namen:",
|
||||
sensebox_phyphox_createExperiment: "Erstelle Experiment",
|
||||
sensebox_phyphox_experimentName: "Name des Experiments",
|
||||
sensebox_phyphox_experimentTitle: "Titel",
|
||||
sensebox_phyphox_experimentCategory: "Kategorie",
|
||||
sensebox_phyphox_experimentDescription: "Beschreibung",
|
||||
sensebox_phyphox_experiment_description: "Kurze Beschreibung des Experiments",
|
||||
sensebox_phyphox_writeValues: "Sende Werte",
|
||||
sensebox_phyphox_createView: "Mit Graphen:",
|
||||
sensebox_phyphox_createGraph: "Erstelle Graph",
|
||||
sensebox_phyphox_graphLabel: "",
|
||||
sensebox_phyphox_unitx: "Einheit x-Achse",
|
||||
sensebox_phyphox_unity: "Einheit y-Achse",
|
||||
sensebox_phyphox_labelx: "Beschriftung x-Achse",
|
||||
sensebox_phyphox_labely: "Beschriftung y-Achse",
|
||||
sensebox_phyphox_channel0: "Wert x-Achse",
|
||||
sensebox_phyphox_channel1: "Wert y-Achse",
|
||||
sensebox_phyphox_style_dots: "Punkte",
|
||||
sensebox_phyphox_style_line: "Linie",
|
||||
sensebox_phyphox_timestamp: "Zeitstempel",
|
||||
sensebox_phyphox_channel: "Kanal",
|
||||
sensebox_phyphox_sendchannel: "sende an Kanal:",
|
||||
sensebox_phyphox_graphStyle: "Stil",
|
||||
|
||||
sensebox_phyphox_init_tooltip:
|
||||
"Initialisere das Bluetooth Bee. Stecke diese auf dem Steckplatz **XBEE1**. Gib dem Phyphox Messgerät einen eindeutigen Namen, damit du dieses in der App wiederfindest",
|
||||
sensebox_phyphox_experiment_tooltip:
|
||||
"Erstelle ein Experiment und vergib einen eindeutigen Namen und eine kurze Beschreibung. Füge bis zu 5 verschiedene Graphen in der Ansicht hinzu. ",
|
||||
sensebox_phyphox_graph_tooltip:
|
||||
"Erstellt einen neuen Graph für das Experiment. Gibt die Einheit und Beschriftung für die Achsen an und wähle den Stil der Visualisuerng der Messwerte. Füge an die Schnittstellen für die Werte der X- und Y-Achse den Kanal an auf dem die Messwerte später gesendet werden. Möchtest du einen Zeitstempel über die Phyphox App erstellen lassen verbinde den Block *Zeitstempel*",
|
||||
sensebox_phyphox_timestamp_tooltip:
|
||||
"Verwende diesen Block, um einen Zeitstempel über die Phyphox App erstellen zu lassen",
|
||||
sensebox_phyphox_sendchannel_tooltip:
|
||||
"Sendet einen Messwert an den ausgewählten Kanal",
|
||||
sensebox_phyphox_experiment_send_tooltip:
|
||||
"Sendet die Messwerte an die Phyphox App",
|
||||
};
|
||||
@ -6,10 +6,8 @@ export const LED = {
|
||||
senseBox_ws2818_rgb_led_init: "RGB LED (WS2818) initialisieren",
|
||||
senseBox_ws2818_rgb_led_position: "Position",
|
||||
senseBox_ws2818_rgb_led_brightness: "Helligkeit",
|
||||
senseBox_ws2818_rgb_led_tooltip:
|
||||
"Verändere mit diesem Block die Farbe deiner RGB-LED. Verbinde einen Block für die Farbe. Wenn mehrere RGB-LEDs miteinander verkettet werden kannst du über die Position bestimmen welche LED angesteuert wird. ",
|
||||
senseBox_ws2818_rgb_led_init_tooltip:
|
||||
"Schließe die RGB-LED an einen der drei **digital/analog Ports** an. Wenn mehrere RGB-LEDs miteinander verkettet werden kannst du über die Position bestimmen welche LED angesteuert wird. ",
|
||||
senseBox_ws2818_rgb_led_tooltip: "Verändere mit diesem Block die Farbe deiner RGB-LED. Verbinde einen Block für die Farbe. Wenn mehrere RGB-LEDs miteinander verkettet werden kannst du über die Position bestimmen welche LED angesteuert wird. ",
|
||||
senseBox_ws2818_rgb_led_init_tooltip: "Schließe die RGB-LED an einen der drei **digital/analog Ports** an. Wenn mehrere RGB-LEDs miteinander verkettet werden kannst du über die Position bestimmen welche LED angesteuert wird. ",
|
||||
senseBox_ws2818_rgb_led_color: "Farbe",
|
||||
senseBox_ws2818_rgb_led_number: "Anzahl",
|
||||
|
||||
@ -22,11 +20,9 @@ export const LED = {
|
||||
COLOUR_BLEND_HELPURL: "http://meyerweb.com/eric/tools/color-blend/",
|
||||
COLOUR_BLEND_RATIO: "im Verhältnis",
|
||||
COLOUR_BLEND_TITLE: "mische",
|
||||
COLOUR_BLEND_TOOLTIP:
|
||||
"Vermische 2 Farben mit konfigurierbaren Farbverhältnis (0.0 - 1.0).",
|
||||
COLOUR_BLEND_TOOLTIP: "Vermische 2 Farben mit konfigurierbaren Farbverhältnis (0.0 - 1.0).",
|
||||
COLOUR_PICKER_HELPURL: "https://de.wikipedia.org/wiki/Farbe",
|
||||
COLOUR_PICKER_TOOLTIP:
|
||||
"Wähle eine Farbe aus der Palette. Die Farbe wird automatisch in RGB-Werte konvertiert.",
|
||||
COLOUR_PICKER_TOOLTIP: "Wähle eine Farbe aus der Palette. Die Farbe wird automatisch in RGB-Werte konvertiert.",
|
||||
COLOUR_RANDOM_HELPURL: "http://randomcolour.com", // untranslated
|
||||
COLOUR_RANDOM_TITLE: "zufällige Farbe",
|
||||
COLOUR_RANDOM_TOOLTIP: "Erstelle eine Farbe nach dem Zufallsprinzip.",
|
||||
@ -35,6 +31,6 @@ export const LED = {
|
||||
COLOUR_RGB_HELPURL: "https://de.wikipedia.org/wiki/RGB-Farbraum",
|
||||
COLOUR_RGB_RED: "rot",
|
||||
COLOUR_RGB_TITLE: "Farbe mit",
|
||||
COLOUR_RGB_TOOLTIP:
|
||||
"Erstelle eine Farbe mit selbst definierten Rot-, Grün- und Blauwerten. Alle Werte müssen zwischen 0 und 255 liegen. 0 ist hierbei die geringte Intensität der Farbe 255 die höchste.",
|
||||
};
|
||||
COLOUR_RGB_TOOLTIP: "Erstelle eine Farbe mit selbst definierten Rot-, Grün- und Blauwerten. Alle Werte müssen zwischen 0 und 255 liegen. 0 ist hierbei die geringte Intensität der Farbe 255 die höchste.",
|
||||
|
||||
}
|
||||
@ -28,32 +28,17 @@ export const LORA = {
|
||||
senseBox_LoRa_cayenne_lat: "Breitengrad",
|
||||
senseBox_LoRa_cayenne_lng: "Längengrad",
|
||||
senseBox_LoRa_cayenne_alt: "Höhe",
|
||||
senseBox_LoRa_cayenne_concentration: "Konzentration",
|
||||
|
||||
senseBox_LoRa_cayenne_tip: "Sende Daten als Cayenne Payload Format",
|
||||
senseBox_LoRa_cayenne_gps_tip: "Sende GPS",
|
||||
senseBox_LoRa_cayenne_temperature_tip:
|
||||
"Sendet Temperaturwert mit einer Nachkommastelle",
|
||||
senseBox_LoRa_cayenne_pressure_tip:
|
||||
"Sendet Luftdruck mit einer Nachkommastelle",
|
||||
senseBox_LoRa_cayenne_temperature_tip: "Sendet Temperaturwert mit einer Nachkommastelle",
|
||||
senseBox_LoRa_cayenne_pressure_tip: "Sendet Luftdruck mit einer Nachkommastelle",
|
||||
senseBox_LoRa_cayenne_luminosity_tip: "Sendet Helligkeitswert",
|
||||
senseBox_LoRa_cayenne_analog_tip:
|
||||
"Sendet einen Dezimalwert mit einer Nachkommastelle",
|
||||
|
||||
senseBox_LoRa_cayenne_concentration_tip: "Sendet eine Konzentration in PPM",
|
||||
senseBox_LoRa_cayenne_analog_tip: "Sendet einen Dezimalwert mit einer Nachkommastelle",
|
||||
|
||||
senseBox_LoRa_message_tooltip: "Sende eine Nachricht über LoRa",
|
||||
senseBox_LoRa_sensor_tip:
|
||||
"Sende einen Sensorwert mit einer bestimmten Anzahl an Bytes",
|
||||
senseBox_LoRa_init_abp_tooltip:
|
||||
"Initialisiere die LoRa übertragung. Die Aktivierung erfolgt über ABP. Registriere eine Application auf [thethingsnetwork](https://thethingsnetwork.com) und kopiere den **Network Session Key** und den **App Session Key** im **msb Format** und die **Device ID** im **hex Format**.",
|
||||
senseBox_LoRa_init_helpurl:
|
||||
"https://docs.sensebox.de/blockly/blockly-web-lora/",
|
||||
senseBox_LoRa_init_otaa_tooltip:
|
||||
"Initialisiere die LoRa übertragung. Die Aktivierung erfolgt über OTAA. Registriere eine Application auf [thethingsnetwork](https://thethingsnetwork.com) und kopiere die **DEVICE EUI** und die **Application EUI** im **lsb Format** den **App Key** im **msb Format**.",
|
||||
|
||||
sensebox_lora_ttn_mapper_tip:
|
||||
"Mit einem TTN Mapper kannst du die LoRa-Netzabdeckung in deiner Umgebung aufzeichnen. Die Daten werden dann auf [ttnmaper](https://ttnmapper.org) angezeigt. Den notwendigen Decoder findest du [hier](https://gist.github.com/felixerdy/f959ac03df98c6947f1c7f35d537f23e#file-decoder-js).",
|
||||
sensebox_lora_ttn_mapper_helpurl:
|
||||
"https://sensebox.de/projects/de/2020-03-06-ttn-mapper",
|
||||
};
|
||||
senseBox_LoRa_sensor_tip: "Sende einen Sensorwert mit einer bestimmten Anzahl an Bytes",
|
||||
senseBox_LoRa_init_abp_tooltip: "Initialisiere die LoRa übertragung. Die Aktivierung erfolgt über ABP. Registriere eine Application auf [thethingsnetwork](https://thethingsnetwork.com) und kopiere den **Network Session Key** und den **App Session Key** im **msb Format** und die **Device ID** im **hex Format**.",
|
||||
senseBox_LoRa_init_helpurl: "https://docs.sensebox.de/blockly/blockly-web-lora/",
|
||||
senseBox_LoRa_init_otaa_tooltip: "Initialisiere die LoRa übertragung. Die Aktivierung erfolgt über OTAA. Registriere eine Application auf [thethingsnetwork](https://thethingsnetwork.com) und kopiere die **DEVICE EUI** und die **Application EUI** im **lsb Format** den **App Key** im **msb Format**.",
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
export const MOTORS = {
|
||||
|
||||
/**
|
||||
* Motors
|
||||
*/
|
||||
|
||||
sensebox_motors_beginServoMotor: "Initialisiere Servomotor",
|
||||
sensebox_motors_beginServoMotor_pin: "Pin:",
|
||||
sensebox_motors_beginServoMotor_tooltip: "Verbinde einen digitalen Pin mit dem orangen Kabel des Servomotrors. Verbinde zusätzlich GND mit GND (schwarzes und braunes Kabel) und 5V mit 5V (rotes Kabel).",
|
||||
sensebox_motors_beginServoMotor_helpurl: "https://de.wikipedia.org/wiki/Servomotor",
|
||||
|
||||
sensebox_motors_moveServoMotor: "Bewege Servomotor",
|
||||
sensebox_motors_moveServoMotor_pin: "Pin:",
|
||||
sensebox_motors_moveServoMotor_degrees: "Winkel in Grad:",
|
||||
sensebox_motors_moveServoMotor_tooltip: "Der Servomotor kann zwischen 0 und 180 Grad bewegt werden.",
|
||||
sensebox_motors_moveServoMotor_helpurl: "https://de.wikipedia.org/wiki/Servomotor",
|
||||
|
||||
sensebox_motors_I2CMotorBoard_begin: "Initialize I2C Motor Board",
|
||||
sensebox_motors_I2CMotorBoard_begin_tooltip: "Connect the I2C Moztor Board with the two DC Motors to one of the five I2C-Ports. Use this Block inside the setup()-function.",
|
||||
sensebox_motors_I2CMotorBoard_begin_helpurl: "TODO",
|
||||
|
||||
sensebox_motors_I2CMotorBoard_moveDCMotor: "Move",
|
||||
sensebox_motors_I2CMotorBoard_moveDCMotor_left: "left",
|
||||
sensebox_motors_I2CMotorBoard_moveDCMotor_right: "right",
|
||||
sensebox_motors_I2CMotorBoard_moveDCMotor_motor: "DC Motor at I2C Motor Board",
|
||||
sensebox_motors_I2CMotorBoard_moveDCMotor_speed: "Speed:",
|
||||
sensebox_motors_I2CMotorBoard_moveDCMotor_tooltip: "You can set the Speed between -100 and 100.",
|
||||
sensebox_motors_I2CMotorBoard_moveDCMotor_helpurl: "TODO",
|
||||
|
||||
sensebox_motors_I2CMotorBoard_stopDCMotor: "Stop ",
|
||||
sensebox_motors_I2CMotorBoard_stopDCMotor_left: "left",
|
||||
sensebox_motors_I2CMotorBoard_stopDCMotor_right: "right",
|
||||
sensebox_motors_I2CMotorBoard_stopDCMotor_motor: "DC Motor at I2C Motor Board",
|
||||
sensebox_motors_I2CMotorBoard_stopDCMotor_tooltip: "TODO",
|
||||
sensebox_motors_I2CMotorBoard_stopDCMotor_helpurl: "TODO",
|
||||
|
||||
sensebox_motors_beginStepperMotor: "Initialize Stepper Motor (28BYJ-48)",
|
||||
sensebox_motors_beginStepperMotor_rpm: "Rotations per Minute:",
|
||||
sensebox_motors_beginStepperMotor_pins: "Input Pins (IN1-IN4):",
|
||||
sensebox_motors_beginStepperMotor_tooltip: "Connect four of the the digital pins in the right order to the inputs IN1-IN4 on the stepper motor board. Connect a GND pin (black wire) to the minus pin and a 5V pin (red wire) to the plus pin on the board. Also connect the stepper motor to this Board. Use this Block inside the setup()-function.",
|
||||
sensebox_motors_beginStepperMotor_helpurl: "TODO",
|
||||
|
||||
sensebox_motors_moveStepperMotor: "Move Stepper Motor (28BYJ-48)",
|
||||
sensebox_motors_moveStepperMotor_step: "Steps:",
|
||||
sensebox_motors_moveStepperMotor_tooltip: "Move stepper motor. 2048 steps equal a full rotation.",
|
||||
sensebox_motors_moveStepperMotor_helpurl: "TODO",
|
||||
};
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
export const NTP = {
|
||||
sensebox_ntp_init: "Initialisiere NTP",
|
||||
sensebox_ntp_init_tooltip: "Initialisiere den NTP Server.",
|
||||
sensebox_ntp_get: "Hole Zeit von NTP Server: ",
|
||||
sensebox_ntp_get_timestamp_tooltip:
|
||||
"Gibt dir einen in ISO 8601 formatierten Zeitstempel zurück. Bsp: 2021-12-24T18:21Z",
|
||||
sensebox_ntp_get_tooltip:
|
||||
"Gibt dir den ausgewählten Wert zurück. Unix Zeit entspricht der Anzahl der Sekunden seit dem 1.1.1970",
|
||||
sensebox_ntp_epochTime: "Unix Zeit",
|
||||
sensebox_ntp_formattedTimeStamp: "Zeitstempel (hh:mm:ss)",
|
||||
};
|
||||
@ -2,11 +2,8 @@ export const OSEM = {
|
||||
/**
|
||||
* openSenseMap
|
||||
*/
|
||||
senseBox_osem_connection_tip:
|
||||
"Verwende diesen Block, um deine senseBox mit der openSenseMap zu verbinden. Registriere deine senseBox auf der openSenseMap und trage die IDs und den API-Schlüssel ein. Verwende anschließend den Block ***Sende Messwert an die openSenseMap*** und die Sensor-ID, um die Messwerte zu übertragen.",
|
||||
senseBox_osem_connection_helpurl: "https://www.opensensemap.org/",
|
||||
senseBox_send_to_osem_tip:
|
||||
"Sende mit diesem Block Messwerte an die openSenseMap. Verwende pro Messwert einen Block und trage die zugewiesene Sensor ID ein",
|
||||
senseBox_osem_connection_tip: "stellt eine WLAN verbindung her",
|
||||
senseBox_send_to_osem_tip: "sende Messwert an",
|
||||
senseBox_send_to_osem: "Sende Messwert an die openSenseMap",
|
||||
senseBox_osem_connection: "Verbinde mit openSenseMap:",
|
||||
senseBox_osem_host: "opensensemap.org",
|
||||
@ -15,9 +12,6 @@ export const OSEM = {
|
||||
senseBox_osem_stationary: "Stationär",
|
||||
senseBox_osem_mobile: "Mobil",
|
||||
senseBox_osem_access_token: "API Schlüssel",
|
||||
senseBox_send_mobile_to_osem:
|
||||
"Sende Messwert und Standort an die openSenseMap",
|
||||
senseBox_send_mobile_to_osem_tip:
|
||||
"Sende Messwert und Standort an die openSenseMap",
|
||||
senseBox_osem_restart: "Bei Verbindungsverlust Gerät neustarten?",
|
||||
};
|
||||
senseBox_send_mobile_to_osem: "Sende Messwert und Standort an die openSenseMap",
|
||||
senseBox_send_mobile_to_osem_tip: "Sende Messwert und Standort an die openSenseMap",
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
export const RTC = {
|
||||
sensebox_rtc_init: "Initialisiere externe RTC",
|
||||
sensebox_rtc_init_tooltip:
|
||||
"Initialisiere die RTC. Schließe diese an einen der 5 I2C/Wire Anschlüsse an und lege die Batterie ein. Bevor du die Uhrzeit auslesen kannst muss diese zunächst einmal gesetzt werden. Dieser Schritt muss normalerweise nur einmalig durchgeführt werden.",
|
||||
sensebox_rtc_set: "Setze Uhrzeit/Datum der externen RTC",
|
||||
sensebox_rtc_set_tooltip:
|
||||
"Stellt die Uhrzeit der RTC ein. Beachte, dass du diesen Block im Setup ausführst.",
|
||||
sensebox_rtc_get_timestamp: "Zeitstempel externe RTC (RFC 3339)",
|
||||
sensebox_rtc_get_timestamp_tooltip:
|
||||
"Gibt dir einen in ISO 8601 formatierten Zeitstempel zurück. Bsp: 2021-12-24T18:21Z",
|
||||
sensebox_rtc_get: "Wert (externe RTC): ",
|
||||
sensebox_rtc_get_tooltip: "Gibt dir den ausgewählten Wert zurück.",
|
||||
sensebox_rtc_second: "Sekunden",
|
||||
sensebox_rtc_minutes: "Minuten",
|
||||
sensebox_rtc_hour: "Stunden",
|
||||
sensebox_rtc_day: "Tag",
|
||||
sensebox_rtc_month: "Monat",
|
||||
sensebox_rtc_year: "Jahr",
|
||||
sensebox_internal_rtc_init: "Initialisiere interne RTC",
|
||||
sensebox_internal_rtc_init_tooltip:
|
||||
"Initialisieren der internen RTC. Diese RTC ist nicht batteriegepuffert und wird bei jedem Einschaltvorgang zurückgesetzt",
|
||||
sensebox_internal_rtc_set: "Setze interne RTC Zeit/Datum (Unix Time)",
|
||||
sensebox_internal_rtc_set_tooltip:
|
||||
"Setzt die Zeit der internen RTC. Führe den Block einmalig im Setup aus und setzte die Uhrzeit über die Unix Zeit.",
|
||||
sensebox_internal_rtc_get: "Wert (interne RTC): ",
|
||||
sensebox_internal_rtc_get_timestamp: "Zeitstempel interne RTC (RFC 3339)",
|
||||
sensebox_internal_rtc_get_timestamp_tooltip:
|
||||
"Returns a timestamp formatted in ISO 8601. Ex: 2021-12-24T18:21Z",
|
||||
sensebox_internal_rtc_get_tooltip: "Gibt den ausgewählten Wert zurück",
|
||||
sensebox_internal_rtc_epoch: "Unix Zeit",
|
||||
sensebox_internal_rtc_year: "Jahr",
|
||||
sensebox_internal_rtc_month: "Monat",
|
||||
sensebox_internal_rtc_day: "Tag",
|
||||
sensebox_internal_rtc_hour: "Stunde",
|
||||
sensebox_internal_rtc_minutes: "Minute",
|
||||
sensebox_internal_rtc_seconds: "Sekunde",
|
||||
};
|
||||
@ -3,9 +3,8 @@ export const SD = {
|
||||
* SD-Block
|
||||
*/
|
||||
senseBox_sd_create_file: "Erstelle Datei auf SD-Karte",
|
||||
sensebox_sd_helpurl: "https://docs.sensebox.de/hardware/bee-sd/",
|
||||
senseBox_sd_write_file: "Schreibe Daten auf SD-Karte",
|
||||
senseBox_sd_open_file: "Öffne eine Datei auf der SD-Karte",
|
||||
senseBox_sd_open_file: "Öffne Datei auf der SD-Karte",
|
||||
senseBox_sd_create_file_tooltip:
|
||||
"Erstellt eine Datei auf der Karte. Stecke das SD-Bee auf den Steckplatz **XBEE2**. Die **maximale** Länge des Dateinamen sind **8 Zeichen**. Die Datei sollte zuerst im *Setup()* erstellt werden",
|
||||
senseBox_sd_write_file_tooptip:
|
||||
@ -14,12 +13,4 @@ export const SD = {
|
||||
"Öffne die Datei auf der SD-Karte, um Dateien zu speichern. Am Ende der Schleife wird die Datei automatisch wieder geschlossen.",
|
||||
sensebox_sd_filename: "Daten",
|
||||
senseBox_sd_decimals: "Dezimalen",
|
||||
sensebox_sd_osem: "Erstelle CSV-Datei für openSenseMap",
|
||||
sensebox_sd_osem_tip:
|
||||
"Erstellt eine CSV-Datei, die später auf die openSenseMap hochgeladen werden kann. ",
|
||||
sensebox_sd_save_for_osem: "Speichere Messwert",
|
||||
sensebox_sd_save_for_osem_tip:
|
||||
"Füge eine Messung mit Sensor ID zur CSV-Datei hinzu",
|
||||
sensebox_sd_save_for_osem_id: "Sensor ID:",
|
||||
sensebox_sd_measurement: "Messwerte",
|
||||
};
|
||||
|
||||