update loops tutorial
This commit is contained in:
parent
c99ca92a4e
commit
40d8301990
@ -1,53 +1,80 @@
|
||||
|
||||
import Blockly from 'blockly';
|
||||
import { getColour } from '../helpers/colour';
|
||||
import { getCompatibleTypes } from '../helpers/types'
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'controls_for',
|
||||
message0: 'count with %1 from %2 to %3 by adding %4',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_variable',
|
||||
name: 'VAR',
|
||||
variable: null,
|
||||
variableTypes: ['Number'],
|
||||
defaultType: 'Number',
|
||||
createNewVariable: true,
|
||||
showOnlyVariableAssigned: false,
|
||||
},
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'FROM',
|
||||
check: 'Number',
|
||||
align: 'RIGHT',
|
||||
},
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'TO',
|
||||
check: 'Number',
|
||||
align: 'RIGHT',
|
||||
},
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'BY',
|
||||
check: 'Number',
|
||||
align: 'RIGHT',
|
||||
},
|
||||
],
|
||||
message1: '%{BKY_CONTROLS_REPEAT_INPUT_DO} %1',
|
||||
args1: [
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'DO',
|
||||
},
|
||||
],
|
||||
inputsInline: false,
|
||||
previousStatement: null,
|
||||
nextStatement: null,
|
||||
colour: getColour().loops,
|
||||
helpUrl: '%{BKY_CONTROLS_FOR_HELPURL}',
|
||||
extensions: ['contextMenu_newGetVariableBlock', 'controls_for_tooltip'],
|
||||
},
|
||||
]);
|
||||
// Blockly.defineBlocksWithJsonArray([
|
||||
// {
|
||||
// type: 'controls_for',
|
||||
// message0: 'count with %1 from %2 to %3 by adding %4',
|
||||
// args0: [
|
||||
// {
|
||||
// type: 'field_variable',
|
||||
// name: 'VAR',
|
||||
// variable: null,
|
||||
// variableTypes: ['Number'],
|
||||
// defaultType: 'Number',
|
||||
// createNewVariable: true,
|
||||
// showOnlyVariableAssigned: false,
|
||||
// },
|
||||
// {
|
||||
// type: 'input_value',
|
||||
// name: 'FROM',
|
||||
// check: 'Number',
|
||||
// align: 'RIGHT',
|
||||
// },
|
||||
// {
|
||||
// type: 'input_value',
|
||||
// name: 'TO',
|
||||
// check: 'Number',
|
||||
// align: 'RIGHT',
|
||||
// },
|
||||
// {
|
||||
// type: 'input_value',
|
||||
// name: 'BY',
|
||||
// check: 'Number',
|
||||
// align: 'RIGHT',
|
||||
// },
|
||||
// ],
|
||||
// message1: '%{BKY_CONTROLS_REPEAT_INPUT_DO} %1',
|
||||
// args1: [
|
||||
// {
|
||||
// type: 'input_statement',
|
||||
// name: 'DO',
|
||||
// },
|
||||
// ],
|
||||
// inputsInline: false,
|
||||
// previousStatement: null,
|
||||
// nextStatement: null,
|
||||
// colour: getColour().loops,
|
||||
// helpUrl: '%{BKY_CONTROLS_FOR_HELPURL}',
|
||||
// extensions: ['contextMenu_newGetVariableBlock', 'controls_for_tooltip'],
|
||||
// },
|
||||
// ]);
|
||||
|
||||
Blockly.Blocks['controls_repeat_ext'] = {
|
||||
/**
|
||||
* Block for repeat n times (external number).
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.CONTROLS_REPEAT_TITLE,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "TIMES",
|
||||
"check": getCompatibleTypes(Number),
|
||||
}
|
||||
],
|
||||
"previousStatement": null,
|
||||
"nextStatement": null,
|
||||
"colour": getColour().loops,
|
||||
"tooltip": Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,
|
||||
"helpUrl": Blockly.Msg.CONTROLS_REPEAT_HELPURL
|
||||
});
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,13 @@
|
||||
"type": "instruction",
|
||||
"headline": "Erste Schritte",
|
||||
"text": "In diesem Tutorial lernst du die ersten Schritte mit der senseBox kennen. Du erstellst ein erstes Programm, baust einen ersten Schaltkreis auf und lernst, wie du das Programm auf die senseBox MCU überträgst.",
|
||||
"hardware":["senseboxmcu","led","breadboard","jst-adapter","resistor-470ohm"],
|
||||
"hardware": [
|
||||
"senseboxmcu",
|
||||
"led",
|
||||
"breadboard",
|
||||
"jst-adapter",
|
||||
"resistor-470ohm"
|
||||
],
|
||||
"requirements": []
|
||||
},
|
||||
{
|
||||
@ -42,6 +48,42 @@
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Schleifen",
|
||||
"steps": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "instruction",
|
||||
"headline": "Schleifen",
|
||||
"text": "In diesem Tutorial wird die Verwendung von Schleifen eingeführt. Eine Schleife (auch „Wiederholung“ oder englisch loop) ist eine Kontrollstruktur in Programmiersprachen. Sie wiederholt einen Anweisungs-Block – den sogenannten Schleifenrumpf oder Schleifenkörper –, solange die Schleifenbedingung als Laufbedingung gültig bleibt bzw. als Abbruchbedingung nicht eintritt. Schleifen, deren Schleifenbedingung immer zur Fortsetzung führt oder die keine Schleifenbedingung haben, sind Endlosschleifen. Die Endlosschleife hast du bereits im ersten Tutorial \"Erste Schritte\" kennengelernt",
|
||||
"hardware": [
|
||||
"breadboard",
|
||||
"jst-adapter",
|
||||
"senseboxmcu",
|
||||
"led",
|
||||
"resistor-470ohm"
|
||||
],
|
||||
"requirements": [
|
||||
1
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": "instruction",
|
||||
"headline": "Verwendung von Schleifen",
|
||||
"text": "Die Blöcke findest du in der Kategorie \"Schleifen\". Die einfachste Schleife, die du Verwenden kannst, ist der Block \"Wiederhole 10 mal\". Bei diesem Block kannst du die Blöcke, die eine bestimmte Zahl wiederholt werden soll einfach in den offenen Block abschnitt ziehen. ",
|
||||
"xml": "<xml xmlns=\"https://developers.google.com/blockly/xml\">\n <block type=\"controls_repeat_ext\" id=\"!|`dyF$`~*!l~D[TUc4N\" x=\"38\" y=\"32\">\n <value name=\"TIMES\">\n <block type=\"math_number\" id=\"ktgQ[7pD~M{sq;r^kLuz\">\n <field name=\"NUM\">10</field>\n </block>\n </value>\n </block>\n</xml>"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "task",
|
||||
"headline": "Verwendung von Schleifen",
|
||||
"text": "Lass die LED genau 5 mal in einem Abstand von 1000 Millisekunden blinken. Anschließend soll die LED ausgeschaltet werden. ",
|
||||
"xml": "<xml xmlns=\"https://developers.google.com/blockly/xml\">\n <block type=\"arduino_functions\" id=\"QWW|$jB8+*EL;}|#uA\" deletable=\"false\" x=\"18\" y=\"18\">\n <statement name=\"SETUP_FUNC\">\n <block type=\"controls_repeat_ext\" id=\"_d{J^FWUT8M?}o[/6Fpj\">\n <value name=\"TIMES\">\n <block type=\"math_number\" id=\"qao_;lzo~kE?25HM*kJ+\">\n <field name=\"NUM\">5</field>\n </block>\n </value>\n <statement name=\"DO\">\n <block type=\"sensebox_led\" id=\"A)}4:wR_79zAHUBq5?1j\">\n <field name=\"PIN\">1</field>\n <field name=\"STAT\">HIGH</field>\n <next>\n <block type=\"time_delay\" id=\"Yfn;,|wxaRhium=T[-wM\">\n <value name=\"DELAY_TIME_MILI\">\n <block type=\"math_number\" id=\"z=1f4hMm_Q~e-+Wvh,S|\">\n <field name=\"NUM\">1000</field>\n </block>\n </value>\n <next>\n <block type=\"sensebox_led\" id=\"nu2%x%_iigf]r$FJ7XEw\">\n <field name=\"PIN\">1</field>\n <field name=\"STAT\">LOW</field>\n <next>\n <block type=\"time_delay\" id=\"4@Y4E|ewWB)([vf/4Ttn\">\n <value name=\"DELAY_TIME_MILI\">\n <block type=\"math_number\" id=\"l,ZAG8;|Uv^:P5/FOjwD\">\n <field name=\"NUM\">1000</field>\n </block>\n </value>\n </block>\n </next>\n </block>\n </next>\n </block>\n </next>\n </block>\n </statement>\n </block>\n </statement>\n </block>\n</xml>"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "WLAN einrichten",
|
||||
"steps": [
|
||||
{
|
||||
@ -49,8 +91,13 @@
|
||||
"type": "instruction",
|
||||
"headline": "Einführung",
|
||||
"text": "In diesem Tutorial lernst du wie man die senseBox mit dem Internet verbindest.",
|
||||
"hardware": ["senseboxmcu", "wifi-bee"],
|
||||
"requirements": [1]
|
||||
"hardware": [
|
||||
"senseboxmcu",
|
||||
"wifi-bee"
|
||||
],
|
||||
"requirements": [
|
||||
1
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
|
Loading…
x
Reference in New Issue
Block a user