Project aiming to make a self-controlled solar reflector
Dependencies: Accelerometer LCD Inverter Algorithm MotorDriver Anemometer GUI ArduinoJson Misc Definitions Pushbutton WebSocketClient temp_fan
main.cpp
- Committer:
- khaiminhvn
- Date:
- 2021-03-12
- Revision:
- 7:2b6438e586e6
- Parent:
- 6:0b7a6e51cdf8
- Child:
- 8:a1481d5f0572
File content as of revision 7:2b6438e586e6:
/* For settings of system behaviour, see Defs_sett.h For pin assignment list, see PinAssignment.h */ //INCLUDES #include "mbed.h" #include "stdio.h" #include "string" // std::string, std::to_string #include "Accelerometer.h" #include "Anemometer.h" #include "Algorithm.h" #include "MotorDriver.h" #include "Defs_Sett.h" #include "Pushbutton.h" #include "PinAssignment.h" #include "LCD.h" #include <string> #define timer_read_s(x) chrono::duration_cast<chrono::seconds>((x).elapsed_time()).count() //Initialize Global Variables I2C i2c(PIN_SDA,PIN_SCL); Anemometer ane; // //MotorDriver motor; LowPowerTimer t,t_mode; int mode = OP_CALIBRATION; Pushbutton bt_fn(PIN_BTFN,&mode); Pushbutton bt_inc(PIN_BTINC); Pushbutton bt_dec(PIN_BTDEC); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// int main() { i2c.frequency(I2C_FREQ); //Accelerometer acc(&i2c); //Accelerometer LCD lcd(&i2c); float ang_P,ang_R; float ref_R1,ref_R2; int flag_time = 1, flag_idle = 0; int t_elapsed; int wthres = WIND_THRES_INIT; char buffer[16]; string topL = "PUT SENSORS IN"; string botL = "CALIBRATION SLOT"; t.start(); //Start timer lcd.LCD_display(topL, botL); while(1) { switch(mode) { case OP_PLACEMENT:{ topL = "PUT SENSOR ON"; botL = "PANEL&REFLECTORS"; lcd.LCD_display(topL,botL); break; } //////////////////////////////////////////////////////////////////////////////// case OP_NORMAL:{ topL = "NORMAL"; botL = ""; lcd.LCD_display(topL,botL); break; } //////////////////////////////////////////////////////////////////////////////// case OP_WIND:{ ane.checkWind(&mode); topL = "WIND SAFETY"; botL = ""; lcd.LCD_display(topL,botL); break; } //////////////////////////////////////////////////////////////////////////////// case OP_MANUAL1:{ topL = "MANUAL: M1"; botL = ""; lcd.LCD_display(topL,botL); break; } //////////////////////////////////////////////////////////////////////////////// case OP_MANUAL2:{ topL = "MANUAL: M2"; botL = ""; lcd.LCD_display(topL,botL); break; } //////////////////////////////////////////////////////////////////////////////// case OP_WSETTING:{ topL = "Threshold:"; botL = ""; lcd.LCD_display(topL,botL); break; } } wait_us(LOOP_DELAY); } } //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////