Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
xDotBridge/inc/nBitAnalogLadder.h@100:0882cf295f8e, 2017-11-29 (annotated)
- Committer:
- mbriggs_vortex
- Date:
- Wed Nov 29 13:54:36 2017 -0700
- Revision:
- 100:0882cf295f8e
- Parent:
- 33:c7bb3fbc024a
Adding relaese bin to repo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Matt Briggs | 31:9c535a708ae9 | 1 | /* |
Matt Briggs | 31:9c535a708ae9 | 2 | * nBitAnalogLadder.h |
Matt Briggs | 31:9c535a708ae9 | 3 | * |
Matt Briggs | 31:9c535a708ae9 | 4 | * This library converts analog voltage to to a bit value. This is a table based implementation |
Matt Briggs | 31:9c535a708ae9 | 5 | * so the thresholds are hard-coded and can be adjusted. |
Matt Briggs | 31:9c535a708ae9 | 6 | * |
Matt Briggs | 31:9c535a708ae9 | 7 | */ |
Matt Briggs | 31:9c535a708ae9 | 8 | |
Matt Briggs | 33:c7bb3fbc024a | 9 | #include <stdint.h> |
Matt Briggs | 33:c7bb3fbc024a | 10 | |
Matt Briggs | 31:9c535a708ae9 | 11 | #ifndef XDOTBRIDGE_INC_NBITANALOGLADDER_H_ |
Matt Briggs | 31:9c535a708ae9 | 12 | #define XDOTBRIDGE_INC_NBITANALOGLADDER_H_ |
Matt Briggs | 31:9c535a708ae9 | 13 | |
Matt Briggs | 31:9c535a708ae9 | 14 | const uint8_t TABLE_MIN_IDX = 0; |
Matt Briggs | 31:9c535a708ae9 | 15 | const uint8_t TABLE_MAX_IDX = 1; |
Matt Briggs | 31:9c535a708ae9 | 16 | const float NOM_VCC = 3.3; // Used so table values can be in voltage not relative values |
Matt Briggs | 31:9c535a708ae9 | 17 | |
Matt Briggs | 31:9c535a708ae9 | 18 | // Use voltage values in numerator |
Matt Briggs | 31:9c535a708ae9 | 19 | const float tenValueTable [][2] = { |
Matt Briggs | 31:9c535a708ae9 | 20 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 0 |
Matt Briggs | 31:9c535a708ae9 | 21 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 1 |
Matt Briggs | 31:9c535a708ae9 | 22 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 2 |
Matt Briggs | 31:9c535a708ae9 | 23 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 3 |
Matt Briggs | 31:9c535a708ae9 | 24 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 4 |
Matt Briggs | 31:9c535a708ae9 | 25 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 5 |
Matt Briggs | 31:9c535a708ae9 | 26 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 6 |
Matt Briggs | 31:9c535a708ae9 | 27 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 7 |
Matt Briggs | 31:9c535a708ae9 | 28 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 8 |
Matt Briggs | 31:9c535a708ae9 | 29 | {0.0/NOM_VCC, 0.1/NOM_VCC} // 9 |
Matt Briggs | 31:9c535a708ae9 | 30 | }; |
Matt Briggs | 31:9c535a708ae9 | 31 | |
Matt Briggs | 33:c7bb3fbc024a | 32 | uint8_t convAnalogLadder (const float &analogV, const float valueTable[][2], uint8_t nVals); |
Matt Briggs | 31:9c535a708ae9 | 33 | |
Matt Briggs | 31:9c535a708ae9 | 34 | #endif /* XDOTBRIDGE_INC_NBITANALOGLADDER_H_ */ |