don't filter or throttle serial, let the user deal with it.
This commit is contained in:
		@@ -8,10 +8,6 @@ namespace led {
 | 
			
		||||
    let barGraphHigh = 0;
 | 
			
		||||
    // when was the current high value recorded
 | 
			
		||||
    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.
 | 
			
		||||
@@ -22,13 +18,9 @@ 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 {        
 | 
			
		||||
        value = Math.abs(value);
 | 
			
		||||
        barGraphFilteredValue = (barGraphFilteredValue * 3 + value * 7) / 10;
 | 
			
		||||
        let now = input.runningTime();
 | 
			
		||||
        if (now - barGraphLastSerialMessage > 100) {
 | 
			
		||||
            serial.writeString(barGraphFilteredValue.toString() + "\r\n");
 | 
			
		||||
            barGraphLastSerialMessage = now;
 | 
			
		||||
        }
 | 
			
		||||
        serial.writeString(value.toString() + "\r\n");
 | 
			
		||||
        value = Math.abs(value);
 | 
			
		||||
        
 | 
			
		||||
        if (high != 0) barGraphHigh = high;
 | 
			
		||||
        else if (value > barGraphHigh || now - barGraphHighLast > 5000) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user