Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
aeff3d9f45 | |||
6530bc26ae | |||
8ea9f1fb26 | |||
1e94e04104 | |||
e95d29286a | |||
14d50810cb | |||
250e21b5c9 | |||
98eab3672f | |||
360e2b7ba6 | |||
f255e1a903 | |||
d4762cc5b5 | |||
749b5266cb | |||
bbd23f6d26 | |||
4bef7d50bd | |||
bf423ca037 | |||
7556796eb6 | |||
0a380a70d1 | |||
5c57e0faa4 | |||
41abeb62c3 | |||
b6eeeef4d5 | |||
b5b7edb978 | |||
a65fe1343c | |||
3165fb3749 | |||
2789887f3b | |||
d230fdd2fb | |||
88c9ef5b22 | |||
154115cc66 | |||
145dbaeb8f | |||
1c8ceaef17 | |||
e30c6f7149 | |||
e69174ed0f | |||
303d37ac9b | |||
69e2b41c40 |
60
cmds/cmds.ts
60
cmds/cmds.ts
@ -1,60 +0,0 @@
|
|||||||
/// <reference path="../node_modules/pxt-core/typings/node/node.d.ts"/>
|
|
||||||
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
|
|
||||||
|
|
||||||
import * as fs from "fs";
|
|
||||||
import * as path from "path";
|
|
||||||
import * as child_process from "child_process";
|
|
||||||
|
|
||||||
let writeFileAsync: any = Promise.promisify(fs.writeFile)
|
|
||||||
let execAsync: (cmd: string, options?: { cwd?: string }) => Promise<Buffer> = Promise.promisify(child_process.exec)
|
|
||||||
let readDirAsync = Promise.promisify(fs.readdir)
|
|
||||||
|
|
||||||
|
|
||||||
export function deployCoreAsync(res: ts.pxtc.CompileResult) {
|
|
||||||
return getBitDrivesAsync()
|
|
||||||
.then(drives => {
|
|
||||||
if (drives.length == 0) {
|
|
||||||
console.log("cannot find any drives to deploy to");
|
|
||||||
return Promise.resolve(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "));
|
|
||||||
|
|
||||||
let writeHexFile = (filename: string) => {
|
|
||||||
return writeFileAsync(filename + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX])
|
|
||||||
.then(() => console.log("wrote hex file to " + filename));
|
|
||||||
};
|
|
||||||
|
|
||||||
return Promise.map(drives, d => writeHexFile(d))
|
|
||||||
.then(() => drives.length);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getBitDrivesAsync(): Promise<string[]> {
|
|
||||||
if (process.platform == "win32") {
|
|
||||||
const rx = new RegExp("^([A-Z]:).* " + pxt.appTarget.compile.deployDrives)
|
|
||||||
return execAsync("wmic PATH Win32_LogicalDisk get DeviceID, VolumeName, FileSystem")
|
|
||||||
.then(buf => {
|
|
||||||
let res: string[] = []
|
|
||||||
buf.toString("utf8").split(/\n/).forEach(ln => {
|
|
||||||
let m = rx.exec(ln)
|
|
||||||
if (m) {
|
|
||||||
res.push(m[1] + "/")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else if (process.platform == "darwin") {
|
|
||||||
const rx = new RegExp(pxt.appTarget.compile.deployDrives)
|
|
||||||
return readDirAsync("/Volumes")
|
|
||||||
.then(lst => lst.filter(s => rx.test(s)).map(s => "/Volumes/" + s + "/"))
|
|
||||||
} else if (process.platform == "linux") {
|
|
||||||
const rx = new RegExp(pxt.appTarget.compile.deployDrives)
|
|
||||||
const user = process.env["USER"]
|
|
||||||
return readDirAsync(`/media/${user}`)
|
|
||||||
.then(lst => lst.filter(s => rx.test(s)).map(s => `/media/${user}/${s}/`))
|
|
||||||
} else {
|
|
||||||
return Promise.resolve([])
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +1,6 @@
|
|||||||
|
/// <reference path="../node_modules/pxt-core/typings/node/node.d.ts"/>
|
||||||
|
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
|
||||||
|
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
export let pxtCore = require("pxt-core");
|
export let pxtCore = require("pxt-core");
|
||||||
// require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir
|
// require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"appref": "v0.5.89"
|
"appref": "v0.7.3"
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"bluetooth": "Support for additional Bluetooth services.",
|
"bluetooth": "Support for additional Bluetooth services.\n\nSupport for additional Bluetooth services.",
|
||||||
"bluetooth.onBluetoothConnected": "Register code to run when the micro:bit is connected to over Bluetooth",
|
"bluetooth.onBluetoothConnected": "Register code to run when the micro:bit is connected to over Bluetooth",
|
||||||
"bluetooth.onBluetoothConnected|param|body": "Code to run when a Bluetooth connection is established",
|
"bluetooth.onBluetoothConnected|param|body": "Code to run when a Bluetooth connection is established",
|
||||||
"bluetooth.onBluetoothDisconnected": "Register code to run when a bluetooth connection to the micro:bit is lost",
|
"bluetooth.onBluetoothDisconnected": "Register code to run when a bluetooth connection to the micro:bit is lost",
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
"String.substr": "Return substring of the current string.",
|
"String.substr": "Return substring of the current string.",
|
||||||
"String.substr|param|length": "number of characters to extract",
|
"String.substr|param|length": "number of characters to extract",
|
||||||
"String.substr|param|start": "first character index; can be negative from counting from the end, eg:0",
|
"String.substr|param|start": "first character index; can be negative from counting from the end, eg:0",
|
||||||
"basic": "Provides access to basic micro:bit functionality.",
|
"basic": "Provides access to basic micro:bit functionality.\n\nProvides access to basic micro:bit functionality.",
|
||||||
"basic.clearScreen": "Turn off all LEDs",
|
"basic.clearScreen": "Turn off all LEDs",
|
||||||
"basic.color": "Converts the color name to a number",
|
"basic.color": "Converts the color name to a number",
|
||||||
"basic.forever": "Repeats the code forever in the background. On each iteration, allows other codes to run.",
|
"basic.forever": "Repeats the code forever in the background. On each iteration, allows other codes to run.",
|
||||||
|
@ -79,7 +79,7 @@ namespace pxt {
|
|||||||
|
|
||||||
intcheck(vtable->methods[0] == &RefRecord_destroy, ERR_SIZE, 3);
|
intcheck(vtable->methods[0] == &RefRecord_destroy, ERR_SIZE, 3);
|
||||||
intcheck(vtable->methods[1] == &RefRecord_print, ERR_SIZE, 4);
|
intcheck(vtable->methods[1] == &RefRecord_print, ERR_SIZE, 4);
|
||||||
|
|
||||||
void *ptr = ::operator new(vtable->numbytes);
|
void *ptr = ::operator new(vtable->numbytes);
|
||||||
RefRecord *r = new (ptr) RefRecord(PXT_VTABLE_TO_INT(vtable));
|
RefRecord *r = new (ptr) RefRecord(PXT_VTABLE_TO_INT(vtable));
|
||||||
memset(r->fields, 0, vtable->numbytes - sizeof(RefRecord));
|
memset(r->fields, 0, vtable->numbytes - sizeof(RefRecord));
|
||||||
@ -117,7 +117,6 @@ namespace pxt {
|
|||||||
|
|
||||||
void RefObject::destroy() {
|
void RefObject::destroy() {
|
||||||
((RefObjectMethod)getVTable()->methods[0])(this);
|
((RefObjectMethod)getVTable()->methods[0])(this);
|
||||||
delete this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefObject::print() {
|
void RefObject::print() {
|
||||||
@ -132,6 +131,9 @@ namespace pxt {
|
|||||||
if (refmask[i]) decr(r->fields[i]);
|
if (refmask[i]) decr(r->fields[i]);
|
||||||
r->fields[i] = 0;
|
r->fields[i] = 0;
|
||||||
}
|
}
|
||||||
|
//RefRecord is allocated using placement new
|
||||||
|
r->~RefRecord();
|
||||||
|
::operator delete(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefRecord_print(RefRecord *r)
|
void RefRecord_print(RefRecord *r)
|
||||||
@ -242,6 +244,7 @@ namespace pxt {
|
|||||||
this->data[i] = 0;
|
this->data[i] = 0;
|
||||||
}
|
}
|
||||||
this->data.resize(0);
|
this->data.resize(0);
|
||||||
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefCollection::print()
|
void RefCollection::print()
|
||||||
@ -258,6 +261,9 @@ namespace pxt {
|
|||||||
decr(fields[i]);
|
decr(fields[i]);
|
||||||
fields[i] = 0;
|
fields[i] = 0;
|
||||||
}
|
}
|
||||||
|
//RefAction is allocated using placement new
|
||||||
|
this->~RefAction();
|
||||||
|
::operator delete(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefAction::print()
|
void RefAction::print()
|
||||||
@ -272,6 +278,7 @@ namespace pxt {
|
|||||||
|
|
||||||
void RefLocal::destroy()
|
void RefLocal::destroy()
|
||||||
{
|
{
|
||||||
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
PXT_VTABLE_CTOR(RefLocal) {
|
PXT_VTABLE_CTOR(RefLocal) {
|
||||||
@ -290,6 +297,7 @@ namespace pxt {
|
|||||||
void RefRefLocal::destroy()
|
void RefRefLocal::destroy()
|
||||||
{
|
{
|
||||||
decr(v);
|
decr(v);
|
||||||
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
PXT_VTABLE_BEGIN(RefMap, 0, RefMapMarker)
|
PXT_VTABLE_BEGIN(RefMap, 0, RefMapMarker)
|
||||||
@ -304,6 +312,7 @@ namespace pxt {
|
|||||||
data[i].val = 0;
|
data[i].val = 0;
|
||||||
}
|
}
|
||||||
data.resize(0);
|
data.resize(0);
|
||||||
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RefMap::findIdx(uint32_t key) {
|
int RefMap::findIdx(uint32_t key) {
|
||||||
@ -328,7 +337,7 @@ namespace pxt {
|
|||||||
for(std::set<RefObject*>::iterator itr = allptrs.begin();itr!=allptrs.end();itr++)
|
for(std::set<RefObject*>::iterator itr = allptrs.begin();itr!=allptrs.end();itr++)
|
||||||
{
|
{
|
||||||
(*itr)->print();
|
(*itr)->print();
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -341,16 +350,16 @@ namespace pxt {
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
map<pair<int, int>, Action> handlersMap;
|
map<pair<int, int>, Action> handlersMap;
|
||||||
|
|
||||||
MicroBitEvent lastEvent;
|
MicroBitEvent lastEvent;
|
||||||
|
|
||||||
// We have the invariant that if [dispatchEvent] is registered against the DAL
|
// We have the invariant that if [dispatchEvent] is registered against the DAL
|
||||||
// for a given event, then [handlersMap] contains a valid entry for that
|
// for a given event, then [handlersMap] contains a valid entry for that
|
||||||
// event.
|
// event.
|
||||||
void dispatchEvent(MicroBitEvent e) {
|
void dispatchEvent(MicroBitEvent e) {
|
||||||
|
|
||||||
lastEvent = e;
|
lastEvent = e;
|
||||||
|
|
||||||
Action curr = handlersMap[{ e.source, e.value }];
|
Action curr = handlersMap[{ e.source, e.value }];
|
||||||
if (curr)
|
if (curr)
|
||||||
runAction1(curr, e.value);
|
runAction1(curr, e.value);
|
||||||
@ -383,7 +392,7 @@ namespace pxt {
|
|||||||
create_fiber((void(*)(void*))runAction0, (void*)a, fiberDone);
|
create_fiber((void(*)(void*))runAction0, (void*)a, fiberDone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void error(ERROR code, int subcode)
|
void error(ERROR code, int subcode)
|
||||||
{
|
{
|
||||||
@ -435,10 +444,10 @@ namespace pxt {
|
|||||||
|
|
||||||
// unique group for radio based on source hash
|
// unique group for radio based on source hash
|
||||||
// ::touch_develop::micro_bit::radioDefaultGroup = programHash();
|
// ::touch_develop::micro_bit::radioDefaultGroup = programHash();
|
||||||
|
|
||||||
// repeat error 4 times and restart as needed
|
// repeat error 4 times and restart as needed
|
||||||
microbit_panic_timeout(4);
|
microbit_panic_timeout(4);
|
||||||
|
|
||||||
int32_t ver = *pc++;
|
int32_t ver = *pc++;
|
||||||
checkStr(ver == 0x4209, ":( Bad runtime version");
|
checkStr(ver == 0x4209, ":( Bad runtime version");
|
||||||
|
|
||||||
@ -467,6 +476,6 @@ namespace pxt {
|
|||||||
{
|
{
|
||||||
exec_binary((int32_t*)functionsAndBytecode);
|
exec_binary((int32_t*)functionsAndBytecode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: ts=2 sw=2 expandtab
|
// vim: ts=2 sw=2 expandtab
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pxt-calliope",
|
"name": "pxt-calliope",
|
||||||
"version": "0.5.94",
|
"version": "0.7.7",
|
||||||
"description": "calliope target for PXT",
|
"description": "calliope target for PXT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"JavaScript",
|
"JavaScript",
|
||||||
@ -34,6 +34,6 @@
|
|||||||
"semantic-ui-less": "^2.2.4"
|
"semantic-ui-less": "^2.2.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pxt-core": "0.5.87"
|
"pxt-core": "0.7.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,9 @@
|
|||||||
"mathBlocks": true,
|
"mathBlocks": true,
|
||||||
"loopsBlocks": true,
|
"loopsBlocks": true,
|
||||||
"logicBlocks": true,
|
"logicBlocks": true,
|
||||||
"variablesBlocks": true
|
"variablesBlocks": true,
|
||||||
|
"onStartColor": "#54C9C9",
|
||||||
|
"onStartNamespace": "basic"
|
||||||
},
|
},
|
||||||
"simulator": {
|
"simulator": {
|
||||||
"autoRun": true,
|
"autoRun": true,
|
||||||
@ -289,8 +291,16 @@
|
|||||||
],
|
],
|
||||||
"invertedMenu": true,
|
"invertedMenu": true,
|
||||||
"invertedToolbox": true,
|
"invertedToolbox": true,
|
||||||
|
"monacoToolbox": false,
|
||||||
"simAnimationEnter": "rotate in",
|
"simAnimationEnter": "rotate in",
|
||||||
"simAnimationExit": "rotate out",
|
"simAnimationExit": "rotate out",
|
||||||
"blocklyOptions": { }
|
"blocklyOptions": {
|
||||||
|
"grid": {
|
||||||
|
"spacing": 45,
|
||||||
|
"length": 7,
|
||||||
|
"colour": "rgba(189, 195, 199, 0.30)",
|
||||||
|
"snap": false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
background: #4ECC60 !important;
|
background: #4ECC60 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.blocks-menuitem, .javascript-menuitem {
|
.blocks-menuitem.active, .javascript-menuitem.active {
|
||||||
background: #738791 !important;
|
background: #738791 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,10 +87,13 @@
|
|||||||
padding:7px;
|
padding:7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#blocklyAddPackage {
|
/* Blockly Toolbox Buttons */
|
||||||
text-align: left;
|
#blocklyToolboxButtons .blocklyAddPackageButton {
|
||||||
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
#blocklyAddPackage button {
|
|
||||||
|
#blocklyToolboxButtons .blocklyUndoButton {
|
||||||
background-color: rgba(0, 0, 0, 0.3);
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
@ -100,7 +103,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Mobile */
|
/* Mobile */
|
||||||
@media only screen and (max-width: @largestMobileScreen) {
|
@media only screen and (max-width: @largestMobileEditorBreakpoint) {
|
||||||
.blocklyTreeLabel {
|
.blocklyTreeLabel {
|
||||||
font-size: 0.5rem !important;
|
font-size: 0.5rem !important;
|
||||||
}
|
}
|
||||||
@ -110,27 +113,42 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Tablet */
|
/* Tablet */
|
||||||
@media only screen and (min-width: @tabletBreakpoint) and (max-width: @largestTabletScreen) {
|
@media only screen and (min-width: @tabletEditorBreakpoint) and (max-width: @largestTabletEditorBreakpoint) {
|
||||||
.organization {
|
.organization {
|
||||||
top: auto;
|
top: auto;
|
||||||
}
|
}
|
||||||
|
/* Blockly Toolbox buttons */
|
||||||
|
#blocklyToolboxButtons {
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Small Monitor */
|
/* Small Monitor */
|
||||||
@media only screen and (min-width: @computerBreakpoint) and (max-width: @largestSmallMonitor) {
|
@media only screen and (min-width: @computerEditorBreakpoint) and (max-width: @largestSmallMonitorEditorBreakpoint) {
|
||||||
.organization {
|
.organization {
|
||||||
top: auto;
|
top: auto;
|
||||||
}
|
}
|
||||||
.blocklyTreeRow {
|
.blocklyTreeRow {
|
||||||
width: 230px;
|
width: 230px;
|
||||||
}
|
}
|
||||||
|
/* Blockly Toolbox buttons */
|
||||||
|
#blocklyToolboxButtons {
|
||||||
|
margin-right: 1rem;
|
||||||
|
margin-left: 1rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Large Monitor */
|
/* Large Monitor */
|
||||||
@media only screen and (min-width: @largeMonitorBreakpoint) {
|
@media only screen and (min-width: @largeMonitorEditorBreakpoint) {
|
||||||
.blocklyTreeRow {
|
.blocklyTreeRow {
|
||||||
width: 230px;
|
width: 230px;
|
||||||
}
|
}
|
||||||
|
/* Blockly Toolbox buttons */
|
||||||
|
#blocklyToolboxButtons {
|
||||||
|
margin-right: 2rem;
|
||||||
|
margin-left: 2rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
|
Reference in New Issue
Block a user