From 3d08876c33abf15740b916b0a13f00ad8b79cb36 Mon Sep 17 00:00:00 2001 From: "H. Saw" <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sat, 29 Oct 2022 20:33:29 +0800 Subject: [PATCH] Initial files for MakeCode project --- .vscode/settings.json | 23 +++++++++++++++++++++++ Gemfile | 2 ++ Makefile | 10 ++++++++++ README.md | 31 +++++++++++++++++++++++++++++++ _config.yml | 8 ++++++++ main.blocks | 1 + main.py | 13 +++++++++++++ main.ts | 25 +++++++++++++++++++++++++ pxt.json | 26 ++++++++++++++++++++++++++ test.ts | 1 + tsconfig.json | 9 +++++++++ 11 files changed, 149 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 Gemfile create mode 100644 Makefile create mode 100644 README.md create mode 100644 _config.yml create mode 100644 main.blocks create mode 100644 main.py create mode 100644 main.ts create mode 100644 pxt.json create mode 100644 test.ts create mode 100644 tsconfig.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f8106d4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,23 @@ +{ + "editor.formatOnType": true, + "files.autoSave": "afterDelay", + "files.watcherExclude": { + "**/.git/objects/**": true, + "**/built/**": true, + "**/node_modules/**": true, + "**/yotta_modules/**": true, + "**/yotta_targets": true, + "**/pxt_modules/**": true + }, + "files.associations": { + "*.blocks": "html", + "*.jres": "json" + }, + "search.exclude": { + "**/built": true, + "**/node_modules": true, + "**/yotta_modules": true, + "**/yotta_targets": true, + "**/pxt_modules": true + } +} \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..91ceacd --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'github-pages', group: :jekyll_plugins \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9068464 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +all: deploy + +build: + pxt build + +deploy: + pxt deploy + +test: + pxt test diff --git a/README.md b/README.md new file mode 100644 index 0000000..3372dac --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ + +> Open this page at [https://buzz-lightsnack-2007.github.io/microbit_simplecounter/](https://buzz-lightsnack-2007.github.io/microbit_simplecounter/) + +## Use as Extension + +This repository can be added as an **extension** in MakeCode. + +* open [https://makecode.microbit.org/](https://makecode.microbit.org/) +* click on **New Project** +* click on **Extensions** under the gearwheel menu +* search for **https://github.com/buzz-lightsnack-2007/microbit_simplecounter** and import + +## Edit this project ![Build status badge](https://github.com/buzz-lightsnack-2007/microbit_simplecounter/workflows/MakeCode/badge.svg) + +To edit this repository in MakeCode. + +* open [https://makecode.microbit.org/](https://makecode.microbit.org/) +* click on **Import** then click on **Import URL** +* paste **https://github.com/buzz-lightsnack-2007/microbit_simplecounter** and click import + +## Blocks preview + +This image shows the blocks code from the last commit in master. +This image may take a few minutes to refresh. + +![A rendered view of the blocks](https://github.com/buzz-lightsnack-2007/microbit_simplecounter/raw/master/.github/makecode/blocks.png) + +#### Metadata (used for search, rendering) + +* for PXT/microbit + diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..f56a029 --- /dev/null +++ b/_config.yml @@ -0,0 +1,8 @@ +makecode: + target: microbit + platform: microbit + home_url: https://makecode.microbit.org/ +theme: jekyll-theme-slate +include: + - assets + - README.md diff --git a/main.blocks b/main.blocks new file mode 100644 index 0000000..cd87c89 --- /dev/null +++ b/main.blocks @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..917d893 --- /dev/null +++ b/main.py @@ -0,0 +1,13 @@ +""" + CounterTracker + simple counter tracker for the Micro:Bit +""" + + + + +def startup(): + music.ring_tone(Note.C) + return(True) + + diff --git a/main.ts b/main.ts new file mode 100644 index 0000000..062471d --- /dev/null +++ b/main.ts @@ -0,0 +1,25 @@ +/** + CounterTracker + simple counter tracker for the Micro:Bit + + */ + +input.onButtonPressed(Button.A, function () { + count += 1; + basic.showNumber(count) +}) + +input.onButtonPressed(Button.AB, function() { + count = 0; + basic.showNumber(count) +}) + +function startup(): boolean { + music.ringTone(Note.C) + count = 0; + basic.showNumber(count) + return true +} + +let count = 0; +startup() \ No newline at end of file diff --git a/pxt.json b/pxt.json new file mode 100644 index 0000000..5e4ed7b --- /dev/null +++ b/pxt.json @@ -0,0 +1,26 @@ +{ + "name": "MicroBit_SimpleCounter", + "description": "", + "dependencies": { + "core": "*", + "radio": "*", + "microphone": "*" + }, + "files": [ + "main.blocks", + "main.ts", + "README.md", + "main.py" + ], + "testFiles": [ + "test.ts" + ], + "targetVersions": { + "target": "5.0.12", + "targetId": "microbit" + }, + "supportedTargets": [ + "microbit" + ], + "preferredEditor": "tsprj" +} diff --git a/test.ts b/test.ts new file mode 100644 index 0000000..7bf240c --- /dev/null +++ b/test.ts @@ -0,0 +1 @@ +// tests go here; this will not be compiled when this package is used as an extension. diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..46f831b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "target": "ES5", + "noImplicitAny": true, + "outDir": "built", + "rootDir": "." + }, + "exclude": ["pxt_modules/**/*test.ts"] +}