Skip to content
Jim Lee edited this page Mar 19, 2020 · 18 revisions

Abstract:

A very common issue one runs across when programming is unit translation and value limiting. You are given some value that covers an arbitrary range and you need to "map" this value to a unit that you are looking for. And, at the same time, limit the range of the inputted data to "sane" values.

That was really wordy, lets try an example. You would like to make a digital volt meter. You have an analog input that gives values from 0 to say.. 1024. Next you need to find what the limits are of your circuit. What's your lowest voltage? What number do you read from the analog input at this low voltage? What's your highest voltage? What number do you read from the analog input at this high voltage? This gives us 4 values.

Low voltage - corresponding analog value analogA.
High voltage - corresponding analog value, analogB.

From this we plug all four into a mapper object mapper myMapper(analogA, analogB,lowVoltage,highVoltage); Now that we have our mapper we can read analog values, put it in our mapper object and read off actual calculated voltages.

linkListObj:

Constructor:

mapper(void);
No parameters, creates a mapper...

Other methods:

`

Clone this wiki locally