Skip to content

Commit

Permalink
2KG
Browse files Browse the repository at this point in the history
  • Loading branch information
hogan96 committed Dec 3, 2019
1 parent dd1b2a9 commit b1e955f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .header.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"pubCurrent": false,
"_rev": null,
"id": "5f3fc131-dd08-4e8a-2a3f-61c22ba89542",
"recentUse": 1559628424,
"modificationTime": 1559628424,
"recentUse": 1575338102,
"modificationTime": 1575338048,
"blobId": null,
"blobVersion": null,
"blobCurrent": false,
Expand Down
2 changes: 2 additions & 0 deletions _locales/zh/robotbit-strings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"robotbit.Servo|block": "舵机|%index|角度 %degree",
"robotbit.GeekServo|block": "GeekServo舵机|%index|角度 %degree",
"robotbit.GeekServo2KG|block": "2KG舵机|%index|角度 %degree",
"robotbit.StepperDegree|block": "步进 28BYJ-48|%index|角度 %degree",
"robotbit.StepperTurn|block": "步进 28BYJ-48|%index|圈数 %turn",
"robotbit.StepperDual|block": "双步进(角度) |M1 %degree1| M2 %degree2",
Expand Down
22 changes: 21 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ namespace robotbit {
*/
//% blockId=robotbit_gservo block="Geek Servo|%index|degree %degree"
//% weight=99
//% blockGap=50
//% degree.min=-45 degree.max=225
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
export function GeekServo(index: Servos, degree: number): void {
Expand All @@ -255,6 +254,27 @@ namespace robotbit {
setPwm(index + 7, 0, value)
}

/**
* GeekServo2KG
* @param index Servo Channel; eg: S1
* @param degree [0-360] degree of servo; eg: 0, 180, 360
*/
//% blockId=robotbit_gservo2kg block="GeekServo2KG|%index|degree %degree"
//% weight=98
//% blockGap=50
//% degree.min=0 degree.max=360
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
export function GeekServo2KG(index: Servos, degree: number): void {
if (!initialized) {
initPCA9685()
}
// 50hz: 20,000 us
//let v_us = (degree * 2000 / 360 + 500) 0.5 ~ 2.5
let v_us = (Math.floor((degree) * 2000 / 350) + 500) //fixed
let value = v_us * 4096 / 20000
setPwm(index + 7, 0, value)
}

//% blockId=robotbit_stepper_degree block="Stepper 28BYJ-48|%index|degree %degree"
//% weight=90
export function StepperDegree(index: Steppers, degree: number): void {
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": "robotbit",
"version": "0.3.2",
"version": "0.3.3",
"description": "Extension for Kittenbot Robotbit",
"license": "MIT",
"dependencies": {
Expand Down

0 comments on commit b1e955f

Please sign in to comment.