From 9002edbb22806f6f6873d326ad142273b3ac371a Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 5 Oct 2018 11:09:08 -0700 Subject: [PATCH] Servo library support (#1343) * ateempt at bringin servos * basic plumbing * avoid math map duplicate * missing parts annontation * pretify parts * extend appcompat layer * updated strings * more compat layer * annotations * don't rely on webmidi * updated pxt ref * bump pxt * adding whenUsed * updated v1 readme * more pins * more pins * compress the parts definition * update common packages --- README.md | 28 ++- docs/static/libs/servo.png | Bin 0 -> 17732 bytes libs/core/_locales/core-jsdoc-strings.json | 30 +++ libs/core/_locales/core-strings.json | 11 + libs/core/math.ts | 16 -- libs/core/pins.ts | 2 +- libs/core/pinscompat.ts | 231 +++++++++++++++++++ libs/core/pxt.json | 3 +- libs/core/pxtparts.json | 22 +- libs/servo/_locales/servo-jsdoc-strings.json | 5 + libs/servo/_locales/servo-strings.json | 10 + libs/servo/pxt.json | 3 + libs/servo/targetoverrides.ts | 8 + package.json | 4 +- pxtarget.json | 3 +- 15 files changed, 333 insertions(+), 43 deletions(-) create mode 100644 docs/static/libs/servo.png delete mode 100644 libs/core/math.ts create mode 100644 libs/core/pinscompat.ts create mode 100644 libs/servo/_locales/servo-jsdoc-strings.json create mode 100644 libs/servo/_locales/servo-strings.json create mode 100644 libs/servo/pxt.json create mode 100644 libs/servo/targetoverrides.ts diff --git a/README.md b/README.md index 19bf3cd8..e8fe306a 100644 --- a/README.md +++ b/README.md @@ -31,30 +31,38 @@ npm install npm run build cd .. ``` -5. Clone the `v1` branch of this repository. +5. Clone the pxt-common-packages repository +``` +git clone https://github.com/microsoft/pxt-common-packages +cd pxt-common-packages +npm install +cd .. +``` +6. Clone the `v1` branch of this repository. ``` git clone https://github.com/microsoft/pxt-microbit --branch v1 cd pxt-microbit ``` -6. Install the PXT command line (add `sudo` for Mac/Linux shells). +7. Install the PXT command line (add `sudo` for Mac/Linux shells). ``` npm install -g pxt ``` -7. Install the pxt-microbit dependencies. +8. Install the pxt-microbit dependencies. ``` npm install ``` 8. Link pxt-microbit back to base pxt repo (add `sudo` for Mac/Linux shells). ``` npm link ../pxt +npm link ../pxt-common-packages ``` Note the above command assumes the folder structure of ``` makecode | - ----------------- - | | - pxt pxt-microbit + ---------------------------------- + | | | + pxt pxt-common-packages pxt-microbit ``` ### Running @@ -73,17 +81,13 @@ pxt serve --localbuild ### Updates -To update your PXT version and make sure you're running the latest tools, run: -``` -pxt update -``` - -More instructions are at https://github.com/Microsoft/pxt#running-a-target-from-localhost +Make sure to pull changes from all repos regularly. More instructions are at https://github.com/Microsoft/pxt#running-a-target-from-localhost ## Repos The pxt-microbit target depends on several other repos. The main ones are: - https://github.com/Microsoft/pxt, the PXT framework +- https://github.com/Microsoft/pxt-commmon-packages, common APIs accross various MakeCode editors - https://github.com/lancaster-university/microbit, basic wrapper around the DAL - https://github.com/lancaster-university/microbit-dal diff --git a/docs/static/libs/servo.png b/docs/static/libs/servo.png new file mode 100644 index 0000000000000000000000000000000000000000..c12b1badea29f9c107713b21ed0f44b54db34d68 GIT binary patch literal 17732 zcmcG#gLfa__dVR$wr$(C&BitxyHR7?w$s>YY_+j%8_&Eyzwf{BWUXjkvu5r+bIv|{ z?|UagSy2iB78my0w{HkC(&DP$zJU+}fA>Ly0zc{IX?B2L;Fcl^BHz9>#KFBALjeE7 zI7#cc0_QLN_YETOSNjGyi1R~2`-hsN#Saf-7xQmU#?}r$7#+-i5VJEfGqSSW5L>5w z`zGEmBQB!uX>g$r<14R)CDdfL^&~EiDnl+BuORvhIfCBA(6$U+qf=F`JZCjcb+xb~ zKZ>!^rb=^8)3!p>+K)PNb%_ymi-&E7-eWUsGBd*SYwK%degAN3(&uTtY29@u^e|2$ z65X1i(LRAxLO0&-d$Du^CixmBjcPH(Sj&GOiTwZg(J1WjJL+gV!c?u;G{Y#9MS!jS ze|Mupy(1JI&Qtc`5LXCk<0Agh8ttBVY@l6fkxsw}EAKoFK+1I!IfNw!sUT}p58j_4 zxdK^R@HSf`mC(etFr+vUotqC)q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f-l{pdOh0#miNnIuw*KPxlnP_m4`4g>?0;afSF$(fwttQ)TeEjNW zU`5gPxZ2(w0&9#&ligxak*OZiR%`T%LC1O&zSI`F{3+sSWG2nSneibu>s+c9gqUI@ zh8Q~PnN%bc1Gc}7d??y#%OxIWgIb!Sm!WDx;0T*8Tn6s9nisj?7I`eH2+&AMzD4`+ zQ^;1X%NxE(D061ED6Z(m5KblU-U_-(B%6zili~2eKv9Z{v9?=UM+>9uUhxom^<4& zR0>rVx(5{=Dr=y_S@{_wXSs0RdOhGE-pZk1F7&lyn(v3U;>XnrcwrYn_)0z<$_29? z!}&sQvNP-{$sg5OhdN1eGMi#BYeY0;wk)N1}M2 z$}l8<4%H^p5vDHH6m^A67B(p@_6N3wS}P&_2<;ux6l{?dkIimEm<&D$3QfL$rp%25E<{rIaa({sQTW3jF)&5Bgaz_ zFO(>UO5j`-{0qp(YjRTbuS8P#Dtd|{8(7oikx=N^uNlNGr!8d76g5d(UxXJH!MF@9 zRaTe;Q!?T8j__d*_~Lok{KB&*U`W(#jsGHLmHZ`{g5u^Yk($i8O;sg*nkdXgZ84KN zQ(7rH=QWo=+CFG@8oF+VQO~h!WrZm)x)r=M7W%AyCIw8SNd3eKH}fpS%%o_UIwx2K zg|F@uMnZ^we#!*s(G$jMqzH3jrr7hsURtC`kxJ%0B!duLcglGXT5DBSQ+9`h2pAL( z6SQRv$zD{XNRgUEi?RN0sM24t(CSE`MIrb&LS`_$P#wn9fx-k)z(k5Pn7MbU7I)31 zWD~mArb6XpI_j+bNG0HD4>i4^c@^j#4TEcn0wz+VG0eSB#d8urqS8#2d(uu#=SWJ! zmpW74k4nGEB;a8WAughTi4 void): void; + + onEvent(event: PinEvent, body: () => void): void; + + pulseIn(value: PulseValue, maxDuration?: number): number; + + setPull(pull: PinPullMode): void; +} + +//% noRefCounting fixedInstances +interface AnalogInPin extends DigitalInOutPin { + analogRead(): number; +} + +//% noRefCounting fixedInstances +interface AnalogOutPin extends DigitalInOutPin { + analogWrite(value: number): void; +} + +//% noRefCounting fixedInstances +interface AnalogInOutPin extends AnalogInPin, AnalogOutPin { +} + +//% noRefCounting fixedInstances +interface PwmOnlyPin extends DigitalInOutPin, AnalogOutPin { + //% parts=microservo trackArgs=0 + analogSetPeriod(period: number): void; + + //% parts=microservo trackArgs=0 + servoWrite(value: number): void; + + //% parts=microservo trackArgs=0 + servoSetPulse(duration: number): void; +} + +//% noRefCounting fixedInstances +interface PwmPin extends PwmOnlyPin, DigitalInOutPin, AnalogInPin { +} + +//% noRefCounting fixedInstances +class MicrobitPin implements AnalogInPin, AnalogOutPin, AnalogInOutPin, PwmOnlyPin { + public id: number; + constructor(id: number) { + this.id = id; + } + + protected digitalId(): DigitalPin { + return this.id; + } + + protected analogId(): AnalogPin { + return this.id; + } + + digitalRead(): boolean { + return pins.digitalReadPin(this.digitalId()) != 0; + } + + digitalWrite(value: boolean): void { + pins.digitalWritePin(this.digitalId(), value ? 1 : 0); + } + + onPulsed(pulse: PulseValue, body: () => void): void { + pins.onPulsed(this.digitalId(), pulse, body); + } + + onEvent(event: PinEvent, body: () => void): void { + // TODO + } + + pulseIn(value: PulseValue, maxDuration?: number): number { + return pins.pulseIn(this.digitalId(), value, maxDuration); + } + + setPull(pull: PinPullMode): void { + pins.setPull(this.digitalId(), pull); + } + + analogRead(): number { + return pins.analogReadPin(this.analogId()); + } + + analogWrite(value: number): void { + pins.analogWritePin(this.analogId(), value); + } + + analogSetPeriod(period: number): void { + pins.analogSetPeriod(this.analogId(), period); + } + + servoWrite(value: number): void { + pins.servoWritePin(this.analogId(), value); + } + + servoSetPulse(duration: number): void { + pins.servoSetPulse(this.analogId(), duration); + } +} + +namespace pins { + /** + * Pin P0 + */ + //% fixedInstance whenUsed + export const P0: PwmPin = new MicrobitPin(DigitalPin.P0); + + /** + * Pin P1 + */ + //% fixedInstance whenUsed + export const P1: PwmPin = new MicrobitPin(DigitalPin.P1); + + /** + * Pin P2 + */ + //% fixedInstance whenUsed + export const P2: PwmPin = new MicrobitPin(DigitalPin.P2); + + /** + * Pin P3 + */ + //% fixedInstance whenUsed + export const P3: AnalogInPin = new MicrobitPin(DigitalPin.P3); + + /** + * Pin P4 + */ + //% fixedInstance whenUsed + export const P4: AnalogInPin = new MicrobitPin(DigitalPin.P4); + + /** + * Pin P5 + */ + //% fixedInstance whenUsed + export const P5: DigitalInOutPin = new MicrobitPin(DigitalPin.P5); + + /** + * Pin P6 + */ + //% fixedInstance whenUsed + export const P6: DigitalInOutPin = new MicrobitPin(DigitalPin.P6); + + /** + * Pin P7 + */ + //% fixedInstance whenUsed + export const P7: DigitalInOutPin = new MicrobitPin(DigitalPin.P7); + + /** + * Pin P8 + */ + //% fixedInstance whenUsed + export const P8: DigitalInOutPin = new MicrobitPin(DigitalPin.P8); + + /** + * Pin P9 + */ + //% fixedInstance whenUsed + export const P9: DigitalInOutPin = new MicrobitPin(DigitalPin.P9); + + /** + * Pin P10 + */ + //% fixedInstance whenUsed + export const P10: AnalogInPin = new MicrobitPin(DigitalPin.P10); + + /** + * Pin P3 + */ + //% fixedInstance whenUsed + export const P11: DigitalInOutPin = new MicrobitPin(DigitalPin.P11); + + /** + * Pin P12 + */ + //% fixedInstance whenUsed + export const P12: DigitalInOutPin = new MicrobitPin(DigitalPin.P12); + + /** + * Pin P13 + */ + //% fixedInstance whenUsed + export const P13: DigitalInOutPin = new MicrobitPin(DigitalPin.P13); + + /** + * Pin P14 + */ + //% fixedInstance whenUsed + export const P14: DigitalInOutPin = new MicrobitPin(DigitalPin.P14); + + /** + * Pin P15 + */ + //% fixedInstance whenUsed + export const P15: DigitalInOutPin = new MicrobitPin(DigitalPin.P15); + + /** + * Pin P16 + */ + //% fixedInstance whenUsed + export const P16: DigitalInOutPin = new MicrobitPin(DigitalPin.P16); + + /** + * Pin P19 + */ + //% fixedInstance whenUsed + export const P19: DigitalInOutPin = new MicrobitPin(DigitalPin.P19); + + /** + * Pin P19 + */ + //% fixedInstance whenUsed + export const P20: DigitalInOutPin = new MicrobitPin(DigitalPin.P20); +} diff --git a/libs/core/pxt.json b/libs/core/pxt.json index dd66f067..cca2f32f 100644 --- a/libs/core/pxt.json +++ b/libs/core/pxt.json @@ -13,10 +13,11 @@ "dal.d.ts", "enums.d.ts", "shims.d.ts", - "pxt-core.d.ts", + "pxt-core.d.ts", "core.cpp", "pxt-helpers.ts", "helpers.ts", + "pinscompat.ts", "codal.cpp", "images.cpp", "basic.cpp", diff --git a/libs/core/pxtparts.json b/libs/core/pxtparts.json index 64e0fb03..470c7e2a 100644 --- a/libs/core/pxtparts.json +++ b/libs/core/pxtparts.json @@ -111,16 +111,18 @@ "orientation": "+Z" } ], - "instantiation": { - "kind": "function", - "fullyQualifiedName": "pins.servoWritePin", - "argumentRoles": [ - { - "pinInstantiationIdx": 0, - "partParameter": "name" - } - ] - }, + "instantiations": [ + { + "kind": "function", + "fullyQualifiedName": "pins.servoWritePin,pins.servoSetPulse,PwmOnlyPin.servoWrite,PwmOnlyPin.servoSetPulse,servos.Servo.setAngle,servos.Servo.run,servos.Servo.setPulse", + "argumentRoles": [ + { + "pinInstantiationIdx": 0, + "partParameter": "name" + } + ] + } + ], "assembly": [ { "part": true, diff --git a/libs/servo/_locales/servo-jsdoc-strings.json b/libs/servo/_locales/servo-jsdoc-strings.json new file mode 100644 index 00000000..074caba1 --- /dev/null +++ b/libs/servo/_locales/servo-jsdoc-strings.json @@ -0,0 +1,5 @@ +{ + "servos.Servo.run": "Set the throttle on a continuous servo", + "servos.Servo.run|param|speed": "the throttle of the motor from -100% to 100%", + "servos.Servo.setAngle": "set the servo angle" +} \ No newline at end of file diff --git a/libs/servo/_locales/servo-strings.json b/libs/servo/_locales/servo-strings.json new file mode 100644 index 00000000..bc94133f --- /dev/null +++ b/libs/servo/_locales/servo-strings.json @@ -0,0 +1,10 @@ +{ + "servos.P0|block": "servo P0", + "servos.P1|block": "servo P1", + "servos.P2|block": "servo P2", + "servos.Servo.run|block": "continuous %servo run at %speed=speedPicker \\%", + "servos.Servo.setAngle|block": "set %servo angle to %degrees=protractorPicker °", + "servos.Servo.setPulse|block": "set %servo pulse to %micros μs", + "{id:category}Servos": "Servos", + "{id:group}Servos": "Servos" +} \ No newline at end of file diff --git a/libs/servo/pxt.json b/libs/servo/pxt.json new file mode 100644 index 00000000..1fa7ec3e --- /dev/null +++ b/libs/servo/pxt.json @@ -0,0 +1,3 @@ +{ + "additionalFilePath": "../../node_modules/pxt-common-packages/libs/servo" +} diff --git a/libs/servo/targetoverrides.ts b/libs/servo/targetoverrides.ts new file mode 100644 index 00000000..1cef1499 --- /dev/null +++ b/libs/servo/targetoverrides.ts @@ -0,0 +1,8 @@ +namespace servos { + //% block="servo P0" fixedInstance whenUsed + export const P0 = new servos.PinServo(pins.P0); + //% block="servo P1" fixedInstance whenUsed + export const P1 = new servos.PinServo(pins.P1); + //% block="servo P2" fixedInstance whenUsed + export const P2 = new servos.PinServo(pins.P2); +} \ No newline at end of file diff --git a/package.json b/package.json index 991be80c..0628c5e4 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@types/node": "8.0.53" }, "dependencies": { - "pxt-common-packages": "0.23.57", - "pxt-core": "4.1.17" + "pxt-common-packages": "0.24.2", + "pxt-core": "4.1.18" } } diff --git a/pxtarget.json b/pxtarget.json index 79452bb0..d52a6e9e 100644 --- a/pxtarget.json +++ b/pxtarget.json @@ -9,7 +9,8 @@ "libs/core", "libs/radio", "libs/devices", - "libs/bluetooth" + "libs/bluetooth", + "libs/servo" ], "cloud": { "workspace": false,