Compare commits
2 Commits
master
...
block/add-
Author | SHA1 | Date | |
---|---|---|---|
|
0f0bd2aea4 | ||
|
e685724a1f |
3
.env
3
.env
@ -1,4 +1,5 @@
|
|||||||
REACT_APP_COMPILER_URL=https://compiler.sensebox.de
|
#REACT_APP_COMPILER_URL=https://compiler.sensebox.de
|
||||||
|
REACT_APP_COMPILER_URL=http://localhost:3000
|
||||||
REACT_APP_BOARD=sensebox-mcu
|
REACT_APP_BOARD=sensebox-mcu
|
||||||
REACT_APP_BLOCKLY_API=https://api.blockly.sensebox.de
|
REACT_APP_BLOCKLY_API=https://api.blockly.sensebox.de
|
||||||
|
|
||||||
|
@ -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 }}
|
|
12
Dockerfile
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;'"]
|
|
@ -1,11 +0,0 @@
|
|||||||
# docker-compose.yml
|
|
||||||
services:
|
|
||||||
smarti:
|
|
||||||
mem_limit: 2048m
|
|
||||||
mem_reservation: 128M
|
|
||||||
cpus: 2
|
|
||||||
build:
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
ports:
|
|
||||||
- "80"
|
|
||||||
|
|
@ -70,8 +70,5 @@
|
|||||||
">0.2%",
|
">0.2%",
|
||||||
"not dead",
|
"not dead",
|
||||||
"not op_mini all"
|
"not op_mini all"
|
||||||
],
|
]
|
||||||
"devDependencies": {
|
|
||||||
"@babel/plugin-proposal-private-property-in-object": "7.21.11"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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('');
|
|
||||||
}
|
|
||||||
};
|
|
@ -26,6 +26,5 @@ import "./variables";
|
|||||||
import "./lists";
|
import "./lists";
|
||||||
import "./watchdog";
|
import "./watchdog";
|
||||||
import "./webserver";
|
import "./webserver";
|
||||||
import "./CleVerLab"
|
|
||||||
|
|
||||||
import "../helpers/types";
|
import "../helpers/types";
|
||||||
|
@ -583,3 +583,46 @@ Blockly.Blocks["sensebox_sensor_dps310"] = {
|
|||||||
this.setHelpUrl(Blockly.Msg.senseBox_sps30_helpurl);
|
this.setHelpUrl(Blockly.Msg.senseBox_sps30_helpurl);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GPS Module BN880
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
Blockly.Blocks["sensebox_gps_bn880"] = {
|
||||||
|
init: function () {
|
||||||
|
var dropdownOptions = [
|
||||||
|
[Blockly.Msg.senseBox_gps_lat, "latitude"],
|
||||||
|
[Blockly.Msg.senseBox_gps_lng, "longitude"],
|
||||||
|
[Blockly.Msg.senseBox_gps_alt, "altitude"],
|
||||||
|
[Blockly.Msg.senseBox_gps_timeStamp, "timestamp"],
|
||||||
|
];
|
||||||
|
this.appendDummyInput().appendField("GPS Modul BN-880");
|
||||||
|
this.appendDummyInput()
|
||||||
|
.setAlign(Blockly.ALIGN_RIGHT)
|
||||||
|
.appendField(Blockly.Msg.senseBox_value)
|
||||||
|
.appendField(new Blockly.FieldDropdown(dropdownOptions), "dropdown");
|
||||||
|
this.appendDummyInput()
|
||||||
|
.setAlign(Blockly.ALIGN_RIGHT)
|
||||||
|
.appendField("Serial Port:")
|
||||||
|
.appendField(
|
||||||
|
new Blockly.FieldDropdown(
|
||||||
|
selectedBoard().serialSensors),
|
||||||
|
"serial"
|
||||||
|
);
|
||||||
|
|
||||||
|
this.setOutput(true);
|
||||||
|
this.setColour(getColour().sensebox);
|
||||||
|
this.setTooltip(Blockly.Msg.senseBox_gps_tooltip);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
Blockly.Blocks["sensebox_gps_isValid"] = {
|
||||||
|
init: function () {
|
||||||
|
this.appendDummyInput().appendField("GPS Modul is valid");
|
||||||
|
this.setOutput(true, Types.BOOLEAN.typeName);
|
||||||
|
this.setColour(getColour().sensebox);
|
||||||
|
this.setTooltip(Blockly.Msg.senseBox_gps_tooltip);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
@ -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];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -27,4 +27,3 @@ import "./variables";
|
|||||||
import "./lists";
|
import "./lists";
|
||||||
import "./watchdog";
|
import "./watchdog";
|
||||||
import "./webserver";
|
import "./webserver";
|
||||||
import "./CleVerLab"
|
|
@ -753,3 +753,58 @@ if (time_startsps > time_actualsps + intervalsps) {
|
|||||||
var code = `m.mc_${dropdown_name}`;
|
var code = `m.mc_${dropdown_name}`;
|
||||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GPS Module
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
Blockly.Arduino.sensebox_gps_bn880 = function () {
|
||||||
|
var dropdown = this.getFieldValue("dropdown");
|
||||||
|
var serial = this.getFieldValue("serial");
|
||||||
|
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||||
|
Blockly.Arduino.libraries_["tinygps_library"] =
|
||||||
|
"#include <TinyGPSPlus.h> // http://librarymanager/All#SparkFun_u-blox_GNSS_Arduino_Library";
|
||||||
|
Blockly.Arduino.definitions_["TinyGPS"] = "TinyGPSPlus gps;";
|
||||||
|
Blockly.Arduino.setupCode_["init_tinygps"] = `
|
||||||
|
${serial}.begin(9600); // BN880
|
||||||
|
while (gps.location.lat() == 0.0 && gps.location.lng() == 0.0);
|
||||||
|
`
|
||||||
|
var code = "";
|
||||||
|
switch (dropdown) {
|
||||||
|
case "latitude":
|
||||||
|
code = "gps.location.lat()";
|
||||||
|
break;
|
||||||
|
case "longitude":
|
||||||
|
code = "gps.location.lng()";
|
||||||
|
break;
|
||||||
|
case "altitude":
|
||||||
|
code = "gps.altitude.meters()";
|
||||||
|
break;
|
||||||
|
case "timestamp":
|
||||||
|
Blockly.Arduino.variables_["define_tsBuffer"] = `char tsBuffer[21];`
|
||||||
|
Blockly.Arduino.codeFunctions_["getTimeStamp()"] = `
|
||||||
|
char *getTimeStamp()
|
||||||
|
{
|
||||||
|
memset(tsBuffer, 0, sizeof(tsBuffer));
|
||||||
|
if ((gps.date.isValid() == true) && (gps.time.isValid() == true))
|
||||||
|
{
|
||||||
|
sprintf(tsBuffer, "%04d-%02d-%02dT%02d:%02d:%02dZ",
|
||||||
|
gps.date.year(), gps.date.month(), gps.date.day(), gps.time.hour(), gps.time.minute(), gps.time.second());
|
||||||
|
}
|
||||||
|
return tsBuffer;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
code = "getTimeStamp()";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
code = "";
|
||||||
|
}
|
||||||
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
|
};
|
||||||
|
|
||||||
|
Blockly.Arduino.sensebox_gps_isValid = function () {
|
||||||
|
var code ="gps.location.isValid()";
|
||||||
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
|
};
|
||||||
|
@ -15,7 +15,6 @@ const colours = {
|
|||||||
webserver: 40,
|
webserver: 40,
|
||||||
phyphox: 25,
|
phyphox: 25,
|
||||||
motors: 190,
|
motors: 190,
|
||||||
cleverlab: 185 ,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getColour = () => {
|
export const getColour = () => {
|
||||||
|
@ -104,4 +104,4 @@ export const getCompatibleTypes = (type) => {
|
|||||||
return compatibleTypes[type];
|
return compatibleTypes[type];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const VARIABLE_TYPES = [['SHORT_NUMBER', 'char'], ['NUMBER', 'int'], ['DECIMAL', 'long'], ['TEXT', 'String'], ['CHARACTER', 'char'], ['BOOLEAN', 'boolean'], ['NULL', 'void'], ['UNDEF', 'undefined']];
|
export const VARIABLE_TYPES = [['NUMBER', 'int'], ['DECIMAL', 'long'], ['TEXT', 'String'], ['CHARACTER', 'char'], ['BOOLEAN', 'boolean'], ['NULL', 'void'], ['UNDEF', 'undefined']];
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
export const CLEVERLAB = {
|
|
||||||
|
|
||||||
}
|
|
@ -633,11 +633,6 @@ class Toolbox extends React.Component {
|
|||||||
colour={getColour().procedures}
|
colour={getColour().procedures}
|
||||||
custom="PROCEDURE"
|
custom="PROCEDURE"
|
||||||
></Category>
|
></Category>
|
||||||
<Category name="CleVerLab" colour={getColour().cleverlab}>
|
|
||||||
<Block type="CleVerLab_pH" />
|
|
||||||
<Block type="CleVerLab_pump" />
|
|
||||||
<Block type="CleVerLab_cali1" />
|
|
||||||
</Category>
|
|
||||||
<Category name={Blockly.Msg.toolbox_advanced} colour={getColour().io}>
|
<Category name={Blockly.Msg.toolbox_advanced} colour={getColour().io}>
|
||||||
<Category
|
<Category
|
||||||
name={Blockly.Msg.toolbox_serial}
|
name={Blockly.Msg.toolbox_serial}
|
||||||
@ -645,6 +640,8 @@ class Toolbox extends React.Component {
|
|||||||
>
|
>
|
||||||
<Block type="init_serial_monitor"></Block>
|
<Block type="init_serial_monitor"></Block>
|
||||||
<Block type="print_serial_monitor"></Block>
|
<Block type="print_serial_monitor"></Block>
|
||||||
|
<Block type="sensebox_gps_bn880" />
|
||||||
|
<Block type="sensebox_gps_isValid" />
|
||||||
</Category>
|
</Category>
|
||||||
<Category name={Blockly.Msg.toolbox_io} colour={getColour().io}>
|
<Category name={Blockly.Msg.toolbox_io} colour={getColour().io}>
|
||||||
<Block type="io_digitalwrite"></Block>
|
<Block type="io_digitalwrite"></Block>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user