don't filter or throttle serial, let the user deal with it.

This commit is contained in:
Peli de Halleux 2016-04-22 13:12:43 -07:00
parent 9e073aee36
commit e746c13212

View File

@ -8,10 +8,6 @@ namespace led {
let barGraphHigh = 0; let barGraphHigh = 0;
// when was the current high value recorded // when was the current high value recorded
let barGraphHighLast = 0; let barGraphHighLast = 0;
// last time serial was written
let barGraphLastSerialMessage = 0;
// last filtered value
let barGraphFilteredValue = 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.
@ -22,13 +18,9 @@ namespace led {
//% help=/led/plot-bar-graph weight=20 //% 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 //% 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 {
value = Math.abs(value);
barGraphFilteredValue = (barGraphFilteredValue * 3 + value * 7) / 10;
let now = input.runningTime(); let now = input.runningTime();
if (now - barGraphLastSerialMessage > 100) { serial.writeString(value.toString() + "\r\n");
serial.writeString(barGraphFilteredValue.toString() + "\r\n"); value = Math.abs(value);
barGraphLastSerialMessage = now;
}
if (high != 0) barGraphHigh = high; if (high != 0) barGraphHigh = high;
else if (value > barGraphHigh || now - barGraphHighLast > 5000) { else if (value > barGraphHigh || now - barGraphHighLast > 5000) {