2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Config/Config.h@36:3095e00eef37, 2019-01-01 (annotated)
- Committer:
- shimniok
- Date:
- Tue Jan 01 17:44:27 2019 +0000
- Revision:
- 36:3095e00eef37
- Parent:
- Config.h@9:fc3575d2cbbf
File reorganization
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 1:7019a60fd585 | 1 | #ifndef __CONFIG_H |
shimniok | 1:7019a60fd585 | 2 | #define __CONFIG_H |
shimniok | 1:7019a60fd585 | 3 | |
shimniok | 3:4ffb1f9ba166 | 4 | #include "mbed.h" |
shimniok | 3:4ffb1f9ba166 | 5 | |
shimniok | 8:ba70bb062aa0 | 6 | #define MAXSTR 30 |
shimniok | 7:1f2661b840ed | 7 | #define MAXTBL 30 |
shimniok | 6:83a6666a62d7 | 8 | |
shimniok | 7:1f2661b840ed | 9 | union Value { |
shimniok | 7:1f2661b840ed | 10 | double d; |
shimniok | 7:1f2661b840ed | 11 | int i; |
shimniok | 7:1f2661b840ed | 12 | }; |
shimniok | 7:1f2661b840ed | 13 | |
shimniok | 6:83a6666a62d7 | 14 | typedef struct { |
shimniok | 6:83a6666a62d7 | 15 | char key[MAXSTR]; |
shimniok | 6:83a6666a62d7 | 16 | char format; |
shimniok | 7:1f2661b840ed | 17 | Value value; |
shimniok | 6:83a6666a62d7 | 18 | } ConfigEntry; |
shimniok | 6:83a6666a62d7 | 19 | |
shimniok | 1:7019a60fd585 | 20 | class Config { |
shimniok | 1:7019a60fd585 | 21 | public: |
shimniok | 7:1f2661b840ed | 22 | enum{INT, DOUBLE} format; |
shimniok | 7:1f2661b840ed | 23 | Config(); |
shimniok | 1:7019a60fd585 | 24 | int load(char *filename); |
shimniok | 7:1f2661b840ed | 25 | int assign(char *key, char *value); |
shimniok | 7:1f2661b840ed | 26 | void add(char *key, char format); |
shimniok | 6:83a6666a62d7 | 27 | void attach(Callback<void(char *)>, char *key, char format); |
shimniok | 9:fc3575d2cbbf | 28 | int get(char *key, double *value); |
shimniok | 9:fc3575d2cbbf | 29 | int get(char *key, int *value); |
shimniok | 9:fc3575d2cbbf | 30 | template<typename T> |
shimniok | 9:fc3575d2cbbf | 31 | T retrieve(char *key); |
shimniok | 4:de7feb458652 | 32 | |
shimniok | 4:de7feb458652 | 33 | private: |
shimniok | 4:de7feb458652 | 34 | static const int MAXBUF=128; |
shimniok | 4:de7feb458652 | 35 | char buf[MAXBUF]; |
shimniok | 7:1f2661b840ed | 36 | ConfigEntry table[MAXTBL]; |
shimniok | 7:1f2661b840ed | 37 | int itable; |
shimniok | 6:83a6666a62d7 | 38 | int lookup(char *key); |
shimniok | 4:de7feb458652 | 39 | }; |
shimniok | 1:7019a60fd585 | 40 | |
shimniok | 1:7019a60fd585 | 41 | #endif |