Skip to content

Commit 511dd37

Browse files
committed
Initial files for MakeCode project
1 parent 76b936c commit 511dd37

13 files changed

+228
-0
lines changed

.github/workflows/cfg-check.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Check pxt.json
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'main'
8+
9+
jobs:
10+
check-cfg:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [14.x]
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Use Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
- name: npm install
22+
run: |
23+
npm install -g pxt
24+
pxt target microbit
25+
- name: Checkout current state
26+
run: |
27+
git checkout -- .
28+
git clean -fd
29+
- name: Fix files listed in config if necessary
30+
run: pxt checkpkgcfg
31+
- name: Create Pull Request
32+
uses: peter-evans/create-pull-request@v3
33+
continue-on-error: true
34+
with:
35+
title: 'Removing missing files from pxt.json'
36+
commit-message: 'Removing missing files from pxt.json'
37+
delete-branch: true

.github/workflows/makecode.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: MakeCode
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
strategy:
11+
matrix:
12+
node-version: [14.x]
13+
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Use Node.js ${{ matrix.node-version }}
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: ${{ matrix.node-version }}
20+
- name: npm install
21+
run: |
22+
npm install -g pxt
23+
pxt target microbit
24+
- name: build
25+
run: |
26+
pxt install
27+
pxt build --cloud
28+
env:
29+
CI: true

.vscode/settings.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"editor.formatOnType": true,
3+
"files.autoSave": "afterDelay",
4+
"files.watcherExclude": {
5+
"**/.git/objects/**": true,
6+
"**/built/**": true,
7+
"**/node_modules/**": true,
8+
"**/yotta_modules/**": true,
9+
"**/yotta_targets": true,
10+
"**/pxt_modules/**": true
11+
},
12+
"files.associations": {
13+
"*.blocks": "html",
14+
"*.jres": "json"
15+
},
16+
"search.exclude": {
17+
"**/built": true,
18+
"**/node_modules": true,
19+
"**/yotta_modules": true,
20+
"**/yotta_targets": true,
21+
"**/pxt_modules": true
22+
}
23+
}

