Skip to content

Commit

Permalink
add new block
Browse files Browse the repository at this point in the history
  • Loading branch information
demoCrash committed Nov 15, 2018
1 parent 555b540 commit 7db2e3b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions _locales/zh/ovobot-jsdoc-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"ovobot.rawMotor|param|duration": "旋转时间,eg:0 ",
"ovobot.rawMotor|param|left": "左轮速度,left.min=-255 left.max=255 eg: 0",
"ovobot.rawMotor|param|right": "右轮速度,right.min=-255 right.max=255 eg:0",
"ovobot.rawMotorWithPwm": "TODO: 独立设置左右轮速度函数。",
"ovobot.rawMotorWithPwm|param|left": "左轮速度,left.min=-255 left.max=255 eg: 0",
"ovobot.rawMotorWithPwm|param|right": "右轮速度,right.min=-255 right.max=255 eg:0",
"ovobot.readDistance": "TODO: 获取超声波传感器与前方障碍物的距离函数。",
"ovobot.readLightStrength": "TODO: 获取光电强度函数。",
"ovobot.readLineSensorData": "TODO: 获取左右巡线传感器数据函数。",
Expand Down
1 change: 1 addition & 0 deletions _locales/zh/ovobot-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"ovobot.initGyroSensor|block": "初始化陀螺仪",
"ovobot.move|block": "移动|方向 %movedir|速度 %speed|时间 (ms) %duration",
"ovobot.rawMotor|block": "驱动电机|左轮 %left|右轮 %right|时间 (ms) %duration",
"ovobot.rawMotorWithPwm|block": "驱动电机|左轮 %left|右轮 %right",
"ovobot.readDistance|block": "超声波距离",
"ovobot.readLightStrength|block": "光线强度",
"ovobot.readLineSensorData|block": "检测黑线 %lineSensor",
Expand Down
14 changes: 14 additions & 0 deletions ovobot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,20 @@ namespace ovobot {
moveMotorOut(0, 0);
}

/**
* TODO: 独立设置左右轮速度函数。
* @param left 左轮速度,left.min=-255 left.max=255 eg: 0
* @param right 右轮速度,right.min=-255 right.max=255 eg:0
*/
//% blockId=set_rawMotor_withpwm block="rawMotor |left %left|right %right"
//% weight=55
export function rawMotorWithPwm(left: number, right: number) {
setupMotorPWM();
left = constract(left, -255, 255);
right = constract(right, -255, 255);
moveMotorOut(left, right);
}

/**
* TODO: 获取超声波传感器与前方障碍物的距离函数。
*/
Expand Down
2 changes: 1 addition & 1 deletion pxt.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ovobot",
"version": "0.0.5",
"version": "0.0.6",
"dependencies": {
"core": "*",
"radio": "*"
Expand Down

0 comments on commit 7db2e3b

Please sign in to comment.