Skip to content

Commit

Permalink
Updated documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
suoapvs committed Jan 30, 2019
1 parent 7f6c13e commit f212175
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,82 +76,82 @@ boolean value = sensor->isHigh();
boolean value = sensor->isLow();
```

### [Map Sensor](/src/MapSensor.h)
### [Average Sensor](/src/AverageSensor.h)

Reads a signal from a origin sensor, maps the signal and return it.
Re-maps the signal from one range to another.
That is, a signal of fromLow would get mapped to toLow,
a signal of fromHigh to toHigh, signals in-between to signals in-between, etc.
Reads a signal from a origin sensor,
averages the signal and return it.

```cpp
#include <Sensor.h>
#include <AnalogSensor.h>
#include <MapSensor.h>
#include <AverageSensor.h>

Sensor* origin = new AnalogSensor(ANALOG_PIN);

/**
FROM_LOW - the lower bound of the value’s current range;
FROM_HIGH - the upper bound of the value’s current range;
TO_LOW - the lower bound of the value’s target range;
TO_HIGH - the upper bound of the value’s target range.
COUNTER - number of readings;
DELAY_TIME - delay time between readings.
*/
Sensor* sensor = new MapSensor(
origin,
FROM_LOW, FROM_HIGH,
TO_LOW, TO_HIGH
);
Sensor* sensor = new AverageSensor(origin, COUNTER, DELAY_TIME);

/**
Returns the mapped signal value.
Returns the average signal value.
*/
int value = sensor->read();
```

### [Average Sensor](/src/AverageSensor.h)
### [Smooth Sensor](/src/SmoothSensor.h)

Reads a signal from a origin sensor,
averages the signal and return it.
smoothes (moving average, rolling average or running average)
the signal and return it.

```cpp
#include <Sensor.h>
#include <AnalogSensor.h>
#include <AverageSensor.h>
#include <SmoothSensor.h>

Sensor* origin = new AnalogSensor(ANALOG_PIN);

/**
COUNTER - number of readings;
DELAY_TIME - delay time between readings.
SMOOTHING_FACTOR - smoothing factor of readings (0 = not smooth).
*/
Sensor* sensor = new AverageSensor(origin, COUNTER, DELAY_TIME);
Sensor* sensor = new SmoothSensor(origin, SMOOTHING_FACTOR);

/**
Returns the average signal value.
Return the average signal value.
*/
int value = sensor->read();
```

### [SmoothSensor](/src/SmoothSensor.h)
### [Map Sensor](/src/MapSensor.h)

Reads a signal from a origin sensor,
smoothes (moving average, rolling average or running average)
the signal and return it.
Reads a signal from a origin sensor, maps the signal and return it.
Re-maps the signal from one range to another.
That is, a signal of fromLow would get mapped to toLow,
a signal of fromHigh to toHigh, signals in-between to signals in-between, etc.

```cpp
#include <Sensor.h>
#include <AnalogSensor.h>
#include <SmoothSensor.h>
#include <MapSensor.h>

Sensor* origin = new AnalogSensor(ANALOG_PIN);

/**
SMOOTHING_FACTOR - smoothing factor of readings (0 = not smooth).
FROM_LOW - the lower bound of the value’s current range;
FROM_HIGH - the upper bound of the value’s current range;
TO_LOW - the lower bound of the value’s target range;
TO_HIGH - the upper bound of the value’s target range.
*/
Sensor* sensor = new SmoothSensor(origin, SMOOTHING_FACTOR);
Sensor* sensor = new MapSensor(
origin,
FROM_LOW, FROM_HIGH,
TO_LOW, TO_HIGH
);

/**
Return the average signal value.
Returns the mapped signal value.
*/
int value = sensor->read();
```
Expand Down

0 comments on commit f212175

Please sign in to comment.