Skip to content

Commit cb5758a

Browse files
committed
more work on pxt dev docs
1 parent 014cf3f commit cb5758a

3 files changed

Lines changed: 97 additions & 26 deletions

File tree

docs/docs.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,21 @@ MakeCode is a toolkit to create JavaScript/Blocks online editors.
1818

1919
## PXT developer resources
2020

21-
* [pxt command line interface](/cli)
22-
* [creating a PXT target](/target-creation), [pxtarget.json](/targets/pxtarget)
23-
* [creating a PXT package](/packages)
21+
### [pxt command line interface](/cli)
22+
23+
### [creating a PXT target](/target-creation)
24+
* [pxtarget.json](/targets/pxtarget)
2425
* [expose your APIs as blocks](/defining-blocks)
25-
* [auto-generation of library files](/simshim), from either C++ or TypeScript sources
26-
* [embedding source code](/source-embedding) and [partial flashing](/partial-flashing)
27-
* [async functions and threads](/async)
26+
* [auto-generation of library files](/simshim), from C++ or TypeScript
27+
* [async functions and threads](/async)
28+
* [board definition](/targets/board)
29+
* [theming](/targets/theming)
30+
31+
### [creating a PXT package](/packages)
32+
33+
### resources specific to devices
34+
35+
* [UF2 file format](http://github.com/microsoft/uf2)
36+
* [embedding source code](/source-embedding)
37+
* [partial flashing](/partial-flashing)
38+

docs/targets/board.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Board Definition
2+
3+
TBD
4+
5+
```typescript
6+
interface BoardDefinition {
7+
visual: BoardImageDefinition | string,
8+
gpioPinBlocks?: string[][],
9+
gpioPinMap: { [pin: string]: string },
10+
groundPins: string[],
11+
threeVoltPins: string[],
12+
attachPowerOnRight?: boolean,
13+
onboardComponents?: string[]
14+
useCrocClips?: boolean,
15+
marginWhenBreadboarding?: [number, number, number, number],
16+
spiPins?: {
17+
MOSI: string,
18+
MISO: string,
19+
SCK: string,
20+
},
21+
i2cPins?: {
22+
SDA: string,
23+
SCL: string,
24+
},
25+
analogInPins?: string[] //TODO: implement allocation
26+
}
27+
```

docs/targets/pxtarget.md

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ Most of the user-defined fields for `pxttarget.json` are described by the interf
8989

9090
### corepkg: string
9191

92-
A target must have a package under the libs/ directory where the core APIs for the target reside.
93-
Also, the core should always be bundled with the web app, as shown below:
92+
A target must have a core [package](/packages) under the libs/ directory
93+
where the core APIs for the target reside.
94+
The core package should always be bundled with the web app, as shown below:
9495
```typescript
9596
"corepkg": "core",
9697
"bundleddirs": [
@@ -177,13 +178,13 @@ the `cloud` field in pxttarget.json, defined by the `AppCloud` interface:
177178
packages?: boolean; // enabled loading of packages (from github)
178179
preferredPackages?: string[]; // list of company/project(#tag) of packages on github
179180
githubPackages?: boolean; // enable user-specified term for searching github for packages
180-
181-
// not currently supported
182-
workspaces?: boolean;
183181

184182
// to be retired soon
185183
publishing?: boolean; // must set true for importing? to work; no other purpose evident
186184
embedding?: boolean;
185+
186+
// not currently supported
187+
workspaces?: boolean;
187188
}
188189
```
189190

@@ -203,42 +204,73 @@ For example in the pxttarget.json for http://github.com/microsoft/pxt-microbit,
203204

204205
### simulator?: AppSimulator;
205206

207+
PXT provides a JavaScript-based simulation environment on the left side of the web
208+
app (typically for physical computing devices like the micro:bit). PXT uses the
209+
term [board](/targets/board) to refer to the main physical computing device shown in the simulator.
210+
Each target has one board (plus optional parts).
211+
206212
```typescript
207213
interface AppSimulator {
208-
autoRun?: boolean;
209-
stopOnChange?: boolean;
210-
hideRestart?: boolean;
211-
enableTrace?: boolean;
212-
hideFullscreen?: boolean;
213-
streams?: boolean;
214-
aspectRatio?: number; // width / height
215-
boardDefinition?: pxsim.BoardDefinition;
216-
parts?: boolean; // parts enabled?
217-
instructions?: boolean;
218-
partsAspectRatio?: number; // aspect ratio of the simulator when parts are displayed
219-
headless?: boolean; // whether simulator should still run while collapsed
220-
trustedUrls?: string[]; // URLs that are allowed in simulator modal messages
214+
// define aspects of physical computing device
215+
boardDefinition?: BoardDefinition;
216+
217+
// running and code changes
218+
autoRun?: boolean; // automatically run program after a change to its code
219+
stopOnChange?: boolean; // stop execution when user changes code
220+
headless?: boolean; // whether simulator should still run while collapsed
221+
222+
// buttons and parts
223+
hideRestart?: boolean; // hide the restart button
224+
hideFullscreen?: boolean; // hide the fullscreen button
225+
enableTrace?: boolean; // enable the slow-mode (snail) button
226+
parts?: boolean; // parts enabled?
227+
instructions?: boolean; // generate step-by-step wiring instructions (Make button)
228+
229+
// appearance
230+
aspectRatio?: number; // width / height
231+
partsAspectRatio?: number; // aspect ratio of the simulator when parts are displayed
232+
233+
// miscellaneous
234+
trustedUrls?: string[]; // URLs that are allowed in simulator modal messages
221235
}
222236
```
223237

238+
224239
### runtime?: RuntimeOptions;
225240

241+
This severely misnamed option controls the available blocks in the Blockly editor:
242+
226243
```typescript
227244
interface RuntimeOptions {
228-
mathBlocks?: boolean;
245+
// control whether or not Blockly built-in categories appear
246+
mathBlocks?: boolean;
229247
textBlocks?: boolean;
230248
listsBlocks?: boolean;
231249
variablesBlocks?: boolean;
232250
logicBlocks?: boolean;
233251
loopsBlocks?: boolean;
252+
253+
// ???
234254
extraBlocks?: BlockToolboxDefinition[];
255+
256+
// options specific to the special "on start" block
235257
onStartNamespace?: string; // default = loops
236258
onStartColor?: string;
237259
onStartWeight?: number;
238260
onStartUnDeletable?: boolean;
239261
}
240262
```
241263

264+
```typescript
265+
interface BlockToolboxDefinition {
266+
namespace: string;
267+
type: string;
268+
gap?: number;
269+
weight?: number;
270+
fields?: Map<string>;
271+
}
272+
```
273+
242274
### serial?: AppSerial;
243275

244276
```typescript
@@ -274,4 +306,5 @@ For example in the pxttarget.json for http://github.com/microsoft/pxt-microbit,
274306
userVoiceApiKey?: string;
275307
userVoiceForumId?: number;
276308
}
277-
```
309+
```
310+

0 commit comments

Comments
 (0)