-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
374 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Check pxt.json | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
- 'main' | ||
|
||
jobs: | ||
check-cfg: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [14.x] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: npm install | ||
run: | | ||
npm install -g pxt | ||
pxt target microbit | ||
- name: Checkout current state | ||
run: | | ||
git checkout -- . | ||
git clean -fd | ||
- name: Fix files listed in config if necessary | ||
run: pxt checkpkgcfg | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
continue-on-error: true | ||
with: | ||
title: 'Removing missing files from pxt.json' | ||
commit-message: 'Removing missing files from pxt.json' | ||
delete-branch: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: MakeCode | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: npm install | ||
run: | | ||
npm install -g pxt | ||
pxt target microbit | ||
- name: build | ||
run: | | ||
pxt install | ||
pxt build --cloud | ||
env: | ||
CI: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
// A task runner that calls the MakeCode (PXT) compiler | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [{ | ||
"label": "pxt deploy", | ||
"type": "shell", | ||
"command": "pxt deploy --local", | ||
"group": "build", | ||
"problemMatcher": [ "$tsc" ] | ||
}, { | ||
"label": "pxt build", | ||
"type": "shell", | ||
"command": "pxt build --local", | ||
"group": "build", | ||
"problemMatcher": [ "$tsc" ] | ||
}, { | ||
"label": "pxt install", | ||
"type": "shell", | ||
"command": "pxt install", | ||
"group": "build", | ||
"problemMatcher": [ "$tsc" ] | ||
}, { | ||
"label": "pxt clean", | ||
"type": "shell", | ||
"command": "pxt clean", | ||
"group": "test", | ||
"problemMatcher": [ "$tsc" ] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
source 'https://rubygems.org' | ||
gem 'github-pages', group: :jekyll_plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
all: deploy | ||
|
||
build: | ||
pxt build | ||
|
||
deploy: | ||
pxt deploy | ||
|
||
test: | ||
pxt test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
> Open this page at [https://fadeongithub.github.io/magnet-meter-for-microbit/](https://fadeongithub.github.io/magnet-meter-for-microbit/) | ||
## 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/fadeongithub/magnet-meter-for-microbit** and import | ||
|
||
## Edit this project ![Build status badge](https://github.com/fadeongithub/magnet-meter-for-microbit/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/fadeongithub/magnet-meter-for-microbit** 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/fadeongithub/magnet-meter-for-microbit/raw/master/.github/makecode/blocks.png) | ||
|
||
#### Metadata (used for search, rendering) | ||
|
||
* for PXT/microbit | ||
<script src="https://makecode.com/gh-pages-embed.js"></script><script>makeCodeRender("{{ site.makecode.home_url }}", "{{ site.github.owner_name }}/{{ site.github.repository_name }}");</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
makecode: | ||
target: microbit | ||
platform: microbit | ||
home_url: https://makecode.microbit.org/ | ||
theme: jekyll-theme-slate | ||
include: | ||
- assets | ||
- README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<xml xmlns="https://developers.google.com/blockly/xml"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
def on_microbit_id_button_a_evt(): | ||
if input.magnetic_force(Dimension.STRENGTH) < 0 and input.magnetic_force(Dimension.STRENGTH) < 20: | ||
basic.show_leds(""" | ||
. . . . . | ||
. . . . . | ||
. . . . . | ||
. . . . . | ||
# # # # # | ||
""") | ||
elif input.magnetic_force(Dimension.STRENGTH) > 20 and input.magnetic_force(Dimension.STRENGTH) < 40: | ||
basic.show_leds(""" | ||
. . . . . | ||
. . . . . | ||
. . . . . | ||
# # # # # | ||
# # # # # | ||
""") | ||
elif input.magnetic_force(Dimension.STRENGTH) > 40 and input.magnetic_force(Dimension.STRENGTH) < 60: | ||
basic.show_leds(""" | ||
. . . . . | ||
. . . . . | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
""") | ||
elif input.magnetic_force(Dimension.STRENGTH) > 60 and input.magnetic_force(Dimension.STRENGTH) < 80: | ||
basic.show_leds(""" | ||
. . . . . | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
""") | ||
elif input.magnetic_force(Dimension.STRENGTH) > 80 and input.magnetic_force(Dimension.STRENGTH) < 100: | ||
basic.show_leds(""" | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
""") | ||
else: | ||
basic.show_leds(""" | ||
# . # . # | ||
# . # . # | ||
# . # . # | ||
. . . . . | ||
# . # . # | ||
""") | ||
control.on_event(EventBusSource.MICROBIT_ID_BUTTON_A, | ||
EventBusValue.MICROBIT_EVT_ANY, | ||
on_microbit_id_button_a_evt) | ||
|
||
basic.show_string("MAGNET METER") | ||
basic.show_leds(""" | ||
. # . # . | ||
. # . # . | ||
. . . . . | ||
# . . . # | ||
. # # # . | ||
""") | ||
control.wait_micros(48) | ||
basic.clear_screen() | ||
basic.show_leds(""" | ||
. # # # . | ||
# . . . # | ||
# # # # # | ||
# . . . # | ||
# . . . # | ||
""") | ||
control.raise_event(EventBusSource.MICROBIT_ID_BUTTON_A, | ||
EventBusValue.MICROBIT_EVT_ANY) | ||
|
||
def on_forever(): | ||
if input.button_is_pressed(Button.AB): | ||
basic.show_leds(""" | ||
# # # # # | ||
# . . . . | ||
# . # . # | ||
# . . . . | ||
# # # # # | ||
""") | ||
music.play_melody("E F G A G - B C5 ", 500) | ||
basic.forever(on_forever) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
control.onEvent(EventBusSource.MICROBIT_ID_BUTTON_A, EventBusValue.MICROBIT_EVT_ANY, function on_microbit_id_button_a_evt() { | ||
if (input.magneticForce(Dimension.Strength) < 0 && input.magneticForce(Dimension.Strength) < 20) { | ||
basic.showLeds(` | ||
. . . . . | ||
. . . . . | ||
. . . . . | ||
. . . . . | ||
# # # # # | ||
`) | ||
} else if (input.magneticForce(Dimension.Strength) > 20 && input.magneticForce(Dimension.Strength) < 40) { | ||
basic.showLeds(` | ||
. . . . . | ||
. . . . . | ||
. . . . . | ||
# # # # # | ||
# # # # # | ||
`) | ||
} else if (input.magneticForce(Dimension.Strength) > 40 && input.magneticForce(Dimension.Strength) < 60) { | ||
basic.showLeds(` | ||
. . . . . | ||
. . . . . | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
`) | ||
} else if (input.magneticForce(Dimension.Strength) > 60 && input.magneticForce(Dimension.Strength) < 80) { | ||
basic.showLeds(` | ||
. . . . . | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
`) | ||
} else if (input.magneticForce(Dimension.Strength) > 80 && input.magneticForce(Dimension.Strength) < 100) { | ||
basic.showLeds(` | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
# # # # # | ||
`) | ||
} else { | ||
basic.showLeds(` | ||
# . # . # | ||
# . # . # | ||
# . # . # | ||
. . . . . | ||
# . # . # | ||
`) | ||
} | ||
|
||
}) | ||
basic.showString("MAGNET METER") | ||
basic.showLeds(` | ||
. # . # . | ||
. # . # . | ||
. . . . . | ||
# . . . # | ||
. # # # . | ||
`) | ||
control.waitMicros(48) | ||
basic.clearScreen() | ||
basic.showLeds(` | ||
. # # # . | ||
# . . . # | ||
# # # # # | ||
# . . . # | ||
# . . . # | ||
`) | ||
control.raiseEvent(EventBusSource.MICROBIT_ID_BUTTON_A, EventBusValue.MICROBIT_EVT_ANY) | ||
basic.forever(function on_forever() { | ||
if (input.buttonIsPressed(Button.AB)) { | ||
basic.showLeds(` | ||
# # # # # | ||
# . . . . | ||
# . # . # | ||
# . . . . | ||
# # # # # | ||
`) | ||
music.playMelody("E F G A G - B C5 ", 500) | ||
} | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "magnet meter", | ||
"description": "", | ||
"dependencies": { | ||
"core": "*", | ||
"radio": "*", | ||
"microphone": "*" | ||
}, | ||
"files": [ | ||
"main.blocks", | ||
"main.ts", | ||
"README.md", | ||
"main.py" | ||
], | ||
"testFiles": [ | ||
"test.ts" | ||
], | ||
"targetVersions": { | ||
"target": "4.0.18", | ||
"targetId": "microbit" | ||
}, | ||
"supportedTargets": [ | ||
"microbit" | ||
], | ||
"preferredEditor": "pyprj" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// tests go here; this will not be compiled when this package is used as an extension. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES5", | ||
"noImplicitAny": true, | ||
"outDir": "built", | ||
"rootDir": "." | ||
}, | ||
"exclude": ["pxt_modules/**/*test.ts"] | ||
} |