Compare commits

..

8 Commits

Author SHA1 Message Date
24420a2cc4 0.2.121 2016-05-16 21:52:35 -07:00
2f8b61998b bringing back triangles / logo on simulator 2016-05-16 21:48:54 -07:00
af38071c6a 0.2.120 2016-05-16 16:25:04 -07:00
89f09c7f35 added pins->on pulsed 2016-05-16 16:24:44 -07:00
a667467bbd 0.2.119 2016-05-13 06:25:57 -07:00
ada2583e17 removing browserconfig.xml / favicon.ico until cloud supports it 2016-05-13 06:18:15 -07:00
c04538313d 0.2.118 2016-05-13 05:44:48 -07:00
1039dc560e Bump pxt-core to 0.2.129 2016-05-13 05:44:46 -07:00
15 changed files with 143 additions and 60 deletions

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/static/icons/mstile-70x70.png"/>
<square150x150logo src="/static/icons/mstile-150x150.png"/>
<square310x310logo src="/static/icons/mstile-310x310.png"/>
<wide310x150logo src="/static/icons/mstile-310x150.png"/>
<TileColor>#9f00a7</TileColor>
</tile>
</msapplication>
</browserconfig>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

View File

@ -141,7 +141,7 @@ namespace control {
* @param value Component specific code indicating the cause of the event.
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
*/
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
//% mode.defl=CREATE_AND_FIRE
void raiseEvent(int src, int value, EventCreationMode mode) {
MicroBitEvent evt(src, value, (MicroBitEventLaunchMode)mode);
@ -150,11 +150,29 @@ namespace control {
/**
* Raises an event in the event bus.
*/
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source|with value %value=control_event_value"
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
//% blockExternalInputs=1
void onEvent(int src, int value, Action handler) {
registerWithDal(src, value, handler);
}
/**
* Gets the value of the last event executed on the bus
*/
//% blockId=control_event_value" block="event value"
//% weight=18
int eventValue() {
return pxt::lastEvent.value;
}
/**
* Gets the timestamp of the last event executed on the bus
*/
//% blockId=control_event_timestamp" block="event timestamp"
//% weight=19 blockGap-8
int eventTimestamp() {
return pxt::lastEvent.timestamp;
}
/**
* Gets a friendly name for the device derived from the its serial number

View File

@ -7,15 +7,15 @@ namespace control {
/**
* Returns the value of a C++ runtime constant
*/
//% weight=19 weight=19 blockId="control_event_source" block="%id"
export function eventSource(id: EventBusSource) : number {
//% weight=2 weight=19 blockId="control_event_source_id" block="%id" blockGap=8
export function eventSourceId(id: EventBusSource): number {
return id;
}
/**
* Returns the value of a C++ runtime constant
*/
//% weight=19 weight=19 blockId="control_event_value" block="%id"
export function eventValue(id: EventBusValue) : number {
//% weight=1 weight=19 blockId="control_event_value_id" block="%id"
export function eventValueId(id: EventBusValue): number {
return id;
}
@ -23,8 +23,7 @@ namespace control {
* Display specified error code and stop the program.
*/
//% shim=pxtrt::panic
export function panic(code:number)
{
export function panic(code: number) {
}
/**

View File

@ -262,6 +262,12 @@ declare namespace led {
P4 = 11, // MICROBIT_ID_IO_P4
P10 = 17, // MICROBIT_ID_IO_P10
}
declare enum PulseValue {
High = 4, // MICROBIT_PIN_EVT_PULSE_HI
Low = 5, // MICROBIT_PIN_EVT_PULSE_LO
}
declare namespace pins {
}
declare namespace serial {

View File

@ -104,7 +104,7 @@ namespace input {
* @param button TODO
* @param body TODO
*/
//% help=input/on-button-pressed weight=85
//% help=input/on-button-pressed weight=85 blockGap=8
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
void onButtonPressed(Button button, Action body) {
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
@ -114,7 +114,7 @@ namespace input {
* Attaches code to run when the screen is facing up.
* @param body TODO
*/
//% help=input/on-gesture weight=84
//% help=input/on-gesture weight=84 blockGap=8
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
void onGesture(Gesture gesture, Action body) {
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);

View File

@ -8,7 +8,7 @@ namespace led {
let barGraphHigh = 0;
// when was the current high value recorded
let barGraphHighLast = 0;
/**
* Displays a vertical bar graph based on the `value` and `high` value.
* If `high` is 0, the chart gets adjusted automatically.
@ -17,35 +17,35 @@ namespace led {
*/
//% help=/led/plot-bar-graph weight=20
//% blockId=device_plot_bar_graph block="plot bar graph of %value |up to %high" icon="\uf080" blockExternalInputs=true
export function plotBarGraph(value: number, high: number): void {
export function plotBarGraph(value: number, high: number): void {
let now = input.runningTime();
serial.writeString(value.toString() + "\r\n");
value = Math.abs(value);
if (high != 0) barGraphHigh = high;
else if (value > barGraphHigh || now - barGraphHighLast > 5000) {
barGraphHigh = value;
barGraphHighLast = now;
}
barGraphHigh = Math.max(barGraphHigh, 16);
let v = (value * 15) / barGraphHigh;
let k = 0;
for(let y = 4; y >= 0; --y) {
for (let y = 4; y >= 0; --y) {
for (let x = 0; x < 3; ++x) {
if (k > v) {
unplot(2-x,y);
unplot(2+x,y);
unplot(2 - x, y);
unplot(2 + x, y);
} else {
plot(2-x, y);
plot(2+x, y);
plot(2 - x, y);
plot(2 + x, y);
}
++k;
}
}
}
}
/**
* Toggles a particular pixel
* @param x TODO

View File

@ -77,9 +77,9 @@ enum BeatFraction {
/**
* Generation of music tones through pin ``P0``.
*/
//% color=52 weight=33
//% color=52 weight=98
namespace music {
var beatsPerMinute: number = 120;
let beatsPerMinute: number = 120;
/**
* Plays a tone through pin ``P0`` for the given duration.

View File

@ -31,6 +31,11 @@ enum class AnalogPin {
P10 = MICROBIT_ID_IO_P10,
};
enum class PulseValue {
High = MICROBIT_PIN_EVT_PULSE_HI,
Low = MICROBIT_PIN_EVT_PULSE_LO
};
MicroBitPin *getPin(int id) {
switch (id) {
case MICROBIT_ID_IO_P0: return &uBit.io.P0;
@ -75,7 +80,6 @@ namespace pins {
return getPin(id);
}
/**
* Read the specified pin or connector as either 0 or 1
* @param name pin to read from
@ -129,6 +133,29 @@ namespace pins {
void analogSetPeriod(AnalogPin name, int micros) {
PINOP(setAnalogPeriodUs(micros));
}
/**
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
*/
//% help=pins/on-pulsed weight=22 blockGap=8
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
void onPulsed(DigitalPin name, PulseValue pulse, Action body) {
MicroBitPin* pin = getPin((int)name);
if (!pin) return;
pin->eventOn(MICROBIT_PIN_EVENT_ON_PULSE);
registerWithDal((int)name, (int)pulse, body);
}
/**
* Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulse`` handler.
*/
//% help=pins/pulse-micros
//% blockId=pins_pulse_duration block="pulse duration (us)"
//% weight=21
int pulseDuration() {
return pxt::lastEvent.timestamp;
}
/**
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).

View File

@ -20,7 +20,7 @@ namespace pins {
/**
* Read one number from 7-bit I2C address.
*/
//% help=pins/i2c-read-number
//% help=pins/i2c-read-number blockGap=8
//% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format=i2c_sizeof" weight=7
export function i2cReadNumber(address: number, format: NumberFormat): number {
let buf = pins.i2cReadBuffer(address, pins.sizeOf(format))

View File

@ -200,7 +200,7 @@ declare namespace input {
* @param button TODO
* @param body TODO
*/
//% help=input/on-button-pressed weight=85
//% help=input/on-button-pressed weight=85 blockGap=8
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192" shim=input::onButtonPressed
function onButtonPressed(button: Button, body: () => void): void;
@ -208,7 +208,7 @@ declare namespace input {
* Attaches code to run when the screen is facing up.
* @param body TODO
*/
//% help=input/on-gesture weight=84
//% help=input/on-gesture weight=84 blockGap=8
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135" shim=input::onGesture
function onGesture(gesture: Gesture, body: () => void): void;
@ -332,17 +332,31 @@ declare namespace control {
* @param value Component specific code indicating the cause of the event.
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
*/
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
//% mode.defl=1 shim=control::raiseEvent
function raiseEvent(src: number, value: number, mode?: EventCreationMode): void;
/**
* Raises an event in the event bus.
*/
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source|with value %value=control_event_value"
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
//% blockExternalInputs=1 shim=control::onEvent
function onEvent(src: number, value: number, handler: () => void): void;
/**
* Gets the value of the last event executed on the bus
*/
//% blockId=control_event_value" block="event value"
//% weight=18 shim=control::eventValue
function eventValue(): number;
/**
* Gets the timestamp of the last event executed on the bus
*/
//% blockId=control_event_timestamp" block="event timestamp"
//% weight=19 blockGap-8 shim=control::eventTimestamp
function eventTimestamp(): number;
/**
* Gets a friendly name for the device derived from the its serial number
*/
@ -473,6 +487,21 @@ declare namespace pins {
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" shim=pins::analogSetPeriod
function analogSetPeriod(name: AnalogPin, micros: number): void;
/**
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
*/
//% help=pins/on-pulsed weight=22 blockGap=8
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse" shim=pins::onPulsed
function onPulsed(name: DigitalPin, pulse: PulseValue, body: () => void): void;
/**
* Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulse`` handler.
*/
//% help=pins/pulse-micros
//% blockId=pins_pulse_duration block="pulse duration (us)"
//% weight=21 shim=pins::pulseDuration
function pulseDuration(): number;
/**
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
* @param name pin to write to

View File

@ -1,6 +1,6 @@
{
"name": "pxt-microbit",
"version": "0.2.117",
"version": "0.2.121",
"description": "BBC micro:bit target for PXT",
"keywords": [
"JavaScript",
@ -29,6 +29,6 @@
"typescript": "^1.8.7"
},
"dependencies": {
"pxt-core": "0.2.127"
"pxt-core": "0.2.129"
}
}

View File

@ -63,7 +63,7 @@
"aspectRatio": 1.22
},
"compileService": {
"gittag": "v0.1.9",
"gittag": "v0.1.10",
"serviceId": "ws"
},
"serial": {

View File

@ -501,6 +501,13 @@ namespace pxsim.radio {
}
namespace pxsim.pins {
export function onPulse(name: number, pulse: number, body: RefAction) {
}
export function pulseDuration(): number {
return 0;
}
export function digitalReadPin(pinId: number): number {
let pin = getPin(pinId);
if (!pin) return;

View File

@ -234,8 +234,8 @@ namespace pxsim.micro_bit {
let t = Math.max(tmin, Math.min(tmax, state.temperature))
let per = Math.floor((state.temperature - tmin) / (tmax - tmin) * 100)
svg.setGradientValue(this.thermometerGradient, 100 - per + '%');
this.thermometerText.textContent = t + '°C';
svg.setGradientValue(this.thermometerGradient, 100 - per + "%");
this.thermometerText.textContent = t + "°C";
}
private updateHeading() {
@ -244,8 +244,8 @@ namespace pxsim.micro_bit {
let state = this.board;
if (!state || !state.usesHeading) return;
if (!this.headInitialized) {
let p = svg.path(this.head, "sim-theme", "m269.9,50.134647l0,0l-39.5,0l0,0c-14.1,0.1 -24.6,10.7 -24.6,24.8c0,13.9 10.4,24.4 24.3,24.7l0,0l39.6,0c14.2,0 40.36034,-22.97069 40.36034,-24.85394c0,-1.88326 -26.06034,-24.54606 -40.16034,-24.64606m-0.2,39l0,0l-39.3,0c-7.7,-0.1 -14,-6.4 -14,-14.2c0,-7.8 6.4,-14.2 14.2,-14.2l39.1,0c7.8,0 14.2,6.4 14.2,14.2c0,7.9 -6.4,14.2 -14.2,14.2l0,0l0,0z");
this.logos.push(p);
let p = this.head.firstChild.nextSibling as SVGPathElement;
p.setAttribute("d", "m269.9,50.134647l0,0l-39.5,0l0,0c-14.1,0.1 -24.6,10.7 -24.6,24.8c0,13.9 10.4,24.4 24.3,24.7l0,0l39.6,0c14.2,0 40.36034,-22.97069 40.36034,-24.85394c0,-1.88326 -26.06034,-24.54606 -40.16034,-24.64606m-0.2,39l0,0l-39.3,0c-7.7,-0.1 -14,-6.4 -14,-14.2c0,-7.8 6.4,-14.2 14.2,-14.2l39.1,0c7.8,0 14.2,6.4 14.2,14.2c0,7.9 -6.4,14.2 -14.2,14.2l0,0l0,0z");
this.updateTheme();
let pt = this.element.createSVGPoint();
svg.buttonEvents(
@ -437,6 +437,18 @@ svg.sim.grayscale {
}
/* animations */
.sim-theme-glow {
animation-name: sim-theme-glow-animation;
animation-timing-function: ease-in-out;
animation-direction: alternate;
animation-iteration-count: infinite;
animation-duration: 1.25s;
}
@keyframes sim-theme-glow-animation {
from { opacity: 1; }
to { opacity: 0.8; }
}
.sim-flash {
animation-name: sim-flash-animation;
animation-duration: 0.1s;
@ -452,9 +464,6 @@ svg.sim.grayscale {
animation-duration: 0.4s;
animation-timing-function: ease-in;
}
.sim-button-label {
fill:#fff;
}
@keyframes sim-flash-stroke-animation {
from { stroke: yellow; }
@ -481,11 +490,11 @@ svg.sim.grayscale {
this.display = svg.path(this.g, "sim-display", "M333.8,310.3H165.9c-8.3,0-15-6.7-15-15V127.5c0-8.3,6.7-15,15-15h167.8c8.3,0,15,6.7,15,15v167.8C348.8,303.6,342.1,310.3,333.8,310.3z");
this.logos = [];
//this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "115,56.7 173.1,0 115,0" }));
//this.logos.push(svg.path(this.g, "sim-theme", "M114.2,0H25.9C12.1,2.1,0,13.3,0,27.7v83.9L114.2,0z"));
//this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "173,27.9 202.5,0 173,0" }));
//this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "54.1,242.4 54.1,274.1 22.4,274.1" }));
//this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "446.2,164.6 446.2,132.8 477.9,132.8" }));
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "115,56.7 173.1,0 115,0" }));
this.logos.push(svg.path(this.g, "sim-theme", "M114.2,0H25.9C12.1,2.1,0,13.3,0,27.7v83.9L114.2,0z"));
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "173,27.9 202.5,0 173,0" }));
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "54.1,242.4 54.1,274.1 22.4,274.1" }));
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "446.2,164.6 446.2,132.8 477.9,132.8" }));
// leds
this.leds = [];
@ -504,9 +513,9 @@ svg.sim.grayscale {
// head
this.head = <SVGGElement>svg.child(this.g, "g", {});
svg.child(this.head, "circle", { cx: 258, cy: 75, r: 100, fill: "transparent" })
//this.logos.push(svg.path(this.head, "sim-theme", "M269.9,50.2L269.9,50.2l-39.5,0v0c-14.1,0.1-24.6,10.7-24.6,24.8c0,13.9,10.4,24.4,24.3,24.7v0h39.6c14.2,0,24.8-10.6,24.8-24.7C294.5,61,284,50.3,269.9,50.2 M269.7,89.2L269.7,89.2l-39.3,0c-7.7-0.1-14-6.4-14-14.2c0-7.8,6.4-14.2,14.2-14.2h39.1c7.8,0,14.2,6.4,14.2,14.2C283.9,82.9,277.5,89.2,269.7,89.2"));
//this.logos.push(svg.path(this.head, "sim-theme", "M230.6,69.7c-2.9,0-5.3,2.4-5.3,5.3c0,2.9,2.4,5.3,5.3,5.3c2.9,0,5.3-2.4,5.3-5.3C235.9,72.1,233.5,69.7,230.6,69.7"));
//this.logos.push(svg.path(this.head, "sim-theme", "M269.7,80.3c2.9,0,5.3-2.4,5.3-5.3c0-2.9-2.4-5.3-5.3-5.3c-2.9,0-5.3,2.4-5.3,5.3C264.4,77.9,266.8,80.3,269.7,80.3"));
this.logos.push(svg.path(this.head, "sim-theme sim-theme-glow", "M269.9,50.2L269.9,50.2l-39.5,0v0c-14.1,0.1-24.6,10.7-24.6,24.8c0,13.9,10.4,24.4,24.3,24.7v0h39.6c14.2,0,24.8-10.6,24.8-24.7C294.5,61,284,50.3,269.9,50.2 M269.7,89.2L269.7,89.2l-39.3,0c-7.7-0.1-14-6.4-14-14.2c0-7.8,6.4-14.2,14.2-14.2h39.1c7.8,0,14.2,6.4,14.2,14.2C283.9,82.9,277.5,89.2,269.7,89.2"));
this.logos.push(svg.path(this.head, "sim-theme sim-theme-glow", "M230.6,69.7c-2.9,0-5.3,2.4-5.3,5.3c0,2.9,2.4,5.3,5.3,5.3c2.9,0,5.3-2.4,5.3-5.3C235.9,72.1,233.5,69.7,230.6,69.7"));
this.logos.push(svg.path(this.head, "sim-theme sim-theme-glow", "M269.7,80.3c2.9,0,5.3-2.4,5.3-5.3c0-2.9-2.4-5.3-5.3-5.3c-2.9,0-5.3,2.4-5.3,5.3C264.4,77.9,266.8,80.3,269.7,80.3"));
this.headText = <SVGTextElement>svg.child(this.g, "text", { x: 310, y: 100, class: "sim-text" })
// https://www.microbit.co.uk/device/pins