I messed up the merge, so pushing it over to another repo so I don't lose it. Will tidy up and remove later

Dependencies:   BufferedSerial FatFileSystemCpp mbed

Committer:
AndyA
Date:
Tue Feb 09 16:55:52 2021 +0000
Revision:
6:61274e214f46
Parent:
5:7994913a15fe
Fix FIZ stuff

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AndyA 3:14d241e29be3 1 #ifndef __FIZReader_H__
AndyA 3:14d241e29be3 2 #define __FIZReader_H__
AndyA 3:14d241e29be3 3 #include "BufferedSerial.h"
AndyA 3:14d241e29be3 4
AndyA 5:7994913a15fe 5 #define InBufferSize 32
AndyA 5:7994913a15fe 6
AndyA 3:14d241e29be3 7 class FIZReader {
AndyA 3:14d241e29be3 8
AndyA 3:14d241e29be3 9 public:
AndyA 3:14d241e29be3 10 FIZReader(const PinName Tx, const PinName Rx);
AndyA 3:14d241e29be3 11 void requestCurrent();
AndyA 3:14d241e29be3 12
AndyA 3:14d241e29be3 13 /// true if the values have been updated since the last update.
AndyA 3:14d241e29be3 14 bool getMostRecent(uint32_t *focus, uint16_t *iris, uint16_t *zoom);
AndyA 3:14d241e29be3 15
AndyA 3:14d241e29be3 16 private:
AndyA 3:14d241e29be3 17
AndyA 6:61274e214f46 18 RawSerial _port;
AndyA 3:14d241e29be3 19
AndyA 3:14d241e29be3 20 void OnRx(void);
AndyA 3:14d241e29be3 21 void parsePacket();
AndyA 3:14d241e29be3 22
AndyA 5:7994913a15fe 23 uint8_t inputBuffer[InBufferSize];
AndyA 3:14d241e29be3 24 int inputPtr;
AndyA 3:14d241e29be3 25
AndyA 3:14d241e29be3 26 uint32_t _focus;
AndyA 3:14d241e29be3 27 uint16_t _iris;
AndyA 3:14d241e29be3 28 uint16_t _zoom;
AndyA 3:14d241e29be3 29 bool newData;
AndyA 5:7994913a15fe 30
AndyA 5:7994913a15fe 31 inline int hexValue(char ascii) {
AndyA 5:7994913a15fe 32 if (((ascii-'0') >= 0) && ((ascii-'0') <= 9))
AndyA 5:7994913a15fe 33 return ascii-'0';
AndyA 5:7994913a15fe 34 if (((ascii-'A') >= 0) && ((ascii-'A') <= 5))
AndyA 5:7994913a15fe 35 return ascii-'A'+10;
AndyA 5:7994913a15fe 36 if (((ascii-'a') >= 0) && ((ascii-'a') <= 5))
AndyA 5:7994913a15fe 37 return ascii-'a'+10;
AndyA 5:7994913a15fe 38 return 0;
AndyA 5:7994913a15fe 39 }
AndyA 5:7994913a15fe 40
AndyA 3:14d241e29be3 41 };
AndyA 3:14d241e29be3 42
AndyA 3:14d241e29be3 43 #endif