.vscode/tasks.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
// A task runner that calls the MakeCode (PXT) compiler
3+
{
4+
"version": "2.0.0",
5+
"tasks": [{
6+
"label": "pxt deploy",
7+
"type": "shell",
8+
"command": "pxt deploy --local",
9+
"group": "build",
10+
"problemMatcher": [ "$tsc" ]
11+
}, {
12+
"label": "pxt build",
13+
"type": "shell",
14+
"command": "pxt build --local",
15+
"group": "build",
16+
"problemMatcher": [ "$tsc" ]
17+
}, {
18+
"label": "pxt install",
19+
"type": "shell",
20+
"command": "pxt install",
21+
"group": "build",
22+
"problemMatcher": [ "$tsc" ]
23+
}, {
24+
"label": "pxt clean",
25+
"type": "shell",
26+
"command": "pxt clean",
27+
"group": "test",
28+
"problemMatcher": [ "$tsc" ]
29+
}]
30+
}

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source 'https://rubygems.org'
2+
gem 'github-pages', group: :jekyll_plugins

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
all: deploy
2+
3+
build:
4+
pxt build
5+
6+
deploy:
7+
pxt deploy
8+
9+
test:
10+
pxt test

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
> Open this page at [https://astr0fix.github.io/multi-use-compass-for-microbit/](https://astr0fix.github.io/multi-use-compass-for-microbit/)
3+
4+
## Use as Extension
5+
6+
This repository can be added as an **extension** in MakeCode.
7+
8+
* open [https://makecode.microbit.org/](https://makecode.microbit.org/)
9+
* click on **New Project**
10+
* click on **Extensions** under the gearwheel menu
11+
* search for **https://github.com/astr0fix/multi-use-compass-for-microbit** and import
12+
13+
## Edit this project ![Build status badge](https://github.com/astr0fix/multi-use-compass-for-microbit/workflows/MakeCode/badge.svg)
14+
15+
To edit this repository in MakeCode.
16+
17+
* open [https://makecode.microbit.org/](https://makecode.microbit.org/)
18+
* click on **Import** then click on **Import URL**
19+
* paste **https://github.com/astr0fix/multi-use-compass-for-microbit** and click import
20+
21+
## Blocks preview
22+
23+
This image shows the blocks code from the last commit in master.
24+
This image may take a few minutes to refresh.
25+
26+
![A rendered view of the blocks](https://github.com/astr0fix/multi-use-compass-for-microbit/raw/master/.github/makecode/blocks.png)
27+
28+
#### Metadata (used for search, rendering)
29+
30+
* for PXT/microbit
31+
<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>

_config.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
makecode:
2+
target: microbit
3+
platform: microbit
4+
home_url: https://makecode.microbit.org/
5+
theme: jekyll-theme-slate
6+
include:
7+
- assets
8+
- README.md

main.blocks

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<xml xmlns="https://developers.google.com/blockly/xml"><block type="pxt-on-start" id="PV#ZnvrYkAFrMRkQ#*O4" x="20" y="20"><statement name="HANDLER"><block type="device_print_message" id="5O,c9;v.bd[Xm9Cc}4Cb"><value name="text"><shadow type="text" id="CR:W8mnBaFVZk~Fu66%t"><field name="TEXT">Compass Starting</field></shadow></value></block></statement></block><block type="device_button_event" id="=#KHV#t9e,J]ILAdipLA" x="460" y="15"><field name="NAME">Button.AB</field><statement name="HANDLER"><block type="device_clear_display" id="KM:Bs4Oc5.yN,Eg:+2Il"><next><block type="device_print_message" id="xtJThSuNLKMeJ}=R-WZj"><value name="text"><shadow type="text" id="zKI`#`2oh?7S@DE@$/Ir"><field name="TEXT">Mode: Point North</field></shadow></value><next><block type="device_while" id="BXY^@i)-WEp;oV}1)BI*"><value name="COND"><shadow type="logic_boolean" id="Mf`M:Tx+@7w[dYBpG6lA"><field name="BOOL">TRUE</field></shadow></value><statement name="DO"><block type="basic_show_arrow" id="J[QG{C_!pkJ6A9ILb#T-"><value name="i"><shadow type="device_arrow" id="D~[$~F/ZQD0ShE!I|p1?"><field name="arrow">ArrowNames.North</field></shadow></value></block></statement></block></next></block></next></block></statement></block><block type="device_button_event" id="8nYyIx5_$_[fsgIx_/@j" x="20" y="165"><field name="NAME">Button.B</field><statement name="HANDLER"><block type="device_clear_display" id="o6T,p%Y(|(T.f!+1DK:B"><next><block type="device_print_message" id="UwM|a7f%$Hmi6_?IJ@(c"><value name="text"><shadow type="text" id="@gQ6wTKwAyDSG,0YmH`W"><field name="TEXT">Mode: Magnetic Force</field></shadow></value><next><block type="device_while" id="DmJ_Jmc59uac~:?3{=|J"><value name="COND"><shadow type="logic_boolean" id="CbEGgj!t:k?E,5JF;o20"><field name="BOOL">TRUE</field></shadow></value><statement name="DO"><block type="device_show_number" id=")CLX$31leZKAI{jAm.cI"><value name="number"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="device_get_magnetic_force" id="u.42Sg9+70]$d5l4JG=7"><field name="NAME">Dimension.X</field></block></value></block></statement></block></next></block></next></block></statement></block><block type="device_button_event" id="BPB%c%$^yf?acPVV*Wpb" x="460" y="337"><field name="NAME">Button.A</field><statement name="HANDLER"><block type="device_clear_display" id="%]iD=t_xk^D#7^8H.`,a"><next><block type="device_print_message" id="#f$s}A2dGvtCuTTe4J,a"><value name="text"><shadow type="text" id="PP@t[r.n-$s^}:7|-XyI"><field name="TEXT">Mode: Heading</field></shadow></value><next><block type="device_while" id="{]~K:U_DVW2GI`%~SDu#"><value name="COND"><shadow type="logic_boolean" id="3!P**NZ1|K[ikwv9I@-:"><field name="BOOL">TRUE</field></shadow></value><statement name="DO"><block type="device_show_number" id="OyYyi+mby+z7PKgArsC3"><value name="number"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="device_heading" id="rBLZmA=26rtTnpRsmkH["/></value></block></statement></block></next></block></next></block></statement></block></xml>

main.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
input.onButtonPressed(Button.A, function () {
2+
basic.clearScreen()
3+
basic.showString("Mode: Heading")
4+
while (true) {
5+
basic.showNumber(input.compassHeading())
6+
}
7+
})
8+
input.onButtonPressed(Button.AB, function () {
9+
basic.clearScreen()
10+
basic.showString("Mode: Point North")
11+
while (true) {
12+
basic.showArrow(ArrowNames.North)
13+
}
14+
})
15+
input.onButtonPressed(Button.B, function () {
16+
basic.clearScreen()
17+
basic.showString("Mode: Magnetic Force")
18+
while (true) {
19+
basic.showNumber(input.magneticForce(Dimension.X))
20+
}
21+
})
22+
basic.showString("Compass Starting")

pxt.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "New Multi Use Compass Test",
3+
"description": "",
4+
"dependencies": {
5+
"core": "*",
6+
"radio": "*",
7+
"microphone": "*"
8+
},
9+
"files": [
10+
"main.blocks",
11+
"main.ts",
12+
"README.md"
13+
],
14+
"testFiles": [
15+
"test.ts"
16+
],
17+
"targetVersions": {
18+
"target": "4.0.11",
19+
"targetId": "microbit"
20+
},
21+
"supportedTargets": [
22+
"microbit"
23+
],
24+
"preferredEditor": "blocksprj"
25+
}

test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// tests go here; this will not be compiled when this package is used as an extension.

tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES5",
4+
"noImplicitAny": true,
5+
"outDir": "built",
6+
"rootDir": "."
7+
},
8+
"exclude": ["pxt_modules/**/*test.ts"]
9+
}

0 commit comments

Comments
 (0)