added german messages and put only servo motor in toolbox
This commit is contained in:
@@ -5,7 +5,7 @@ import "./sensebox-telegram";
|
||||
import "./sensebox-osem";
|
||||
import "./sensebox-web";
|
||||
import "./sensebox-display";
|
||||
import "./sensebox-motor";
|
||||
import "./sensebox-motors";
|
||||
import "./sensebox-lora";
|
||||
import "./sensebox-led";
|
||||
import "./sensebox";
|
||||
|
||||
+30
-26
@@ -1,29 +1,5 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
|
||||
/**
|
||||
* 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_["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;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Servo Motor
|
||||
@@ -31,9 +7,10 @@ Blockly.Arduino.sensebox_motors_moveStepperMotor = function () {
|
||||
*/
|
||||
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"] = `Servo servo_motor_${pin}; // servo Motor`;
|
||||
Blockly.Arduino.setupCode_["setup_servo_moto"] = `servo_motor_${pin}.attach(${pin}); // attach servo motor to pin ${pin}`;
|
||||
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;
|
||||
};
|
||||
@@ -50,6 +27,7 @@ Blockly.Arduino.sensebox_motors_moveServoMotor = function () {
|
||||
*
|
||||
*/
|
||||
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`;
|
||||
@@ -70,4 +48,30 @@ 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;
|
||||
};
|
||||
Reference in New Issue
Block a user