├── .clang-format ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── check-if-merged-pr.yml │ ├── is-vtag.yml │ ├── pxt-buildpush.yml │ ├── pxt-buildvtag.yml │ └── tag-bump-commit.yml ├── .gitignore ├── .prettierrc ├── LICENSE ├── README.md ├── SECURITY.md ├── ThirdPartyNotice ├── cpptests ├── queue.cpp └── screen │ ├── Makefile │ ├── TODO.md │ ├── imgtest.cpp │ ├── platform.h │ ├── pxt.h │ ├── pxtconfig.h │ └── pxtcore.h ├── docs └── static │ └── libs │ ├── datalogger.png │ ├── gamepad.png │ ├── keyboard.png │ ├── lora.png │ ├── mouse.png │ ├── radio-broadcast.png │ ├── radio.png │ ├── servo.png │ └── storage.png ├── libs ├── accelerometer │ ├── README.md │ ├── accelerometer.cpp │ ├── accelhw.cpp │ ├── axis.h │ ├── docs │ │ └── reference │ │ │ ├── input.md │ │ │ └── input │ │ │ ├── acceleration.md │ │ │ ├── on-gesture.md │ │ │ ├── rotation.md │ │ │ └── set-accelerometer-range.md │ ├── enums.d.ts │ ├── gesture.ts │ ├── ns.ts │ ├── part.svg │ ├── pxt.json │ ├── pxtparts.json │ ├── shims.d.ts │ ├── sim │ │ ├── accelerometer.ts │ │ └── state.ts │ └── test.ts ├── animation │ ├── README.md │ ├── docs │ │ ├── reference │ │ │ └── animation │ │ │ │ ├── add-animation-frame.md │ │ │ │ ├── attach-animation.md │ │ │ │ ├── create-animation.md │ │ │ │ └── set-action.md │ │ └── types │ │ │ └── animation.md │ ├── legacy.ts │ ├── pxt.json │ ├── targetoverrides.ts │ └── test.ts ├── azureiot │ ├── README.md │ ├── azureiot.ts │ ├── pxt.json │ └── test.ts ├── base │ ├── README.md │ ├── advmath.cpp │ ├── buffer.cpp │ ├── buffer.ts │ ├── configkeys.h │ ├── console.ts │ ├── control.cpp │ ├── control.ts │ ├── controlgc.cpp │ ├── controlmessage.ts │ ├── core.cpp │ ├── docs │ │ ├── blocks │ │ │ └── pause-until.md │ │ ├── device │ │ │ └── error-codes.md │ │ └── reference │ │ │ ├── console.md │ │ │ ├── console │ │ │ ├── log-value.md │ │ │ └── log.md │ │ │ ├── control.md │ │ │ ├── control │ │ │ ├── assert.md │ │ │ ├── device-dal-version.md │ │ │ ├── device-serial-number.md │ │ │ ├── millis.md │ │ │ ├── on-event.md │ │ │ ├── panic.md │ │ │ ├── raise-event.md │ │ │ ├── reset.md │ │ │ ├── run-in-background.md │ │ │ ├── run-in-parallel.md │ │ │ ├── wait-for-event.md │ │ │ └── wait-micros.md │ │ │ ├── input.md │ │ │ ├── loops │ │ │ ├── forever.md │ │ │ └── pause.md │ │ │ └── text │ │ │ └── convert-to-text.md │ ├── enums.d.ts │ ├── eventcontext.ts │ ├── fixed.ts │ ├── forever.ts │ ├── gc.cpp │ ├── gcstats.ts │ ├── interval.ts │ ├── json.ts │ ├── loops.cpp │ ├── math.ts │ ├── ns.ts │ ├── pause.ts │ ├── perfcounters.ts │ ├── poll.ts │ ├── pxt.cpp │ ├── pxt.json │ ├── pxtbase.h │ ├── scheduling.ts │ ├── shims.d.ts │ ├── sim │ │ ├── cfg.ts │ │ ├── control.ts │ │ ├── controlmessage.ts │ │ ├── core.ts │ │ ├── loops.ts │ │ └── tsconfig.json │ ├── templates.ts │ ├── test.ts │ ├── trig.cpp │ └── utfdecoder.ts ├── browser-events │ ├── browserEvents.cpp │ ├── browserEvents.ts │ ├── keyboard.ts │ ├── pxt.json │ ├── shims.d.ts │ └── sim │ │ ├── browserEvent.ts │ │ ├── keyboard.ts │ │ ├── mouseState.ts │ │ └── time.ts ├── buttons │ ├── README.md │ ├── buttons.cpp │ ├── docs │ │ └── reference │ │ │ └── input │ │ │ └── button │ │ │ ├── is-pressed.md │ │ │ ├── on-event.md │ │ │ ├── touch-sensors.md │ │ │ └── was-pressed.md │ ├── enums.d.ts │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ │ └── buttons.ts │ └── test.ts ├── cable │ ├── README.md │ ├── cable.cpp │ ├── cable.ts │ ├── docs │ │ └── reference │ │ │ ├── network.md │ │ │ └── network │ │ │ ├── cable-send-number.md │ │ │ └── on-cable-received-number.md │ ├── pxt.json │ ├── shims.d.ts │ └── sim │ │ ├── cable.ts │ │ └── state.ts ├── color-coded-tilemap │ ├── README.md │ ├── docs │ │ └── reference │ │ │ ├── color-coded-tilemap.md │ │ │ └── color-coded-tilemap │ │ │ ├── get-tile.md │ │ │ ├── get-tiles-by-type.md │ │ │ ├── on-hit-tile.md │ │ │ ├── place-on-random-tile.md │ │ │ ├── place.md │ │ │ ├── set-tile-at.md │ │ │ ├── set-tile-map.md │ │ │ ├── set-tile.md │ │ │ ├── tile-map.md │ │ │ └── tile.md │ ├── pxt.json │ └── tilemap.ts ├── color-sensor │ ├── README.md │ ├── colorsensor.ts │ ├── pxt.json │ ├── tcs34725.ts │ └── test.ts ├── color │ ├── README.md │ ├── colorbuffer.ts │ ├── colors.ts │ └── pxt.json ├── controller---none │ ├── controllerimpl.ts │ └── pxt.json ├── controller │ ├── README.md │ ├── accelerometer.ts │ ├── controller.ts │ ├── controllerimpl.ts │ ├── crank.ts │ ├── light.ts │ ├── lightsensor.ts │ ├── pxt.json │ ├── state.ts │ ├── thermometer.ts │ └── vibration.ts ├── core---esp32 │ ├── CMakeLists.txt │ ├── Makefile │ ├── certs.mk │ ├── codalemu.cpp │ ├── crypto.cpp │ ├── crypto.ts │ ├── dal.d.ts │ ├── dmesg.cpp │ ├── dmesg.h │ ├── enums.d.ts │ ├── pins.cpp │ ├── pintarget.cpp │ ├── pintarget.h │ ├── platform.cpp │ ├── platform.h │ ├── pxt.h │ ├── pxt.json │ ├── sdkconfig.defaults │ ├── shims.d.ts │ ├── target.cpp │ ├── usb.cpp │ ├── vmload.cpp │ └── worker.cpp ├── core---esp32s2 │ ├── Makefile │ ├── dal.d.ts │ ├── enums.d.ts │ ├── pxt.json │ ├── sdkconfig.defaults │ └── shims.d.ts ├── core---linux │ ├── Makefile │ ├── codalemu.cpp │ ├── config.cpp │ ├── control.cpp │ ├── dal.d.ts │ ├── dmesg.cpp │ ├── enums.d.ts │ ├── linux.cpp │ ├── platform.cpp │ ├── platform.h │ ├── platform_includes.h │ ├── pxt.h │ ├── pxt.json │ ├── pxtcore.h │ ├── shims.d.ts │ └── target.cpp ├── core---nrf52 │ ├── dal.d.ts │ ├── enums.d.ts │ ├── platform.cpp │ ├── platform.h │ ├── pxt.json │ └── shims.d.ts ├── core---rp2040 │ ├── platform.cpp │ ├── platform.h │ └── pxt.json ├── core---samd │ ├── dal.d.ts │ ├── enums.d.ts │ ├── platform.cpp │ ├── platform.h │ ├── pxt.json │ └── shims.d.ts ├── core---stm32 │ ├── dal.d.ts │ ├── enums.d.ts │ ├── platform.cpp │ ├── platform.h │ ├── pxt.json │ └── shims.d.ts ├── core---vm │ ├── Makefile │ ├── config.cpp │ ├── keys.cpp │ ├── platform.h │ ├── pxt.h │ ├── pxt.json │ ├── scheduler.cpp │ ├── target.cpp │ ├── verify.cpp │ ├── vm.cpp │ ├── vm.h │ ├── vmcache.cpp │ └── vmload.cpp ├── core │ ├── README.md │ ├── codal.cpp │ ├── control.cpp │ ├── dal.d.ts │ ├── dmac.cpp │ ├── dmac.h │ ├── docs │ │ ├── device │ │ │ ├── simulator.md │ │ │ ├── usb.md │ │ │ └── usb │ │ │ │ └── troubleshooting.md │ │ └── reference │ │ │ ├── pins.md │ │ │ └── pins │ │ │ ├── analog-read.md │ │ │ ├── analog-set-period.md │ │ │ ├── analog-write.md │ │ │ ├── create-i2c.md │ │ │ ├── create-spi.md │ │ │ ├── digital-read.md │ │ │ ├── digital-write.md │ │ │ ├── i2c-read-number.md │ │ │ ├── i2c-read-register.md │ │ │ ├── i2c-write-number.md │ │ │ ├── i2c-write-register.md │ │ │ ├── on-event.md │ │ │ ├── on-pulsed.md │ │ │ ├── pulse-duration.md │ │ │ ├── pulse-in.md │ │ │ ├── servo-set-pulse.md │ │ │ ├── servo-write.md │ │ │ ├── set-pull.md │ │ │ ├── spi-frequency.md │ │ │ ├── spi-mode.md │ │ │ ├── spi-transfer.md │ │ │ ├── spi-write.md │ │ │ └── what-is-pwm.md │ ├── enums.d.ts │ ├── hf2.cpp │ ├── hf2.h │ ├── hf2dbg.h │ ├── i2c.cpp │ ├── i2c.ts │ ├── keyvaluestorage.cpp │ ├── keyvaluestorage.ts │ ├── leveldetector.ts │ ├── light.cpp │ ├── light.h │ ├── ns.ts │ ├── pins.cpp │ ├── pins.h │ ├── pins.ts │ ├── pinsAnalog.cpp │ ├── pinsDigital.cpp │ ├── pinsPWM.cpp │ ├── pinscompat.ts │ ├── platform.cpp │ ├── platform.h │ ├── pxt.h │ ├── pxt.json │ ├── pxtcore.h │ ├── pxtparts.json │ ├── shims.d.ts │ ├── sim │ │ ├── analogSensor.ts │ │ ├── buttons.ts │ │ ├── edgeconnector.ts │ │ ├── keyvaluestorage.ts │ │ ├── led.ts │ │ ├── microservo.ts │ │ ├── neopixel.ts │ │ ├── photocell.ts │ │ ├── pins.ts │ │ ├── serial.ts │ │ ├── switch.ts │ │ ├── toggle.ts │ │ ├── tsconfig.json │ │ └── visuals │ │ │ ├── led.svg │ │ │ ├── photocell.svg │ │ │ ├── switch_off.svg │ │ │ └── switch_on.svg │ ├── spi.cpp │ ├── spi.ts │ ├── test.ts │ ├── timer.ts │ ├── uf2format.h │ ├── uf2hid.h │ └── usb.cpp ├── datalogger │ ├── README.md │ ├── datalogger.ts │ ├── docs │ │ └── reference │ │ │ ├── datalogger.md │ │ │ └── datalogger │ │ │ ├── add-row.md │ │ │ ├── add-value.md │ │ │ ├── send-to-console.md │ │ │ ├── set-enabled.md │ │ │ ├── set-sample-interval.md │ │ │ └── set-separator.md │ ├── pxt.json │ ├── storagedatalogger.ts │ ├── targetoverrides.ts │ └── test.ts ├── display │ ├── display.ts │ ├── displayImage.ts │ ├── graph.ts │ ├── pxt.json │ └── targetoverrides.ts ├── edge-connector │ ├── README.md │ ├── device.d.ts │ ├── docs │ │ └── reference │ │ │ └── edge-connector.md │ ├── pinscompat.ts │ └── pxt.json ├── esp32 │ ├── README.md │ ├── atcontroller.ts │ ├── espflasher.cpp │ ├── net.ts │ ├── ninacontroller.ts │ ├── pxt.json │ └── test.ts ├── feather │ ├── README.md │ ├── device.d.ts │ ├── docs │ │ └── reference │ │ │ └── feather.md │ ├── pxt.json │ └── targetoverrides.d.ts ├── game---light │ ├── compat.ts │ └── pxt.json ├── game │ ├── animation.ts │ ├── ask.ts │ ├── assetTemplates.ts │ ├── background.ts │ ├── basesprite.ts │ ├── camera.ts │ ├── console.ts │ ├── constants.ts │ ├── controller.ts │ ├── controllerbutton.ts │ ├── controllerbuttons.cpp │ ├── controlleroverrides.ts │ ├── docs │ │ ├── reference │ │ │ ├── animation.md │ │ │ ├── animation │ │ │ │ ├── animation-frames.md │ │ │ │ ├── run-image-animation.md │ │ │ │ ├── run-movement-animation.md │ │ │ │ └── stop-animation.md │ │ │ ├── controller.md │ │ │ ├── controller │ │ │ │ ├── button │ │ │ │ │ ├── is-pressed.md │ │ │ │ │ ├── on-event.md │ │ │ │ │ ├── pause-until.md │ │ │ │ │ ├── repeat-delay.md │ │ │ │ │ └── repeat-interval.md │ │ │ │ ├── dx.md │ │ │ │ ├── dy.md │ │ │ │ ├── move-sprite.md │ │ │ │ ├── on-button-event.md │ │ │ │ ├── on-event.md │ │ │ │ └── set-repeat-default.md │ │ │ ├── effects │ │ │ │ ├── clear-particles.md │ │ │ │ ├── end-screen-effect.md │ │ │ │ └── start-screen-effect.md │ │ │ ├── game.md │ │ │ ├── game │ │ │ │ ├── ask-for-number.md │ │ │ │ ├── ask-for-string.md │ │ │ │ ├── ask.md │ │ │ │ ├── on-paint.md │ │ │ │ ├── on-update-interval.md │ │ │ │ ├── on-update.md │ │ │ │ ├── over.md │ │ │ │ ├── set-dialog-cursor.md │ │ │ │ ├── set-dialog-frame.md │ │ │ │ ├── set-dialog-text-color.md │ │ │ │ ├── set-game-over-effect.md │ │ │ │ ├── set-game-over-message.md │ │ │ │ ├── set-game-over-playable.md │ │ │ │ ├── set-game-over-scoring-type.md │ │ │ │ ├── show-long-text.md │ │ │ │ └── splash.md │ │ │ ├── image.md │ │ │ ├── images.md │ │ │ ├── images │ │ │ │ ├── create.md │ │ │ │ ├── image.md │ │ │ │ ├── image │ │ │ │ │ ├── clone.md │ │ │ │ │ ├── draw-line.md │ │ │ │ │ ├── draw-rect.md │ │ │ │ │ ├── equals.md │ │ │ │ │ ├── fill-rect.md │ │ │ │ │ ├── fill.md │ │ │ │ │ ├── flip-x.md │ │ │ │ │ ├── flip-y.md │ │ │ │ │ ├── get-pixel.md │ │ │ │ │ ├── replace.md │ │ │ │ │ ├── scroll.md │ │ │ │ │ └── set-pixel.md │ │ │ │ ├── screen-image.md │ │ │ │ └── sprite-image.md │ │ │ ├── info.md │ │ │ ├── info │ │ │ │ ├── change-countdown-by.md │ │ │ │ ├── change-life-by.md │ │ │ │ ├── change-score-by.md │ │ │ │ ├── countdown.md │ │ │ │ ├── has-life.md │ │ │ │ ├── high-score.md │ │ │ │ ├── life.md │ │ │ │ ├── on-countdown-end.md │ │ │ │ ├── on-life-zero.md │ │ │ │ ├── on-score.md │ │ │ │ ├── score.md │ │ │ │ ├── set-life.md │ │ │ │ ├── set-score.md │ │ │ │ ├── start-countdown.md │ │ │ │ └── stop-countdown.md │ │ │ ├── math │ │ │ │ └── percent-chance.md │ │ │ ├── scene.md │ │ │ ├── scene │ │ │ │ ├── background-color.md │ │ │ │ ├── background-image.md │ │ │ │ ├── camera-follow-sprite.md │ │ │ │ ├── camera-left.md │ │ │ │ ├── camera-property.md │ │ │ │ ├── camera-shake.md │ │ │ │ ├── camera-top.md │ │ │ │ ├── center-camera-at.md │ │ │ │ ├── get-neighboring-location.md │ │ │ │ ├── get-tile-location.md │ │ │ │ ├── get-tiles-by-type.md │ │ │ │ ├── is-hitting-tile.md │ │ │ │ ├── location.md │ │ │ │ ├── on-hit-wall.md │ │ │ │ ├── on-overlap-tile.md │ │ │ │ ├── place-on-random-tile.md │ │ │ │ ├── place-on-tile.md │ │ │ │ ├── screen-height.md │ │ │ │ ├── screen-width.md │ │ │ │ ├── set-background-color.md │ │ │ │ ├── set-background-image.md │ │ │ │ ├── set-tile-at.md │ │ │ │ ├── set-tilemap.md │ │ │ │ ├── set-wall-at.md │ │ │ │ ├── tile-at-location-equals.md │ │ │ │ ├── tile-at-location-is-wall.md │ │ │ │ ├── tile-image-at-location.md │ │ │ │ ├── tile-kind-at.md │ │ │ │ └── tilemap-location.md │ │ │ ├── sprites.md │ │ │ ├── sprites │ │ │ │ ├── all-of-kind.md │ │ │ │ ├── create-projectile-from-side.md │ │ │ │ ├── create-projectile-from-sprite.md │ │ │ │ ├── create-projectile.md │ │ │ │ ├── create.md │ │ │ │ ├── destroy-all-sprites-of-kind.md │ │ │ │ ├── on-created.md │ │ │ │ ├── on-destroyed.md │ │ │ │ ├── on-overlap.md │ │ │ │ ├── sprite-kind.md │ │ │ │ └── sprite │ │ │ │ │ ├── ax.md │ │ │ │ │ ├── ay.md │ │ │ │ │ ├── bottom.md │ │ │ │ │ ├── change-scale.md │ │ │ │ │ ├── destroy.md │ │ │ │ │ ├── follow.md │ │ │ │ │ ├── fx.md │ │ │ │ │ ├── fy.md │ │ │ │ │ ├── height.md │ │ │ │ │ ├── image.md │ │ │ │ │ ├── is-hitting-tile.md │ │ │ │ │ ├── kind.md │ │ │ │ │ ├── left.md │ │ │ │ │ ├── lifespan.md │ │ │ │ │ ├── overlaps-with.md │ │ │ │ │ ├── right.md │ │ │ │ │ ├── say.md │ │ │ │ │ ├── scale.md │ │ │ │ │ ├── set-bounce-on-wall.md │ │ │ │ │ ├── set-flag.md │ │ │ │ │ ├── set-image.md │ │ │ │ │ ├── set-kind.md │ │ │ │ │ ├── set-position.md │ │ │ │ │ ├── set-scale.md │ │ │ │ │ ├── set-stay-in-screen.md │ │ │ │ │ ├── set-velocity.md │ │ │ │ │ ├── start-effect.md │ │ │ │ │ ├── sx.md │ │ │ │ │ ├── sy.md │ │ │ │ │ ├── tile-hit-from.md │ │ │ │ │ ├── tile-kind-at.md │ │ │ │ │ ├── top.md │ │ │ │ │ ├── type.md │ │ │ │ │ ├── vx.md │ │ │ │ │ ├── vy.md │ │ │ │ │ ├── width.md │ │ │ │ │ ├── x.md │ │ │ │ │ ├── y.md │ │ │ │ │ └── z.md │ │ │ ├── tiles.md │ │ │ └── tiles │ │ │ │ ├── get-neighboring-location.md │ │ │ │ ├── get-tile-location.md │ │ │ │ ├── get-tiles-by-type.md │ │ │ │ ├── location.md │ │ │ │ ├── on-hit-wall.md │ │ │ │ ├── on-overlap-tile.md │ │ │ │ ├── place-on-random-tile.md │ │ │ │ ├── place-on-tile.md │ │ │ │ ├── place.md │ │ │ │ ├── set-current-tilemap.md │ │ │ │ ├── set-tile-at.md │ │ │ │ ├── set-tile-map.md │ │ │ │ ├── set-tilemap.md │ │ │ │ ├── set-wall-at.md │ │ │ │ ├── tile-at-location-equals.md │ │ │ │ ├── tile-at-location-is-wall.md │ │ │ │ ├── tile-image-at-location.md │ │ │ │ ├── tile-map.md │ │ │ │ └── tilemap.md │ │ └── types │ │ │ ├── image.md │ │ │ └── sprite.md │ ├── effects.ts │ ├── extendableSprite.ts │ ├── fieldeditors.ts │ ├── game.ts │ ├── gameoverrides.ts │ ├── gameutil.ts │ ├── hitbox.ts │ ├── info.ts │ ├── keymap.cpp │ ├── keymap.ts │ ├── mathUtil.ts │ ├── metrics.ts │ ├── multiplayer.cpp │ ├── multiplayer.ts │ ├── ns.ts │ ├── numberprompt.ts │ ├── obstacle.ts │ ├── particleeffects.ts │ ├── particlefactories.ts │ ├── particles.ts │ ├── physics.ts │ ├── prompt.ts │ ├── pxt.json │ ├── renderText.ts │ ├── renderable.ts │ ├── rotation.ts │ ├── scene.ts │ ├── scenes.ts │ ├── sim │ │ ├── api.ts │ │ ├── keymap.ts │ │ └── multiplayer.ts │ ├── sprite.d.ts │ ├── sprite.ts │ ├── spriteevents.ts │ ├── spritekind.ts │ ├── spritemap.ts │ ├── sprites.ts │ ├── spritesay.ts │ ├── spriteset.ts │ ├── systemKeyboard.cpp │ ├── systemKeyboard.d.ts │ ├── systemmenu.ts │ ├── systemmenuicons.ts │ ├── targetoverrides.cpp │ ├── targetoverrides.ts │ ├── temp.d.ts │ ├── textDialogs.ts │ ├── texteffects.ts │ ├── tilemap.ts │ └── tsconfig.json ├── gamepad │ ├── docs │ │ └── reference │ │ │ ├── gamepad.md │ │ │ └── gamepad │ │ │ ├── move.md │ │ │ ├── set-button.md │ │ │ └── set-throttle.md │ ├── gamepad.cpp │ ├── gamepad.ts │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ │ ├── gamepad.ts │ │ └── state.ts │ └── test.ts ├── infrared │ ├── README.md │ ├── docs │ │ └── reference │ │ │ ├── network.md │ │ │ └── network │ │ │ ├── infrared-send-number.md │ │ │ └── on-infrared-received-number.md │ ├── ir.cpp │ ├── ir.ts │ ├── pxt.json │ ├── shims.d.ts │ └── sim │ │ ├── ir.ts │ │ └── state.ts ├── keyboard │ ├── docs │ │ └── reference │ │ │ ├── keyboard.md │ │ │ └── keyboard │ │ │ ├── function-key.md │ │ │ ├── key.md │ │ │ ├── media-key.md │ │ │ └── type.md │ ├── enums.d.ts │ ├── keyboard.cpp │ ├── keyboard.ts │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ │ └── keyboard.ts │ └── test.ts ├── lcd │ ├── README.md │ ├── characterlcd.ts │ ├── characterlcdmono.ts │ ├── characterlcdrbg.ts │ ├── lcd.cpp │ ├── lcd.ts │ ├── pxt.json │ ├── pxtparts.json │ ├── sim │ │ ├── lcd.svg │ │ ├── state.ts │ │ └── visual.ts │ └── test.ts ├── light-spectrum-sensor │ ├── README.md │ ├── pxt.json │ ├── sensor.ts │ ├── test.ts │ └── tsl2591.ts ├── light │ ├── README.md │ ├── animations.jres │ ├── create.ts │ ├── defaultlights.ts │ ├── defaultlightsoverrides.ts │ ├── defaultstrip.ts │ ├── docs │ │ ├── examples │ │ │ ├── photon-bounce.md │ │ │ ├── photon-color-wipe.md │ │ │ ├── photon-rainbow.md │ │ │ ├── photon-roundtrip.md │ │ │ ├── photon-spark.md │ │ │ └── photon-wand.md │ │ └── reference │ │ │ ├── light.md │ │ │ └── light │ │ │ ├── color-wheel.md │ │ │ ├── color-wipe-animation.md │ │ │ ├── colors.md │ │ │ ├── comet-animation.md │ │ │ ├── create-strip.md │ │ │ ├── fade.md │ │ │ ├── hsv.md │ │ │ ├── neopixelstrip │ │ │ ├── brightness.md │ │ │ ├── clear.md │ │ │ ├── graph.md │ │ │ ├── length.md │ │ │ ├── move.md │ │ │ ├── photon-flip.md │ │ │ ├── photon-forward.md │ │ │ ├── pixel-color.md │ │ │ ├── range.md │ │ │ ├── set-all.md │ │ │ ├── set-brightness.md │ │ │ ├── set-buffered.md │ │ │ ├── set-mode.md │ │ │ ├── set-photon-mode.md │ │ │ ├── set-photon-pen-color.md │ │ │ ├── set-photon-pen-hue.md │ │ │ ├── set-photon-position.md │ │ │ ├── set-pixel-color.md │ │ │ ├── set-pixel-white-led.md │ │ │ ├── show-animation-frame.md │ │ │ ├── show-animation.md │ │ │ ├── show.md │ │ │ └── stop-all-animations.md │ │ │ ├── rainbow-cycle-animation.md │ │ │ ├── rgb.md │ │ │ ├── running-lights-animation.md │ │ │ ├── sparkle-animation.md │ │ │ └── theatre-chase-animation.md │ ├── jres │ │ └── animations │ │ │ ├── colorWipeAnimation-icon.png │ │ │ ├── colorWipeAnimation-icon.svg │ │ │ ├── cometAnimation-icon.png │ │ │ ├── cometAnimation-icon.svg │ │ │ ├── rainbowAnimation-icon.png │ │ │ ├── rainbowAnimation-icon.svg │ │ │ ├── runningLightsAnimation-icon.png │ │ │ ├── runningLightsAnimation-icon.svg │ │ │ ├── sparkleAnimation-icon.png │ │ │ ├── sparkleAnimation-icon.svg │ │ │ ├── theaterChaseAnimation-icon.png │ │ │ └── theaterChaseAnimation-icon.svg │ ├── neopixel.ts │ ├── neopixeloverrides.ts │ ├── ns.ts │ ├── onboardstrip.ts │ ├── pxt.json │ ├── targetoverrides.ts │ ├── test.ts │ └── transitions.ts ├── lightsensor │ ├── README.md │ ├── docs │ │ └── reference │ │ │ ├── input.md │ │ │ └── input │ │ │ ├── light-level.md │ │ │ ├── on-light-condition-changed.md │ │ │ └── set-light-threshold.md │ ├── enums.d.ts │ ├── lightsensor.cpp │ ├── ns.ts │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ │ ├── lightsensor.ts │ │ └── state.ts │ └── test.ts ├── lora │ ├── README.md │ ├── docs │ │ └── reference │ │ │ └── lora.md │ ├── lora.ts │ ├── pxt.json │ ├── register-arduino.txt │ ├── register-makecode.txt │ └── test.ts ├── matrix-keypad │ ├── README.md │ ├── keypad.ts │ ├── pxt.json │ └── test.ts ├── microphone │ ├── README.md │ ├── docs │ │ └── reference │ │ │ ├── input.md │ │ │ └── input │ │ │ ├── on-loud-sound.md │ │ │ ├── set-loud-sound-threshold.md │ │ │ └── sound-level.md │ ├── enums.d.ts │ ├── microphone.cpp │ ├── microphonehw.cpp │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ │ ├── microphone.ts │ │ └── state.ts │ ├── targetoverrides.ts │ └── test.ts ├── mixer---ext │ ├── SoundOutput.h │ ├── pins.cpp │ ├── pxt.json │ ├── sound.cpp │ └── targetoverrides.ts ├── mixer---linux │ ├── SoundOutput.h │ ├── pins.cpp │ ├── pxt.json │ ├── sound.cpp │ └── targetoverrides.ts ├── mixer---none │ ├── SoundOutput.h │ ├── melody.cpp │ ├── melody.h │ └── pxt.json ├── mixer---nrf52 │ ├── SoundOutput.h │ └── pxt.json ├── mixer---rp2040 │ ├── SoundOutput.h │ └── pxt.json ├── mixer---samd │ ├── SoundOutput.h │ └── pxt.json ├── mixer---stm32 │ ├── SoundOutput.h │ └── pxt.json ├── mixer │ ├── SoundOutput.h │ ├── docs │ │ ├── reference │ │ │ ├── music.md │ │ │ └── music │ │ │ │ ├── beat.md │ │ │ │ ├── change-tempo-by.md │ │ │ │ ├── composing-sounds.md │ │ │ │ ├── create-song.md │ │ │ │ ├── create-sound-effect.md │ │ │ │ ├── melody-editor.md │ │ │ │ ├── melody-playable.md │ │ │ │ ├── melody │ │ │ │ ├── loop.md │ │ │ │ ├── play-until-done.md │ │ │ │ ├── play.md │ │ │ │ └── stop.md │ │ │ │ ├── note-frequency.md │ │ │ │ ├── play-melody.md │ │ │ │ ├── play-sound-effect.md │ │ │ │ ├── play-tone.md │ │ │ │ ├── play.md │ │ │ │ ├── randomize-sound.md │ │ │ │ ├── rest.md │ │ │ │ ├── ring-tone.md │ │ │ │ ├── set-tempo.md │ │ │ │ ├── set-volume.md │ │ │ │ ├── song-editor.md │ │ │ │ ├── stop-all-sounds.md │ │ │ │ ├── string-playable.md │ │ │ │ ├── tempo.md │ │ │ │ └── tone-playable.md │ │ └── types │ │ │ ├── playable.md │ │ │ └── sound-effect.md │ ├── instrument.ts │ ├── legacy.ts │ ├── melody.cpp │ ├── melody.h │ ├── melody.ts │ ├── playable.ts │ ├── pxt.json │ ├── sequencer.ts │ ├── sim │ │ └── music.ts │ ├── sound.cpp │ ├── soundEffect.ts │ └── targetoverrides.ts ├── mouse │ ├── docs │ │ └── reference │ │ │ ├── mouse.md │ │ │ └── mouse │ │ │ ├── move.md │ │ │ ├── set-button.md │ │ │ └── turn-wheel.md │ ├── enums.d.ts │ ├── mouse.cpp │ ├── mouse.ts │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ │ └── mouse.ts │ └── test.ts ├── mqtt │ ├── README.md │ ├── mqtt.ts │ ├── pxt.json │ ├── sim │ │ └── net.ts │ └── test.ts ├── multiplayer │ ├── README.md │ ├── docs │ │ ├── .gitkeep │ │ ├── reference │ │ │ ├── multiplayer.md │ │ │ └── multiplayer │ │ │ │ ├── change-player-state-by.md │ │ │ │ ├── game-over-player-win.md │ │ │ │ ├── get-player-by-index.md │ │ │ │ ├── get-player-by-number.md │ │ │ │ ├── get-player-by-sprite.md │ │ │ │ ├── get-player-property.md │ │ │ │ ├── get-player-sprite.md │ │ │ │ ├── get-player-state.md │ │ │ │ ├── is-button-pressed.md │ │ │ │ ├── move-with-buttons.md │ │ │ │ ├── multiplayer-state.md │ │ │ │ ├── on-button-event.md │ │ │ │ ├── on-controller-event.md │ │ │ │ ├── on-life-zero.md │ │ │ │ ├── on-score.md │ │ │ │ ├── player-selector.md │ │ │ │ ├── set-player-indicators-visible.md │ │ │ │ ├── set-player-sprite.md │ │ │ │ └── set-player-state.md │ │ └── types │ │ │ └── player.md │ ├── fieldEditors.ts │ ├── images.ts │ ├── ns.ts │ ├── player.ts │ ├── pxt.json │ ├── stateKind.ts │ ├── targetoverrides.ts │ └── test.ts ├── music---linux │ ├── enums.d.ts │ ├── music.cpp │ ├── pxt.json │ └── shims.d.ts ├── music---pwm │ ├── enums.d.ts │ ├── music.cpp │ ├── pxt.json │ └── shims.d.ts ├── music │ ├── README.md │ ├── docs │ │ └── reference │ │ │ ├── music.md │ │ │ └── music │ │ │ ├── beat.md │ │ │ ├── change-tempo-by.md │ │ │ ├── composing-sounds.md │ │ │ ├── note-frequency.md │ │ │ ├── play-sound-until-done.md │ │ │ ├── play-sound.md │ │ │ ├── play-tone.md │ │ │ ├── rest.md │ │ │ ├── ring-tone.md │ │ │ ├── set-output.md │ │ │ ├── set-pitch-pin.md │ │ │ ├── set-speaker-volume.md │ │ │ ├── set-tempo.md │ │ │ ├── set-tone.md │ │ │ ├── set-volume.md │ │ │ ├── sounds.md │ │ │ ├── stop-all-sounds.md │ │ │ └── tempo.md │ ├── enums.d.ts │ ├── headphone.svg │ ├── melodies.ts │ ├── music.cpp │ ├── music.ts │ ├── ns.ts │ ├── piano.ts │ ├── pins.cpp │ ├── pxt.json │ ├── pxtparts.json │ ├── shims.d.ts │ ├── sim │ │ ├── music.ts │ │ └── state.ts │ ├── speaker.svg │ └── test.ts ├── net-game │ ├── pxt.json │ └── settings.ts ├── net │ ├── README.md │ ├── controller.ts │ ├── controllersocket.ts │ ├── net.ts │ ├── netutil.ts │ ├── pxt.json │ └── requests.ts ├── palette │ ├── README.md │ ├── palette.ts │ ├── pxt.json │ └── test.ts ├── pixel │ ├── pixel.ts │ └── pxt.json ├── power │ ├── docs │ │ └── reference │ │ │ ├── power.md │ │ │ └── power │ │ │ ├── check-deep-sleep.md │ │ │ ├── deep-sleep.md │ │ │ ├── poke.md │ │ │ └── set-deep-sleep-timeout.md │ ├── power.ts │ └── pxt.json ├── proximity │ ├── proximity.ts │ ├── pxt.json │ └── vl53l0x.ts ├── pulse │ ├── README.md │ ├── bitvector.h │ ├── ns.ts │ ├── pulse.cpp │ ├── pulse.h │ ├── pxt.json │ └── shims.d.ts ├── radio-broadcast │ ├── docs │ │ └── reference │ │ │ ├── radio-broadcast.md │ │ │ └── radio │ │ │ ├── on-received-message.md │ │ │ └── send-message.md │ ├── pxt.json │ └── radio-broadcast.ts ├── radio │ ├── README.md │ ├── docs │ │ └── reference │ │ │ ├── radio.md │ │ │ └── radio │ │ │ ├── on-received-buffer.md │ │ │ ├── on-received-number.md │ │ │ ├── on-received-string.md │ │ │ ├── on-received-value.md │ │ │ ├── packet.md │ │ │ ├── raise-event.md │ │ │ ├── send-buffer.md │ │ │ ├── send-number.md │ │ │ ├── send-string.md │ │ │ ├── send-value.md │ │ │ ├── set-frequency-band.md │ │ │ ├── set-group.md │ │ │ ├── set-transmit-power.md │ │ │ └── set-transmit-serial-number.md │ ├── enums.d.ts │ ├── pxt.json │ ├── radio.cpp │ ├── radio.ts │ ├── shims.d.ts │ ├── sim │ │ ├── radio.ts │ │ └── state.ts │ ├── targetoverrides.ts │ └── test.ts ├── rotary-encoder │ ├── README.md │ ├── enums.d.ts │ ├── ns.ts │ ├── pxt.json │ ├── rotary.cpp │ ├── shims.d.ts │ ├── sim │ │ └── rotary-encoder.ts │ └── targetoverrides.ts ├── screen---ext │ ├── pxt.json │ ├── screen.cpp │ ├── shims.d.ts │ └── targetoverrides.ts ├── screen---linux │ ├── pxt.json │ ├── screen.cpp │ ├── shims.d.ts │ └── targetoverrides.ts ├── screen---st7735 │ ├── arcadegamepad.h │ ├── arcadesound.h │ ├── indexedscreen.h │ ├── jddisplay.cpp │ ├── jddisplay.h │ ├── jdprotocol.h │ ├── panic.cpp │ ├── pxt.json │ ├── screen.cpp │ ├── shims.d.ts │ └── targetoverrides.ts ├── screen │ ├── fieldeditors.ts │ ├── font12.jres │ ├── frame.ts │ ├── image.cpp │ ├── image.d.ts │ ├── image.ts │ ├── imagesoverrides.jres │ ├── imagesoverrides.ts │ ├── ns.ts │ ├── panic.cpp │ ├── pxt.json │ ├── pxtparts.json │ ├── screen.cpp │ ├── screenimage.ts │ ├── shims.d.ts │ ├── sim │ │ ├── image.ts │ │ ├── part.svg │ │ ├── state.ts │ │ ├── tsconfig.json │ │ └── visual.ts │ ├── targetoverrides.ts │ └── text.ts ├── serial---linux │ ├── pxt.json │ ├── serial-target.cpp │ ├── serial-target.h │ └── serial-target.ts ├── serial │ ├── docs │ │ └── reference │ │ │ ├── serial.md │ │ │ └── serial │ │ │ ├── attach-to-console.md │ │ │ ├── create-serial.md │ │ │ ├── on-delimiter-received.md │ │ │ ├── on-event.md │ │ │ ├── read-buffer.md │ │ │ ├── read-line.md │ │ │ ├── read-string.md │ │ │ ├── read-until.md │ │ │ ├── redirect.md │ │ │ ├── set-baud-rate.md │ │ │ ├── set-rx-buffer-size.md │ │ │ ├── set-tx-buffer-size.md │ │ │ ├── write-buffer.md │ │ │ ├── write-line.md │ │ │ ├── write-number.md │ │ │ ├── write-string.md │ │ │ └── write-value.md │ ├── enums.d.ts │ ├── pxt.json │ ├── serial-common.cpp │ ├── serial-common.h │ ├── serial-target.cpp │ ├── serial-target.h │ ├── serial-target.ts │ ├── serial.ts │ ├── shims.d.ts │ └── test.ts ├── servo │ ├── README.md │ ├── docs │ │ └── reference │ │ │ ├── servo.md │ │ │ ├── servos.md │ │ │ └── servos │ │ │ ├── run.md │ │ │ ├── set-angle.md │ │ │ ├── set-pulse.md │ │ │ ├── set-range.md │ │ │ ├── set-stop-on-neutral.md │ │ │ └── stop.md │ ├── ns.ts │ ├── pxt.json │ ├── servo.ts │ └── targetoverrides.ts ├── settings---esp32 │ ├── pxt.json │ └── settings.cpp ├── settings---files │ ├── pxt.json │ └── settings.cpp ├── settings │ ├── Flash.h │ ├── NRF52Flash.cpp │ ├── RAFFS.cpp │ ├── RAFFS.h │ ├── README.md │ ├── RP2040Flash.cpp │ ├── SAMDFlash.cpp │ ├── STM32Flash.cpp │ ├── pxt.json │ ├── settings.cpp │ ├── settings.ts │ ├── shims.d.ts │ ├── sim │ │ └── settings.ts │ └── targetoverrides.ts ├── shader │ ├── pxt.json │ ├── shader.cpp │ ├── shader.ts │ └── sim │ │ └── shader.ts ├── sprite-scaling │ ├── README.md │ ├── docs │ │ └── reference │ │ │ ├── sprite-scaling.md │ │ │ └── sprites │ │ │ └── scaling │ │ │ ├── scale-by-percent.md │ │ │ ├── scale-by-pixels.md │ │ │ ├── scale-to-percent.md │ │ │ └── scale-to-pixels.md │ ├── pxt.json │ ├── scaling.ts │ ├── targetoverrides.ts │ └── test.ts ├── storage │ ├── GhostSNORFS.cpp │ ├── GhostSNORFS.h │ ├── SNORFS.cpp │ ├── SNORFS.h │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ │ ├── state.ts │ │ └── storage.ts │ ├── storage.cpp │ └── storage.ts ├── storyboard │ ├── README.md │ ├── loader.ts │ ├── pxt.json │ ├── storyboard.ts │ └── test.ts ├── switch │ ├── README.md │ ├── docs │ │ └── reference │ │ │ └── input │ │ │ └── on-switch-moved.md │ ├── enums.d.ts │ ├── ns.ts │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ │ ├── state.ts │ │ └── switch.ts │ └── switch.cpp ├── tests │ ├── README.md │ ├── pxt.json │ ├── targetoverrides.ts │ └── tests.ts ├── text-to-speech │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ │ └── tts.ts │ └── tts.ts ├── thermometer │ ├── README.md │ ├── docs │ │ └── reference │ │ │ ├── input.md │ │ │ └── input │ │ │ ├── on-temperature-condition-changed.md │ │ │ └── temperature.md │ ├── enums.d.ts │ ├── ns.ts │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ │ ├── state.ts │ │ └── temperature.ts │ ├── target_temperature.h │ ├── temperature.cpp │ └── test.ts ├── touch │ ├── README.md │ ├── docs │ │ └── reference │ │ │ └── input │ │ │ └── touch │ │ │ ├── calibrate.md │ │ │ ├── set-threshold.md │ │ │ └── value.md │ ├── enums.d.ts │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ │ ├── state.ts │ │ └── touch.ts │ ├── test.ts │ ├── touch.cpp │ ├── touch.h │ └── touch.ts ├── tsconfig.json └── wifi---esp32 │ ├── README.md │ ├── buildlogin.sh │ ├── ca-bundle.pem │ ├── certs.md │ ├── controller.ts │ ├── enums.d.ts │ ├── filter-bundle.js │ ├── httpserver.cpp │ ├── login.full.html │ ├── login.html │ ├── pxt.json │ ├── shims.d.ts │ ├── sim │ ├── tsconfig.json │ └── wifisockets.ts │ ├── socket.cpp │ ├── wifi.cpp │ └── wifi.h ├── package.json ├── pxtarget.json ├── scripts ├── font-compiler │ ├── README.md │ ├── font-compiler.js │ ├── fromttf │ │ ├── README.md │ │ ├── bitmap-font-generator-config.bmfc │ │ ├── filter-from-font12.js │ │ ├── fnt2txt.js │ │ ├── font12.txt │ │ ├── freq-jp.txt │ │ ├── freq-sc.txt │ │ ├── freq-uni.txt │ │ └── gentext.js │ └── src │ │ ├── font5.txt │ │ ├── font8.txt │ │ ├── xorg-fixed-5x7.txt │ │ └── xorg-fixed-6x8.txt ├── raffs │ ├── CodalDevice.h │ ├── CodalDmesg.h │ ├── Makefile │ ├── MessageBus.h │ ├── NotifyEvents.h │ ├── raffs-test.cpp │ └── raffs-test.h ├── revfont.js └── snorfs │ ├── CodalDevice.h │ ├── CodalDmesg.h │ ├── Makefile │ ├── README.md │ ├── SNORFS-test.cpp │ └── SNORFS-test.h └── sim └── tsconfig.json /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | IndentWidth: 4 3 | UseTab: Never 4 | ColumnLimit: 100 5 | AllowShortFunctionsOnASingleLine: Inline 6 | SortIncludes: false 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # enforce unix style line endings 2 | *.ts text eol=lf 3 | *.tsx text eol=lf 4 | *.cpp text eol=lf 5 | *.h text eol=lf 6 | *.jres text eol=lf 7 | *.asm text eol=lf 8 | *.md text eol=lf 9 | *.txt text eol=lf 10 | *.js text eol=lf 11 | *.json text eol=lf 12 | *.xml text eol=lf 13 | *.svg text eol=lf 14 | *.yaml text eol=lf 15 | *.css text eol=lf 16 | *.html text eol=lf 17 | *.py text eol=lf 18 | *.exp text eol=lf 19 | *.manifest text eol=lf 20 | 21 | # do not enforce text for everything - it causes issues with random binary files 22 | 23 | *.sln text eol=crlf 24 | 25 | *.png binary 26 | *.jpg binary 27 | *.jpeg binary 28 | *.gif binary 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yotta_modules 3 | yotta_targets 4 | pxt_modules 5 | built 6 | typings 7 | tmp 8 | temp 9 | .vscode 10 | 11 | *.user 12 | *.sw? 13 | *.ts.new 14 | *.tgz 15 | *.db 16 | *.suo 17 | *.log 18 | .pioenvs 19 | .piolibdeps 20 | lib/ 21 | projects/ 22 | _locales/ 23 | libpxt.a 24 | test 25 | scripts/snorfs/stest* 26 | scripts/raffs/stest* 27 | package-lock.json 28 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "avoid", 3 | "semi": true, 4 | "tabWidth": 4 5 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MakeCode Common packages 2 | 3 | A set of packages used in various MakeCode editors such as https://arcade.makecode.com, https://makecode.adafruit.com, https://maker.makecode.com https://makecode.microbit.org, etc... 4 | 5 | ## Contributing 6 | 7 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 8 | -------------------------------------------------------------------------------- /cpptests/screen/Makefile: -------------------------------------------------------------------------------- 1 | T = ../../libs 2 | CFLAGS = -ffunction-sections -fno-rtti -fno-exceptions -std=c++11 \ 3 | -W -Wall -Wno-unused-const-variable \ 4 | -g -O3 \ 5 | -DX86_64 -I. -I$(T)/base 6 | PXT_SRC = $(T)/screen/image.cpp \ 7 | $(T)/base/pxt.cpp \ 8 | $(T)/base/core.cpp \ 9 | 10 | all: inner 11 | 12 | docker: 13 | docker run --rm -it -v $$PWD/../..:/src -w /src/cpptests/screen -u build pext/yotta make inner 14 | 15 | build: 16 | rm -f libpxt.a 17 | gcc $(CFLAGS) -c $(PXT_SRC) 18 | ar r libpxt.a *.o 19 | rm -f *.o 20 | gcc $(CFLAGS) -o test imgtest.cpp -L. -lpxt 21 | 22 | inner: build 23 | @echo; echo Testing...; echo 24 | @./test || : 25 | @echo 26 | @rm -rf libpxt.a test test.dSYM 27 | -------------------------------------------------------------------------------- /cpptests/screen/TODO.md: -------------------------------------------------------------------------------- 1 | ## PXT TODO 2 | 3 | * [x] emit buffers with 32 bit length 4 | * [x] fix @f4 encoding 5 | * [x] fix memcpy 6 | -------------------------------------------------------------------------------- /cpptests/screen/platform.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/cpptests/screen/platform.h -------------------------------------------------------------------------------- /cpptests/screen/pxt.h: -------------------------------------------------------------------------------- 1 | #ifndef __PXT_H 2 | #define __PXT_H 3 | 4 | #include "pxtbase.h" 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /cpptests/screen/pxtconfig.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/cpptests/screen/pxtconfig.h -------------------------------------------------------------------------------- /cpptests/screen/pxtcore.h: -------------------------------------------------------------------------------- 1 | #ifndef __PXTCORE_H 2 | #define __PXTCORE_H 3 | 4 | #include 5 | #include 6 | 7 | #define ramint_t uint32_t 8 | #define IMAGE_BITS 4 9 | 10 | #define DMESG(...) do { printf(__VA_ARGS__); printf("\n"); } while(0) 11 | 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /docs/static/libs/datalogger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/docs/static/libs/datalogger.png -------------------------------------------------------------------------------- /docs/static/libs/gamepad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/docs/static/libs/gamepad.png -------------------------------------------------------------------------------- /docs/static/libs/keyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/docs/static/libs/keyboard.png -------------------------------------------------------------------------------- /docs/static/libs/lora.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/docs/static/libs/lora.png -------------------------------------------------------------------------------- /docs/static/libs/mouse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/docs/static/libs/mouse.png -------------------------------------------------------------------------------- /docs/static/libs/radio-broadcast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/docs/static/libs/radio-broadcast.png -------------------------------------------------------------------------------- /docs/static/libs/radio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/docs/static/libs/radio.png -------------------------------------------------------------------------------- /docs/static/libs/servo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/docs/static/libs/servo.png -------------------------------------------------------------------------------- /docs/static/libs/storage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/docs/static/libs/storage.png -------------------------------------------------------------------------------- /libs/accelerometer/README.md: -------------------------------------------------------------------------------- 1 | # accelerometer 2 | 3 | The accelerometer library. 4 | 5 | -------------------------------------------------------------------------------- /libs/accelerometer/axis.h: -------------------------------------------------------------------------------- 1 | // Override in target to change inversion of axis 2 | 3 | #define ACC_SYSTEM NORTH_EAST_UP 4 | #define ACC_UPSIDEDOWN false 5 | #define ACC_ROTATION COORDINATE_SPACE_ROTATED_0 6 | -------------------------------------------------------------------------------- /libs/accelerometer/docs/reference/input.md: -------------------------------------------------------------------------------- 1 | # @extends 2 | 3 | ## #accelerometer 4 | 5 | ```cards 6 | input.acceleration(Dimension.X); 7 | input.onGesture(Gesture.Shake, () => { 8 | 9 | }); 10 | input.rotation(Rotation.Pitch); 11 | input.setAccelerometerRange(AcceleratorRange.OneG); 12 | ``` 13 | 14 | ```package 15 | accelerometer 16 | ``` 17 | -------------------------------------------------------------------------------- /libs/accelerometer/ns.ts: -------------------------------------------------------------------------------- 1 | 2 | //% color="#B4009E" weight=98 icon="\uf192" 3 | namespace input { 4 | } -------------------------------------------------------------------------------- /libs/accelerometer/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "accelerometer", 3 | "description": "The accelerometer library", 4 | "files": [ 5 | "README.md", 6 | "accelerometer.cpp", 7 | "accelhw.cpp", 8 | "axis.h", 9 | "gesture.ts", 10 | "shims.d.ts", 11 | "enums.d.ts", 12 | "ns.ts", 13 | "pxtparts.json", 14 | "part.svg" 15 | ], 16 | "testFiles": [ 17 | "test.ts" 18 | ], 19 | "public": true, 20 | "dependencies": { 21 | "core": "file:../core" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /libs/accelerometer/sim/state.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim { 2 | export interface AccelerometerBoard extends CommonBoard { 3 | accelerometerState: AccelerometerState; 4 | invertAccelerometerXAxis?: boolean; 5 | invertAccelerometerYAxis?: boolean; 6 | invertAccelerometerZAxis?: boolean; 7 | } 8 | 9 | export function accelerometer(): AccelerometerState { 10 | return (board() as AccelerometerBoard).accelerometerState; 11 | } 12 | } -------------------------------------------------------------------------------- /libs/accelerometer/test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/accelerometer/test.ts -------------------------------------------------------------------------------- /libs/animation/README.md: -------------------------------------------------------------------------------- 1 | # Animations 2 | 3 | A small animation library. -------------------------------------------------------------------------------- /libs/animation/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "animation", 3 | "description": "Advanced state based animations for sprites", 4 | "files": [ 5 | "README.md", 6 | "legacy.ts", 7 | "targetoverrides.ts" 8 | ], 9 | "testFiles": [ 10 | "test.ts" 11 | ], 12 | "public": true, 13 | "dependencies": { 14 | "game": "file:../game" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /libs/animation/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // TODO any platform specific overrides -------------------------------------------------------------------------------- /libs/azureiot/README.md: -------------------------------------------------------------------------------- 1 | # Azure IoT support - beta 2 | 3 | Azure MQTT communication layer. 4 | A port of https://github.com/rovale/micro-mqtt for MakeCode. 5 | 6 | ## Settings 7 | 8 | The connection string should be stored in the "azureiot" secret in the settings. -------------------------------------------------------------------------------- /libs/azureiot/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "azureiot", 3 | "description": "Azure IoT - beta", 4 | "files": [ 5 | "azureiot.ts", 6 | "README.md" 7 | ], 8 | "testFiles": [ 9 | "test.ts" 10 | ], 11 | "public": true, 12 | "dependencies": { 13 | "mqtt": "file:../mqtt", 14 | "settings": "file:../settings" 15 | }, 16 | "testDependencies": { 17 | "esp32": "file:../esp32" 18 | } 19 | } -------------------------------------------------------------------------------- /libs/azureiot/test.ts: -------------------------------------------------------------------------------- 1 | function test() { 2 | 3 | const log = console.log; 4 | const esp = net.instance().controller(); 5 | 6 | if (!esp.connect()) { 7 | log("can't connect") 8 | return 9 | } 10 | 11 | log("ping: " + esp.ping("bing.com")) 12 | 13 | azureiot.connect() 14 | log("mqtt connected") 15 | 16 | azureiot.onMessageReceived((msg) => { 17 | log("MSG:" + JSON.stringify(msg)) 18 | }) 19 | 20 | azureiot.onMethod("echo", msg => { 21 | log("ECHO " + msg.displayedValue) 22 | msg.type = "echo" 23 | return {} 24 | }) 25 | } 26 | 27 | test(); -------------------------------------------------------------------------------- /libs/base/README.md: -------------------------------------------------------------------------------- 1 | # base 2 | 3 | The base library, shared by all C++ targets (not only Codal-based). 4 | 5 | 6 | -------------------------------------------------------------------------------- /libs/base/advmath.cpp: -------------------------------------------------------------------------------- 1 | #include "pxtbase.h" 2 | 3 | using namespace std; 4 | 5 | #define SINGLE(op) return fromDouble(::op(toDouble(x))); 6 | 7 | namespace Math_ { 8 | 9 | //% 10 | TNumber log2(TNumber x){SINGLE(log2)} 11 | //% 12 | TNumber exp(TNumber x){SINGLE(exp)} 13 | //% 14 | TNumber tanh(TNumber x){SINGLE(tanh)} 15 | //% 16 | TNumber sinh(TNumber x){SINGLE(sinh)} 17 | //% 18 | TNumber cosh(TNumber x){SINGLE(cosh)} 19 | //% 20 | TNumber atanh(TNumber x){SINGLE(atanh)} 21 | //% 22 | TNumber asinh(TNumber x){SINGLE(asinh)} 23 | //% 24 | TNumber acosh(TNumber x){SINGLE(acosh)} 25 | 26 | } -------------------------------------------------------------------------------- /libs/base/docs/reference/console.md: -------------------------------------------------------------------------------- 1 | # Console 2 | 3 | Output text and data values to the console. 4 | 5 | ```cards 6 | console.log(""); 7 | console.logValue("x", 0); 8 | ``` 9 | 10 | ## See also 11 | 12 | [log](/reference/console/log), 13 | [log value](/reference/console/log-value) -------------------------------------------------------------------------------- /libs/base/docs/reference/control.md: -------------------------------------------------------------------------------- 1 | # Control 2 | 3 | Program controls and events. 4 | 5 | ```cards 6 | control.millis(); 7 | control.runInParallel(() => { 8 | 9 | }); 10 | control.reset(); 11 | control.waitMicros(4); 12 | control.deviceSerialNumber(); 13 | ``` 14 | 15 | ## Advanced #advanced 16 | 17 | ```cards 18 | control.raiseEvent(0, 0); 19 | control.onEvent(0, 0, () => { 20 | 21 | }); 22 | control.assert(false, 0); 23 | control.deviceDalVersion(); 24 | control.panic(0); 25 | ``` 26 | -------------------------------------------------------------------------------- /libs/base/docs/reference/control/device-dal-version.md: -------------------------------------------------------------------------------- 1 | # device Dal Version 2 | 3 | Get the version information for the system software on the @boardname@. 4 | 5 | ```sig 6 | control.deviceDalVersion() 7 | ``` 8 | 9 | ## Returns 10 | 11 | * a [string](/types/string) that represents the version of the system software (DAL) on the board. 12 | 13 | Returns `"sim"` when running the simulator, and `"linux"` when running on Raspberry Pi. 14 | 15 | ## Example #example 16 | 17 | Write the system software version to the serial port. 18 | 19 | ```blocks 20 | serial.writeLine("DAL version = " + control.deviceDalVersion()); 21 | ``` 22 | 23 | ## See also #seealso 24 | 25 | [device serial number](/reference/control/device-serial-number) 26 | -------------------------------------------------------------------------------- /libs/base/docs/reference/control/device-serial-number.md: -------------------------------------------------------------------------------- 1 | # device Serial Number 2 | 3 | Get the serial number for the @boardname@ 4 | 5 | ```sig 6 | control.deviceSerialNumber() 7 | ``` 8 | 9 | The system software in your board creates a unique number to identify the board. You can use this number in your program if you want to know which board is running your program. 10 | 11 | ## Returns 12 | 13 | * a [number](/types/number) that is created to uniquely identify this board. 14 | 15 | ## Example #example 16 | 17 | Write the board serial number to the serial port. 18 | 19 | ```blocks 20 | serial.writeValue("serialnumber", control.deviceSerialNumber()); 21 | ``` 22 | 23 | ## See also #seealso 24 | 25 | [device dal version](/reference/control/device-dal-version) -------------------------------------------------------------------------------- /libs/base/docs/reference/control/millis.md: -------------------------------------------------------------------------------- 1 | # millis 2 | 3 | Get the number of milliseconds of time passed since the board was turned on. 4 | 5 | ```sig 6 | control.millis() 7 | ``` 8 | 9 | ## Returns 10 | 11 | * the [number](/types/number) of milliseconds of time since the board was turned on. 12 | 13 | ## Example #example 14 | 15 | Find how many days, hours, minutes, and seconds the @boardname@ has been running. 16 | 17 | ```blocks 18 | let msecs = control.millis() 19 | let seconds = msecs / 1000 20 | let mins = seconds / 60 21 | let hours = mins / 60 22 | let days = hours / 24 23 | ``` 24 | 25 | ## #seealso -------------------------------------------------------------------------------- /libs/base/docs/reference/control/reset.md: -------------------------------------------------------------------------------- 1 | # reset 2 | 3 | Reset the board and start the program from the beginning. 4 | 5 | ```sig 6 | control.reset() 7 | ``` 8 | 9 | Everything that the program did with the board is set back to the way it was before the 10 | program started. The program starts over again from the beginning. 11 | 12 | ## Example #example 13 | 14 | Reset the board and begin again. 15 | 16 | ```blocks 17 | control.reset() 18 | ``` 19 | 20 | ## #seealso -------------------------------------------------------------------------------- /libs/base/docs/reference/control/run-in-background.md: -------------------------------------------------------------------------------- 1 | # run In Background 2 | 3 | This function is deprecated and replaced by [run in parallel](/reference/control/run-in-parallel). -------------------------------------------------------------------------------- /libs/base/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum NumberFormat { 5 | Int8LE = 1, 6 | UInt8LE = 2, 7 | Int16LE = 3, 8 | UInt16LE = 4, 9 | Int32LE = 5, 10 | Int8BE = 6, 11 | UInt8BE = 7, 12 | Int16BE = 8, 13 | UInt16BE = 9, 14 | Int32BE = 10, 15 | 16 | UInt32LE = 11, 17 | UInt32BE = 12, 18 | Float32LE = 13, 19 | Float64LE = 14, 20 | Float32BE = 15, 21 | Float64BE = 16, 22 | } 23 | 24 | 25 | declare const enum PerfCounters { 26 | GC = 0, 27 | } 28 | 29 | // Auto-generated. Do not edit. Really. 30 | -------------------------------------------------------------------------------- /libs/base/forever.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Repeats the code forever in the background. On each iteration, allows other codes to run. 3 | * @param body code to execute 4 | */ 5 | //% help=loops/forever weight=100 afterOnStart=true blockNamespace="loops" 6 | //% blockId=forever block="forever" blockAllowMultiple=1 7 | function forever(a: () => void): void { 8 | loops.forever(a); 9 | } 10 | 11 | // micro:bit compatibility 12 | // these functions allow some level of reuse 13 | // between micro:bit and other maker-style editors 14 | namespace basic { 15 | export function forever(a: () => void) { 16 | loops.forever(a); 17 | } 18 | } -------------------------------------------------------------------------------- /libs/base/loops.cpp: -------------------------------------------------------------------------------- 1 | #include "pxtbase.h" 2 | 3 | namespace loops { 4 | 5 | /** 6 | * Repeats the code forever in the background. On each iteration, allows other codes to run. 7 | * @param body code to execute 8 | */ 9 | //% help=loops/forever weight=100 afterOnStart=true deprecated=true 10 | //% blockId=forever_deprecated block="forever" blockAllowMultiple=1 11 | void forever(Action a) { 12 | runForever(a); 13 | } 14 | 15 | /** 16 | * Pause for the specified time in milliseconds 17 | * @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000 18 | */ 19 | //% help=loops/pause weight=99 deprecated=true 20 | //% async block="pause %pause=timePicker|ms" 21 | //% blockId=device_pause_deprecated 22 | void pause(int ms) { 23 | if (ms < 0) return; 24 | sleep_ms(ms); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /libs/base/ns.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Respond to and read data from buttons and sensors. 4 | */ 5 | //% color="#B4009E" weight=98 icon="\uf192" 6 | namespace input { 7 | } 8 | -------------------------------------------------------------------------------- /libs/base/pause.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Pause for the specified time in milliseconds 3 | * @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000 4 | */ 5 | //% help=loops/pause weight=99 6 | //% async block="pause %pause=timePicker|ms" 7 | //% blockId=device_pause blockNamespace="loops" 8 | function pause(ms: number): void { 9 | loops.pause(ms); 10 | } 11 | 12 | // micro:bit compatibility 13 | // these functions allow some level of reuse 14 | // between micro:bit and other maker-style editors 15 | namespace basic { 16 | export function pause(millis: number) { 17 | loops.pause(millis); 18 | } 19 | } -------------------------------------------------------------------------------- /libs/base/perfcounters.ts: -------------------------------------------------------------------------------- 1 | namespace control { 2 | /** 3 | * Enable profiling for current function. 4 | */ 5 | //% shim=TD_NOOP shimArgument=perfCounter 6 | export function enablePerfCounter(name?: string) { } 7 | 8 | /** 9 | * Dump values of profiling performance counters. 10 | */ 11 | //% shim=pxt::dumpPerfCounters 12 | export function dmesgPerfCounters() { } 13 | } 14 | -------------------------------------------------------------------------------- /libs/base/sim/cfg.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim { 2 | export interface EdgeConnectorBoard { 3 | edgeConnectorState: EdgeConnectorState; 4 | } 5 | } 6 | 7 | namespace pxsim.pxtcore { 8 | export function getPin(id: number): pxsim.Pin { 9 | const b = board() as EdgeConnectorBoard; 10 | if (b && b.edgeConnectorState) 11 | return b.edgeConnectorState.getPin(id); 12 | return undefined; 13 | } 14 | export function lookupPinCfg(key: number): pxsim.Pin { 15 | return getPinCfg(key); 16 | } 17 | export function getPinCfg(key: number): pxsim.Pin { 18 | return getPin(getConfig(key, -1)) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /libs/base/sim/core.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | namespace pxsim { 4 | export interface CommonBoard extends CoreBoard 5 | , EdgeConnectorBoard, EventBusBoard { 6 | bus: EventBus; 7 | buttonState: CommonButtonState; 8 | edgeConnectorState: EdgeConnectorState; 9 | } 10 | 11 | export function board(): CommonBoard { 12 | return runtime && runtime.board as CommonBoard; 13 | } 14 | } -------------------------------------------------------------------------------- /libs/base/sim/loops.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim.loops { 2 | export let pause = thread.pause; 3 | export let forever = thread.forever; 4 | } -------------------------------------------------------------------------------- /libs/base/sim/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "noImplicitAny": true, 5 | "noImplicitReturns": true, 6 | "lib": [ 7 | "DOM", 8 | "DOM.Iterable", 9 | "ES2017" 10 | ], 11 | "rootDir": ".", 12 | "newLine": "LF", 13 | "sourceMap": false 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /libs/base/templates.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Tagged hex literal converter 3 | */ 4 | //% shim=@hex 5 | function hex(lits: any, ...args: any[]): Buffer { return null } 6 | -------------------------------------------------------------------------------- /libs/base/test.ts: -------------------------------------------------------------------------------- 1 | let i = 1 2 | let f = 0.5 3 | let plus = i + f 4 | let minus = i - f 5 | 6 | let r = Math.random() 7 | let ri = Math.randomRange(5, 10) 8 | 9 | 10 | function check(cond:boolean) { control.assert(cond, 108) } 11 | 12 | check(Buffer.pack("<2h", [0x3412, 0x7856]).toHex() == "12345678") 13 | check(Buffer.pack(">hh", [0x3412, 0x7856]).toHex() == "34127856") 14 | check(Buffer.fromHex("F00d").toHex() == "f00d") -------------------------------------------------------------------------------- /libs/base/trig.cpp: -------------------------------------------------------------------------------- 1 | #include "pxtbase.h" 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | namespace Math_ { 8 | 9 | #define SINGLE(op) return fromDouble(::op(toDouble(x))); 10 | 11 | //% 12 | TNumber atan2(TNumber y, TNumber x) { 13 | return fromDouble(::atan2(toDouble(y), toDouble(x))); 14 | } 15 | 16 | //% 17 | TNumber tan(TNumber x){SINGLE(tan)} 18 | 19 | //% 20 | TNumber sin(TNumber x){SINGLE(sin)} 21 | 22 | //% 23 | TNumber cos(TNumber x){SINGLE(cos)} 24 | 25 | //% 26 | TNumber atan(TNumber x){SINGLE(atan)} 27 | 28 | //% 29 | TNumber asin(TNumber x){SINGLE(asin)} 30 | 31 | //% 32 | TNumber acos(TNumber x){SINGLE(acos)} 33 | 34 | //% 35 | TNumber sqrt(TNumber x){SINGLE(sqrt)} 36 | 37 | } -------------------------------------------------------------------------------- /libs/browser-events/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "browser-events", 3 | "description": "A package for interacting with browser-only functionality like keyboard and mouse events", 4 | "files": [ 5 | "browserEvents.cpp", 6 | "browserEvents.ts", 7 | "keyboard.ts", 8 | "shims.d.ts" 9 | ], 10 | "public": true, 11 | "dependencies": { 12 | "core": "file:../core" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /libs/browser-events/sim/browserEvent.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim.browserEvents { 2 | export function mouseX() { 3 | return (pxsim.board() as BrowserEventsBoard).mouseState.mouseX(); 4 | } 5 | 6 | export function mouseY() { 7 | return (pxsim.board() as BrowserEventsBoard).mouseState.mouseY(); 8 | } 9 | 10 | export function wheelDx() { 11 | return (pxsim.board() as BrowserEventsBoard).mouseState.wheelDx(); 12 | } 13 | 14 | export function wheelDy() { 15 | return (pxsim.board() as BrowserEventsBoard).mouseState.wheelDy(); 16 | } 17 | 18 | export function wheelDz() { 19 | return (pxsim.board() as BrowserEventsBoard).mouseState.wheelDz(); 20 | } 21 | } -------------------------------------------------------------------------------- /libs/buttons/README.md: -------------------------------------------------------------------------------- 1 | # buttons 2 | 3 | A library to handle 2 buttons A and B. 4 | -------------------------------------------------------------------------------- /libs/buttons/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | /** 5 | * User interaction on buttons 6 | */ 7 | 8 | declare const enum ButtonEvent { 9 | //% block="click" 10 | Click = 3, // DEVICE_BUTTON_EVT_CLICK 11 | //% block="long click" 12 | LongClick = 4, // DEVICE_BUTTON_EVT_LONG_CLICK 13 | //% block="up" 14 | Up = 2, // DEVICE_BUTTON_EVT_UP 15 | //% block="down" 16 | Down = 1, // DEVICE_BUTTON_EVT_DOWN 17 | } 18 | 19 | // Auto-generated. Do not edit. Really. 20 | -------------------------------------------------------------------------------- /libs/buttons/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "buttons", 3 | "description": "Button A and B drivers", 4 | "files": [ 5 | "README.md", 6 | "buttons.cpp", 7 | "shims.d.ts", 8 | "enums.d.ts" 9 | ], 10 | "testFiles": [ 11 | "test.ts" 12 | ], 13 | "public": true, 14 | "dependencies": { 15 | "core": "file:../core" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /libs/buttons/test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/buttons/test.ts -------------------------------------------------------------------------------- /libs/cable/README.md: -------------------------------------------------------------------------------- 1 | # cable 2 | 3 | The Cable library. 4 | 5 | -------------------------------------------------------------------------------- /libs/cable/docs/reference/network.md: -------------------------------------------------------------------------------- 1 | # Network #network 2 | 3 | Send and receive data between your @boardname@ and another board. 4 | 5 | ## Cable #cable 6 | 7 | ```cards 8 | network.cableSendNumber(0); 9 | network.onCableReceivedNumber(function (num) { 10 | 11 | }) 12 | ``` 13 | 14 | ## #infrared 15 | 16 | ## See also 17 | 18 | [cable send number](/reference/network/cable-send-number), 19 | [on cable received number](/reference/network/on-cable-received-number) 20 | 21 | ### #cableseealso 22 | 23 | ```package 24 | cable 25 | ``` 26 | -------------------------------------------------------------------------------- /libs/cable/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cable", 3 | "description": "Communication over Wire", 4 | "files": [ 5 | "README.md", 6 | "cable.cpp", 7 | "cable.ts", 8 | "shims.d.ts" 9 | ], 10 | "public": true, 11 | "dependencies": { 12 | "core": "file:../core", 13 | "pulse": "file:../pulse" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /libs/cable/shims.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | declare namespace network { 3 | 4 | /** 5 | * Send data over cable. 6 | */ 7 | //% parts="cable" shim=network::cableSendPacket 8 | function cableSendPacket(buf: Buffer): void; 9 | 10 | /** 11 | * Get most recent packet received over cable. 12 | */ 13 | //% parts="cable" shim=network::cablePacket 14 | function cablePacket(): Buffer; 15 | 16 | /** 17 | * Run action after a packet is recieved over cable. 18 | */ 19 | //% parts="cable" shim=network::onCablePacket 20 | function onCablePacket(body: () => void): void; 21 | 22 | /** 23 | * Run action after there's an error reciving packet over cable. 24 | */ 25 | //% shim=network::onCableError 26 | function onCableError(body: () => void): void; 27 | } 28 | 29 | // Auto-generated. Do not edit. Really. 30 | -------------------------------------------------------------------------------- /libs/cable/sim/cable.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim.network { 2 | export function cableSendPacket(buf: RefBuffer): void { 3 | const state = getCableState(); 4 | state.send(buf); 5 | } 6 | 7 | export function cablePacket() : RefBuffer { 8 | const state = getCableState(); 9 | return (state.packet); 10 | } 11 | 12 | export function onCablePacket(body: RefAction): void { 13 | const state = getCableState(); 14 | state.listen(body); 15 | } 16 | 17 | export function onCableError(body: RefAction): void { 18 | const state = getCableState(); 19 | state.listenError(body); 20 | } 21 | } -------------------------------------------------------------------------------- /libs/color-coded-tilemap/README.md: -------------------------------------------------------------------------------- 1 | # Color-coded Tilemap 2 | 3 | Blocks for the color-coded tilemap. -------------------------------------------------------------------------------- /libs/color-coded-tilemap/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "color-coded-tilemap", 3 | "description": "Blocks for the color-coded tilemap", 4 | "files": [ 5 | "README.md", 6 | "tilemap.ts" 7 | ], 8 | "public": true, 9 | "dependencies": { 10 | "game": "file:../game" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /libs/color-sensor/README.md: -------------------------------------------------------------------------------- 1 | # Color Sensor 2 | 3 | Ambient light sensor -------------------------------------------------------------------------------- /libs/color-sensor/colorsensor.ts: -------------------------------------------------------------------------------- 1 | namespace sensors { 2 | export interface ColorSensor { 3 | /** 4 | * Reads an RGB color from the sensor 5 | */ 6 | color(): number; 7 | } 8 | } 9 | 10 | namespace input { 11 | let _colorSensor: sensors.ColorSensor; 12 | 13 | /** 14 | * Uses a color sensor to capture the ambient color as a RGB value. 15 | */ 16 | //% blockId=sensor_lightcolor block="light color" 17 | //% group="Color Sensor" 18 | export function lightColor(): number { 19 | if (!_colorSensor) 20 | _colorSensor = new sensors.TCS34725(); 21 | return _colorSensor.color(); 22 | } 23 | } -------------------------------------------------------------------------------- /libs/color-sensor/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "color-sensor", 3 | "description": "Color sensor (TCS24725)", 4 | "files": [ 5 | "README.md", 6 | "colorsensor.ts", 7 | "tcs34725.ts" 8 | ], 9 | "testFiles": [ 10 | "test.ts" 11 | ], 12 | "public": true, 13 | "dependencies": { 14 | "core": "file:../core" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /libs/color-sensor/test.ts: -------------------------------------------------------------------------------- 1 | // tests 2 | -------------------------------------------------------------------------------- /libs/color/README.md: -------------------------------------------------------------------------------- 1 | # Colors 2 | 3 | Color manipulation -------------------------------------------------------------------------------- /libs/color/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "color", 3 | "description": "Color manipulation", 4 | "files": [ 5 | "colors.ts", 6 | "colorbuffer.ts", 7 | "README.md" 8 | ], 9 | "public": true, 10 | "weight": 1, 11 | "dependencies": { 12 | "core": "file:../core" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /libs/controller---none/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "controller---none", 3 | "additionalFilePath": "../controller", 4 | "dependencies": { 5 | "core": "file:../core", 6 | "game": "file:../game" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /libs/controller/README.md: -------------------------------------------------------------------------------- 1 | # Controller 2 | 3 | Extra features for Aracde controllers 4 | -------------------------------------------------------------------------------- /libs/controller/controller.ts: -------------------------------------------------------------------------------- 1 | namespace controller { 2 | /** 3 | * Configures the timing of the on button repeat event for all of the controller buttons 4 | * @param delay number of milliseconds from when the button is pressed to when the repeat event starts firing, eg: 500 5 | * @param interval minimum number of milliseconds between calls to the button repeat event, eg: 30 6 | */ 7 | //% blockId=repeatDefaultDelayInterval block="set button repeat delay $delay ms interval $interval ms" 8 | //% weight=10 9 | //% group="Single Player" 10 | export function configureRepeatEventDefaults(delay: number, interval: number) { 11 | controller.setRepeatDefault(delay, interval); 12 | } 13 | } -------------------------------------------------------------------------------- /libs/controller/crank.ts: -------------------------------------------------------------------------------- 1 | namespace controller { 2 | /** 3 | * Gets the current position of the crank. 4 | */ 5 | //% blockId=controller_crank_position block="crank position" 6 | //% weight=29 blockGap=8 7 | //% group="Extras" 8 | export function crankPosition(): number { 9 | return controller.__internal.crankPosition(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /libs/controller/light.ts: -------------------------------------------------------------------------------- 1 | namespace controller { 2 | /** 3 | * Shows a color pulse 4 | * @param rgb RGB color of the LED 5 | */ 6 | //% blockId="ctrllightpulse" block="start light pulse %rgb=colorNumberPicker|for %duration=timePicker|ms" 7 | //% weight=80 blockGap=8 8 | //% group="Extras" 9 | export function startLightPulse(rgb: number, duration: number) { 10 | controller.__internal.startLightPulse(rgb, duration); 11 | } 12 | } 13 | 14 | //% advanced=true 15 | namespace light { 16 | 17 | } -------------------------------------------------------------------------------- /libs/controller/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "controller", 3 | "description": "Extra game controller functionalities", 4 | "files": [ 5 | "README.md", 6 | "state.ts", 7 | "vibration.ts", 8 | "accelerometer.ts", 9 | "lightsensor.ts", 10 | "thermometer.ts", 11 | "controller.ts", 12 | "light.ts", 13 | "crank.ts", 14 | "controllerimpl.ts" 15 | ], 16 | "public": true, 17 | "dependencies": { 18 | "core": "file:../core", 19 | "accelerometer": "file:../accelerometer", 20 | "lightsensor": "file:../lightsensor", 21 | "thermometer": "file:../thermometer", 22 | "game": "file:../game", 23 | "light": "file:../light", 24 | "rotary-encoder": "file:../rotary-encoder" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /libs/controller/thermometer.ts: -------------------------------------------------------------------------------- 1 | const enum ControllerTemperatureUnit { 2 | //% block="°C" 3 | Celsius = 0, 4 | //% block="°F" 5 | Fahrenheit = 1, 6 | } 7 | 8 | 9 | namespace controller { 10 | /** 11 | * Get the temperature in Celsius or Fahrenheit degrees. 12 | */ 13 | //% blockId=ctrltemperature block="temperature in %unit" 14 | //% parts="thermometer" 15 | //% weight=26 16 | //% group="Extras" 17 | export function temperature(unit: ControllerTemperatureUnit): number { 18 | return controller.__internal.temperature(unit); 19 | } 20 | } -------------------------------------------------------------------------------- /libs/controller/vibration.ts: -------------------------------------------------------------------------------- 1 | namespace controller { 2 | /** 3 | * Vibrates the controller for the given duration (in milli seconds) 4 | * @param millis 5 | */ 6 | //% blockId=ctrlvibrate block="vibrate $millis ms" 7 | //% millis.shadow=timePicker 8 | //% group="Extras" 9 | export function vibrate(millis: number) { 10 | controller.__internal.vibrate(millis); 11 | } 12 | } -------------------------------------------------------------------------------- /libs/core---esp32/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 4 | 5 | project(pxtapp) 6 | -------------------------------------------------------------------------------- /libs/core---esp32/Makefile: -------------------------------------------------------------------------------- 1 | all: certs/ca-bundle.pem 2 | LC_ALL=C.UTF-8 idf.py build 3 | base64 build/pxtapp.bin > build/pxtapp.b64 4 | 5 | include certs.mk 6 | -------------------------------------------------------------------------------- /libs/core---esp32/certs.mk: -------------------------------------------------------------------------------- 1 | certs/ca-bundle.pem: 2 | mkdir -p certs 3 | curl https://raw.githubusercontent.com/microsoft/pxt-common-packages/9e8fdb8fd6e21c096f1fe2340652473ddab05d7e/libs/wifi---esp32/ca-bundle.pem > $@ 4 | -------------------------------------------------------------------------------- /libs/core---esp32/codalemu.cpp: -------------------------------------------------------------------------------- 1 | #include "pxt.h" 2 | 3 | IRAM_ATTR void target_wait_us(uint32_t us) { 4 | int64_t later = esp_timer_get_time() + us; 5 | while (esp_timer_get_time() < later) { 6 | ; 7 | } 8 | } 9 | 10 | static portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED; 11 | int int_level; 12 | 13 | IRAM_ATTR void target_disable_irq() { 14 | vPortEnterCritical(&global_int_mux); 15 | int_level++; 16 | } 17 | 18 | IRAM_ATTR void target_enable_irq() { 19 | int_level--; 20 | vPortExitCritical(&global_int_mux); 21 | } 22 | -------------------------------------------------------------------------------- /libs/core---esp32/dmesg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifndef DMESG 6 | #ifdef __cplusplus 7 | extern "C" void dmesg(const char *fmt, ...); 8 | #define DMESG ::dmesg 9 | #else // not C++ 10 | void dmesg(const char *fmt, ...); 11 | #define DMESG dmesg 12 | #endif 13 | #endif 14 | -------------------------------------------------------------------------------- /libs/core---esp32/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum PulseValue { 5 | //% block=high 6 | High = 4, // DEVICE_PIN_EVT_PULSE_HI 7 | //% block=low 8 | Low = 5, // DEVICE_PIN_EVT_PULSE_LO 9 | } 10 | 11 | 12 | declare const enum PinEvent { 13 | //% block="pulse high" 14 | PulseHigh = 4, // DEVICE_PIN_EVT_PULSE_HI 15 | //% block="pulse low" 16 | PulseLow = 5, // DEVICE_PIN_EVT_PULSE_LO 17 | //% block="rise" 18 | Rise = 2, // DEVICE_PIN_EVT_RISE 19 | //% block="fall" 20 | Fall = 3, // DEVICE_PIN_EVT_FALL 21 | } 22 | 23 | 24 | declare const enum PinPullMode { 25 | //% block="down" 26 | PullDown = 0, 27 | //% block="up" 28 | PullUp = 1, 29 | //% block="none" 30 | PullNone = 2, 31 | } 32 | 33 | // Auto-generated. Do not edit. Really. 34 | -------------------------------------------------------------------------------- /libs/core---esp32/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_NEWLIB_ENABLE=y 2 | CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL=y 3 | CONFIG_NEWLIB_NANO_FORMAT= 4 | CONFIG_SSL_USING_MBEDTLS=y 5 | CONFIG_LWIP_IPV6=y 6 | CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y 7 | CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y 8 | CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certs" 9 | -------------------------------------------------------------------------------- /libs/core---esp32s2/Makefile: -------------------------------------------------------------------------------- 1 | all: certs/ca-bundle.pem 2 | LC_ALL=C.UTF-8 idf.py build 3 | base64 build/pxtapp.bin > build/pxtapp.b64 4 | 5 | include certs.mk -------------------------------------------------------------------------------- /libs/core---esp32s2/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum PulseValue { 5 | //% block=high 6 | High = 4, // DEVICE_PIN_EVT_PULSE_HI 7 | //% block=low 8 | Low = 5, // DEVICE_PIN_EVT_PULSE_LO 9 | } 10 | 11 | 12 | declare const enum PinEvent { 13 | //% block="pulse high" 14 | PulseHigh = 4, // DEVICE_PIN_EVT_PULSE_HI 15 | //% block="pulse low" 16 | PulseLow = 5, // DEVICE_PIN_EVT_PULSE_LO 17 | //% block="rise" 18 | Rise = 2, // DEVICE_PIN_EVT_RISE 19 | //% block="fall" 20 | Fall = 3, // DEVICE_PIN_EVT_FALL 21 | } 22 | 23 | 24 | declare const enum PinPullMode { 25 | //% block="down" 26 | PullDown = 0, 27 | //% block="up" 28 | PullUp = 1, 29 | //% block="none" 30 | PullNone = 2, 31 | } 32 | 33 | // Auto-generated. Do not edit. Really. 34 | -------------------------------------------------------------------------------- /libs/core---esp32s2/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "core---esp32s2", 3 | "additionalFilePath": "../core---esp32" 4 | } 5 | -------------------------------------------------------------------------------- /libs/core---esp32s2/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_TARGET="esp32s2" 2 | CONFIG_NEWLIB_ENABLE=y 3 | CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL=y 4 | CONFIG_NEWLIB_NANO_FORMAT= 5 | CONFIG_SSL_USING_MBEDTLS=y 6 | CONFIG_LWIP_IPV6=y 7 | CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y 8 | CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y 9 | CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certs" 10 | CONFIG_USB_ENABLED=y 11 | CONFIG_USB_CDC_ENABLED=y 12 | -------------------------------------------------------------------------------- /libs/core---linux/codalemu.cpp: -------------------------------------------------------------------------------- 1 | #include "pxt.h" 2 | #include 3 | 4 | namespace pxt { 5 | 6 | static pthread_mutex_t irqMutex; 7 | void target_disable_irq() { 8 | pthread_mutex_lock(&irqMutex); 9 | } 10 | void target_enable_irq() { 11 | pthread_mutex_unlock(&irqMutex); 12 | } 13 | 14 | } // namespace pxt 15 | 16 | -------------------------------------------------------------------------------- /libs/core---linux/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum PulseValue { 5 | //% block=high 6 | High = 4, // DEVICE_PIN_EVT_PULSE_HI 7 | //% block=low 8 | Low = 5, // DEVICE_PIN_EVT_PULSE_LO 9 | } 10 | 11 | 12 | declare const enum PinEvent { 13 | //% block="pulse high" 14 | PulseHigh = 4, // DEVICE_PIN_EVT_PULSE_HI 15 | //% block="pulse low" 16 | PulseLow = 5, // DEVICE_PIN_EVT_PULSE_LO 17 | //% block="rise" 18 | Rise = 2, // DEVICE_PIN_EVT_RISE 19 | //% block="fall" 20 | Fall = 3, // DEVICE_PIN_EVT_FALL 21 | } 22 | 23 | 24 | declare const enum PinPullMode { 25 | //% block="down" 26 | PullDown = 0, 27 | //% block="up" 28 | PullUp = 1, 29 | //% block="none" 30 | PullNone = 2, 31 | } 32 | 33 | // Auto-generated. Do not edit. Really. 34 | -------------------------------------------------------------------------------- /libs/core---linux/platform.cpp: -------------------------------------------------------------------------------- 1 | #include "pxt.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace pxt { 8 | 9 | static void initRandomSeed() { 10 | int seed = 0xC0DA1; 11 | int fd = open("/dev/urandom", O_RDONLY); 12 | read(fd, &seed, sizeof(seed)); 13 | close(fd); 14 | seedRandom(seed); 15 | } 16 | 17 | void sendSerial(const char *data, int len) { 18 | /* 19 | if (!serial) { 20 | serial = new codal::_mbed::Serial(USBTX, NC); 21 | serial->baud(9600); 22 | } 23 | serial->send((uint8_t*)data, len); 24 | */ 25 | } 26 | 27 | extern "C" void drawPanic(int code) 28 | { 29 | // TODO 30 | } 31 | 32 | 33 | extern "C" void target_init() 34 | { 35 | initRandomSeed(); 36 | } 37 | 38 | void updateScreen(Image_ img); 39 | 40 | void screen_init() { 41 | updateScreen(NULL); 42 | } 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /libs/core---linux/platform_includes.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define PROCESSOR_WORD_TYPE uintptr_t 9 | -------------------------------------------------------------------------------- /libs/core---linux/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "core---linux", 3 | "files": [ 4 | "README.md", 5 | "Makefile", 6 | "dal.d.ts", 7 | "linux.cpp", 8 | "config.cpp", 9 | "target.cpp", 10 | "pxt.h", 11 | "platform.h", 12 | "platform.cpp", 13 | "pxtcore.h", 14 | "pins.h", 15 | "control.cpp", 16 | "dmesg.cpp", 17 | "shims.d.ts", 18 | "enums.d.ts", 19 | "ns.ts", 20 | "timer.ts", 21 | "platform_includes.h", 22 | "codalemu.cpp", 23 | "pxtparts.json" 24 | ], 25 | "additionalFilePath": "../core" 26 | } -------------------------------------------------------------------------------- /libs/core---linux/pxtcore.h: -------------------------------------------------------------------------------- 1 | #ifndef __PXTCORE_H 2 | #define __PXTCORE_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace pxt { 9 | void *gcAllocBlock(size_t sz); 10 | void vm_stack_trace(); 11 | } 12 | 13 | extern "C" void dmesg(const char *fmt, ...); 14 | extern "C" void vdmesg(const char *format, va_list arg); 15 | #define DMESG ::dmesg 16 | 17 | static inline void itoa(int v, char *dst) { 18 | snprintf(dst, 30, "%d", v); 19 | } 20 | 21 | extern "C" void *xmalloc(size_t sz); 22 | #define xfree free 23 | 24 | #define GC_ALLOC_BLOCK gcAllocBlock 25 | 26 | #ifndef POKY 27 | // This seems to degrade performance - probably due to cache size 28 | //#define GC_BLOCK_SIZE (1024 * 64) 29 | #endif 30 | 31 | #define PXT_HARD_FLOAT 1 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libs/core---nrf52/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum PulseValue { 5 | //% block=high 6 | High = 4, // DEVICE_PIN_EVT_PULSE_HI 7 | //% block=low 8 | Low = 5, // DEVICE_PIN_EVT_PULSE_LO 9 | } 10 | 11 | 12 | declare const enum PinEvent { 13 | //% block="pulse high" 14 | PulseHigh = 4, // DEVICE_PIN_EVT_PULSE_HI 15 | //% block="pulse low" 16 | PulseLow = 5, // DEVICE_PIN_EVT_PULSE_LO 17 | //% block="rise" 18 | Rise = 2, // DEVICE_PIN_EVT_RISE 19 | //% block="fall" 20 | Fall = 3, // DEVICE_PIN_EVT_FALL 21 | } 22 | 23 | 24 | declare const enum PinPullMode { 25 | //% block="down" 26 | PullDown = 0, 27 | //% block="up" 28 | PullUp = 1, 29 | //% block="none" 30 | PullNone = 2, 31 | } 32 | 33 | // Auto-generated. Do not edit. Really. 34 | -------------------------------------------------------------------------------- /libs/core---nrf52/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "core---nrf52", 3 | "additionalFilePath": "../core" 4 | } 5 | -------------------------------------------------------------------------------- /libs/core---rp2040/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "core---rp2040", 3 | "additionalFilePath": "../core" 4 | } -------------------------------------------------------------------------------- /libs/core---samd/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum PulseValue { 5 | //% block=high 6 | High = 4, // DEVICE_PIN_EVT_PULSE_HI 7 | //% block=low 8 | Low = 5, // DEVICE_PIN_EVT_PULSE_LO 9 | } 10 | 11 | 12 | declare const enum PinEvent { 13 | //% block="pulse high" 14 | PulseHigh = 4, // DEVICE_PIN_EVT_PULSE_HI 15 | //% block="pulse low" 16 | PulseLow = 5, // DEVICE_PIN_EVT_PULSE_LO 17 | //% block="rise" 18 | Rise = 2, // DEVICE_PIN_EVT_RISE 19 | //% block="fall" 20 | Fall = 3, // DEVICE_PIN_EVT_FALL 21 | } 22 | 23 | 24 | declare const enum PinPullMode { 25 | //% block="down" 26 | PullDown = 0, 27 | //% block="up" 28 | PullUp = 1, 29 | //% block="none" 30 | PullNone = 2, 31 | } 32 | 33 | // Auto-generated. Do not edit. Really. 34 | -------------------------------------------------------------------------------- /libs/core---samd/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "core---samd", 3 | "additionalFilePath": "../core" 4 | } -------------------------------------------------------------------------------- /libs/core---stm32/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum PulseValue { 5 | //% block=high 6 | High = 4, // DEVICE_PIN_EVT_PULSE_HI 7 | //% block=low 8 | Low = 5, // DEVICE_PIN_EVT_PULSE_LO 9 | } 10 | 11 | 12 | declare const enum PinEvent { 13 | //% block="pulse high" 14 | PulseHigh = 4, // DEVICE_PIN_EVT_PULSE_HI 15 | //% block="pulse low" 16 | PulseLow = 5, // DEVICE_PIN_EVT_PULSE_LO 17 | //% block="rise" 18 | Rise = 2, // DEVICE_PIN_EVT_RISE 19 | //% block="fall" 20 | Fall = 3, // DEVICE_PIN_EVT_FALL 21 | } 22 | 23 | 24 | declare const enum PinPullMode { 25 | //% block="down" 26 | PullDown = 0, 27 | //% block="up" 28 | PullUp = 1, 29 | //% block="none" 30 | PullNone = 2, 31 | } 32 | 33 | // Auto-generated. Do not edit. Really. 34 | -------------------------------------------------------------------------------- /libs/core---stm32/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "core---stm32", 3 | "additionalFilePath": "../core" 4 | } -------------------------------------------------------------------------------- /libs/core---vm/config.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/core---vm/keys.cpp: -------------------------------------------------------------------------------- 1 | #include "pxt.h" 2 | 3 | namespace pxt { 4 | void initKeys() {} 5 | 6 | //% expose 7 | int pressureLevelByButtonId(int btnId, int codalId) { 8 | return 0; // TODO 9 | } 10 | 11 | //% expose 12 | void setupButton(int buttonId, int key) { 13 | (void)buttonId; 14 | (void)key; 15 | // not needed on RPi 16 | } 17 | 18 | } // namespace pxt -------------------------------------------------------------------------------- /libs/core---vm/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "core---vm", 3 | "files": [ 4 | "README.md", 5 | "Makefile", 6 | "dal.d.ts", 7 | "scheduler.cpp", 8 | "config.cpp", 9 | "target.cpp", 10 | "pxt.h", 11 | "platform.h", 12 | "platform.cpp", 13 | "pxtcore.h", 14 | "pins.h", 15 | "control.cpp", 16 | "shims.d.ts", 17 | "enums.d.ts", 18 | "ns.ts", 19 | "timer.ts", 20 | "platform_includes.h", 21 | "codalemu.cpp", 22 | "dmesg.cpp", 23 | "keys.cpp", 24 | "vm.cpp", 25 | "vmload.cpp", 26 | "vm.h", 27 | "vmcache.cpp", 28 | "verify.cpp", 29 | "pxtparts.json" 30 | ], 31 | "additionalFilePath": "../core---linux" 32 | } -------------------------------------------------------------------------------- /libs/core/README.md: -------------------------------------------------------------------------------- 1 | # core 2 | 3 | The core library for Codal-based targets. 4 | 5 | -------------------------------------------------------------------------------- /libs/core/dmac.cpp: -------------------------------------------------------------------------------- 1 | #include "dmac.h" 2 | 3 | namespace pxt { 4 | 5 | #ifdef CODAL_DMAC 6 | SINGLETON(WDMAC); 7 | #endif 8 | 9 | } -------------------------------------------------------------------------------- /libs/core/dmac.h: -------------------------------------------------------------------------------- 1 | #ifndef __DMAC_H 2 | #define __DMAC_H 3 | 4 | #include "pxt.h" 5 | 6 | namespace pxt { 7 | 8 | #ifdef CODAL_DMAC 9 | class WDMAC { 10 | public: 11 | CODAL_DMAC dmac; 12 | 13 | WDMAC() {} 14 | }; 15 | 16 | WDMAC* getWDMAC(); 17 | #endif 18 | 19 | } 20 | 21 | #endif -------------------------------------------------------------------------------- /libs/core/docs/device/simulator.md: -------------------------------------------------------------------------------- 1 | # Simulator 2 | 3 | The JavaScript simulator lets you run and test most @boardname@ programs in the browser. 4 | It simulates sensor inputs and user interactions. 5 | 6 | ## #example 7 | -------------------------------------------------------------------------------- /libs/core/docs/device/usb.md: -------------------------------------------------------------------------------- 1 | # Uploading programs on your @boardname@ 2 | 3 | While you're writing and testing your programs, you'll mostly be [running them 4 | in the simulator](/device/simulator), but once you've finished your program you 5 | can **compile** it and run it on your @boardname@. 6 | 7 | The basic steps are: 8 | 9 | 1. Connect your @boardname@ to your computer via USB 10 | 2. Press the reset button **once** and see that the **@drivename@** drive appears 11 | 2. Click **Download** and download the `.uf2` file 12 | 3. Copy the `.uf2` file from your computer onto the @drivename@ drive 13 | 14 | ### ~ hint 15 | 16 | In Microsoft Edge, Firefox and Internet Explorer, you can save the ``.uf2`` file directly into the @drivename@ drive! 17 | 18 | ### ~ 19 | 20 | ### ~hint 21 | 22 | Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting). 23 | 24 | ### ~ 25 | -------------------------------------------------------------------------------- /libs/core/docs/device/usb/troubleshooting.md: -------------------------------------------------------------------------------- 1 | # Troubleshooting Transfer 2 | 3 | ## No @drivename@ drive 4 | 5 | Make sure to press the reset button once when connected to turn on the @drivename@ drive. 6 | 7 | ## Multiple downloads 8 | 9 | You can’t drag and drop more than one ``.uf2`` file at once onto your @boardname@. If 10 | you try to drag and drop a second ``.uf2`` file onto your @boardname@ before the first 11 | file has finished downloading, then the second file may fail in different ways. 12 | -------------------------------------------------------------------------------- /libs/core/docs/reference/pins/create-i2c.md: -------------------------------------------------------------------------------- 1 | # create I2C 2 | 3 | Opens a I2C serial communication channel over the given pins. 4 | 5 | ```sig 6 | pins.createI2C(undefined, undefined); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * ``SDA`` pin 12 | * ``SCL`` pin 13 | 14 | ## Return 15 | 16 | A ``I2C`` instance that allows to interact with the bus directly. -------------------------------------------------------------------------------- /libs/core/docs/reference/pins/create-spi.md: -------------------------------------------------------------------------------- 1 | # create SPI 2 | 3 | Opens a SPI serial communication channel over the given pins. 4 | 5 | ```sig 6 | pins.createSPI(undefined, undefined); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * ``MOSI`` pin 12 | * ``MISO`` pin 13 | * ``SCK`` pin 14 | 15 | ## Return 16 | 17 | A ``SPI`` instance that allows to interact with the bus directly. -------------------------------------------------------------------------------- /libs/core/docs/reference/pins/spi-frequency.md: -------------------------------------------------------------------------------- 1 | # spi Frequency 2 | 3 | Set the SPI clock frequency. 4 | 5 | ```sig 6 | pins.spiFrequency(1000000); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **frequency**: a [number](/types/number) to set as the frequency for the SPI bus clock. This value is the number of clock changes per second (Hz). 12 | 13 | ## Example 14 | 15 | Set the SPI clock frequency to `1` megahertz. 16 | 17 | ```blocks 18 | pins.spiFrequency(1000000); 19 | ``` 20 | 21 | ## See also 22 | 23 | [spi mode](/reference/pins/spi-mode) 24 | -------------------------------------------------------------------------------- /libs/core/docs/reference/pins/spi-write.md: -------------------------------------------------------------------------------- 1 | # spi Write 2 | 3 | Write a single data value to an SPI slave device and return the response. 4 | 5 | ```sig 6 | pins.spiWrite(0); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * ``value``: a [number](/types/number) value to send to the SPI slave. 12 | 13 | ## Returns 14 | 15 | * a [number](/types/number) which is a response value from the SPI slave. 16 | 17 | ## Example 18 | 19 | Write the value of `16` to the SPI slave device. 20 | 21 | ```blocks 22 | let spiOK = pins.spiWrite(16); 23 | ``` 24 | 25 | ## See also 26 | 27 | [spi transfer](/reference/pins/spi-transfer) 28 | -------------------------------------------------------------------------------- /libs/core/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum PulseValue { 5 | //% block=high 6 | High = 4, // DEVICE_PIN_EVT_PULSE_HI 7 | //% block=low 8 | Low = 5, // DEVICE_PIN_EVT_PULSE_LO 9 | } 10 | 11 | 12 | declare const enum PinEvent { 13 | //% block="pulse high" 14 | PulseHigh = 4, // DEVICE_PIN_EVT_PULSE_HI 15 | //% block="pulse low" 16 | PulseLow = 5, // DEVICE_PIN_EVT_PULSE_LO 17 | //% block="rise" 18 | Rise = 2, // DEVICE_PIN_EVT_RISE 19 | //% block="fall" 20 | Fall = 3, // DEVICE_PIN_EVT_FALL 21 | } 22 | 23 | 24 | declare const enum PinPullMode { 25 | //% block="down" 26 | PullDown = 0, 27 | //% block="up" 28 | PullUp = 1, 29 | //% block="none" 30 | PullNone = 2, 31 | } 32 | 33 | // Auto-generated. Do not edit. Really. 34 | -------------------------------------------------------------------------------- /libs/core/hf2dbg.h: -------------------------------------------------------------------------------- 1 | #ifndef HF2DBG_H 2 | #define HF2DBG_H 1 3 | 4 | // we use a location at the top of the stack to store a magic value 5 | // which causes us to stop at the very first break point in the program 6 | #define HF2_DBG_MAGIC_PTR ((uint32_t *)(DEVICE_STACK_BASE - (DEVICE_STACK_SIZE - 4))) 7 | #define HF2_DBG_MAGIC_START 0xf0ebac7f 8 | 9 | #define HF2_DBG_GET_GLOBAL_STATE 0x53fc66e0 10 | struct HF2_GLOBAL_STATE_Result { 11 | uint32_t num_globals; 12 | uint32_t globals_addr; 13 | }; 14 | 15 | #define HF2_DBG_RESTART 0x1120bd93 16 | #define HF2_DBG_RESUME 0x27a55931 17 | #define HF2_EV_DBG_PAUSED 0x3692f9fd 18 | #define HF2_DBG_GET_STACK 0x70901510 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /libs/core/light.h: -------------------------------------------------------------------------------- 1 | #ifndef __PXT_LIGHT_H 2 | #define __PXT_LIGHT_H 3 | 4 | #include "pxt.h" 5 | 6 | namespace light { 7 | /** 8 | * Clear onboard neopixels 9 | */ 10 | void clear(); 11 | 12 | /** 13 | * Send a programmable light buffer to the specified digital pin 14 | * @param data The pin that the lights are connected to 15 | * @param clk the clock line if any 16 | * @param mode the color encoding mode 17 | * @param buf The buffer to send to the pin 18 | */ 19 | //% 20 | void sendBuffer(DigitalInOutPin data, DigitalInOutPin clk, int mode, Buffer buf); 21 | 22 | void neopixelSendData(DevicePin* pin, int mode, const uint8_t* data, unsigned length); 23 | } 24 | 25 | #endif -------------------------------------------------------------------------------- /libs/core/ns.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Events and data from sensors. 3 | */ 4 | //% color="#B4009E" weight=98 icon="\uf192" 5 | //% groups='["other", "More"]' 6 | namespace input { 7 | } 8 | 9 | /** 10 | * Servos 11 | */ 12 | //% color="#03AA74" weight=88 icon="\uf021" 13 | namespace servos { 14 | 15 | } 16 | 17 | /** 18 | * A Joint Asynchronous Communications, Device Agnostic Control. 19 | */ 20 | //% color="#E79251" weight=1 icon="\uf185" 21 | //% groups='["Broadcast", "Console", "Control"]' 22 | //% blockGap=8 23 | namespace jacdac { 24 | 25 | } -------------------------------------------------------------------------------- /libs/core/pinscompat.ts: -------------------------------------------------------------------------------- 1 | // filled in by microbit -------------------------------------------------------------------------------- /libs/core/pxtcore.h: -------------------------------------------------------------------------------- 1 | #ifndef __PXTCORE_H 2 | #define __PXTCORE_H 3 | 4 | #include "CodalDmesg.h" 5 | #include "CodalHeapAllocator.h" 6 | 7 | #define PXT_CODAL 1 8 | 9 | #define itoa(a, b) codal::itoa(a, b) 10 | 11 | #define GC_GET_HEAP_SIZE() device_heap_size(0) 12 | #define GC_STACK_BASE DEVICE_STACK_BASE 13 | #define xmalloc device_malloc 14 | #define xfree device_free 15 | 16 | // on most devices we allocate the entire heap at once, so large allocs should work 17 | // if they don't you just get the regular out of memory instead of alloc too large 18 | #define GC_MAX_ALLOC_SIZE (128 * 1024) 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /libs/core/sim/keyvaluestorage.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim.configStorage { 2 | export function setBuffer(key: string, value: RefBuffer): void { 3 | // TODO 4 | } 5 | export function getBuffer(key: string): RefBuffer { 6 | // TODO 7 | return undefined; 8 | } 9 | export function removeItem(key: string): void { 10 | // TODO 11 | } 12 | export function clear(): void { 13 | // TODO 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /libs/core/sim/toggle.ts: -------------------------------------------------------------------------------- 1 | 2 | namespace pxsim { 3 | export class ToggleState { 4 | constructor (private pin: Pin) { } 5 | toggle() { 6 | const on = !!this.pin.value; 7 | this.pin.setValue(on ? 0 : 1023); 8 | } 9 | 10 | on() { 11 | return this.pin.value > 0; 12 | } 13 | } 14 | 15 | export interface ToggleStateConstructor { 16 | (pin: Pin): ToggleState; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /libs/core/sim/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "noImplicitAny": true, 5 | "noImplicitReturns": true, 6 | "lib": [ 7 | "DOM", 8 | "DOM.Iterable", 9 | "ES2017" 10 | ], 11 | "rootDir": ".", 12 | "newLine": "LF", 13 | "sourceMap": false 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /libs/core/test.ts: -------------------------------------------------------------------------------- 1 | let i = 1 2 | let f = 0.5 3 | let plus = i + f 4 | let minus = i - f 5 | 6 | let r = Math.random() 7 | let ri = Math.randomRange(5, 10) 8 | 9 | -------------------------------------------------------------------------------- /libs/datalogger/README.md: -------------------------------------------------------------------------------- 1 | # Data logger 2 | 3 | A tiny libraty to create CSV log files. -------------------------------------------------------------------------------- /libs/datalogger/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "datalogger", 3 | "description": "Tiny data logging framework", 4 | "files": [ 5 | "README.md", 6 | "datalogger.ts", 7 | "storagedatalogger.ts", 8 | "targetoverrides.ts" 9 | ], 10 | "testFiles": [ 11 | "test.ts" 12 | ], 13 | "public": true, 14 | "dependencies": { 15 | "core": "file:../core", 16 | "storage": "file:../storage" 17 | } 18 | } -------------------------------------------------------------------------------- /libs/datalogger/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // add target specific things here 2 | namespace datalogger { 3 | datalogger.setStorage(new FileStorage("log.csv")); 4 | } -------------------------------------------------------------------------------- /libs/datalogger/test.ts: -------------------------------------------------------------------------------- 1 | let k = 0; 2 | forever(function () { 3 | datalogger.addRow() 4 | datalogger.addValue("x", k) 5 | datalogger.addValue("y", 1 / k) 6 | }) 7 | -------------------------------------------------------------------------------- /libs/display/displayImage.ts: -------------------------------------------------------------------------------- 1 | namespace display { 2 | /** 3 | * Show an image on the screen 4 | * @param image image to draw 5 | */ 6 | //% blockId=displayshowimage block="show image %image=image_picker" 7 | //% weight=100 group="Screen" blockGap=8 8 | //% help=display/show-image 9 | export function showImage(image: Image, duration: number = 400) { 10 | screen.fill(0); 11 | if (image) 12 | screen.drawImage(image, 0, 0) 13 | if (duration > 0) 14 | pause(duration); 15 | } 16 | } -------------------------------------------------------------------------------- /libs/display/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "display", 3 | "description": "Basic display functionalitites", 4 | "files": [ 5 | "display.ts", 6 | "displayImage.ts", 7 | "graph.ts", 8 | "targetoverrides.ts" 9 | ], 10 | "dependencies": { 11 | "screen": "file:../screen" 12 | }, 13 | "public": true 14 | } 15 | -------------------------------------------------------------------------------- /libs/display/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // Overriden in target -------------------------------------------------------------------------------- /libs/edge-connector/README.md: -------------------------------------------------------------------------------- 1 | # Edge connector 2 | 3 | Support for 20 pin edge connector. 4 | 5 | ## Config 6 | 7 | Pin mapping must be specified in config key section. -------------------------------------------------------------------------------- /libs/edge-connector/docs/reference/edge-connector.md: -------------------------------------------------------------------------------- 1 | # Edge Connector 2 | 3 | Some MakeCode Arcade compatible [hardware](/arcade-devices) devices have edge connectors which can add programmable pins which are accessible through the [pins](/reference/pins) namespace. The edge connector extension will map the pins of a 20-pin conncector for both analog and digital I/O. 4 | 5 | The [Meowbit](https://www.kittenbot.cc/collections/frontpage/products/meowbit-codable-console-for-microsoft-makecode-arcade) from KittenBot is an example of a MakeCode Arcade device with an edge connector. 6 | -------------------------------------------------------------------------------- /libs/edge-connector/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "edge-connector", 3 | "description": "20 pin Edge Connector", 4 | "files": [ 5 | "README.md", 6 | "device.d.ts", 7 | "pinscompat.ts" 8 | ], 9 | "public": true, 10 | "dependencies": { 11 | "core": "file:../core" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /libs/esp32/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "esp32", 3 | "description": "ESP32 over SPI - beta", 4 | "files": [ 5 | "net.ts", 6 | "ninacontroller.ts", 7 | "README.md" 8 | ], 9 | "testFiles": [ 10 | "test.ts" 11 | ], 12 | "public": true, 13 | "dependencies": { 14 | "core": "file:../core", 15 | "net": "file:../net", 16 | "settings": "file:../settings" 17 | } 18 | } -------------------------------------------------------------------------------- /libs/esp32/test.ts: -------------------------------------------------------------------------------- 1 | function test() { 2 | 3 | const log = console.log; 4 | const esp = net.instance().controller() 5 | 6 | if (!esp.isIdle) 7 | return 8 | 9 | log(`Firmware vers. ${esp.firmwareVersion}`) 10 | log(`MAC addr: ${esp.MACaddress.toHex()}`) 11 | log("Temp: " + esp.getTemperature()) 12 | 13 | if (!esp.connect()) { 14 | log("can't connect") 15 | return 16 | } 17 | 18 | log("ping: " + esp.ping("bing.com")) 19 | } 20 | 21 | test(); -------------------------------------------------------------------------------- /libs/feather/README.md: -------------------------------------------------------------------------------- 1 | # feather 2 | 3 | Provides pin definition for Adafruit Feather compatible boards. 4 | 5 | 6 | See https://learn.adafruit.com/assets/78438 -------------------------------------------------------------------------------- /libs/feather/docs/reference/feather.md: -------------------------------------------------------------------------------- 1 | # Feather 2 | 3 | Feather is a family of microcontroller and accessory boards from [Adafruit](https://www.adafruit.com/category/943). The **feather** extension enables pin mapping for MakeCode Arcade on the feather board. 4 | 5 | You can learn more about the Adafruit feather in general at: 6 | 7 | https://learn.adafruit.com/adafruit-feather 8 | 9 | The pinout diagram for Adafruit Feather M4 Express is here: 10 | 11 | https://learn.adafruit.com/assets/78438 -------------------------------------------------------------------------------- /libs/feather/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "feather", 3 | "description": "Adafruit Feather pinout", 4 | "files": [ 5 | "README.md", 6 | "device.d.ts", 7 | "targetoverrides.d.ts" 8 | ], 9 | "dependencies": { 10 | "core": "file:../core" 11 | }, 12 | "public": true, 13 | "weight": 2 14 | } 15 | -------------------------------------------------------------------------------- /libs/feather/targetoverrides.d.ts: -------------------------------------------------------------------------------- 1 | // target specific customizations -------------------------------------------------------------------------------- /libs/game---light/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "game---light", 3 | "description": "Empty game library - beta", 4 | "files": [ 5 | "compat.ts", 6 | "console.ts", 7 | "constants.ts", 8 | "controlleroverrides.ts", 9 | "controllerbutton.ts", 10 | "controllerbuttons.cpp", 11 | "mathUtil.ts", 12 | "gameutil.ts", 13 | "targetoverrides.cpp", 14 | "targetoverrides.ts" 15 | ], 16 | "public": true, 17 | "additionalFilePath": "../game", 18 | "dependencies": { 19 | "settings": "file:../settings", 20 | "screen": "file:../screen" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /libs/game/constants.ts: -------------------------------------------------------------------------------- 1 | const KEY_UP = 2048; 2 | const KEY_DOWN = 2049; 3 | const INTERNAL_KEY_UP = 2050; 4 | const INTERNAL_KEY_DOWN = 2051; 5 | const SYSTEM_KEY_UP = 2052; 6 | const SYSTEM_KEY_DOWN = 2053; 7 | const KEY_REPEAT = 2054; 8 | const SYSTEM_KEY_REPEAT = 2055; 9 | -------------------------------------------------------------------------------- /libs/game/docs/reference/effects/end-screen-effect.md: -------------------------------------------------------------------------------- 1 | # end Screen Effect 2 | 3 | Stop a built-in effect from displaying on the screen. 4 | 5 | ```sig 6 | effects.confetti.startScreenEffect() 7 | ``` 8 | 9 | There are several built-in effects you can show on the screen. This will stop the effect you choose if it's currently displaying. In the Blocks editor, you can select an effect from a list in the block. 10 | 11 | ## Example #example 12 | 13 | Start the ``blizzard`` and ``confetti`` effects on the screen. Wait 5 seconds and then stop only the ``confetti`` effect. 14 | 15 | ```blocks 16 | effects.blizzard.startScreenEffect() 17 | effects.confetti.startScreenEffect() 18 | pause(5000) 19 | effects.confetti.endScreenEffect() 20 | ``` 21 | 22 | ## See also #seealso 23 | 24 | [start screen effect](/reference/scene/start-screen-effect) -------------------------------------------------------------------------------- /libs/game/docs/reference/effects/start-screen-effect.md: -------------------------------------------------------------------------------- 1 | # start Screen Effect 2 | 3 | Start a displaying a built-in effect on the screen. 4 | 5 | ```sig 6 | effects.confetti.startScreenEffect() 7 | ``` 8 | 9 | There are several built-in effects you can show on the screen. This will start the effect you choose. In the Blocks editor, you can select an effect from a list in the block. 10 | 11 | ## Example #example 12 | 13 | Start the ``blizzard`` effect on the screen. Wait 5 seconds and then stop the effect. 14 | 15 | ```blocks 16 | effects.blizzard.startScreenEffect() 17 | pause(5000) 18 | effects.blizzard.endScreenEffect() 19 | ``` 20 | 21 | ## See also #seealso 22 | 23 | [end screen effect](/reference/scene/end-screen-effect) -------------------------------------------------------------------------------- /libs/game/docs/reference/game/on-paint.md: -------------------------------------------------------------------------------- 1 | # on Paint 2 | 3 | Draw on screen before sprites. 4 | 5 | ```sig 6 | game.onPaint(function () { 7 | 8 | }) 9 | ``` 10 | 11 | ## Parameters 12 | 13 | * **a**: the code to run for painting the screen before the sprites are drawn. 14 | 15 | ## Example #example 16 | 17 | Randomly change the screen background color every `2` seconds. 18 | 19 | ```blocks 20 | let bkColor = 0 21 | bkColor = 0 22 | game.onPaint(function () { 23 | scene.setBackgroundColor(bkColor) 24 | }) 25 | game.onUpdateInterval(2000, function () { 26 | bkColor = Math.randomRange(0, 15) 27 | }) 28 | ``` 29 | 30 | ## See also #seealso 31 | 32 | [update](/reference/game/on-update) -------------------------------------------------------------------------------- /libs/game/docs/reference/game/set-dialog-text-color.md: -------------------------------------------------------------------------------- 1 | # set Dialog Text Color 2 | 3 | Set the color for the text that's displayed in the long text dialog. 4 | 5 | ```sig 6 | game.setDialogTextColor(0) 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **color**: the [number](/types/number) for the color used to display the dialog text. 12 | 13 | ## Example #example 14 | 15 | Show text with color `10` in the long text dialog. 16 | 17 | ```blocks 18 | game.setDialogTextColor(10) 19 | game.showLongText("Some long text with color!", DialogLayout.Center) 20 | ``` 21 | 22 | ## See also #seealso 23 | 24 | [set dialog frame](/reference/game/set-dialog-frame), 25 | [set dialog cursor](/reference/game/set-dialog-cursor), 26 | [show long text](/reference/game/show-long-text) 27 | 28 | 29 | -------------------------------------------------------------------------------- /libs/game/docs/reference/game/splash.md: -------------------------------------------------------------------------------- 1 | # splash 2 | 3 | Show a title and a subtitle on the screen. 4 | 5 | ```sig 6 | game.splash("") 7 | ``` 8 | 9 | You can splash a title on the screen at the beginning of your game or at sometime later in the game. To show more information, add an optional subtitle string. The splash text goes away when you press a key or button. 10 | 11 | ## Parameters 12 | 13 | * **title**: a [string](/types/string) that is your splash text. 14 | * **subtitle**: a [string](/types/string) that is an optional second line of splash text. 15 | 16 | ## Example #example 17 | 18 | Show the title screen of the game before showing the menu. 19 | 20 | ```blocks 21 | game.splash("Magical Forest", "Find your way out!!!") 22 | let choice = game.askForString("Choose game: (1) Thick Woods, (2) Valley Grove", 1) 23 | ``` 24 | 25 | ## See also #seealso 26 | 27 | [ask](/reference/game/ask) -------------------------------------------------------------------------------- /libs/game/docs/reference/info/change-countdown-by.md: -------------------------------------------------------------------------------- 1 | # change Countdown By 2 | 3 | Change the current game countdown time up or down by this amount. 4 | 5 | ```sig 6 | info.changeCountdownBy(0) 7 | ``` 8 | 9 | The current game countdown time amount is increased by adding the change value when it is greater than zero (positive). If the change number is less than zero (negative), the game countdown is reduced by the value of the change number. 10 | 11 | ## Parameters 12 | 13 | * **value**: a [number](/types/number) seconds to change the game countdown by. 14 | 15 | ## Example #example 16 | 17 | Reduce game countdown time by `3` seconds. 18 | 19 | ```blocks 20 | info.changeCountdown(-3) 21 | ``` 22 | 23 | ## See also #seealso 24 | 25 | [countdown](/reference/info/score), 26 | [on countdown end](/reference/info/on-countdown-end) -------------------------------------------------------------------------------- /libs/game/docs/reference/info/has-life.md: -------------------------------------------------------------------------------- 1 | # has Life 2 | 3 | ```sig 4 | info.player2.hasLife() 5 | ``` 6 | 7 | Returns a ``true`` value if the life count for the player is greater than zero. 8 | 9 | ## Returns 10 | 11 | * a [boolean](/types/boolean) that is ``true`` if the player has lives remaining. Otherwise, ``false`` is returned. 12 | 13 | ## Example #Example 14 | 15 | Remove one life from the player every `100` milliseconds. When the player's lives reach 0, end the game early. 16 | 17 | ```blocks 18 | info.player2.setLife(20) 19 | game.onUpdate(function () { 20 | if (info.player2.hasLife() == false) { 21 | game.over() 22 | } 23 | }) 24 | 25 | game.onUpdateInterval(100, function () { 26 | info.player2.changeLifeBy(-1) 27 | }) 28 | ``` 29 | 30 | ## See also 31 | 32 | [change life by](/reference/info/change-life-by), 33 | [on life zero](/reference/info/on-life-zero) -------------------------------------------------------------------------------- /libs/game/docs/reference/info/high-score.md: -------------------------------------------------------------------------------- 1 | # high Score 2 | 3 | Get the highest score recored for the game. 4 | 5 | ```sig 6 | info.highScore() 7 | ``` 8 | 9 | The highest score recorded by your game program is remembered. So, you can find out what the player's best score was for the game. 10 | 11 | ## Returns 12 | 13 | * a [number](/types/number) that is the highest game score. 14 | 15 | ## Example #example 16 | 17 | Add `9` to the life count if the player had a high score of `100000` points. 18 | 19 | ```blocks 20 | let lifeBonus = true 21 | 22 | if (info.highScore() >= 100000) { 23 | if (lifeBonus) { 24 | info.changeLifeBy(9) 25 | lifeBonus = false 26 | } 27 | } 28 | ``` 29 | 30 | ## See also #seealso 31 | 32 | [set score](/reference/info/set-score), 33 | [change score by](/reference/info/change-score-by), 34 | [score](/reference/info/score) 35 | -------------------------------------------------------------------------------- /libs/game/docs/reference/info/set-life.md: -------------------------------------------------------------------------------- 1 | # set Life 2 | 3 | Set the player life count to this amount. 4 | 5 | ```sig 6 | info.setLife(0) 7 | ``` 8 | 9 | Your program has a life counter which you can set to record the number of lives remaining for a player in your game. 10 | 11 | ## Parameters 12 | 13 | * **score**: a [number](/types/number) to set the life count to. 14 | 15 | ## Example #example 16 | 17 | Set the player life count to `9` lives before starting the game. 18 | 19 | ### Single player 20 | 21 | ```blocks 22 | info.setLife(9) 23 | ``` 24 | 25 | ### Multiplayer 26 | 27 | ```blocks 28 | info.player2.setLife(9) 29 | ``` 30 | 31 | ## See also #seealso 32 | 33 | [change life by](/reference/info/change-life-by) -------------------------------------------------------------------------------- /libs/game/docs/reference/info/set-score.md: -------------------------------------------------------------------------------- 1 | # set Score 2 | 3 | Set the game score for a player to this amount. 4 | 5 | ```sig 6 | info.setScore(0) 7 | ``` 8 | 9 | Your program has a score counter which you can set to record the current score for a game player. 10 | 11 | ## Parameters 12 | 13 | * **score**: a [number](/types/number) to set the current score to. 14 | 15 | ## Example #example 16 | 17 | Give the player `110` points to before starting the game. 18 | 19 | ### Single player 20 | 21 | ```blocks 22 | info.setScore(110) 23 | ``` 24 | 25 | ### Multiplayer 26 | 27 | ```blocks 28 | info.player2.setScore(110) 29 | ``` 30 | 31 | ## See also #seealso 32 | 33 | [change score by](/reference/info/change-score-by), 34 | [score](/reference/info/score), 35 | [on score](/reference/info/on-score) -------------------------------------------------------------------------------- /libs/game/docs/reference/info/start-countdown.md: -------------------------------------------------------------------------------- 1 | # start Countdown 2 | 3 | Start the countdown timer for the amount of gameplay time. The current game lasts for this amount of time. 4 | 5 | ```sig 6 | info.startCountdown(0) 7 | ``` 8 | 9 | The game time is set as a number of seconds. When the game time finishes, a game over notification happens and the current game ends. 10 | 11 | ## Parameters 12 | 13 | * **duration**: the [number](/types/number) seconds to play the game for. 14 | 15 | ## Example #example 16 | 17 | Set the game time to `30` seconds. 18 | 19 | ```blocks 20 | info.startCountdown(30) 21 | ``` 22 | 23 | ## See also #seealso 24 | 25 | [set score](/reference/info/set-score), 26 | [stop countdown](/reference/info/stop-countdown), 27 | [on countdown end](/reference/info/on-countdown-end) 28 | -------------------------------------------------------------------------------- /libs/game/docs/reference/info/stop-countdown.md: -------------------------------------------------------------------------------- 1 | # stop Countdown 2 | 3 | Stops the countdown timer but gameplay continues. 4 | 5 | ```sig 6 | info.stopCountdown() 7 | ``` 8 | 9 | When you stop the game timer the game continues but the there is no more time limit. You can't resume the countdown from the previous time. You must start the countdown again to reset a time limit for the game. 10 | 11 | ## Example #example 12 | 13 | Set the game time to `30` seconds. Wait `5` seconds, stop the countdown, wait `2` seconds and end the game. 14 | 15 | ```blocks 16 | info.startCountdown(30) 17 | pause(5000) 18 | info.stopCountdown() 19 | pause(2000) 20 | game.over() 21 | ``` 22 | 23 | ## See also #seealso 24 | 25 | [start countdown](/reference/info/start-countdown), 26 | [on countdown end](/reference/info/on-countdown-end) 27 | -------------------------------------------------------------------------------- /libs/game/docs/reference/math/percent-chance.md: -------------------------------------------------------------------------------- 1 | # percent Chance 2 | 3 | Return a boolean value that is true a given percentage of the time. 4 | 5 | ```sig 6 | Math.percentChance(0) 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **percentage**: a [number](/types/number) which is the percentage chance that the returned value will be `true`. The percentage is a value beteen `0` and `100`. 12 | 13 | ## Returns 14 | 15 | * a [boolean](/types/boolean) that is `true` for the **percentage** of chance given. 16 | 17 | ## Example #example 18 | 19 | Simulate picking the number `1` when rolling dice. Use a percentage chance to see 20 | if your number is rolled. 21 | 22 | ```blocks 23 | let isOne = Math.percentChance(100 / 6) 24 | ``` 25 | 26 | ## See Also 27 | 28 | [random range](/reference/math/random-range) -------------------------------------------------------------------------------- /libs/game/docs/reference/scene/camera-left.md: -------------------------------------------------------------------------------- 1 | # camera left **deprecated** 2 | 3 | Returns the x coordinate of the camera (the left side of the screen). 4 | 5 | ```sig 6 | scene.cameraLeft() 7 | ``` 8 | 9 | ## See also #seealso 10 | 11 | [camera follow sprite](/reference/scene/camera-follow-sprite) 12 | [center camera at](/reference/scene/center-camera-at) 13 | [camera property](/reference/scene/camera-property) -------------------------------------------------------------------------------- /libs/game/docs/reference/scene/camera-shake.md: -------------------------------------------------------------------------------- 1 | # camera Shake 2 | 3 | Shake the camera view to create a shock effect. 4 | 5 | ```sig 6 | scene.cameraShake(4, 1000) 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **amplitude**: a [number](/types/number) maximum offset the camera will move. 12 | * **duration**: a [number](/types/number) duration in milli-seconds 13 | 14 | ## Example #example 15 | 16 | Shake the camera view for 1 second. 17 | 18 | ```blocks 19 | scene.cameraShake(4, 1000) 20 | ``` 21 | 22 | ## See also #seealso 23 | 24 | [camera follow sprite](/reference/scene/camera-follow-sprite) -------------------------------------------------------------------------------- /libs/game/docs/reference/scene/camera-top.md: -------------------------------------------------------------------------------- 1 | # camera top **deprecated** 2 | 3 | Returns the y coordinate of the camera (the top of the screen). 4 | 5 | ```sig 6 | scene.cameraTop() 7 | ``` 8 | 9 | ## See also #seealso 10 | 11 | [camera follow sprite](/reference/scene/camera-follow-sprite) 12 | [center camera at](/reference/scene/center-camera-at) 13 | [camera property](/reference/scene/camera-property) -------------------------------------------------------------------------------- /libs/game/docs/reference/scene/screen-height.md: -------------------------------------------------------------------------------- 1 | # screen Height 2 | 3 | Get the height in pixels of the screen. 4 | 5 | ```sig 6 | scene.screenWidth() 7 | ``` 8 | 9 | ## Returns 10 | 11 | * a [number](/types/number) that's the height of the screen on the game device or simulator. 12 | 13 | ## Example #example 14 | 15 | Draw a wide line down the entire screen. 16 | 17 | ```blocks 18 | let showLine: Sprite = null 19 | let wideLine: Image = null 20 | wideLine = image.create(3, scene.screenHeight()) 21 | wideLine.fill(5) 22 | showLine = sprites.create(wideLine) 23 | ``` 24 | 25 | ## See also #seealso 26 | 27 | [screen width](/reference/scene/screen-width) 28 | 29 | -------------------------------------------------------------------------------- /libs/game/docs/reference/scene/screen-width.md: -------------------------------------------------------------------------------- 1 | # screen Width 2 | 3 | Get the width in pixels of the screen. 4 | 5 | ```sig 6 | scene.screenWidth() 7 | ``` 8 | 9 | ## Returns 10 | 11 | * a [number](/types/number) that's the width of the screen on the game device or simulator. 12 | 13 | ## Example #example 14 | 15 | Draw a wide line across the entire screen. 16 | 17 | ```blocks 18 | let showLine: Sprite = null 19 | let wideLine: Image = null 20 | wideLine = image.create(scene.screenWidth(), 3) 21 | wideLine.fill(5) 22 | showLine = sprites.create(wideLine) 23 | ``` 24 | 25 | ## See also #seealso 26 | 27 | [screen height](/reference/scene/screen-height) 28 | 29 | -------------------------------------------------------------------------------- /libs/game/docs/types/sprite.md: -------------------------------------------------------------------------------- 1 | # Sprite 2 | 3 | A sprite is a complex type that allows an image to show on the screen and move around. A sprite has functions to locate and move an image that it contains. Sprites can overlap, flip, and collide with each other. A sprite can also have multiple image _frames_ to create animations. -------------------------------------------------------------------------------- /libs/game/gameoverrides.ts: -------------------------------------------------------------------------------- 1 | // override in targets -------------------------------------------------------------------------------- /libs/game/keymap.cpp: -------------------------------------------------------------------------------- 1 | #include "pxt.h" 2 | 3 | namespace keymap { 4 | 5 | void _setPlayerKeys(int player, int up, int down, int left, int right, int A, int B) { 6 | // not supported 7 | } 8 | 9 | void _setSystemKeys(int screenshot, int gif) { 10 | // not supported 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /libs/game/metrics.ts: -------------------------------------------------------------------------------- 1 | namespace performance { 2 | 3 | } -------------------------------------------------------------------------------- /libs/game/multiplayer.cpp: -------------------------------------------------------------------------------- 1 | #include "pxt.h" 2 | 3 | namespace multiplayer { 4 | //% 5 | void postImage(Image_ im) { 6 | } 7 | //% 8 | void postIcon(int type, int icon, Image_ im) { 9 | } 10 | 11 | //% 12 | void setOrigin(String origin) { 13 | } 14 | 15 | //% 16 | Image_ getCurrentImage() { 17 | return NULL; 18 | } 19 | 20 | //% 21 | String getOrigin() { 22 | return NULL; 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /libs/game/ns.ts: -------------------------------------------------------------------------------- 1 | //% color=#8854d0 weight=97 icon="\uf111" 2 | //% blockGap=8 3 | //% groups='["Gameplay", "Game Over", "Prompt", "Dialogs"]' 4 | namespace game { 5 | } 6 | -------------------------------------------------------------------------------- /libs/game/sim/api.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim.info { 2 | } -------------------------------------------------------------------------------- /libs/game/sprite.d.ts: -------------------------------------------------------------------------------- 1 | declare interface Sprite { 2 | //% group="Physics" blockSetVariable="mySprite" 3 | //% blockCombine block="z (depth)" 4 | z: number; 5 | // this is defined in the superclass BaseSprite, so it needs to be declared here to show up 6 | // in the blocks for sprites. 7 | } -------------------------------------------------------------------------------- /libs/game/systemKeyboard.cpp: -------------------------------------------------------------------------------- 1 | #include "pxt.h" 2 | 3 | namespace Keyboard { 4 | 5 | //% 6 | void promptForText(int maxLength, bool numberOnly) { 7 | } 8 | 9 | //% 10 | void cancelTextPrompt() { 11 | } 12 | 13 | //% 14 | char* getTextPromptString() { 15 | return NULL; 16 | } 17 | 18 | //% 19 | char* getLocalizedInstructions() { 20 | return NULL; 21 | } 22 | 23 | //% 24 | int getTextPromptSelectionStart() { 25 | return 0; 26 | } 27 | 28 | //% 29 | int getTextPromptSelectionEnd() { 30 | return 0; 31 | } 32 | 33 | //% 34 | bool isSystemKeyboardSupported() { 35 | return false; 36 | } 37 | } -------------------------------------------------------------------------------- /libs/game/targetoverrides.cpp: -------------------------------------------------------------------------------- 1 | // Overriden in target 2 | -------------------------------------------------------------------------------- /libs/game/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // Overriden in target 2 | -------------------------------------------------------------------------------- /libs/game/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "noImplicitAny": true, 5 | "noImplicitReturns": true, 6 | "outDir": "../built", 7 | "newLine": "LF", 8 | "sourceMap": false, 9 | "types": [] 10 | }, 11 | "include": [ 12 | "*.ts", 13 | "../settings/*.ts", 14 | "../screen/*.ts", 15 | "../mixer/*.ts", 16 | "../power/*.ts", 17 | "../core/*.ts", 18 | "../base/*.ts", 19 | "../../../pxt/libs/pxt-common/*.ts" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /libs/gamepad/docs/reference/gamepad.md: -------------------------------------------------------------------------------- 1 | # Gamepad 2 | 3 | Emulate gamepad actions using a USB connection. 4 | 5 | ## ~ hint 6 | 7 | The @boardname@ needs a connection to a computer or other host device with a USB cable in order to emulate a gamepad. This function doesn't work in the simulator. 8 | 9 | ## ~ 10 | 11 | ```cards 12 | gamepad.setButton(GamepadButton.B, false) 13 | gamepad.move(0, 0, 0) 14 | gamepad.setThrottle(0, 0) 15 | ``` 16 | 17 | ## See also 18 | 19 | [move](/reference/gamepad/move), [set button](/reference/gamepad/set-button), [set throttle](/reference/gamepad/set-throttle) 20 | 21 | ```package 22 | gamepad 23 | ``` -------------------------------------------------------------------------------- /libs/gamepad/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gamepad", 3 | "description": "Gamepad controller over HID", 4 | "files": [ 5 | "gamepad.cpp", 6 | "shims.d.ts", 7 | "gamepad.ts" 8 | ], 9 | "tests": [ 10 | "test.ts" 11 | ], 12 | "public": true, 13 | "dependencies": { 14 | "core": "file:../core" 15 | }, 16 | "yotta": { 17 | "config": { 18 | "DEVICE_USB": 1, 19 | "DEVICE_JOYSTICK": 1 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /libs/gamepad/sim/gamepad.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim.gamepad { 2 | export function setButton(index: number, up: boolean): void { 3 | // TODO 4 | } 5 | 6 | export function move(index: number, x: number, y: number): void { 7 | // TODO 8 | } 9 | 10 | export function setThrottle(index: number, value: number): void { 11 | // TODO 12 | } 13 | } -------------------------------------------------------------------------------- /libs/gamepad/sim/state.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim { 2 | } 3 | -------------------------------------------------------------------------------- /libs/infrared/README.md: -------------------------------------------------------------------------------- 1 | # infrared 2 | 3 | The Infra Red library. 4 | 5 | -------------------------------------------------------------------------------- /libs/infrared/docs/reference/network.md: -------------------------------------------------------------------------------- 1 | # Network #network 2 | 3 | Send and receive data between your @boardname@ and another board. 4 | 5 | ## Infrared 6 | 7 | ```cards 8 | network.infraredSendNumber(0); 9 | network.onInfraredReceivedNumber(function (num) { 10 | 11 | }) 12 | ``` 13 | ## See also 14 | 15 | [infrared send number](/reference/network/infrared-send-number), 16 | [on infrared received number](/reference/network/on-infrared-received-number) 17 | 18 | ```package 19 | infrared 20 | ``` 21 | -------------------------------------------------------------------------------- /libs/infrared/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "infrared", 3 | "description": "Communication over Infra Red", 4 | "files": [ 5 | "README.md", 6 | "ir.cpp", 7 | "ir.ts", 8 | "shims.d.ts" 9 | ], 10 | "public": true, 11 | "dependencies": { 12 | "core": "file:../core", 13 | "pulse": "file:../pulse" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /libs/infrared/sim/ir.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim.network { 2 | export function infraredSendPacket(buf: RefBuffer): void { 3 | const state = getInfraredState(); 4 | state.send(buf); 5 | } 6 | 7 | export function infraredPacket() : RefBuffer { 8 | const state = getInfraredState(); 9 | return state.packet; 10 | } 11 | 12 | export function onInfraredPacket(body: RefAction): void { 13 | const state = getInfraredState(); 14 | state.listen(body); 15 | } 16 | 17 | export function onInfraredError(body: RefAction): void { 18 | const state = getInfraredState(); 19 | state.listenError(body); 20 | } 21 | } -------------------------------------------------------------------------------- /libs/keyboard/docs/reference/keyboard.md: -------------------------------------------------------------------------------- 1 | # Keyboard 2 | 3 | Emulate typing with a keyboard using a USB connection. 4 | 5 | ## ~ hint 6 | 7 | The @boardname@ needs a connection to a computer or other host device with a USB cable in order to emulate a keyboard. This function doesn't work in the simulator. 8 | 9 | ## ~ 10 | 11 | ```cards 12 | keyboard.type("") 13 | keyboard.key("", KeyboardKeyEvent.Press) 14 | keyboard.mediaKey(KeyboardMediaKey.Mute, KeyboardKeyEvent.Press) 15 | keyboard.functionKey(KeyboardFunctionKey.F1Key, KeyboardKeyEvent.Press) 16 | ``` 17 | 18 | ## See also 19 | 20 | [type](/reference/keyboard/type), [key](/reference/keyboard/key), [media key](/reference/keyboard/media-key), [function key](/reference/keyboard/function-key) 21 | 22 | ```package 23 | keyboard 24 | ``` -------------------------------------------------------------------------------- /libs/keyboard/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum KeyboardKeyEvent { 5 | //% block="press" 6 | Press = 0, 7 | //% block="up" 8 | Up = 1, 9 | //% block="down" 10 | Down = 2, 11 | } 12 | 13 | // Auto-generated. Do not edit. Really. 14 | -------------------------------------------------------------------------------- /libs/keyboard/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "keyboard", 3 | "description": "Keyboard emulation over HID", 4 | "files": [ 5 | "keyboard.cpp", 6 | "shims.d.ts", 7 | "enums.d.ts", 8 | "keyboard.ts" 9 | ], 10 | "tests": [ 11 | "test.ts" 12 | ], 13 | "public": true, 14 | "dependencies": { 15 | "core": "file:../core" 16 | }, 17 | "yotta": { 18 | "config": { 19 | "DEVICE_USB": 1, 20 | "DEVICE_KEYBOARD": 1 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /libs/keyboard/shims.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | declare namespace keyboard { 3 | //% shim=keyboard::__flush hidden=1 4 | function __flush(): void; 5 | 6 | //% shim=keyboard::__type hidden=1 7 | function __type(text: string): void; 8 | 9 | //% shim=keyboard::__key hidden=1 10 | function __key(ckey: number, event: KeyboardKeyEvent): void; 11 | 12 | //% shim=keyboard::__mediaKey hidden=1 13 | function __mediaKey(key: uint16, event: KeyboardKeyEvent): void; 14 | 15 | //% shim=keyboard::__functionKey hidden=1 16 | function __functionKey(key: uint16, event: KeyboardKeyEvent): void; 17 | 18 | //% shim=keyboard::__modifierKey hidden=1 19 | function __modifierKey(modifier: uint16, event: KeyboardKeyEvent): void; 20 | } 21 | 22 | // Auto-generated. Do not edit. Really. 23 | -------------------------------------------------------------------------------- /libs/keyboard/test.ts: -------------------------------------------------------------------------------- 1 | keyboard.type("hello world"); 2 | for(let i = 0; i < 10; ++i) // don't send more than 1 3 | keyboard.key("A", KeyboardKeyEvent.Down); 4 | for(let i = 0; i < 10; ++i) // don't send more than 1 5 | keyboard.key("A", KeyboardKeyEvent.Up); 6 | keyboard.key("A", KeyboardKeyEvent.Press); -------------------------------------------------------------------------------- /libs/lcd/README.md: -------------------------------------------------------------------------------- 1 | # LCD 2 | 3 | Ported from https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/. 4 | -------------------------------------------------------------------------------- /libs/lcd/lcd.cpp: -------------------------------------------------------------------------------- 1 | #include "pxt.h" 2 | 3 | namespace lcd { 4 | //% 5 | void __write8(int value, bool char_mode) { 6 | // sim only 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /libs/lcd/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lcd", 3 | "description": "Characeter LCD driver", 4 | "files": [ 5 | "README.md", 6 | "characterlcd.ts", 7 | "characterlcdmono.ts", 8 | "characterlcdrbg.ts", 9 | "lcd.ts", 10 | "lcd.cpp", 11 | "pxtparts.json" 12 | ], 13 | "testFiles": [ 14 | "test.ts" 15 | ], 16 | "public": true, 17 | "dependencies": { 18 | "core": "file:../core" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /libs/lcd/test.ts: -------------------------------------------------------------------------------- 1 | // 2 | -------------------------------------------------------------------------------- /libs/light-spectrum-sensor/README.md: -------------------------------------------------------------------------------- 1 | # Color Sensor 2 | 3 | Ambient light sensor -------------------------------------------------------------------------------- /libs/light-spectrum-sensor/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "light-spectrum-sensor", 3 | "description": "Light Spectrum sensor (TSL2591)", 4 | "files": [ 5 | "README.md", 6 | "sensor.ts", 7 | "tsl2591.ts" 8 | ], 9 | "testFiles": [ 10 | "test.ts" 11 | ], 12 | "public": true, 13 | "dependencies": { 14 | "core": "file:../core" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /libs/light-spectrum-sensor/test.ts: -------------------------------------------------------------------------------- 1 | // tests 2 | -------------------------------------------------------------------------------- /libs/light/README.md: -------------------------------------------------------------------------------- 1 | # neopixel 2 | 3 | The neopixel library. 4 | 5 | -------------------------------------------------------------------------------- /libs/light/docs/examples/photon-color-wipe.md: -------------------------------------------------------------------------------- 1 | # Photon Color Wipe 2 | 3 | ```blocks 4 | let pixels = light.createStrip(); 5 | forever(function() { 6 | pixels.setPhotonPenHue(Math.randomRange(0, 256)) 7 | pixels.setPhotonMode(PhotonMode.PenDown); 8 | for (let i = 0; i < 9; i++) { 9 | pixels.photonForward(1); 10 | pause(20); 11 | } 12 | pixels.setPhotonMode(PhotonMode.Eraser); 13 | for (let i = 0; i < 9; i++) { 14 | pixels.photonForward(1); 15 | pause(20); 16 | } 17 | }) 18 | ``` -------------------------------------------------------------------------------- /libs/light/docs/examples/photon-rainbow.md: -------------------------------------------------------------------------------- 1 | # Photon Rainbow 2 | 3 | ```blocks 4 | let c = 0; 5 | let pixels = light.createStrip(); 6 | forever(function() { 7 | pixels.setPhotonPenHue(c); 8 | pixels.photonForward(1); 9 | c += 16; 10 | }) 11 | ``` 12 | 13 | ```package 14 | light 15 | ``` -------------------------------------------------------------------------------- /libs/light/docs/examples/photon-roundtrip.md: -------------------------------------------------------------------------------- 1 | # Photon Roundtrip 2 | 3 | ```blocks 4 | let pixels = light.createStrip(); 5 | 6 | input.buttonA.onEvent(ButtonEvent.Click, function() { 7 | pixels.setPhotonMode(PhotonMode.PenDown); 8 | pixels.setPhotonPenHue(Math.randomRange(0, 256)); 9 | for (let i = 0; i < 10; i++) { 10 | pixels.photonForward(1); 11 | pause(50); 12 | } 13 | pause(1000); 14 | pixels.setPhotonMode(PhotonMode.Eraser); 15 | for (let i = 0; i < 10; i++) { 16 | pixels.photonForward(-1); 17 | pause(50); 18 | } 19 | }); 20 | ``` -------------------------------------------------------------------------------- /libs/light/docs/examples/photon-spark.md: -------------------------------------------------------------------------------- 1 | # Photon Spark 2 | 3 | ```blocks 4 | let pixels = light.createStrip(); 5 | 6 | pixels.setPhotonMode(PhotonMode.PenUp); 7 | forever(function() { 8 | pixels.photonForward(Math.randomRange(0, 10)) 9 | pause(20) 10 | }) 11 | ``` 12 | 13 | ```package 14 | light 15 | ``` -------------------------------------------------------------------------------- /libs/light/docs/examples/photon-wand.md: -------------------------------------------------------------------------------- 1 | # Photon Wand 2 | 3 | ```blocks 4 | let c = 0; 5 | let pixels = light.createStrip(); 6 | 7 | input.onGesture(Gesture.Shake, function() { 8 | pixels.clear(); 9 | pixels.setPhotonMode(PhotonMode.PenUp); 10 | music.playSound(music.sounds(Sounds.JumpUp)); 11 | 12 | for (let i = 0; i < 50; i++) { 13 | pixels.photonForward(Math.randomRange(0, 51)); 14 | pause(20); 15 | } 16 | pixels.setPhotonMode(PhotonMode.PenDown); 17 | }) 18 | forever(function() { 19 | pixels.photonForward(1); 20 | pixels.setPhotonPenHue(c); 21 | c += 16; 22 | }); 23 | ``` 24 | 25 | ```package 26 | light 27 | ``` -------------------------------------------------------------------------------- /libs/light/docs/reference/light/color-wheel.md: -------------------------------------------------------------------------------- 1 | # color Wheel 2 | 3 | Gets an RGB color given the value of an angle between 0 and 255. Useful 4 | for performing math with colors. 5 | 6 | ```sig 7 | light.colorWheel(0); 8 | ``` 9 | 10 | ## Parameters 11 | 12 | * **angle**: [number](/types/number), 13 | 14 | ## Example 15 | 16 | ```blocks 17 | light.builtin.showColor(light.colorWheel(42)) 18 | ``` 19 | 20 | ```package 21 | light 22 | ``` 23 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/color-wipe-animation.md: -------------------------------------------------------------------------------- 1 | # color Wipe Animation 2 | 3 | Return a new instance of the color wipe animation. 4 | 5 | ``` 6 | light.colorWipeAnimation 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **rgb**: [number](/types/number), 12 | 13 | ## Example 14 | 15 | ```blocks 16 | forever(() => { 17 | light.builtin.showAnimationFrame(light.colorWipeAnimation) 18 | }) 19 | ``` 20 | 21 | ## See Also 22 | 23 | 24 | ```package 25 | light 26 | ``` 27 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/colors.md: -------------------------------------------------------------------------------- 1 | # colors 2 | 3 | Get the RGB value of one of the known colors. 4 | 5 | ```sig 6 | light.colors(Colors.Yellow); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **color**: a well known color, like: ``pink`` 12 | 13 | ## See Also 14 | 15 | [``||rgb||``](/reference/light/rgb) 16 | 17 | ```package 18 | light 19 | ``` 20 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/comet-animation.md: -------------------------------------------------------------------------------- 1 | # comet Animation 2 | 3 | Return a new instance of the comet animation 4 | 5 | ```sig 6 | light.cometAnimation(); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | 12 | ## Example 13 | 14 | ```blocks 15 | forever(() => { 16 | light.builtin.showAnimationFrame(light.cometAnimation()) 17 | }) 18 | ``` 19 | 20 | ## See Also 21 | 22 | ```package 23 | light 24 | ``` 25 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/neopixelstrip/clear.md: -------------------------------------------------------------------------------- 1 | # clear 2 | 3 | Turn off all the pixel LEDs. 4 | 5 | ```sig 6 | light.createStrip().clear() 7 | 8 | ``` 9 | 10 | ## Example 11 | 12 | Turn off all the pixels when button `A` is pressed. 13 | 14 | ```blocks 15 | let strip = light.createStrip() 16 | strip.setAll(0x00ff00) 17 | input.buttonA.onEvent(ButtonEvent.Click, () => { 18 | strip.clear() 19 | }) 20 | ``` 21 | 22 | ## See Also 23 | 24 | [``||set All||``](/reference/light/neopixelstrip/set-all) 25 | 26 | ```package 27 | light 28 | ``` 29 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/neopixelstrip/length.md: -------------------------------------------------------------------------------- 1 | # length 2 | 3 | The number of pixels that are on a pixel strip. 4 | 5 | ```sig 6 | light.createStrip().length() 7 | ``` 8 | 9 | ## Returns 10 | 11 | * The [number](/types/number) of pixels on the pixel strip. 12 | 13 | ## Example 14 | 15 | Shift an `orange` pixel from the beginning of the pixel strip to the end. 16 | 17 | ```blocks 18 | let strip = light.createStrip() 19 | strip.setPixelColor(0, 0xff7f00) 20 | for (let i = 0; i < strip.length() - 1; i++) { 21 | pause(500) 22 | strip.move(LightMove.Shift, 1) 23 | } 24 | ``` 25 | ## See also 26 | 27 | [``||range||``](/reference/light/neopixelstrip/range) 28 | 29 | ```package 30 | light 31 | ``` 32 | 33 | 34 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/neopixelstrip/set-all.md: -------------------------------------------------------------------------------- 1 | # set All 2 | 3 | Make all of the pixels on the strip show one color. 4 | 5 | ```sig 6 | light.createStrip().setAll(0xff0000); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **rgb**: a [number](/types/number) that is the RGB color for all of the pixels. 12 | 13 | ## Example 14 | 15 | Set all of the pixels to `pink`. 16 | 17 | ```blocks 18 | let strip = light.createStrip() 19 | strip.setAll(0xff007f) 20 | ``` 21 | 22 | [``||rgb||``](/reference/light/rgb) 23 | 24 | ```package 25 | light 26 | ``` 27 | 28 | 29 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/neopixelstrip/set-mode.md: -------------------------------------------------------------------------------- 1 | # set Mode 2 | 3 | Sets the color encoding mode sent to the programmable lights. 4 | 5 | ```sig 6 | light.createStrip().setMode(NeoPixelMode.RGB) 7 | ``` 8 | 9 | Most light strips use the Green Red Blue encoding (``NeoPixelMode.RGB``), some use Red Green Blue (``NeoPixelMode.RGB_RGB``). 10 | Some LED strips also have a white LED (``NeoPixelMode.RGBW``). 11 | 12 | ## Parameters 13 | 14 | * **mode**: the desired mode 15 | 16 | ```package 17 | light 18 | ``` 19 | 20 | 21 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/neopixelstrip/set-photon-position.md: -------------------------------------------------------------------------------- 1 | # set Photon Position 2 | 3 | Change the position of the photon 4 | 5 | ```sig 6 | light.createStrip().setPhotonPosition(0) 7 | ``` 8 | 9 | The photon will be reposition to the given index. If the index is out of bounds, it will be wrapped. 10 | 11 | ## Parameters 12 | 13 | * **index**: index of the light where the photon will go 14 | 15 | ## Examples #exsection 16 | 17 | ## See also 18 | 19 | [``||photon forward||``](/reference/light/neopixelstrip/photon-forward), 20 | [``||photon flip||``](/reference/light/neopixelstrip/photon-flip), 21 | [``||set photon pen color||``](/reference/light/neopixelstrip/set-photon-pen-color) 22 | 23 | ```package 24 | light 25 | ``` 26 | 27 | 28 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/neopixelstrip/show.md: -------------------------------------------------------------------------------- 1 | # show 2 | 3 | Tell the pixel strip to show all the buffered pixel changes that are ready. 4 | 5 | ```sig 6 | light.createStrip().show() 7 | ``` 8 | 9 | You use **show** if you have pixel changes that are **[buffered](/reference/light/neopixelstrip/set-buffered)**. Any changes to the pixels caused by other light operations will appear when you use **show**. 10 | 11 | ## Example 12 | 13 | Set the color of two pixels but buffer each light change. Make all the changes appear at the same time. 14 | 15 | ```blocks 16 | let strip = light.createStrip() 17 | strip.setBuffered(true) 18 | strip.setPixelColor(0, 0x0000ff) 19 | strip.setPixelColor(2, 0xff0000) 20 | strip.show() 21 | ``` 22 | 23 | ## See also 24 | 25 | [set buffered](/reference/light/neopixelstrip/set-buffered) 26 | 27 | ```package 28 | light 29 | ``` 30 | 31 | 32 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/neopixelstrip/stop-all-animations.md: -------------------------------------------------------------------------------- 1 | # stop All Animations 2 | 3 | Stop the pixel animation showing right now and any other animations ready to show. 4 | 5 | ```sig 6 | light.createStrip().stopAllAnimations() 7 | 8 | ``` 9 | 10 | ## Example 11 | 12 | Show the ``rainbow`` aninmation for 10 seconds on start. If the ``A`` button 13 | is pressed before 10 seconds is over, stop the ``rainbow``. 14 | 15 | ```blocks 16 | let strip = light.createStrip() 17 | input.buttonA.onEvent(ButtonEvent.Click, () => { 18 | strip.stopAllAnimations() 19 | }) 20 | 21 | strip.showAnimation(light.rainbowAnimation, 10000) 22 | ``` 23 | 24 | ## See Also 25 | 26 | [``||show animation||``](/reference/light/neopixelstrip/show-animation) 27 | 28 | ```package 29 | light 30 | ``` 31 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/rainbow-cycle-animation.md: -------------------------------------------------------------------------------- 1 | # rainbow Cycle Animation 2 | 3 | Return a new instance of the rainbow animation 4 | 5 | ```sig 6 | light.rainbowCycleAnimation(); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | 12 | ## Example 13 | 14 | ```blocks 15 | forever(() => { 16 | light.builtin.showAnimationFrame(light.rainbowCycleAnimation()) 17 | }) 18 | ``` 19 | 20 | ## See Also 21 | 22 | ```package 23 | light 24 | ``` 25 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/running-lights-animation.md: -------------------------------------------------------------------------------- 1 | # running Lights Animation 2 | 3 | Return a new instance of the running lights animation 4 | 5 | ```sig 6 | light.runningLightsAnimation(); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | 12 | ## Example 13 | 14 | ```blocks 15 | forever(() => { 16 | light.builtin.showAnimationFrame(light.runningLightsAnimation()) 17 | }) 18 | ``` 19 | 20 | ## See Also 21 | 22 | ```package 23 | light 24 | ``` 25 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/sparkle-animation.md: -------------------------------------------------------------------------------- 1 | # sparkle Animation 2 | 3 | Return a new instance of the sparkle animation 4 | 5 | ```sig 6 | light.sparkleAnimation(); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | 12 | ## Example 13 | 14 | ```blocks 15 | forever(() => { 16 | light.builtin.showAnimationFrame(light.sparkleAnimation(), 500) 17 | }) 18 | ``` 19 | 20 | ## See Also 21 | 22 | ```package 23 | light 24 | ``` 25 | -------------------------------------------------------------------------------- /libs/light/docs/reference/light/theatre-chase-animation.md: -------------------------------------------------------------------------------- 1 | # theatre Chase Animation 2 | 3 | Return a new instance of the theatre chase animation 4 | 5 | ```sig 6 | light.theatreChaseAnimation(); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | 12 | ## Example 13 | 14 | ```blocks 15 | forever(() => { 16 | light.builtin.showAnimationFrame(light.theatreChaseAnimation(), 500) 17 | }) 18 | ``` 19 | 20 | ## See Also 21 | 22 | ```package 23 | light 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /libs/light/jres/animations/colorWipeAnimation-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/light/jres/animations/colorWipeAnimation-icon.png -------------------------------------------------------------------------------- /libs/light/jres/animations/cometAnimation-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/light/jres/animations/cometAnimation-icon.png -------------------------------------------------------------------------------- /libs/light/jres/animations/rainbowAnimation-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/light/jres/animations/rainbowAnimation-icon.png -------------------------------------------------------------------------------- /libs/light/jres/animations/runningLightsAnimation-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/light/jres/animations/runningLightsAnimation-icon.png -------------------------------------------------------------------------------- /libs/light/jres/animations/sparkleAnimation-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/light/jres/animations/sparkleAnimation-icon.png -------------------------------------------------------------------------------- /libs/light/jres/animations/theaterChaseAnimation-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/light/jres/animations/theaterChaseAnimation-icon.png -------------------------------------------------------------------------------- /libs/light/neopixeloverrides.ts: -------------------------------------------------------------------------------- 1 | // replace in other targets -------------------------------------------------------------------------------- /libs/light/ns.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Functions to operate colored LEDs. 4 | */ 5 | //% weight=100 color="#0078d7" icon="\uf00a" 6 | namespace light { 7 | 8 | } -------------------------------------------------------------------------------- /libs/light/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "light", 3 | "description": "The programmable LED (WS2812b,APA102) driver.", 4 | "files": [ 5 | "README.md", 6 | "neopixel.ts", 7 | "transitions.ts", 8 | "create.ts", 9 | "defaultstrip.ts", 10 | "onboardstrip.ts", 11 | "defaultlights.ts", 12 | "defaultlightsoverrides.ts", 13 | "ns.ts", 14 | "neopixeloverrides.ts", 15 | "animations.jres", 16 | "targetoverrides.ts" 17 | ], 18 | "testFiles": [ 19 | "test.ts" 20 | ], 21 | "public": true, 22 | "dependencies": { 23 | "core": "file:../core", 24 | "color": "file:../color" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /libs/light/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // define built-in strips here -------------------------------------------------------------------------------- /libs/light/test.ts: -------------------------------------------------------------------------------- 1 | 2 | let strip = light.createStrip() 3 | strip.setBrightness(20) 4 | 5 | function flash(n: number) { 6 | control.runInParallel(() => { 7 | strip.setPixelColor(n, 0x0000ff) 8 | pause(1000) 9 | strip.setPixelColor(n, 0x000000) 10 | }) 11 | } 12 | 13 | flash(0) 14 | 15 | -------------------------------------------------------------------------------- /libs/lightsensor/README.md: -------------------------------------------------------------------------------- 1 | # lightsensor 2 | 3 | The lightsensor library. 4 | 5 | -------------------------------------------------------------------------------- /libs/lightsensor/docs/reference/input.md: -------------------------------------------------------------------------------- 1 | # @extends 2 | 3 | ## #lightsensor 4 | 5 | ```cards 6 | input.onLightConditionChanged(LightCondition.Dark, () => { 7 | 8 | }); 9 | input.lightLevel(); 10 | ``` 11 | 12 | ```package 13 | lightsensor 14 | ``` 15 | -------------------------------------------------------------------------------- /libs/lightsensor/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum LightCondition { 5 | //% block="dark" 6 | Dark = 1, // SENSOR_THRESHOLD_LOW 7 | //% block="bright" 8 | Bright = 2, // SENSOR_THRESHOLD_HIGH 9 | } 10 | 11 | // Auto-generated. Do not edit. Really. 12 | -------------------------------------------------------------------------------- /libs/lightsensor/ns.ts: -------------------------------------------------------------------------------- 1 | 2 | //% color="#B4009E" weight=98 icon="\uf192" 3 | namespace input { 4 | } -------------------------------------------------------------------------------- /libs/lightsensor/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lightsensor", 3 | "description": "Onboard light level sensor", 4 | "files": [ 5 | "README.md", 6 | "lightsensor.cpp", 7 | "ns.ts", 8 | "shims.d.ts", 9 | "enums.d.ts" 10 | ], 11 | "testFiles": [ 12 | "test.ts" 13 | ], 14 | "public": true, 15 | "dependencies": { 16 | "core": "file:../core" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /libs/lightsensor/sim/lightsensor.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim.input { 2 | export function lightLevel(): number { 3 | let b = lightSensorState(); 4 | b.setUsed(); 5 | 6 | return b.getLevel(); 7 | } 8 | 9 | export function onLightConditionChanged(condition: number, body: RefAction) { 10 | let b = lightSensorState(); 11 | b.setUsed(); 12 | 13 | pxtcore.registerWithDal(b.id, condition, body); 14 | } 15 | 16 | export function setLightThreshold(condition: number, value: number) { 17 | let b = lightSensorState(); 18 | b.setUsed(); 19 | switch(condition) { 20 | case DAL.SENSOR_THRESHOLD_LOW: b.setLowThreshold(value); break; 21 | case DAL.SENSOR_THRESHOLD_HIGH: b.setHighThreshold(value); break; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /libs/lightsensor/sim/state.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim { 2 | export interface LightSensorBoard extends CommonBoard { 3 | lightSensorState: AnalogSensorState; 4 | } 5 | 6 | export function lightSensorState() { 7 | return (board() as LightSensorBoard).lightSensorState; 8 | } 9 | } -------------------------------------------------------------------------------- /libs/lightsensor/test.ts: -------------------------------------------------------------------------------- 1 | for(let i = 0; i < 100; ++i) { 2 | pause(500) 3 | console.log(`light=${input.lightLevel()}`); 4 | } -------------------------------------------------------------------------------- /libs/lora/README.md: -------------------------------------------------------------------------------- 1 | # LoRa (beta) 2 | 3 | Package adds support LoRa. Adapted from https://github.com/ElectronicCats/pxt-lora/. 4 | -------------------------------------------------------------------------------- /libs/lora/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lora", 3 | "version": "0.2.2", 4 | "description": "Library for Lora - beta", 5 | "license": "MIT", 6 | "files": [ 7 | "README.md", 8 | "lora.ts" 9 | ], 10 | "testFiles": [ 11 | "test.ts" 12 | ], 13 | "public": true, 14 | "dependencies": { 15 | "core": "file:../core" 16 | } 17 | } -------------------------------------------------------------------------------- /libs/lora/test.ts: -------------------------------------------------------------------------------- 1 | // tests go here; this will not be compiled when this package is used as a library 2 | -------------------------------------------------------------------------------- /libs/matrix-keypad/README.md: -------------------------------------------------------------------------------- 1 | # button pad 2 | 3 | -------------------------------------------------------------------------------- /libs/matrix-keypad/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "buttonpad", 3 | "description": "A rectangular matrix of buttons - beta", 4 | "files": [ 5 | "README.md", 6 | "keypad.ts" 7 | ], 8 | "testFiles": [ 9 | "test.ts" 10 | ], 11 | "public": true, 12 | "dependencies": { 13 | "core": "file:../core" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /libs/matrix-keypad/test.ts: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------- /libs/microphone/README.md: -------------------------------------------------------------------------------- 1 | # microphone 2 | 3 | The microphone library. 4 | 5 | -------------------------------------------------------------------------------- /libs/microphone/docs/reference/input.md: -------------------------------------------------------------------------------- 1 | # @extends 2 | 3 | ## #microphone 4 | 5 | ```cards 6 | input.soundLevel(); 7 | input.onLoudSound(() => {}); 8 | input.setLoudSoundThreshold(0) 9 | ``` 10 | 11 | ```package 12 | microphone 13 | ``` 14 | -------------------------------------------------------------------------------- /libs/microphone/docs/reference/input/on-loud-sound.md: -------------------------------------------------------------------------------- 1 | # on Loud Sound 2 | 3 | Run some code when the microphone hears a loud sound. 4 | 5 | ```sig 6 | input.onLoudSound(function(){}); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **handler**: the code to run when a loud sound is heard. 12 | 13 | ## Example #example 14 | 15 | Flash the pixels when a loud sound is detected. 16 | 17 | ```blocks 18 | let pixels = light.createStrip() 19 | 20 | input.onLoudSound(function() { 21 | pixels.setAll(0xff0000) 22 | pause(100) 23 | pixels.setAll(0x000000) 24 | }) 25 | ``` 26 | 27 | # See also #seealso 28 | 29 | [sound level](/reference/input/sound-level) 30 | 31 | ```package 32 | microphone 33 | light 34 | ``` -------------------------------------------------------------------------------- /libs/microphone/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare enum LoudnessCondition { 5 | //% block="quiet" 6 | Quiet = 1, // LEVEL_THRESHOLD_LOW 7 | //% block="loud" 8 | Loud = 2, // LEVEL_THRESHOLD_HIGH 9 | } 10 | 11 | // Auto-generated. Do not edit. Really. 12 | -------------------------------------------------------------------------------- /libs/microphone/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "microphone", 3 | "description": "The microphone library", 4 | "files": [ 5 | "README.md", 6 | "microphone.cpp", 7 | "microphonehw.cpp", 8 | "enums.d.ts", 9 | "shims.d.ts", 10 | "targetoverrides.ts" 11 | ], 12 | "testFiles": [ 13 | "test.ts" 14 | ], 15 | "public": true, 16 | "dependencies": { 17 | "core": "file:../core" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /libs/microphone/sim/microphone.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim.input { 2 | export function soundLevel(): number { 3 | let b = microphoneState(); 4 | if (!b) return 0; 5 | b.setUsed(); 6 | return b.getLevel(); 7 | } 8 | 9 | export function onLoudSound(body: RefAction) { 10 | let b = microphoneState(); 11 | if (!b) return; 12 | b.setUsed(); 13 | pxtcore.registerWithDal(b.id, DAL.LEVEL_THRESHOLD_HIGH, body); 14 | } 15 | 16 | export function setLoudSoundThreshold(value: number) { 17 | let b = microphoneState(); 18 | if (!b) return; 19 | b.setUsed(); 20 | b.setHighThreshold(value); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /libs/microphone/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // target specific code -------------------------------------------------------------------------------- /libs/microphone/test.ts: -------------------------------------------------------------------------------- 1 | // tests -------------------------------------------------------------------------------- /libs/mixer---ext/SoundOutput.h: -------------------------------------------------------------------------------- 1 | #define SAMPLE_RATE 44100 2 | 3 | namespace music { 4 | class WSynthesizer; 5 | 6 | class ExtDAC { 7 | public: 8 | WSynthesizer &src; 9 | ExtDAC(WSynthesizer &data); 10 | int getSampleRate() { return SAMPLE_RATE; } 11 | }; 12 | 13 | class SoundOutput { 14 | public: 15 | ExtDAC dac; 16 | 17 | SoundOutput(WSynthesizer &data) : dac(data) {} 18 | 19 | void setOutput(int) {} 20 | }; 21 | 22 | } // namespace music -------------------------------------------------------------------------------- /libs/mixer---ext/pins.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/mixer---ext/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mixer---ext", 3 | "additionalFilePath": "../mixer" 4 | } 5 | -------------------------------------------------------------------------------- /libs/mixer---ext/sound.cpp: -------------------------------------------------------------------------------- 1 | #include "pxt.h" 2 | #include "SoundOutput.h" 3 | #include "melody.h" 4 | 5 | namespace music { 6 | 7 | static ExtDAC *dac; 8 | 9 | DLLEXPORT void pxt_get_audio_samples(int16_t *buf, unsigned numSamples) { 10 | if (!dac) { 11 | memset(buf, 0, numSamples * 2); 12 | return; 13 | } 14 | 15 | target_disable_irq(); 16 | dac->src.fillSamples(buf, numSamples); 17 | target_enable_irq(); 18 | 19 | for (unsigned i = 0; i < numSamples; ++i) { 20 | // playing at half-volume 21 | buf[i] = buf[i] << 3; 22 | } 23 | 24 | //DMESG("samples %d %d %d %d", numSamples, buf[0], buf[20], buf[100]); 25 | } 26 | 27 | ExtDAC::ExtDAC(WSynthesizer &data) : src(data) { 28 | dac = this; 29 | } 30 | 31 | } // namespace music -------------------------------------------------------------------------------- /libs/mixer---ext/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/mixer---linux/SoundOutput.h: -------------------------------------------------------------------------------- 1 | #define SAMPLE_RATE 44100 2 | 3 | namespace music { 4 | class WSynthesizer; 5 | 6 | class LinuxDAC { 7 | public: 8 | int16_t data[256]; 9 | WSynthesizer &src; 10 | LinuxDAC(WSynthesizer &data); 11 | static void *play(void *); 12 | int getSampleRate() { return SAMPLE_RATE; } 13 | }; 14 | 15 | class SoundOutput { 16 | public: 17 | LinuxDAC dac; 18 | 19 | SoundOutput(WSynthesizer &data) : dac(data) {} 20 | 21 | void setOutput(int) {} 22 | }; 23 | 24 | } // namespace music -------------------------------------------------------------------------------- /libs/mixer---linux/pins.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/mixer---linux/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mixer---linux", 3 | "additionalFilePath": "../mixer" 4 | } 5 | -------------------------------------------------------------------------------- /libs/mixer---linux/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // make sure sound starts 2 | new music.Melody("!440,100").playUntilDone(1) 3 | -------------------------------------------------------------------------------- /libs/mixer---none/SoundOutput.h: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/mixer---none/melody.cpp: -------------------------------------------------------------------------------- 1 | #include "pxt.h" 2 | #include "melody.h" 3 | 4 | namespace music { 5 | //% 6 | void forceOutput(int outp) {} 7 | 8 | //% 9 | void queuePlayInstructions(int when, Buffer buf) { 10 | } 11 | 12 | //% 13 | void enableAmp(int enabled) { 14 | 15 | } 16 | 17 | } // namespace music 18 | -------------------------------------------------------------------------------- /libs/mixer---none/melody.h: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/mixer---none/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mixer---none", 3 | "additionalFilePath": "../mixer" 4 | } 5 | -------------------------------------------------------------------------------- /libs/mixer---nrf52/SoundOutput.h: -------------------------------------------------------------------------------- 1 | #include "NRF52PWM.h" 2 | #include "Synthesizer.h" 3 | #include "Mixer.h" 4 | 5 | class SoundOutput { 6 | public: 7 | NRF52PWM dac; 8 | 9 | SoundOutput(DataSource &data) : dac(NRF_PWM0, data) { 10 | dac.connectPin(*LOOKUP_PIN(JACK_SND), 0); 11 | } 12 | 13 | void setOutput(int output) { } 14 | }; 15 | -------------------------------------------------------------------------------- /libs/mixer---nrf52/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mixer---nrf52", 3 | "additionalFilePath": "../mixer" 4 | } 5 | -------------------------------------------------------------------------------- /libs/mixer---rp2040/SoundOutput.h: -------------------------------------------------------------------------------- 1 | #include "RP2040PWM.h" 2 | #include "Synthesizer.h" 3 | #include "Mixer.h" 4 | 5 | namespace jacdac { 6 | void setJackRouterOutput(int output); 7 | } 8 | 9 | class SoundOutput { 10 | public: 11 | RP2040PWM dac; 12 | 13 | SoundOutput(DataSource &data) : dac(*LOOKUP_PIN(JACK_SND), data, 44000) { 14 | jacdac::setJackRouterOutput(-1); 15 | } 16 | 17 | void setOutput(int output) { jacdac::setJackRouterOutput(output); } 18 | }; 19 | -------------------------------------------------------------------------------- /libs/mixer---rp2040/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mixer---rp2040", 3 | "additionalFilePath": "../mixer" 4 | } 5 | -------------------------------------------------------------------------------- /libs/mixer---samd/SoundOutput.h: -------------------------------------------------------------------------------- 1 | #include "SAMDDAC.h" 2 | #include "Synthesizer.h" 3 | #include "Mixer.h" 4 | 5 | namespace jacdac { 6 | void setJackRouterOutput(int output); 7 | } 8 | 9 | class SoundOutput { 10 | public: 11 | SAMDDAC dac; 12 | 13 | SoundOutput(DataSource &data) : dac(*pxt::lookupPin(PIN_PA02), data) { 14 | jacdac::setJackRouterOutput(-1); 15 | } 16 | 17 | void setOutput(int output) { jacdac::setJackRouterOutput(output); } 18 | }; 19 | -------------------------------------------------------------------------------- /libs/mixer---samd/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mixer---samd", 3 | "additionalFilePath": "../mixer" 4 | } 5 | -------------------------------------------------------------------------------- /libs/mixer---stm32/SoundOutput.h: -------------------------------------------------------------------------------- 1 | #include "ZPWM.h" 2 | #include "Synthesizer.h" 3 | #include "Mixer.h" 4 | 5 | namespace jacdac { 6 | void setJackRouterOutput(int output); 7 | } 8 | 9 | class SoundOutput { 10 | public: 11 | ZPWM dac; 12 | 13 | SoundOutput(DataSource &data) : dac(*LOOKUP_PIN(JACK_SND), data) { 14 | jacdac::setJackRouterOutput(-1); 15 | } 16 | 17 | void setOutput(int output) { jacdac::setJackRouterOutput(output); } 18 | }; 19 | -------------------------------------------------------------------------------- /libs/mixer---stm32/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mixer---stm32", 3 | "additionalFilePath": "../mixer" 4 | } 5 | -------------------------------------------------------------------------------- /libs/mixer/SoundOutput.h: -------------------------------------------------------------------------------- 1 | #include "dmac.h" 2 | #include "SAMD21DAC.h" 3 | #include "Mixer.h" 4 | 5 | // DAC always on PA02 on SAMD21 6 | #define DAC_PIN PA02 7 | 8 | class SoundOutput { 9 | public: 10 | SAMD21DAC dac; 11 | 12 | SoundOutput(DataSource &data) : dac(*lookupPin(DAC_PIN), pxt::getWDMAC()->dmac, data) {} 13 | 14 | void setOutput(int output) { (void)output; } 15 | }; 16 | -------------------------------------------------------------------------------- /libs/mixer/docs/reference/music/beat.md: -------------------------------------------------------------------------------- 1 | # beat 2 | 3 | Get the length of time for a musical beat. 4 | 5 | ```sig 6 | music.beat(BeatFraction.Whole) 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * ``fraction`` means fraction of a beat (BeatFraction.Whole, BeatFraction.Sixteenth, etc.) 12 | 13 | ## Returns 14 | 15 | * a [number](/types/number) that is the amount of time in milliseconds (one-thousandth of a second) for the beat fraction. 16 | 17 | ## Example #example 18 | 19 | ```blocks 20 | music.playTone(Note.C, music.beat(BeatFraction.Quarter)) 21 | ``` 22 | 23 | ## See also #seealso 24 | 25 | [play tone](/reference/music/play-tone), [ring tone](/reference/music/ring-tone), 26 | [rest](/reference/music/rest), [set tempo](/reference/music/set-tempo), 27 | [change tempo by](/reference/music/change-tempo-by) 28 | -------------------------------------------------------------------------------- /libs/mixer/docs/reference/music/tempo.md: -------------------------------------------------------------------------------- 1 | # tempo 2 | 3 | Find the tempo (speed) of the music that is playing right now. 4 | 5 | ```sig 6 | music.tempo() 7 | ``` 8 | 9 | ## #example 10 | 11 | ## Returns 12 | 13 | * a [number](/types/number) that means the count of beats per minute (number of 14 | beats in a minute of the music that the @boardname@ is playing right now). 15 | 16 | ## See also #seealso 17 | 18 | [play tone](/reference/music/play-tone), [ring tone](/reference/music/ring-tone), 19 | [rest](/reference/music/rest), [set tempo](/reference/music/set-tempo), 20 | [change tempo by](/reference/music/change-tempo-by) 21 | -------------------------------------------------------------------------------- /libs/mixer/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mixer", 3 | "description": "The music library with a mixer", 4 | "additionalFilePath": "../music", 5 | "files": [ 6 | "SoundOutput.h", 7 | "sound.cpp", 8 | "melody.h", 9 | "melody.cpp", 10 | "melody.ts", 11 | "piano.ts", 12 | "legacy.ts", 13 | "ns.ts", 14 | "targetoverrides.ts", 15 | "music.ts", 16 | "soundEffect.ts", 17 | "instrument.ts", 18 | "sequencer.ts", 19 | "playable.ts", 20 | "pxtparts.json", 21 | "headphone.svg" 22 | ], 23 | "public": true, 24 | "dependencies": { 25 | "core": "file:../core" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /libs/mixer/sound.cpp: -------------------------------------------------------------------------------- 1 | // to be overridden 2 | -------------------------------------------------------------------------------- /libs/mixer/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/mouse/docs/reference/mouse.md: -------------------------------------------------------------------------------- 1 | # Mouse 2 | 3 | Emulate mouse actions using a USB connection. 4 | 5 | ## ~ hint 6 | 7 | The @boardname@ needs a connection to a computer or other host device with a USB cable in order to emulate a mouse. This function doesn't work in the simulator. 8 | 9 | ## ~ 10 | 11 | ```cards 12 | mouse.setButton(MouseButton.Left, true); 13 | mouse.move(0, 0); 14 | mouse.turnWheel(0); 15 | ``` 16 | 17 | ## See also 18 | 19 | [move](/reference/mouse/move), [set button](/reference/mouse/set-button), [turn wheel](/reference/mouse/turn-wheel) 20 | 21 | ```package 22 | mouse 23 | ``` -------------------------------------------------------------------------------- /libs/mouse/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum MouseButton { 5 | //% block="left" enumval=1 6 | Left = 0x01, 7 | //% block="right" enumval=2 8 | Right = 0x02, 9 | //% block="middle" enumval=4 10 | Middle = 0x04, 11 | } 12 | 13 | // Auto-generated. Do not edit. Really. 14 | -------------------------------------------------------------------------------- /libs/mouse/mouse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Mouse emulation 3 | */ 4 | //% icon="\uf245" color="#303030" 5 | namespace mouse { 6 | /** 7 | * Generates a mouse click 8 | * @param button the button to click 9 | */ 10 | //% help=mouse/click 11 | //% blockId=mouseClick block="mouse click button $button" 12 | //% weight=100 13 | export function click(button: MouseButton): void { 14 | mouse.setButton(button, true) 15 | mouse.setButton(button, false) 16 | } 17 | } -------------------------------------------------------------------------------- /libs/mouse/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mouse", 3 | "description": "Mouse emulation over HID", 4 | "files": [ 5 | "mouse.cpp", 6 | "shims.d.ts", 7 | "enums.d.ts", 8 | "mouse.ts" 9 | ], 10 | "tests": [ 11 | "test.ts" 12 | ], 13 | "public": true, 14 | "dependencies": { 15 | "core": "file:../core" 16 | }, 17 | "yotta": { 18 | "config": { 19 | "DEVICE_USB": 1, 20 | "DEVICE_MOUSE": 1 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /libs/mouse/sim/mouse.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim.mouse { 2 | export function setButton(button: number, down: boolean): void { 3 | } 4 | export function move(x: number, y: number): void { 5 | } 6 | export function turnWheel(w: number): void { 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /libs/mqtt/README.md: -------------------------------------------------------------------------------- 1 | # MQTT 2 | 3 | MQTT communication layer. A port of https://github.com/rovale/micro-mqtt for MakeCode. 4 | -------------------------------------------------------------------------------- /libs/mqtt/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mqtt", 3 | "description": "MQTT for MakeCode - beta", 4 | "files": [ 5 | "README.md", 6 | "mqtt.ts" 7 | ], 8 | "tests": [ 9 | "test.ts" 10 | ], 11 | "public": true, 12 | "dependencies": { 13 | "core": "file:../core", 14 | "net": "file:../net" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /libs/mqtt/test.ts: -------------------------------------------------------------------------------- 1 | // TODO -------------------------------------------------------------------------------- /libs/multiplayer/README.md: -------------------------------------------------------------------------------- 1 | # Multplayer 2 | 3 | Additional blocks for multiplayer. For networked and same-screen alike. 4 | 5 | -------------------------------------------------------------------------------- /libs/multiplayer/docs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/multiplayer/docs/.gitkeep -------------------------------------------------------------------------------- /libs/multiplayer/docs/reference/multiplayer/on-life-zero.md: -------------------------------------------------------------------------------- 1 | # on Life Zero 2 | 3 | Run some code when a player's life points reach zero. 4 | 5 | ```sig 6 | mp.onLifeZero(function (player) {}) 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **handler**: the code to run when any player's life points reach the value of `0`. 12 | 13 | ## Example #example 14 | 15 | Make the player's sprite put up an emergency message when their life points get to zero. 16 | 17 | ```blocks 18 | mp.onLifeZero(function (player) { 19 | mp.getPlayerSprite(player).sayText("Medic, help!!!") 20 | }) 21 | ``` 22 | ## See also #seealso 23 | 24 | [on score](/reference/multiplayer/on-score) 25 | 26 | ```package 27 | multiplayer 28 | ``` 29 | -------------------------------------------------------------------------------- /libs/multiplayer/docs/reference/multiplayer/on-score.md: -------------------------------------------------------------------------------- 1 | # on Score 2 | 3 | Run some code when a player's score reaches a given value. 4 | 5 | ```sig 6 | mp.onScore(100, function (player) {}) 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **score**: a [number](/types/number) that is the score value to trigger the event. 12 | * **handler**: the code to run when any player's score reaches the value in **score**. 13 | 14 | ## Example #example 15 | 16 | Reward each player that reaches a score of `100` with `1` more life point. 17 | 18 | ```blocks 19 | mp.onScore(100, function (player) { 20 | mp.changePlayerStateBy(player, MultiplayerState.score, 1) 21 | }) 22 | ``` 23 | 24 | ## See also #seealso 25 | 26 | [on life zero](/reference/multiplayer/on-life-zero) 27 | 28 | ```package 29 | multiplayer 30 | ``` 31 | -------------------------------------------------------------------------------- /libs/multiplayer/fieldEditors.ts: -------------------------------------------------------------------------------- 1 | namespace mp { 2 | /** 3 | * A type of state to get for a player 4 | */ 5 | //% shim=KIND_GET 6 | //% blockId=mp_multiplayerstate 7 | //% block="$kind" 8 | //% kindNamespace=MultiplayerState 9 | //% kindMemberName=value 10 | //% kindPromptHint="e.g. Cooldown, Speed, Attack..." 11 | //% blockHidden 12 | //% help=multiplayer/multiplayer-state 13 | export function _multiplayerState(kind: number): number { 14 | return kind; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /libs/multiplayer/ns.ts: -------------------------------------------------------------------------------- 1 | //% color="#207a77" weight=96 icon="\uf0c0" 2 | //% blockGap=8 3 | //% block="Multiplayer" 4 | //% groups='["Player", "Controller", "Info", "Game", "Utility"]' 5 | namespace mp { 6 | } 7 | -------------------------------------------------------------------------------- /libs/multiplayer/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "multiplayer", 3 | "description": "Additional blocks for building multiplayer games", 4 | "files": [ 5 | "README.md", 6 | "ns.ts", 7 | "fieldEditors.ts", 8 | "images.ts", 9 | "player.ts", 10 | "stateKind.ts", 11 | "targetoverrides.ts" 12 | ], 13 | "testFiles": [ 14 | "test.ts" 15 | ], 16 | "public": true, 17 | "dependencies": { 18 | "game": "file:../game" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /libs/multiplayer/stateKind.ts: -------------------------------------------------------------------------------- 1 | namespace MultiplayerState { 2 | let nextKind: number; 3 | 4 | export function create() { 5 | if (nextKind === undefined) nextKind = 0; 6 | return nextKind++; 7 | } 8 | 9 | //% isKind 10 | export const score = create(); 11 | 12 | //% isKind 13 | export const life = create(); 14 | } 15 | -------------------------------------------------------------------------------- /libs/multiplayer/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // TODO any platform specific overrides -------------------------------------------------------------------------------- /libs/multiplayer/test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/multiplayer/test.ts -------------------------------------------------------------------------------- /libs/music---linux/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum SoundOutputDestination { 5 | //% block="pin" 6 | Pin = 1, 7 | //% block="speaker" 8 | Speaker = 0, 9 | } 10 | 11 | // Auto-generated. Do not edit. Really. 12 | -------------------------------------------------------------------------------- /libs/music---linux/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "music---linux", 3 | "additionalFilePath": "../music" 4 | } 5 | -------------------------------------------------------------------------------- /libs/music---linux/shims.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | declare namespace music { 3 | 4 | /** 5 | * Play a tone through the speaker for some amount of time. 6 | * @param frequency pitch of the tone to play in Hertz (Hz), eg: Note.C 7 | * @param ms tone duration in milliseconds (ms), eg: BeatFraction.Half 8 | */ 9 | //% help=music/play-tone 10 | //% blockId=music_play_note block="play tone|at %note=device_note|for %duration=device_beat" 11 | //% parts="headphone" async 12 | //% blockNamespace=music 13 | //% weight=76 blockGap=8 shim=music::playTone 14 | function playTone(frequency: int32, ms: int32): void; 15 | } 16 | 17 | // Auto-generated. Do not edit. Really. 18 | -------------------------------------------------------------------------------- /libs/music---pwm/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum SoundOutputDestination { 5 | //% block="pin" 6 | Pin = 1, 7 | //% block="speaker" 8 | Speaker = 0, 9 | } 10 | 11 | // Auto-generated. Do not edit. Really. 12 | -------------------------------------------------------------------------------- /libs/music---pwm/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "music---pwm", 3 | "additionalFilePath": "../music" 4 | } 5 | -------------------------------------------------------------------------------- /libs/music---pwm/shims.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | declare namespace music { 3 | 4 | /** 5 | * Play a tone through the speaker for some amount of time. 6 | * @param frequency pitch of the tone to play in Hertz (Hz), eg: Note.C 7 | * @param ms tone duration in milliseconds (ms), eg: BeatFraction.Half 8 | */ 9 | //% help=music/play-tone 10 | //% blockId=music_play_note block="play tone|at %note=device_note|for %duration=device_beat" 11 | //% parts="headphone" async 12 | //% blockNamespace=music 13 | //% weight=76 blockGap=8 shim=music::playTone 14 | function playTone(frequency: int32, ms: int32): void; 15 | } 16 | 17 | // Auto-generated. Do not edit. Really. 18 | -------------------------------------------------------------------------------- /libs/music/README.md: -------------------------------------------------------------------------------- 1 | # music 2 | 3 | The music library. 4 | 5 | -------------------------------------------------------------------------------- /libs/music/docs/reference/music.md: -------------------------------------------------------------------------------- 1 | # Music 2 | 3 | Make music and play tones. 4 | 5 | ```cards 6 | music.playTone(0, 0); 7 | music.ringTone(0); 8 | music.rest(0); 9 | music.noteFrequency(Note.C); 10 | music.beat(BeatFraction.Whole); 11 | music.tempo(); 12 | music.changeTempoBy(20); 13 | music.setTempo(120); 14 | music.playSound("") 15 | music.playSoundUntilDone("") 16 | music.setVolume(0) 17 | music.stopAllSounds() 18 | music.sounds(Sounds.BaDing) 19 | ``` 20 | 21 | ### See Also 22 | 23 | [playTone](/reference/music/play-tone), [ringTone](/reference/music/ring-tone), [rest](/reference/music/rest), [beat](/reference/music/beat), [tempo](/reference/music/tempo), [changeTempoBy](/reference/music/change-tempo-by),[setTempo](/reference/music/set-tempo) 24 | -------------------------------------------------------------------------------- /libs/music/docs/reference/music/beat.md: -------------------------------------------------------------------------------- 1 | # beat 2 | 3 | Get the length of time for a musical beat. 4 | 5 | ```sig 6 | music.beat(BeatFraction.Whole) 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * ``fraction`` means fraction of a beat (BeatFraction.Whole, BeatFraction.Sixteenth, etc.) 12 | 13 | ## Returns 14 | 15 | * a [number](/types/number) that is the amount of time in milliseconds (one-thousandth of a second) for the beat fraction. 16 | 17 | ## Example #example 18 | 19 | ```blocks 20 | music.playTone(Note.C, music.beat(BeatFraction.Quarter)) 21 | ``` 22 | 23 | ## See also #seealso 24 | 25 | [play tone](/reference/music/play-tone), [ring tone](/reference/music/ring-tone), 26 | [rest](/reference/music/rest), [set tempo](/reference/music/set-tempo), 27 | [change tempo by](/reference/music/change-tempo-by) 28 | 29 | ```package 30 | music 31 | ``` -------------------------------------------------------------------------------- /libs/music/docs/reference/music/set-speaker-volume.md: -------------------------------------------------------------------------------- 1 | # set Speaker Volume 2 | 3 | Set the volume for the speaker on the board. 4 | 5 | ```sig 6 | music.setSpeakerVolume(128) 7 | ``` 8 | 9 | ## #simnote 10 | #### ~hint 11 | **Simulator**: ``||music:set speaker volume||`` works on the @boardname@. It might not work in the simulator on every browser. 12 | #### ~ 13 | 14 | ## Parameters 15 | 16 | * ``volume``: the volume of of the sounds played on the speaker. The volume [number](/reference/types) can be 17 | between `0` for silent and `255` for the loudest sound. 18 | 19 | ## Example #example 20 | 21 | Set the speaker volume to something quieter. 22 | 23 | ```blocks 24 | music.setSpeakerVolume(50) 25 | music.playSound(music.sounds(Sounds.BaDing)) 26 | ``` 27 | 28 | ## See also #seealso 29 | 30 | [play sound](/reference/music/play-sound), [sounds](/reference/music/sounds) 31 | 32 | -------------------------------------------------------------------------------- /libs/music/docs/reference/music/set-tone.md: -------------------------------------------------------------------------------- 1 | # Set Tone 2 | 3 | Specifies the PCM sample used to generate tones. 4 | 5 | ```sig 6 | music.setTone(null) 7 | ``` 8 | 9 | ## #simnote 10 | #### ~hint 11 | **Simulator**: ``||music:set tone||`` works on the @boardname@. It might not work in the simulator on every browser. 12 | #### ~ 13 | 14 | ## Parameters 15 | 16 | * ``buffer``: a buffer containing 1024 10bit unsigned samples. 17 | 18 | ## #example 19 | 20 | ## #seealso 21 | 22 | ```package 23 | music 24 | ``` -------------------------------------------------------------------------------- /libs/music/docs/reference/music/tempo.md: -------------------------------------------------------------------------------- 1 | # tempo 2 | 3 | Find the tempo (speed) of the music that is playing right now. 4 | 5 | ```sig 6 | music.tempo() 7 | ``` 8 | 9 | ## #example 10 | 11 | ## Returns 12 | 13 | * a [number](/types/number) that means the count of beats per minute (number of 14 | beats in a minute of the music that the @boardname@ is playing right now). 15 | 16 | ## See also #seealso 17 | 18 | [play tone](/reference/music/play-tone), [ring tone](/reference/music/ring-tone), 19 | [rest](/reference/music/rest), [set tempo](/reference/music/set-tempo), 20 | [change tempo by](/reference/music/change-tempo-by) 21 | 22 | ```package 23 | music 24 | ``` -------------------------------------------------------------------------------- /libs/music/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum SoundOutputDestination { 5 | //% block="pin" 6 | Pin = 1, 7 | //% block="speaker" 8 | Speaker = 0, 9 | } 10 | 11 | // Auto-generated. Do not edit. Really. 12 | -------------------------------------------------------------------------------- /libs/music/ns.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Generation of music tones. 4 | */ 5 | //% color=#E30FC0 weight=90 icon="\uf025" 6 | //% blockGap=8 7 | //% groups='["Songs", "Sounds", "Tone", "Volume", "Tempo"]' 8 | namespace music { 9 | } -------------------------------------------------------------------------------- /libs/music/piano.ts: -------------------------------------------------------------------------------- 1 | namespace music { 2 | /** 3 | * Get the frequency of a note. 4 | * @param name the note name, eg: Note.C 5 | */ 6 | //% weight=1 help=music/note-frequency 7 | //% blockId=device_note block="%note" 8 | //% shim=TD_ID 9 | //% color="#FFFFFF" colorSecondary="#FFFFFF" colorTertiary="#D83B01" 10 | //% note.fieldEditor="note" note.defl="262" 11 | //% note.fieldOptions.decompileLiterals=true 12 | //% useEnumVal=1 13 | //% weight=10 blockGap=8 14 | //% group="Tone" 15 | export function noteFrequency(name: Note): number { 16 | return name; 17 | } 18 | } -------------------------------------------------------------------------------- /libs/music/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "music", 3 | "description": "The music library", 4 | "files": [ 5 | "README.md", 6 | "music.cpp", 7 | "enums.d.ts", 8 | "shims.d.ts", 9 | "melodies.ts", 10 | "music.ts", 11 | "piano.ts", 12 | "ns.ts", 13 | "headphone.svg", 14 | "pxtparts.json" 15 | ], 16 | "testFiles": [ 17 | "test.ts" 18 | ], 19 | "public": true, 20 | "dependencies": { 21 | "core": "file:../core" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /libs/music/sim/state.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim { 2 | export interface MusicBoard extends CommonBoard { 3 | audioState: AudioState; 4 | 5 | getDefaultPitchPin(): Pin; 6 | } 7 | 8 | export function getAudioState() { 9 | return (board() as MusicBoard).audioState; 10 | } 11 | } -------------------------------------------------------------------------------- /libs/music/test.ts: -------------------------------------------------------------------------------- 1 | for(let i = 1000; i > 0; i -= 50) 2 | music.playTone(440, i) 3 | 4 | for(let i = 0; i < 1000; i += 20) 5 | music.playTone(440, i) 6 | -------------------------------------------------------------------------------- /libs/net-game/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "net-game", 3 | "description": "WiFi support in Arcade - beta", 4 | "files": [ 5 | "settings.ts" 6 | ], 7 | "public": true, 8 | "dependencies": { 9 | "core": "file:../core", 10 | "settings": "file:../settings", 11 | "net": "file:../net", 12 | "game": "file:../game" 13 | } 14 | } -------------------------------------------------------------------------------- /libs/net/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "net", 3 | "description": "Networking abstractions", 4 | "files": [ 5 | "README.md", 6 | "controller.ts", 7 | "controllersocket.ts", 8 | "net.ts", 9 | "netutil.ts", 10 | "requests.ts" 11 | ], 12 | "public": true, 13 | "dependencies": { 14 | "core": "file:../core", 15 | "settings": "file:../settings" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /libs/palette/README.md: -------------------------------------------------------------------------------- 1 | # Palette 2 | 3 | Helpers to manipulate palette in games. -------------------------------------------------------------------------------- /libs/palette/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "palette", 3 | "description": "Palette manipulations", 4 | "files": [ 5 | "palette.ts", 6 | "README.md" 7 | ], 8 | "testFiles": [ 9 | "test.ts" 10 | ], 11 | "public": true, 12 | "weight": 10, 13 | "dependencies": { 14 | "color": "file:../color", 15 | "game": "file:../game" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /libs/palette/test.ts: -------------------------------------------------------------------------------- 1 | 2 | let mySprite = sprites.create(img` 3 | 0 1 2 3 4 | 4 5 6 7 5 | 8 9 a b 6 | c d e f 7 | `.doubled().doubled().doubled().doubled(), SpriteKind.Player) 8 | 9 | controller.A.onEvent(ControllerButtonEvent.Pressed, function () { 10 | const p = palette.defaultPalette(); 11 | for (let i = 0; i < p.length; ++i) { 12 | p.setColor(i, color.rgb(i * 16, 0, 255 - i * 16)); 13 | } 14 | p.setColor(0, 0) 15 | palette.setColors(p) 16 | }) 17 | 18 | controller.B.onEvent(ControllerButtonEvent.Pressed, function () { 19 | palette.reset() 20 | }) 21 | 22 | -------------------------------------------------------------------------------- /libs/pixel/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pixel", 3 | "description": "A single on-board light pixel", 4 | "files": [ 5 | "pixel.ts" 6 | ], 7 | "testFiles": [ 8 | ], 9 | "public": true, 10 | "dependencies": { 11 | "core": "file:../core", 12 | "light": "file:../light" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /libs/power/docs/reference/power.md: -------------------------------------------------------------------------------- 1 | # Power 2 | 3 | Power state mode control. Set the inactivity timeout and sleep state. 4 | 5 | ```cards 6 | power.poke() 7 | power.setDeepSleepTimeout(10) 8 | power.deepSleep() 9 | power.checkDeepSleep() 10 | ``` 11 | 12 | ## See Also 13 | 14 | [poke](/reference/power/poke), 15 | [set deep sleep timeout](/reference/power/set-deep-sleep-timeout), 16 | [deep sleep](/reference/power/deep-sleep), 17 | [check deep sleep](/reference/power/deep-sleep) 18 | 19 | ```package 20 | power 21 | ``` -------------------------------------------------------------------------------- /libs/power/docs/reference/power/check-deep-sleep.md: -------------------------------------------------------------------------------- 1 | # check Deep Sleep 2 | 3 | Check if the "deep sleep" timeout has elapsed and the device should be put to sleep. 4 | 5 | ```sig 6 | power.checkDeepSleep() 7 | ``` 8 | 9 | ## Returns 10 | 11 | * a [boolean](/types/boolean) value that is `true` if the sleep timeout is `0` or `false` if there is time remaining. 12 | 13 | ## Example #example 14 | 15 | Put the device to sleep if the sleep timeout has elapsed. 16 | 17 | ```blocks{ 18 | power.checkDeepSleep() 19 | ``` 20 | 21 | ## See also 22 | 23 | [set deep sleep timeout](/reference/power/set-deep-sleep-timeout), 24 | [deep sleep](/reference/power/deep-sleep) 25 | 26 | ```package 27 | power 28 | ``` -------------------------------------------------------------------------------- /libs/power/docs/reference/power/deep-sleep.md: -------------------------------------------------------------------------------- 1 | # deep Sleep 2 | 3 | Set the device into a low-power consumption mode, or "deep sleep". 4 | 5 | ```sig 6 | power.deepSleep() 7 | ``` 8 | 9 | In order to conserve power when there's no user input to process, events to handle, or indications to display, a device can go into a "deep sleep" state. In a deep sleep state the device stops normal processing of user programs and input events. During deep sleep the device may only respond to certain interrupts and necessary timer events. 10 | 11 | To bring the device out of deep sleep a hardware event, like pressing the reset button, may be required. 12 | 13 | ```blocks 14 | console.log("Feeling tired now. I'm going to sleep."); 15 | power.deepSleep() 16 | ``` 17 | 18 | ```package 19 | power 20 | ``` 21 | 22 | ## See also 23 | 24 | [set deep sleep timeout](/reference/power/set-deep-sleep-timeout) -------------------------------------------------------------------------------- /libs/power/docs/reference/power/set-deep-sleep-timeout.md: -------------------------------------------------------------------------------- 1 | # set Deep Sleep Timeout 2 | 3 | Specify the inactivity duration **in seconds** required to enter deep sleep. 4 | 5 | ```sig 6 | power.setDeepSleepTimeout(10) 7 | ``` 8 | 9 | You can set a timeout for the device to go into "deep sleep" when it has no current activity. The time is set as a number of seconds. 10 | 11 | ## Parameters 12 | 13 | * **seconds**: a [number](types/number) of seconds to wait for any system activity before the device will go into deep sleep. 14 | 15 | ## Example #example 16 | 17 | Set the inactivity timeout to `30` seconds. 18 | 19 | ```blocks 20 | power.setDeepSleepTimeout(30) 21 | ``` 22 | 23 | ## See also 24 | 25 | [check deep sleep](/reference/power/check-deep-sleep), 26 | [poke](/reference/power/poke) 27 | 28 | ```package 29 | power 30 | ``` -------------------------------------------------------------------------------- /libs/power/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "power", 3 | "description": "Power and sleep management", 4 | "files": [ 5 | "power.ts" 6 | ], 7 | "testFiles": [ 8 | ], 9 | "public": true, 10 | "dependencies": { 11 | "core": "file:../core" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /libs/proximity/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "proximity", 3 | "description": "Proximity drivers", 4 | "files": [ 5 | "proximity.ts", 6 | "vl53l0x.ts" 7 | ], 8 | "testFiles": [ 9 | ], 10 | "public": true, 11 | "dependencies": { 12 | "core": "file:../core" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /libs/pulse/README.md: -------------------------------------------------------------------------------- 1 | # pulse 2 | 3 | The Pulse library. 4 | 5 | -------------------------------------------------------------------------------- /libs/pulse/ns.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Communication between devices 3 | */ 4 | //% color=#E3008C weight=89 icon="\uf086" 5 | //% groups='["Infrared", "Cable"]' 6 | namespace network { 7 | } -------------------------------------------------------------------------------- /libs/pulse/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pulse", 3 | "description": "Communication over pulses", 4 | "files": [ 5 | "README.md", 6 | "pulse.cpp", 7 | "pulse.h", 8 | "bitvector.h", 9 | "shims.d.ts", 10 | "ns.ts" 11 | ], 12 | "public": true, 13 | "dependencies": { 14 | "core": "file:../core" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /libs/pulse/shims.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | declare namespace network { 3 | 4 | /** 5 | * Send data over cable. 6 | */ 7 | //% parts="cable" shim=network::cableSendPacket 8 | function cableSendPacket(buf: Buffer): void; 9 | 10 | /** 11 | * Get most recent packet received over cable. 12 | */ 13 | //% parts="cable" shim=network::cablePacket 14 | function cablePacket(): Buffer; 15 | 16 | /** 17 | * Run action after a packet is recieved over cable. 18 | */ 19 | //% parts="cable" shim=network::onCablePacket 20 | function onCablePacket(body: () => void): void; 21 | 22 | /** 23 | * Run action after there's an error reciving packet over cable. 24 | */ 25 | //% shim=network::onCableError 26 | function onCableError(body: () => void): void; 27 | } 28 | 29 | // Auto-generated. Do not edit. Really. 30 | -------------------------------------------------------------------------------- /libs/radio-broadcast/docs/reference/radio-broadcast.md: -------------------------------------------------------------------------------- 1 | # Radio Broadcast 2 | 3 | The Radio Broadcast extension has blocks for sending to and receiving messages from all the @boardname@ boards nearby. Just two blocks are used, one to send a broadcast message and another to run code when a broadcast message is received. 4 | 5 | A message, which is a [number](/types/number), is sent to, or received by all nearby @boardname@ boards regardless of which [Group](/reference/radio/set-group) number they are transmitting or receiving on. 6 | 7 | ## Blocks in this extension 8 | 9 | ```cards 10 | radio.sendMessage(0) 11 | radio.onReceivedMessage(0, function() {}) 12 | ``` 13 | 14 | ## See Also 15 | 16 | [send message](/reference/radio/send-message), 17 | [send value](/reference/radio/on-received-message) 18 | 19 | ```package 20 | radio-broadcast 21 | ``` -------------------------------------------------------------------------------- /libs/radio-broadcast/docs/reference/radio/on-received-message.md: -------------------------------------------------------------------------------- 1 | # on Received Message 2 | 3 | Run part of a program when the @boardname@ receives a 4 | message over ``radio``. 5 | 6 | ```sig 7 | radio.onReceivedMessage(0, function() {}) 8 | ``` 9 | 10 | ## Parameters 11 | 12 | * **msg**: The message to listen for. See [send message](/reference/radio/send-message) 13 | 14 | ## #example 15 | 16 | ## See also 17 | 18 | [Bit Radio](/reference/radio) 19 | [send message](/reference/radio/send-message), 20 | 21 | ```package 22 | radio-broadcast 23 | ``` 24 | -------------------------------------------------------------------------------- /libs/radio-broadcast/docs/reference/radio/send-message.md: -------------------------------------------------------------------------------- 1 | # send Message 2 | 3 | Broadcast a coded message to other @boardname@s connected via ``radio``. 4 | 5 | ```sig 6 | radio.sendMessage(0); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **msg**: a coded message. 12 | 13 | ## #example 14 | 15 | ## See also 16 | 17 | [Bit Radio](/reference/radio) 18 | [on received number](/reference/radio/on-received-number) 19 | 20 | ```package 21 | radio-broadcast 22 | ``` -------------------------------------------------------------------------------- /libs/radio-broadcast/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "radio-broadcast", 3 | "description": "Adds new blocks for message communication in the radio category", 4 | "files": [ 5 | "radio-broadcast.ts" 6 | ], 7 | "dependencies": { 8 | "core": "file:../core", 9 | "radio": "file:../radio" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /libs/radio/README.md: -------------------------------------------------------------------------------- 1 | # radio 2 | 3 | The radio library. 4 | 5 | -------------------------------------------------------------------------------- /libs/radio/docs/reference/radio/raise-event.md: -------------------------------------------------------------------------------- 1 | # raise Event 2 | 3 | Sends an event over radio to be raised in the event bus of other @boardname@. 4 | 5 | ```sig 6 | radio.raiseEvent(10, 10); 7 | ``` 8 | 9 | ## See Also 10 | 11 | [Bit Radio](/reference/radio) 12 | [control raise event](/reference/control/raise-event) -------------------------------------------------------------------------------- /libs/radio/docs/reference/radio/send-buffer.md: -------------------------------------------------------------------------------- 1 | # Send Buffer 2 | 3 | Sends a buffer to other @boardname@s in the area connected by radio. The 4 | maximum buffer length is 19 bytes. 5 | 6 | ```sig 7 | radio.sendBuffer(pins.createBuffer(1)) 8 | ``` 9 | 10 | ## Parameters 11 | 12 | * `msg` is a [buffer](/types/buffer) to send by radio. 13 | 14 | 15 | ## #example 16 | 17 | ## See also 18 | 19 | [Bit Radio](/reference/radio) 20 | [on received buffer](/reference/radio/on-received-buffer) 21 | 22 | ```package 23 | radio 24 | ``` -------------------------------------------------------------------------------- /libs/radio/docs/reference/radio/send-number.md: -------------------------------------------------------------------------------- 1 | # send Number 2 | 3 | Broadcast a [number](/types/number) to other @boardname@s connected via ``radio``. 4 | 5 | ```sig 6 | radio.sendNumber(0); 7 | ``` 8 | 9 | ## Parameters 10 | 11 | * **value**: a [number](/types/number) to send. 12 | 13 | ## ~ hint 14 | 15 | Watch this video to see how the radio hardware works on the @boardname@: 16 | 17 | https://www.youtube.com/watch?v=Re3H2ISfQE8 18 | 19 | ## ~ 20 | 21 | ## #example 22 | 23 | ## See also 24 | 25 | [Bit Radio](/reference/radio) 26 | [on received number](/reference/radio/on-received-number) 27 | 28 | ```package 29 | radio 30 | ``` -------------------------------------------------------------------------------- /libs/radio/docs/reference/radio/send-string.md: -------------------------------------------------------------------------------- 1 | # send String 2 | 3 | Sends a string to other @boardname@s in the area connected by radio. The 4 | maximum string length is 19 characters. 5 | 6 | ```sig 7 | radio.sendString("Hello!") 8 | ``` 9 | 10 | ## Parameters 11 | 12 | * **msg**: a [string](/types/string) to send by radio. 13 | 14 | ## ~ hint 15 | 16 | Watch this video to see how the radio hardware works on the @boardname@: 17 | 18 | https://www.youtube.com/watch?v=Re3H2ISfQE8 19 | 20 | ## ~ 21 | 22 | ## #example 23 | 24 | ## See also 25 | 26 | [Bit Radio](/reference/radio) 27 | [on received string](/reference/radio/on-received-string) 28 | 29 | ```package 30 | radio 31 | ``` -------------------------------------------------------------------------------- /libs/radio/docs/reference/radio/send-value.md: -------------------------------------------------------------------------------- 1 | # send Value 2 | 3 | Send a [string]() and [number]() together by ``radio`` to other @boardname@s. 4 | The maximum [string]() length is 8 characters. 5 | 6 | ```sig 7 | radio.sendValue("name", 0); 8 | ``` 9 | 10 | ## Parameters 11 | 12 | * **name**: a [string](/types/string) that is the name of the value to send. 13 | * **value**: a [number](/types/number) that is the value to send. 14 | 15 | ## ~ hint 16 | 17 | Watch this video to see how the radio hardware works on the @boardname@: 18 | 19 | https://www.youtube.com/watch?v=Re3H2ISfQE8 20 | 21 | ## ~ 22 | 23 | ## #example 24 | 25 | ## See also 26 | 27 | [Bit Radio](/reference/radio) 28 | [on received value](/reference/radio/on-received-value) 29 | 30 | ```package 31 | radio 32 | ``` -------------------------------------------------------------------------------- /libs/radio/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | declare namespace radio { 3 | } 4 | 5 | // Auto-generated. Do not edit. Really. 6 | -------------------------------------------------------------------------------- /libs/radio/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "radio", 3 | "description": "The radio services", 4 | "files": [ 5 | "README.md", 6 | "shims.d.ts", 7 | "enums.d.ts", 8 | "radio.cpp", 9 | "radio.ts", 10 | "targetoverrides.ts" 11 | ], 12 | "public": true, 13 | "dependencies": { 14 | "core": "file:../core" 15 | } 16 | } -------------------------------------------------------------------------------- /libs/radio/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // leave empty -------------------------------------------------------------------------------- /libs/rotary-encoder/README.md: -------------------------------------------------------------------------------- 1 | # Rotary Encoder 2 | 3 | ## Configuration 4 | 5 | Map the following pins in your bootloader to configure the default "crank". 6 | 7 | ```typescript 8 | PIN_ROTARY_ENCODER_A 9 | PIN_ROTARY_ENCODER_B 10 | ``` 11 | -------------------------------------------------------------------------------- /libs/rotary-encoder/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | declare namespace encoders { 3 | } 4 | 5 | // Auto-generated. Do not edit. Really. 6 | -------------------------------------------------------------------------------- /libs/rotary-encoder/ns.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Rotary encoders 3 | */ 4 | //% color="#03AA74" weight=87 icon="\uf021" 5 | namespace encoders { 6 | 7 | /** 8 | * Gets the default rotary encoder if any 9 | */ 10 | //% block="encoder" fixedInstance whenUsed 11 | export const defaultEncoder = encoders.createRotaryEncoder(undefined, undefined); 12 | } -------------------------------------------------------------------------------- /libs/rotary-encoder/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rotary-encoder", 3 | "description": "Driver for rotary encoder", 4 | "files": [ 5 | "rotary.cpp", 6 | "enums.d.ts", 7 | "shims.d.ts", 8 | "ns.ts", 9 | "targetoverrides.ts", 10 | "README.md" 11 | ], 12 | "public": true, 13 | "dependencies": { 14 | "core": "file:../core" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /libs/rotary-encoder/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // target specific 2 | -------------------------------------------------------------------------------- /libs/screen---ext/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "screen---ext", 3 | "additionalFilePath": "../screen" 4 | } 5 | -------------------------------------------------------------------------------- /libs/screen---linux/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "screen---linux", 3 | "additionalFilePath": "../screen" 4 | } 5 | -------------------------------------------------------------------------------- /libs/screen---st7735/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "screen---st7735", 3 | "files": [ 4 | "screen.cpp", 5 | "panic.cpp", 6 | "image.cpp", 7 | "image.ts", 8 | "screenimage.ts", 9 | "text.ts", 10 | "frame.ts", 11 | "shims.d.ts", 12 | "fieldeditors.ts", 13 | "targetoverrides.ts", 14 | "ns.ts", 15 | "image.d.ts", 16 | "pxtparts.json", 17 | "imagesoverrides.jres", 18 | "imagesoverrides.ts", 19 | "font12.jres", 20 | "jdprotocol.h", 21 | "arcadegamepad.h", 22 | "indexedscreen.h", 23 | "arcadesound.h", 24 | "jddisplay.h", 25 | "jddisplay.cpp" 26 | ], 27 | "dependencies": { 28 | "core": "file:../core" 29 | }, 30 | "additionalFilePath": "../screen" 31 | } 32 | -------------------------------------------------------------------------------- /libs/screen/frame.ts: -------------------------------------------------------------------------------- 1 | namespace control.__screen { 2 | let __update: () => void 3 | let __updated = false; 4 | 5 | export function update() { 6 | if (__update) 7 | __update() 8 | __updated = true 9 | } 10 | 11 | export function setupUpdate(update: () => void) { 12 | __updated = true; 13 | __update = update; 14 | update() 15 | } 16 | 17 | // low frequency fallback screen refresh 18 | control.runInParallel(() => { 19 | while (true) { 20 | __updated = false 21 | pause(200) 22 | if (!__updated) { 23 | __screen.update(); 24 | __updated = true 25 | } 26 | } 27 | }) 28 | } 29 | -------------------------------------------------------------------------------- /libs/screen/imagesoverrides.jres: -------------------------------------------------------------------------------- 1 | { 2 | 3 | } -------------------------------------------------------------------------------- /libs/screen/imagesoverrides.ts: -------------------------------------------------------------------------------- 1 | // replace with built-in images -------------------------------------------------------------------------------- /libs/screen/ns.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libs/screen/panic.cpp: -------------------------------------------------------------------------------- 1 | // potentially overriden in targets -------------------------------------------------------------------------------- /libs/screen/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "screen", 3 | "description": "The screen library", 4 | "files": [ 5 | "screen.cpp", 6 | "panic.cpp", 7 | "image.cpp", 8 | "image.ts", 9 | "screenimage.ts", 10 | "text.ts", 11 | "frame.ts", 12 | "shims.d.ts", 13 | "fieldeditors.ts", 14 | "targetoverrides.ts", 15 | "ns.ts", 16 | "image.d.ts", 17 | "pxtparts.json", 18 | "imagesoverrides.jres", 19 | "imagesoverrides.ts", 20 | "font12.jres" 21 | ], 22 | "public": true, 23 | "dependencies": { 24 | "core": "file:../core" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /libs/screen/screen.cpp: -------------------------------------------------------------------------------- 1 | // overriden in targets -------------------------------------------------------------------------------- /libs/screen/screenimage.ts: -------------------------------------------------------------------------------- 1 | 2 | namespace image { 3 | /** 4 | * Get the screen image 5 | */ 6 | //% blockNamespace="images" group="Create" 7 | //% blockId=imagescreen block="screen" 8 | //% help=images/screen-image 9 | export function screenImage(): Image { 10 | return screen; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /libs/screen/sim/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "noImplicitAny": true, 5 | "noImplicitReturns": true, 6 | "lib": [ 7 | "DOM", 8 | "DOM.Iterable", 9 | "ES2017" 10 | ], 11 | "rootDir": ".", 12 | "newLine": "LF", 13 | "sourceMap": false 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /libs/screen/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // This file would be usually overridden by the target. 2 | const screen = image.create(178, 128) as ScreenImage 3 | 4 | namespace _screen_internal { 5 | //% shim=pxt::updateScreen 6 | function updateScreen(img: Image): void {} 7 | //% shim=pxt::updateStats 8 | function updateStats(msg: string): void {} 9 | control.__screen.setupUpdate(() => updateScreen(screen)) 10 | control.EventContext.onStats = function(msg: string) { 11 | updateStats(msg); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /libs/serial---linux/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "serial---linux", 3 | "additionalFilePath": "../serial" 4 | } 5 | -------------------------------------------------------------------------------- /libs/serial---linux/serial-target.ts: -------------------------------------------------------------------------------- 1 | namespace serial { 2 | let _device: Serial; 3 | export function device(): Serial { 4 | if (!_device) { 5 | _device = new Serial(serial.internalCreateSerialDevice(3000)); 6 | } 7 | return _device; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /libs/serial/docs/reference/serial/attach-to-console.md: -------------------------------------------------------------------------------- 1 | # attach To Console 2 | 3 | Direct the data written to the console to go out the serial connection also. 4 | 5 | ```sig 6 | serial.attachToConsole() 7 | ``` 8 | 9 | When you attach the console to the serial transmit connection, any information you log to the console is transmitted over the serial connection too. 10 | 11 | ## Example #example 12 | 13 | Send some console log messages out through the serial connection. 14 | 15 | ```blocks 16 | serial.attachToConsole() 17 | console.log("Send this message to the serial connection") 18 | console.logValue("SerialValue", 999) 19 | ``` 20 | 21 | ## See also #seealso 22 | 23 | [redirect](/reference/serial/redirect) 24 | 25 | ```package 26 | serial 27 | ``` 28 | -------------------------------------------------------------------------------- /libs/serial/docs/reference/serial/read-buffer.md: -------------------------------------------------------------------------------- 1 | # read String 2 | 3 | Read the buffered serial data as a buffer. 4 | 5 | ```sig 6 | serial.readBuffer(); 7 | ``` 8 | 9 | ## Returns 10 | 11 | * a [buffer](/types/buffer) containing input from the serial port. The buffer is empty if no data is available. 12 | 13 | ## See also #seealso 14 | 15 | [read string](/reference/serial/read-string) 16 | 17 | ```package 18 | serial 19 | ``` -------------------------------------------------------------------------------- /libs/serial/docs/reference/serial/read-line.md: -------------------------------------------------------------------------------- 1 | # read Line 2 | 3 | Read the buffered serial data as a line of text characters. 4 | 5 | ```sig 6 | serial.readLine(); 7 | ``` 8 | 9 | Data is read from the serial receive buffer as a string, or line of text, until a newline delimiter is found. The string returned includes the newline character. 10 | 11 | ## Returns 12 | 13 | * a [string](/types/string) containing a line of text received from the serial port. The string is empty if no data is available. 14 | 15 | ## See also #seealso 16 | 17 | [read string](/reference/serial/read-string) 18 | [write line](/reference/serial/write-line), 19 | 20 | ```package 21 | serial 22 | ``` -------------------------------------------------------------------------------- /libs/serial/docs/reference/serial/read-string.md: -------------------------------------------------------------------------------- 1 | # read String 2 | 3 | Read the buffered serial data as a string. 4 | 5 | ```sig 6 | serial.readString(); 7 | ``` 8 | 9 | ## Returns 10 | 11 | * a [string](/types/string) containing input from the serial port. The string is empty if no data is available. 12 | 13 | ## See also #seealso 14 | 15 | [write string](/reference/serial/write-string) 16 | 17 | ```package 18 | serial 19 | ``` -------------------------------------------------------------------------------- /libs/serial/docs/reference/serial/read-until.md: -------------------------------------------------------------------------------- 1 | # read Until 2 | 3 | Read a text from the serial port until a delimiter is found. 4 | 5 | ```sig 6 | serial.readUntil(","); 7 | ``` 8 | 9 | ## Returns 10 | 11 | * a [string](/types/string) containing input from the serial port, such as a response typed by a user 12 | 13 | ## Example #example 14 | 15 | The following example reads strings separated by commands (``,``). 16 | 17 | ```blocks 18 | basic.forever(() => { 19 | let answer = serial.readUntil(","); 20 | serial.writeLine(answer); 21 | }); 22 | ``` 23 | 24 | ## See also #seealso 25 | 26 | [serial](/device/serial), 27 | [serial write line](/reference/serial/write-line), 28 | [serial write value](/reference/serial/write-value) 29 | -------------------------------------------------------------------------------- /libs/serial/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "serial", 3 | "description": "UART communication", 4 | "files": [ 5 | "serial-target.h", 6 | "serial-common.h", 7 | "serial-target.cpp", 8 | "serial-common.cpp", 9 | "serial-target.ts", 10 | "serial.ts", 11 | "enums.d.ts", 12 | "shims.d.ts" 13 | ], 14 | "testFiles": [ 15 | "test.ts" 16 | ], 17 | "public": true, 18 | "dependencies": { 19 | "core": "file:../core" 20 | } 21 | } -------------------------------------------------------------------------------- /libs/serial/test.ts: -------------------------------------------------------------------------------- 1 | for(let i = 0; i < 10; ++i) { 2 | serial.writeLine((++i).toString()) 3 | } -------------------------------------------------------------------------------- /libs/servo/README.md: -------------------------------------------------------------------------------- 1 | # Servo 2 | 3 | A small micro-servo library. -------------------------------------------------------------------------------- /libs/servo/ns.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Control micro servos 3 | */ 4 | //% color="#03AA74" weight=88 icon="\uf021" 5 | namespace servos { 6 | } -------------------------------------------------------------------------------- /libs/servo/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "servo", 3 | "description": "A micro-servo library", 4 | "files": [ 5 | "README.md", 6 | "servo.ts", 7 | "ns.ts", 8 | "targetoverrides.ts" 9 | ], 10 | "public": true, 11 | "dependencies": { 12 | "core": "file:../core" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /libs/servo/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // TODO any platform specific overrides -------------------------------------------------------------------------------- /libs/settings---esp32/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "settings---esp32", 3 | "description": "Settings storage in ESP32 NVS", 4 | "files": [ 5 | "settings.cpp", 6 | "settings.ts" 7 | ], 8 | "additionalFilePath": "../settings", 9 | "public": true, 10 | "dependencies": { 11 | "core": "file:../core" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /libs/settings---files/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "settings---files", 3 | "description": "Settings storage in files", 4 | "files": [ 5 | "settings.cpp", 6 | "settings.ts" 7 | ], 8 | "additionalFilePath": "../settings", 9 | "public": true, 10 | "dependencies": { 11 | "core": "file:../core" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /libs/settings/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "settings", 3 | "description": "Settings storage in internal flash", 4 | "files": [ 5 | "README.md", 6 | "RAFFS.cpp", 7 | "RAFFS.h", 8 | "Flash.h", 9 | "STM32Flash.cpp", 10 | "SAMDFlash.cpp", 11 | "NRF52Flash.cpp", 12 | "RP2040Flash.cpp", 13 | "settings.cpp", 14 | "settings.ts", 15 | "targetoverrides.ts", 16 | "shims.d.ts" 17 | ], 18 | "public": true, 19 | "dependencies": { 20 | "core": "file:../core" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /libs/settings/shims.d.ts: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/settings/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // override this if you want different amount of flash used 2 | namespace config { 3 | export const SETTINGS_SIZE_DEFL = (32*1024) 4 | // export const SETTINGS_SIZE_DEFL = (2*1024) // for SAMD21 5 | // NRF flash page size is 4096, so must be multiple of 4096 on NRF 6 | } 7 | -------------------------------------------------------------------------------- /libs/shader/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shader", 3 | "description": "Utility methods for shading images", 4 | "files": [ 5 | "shader.cpp", 6 | "shader.ts", 7 | "shims.d.ts" 8 | ], 9 | "public": true, 10 | "dependencies": { 11 | "core": "file:../core", 12 | "screen": "file:../screen" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /libs/shader/shader.ts: -------------------------------------------------------------------------------- 1 | namespace helpers { 2 | //% shim=ShaderMethods::_mapImage 3 | function _mapImage(toShade: Image, shadeLevels: Image, xy: number, m: Buffer): void { } 4 | 5 | export function mapImage(toShade: Image, shadeLevels: Image, x: number, y: number, m: Buffer) { 6 | _mapImage(toShade, shadeLevels, pack(x, y), m); 7 | } 8 | 9 | //% shim=ShaderMethods::_mergeImage 10 | function _mergeImage(dst: Image, src: Image, xy: number): void { } 11 | 12 | export function mergeImage(dst: Image, src: Image, x: number, y: number) { 13 | _mergeImage(dst, src, pack(x, y)); 14 | } 15 | 16 | function pack(x: number, y: number) { 17 | return (Math.clamp(-30000, 30000, x | 0) & 0xffff) | (Math.clamp(-30000, 30000, y | 0) << 16) 18 | } 19 | } -------------------------------------------------------------------------------- /libs/sprite-scaling/README.md: -------------------------------------------------------------------------------- 1 | # Sprite Scaling 2 | 3 | Additional sprite scaling methods. 4 | -------------------------------------------------------------------------------- /libs/sprite-scaling/docs/reference/sprite-scaling.md: -------------------------------------------------------------------------------- 1 | # Sprite Scaling 2 | 3 | Scale sprites to expand or shrink their size. 4 | 5 | ## Scaling 6 | 7 | ```cards 8 | scaling.scaleByPercent(null, 50, ScaleDirection.Uniformly, ScaleAnchor.Middle) 9 | scaling.scaleByPixels(null, 1, ScaleDirection.Uniformly, ScaleAnchor.Middle) 10 | scaling.scaleToPercent(null, 100, ScaleDirection.Uniformly, ScaleAnchor.Middle) 11 | scaling.scaleToPixels(null, 1, ScaleDirection.Uniformly, ScaleAnchor.Middle) 12 | ``` 13 | 14 | ## See also 15 | 16 | [scale by percent](/reference/sprites/scaling/scale-by-pixels), 17 | [scale by pixels](/reference/sprites/scaling/scale-by-percent), 18 | [scale to pixels](/reference/sprites/scaling/scale-to-pixels), 19 | [scale to percent](/reference/sprites/scaling/scale-to-percent) 20 | 21 | ```package 22 | sprite-scaling 23 | ``` -------------------------------------------------------------------------------- /libs/sprite-scaling/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sprite-scaling", 3 | "description": "Additional scaling blocks for sprites", 4 | "files": [ 5 | "README.md", 6 | "scaling.ts", 7 | "targetoverrides.ts" 8 | ], 9 | "testFiles": [ 10 | "test.ts" 11 | ], 12 | "public": true, 13 | "dependencies": { 14 | "game": "file:../game" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /libs/sprite-scaling/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // TODO any platform specific overrides -------------------------------------------------------------------------------- /libs/sprite-scaling/test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/sprite-scaling/test.ts -------------------------------------------------------------------------------- /libs/storage/GhostSNORFS.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_GHOSTSNORFS_H 2 | #define DEVICE_GHOSTSNORFS_H 3 | 4 | #include "GhostFAT.h" 5 | #include "SNORFS.h" 6 | 7 | namespace codal 8 | { 9 | 10 | class GhostSNORFS : public GhostFAT 11 | { 12 | protected: 13 | snorfs::FS &fs; 14 | snorfs::File *currFile; 15 | GFATEntry *currEntry; 16 | 17 | static void readFlash(GFATEntry *ent, unsigned blockAddr, char *dst); 18 | static void readFile(GFATEntry *ent, unsigned blockAddr, char *dst); 19 | 20 | public: 21 | GhostSNORFS(snorfs::FS &fs); 22 | virtual void addFiles(); 23 | }; 24 | 25 | } 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /libs/storage/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "storage", 3 | "description": "USB Pen-drive support and flash storage", 4 | "files": [ 5 | "SNORFS.cpp", 6 | "SNORFS.h", 7 | "GhostSNORFS.cpp", 8 | "GhostSNORFS.h", 9 | "storage.cpp", 10 | "storage.ts", 11 | "shims.d.ts" 12 | ], 13 | "public": true, 14 | "dependencies": { 15 | "core": "file:../core" 16 | }, 17 | "yotta": { 18 | "config": { 19 | "DEVICE_USB": 1 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /libs/storage/sim/state.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim { 2 | export class StorageState { 3 | files: pxsim.Map = {}; 4 | } 5 | 6 | export interface StorageBoard extends CommonBoard { 7 | storageState: StorageState; 8 | } 9 | 10 | export function storageState() { 11 | return (board() as StorageBoard).storageState; 12 | } 13 | } -------------------------------------------------------------------------------- /libs/storyboard/README.md: -------------------------------------------------------------------------------- 1 | # Storyboard 2 | 3 | Orchestrate scenes -------------------------------------------------------------------------------- /libs/storyboard/loader.ts: -------------------------------------------------------------------------------- 1 | namespace storyboard { 2 | function loader(done: () => void) { 3 | const font = image.font8; 4 | let m = 40; 5 | let w = screen.width - 2 * m; 6 | let c = 2; 7 | let y = screen.height / 2 - c; 8 | let x = 0; 9 | game.onPaint(function() { 10 | screen.printCenter("MakeCode Arcade", y - font.charHeight - c, 1, font); 11 | screen.drawRect(m, y, w, 2 * c, 1) 12 | screen.fillRect(m, y + 1, x, 2 * c - 2, 3); 13 | 14 | x++; 15 | if (x == w) done(); 16 | }) 17 | } 18 | 19 | /** 20 | * Default boot sequence 21 | */ 22 | //% block="loader" fixedInstance whenUsed 23 | export const loaderBootSequence = new BootSequence(loader, 0); 24 | } -------------------------------------------------------------------------------- /libs/storyboard/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "storyboard", 3 | "description": "Scene manager", 4 | "files": [ 5 | "storyboard.ts", 6 | "loader.ts", 7 | "README.md" 8 | ], 9 | "testFiles": [ 10 | "test.ts" 11 | ], 12 | "public": true, 13 | "weight": 10, 14 | "dependencies": { 15 | "game": "file:../game", 16 | "color": "file:../color", 17 | "palette": "file:../palette" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /libs/switch/README.md: -------------------------------------------------------------------------------- 1 | # switch 2 | 3 | The build-in slide switch library. 4 | -------------------------------------------------------------------------------- /libs/switch/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum SwitchDirection { 5 | //% block="left" 6 | Left = 2, // DEVICE_BUTTON_EVT_UP 7 | //% block="right" 8 | Right = 1, // DEVICE_BUTTON_EVT_DOWN 9 | } 10 | 11 | // Auto-generated. Do not edit. Really. 12 | -------------------------------------------------------------------------------- /libs/switch/ns.ts: -------------------------------------------------------------------------------- 1 | //% color="#d65cd6" 2 | namespace input { 3 | } 4 | -------------------------------------------------------------------------------- /libs/switch/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "switch", 3 | "description": "A slide switch", 4 | "files": [ 5 | "README.md", 6 | "switch.cpp", 7 | "ns.ts", 8 | "shims.d.ts", 9 | "enums.d.ts" 10 | ], 11 | "dependencies": { 12 | "core": "file:../core" 13 | }, 14 | "public": true 15 | } 16 | -------------------------------------------------------------------------------- /libs/switch/sim/state.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim { 2 | export interface SlideSwitchBoard extends CommonBoard { 3 | slideSwitchState: SlideSwitchState; 4 | } 5 | } -------------------------------------------------------------------------------- /libs/tests/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tests", 3 | "description": "A unit test library", 4 | "files": [ 5 | "README.md", 6 | "tests.ts", 7 | "targetoverrides.ts" 8 | ], 9 | "testFiles": [ 10 | ], 11 | "public": true, 12 | "dependencies": { 13 | "core": "file:../core" 14 | } 15 | } -------------------------------------------------------------------------------- /libs/tests/targetoverrides.ts: -------------------------------------------------------------------------------- 1 | // override this file in targets for target specific setup 2 | -------------------------------------------------------------------------------- /libs/text-to-speech/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "text-to-speech", 3 | "description": "Browser-only text to speech support", 4 | "files": [ 5 | "shims.d.ts", 6 | "tts.ts" 7 | ], 8 | "testFiles": [ 9 | ], 10 | "public": true, 11 | "dependencies": { 12 | "core": "file:../core" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /libs/thermometer/README.md: -------------------------------------------------------------------------------- 1 | # temperature 2 | 3 | The temperature library. 4 | 5 | -------------------------------------------------------------------------------- /libs/thermometer/docs/reference/input.md: -------------------------------------------------------------------------------- 1 | # @extends 2 | 3 | ## #thermometer 4 | 5 | ```cards 6 | input.onTemperatureConditionChanged(TemperatureCondition.Hot, 15, TemperatureUnit.Celsius, () => { 7 | 8 | }) 9 | input.temperature(TemperatureUnit.Celsius); 10 | ``` 11 | 12 | ```package 13 | thermometer 14 | ``` 15 | -------------------------------------------------------------------------------- /libs/thermometer/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum TemperatureCondition { 5 | //% block="hot" 6 | Hot = 2, // SENSOR_THRESHOLD_HIGH 7 | //% block="cold" 8 | Cold = 1, // SENSOR_THRESHOLD_LOW 9 | } 10 | 11 | 12 | declare const enum TemperatureUnit { 13 | //% block="°C" 14 | Celsius = 0, 15 | //% block="°F" 16 | Fahrenheit = 1, 17 | } 18 | 19 | // Auto-generated. Do not edit. Really. 20 | -------------------------------------------------------------------------------- /libs/thermometer/ns.ts: -------------------------------------------------------------------------------- 1 | 2 | //% color="#B4009E" weight=98 icon="\uf192" 3 | namespace input { 4 | } -------------------------------------------------------------------------------- /libs/thermometer/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "thermometer", 3 | "description": "A thermometer driver", 4 | "files": [ 5 | "README.md", 6 | "temperature.cpp", 7 | "target_temperature.h", 8 | "shims.d.ts", 9 | "enums.d.ts", 10 | "ns.ts" 11 | ], 12 | "testFiles": [ 13 | "test.ts" 14 | ], 15 | "public": true, 16 | "dependencies": { 17 | "core": "file:../core" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /libs/thermometer/sim/state.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim { 2 | export interface TemperatureBoard extends CommonBoard { 3 | thermometerState: AnalogSensorState; 4 | thermometerUnitState: TemperatureUnit; 5 | } 6 | 7 | export function thermometerState(): AnalogSensorState { 8 | return (board() as TemperatureBoard).thermometerState; 9 | } 10 | 11 | export function setThermometerUnit(unit: TemperatureUnit) { 12 | (board() as TemperatureBoard).thermometerUnitState = unit; 13 | } 14 | } -------------------------------------------------------------------------------- /libs/thermometer/test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/thermometer/test.ts -------------------------------------------------------------------------------- /libs/touch/README.md: -------------------------------------------------------------------------------- 1 | # touch 2 | 3 | The capacitive touch library. 4 | 5 | -------------------------------------------------------------------------------- /libs/touch/docs/reference/input/touch/calibrate.md: -------------------------------------------------------------------------------- 1 | # calibrate 2 | 3 | Begin calibrating the touch pin or button. 4 | 5 | ```sig 6 | input.touchA1.calibrate() 7 | ``` 8 | 9 | Over time, the sensitivity of a touch pin can change. This is due to a change in the surface of the touch area for the pin, such as how clean the pin is, or if the temperature and humidity have changed. If a touch pin takes more or less pressure to detect a pin press than you want, you can start an new calibration. 10 | 11 | After starting the calibration, the process will take several touch presses to complete. 12 | 13 | ## Example #example 14 | 15 | Start the touch pin calibration process. 16 | 17 | ```blocks 18 | input.touchA1.calibrate(); 19 | ``` 20 | 21 | ## See also #seealso 22 | 23 | [set-threshold](/reference/input/touch/set-threshold) 24 | 25 | ```package 26 | touch 27 | ``` 28 | -------------------------------------------------------------------------------- /libs/touch/enums.d.ts: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/touch/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "touch", 3 | "description": "The capacitive touch library", 4 | "files": [ 5 | "README.md", 6 | "touch.h", 7 | "touch.cpp", 8 | "touch.ts", 9 | "shims.d.ts", 10 | "enums.d.ts" 11 | ], 12 | "testFiles": [ 13 | "test.ts" 14 | ], 15 | "public": true, 16 | "dependencies": { 17 | "core": "file:../core", 18 | "buttons": "file:../buttons" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /libs/touch/sim/state.ts: -------------------------------------------------------------------------------- 1 | namespace pxsim { 2 | export interface CapTouchBoard extends CommonBoard { 3 | touchButtonState: TouchButtonState; 4 | } 5 | } -------------------------------------------------------------------------------- /libs/touch/test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/pxt-common-packages/8df414158089efb367d77eac4ac0c600ee6e93e2/libs/touch/test.ts -------------------------------------------------------------------------------- /libs/touch/touch.h: -------------------------------------------------------------------------------- 1 | #define TouchButton CapTouchButton * 2 | -------------------------------------------------------------------------------- /libs/touch/touch.ts: -------------------------------------------------------------------------------- 1 | //% noRefCounting fixedInstances 2 | interface TouchButton extends Button { 3 | // methods filled from C++ 4 | } 5 | -------------------------------------------------------------------------------- /libs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "noImplicitAny": true, 5 | "noImplicitReturns": true, 6 | "outDir": "../built", 7 | "newLine": "LF", 8 | "sourceMap": false, 9 | "types": [] 10 | }, 11 | "include": [ 12 | "*/*.ts", 13 | "../../pxt/libs/pxt-common/*.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /libs/wifi---esp32/README.md: -------------------------------------------------------------------------------- 1 | # Wifi ESP32 2 | 3 | 4 | ## Developer 5 | 6 | Build instructions 7 | * install ESP IDF 4.3.1 8 | * clone https://github.com/microsoft/pxt-common-packages, link to . 9 | * clone https://github.com/microsoft/pxt-maker, link pxt-common-packages 10 | * create projects/... in maker, clone https://github.com/microsoft/pxt-jacdac 11 | * open wifi--esp32 12 | * sh run.sh 13 | -------------------------------------------------------------------------------- /libs/wifi---esp32/buildlogin.sh: -------------------------------------------------------------------------------- 1 | npx html-minifier --removeAttributeQuotes --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --quoteCharacter "'" --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true --html5 true -o login.html login.full.html 2 | -------------------------------------------------------------------------------- /libs/wifi---esp32/certs.md: -------------------------------------------------------------------------------- 1 | # Certificates 2 | 3 | The built-in certificate list is intersection of the 4 | [list used by Mozilla](https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt) 5 | with the [Microsoft Trusted Root Program](https://docs.microsoft.com/en-us/security/trusted-root/participants-list) 6 | 7 | To re-generate the list do the following: 8 | 9 | ```bash 10 | curl https://raw.githubusercontent.com/curl/curl/master/lib/mk-ca-bundle.pl > mk-ca-bundle.pl 11 | perl mk-ca-bundle.pl -f 12 | node filter-bundle.js ca-bundle.crt ca-bundle.pem 13 | ``` 14 | 15 | The `ca-bundle.pem` file should be checked in. Once you have the commit sha, you need to update `certs.mk` elsewhere 16 | in this repository. 17 | 18 | -------------------------------------------------------------------------------- /libs/wifi---esp32/enums.d.ts: -------------------------------------------------------------------------------- 1 | // Auto-generated. Do not edit. 2 | 3 | 4 | declare const enum WifiEvent { 5 | //% 6 | ScanDone = 1, 7 | //% 8 | GotIP = 2, 9 | //% 10 | Disconnected = 3, 11 | //% 12 | AccessPointCredentialsAvailable = 4, 13 | //% 14 | LoginServerStarted = 5, 15 | } 16 | 17 | // Auto-generated. Do not edit. Really. 18 | -------------------------------------------------------------------------------- /libs/wifi---esp32/login.html: -------------------------------------------------------------------------------- 1 |
-------------------------------------------------------------------------------- /libs/wifi---esp32/pxt.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wifi---esp32", 3 | "description": "WiFi implementation for ESP32", 4 | "files": [ 5 | "README.md", 6 | "shims.d.ts", 7 | "enums.d.ts", 8 | "controller.ts", 9 | "wifi.h", 10 | "httpserver.cpp", 11 | "socket.cpp", 12 | "wifi.cpp" 13 | ], 14 | "public": true, 15 | "dependencies": { 16 | "core": "file:../core", 17 | "net": "file:../net" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /libs/wifi---esp32/sim/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "noImplicitAny": true, 5 | "noImplicitReturns": true, 6 | "lib": [ 7 | "DOM", 8 | "DOM.Iterable", 9 | "ES2017" 10 | ], 11 | "newLine": "LF", 12 | "sourceMap": false 13 | }, 14 | "include": [ 15 | "*.ts", 16 | "../../*/sim/*.ts", 17 | "../../../../pxt/pxtsim/*.ts", 18 | "../../../../pxt/pxtsim/*/*.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /libs/wifi---esp32/wifi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pxt.h" 4 | #include "esp_log.h" 5 | 6 | namespace pxt { 7 | // nothing here yet 8 | } // namespace pxt 9 | 10 | namespace _wifi { 11 | enum class WifiEvent { 12 | //% 13 | ScanDone = 1, 14 | //% 15 | GotIP = 2, 16 | //% 17 | Disconnected = 3, 18 | //% 19 | AccessPointCredentialsAvailable = 4, 20 | //% 21 | LoginServerStarted = 5, 22 | }; 23 | 24 | int eventID(); 25 | void startHttpServer(const char* hostName); 26 | } -------------------------------------------------------------------------------- /scripts/font-compiler/fromttf/filter-from-font12.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs") 2 | 3 | function main() { 4 | const utf = fs.readFileSync(process.argv[2], "utf8") 5 | const f12 = fs.readFileSync(process.argv[3], "utf8") 6 | let code = 0 7 | const font = {} 8 | for (let ln of f12.split(/\n/)) { 9 | const m = /^\* '.' (\d+)/.exec(ln) 10 | if (m) { 11 | code = m[1] 12 | font[code] = "" 13 | } 14 | font[code] += ln + "\n" 15 | } 16 | for (let i = 0; i < utf.length; ++i) { 17 | const c = utf.charCodeAt(i) 18 | if (c < 255) 19 | continue 20 | console.log(font[c + ""].replace(/\n$/, "")) 21 | } 22 | } 23 | 24 | main() 25 | 26 | -------------------------------------------------------------------------------- /scripts/font-compiler/fromttf/gentext.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs") 2 | 3 | let s = "" 4 | let k = 0 5 | let chars = [] 6 | for (let l of fs.readFileSync("freqs", "utf8").split("\n")) { 7 | l.replace(/0x[a-f0-9]+/g, f => { 8 | let k = parseInt(f) 9 | if (!k) console.log(f) 10 | else if (k <= 0xffff) { 11 | chars[k] = 1 12 | s += String.fromCharCode(k) 13 | } 14 | }) 15 | } 16 | 17 | //for (let i = 0; i < chars.length; ++i) 18 | // if (chars[i]) 19 | // s += String.fromCharCode(i) 20 | 21 | fs.writeFileSync("freq-uni.txt", s, "utf8") 22 | fs.writeFileSync("fr.txt", s, "utf16le") 23 | -------------------------------------------------------------------------------- /scripts/raffs/CodalDevice.h: -------------------------------------------------------------------------------- 1 | /* dummy */ 2 | -------------------------------------------------------------------------------- /scripts/raffs/CodalDmesg.h: -------------------------------------------------------------------------------- 1 | /* dummy */ 2 | -------------------------------------------------------------------------------- /scripts/raffs/Makefile: -------------------------------------------------------------------------------- 1 | STORAGE_PATH = ../../libs/settings 2 | DEFS = -DRAFFS_TEST=1 -DSAMD51 3 | SFILE = $(STORAGE_PATH)/RAFFS.cpp 4 | 5 | INC = -I. -I$(STORAGE_PATH) 6 | 7 | all: build run 8 | 9 | build: 10 | g++ $(INC) $(DEFS) -include raffs-test.h -g -W -Wall -std=c++11 -o stest \ 11 | raffs-test.cpp $(SFILE) -ferror-limit=5 12 | run: 13 | ./stest 14 | -------------------------------------------------------------------------------- /scripts/raffs/MessageBus.h: -------------------------------------------------------------------------------- 1 | /* dummy */ 2 | -------------------------------------------------------------------------------- /scripts/raffs/NotifyEvents.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace codal { 4 | static inline uint16_t allocateNotifyEvent() { 5 | static uint16_t userNotifyId = 1; 6 | return userNotifyId++; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /scripts/raffs/raffs-test.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | inline int min(int a, int b) 8 | { 9 | return (a < b ? a : b); 10 | } 11 | 12 | inline int max(int a, int b) 13 | { 14 | return (a > b ? a : b); 15 | } 16 | 17 | #define NOLOG(...) ((void)0) 18 | #define DMESG(fmt, ...) printf(fmt "\n" , ## __VA_ARGS__) 19 | 20 | //#define LOG NOLOG 21 | #define LOG DMESG 22 | #define LOGV NOLOG 23 | //#define LOGV DMESG 24 | 25 | #define target_panic(...) assert(false) 26 | #define fiber_wait_for_event(...) assert(false) 27 | -------------------------------------------------------------------------------- /scripts/revfont.js: -------------------------------------------------------------------------------- 1 | // Reverse order of bits in bytes in buffers 2 | 3 | let fs = require("fs") 4 | 5 | let lines = fs.readFileSync(process.argv[2], "utf8").split(/\n/) 6 | let r = "" 7 | 8 | function revbits(v) { 9 | v = (v & 0xf0) >> 4 | (v & 0x0f) << 4; 10 | v = (v & 0xcc) >> 2 | (v & 0x33) << 2; 11 | v = (v & 0xaa) >> 1 | (v & 0x55) << 1; 12 | return v; 13 | } 14 | 15 | for (let l of lines) { 16 | if (l.length > 20 && /^[a-f0-9 ]*$/i.test(l)) { 17 | l = l.replace(/[a-f0-9][a-f0-9]/ig, s => { 18 | let v = parseInt(s,16) 19 | return ("0" + revbits(v).toString(16)).slice(-2) 20 | }) 21 | } 22 | r += l +"\n" 23 | } 24 | 25 | fs.writeFileSync(process.argv[2],r) -------------------------------------------------------------------------------- /scripts/snorfs/CodalDevice.h: -------------------------------------------------------------------------------- 1 | /* dummy */ 2 | -------------------------------------------------------------------------------- /scripts/snorfs/CodalDmesg.h: -------------------------------------------------------------------------------- 1 | /* dummy */ 2 | -------------------------------------------------------------------------------- /scripts/snorfs/Makefile: -------------------------------------------------------------------------------- 1 | INC = -I. -I../inc/core -I../inc/drivers -I../inc/driver-models 2 | all: 3 | g++ $(INC) -DSNORFS_TEST=1 -include SNORFS-test.h -g -W -Wall -std=c++11 -o stest SNORFS-test.cpp ../source/drivers/SNORFS.cpp 4 | ./stest 5 | -------------------------------------------------------------------------------- /scripts/snorfs/SNORFS-test.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | inline int min(int a, int b) 8 | { 9 | return (a < b ? a : b); 10 | } 11 | 12 | inline int max(int a, int b) 13 | { 14 | return (a > b ? a : b); 15 | } 16 | 17 | //#define LOG(...) do{}while(0) 18 | #define LOG printf 19 | 20 | //#define LOGV printf 21 | #define LOGV(...) \ 22 | do \ 23 | { \ 24 | } while (0) 25 | 26 | #define target_panic(...) assert(false) 27 | #define fiber_wait_for_event(...) assert(false) 28 | -------------------------------------------------------------------------------- /sim/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "noImplicitAny": true, 5 | "noImplicitReturns": true, 6 | "outFile": "../built/common-sim.js", 7 | "lib": [ 8 | "DOM", 9 | "DOM.Iterable", 10 | "ES2017" 11 | ], 12 | "rootDir": "../libs", 13 | "newLine": "LF", 14 | "declaration": true, 15 | "sourceMap": false, 16 | "types": [] 17 | }, 18 | "include": [ 19 | "../libs/*/sim/*.ts" 20 | ] 21 | } 22 | 23 | --------------------------------------------------------------------------------