C++ file for display control
Dependencies: 4DGL mbed ConfigFile
Fork of 4DGLtest by
configread.cpp@4:302c2ac97db9, 2014-06-27 (annotated)
- Committer:
- WillemBraat
- Date:
- Fri Jun 27 12:59:51 2014 +0000
- Revision:
- 4:302c2ac97db9
- Child:
- 6:904d00252480
Added Config Read/Write for storing system parameters
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
WillemBraat | 4:302c2ac97db9 | 1 | #include "mbed.h" |
WillemBraat | 4:302c2ac97db9 | 2 | #include "ConfigFile.h" |
WillemBraat | 4:302c2ac97db9 | 3 | |
WillemBraat | 4:302c2ac97db9 | 4 | |
WillemBraat | 4:302c2ac97db9 | 5 | |
WillemBraat | 4:302c2ac97db9 | 6 | void ConfigRead(void) { |
WillemBraat | 4:302c2ac97db9 | 7 | LocalFileSystem local("local"); |
WillemBraat | 4:302c2ac97db9 | 8 | ConfigFile cfg; |
WillemBraat | 4:302c2ac97db9 | 9 | char *key = "MyKey"; |
WillemBraat | 4:302c2ac97db9 | 10 | char value[BUFSIZ]; |
WillemBraat | 4:302c2ac97db9 | 11 | /* |
WillemBraat | 4:302c2ac97db9 | 12 | * Read a configuration file from a mbed. |
WillemBraat | 4:302c2ac97db9 | 13 | */ |
WillemBraat | 4:302c2ac97db9 | 14 | if (!cfg.read("/local/input.cfg")) { |
WillemBraat | 4:302c2ac97db9 | 15 | error("Failure to read a configuration file.\n"); |
WillemBraat | 4:302c2ac97db9 | 16 | } |
WillemBraat | 4:302c2ac97db9 | 17 | |
WillemBraat | 4:302c2ac97db9 | 18 | /* |
WillemBraat | 4:302c2ac97db9 | 19 | * Get a configuration value. |
WillemBraat | 4:302c2ac97db9 | 20 | */ |
WillemBraat | 4:302c2ac97db9 | 21 | if (cfg.getValue(key, &value[0], sizeof(value))) { |
WillemBraat | 4:302c2ac97db9 | 22 | printf("'%s'='%s'\n", key, value); |
WillemBraat | 4:302c2ac97db9 | 23 | } |
WillemBraat | 4:302c2ac97db9 | 24 | } |
WillemBraat | 4:302c2ac97db9 | 25 |