This program is for "LEDCUBE4mbed". You can change the mode for changing the value of "debug".

Dependencies:   ConfigFile FatFileSystem SDFileSystem mbed

Committer:
ds074704261
Date:
Thu Aug 09 08:24:07 2012 +0000
Revision:
0:bedae49a4612
Child:
1:0991aefbe7be
Printf

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ds074704261 0:bedae49a4612 1 #include "mbed.h"
ds074704261 0:bedae49a4612 2 #include "ConfigFile.h"
ds074704261 0:bedae49a4612 3 //#include "SDFileSystem.h"
ds074704261 0:bedae49a4612 4
ds074704261 0:bedae49a4612 5 ConfigFile cfg;
ds074704261 0:bedae49a4612 6 LocalFileSystem local("local");
ds074704261 0:bedae49a4612 7
ds074704261 0:bedae49a4612 8 /*
ds074704261 0:bedae49a4612 9 * ==================================================
ds074704261 0:bedae49a4612 10 * Definition of "LINE"
ds074704261 0:bedae49a4612 11 * ==================================================
ds074704261 0:bedae49a4612 12 *
ds074704261 0:bedae49a4612 13 * C1 C2 C3 C4 C5
ds074704261 0:bedae49a4612 14 * --------------------
ds074704261 0:bedae49a4612 15 * L1 L2 L3 L4 L5
ds074704261 0:bedae49a4612 16 * L6 L7 L8 L9 L10
ds074704261 0:bedae49a4612 17 * L11 L12 L13 L14 L15
ds074704261 0:bedae49a4612 18 * L16 L17 L18 L19 L20
ds074704261 0:bedae49a4612 19 * L21 L22 L23 L24 L25
ds074704261 0:bedae49a4612 20 *
ds074704261 0:bedae49a4612 21 * ==================================================
ds074704261 0:bedae49a4612 22 */
ds074704261 0:bedae49a4612 23
ds074704261 0:bedae49a4612 24 BusOut leds(LED1, LED2, LED3, LED4);
ds074704261 0:bedae49a4612 25 DigitalOut C1(p25); //line1 to line5
ds074704261 0:bedae49a4612 26 DigitalOut C2(p24); //line6 to line10
ds074704261 0:bedae49a4612 27 DigitalOut C3(p23); //line11 to line15
ds074704261 0:bedae49a4612 28 DigitalOut C4(p22); //line16 to line20
ds074704261 0:bedae49a4612 29 DigitalOut C5(p21); //line21 to line25
ds074704261 0:bedae49a4612 30 DigitalOut Call[] = {p25, p24, p23, p22, p21};
ds074704261 0:bedae49a4612 31 DigitalOut mclock(p5); //mainclock
ds074704261 0:bedae49a4612 32 DigitalOut sclock(p6); //subclock
ds074704261 0:bedae49a4612 33
ds074704261 0:bedae49a4612 34 /* ==================================================
ds074704261 0:bedae49a4612 35 * Not implemented
ds074704261 0:bedae49a4612 36 * ==================================================
ds074704261 0:bedae49a4612 37 */
ds074704261 0:bedae49a4612 38 //AnalogIn volume(p20);
ds074704261 0:bedae49a4612 39 /*
ds074704261 0:bedae49a4612 40 // MicroSD Ssytem
ds074704261 0:bedae49a4612 41 #include "SDFileSystem.h"
ds074704261 0:bedae49a4612 42 #define SD_MOSI p5
ds074704261 0:bedae49a4612 43 #define SD_MISO p6
ds074704261 0:bedae49a4612 44 #define SD_SCLK p7
ds074704261 0:bedae49a4612 45 #define SD_CS p8
ds074704261 0:bedae49a4612 46
ds074704261 0:bedae49a4612 47 //SDFileSystem sd(p5, p6, p7, p13, "sd"); // mosi, miso, sclk, cs, name
ds074704261 0:bedae49a4612 48 SDFileSystem sd(SD_MOSI, SD_MISO, SD_SCLK, SD_CS, "sd"); // mosi, miso, sclk, cs, name (HW modification candidate)
ds074704261 0:bedae49a4612 49 */
ds074704261 0:bedae49a4612 50
ds074704261 0:bedae49a4612 51 void resetColumn() {
ds074704261 0:bedae49a4612 52
ds074704261 0:bedae49a4612 53 }
ds074704261 0:bedae49a4612 54
ds074704261 0:bedae49a4612 55 int main() {
ds074704261 0:bedae49a4612 56
ds074704261 0:bedae49a4612 57 //error
ds074704261 0:bedae49a4612 58 if (!cfg.read("/local/pattern.cfg")) {
ds074704261 0:bedae49a4612 59 printf("Failure to read a configuration file.\n");
ds074704261 0:bedae49a4612 60 while(1){
ds074704261 0:bedae49a4612 61 leds = 15;
ds074704261 0:bedae49a4612 62 wait(0.1);
ds074704261 0:bedae49a4612 63 leds = 0;
ds074704261 0:bedae49a4612 64 wait(0.1);
ds074704261 0:bedae49a4612 65 }
ds074704261 0:bedae49a4612 66 }
ds074704261 0:bedae49a4612 67
ds074704261 0:bedae49a4612 68 //read file
ds074704261 0:bedae49a4612 69 printf("reading file...\n");
ds074704261 0:bedae49a4612 70 cfg.read("/local/pattern.cfg");
ds074704261 0:bedae49a4612 71
ds074704261 0:bedae49a4612 72 const int cnt = cfg.getCount();
ds074704261 0:bedae49a4612 73 char buf_key[BUFSIZ];
ds074704261 0:bedae49a4612 74 char buf_value[BUFSIZ];
ds074704261 0:bedae49a4612 75
ds074704261 0:bedae49a4612 76 int n;
ds074704261 0:bedae49a4612 77 long sin2;
ds074704261 0:bedae49a4612 78
ds074704261 0:bedae49a4612 79
ds074704261 0:bedae49a4612 80 for (int i = 0; i < cnt; i++) {
ds074704261 0:bedae49a4612 81 if (cfg.getKeyAndValue(i, buf_key, sizeof(buf_key), buf_value, sizeof(buf_value))) {
ds074704261 0:bedae49a4612 82 //printf("No.%3d:'%s'='%s'\n", i, buf_key, buf_value);
ds074704261 0:bedae49a4612 83
ds074704261 0:bedae49a4612 84 sin2 = strtol(buf_value, NULL, 2);
ds074704261 0:bedae49a4612 85 printf("%d = %d\n", i+1, sin2);
ds074704261 0:bedae49a4612 86
ds074704261 0:bedae49a4612 87 } else {
ds074704261 0:bedae49a4612 88 printf("No.%3d:Failure to get a configuration.\n", i);
ds074704261 0:bedae49a4612 89 }
ds074704261 0:bedae49a4612 90 }
ds074704261 0:bedae49a4612 91 }