
Code for Browonout Generator box
Diff: main.cpp
- Revision:
- 1:8cad7e957324
- Parent:
- 0:9dd5634b94f3
- Child:
- 2:018630ec52d1
--- a/main.cpp Thu Feb 06 17:49:34 2020 +0000 +++ b/main.cpp Fri Feb 07 12:28:58 2020 +0000 @@ -125,6 +125,7 @@ LocalFileSystem fs("local"); bool flg_start = 0; +bool flg_END = false; long double configData[3]; string strData[3]; @@ -228,7 +229,7 @@ Get_Config_data(); } -void cycle() +void cycle_loop() { while(1) { run_Cycle(); @@ -247,26 +248,35 @@ c = pc.getc(); pc.putc(c); if (c == '\n') { - if (str == "on") { + if (str == "on\r") { do21 = 1; - printf("on\r\n"); - } else if (str == "off") { + led1 = 1; + pc.printf("power on\r\n"); + + } else if (str == "off\r") { do21 = 0; - printf("off\r\n"); - } else if (str == "cycle") { + led1 = 0; + pc.printf("power off\r\n"); + + } else if (str == "cycle\r") { run_Cycle(); - printf("cycled\r\n"); - } else if(str == "cycle2") { - cycle(); + pc.printf("cycled\r\n"); + + } else if(str == "cycle2\r") { + pc.printf("clycle loop, power cycle box to stop\r\n"); + cycle_loop(); + + } else if( str == "exit\r") { + flg_read = false; } else { - str = ""; - flg_read = false; + pc.printf("unknown command, see README for command list\r\n"); } - + str = ""; } else { str.push_back(c); } } + pc.printf("exit serial mode \r\n"); } @@ -276,23 +286,23 @@ printf("STARTING\r\n"); init(); printf("Strings: On: %s, repeat: %s, Off: %s \r\n", strData[0].c_str(),strData[1].c_str(), strData[2].c_str() ); - printf("Data: %Lf, %Lf, %Lf\r\n",configData[0],configData[1],configData[2]); -// Mode = (int)configData[1]; -// if(Mode == 0) { -// run_Cycle(); -// } else if(Mode == 1) { -// cycle(); -// } else if(Mode == 2) { -// serial_mode(); -// } else { -// printf("Invalid Mode"); -// } + printf("Data: %Lf, %Lf, %Lf\r\n",configData[0],configData[1],configData[2]); - while((int)configData[1] != 0) { - run_Cycle(); - thread_sleep_for(configData[2]); + while(!flg_END) { + Mode = (int)configData[1]; + if(Mode == 0) { + run_Cycle(); + } else if(Mode == 1) { + cycle_loop(); + } else if(Mode == 2) { + serial_mode(); + Get_Config_data(); + printf("Data: %Lf, %Lf, %Lf\r\n",configData[0],configData[1],configData[2]); + + } else { + printf("Invalid Mode"); + } } - run_Cycle(); printf("END \r\n"); return 0;