![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
chad
Dependencies: MCP23017 WattBob_TextLCD mbed-rtos mbed
Diff: main.cpp
- Revision:
- 11:b48ff77c664a
- Parent:
- 10:2414d28be4ba
- Child:
- 12:d088f8024cf0
--- a/main.cpp Tue Mar 07 18:00:41 2017 +0000 +++ b/main.cpp Tue Mar 07 19:07:24 2017 +0000 @@ -11,7 +11,8 @@ #include "mbed.h" #include "MCP23017.h" #include "WattBob_TextLCD.h" -#include "SDFileSystem" +#include "SDFileSystem.h" +#include "tasks.h" #define BACK_LIGHT_ON(INTERFACE) INTERFACE->write_bit(1,BL_BIT) #define BACK_LIGHT_OFF(INTERFACE) INTERFACE->write_bit(0,BL_BIT) @@ -29,8 +30,8 @@ SDFileSystem uSD(p5, p6, p7, p8, "uSD"); //uSD pinout // Analogue I/O p15 to p20 -AnalogIn A1(p15); // Analogue input to be filtered -AnalogIn A2(p16); // Analogue input to be filtered +AnalogIn A1_(p15); // Analogue input to be filtered +AnalogIn A2_(p16); // Analogue input to be filtered // Timer objects Ticker tick; // Clock timer for CycExec @@ -52,14 +53,14 @@ bool switch_state = 0; // Switch high or low (Digital In) bool WD_pulse; -bool WD_pulse_out = WD_pulse; +//bool WD_pulse_out = WD_pulse; -int A1_In = A1; // Analogue 1 input variable -int A2_In = A2; // Analogue 2 input variable +int A1_in = A1_; // Analogue 1 input variable +int A2_in = A2_; // Analogue 2 input variable int A1_val = 0; // Analogue 1 return variable (Analogue In) int A2_val = 0; // Analogue 2 return variable (Analogue In) -bool DS_sIn = DS_s // Shutdown Switch boolean +bool DS_sIn = DS_s; // Shutdown Switch boolean int error_code = 0; // Error code variable int logcount = 0; // Keep track of log number @@ -68,6 +69,7 @@ // // Main Program // +void CycExec(); int main() { @@ -89,29 +91,29 @@ void CycExec() { - if(tck % 40 = 0){ // Every Second (needs offset) + if(tck % 40 == 4){ // Every Second (needs offset) Task1(timer, FqIn, SampFreq, period, freq); } - else if(tck % 13 = 0){ // Every 1/3 sec + else if(tck % 13 == 8){ // Every 1/3 sec Task2(DSIn, switch_state); } - else if(tck % 80 = 0){ // Every 2 sec + else if(tck % 80 == 7){ // Every 2 sec Task3(WD_pulse, WD); } - else if(tck % 20 = 0){ // Every 1/2 sec + else if(tck % 20 == 0){ // Every 1/2 sec Task4(A1_val, A2_val, A1_in, A2_in); } - else if(tck % 80 = 0){ // Every 2 sec + else if(tck % 80 == 1){ // Every 2 sec Task5(freq, switch_state, A1_val, A2_val); } - else if(tck % 20 = 0){ // Every 0.5 sec + else if(tck % 20 == 3){ // Every 0.5 sec Task6(switch_state, A1_val, A2_val, error_code); } - else if(tck % 20 = 0){ // Every 1/2 sec + else if(tck % 20 == 10){ // Every 1/2 sec Task7(logcount, freq, switch_state, A1_val, A2_val); } - else{ - Task8(DS_sIn, ticker, T5); + else if(tck % 20 == 12){ + Task8(DS_sIn, tick, T5); } tck++; }