![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Diff: Config/Config.h
- Revision:
- 36:3095e00eef37
- Parent:
- 9:fc3575d2cbbf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Config/Config.h Tue Jan 01 17:44:27 2019 +0000 @@ -0,0 +1,41 @@ +#ifndef __CONFIG_H +#define __CONFIG_H + +#include "mbed.h" + +#define MAXSTR 30 +#define MAXTBL 30 + +union Value { + double d; + int i; +}; + +typedef struct { + char key[MAXSTR]; + char format; + Value value; +} ConfigEntry; + +class Config { +public: + enum{INT, DOUBLE} format; + Config(); + int load(char *filename); + int assign(char *key, char *value); + void add(char *key, char format); + void attach(Callback<void(char *)>, char *key, char format); + int get(char *key, double *value); + int get(char *key, int *value); + template<typename T> + T retrieve(char *key); + +private: + static const int MAXBUF=128; + char buf[MAXBUF]; + ConfigEntry table[MAXTBL]; + int itable; + int lookup(char *key); +}; + +#endif \ No newline at end of file