2018 revision to classic DataBus AVC code.

Dependencies:   LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell

Committer:
shimniok
Date:
Wed Dec 05 17:53:06 2018 +0000
Revision:
7:1f2661b840ed
Parent:
6:83a6666a62d7
Child:
8:ba70bb062aa0
Implemented keyword add and value assignment to Config. Testing keywords in main.

Who changed what in which revision?

UserRevisionLine numberNew 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 6:83a6666a62d7 6 #define MAXSTR 10
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 4:de7feb458652 28
shimniok 4:de7feb458652 29 private:
shimniok 4:de7feb458652 30 static const int MAXBUF=128;
shimniok 4:de7feb458652 31 char buf[MAXBUF];
shimniok 7:1f2661b840ed 32 ConfigEntry table[MAXTBL];
shimniok 7:1f2661b840ed 33 int itable;
shimniok 6:83a6666a62d7 34 int lookup(char *key);
shimniok 4:de7feb458652 35 };
shimniok 1:7019a60fd585 36
shimniok 1:7019a60fd585 37 #endif