Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
56713227c5 | |||
fd6e110790 | |||
2336521df1 | |||
2ce72aeb28 | |||
e746c13212 | |||
9e073aee36 | |||
3906f06a2f | |||
d89747fa46 | |||
c4e6618baa | |||
5232be58ce | |||
5a75483811 | |||
4b40585690 | |||
dd65efaab6 | |||
890c2566af | |||
cd71fc5d13 |
@ -4,18 +4,33 @@
|
||||
//% color=3 weight=35
|
||||
namespace led {
|
||||
|
||||
// what's the current high value
|
||||
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.
|
||||
* Displays a vertical bar graph based on the `value` and `high` value.
|
||||
* If `high` is 0, the chart gets adjusted automatically.
|
||||
* @param value current value to plot
|
||||
* @param high maximum value, eg: 1023, 255
|
||||
* @param high maximum value. If 0, maximum value adjusted automatically, eg: 0
|
||||
*/
|
||||
//% 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);
|
||||
|
||||
let v = Math.abs((value * 15) / high);
|
||||
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 x = 0; x < 3; ++x) {
|
||||
|
@ -7,7 +7,7 @@ namespace serial {
|
||||
* Prints a line of text to the serial
|
||||
* @param value to send over serial
|
||||
*/
|
||||
//% help=/serial/write-line
|
||||
//% help=serial/write-line
|
||||
//% blockId=serial_writeline block="serial|write %text"
|
||||
export function writeLine(text: string): void {
|
||||
writeString(text);
|
||||
@ -27,7 +27,7 @@ namespace serial {
|
||||
* @param value to write
|
||||
*/
|
||||
//% weight=80
|
||||
//% help=/serial/write-value
|
||||
//% help=serial/write-value
|
||||
//% blockId=serial_writevalue block="serial|write %name|= %value"
|
||||
export function writeValue(name: string, value: number): void {
|
||||
writeString(name);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.2.81",
|
||||
"version": "0.2.87",
|
||||
"description": "BBC micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -29,6 +29,6 @@
|
||||
"typescript": "^1.8.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.2.88"
|
||||
"pxt-core": "0.2.95"
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,9 @@
|
||||
"hasHex": true,
|
||||
"deployDrives": "^MICROBIT"
|
||||
},
|
||||
"runtime": {
|
||||
"mathBlocks": true
|
||||
},
|
||||
"simulator": {
|
||||
"autoRun": true
|
||||
},
|
||||
|
@ -219,7 +219,7 @@ namespace pxsim.micro_bit {
|
||||
rx:5, ry:5,
|
||||
fill:`url(#${gid})`
|
||||
});
|
||||
this.thermometerText = Svg.child(this.g, "text", { class:'sim-text', x:60, y:130}) as SVGTextElement;
|
||||
this.thermometerText = Svg.child(this.g, "text", { class:'sim-text', x:58, y:130}) as SVGTextElement;
|
||||
this.updateTheme();
|
||||
|
||||
let pt = this.element.createSVGPoint();
|
||||
|
Reference in New Issue
Block a user