Skip to content

Commit 083f8f4

Browse files
committed
Copying the work from pxt-microdata-gui over to this new repo.
1 parent 071154c commit 083f8f4

40 files changed

Lines changed: 8436 additions & 1 deletion

Gemfile

Lines changed: 2 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,26 @@
1-
# MicroGUI
1+
> Open this page at [https://kierpalin.github.io/pxt-microdata-gui/](https://kierpalin.github.io/pxt-microdata-gui/)
2+
3+
## Use as Extension
4+
5+
This repository can be added as an **extension** in MakeCode.
6+
7+
* open [https://makecode.microbit.org/](https://makecode.microbit.org/)
8+
* click on **New Project**
9+
* click on **Extensions** under the gearwheel menu
10+
* search for **https://github.com/kierpalin/pxt-microdata-gui** and import
11+
12+
## Edit this project
13+
14+
To edit this repository in MakeCode.
15+
16+
* open [https://makecode.microbit.org/](https://makecode.microbit.org/)
17+
* click on **Import** then click on **Import URL**
18+
* paste **https://github.com/kierpalin/pxt-microdata-gui** and click import
19+
20+
#### Metadata (used for search, rendering)
21+
22+
* for PXT/microbit
23+
<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>
24+
25+
# Project Objective:
26+
To coalesce aspects of MicroData and MicroCode into a makecode extension that makes the underlying GUI maleable to user-created makecode applications.

_config.yml

Lines changed: 8 additions & 0 deletions
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

_history

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"entries":[{"timestamp":1727278685736,"editorVersion":"7.0.42","changes":[{"type":"edited","filename":"main.blocks","patch":[{"diffs":[[0,"http"],[-1,"s"],[0,"://"],[-1,"developers.google.com/blockly/xml\"><variables></variables><block type=\"pxt-on-start\" id=\"0_nQ{8yq;D6?JeryemVQ\" x=\"0\" y=\"0"],[1,"www.w3.org/1999/xhtml\">\n <block type=\"pxt-on-start"],[0,"\"></"]],"start1":12,"start2":12,"length1":133,"length2":62},{"diffs":[[0,"</block>"],[1,"\n "],[0,"<block t"]],"start1":72,"start2":72,"length1":16,"length2":19},{"diffs":[[0,"ver\""],[-1," id=\"OynB`G^5*-3Xt3NyT8Fn\" x=\"205\" y=\"0\""],[0,"></b"]],"start1":107,"start2":107,"length1":48,"length2":8},{"diffs":[[0,"</block>"],[1,"\n"],[0,"</xml>"]],"start1":112,"start2":112,"length1":14,"length2":15}]},{"type":"edited","filename":"main.ts","patch":[{"diffs":[[-1,"basic.forever(function () {\n\t\n})"],[0,"\n"]],"start1":0,"start2":0,"length1":33,"length2":1}]},{"type":"edited","filename":"pxt.json","patch":[{"diffs":[[0," \""],[-1,"testFiles\": [\n \"test.ts\"\n ],\n \"preferredEditor\": \"blocksprj\""],[1,"additionalFilePaths\": []"],[0,"\n}\n"]],"start1":241,"start2":241,"length1":80,"length2":31}]},{"type":"added","filename":"test.ts","value":"// tests go here; this will not be compiled when this package is used as an extension.\n"}]}],"snapshots":[{"timestamp":1727278685735,"editorVersion":"7.0.42","text":{"main.blocks":"<xml xmlns=\"http://www.w3.org/1999/xhtml\">\n <block type=\"pxt-on-start\"></block>\n <block type=\"device_forever\"></block>\n</xml>","main.ts":"\n","README.md":"","pxt.json":"{\n \"name\": \"MicroGUI\",\n \"description\": \"\",\n \"dependencies\": {\n \"core\": \"*\",\n \"radio\": \"*\",\n \"microphone\": \"*\"\n },\n \"files\": [\n \"main.blocks\",\n \"main.ts\",\n \"README.md\"\n ],\n \"additionalFilePaths\": []\n}\n"}}],"shares":[],"lastSaveTime":1727278695840}

accessibility.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
namespace accessibility {
2+
export interface AccessibilityMessage {
3+
type: "text" | "tile" | "rule" | "led" | "note"
4+
force?: boolean
5+
}
6+
7+
export interface TextAccessibilityMessage extends AccessibilityMessage {
8+
type: "text"
9+
value: string
10+
}
11+
12+
export interface LEDAccessibilityMessage extends AccessibilityMessage {
13+
type: "led"
14+
on: boolean
15+
x: number
16+
y: number
17+
}
18+
19+
export interface NoteAccessibilityMessage extends AccessibilityMessage {
20+
type: "note"
21+
on: boolean
22+
index: number
23+
}
24+
25+
export interface TileAccessibilityMessage extends AccessibilityMessage {
26+
type: "tile"
27+
value: string
28+
}
29+
30+
export interface RuleAccessibilityMessage extends AccessibilityMessage {
31+
type: "rule"
32+
dos: string[]
33+
whens: string[]
34+
}
35+
36+
/**
37+
* Notifies web application about the current content.
38+
*/
39+
//% shim=TD_ID
40+
export function setLiveContent(msg: AccessibilityMessage) {
41+
42+
}
43+
44+
export function ariaToTooltip(ariaId: string) {
45+
return microcode.resolveTooltip(ariaId).replaceAll("_", " ")
46+
}
47+
}

affine.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
namespace microcode {
2+
/**
3+
* An Affine represents a euclidean transformation on a Vec2.
4+
* At the moment this class only supports translation, but if needed it could easily include:
5+
* - Rotation
6+
* - Scaling
7+
* - Skew (less common)
8+
* Affine transformations can be chained thru the `parent` property, in which case `worldPos` will report the composed value.
9+
*/
10+
export class Affine {
11+
private localPos_: Vec2
12+
private parent_: Affine
13+
14+
//% blockCombine block="worldPos" callInDebugger
15+
public get worldPos() {
16+
return this.computeWorldPos()
17+
}
18+
19+
//% blockCombine block="localPos" callInDebugger
20+
public get localPos(): Vec2 {
21+
return this.localPos_
22+
}
23+
public set localPos(v: Vec2) {
24+
this.localPos_.copyFrom(v)
25+
}
26+
27+
//% blockCombine block="parent" callInDebugger
28+
public get parent() {
29+
return this.parent_
30+
}
31+
public set parent(p: Affine) {
32+
this.parent_ = p
33+
}
34+
35+
//% blockCombine block="root" callInDebugger
36+
public get root() {
37+
let node = this.parent
38+
while (node && node.parent) {
39+
node = node.parent
40+
}
41+
return node
42+
}
43+
44+
constructor() {
45+
this.localPos_ = new Vec2()
46+
}
47+
48+
public copyFrom(src: Affine): this {
49+
this.localPos.copyFrom(src.localPos)
50+
return this
51+
}
52+
53+
public clone(): Affine {
54+
const aff = new Affine()
55+
aff.copyFrom(this)
56+
return aff
57+
}
58+
59+
private computeWorldPos(): Vec2 {
60+
const pos = new Vec2()
61+
pos.copyFrom(this.localPos_)
62+
let parent = this.parent_
63+
while (parent) {
64+
Vec2.TranslateToRef(pos, parent.localPos, pos)
65+
parent = parent.parent
66+
}
67+
return pos
68+
}
69+
70+
public transformToRef(v: Vec2, ref: Vec2): Vec2 {
71+
return Vec2.TranslateToRef(v, this.worldPos, ref)
72+
}
73+
}
74+
}

analytics.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace microcode {
2+
export interface AnalyticsEvent {
3+
type: "event"
4+
msg: string
5+
data?: { [name: string]: string | number }
6+
}
7+
8+
/**
9+
* Sends an event to analytics.
10+
*/
11+
//% shim=TD_NOOP
12+
export function reportEvent(
13+
event: string,
14+
data?: { [name: string]: string | number }
15+
) {
16+
const msg: AnalyticsEvent = {
17+
type: "event",
18+
msg: event,
19+
}
20+
if (data) msg.data = data
21+
report(msg)
22+
}
23+
24+
/**
25+
* Sends an analytics message
26+
* @param msg
27+
*/
28+
//% shim=TD_NOOP
29+
function report(msg: AnalyticsEvent) {
30+
31+
}
32+
}

app.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace microcode {
2+
// Auto-save slot
3+
export const SAVESLOT_AUTO = "sa"
4+
5+
export interface SavedState {
6+
progdef: any
7+
version?: string
8+
}
9+
10+
export class App {
11+
private sceneManager: SceneManager
12+
13+
constructor() {
14+
// One interval delay to ensure all static constructors have executed.
15+
basic.pause(10)
16+
reportEvent("app.start")
17+
18+
this.sceneManager = new SceneManager()
19+
datalogger.includeTimestamp(FlashLogTimeStampFormat.None)
20+
}
21+
22+
public pushScene(scene: Scene) {
23+
this.sceneManager.pushScene(scene)
24+
}
25+
26+
public popScene() {
27+
this.sceneManager.popScene()
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)