Practical Robotics Modular Robot Library
sensors.h@6:732aa91eb555, 2017-01-13 (annotated)
- Committer:
- jah128
- Date:
- Fri Jan 13 23:16:23 2017 +0000
- Revision:
- 6:732aa91eb555
- Parent:
- 1:a6728adaf7e7
Updated;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jah128 | 0:8a2dd255c508 | 1 | #ifndef SENSORS_H |
jah128 | 0:8a2dd255c508 | 2 | #define SENSORS_H |
jah128 | 0:8a2dd255c508 | 3 | |
jah128 | 1:a6728adaf7e7 | 4 | /** |
jah128 | 1:a6728adaf7e7 | 5 | * The Sensors class contains the functions to read from the robots sensors |
jah128 | 1:a6728adaf7e7 | 6 | */ |
jah128 | 0:8a2dd255c508 | 7 | class Sensors |
jah128 | 0:8a2dd255c508 | 8 | { |
jah128 | 0:8a2dd255c508 | 9 | public: |
jah128 | 0:8a2dd255c508 | 10 | |
jah128 | 0:8a2dd255c508 | 11 | |
jah128 | 0:8a2dd255c508 | 12 | /** |
jah128 | 0:8a2dd255c508 | 13 | * Reads and stores a value from the ADS7830 i2c ADC used for the Sharp distance sensors |
jah128 | 0:8a2dd255c508 | 14 | * |
jah128 | 0:8a2dd255c508 | 15 | * @param channel - The channel to read from (0 to 7) |
jah128 | 0:8a2dd255c508 | 16 | * @return The 8-bit value returned by the ADC |
jah128 | 0:8a2dd255c508 | 17 | */ |
jah128 | 0:8a2dd255c508 | 18 | char read_adc_value(char channel); |
jah128 | 0:8a2dd255c508 | 19 | |
jah128 | 0:8a2dd255c508 | 20 | /** |
jah128 | 0:8a2dd255c508 | 21 | * Returns the stored value from the last call of read_adc_value |
jah128 | 0:8a2dd255c508 | 22 | * |
jah128 | 0:8a2dd255c508 | 23 | * @param channel - The channel to read from (0 to 7) |
jah128 | 0:8a2dd255c508 | 24 | * @return The stored 8-bit value |
jah128 | 0:8a2dd255c508 | 25 | */ |
jah128 | 0:8a2dd255c508 | 26 | char get_adc_value(char channel); |
jah128 | 0:8a2dd255c508 | 27 | |
jah128 | 0:8a2dd255c508 | 28 | /** |
jah128 | 0:8a2dd255c508 | 29 | * Starts a ticker which reads and stores the value for each distance sensor at a |
jah128 | 0:8a2dd255c508 | 30 | * frequency defined by SENSOR_TICKER_PERIOD (eg 10Hz) |
jah128 | 0:8a2dd255c508 | 31 | */ |
jah128 | 0:8a2dd255c508 | 32 | void start_sensor_ticker(void); |
jah128 | 0:8a2dd255c508 | 33 | |
jah128 | 0:8a2dd255c508 | 34 | /** |
jah128 | 0:8a2dd255c508 | 35 | * Reads the next sensor |
jah128 | 0:8a2dd255c508 | 36 | */ |
jah128 | 0:8a2dd255c508 | 37 | void sensor_ticker_routine(void); |
jah128 | 0:8a2dd255c508 | 38 | }; |
jah128 | 0:8a2dd255c508 | 39 | |
jah128 | 0:8a2dd255c508 | 40 | |
jah128 | 0:8a2dd255c508 | 41 | #endif |