preliminary brownout generator code
Revision 100:dd9492604669, committed 2020-02-04
- Comitter:
- el16ba
- Date:
- Tue Feb 04 17:37:01 2020 +0000
- Parent:
- 99:69dcd2885fbc
- Commit message:
- functioning first draft
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 17 16:21:00 2019 +0000
+++ b/main.cpp Tue Feb 04 17:37:01 2020 +0000
@@ -57,7 +57,7 @@
printf("Get Config data\r\n");
FILE* fp = fopen("/local/config.txt", "r");
int c;
- char stateData = 0;
+ char stateData = 0; //which data it is reading on duration, off duration e.t.c.
char stateRead = 0; //0 = parsing, 1 = reading data
char* pEnd;
string data;
@@ -79,14 +79,28 @@
}
fclose(fp);
+
+ configData[0] = configData[0] /10; //wait functions
+ configData[2] = configData[2] /10;
+
}
+// Runs wait functions and divides by 10 to account for error in function
+// unused as calling function causes too much of a delay when below miliseconds
+void wait_fixed(float t){
+ wait(t / 10);
+}
+
+
//Flips output
void run_Cycle()
{
+ //printf("On \r\n");
do21 = 1;
led1 = 1;
- wait_ms(configData[0]);
+ wait(configData[0]);
+
+ //printf("Off \r\n");
do21 = 0;
led1 = 0;
}
@@ -110,20 +124,16 @@
{
printf("STARTING\r\n");
init();
- printf("Strings: %s, %s, %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]);
+ 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]*10,configData[1],configData[2]*10); //multiplying back to real values
-// Uncomment when external button is implemented to start cycling
-// while(!flg_start){
-// wait_ms(50);
-// }
while((int)configData[1] != 0) {
run_Cycle();
- wait_ms(configData[2]);
+ wait(configData[2]);
}
run_Cycle();
-
+
printf("END \r\n");
return 0;
}
\ No newline at end of file