![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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@31:9c535a708ae9, 2017-01-23 (annotated)
- Committer:
- Matt Briggs
- Date:
- Mon Jan 23 09:02:45 2017 -0700
- Revision:
- 31:9c535a708ae9
- Child:
- 33:c7bb3fbc024a
Adding code for analog ladder
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 | 31:9c535a708ae9 | 9 | #ifndef XDOTBRIDGE_INC_NBITANALOGLADDER_H_ |
Matt Briggs | 31:9c535a708ae9 | 10 | #define XDOTBRIDGE_INC_NBITANALOGLADDER_H_ |
Matt Briggs | 31:9c535a708ae9 | 11 | |
Matt Briggs | 31:9c535a708ae9 | 12 | const uint8_t TABLE_MIN_IDX = 0; |
Matt Briggs | 31:9c535a708ae9 | 13 | const uint8_t TABLE_MAX_IDX = 1; |
Matt Briggs | 31:9c535a708ae9 | 14 | const float NOM_VCC = 3.3; // Used so table values can be in voltage not relative values |
Matt Briggs | 31:9c535a708ae9 | 15 | |
Matt Briggs | 31:9c535a708ae9 | 16 | // Use voltage values in numerator |
Matt Briggs | 31:9c535a708ae9 | 17 | const float tenValueTable [][2] = { |
Matt Briggs | 31:9c535a708ae9 | 18 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 0 |
Matt Briggs | 31:9c535a708ae9 | 19 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 1 |
Matt Briggs | 31:9c535a708ae9 | 20 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 2 |
Matt Briggs | 31:9c535a708ae9 | 21 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 3 |
Matt Briggs | 31:9c535a708ae9 | 22 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 4 |
Matt Briggs | 31:9c535a708ae9 | 23 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 5 |
Matt Briggs | 31:9c535a708ae9 | 24 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 6 |
Matt Briggs | 31:9c535a708ae9 | 25 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 7 |
Matt Briggs | 31:9c535a708ae9 | 26 | {0.0/NOM_VCC, 0.1/NOM_VCC}, // 8 |
Matt Briggs | 31:9c535a708ae9 | 27 | {0.0/NOM_VCC, 0.1/NOM_VCC} // 9 |
Matt Briggs | 31:9c535a708ae9 | 28 | }; |
Matt Briggs | 31:9c535a708ae9 | 29 | |
Matt Briggs | 31:9c535a708ae9 | 30 | uint8_t convAnalogLadder (const float &analogV, const float *valueTable, uint8_t nVals); |
Matt Briggs | 31:9c535a708ae9 | 31 | |
Matt Briggs | 31:9c535a708ae9 | 32 | #endif /* XDOTBRIDGE_INC_NBITANALOGLADDER_H_ */ |