-
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
12 changed files
with
207 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,3 @@ | ||
{ | ||
"recommendations": ["ms-edu.pxt-vscode-web"] | ||
} |
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 @@ | ||
{ | ||
"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, | ||
"**/.pxt/**": true | ||
}, | ||
"files.associations": { | ||
"*.blocks": "html", | ||
"*.jres": "json" | ||
}, | ||
"search.exclude": { | ||
"**/built": true, | ||
"**/node_modules": true, | ||
"**/yotta_modules": true, | ||
"**/yotta_targets": true, | ||
"**/pxt_modules": true, | ||
"**/.pxt": true | ||
}, | ||
"files.exclude": { | ||
"**/pxt_modules": true, | ||
"**/.pxt": 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,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,24 @@ | ||
|
||
> Öppna denna sida på [https://pebkac03.github.io/pxt-microbit-led-oop/](https://pebkac03.github.io/pxt-microbit-led-oop/) | ||
## Använd som tillägg | ||
|
||
Denna databas kan läggas till som ett **tillägg** i MakeCode. | ||
|
||
* öppna [https://makecode.microbit.org/](https://makecode.microbit.org/) | ||
* klicka på **Nytt projekt** | ||
* klicka på **Tillägg** under kugghjulsmenyn | ||
* sök efter **https://github.com/pebkac03/pxt-microbit-led-oop** och importera | ||
|
||
## Redigera detta projekt | ||
|
||
Redigera den här databasen i MakeCode. | ||
|
||
* öppna [https://makecode.microbit.org/](https://makecode.microbit.org/) | ||
* klicka på **Importera** och klicka sedan på **Importera URL** | ||
* klistra in **https://github.com/pebkac03/pxt-microbit-led-oop** och klicka på importera | ||
|
||
#### Metadata (används för sökning och 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"><variables><variable id="+C_+SBD.p6%`!CUPIhfg">i</variable><variable id="kex|k}[3owo:$L,!02]|">list</variable><variable id="S;j(sHIkgDP9nGWBTPaU">square</variable></variables></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,94 @@ | ||
class LedDisplay { | ||
private static allLeds: Array<{ x: number, y: number }> = [ | ||
{ x: 0, y: 0 }, | ||
{ x: 0, y: 1 }, | ||
{ x: 0, y: 2 }, | ||
{ x: 0, y: 3 }, | ||
{ x: 0, y: 4 }, | ||
{ x: 1, y: 0 }, | ||
{ x: 1, y: 1 }, | ||
{ x: 1, y: 2 }, | ||
{ x: 1, y: 3 }, | ||
{ x: 1, y: 4 }, | ||
{ x: 2, y: 0 }, | ||
{ x: 2, y: 1 }, | ||
{ x: 2, y: 2 }, | ||
{ x: 2, y: 3 }, | ||
{ x: 2, y: 4 }, | ||
{ x: 3, y: 0 }, | ||
{ x: 3, y: 1 }, | ||
{ x: 3, y: 2 }, | ||
{ x: 3, y: 3 }, | ||
{ x: 3, y: 4 }, | ||
{ x: 4, y: 0 }, | ||
{ x: 4, y: 1 }, | ||
{ x: 4, y: 2 }, | ||
{ x: 4, y: 3 }, | ||
{ x: 4, y: 4 }, | ||
]; | ||
|
||
image: Array<{ x: number, y: number }>; | ||
constructor(image: Array<{ x: number, y: number }>) { | ||
this.image = image; | ||
} | ||
|
||
activate(): void { | ||
for (let i = 0; i < LedDisplay.allLeds.length; i++) { | ||
let currentLed: { x: number, y: number } = LedDisplay.allLeds[i]; | ||
if (this.image.some((element) => this.shallowEqual(currentLed, element))) { | ||
led.plot(LedDisplay.allLeds[i].x, LedDisplay.allLeds[i].y); | ||
} else { | ||
led.unplot(LedDisplay.allLeds[i].x, LedDisplay.allLeds[i].y); | ||
} | ||
|
||
} | ||
} | ||
|
||
private shallowEqual(object1: { x: number, y: number }, object2: { x: number, y: number }): boolean { | ||
if (object1["x"] !== object2["x"]) { | ||
return false; | ||
} | ||
if (object1["y"] !== object2["y"]) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} | ||
const line: LedDisplay = new LedDisplay([ | ||
{ x: 0, y: 1 }, | ||
{ x: 1, y: 1 }, | ||
{ x: 2, y: 1 }, | ||
{ x: 3, y: 1 }, | ||
{ x: 4, y: 1 }, | ||
]) | ||
const square: LedDisplay = new LedDisplay([ | ||
{ x: 0, y: 0 }, | ||
{ x: 1, y: 0 }, | ||
{ x: 2, y: 0 }, | ||
{ x: 3, y: 0 }, | ||
{ x: 4, y: 0 }, | ||
{ x: 0, y: 1 }, | ||
{ x: 4, y: 1 }, | ||
{ x: 0, y: 2 }, | ||
{ x: 4, y: 2 }, | ||
{ x: 0, y: 3 }, | ||
{ x: 4, y: 3 }, | ||
{ x: 0, y: 4 }, | ||
{ x: 1, y: 4 }, | ||
{ x: 2, y: 4 }, | ||
{ x: 3, y: 4 }, | ||
{ x: 4, y: 4 }, | ||
]); | ||
|
||
input.onButtonPressed(Button.A, function () { | ||
square.activate(); | ||
}) | ||
input.onButtonPressed(Button.B, function () { | ||
line.activate(); | ||
}) | ||
|
||
|
||
|
||
basic.forever(function () { | ||
|
||
}) |
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,25 @@ | ||
{ | ||
"name": "test", | ||
"description": "", | ||
"dependencies": { | ||
"core": "*", | ||
"radio": "*", | ||
"microphone": "*" | ||
}, | ||
"files": [ | ||
"main.blocks", | ||
"main.ts", | ||
"README.md" | ||
], | ||
"testFiles": [ | ||
"test.ts" | ||
], | ||
"targetVersions": { | ||
"target": "7.0.51", | ||
"targetId": "microbit" | ||
}, | ||
"supportedTargets": [ | ||
"microbit" | ||
], | ||
"preferredEditor": "tsprj" | ||
} |
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 @@ | ||
// här hamnar tester och detta kompileras inte när det här paketet används som ett tillägg. |
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"] | ||
} |