Skip to content

Latest commit

 

History

History

adc

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Table

Source table

x 0 6,8 7,2 7,5 8
y 0 1 5 17 22

Supported input format

json

[[0, 0], [6.8, 1], [7.2, 5], [7.5, 17], [8, 22]]

csv

0,0; 6.8,1; 7.2,5; 7.5,17; 8,22

Piecewise linear approximation

import { piecewise } from "https://raw.githubusercontent.com/rightech/handler-libs/1.0.6/adc/table.js";

/**
 * @param {number} adc1 adc value from object packet
 * @param {string} table1 adc table from object config
 */
export function process(adc1, table1) {
  const value1 = piecewise(table1)(adc1);

  return { value1 };
}

/**
 * @test adc1 3.14
 * @test table1 "[[0, 0], [6.8, 1], [7.2, 5]]"
 */