Skip to content

Commit

Permalink
Initiala filer för MakeCode-projekt
Browse files Browse the repository at this point in the history
  • Loading branch information
Pebkac03 committed Dec 6, 2024
1 parent 6df9acf commit 66e904a
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["ms-edu.pxt-vscode-web"]
}
29 changes: 29 additions & 0 deletions .vscode/settings.json
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
}
}
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source 'https://rubygems.org'
gem 'github-pages', group: :jekyll_plugins
10 changes: 10 additions & 0 deletions Makefile
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
24 changes: 24 additions & 0 deletions README.md
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>
8 changes: 8 additions & 0 deletions _config.yml
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
1 change: 1 addition & 0 deletions _history

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions main.blocks
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>
94 changes: 94 additions & 0 deletions main.ts
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 () {

})
25 changes: 25 additions & 0 deletions pxt.json
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"
}
1 change: 1 addition & 0 deletions test.ts
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.
9 changes: 9 additions & 0 deletions tsconfig.json
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"]
}

0 comments on commit 66e904a

Please sign in to comment.