Project aiming to make a self-controlled solar reflector

Dependencies:   Accelerometer LCD Inverter Algorithm MotorDriver Anemometer GUI ArduinoJson Misc Definitions Pushbutton WebSocketClient temp_fan

Revision:
8:a1481d5f0572
Parent:
7:2b6438e586e6
Child:
9:6e950b9a9a81
--- a/main.cpp	Fri Mar 12 00:57:44 2021 +0000
+++ b/main.cpp	Fri Mar 12 01:08:32 2021 +0000
@@ -26,10 +26,6 @@
 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()
@@ -40,11 +36,20 @@
 
 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];
 
+//FLAGS
+int flag_time = 1; //Normal mode time
+int flag_idle = 0; //Idling time
+int flag_disp = 1; //Anti-flickering
+
+//PUSH BUTTONS
+Pushbutton bt_fn(PIN_BTFN,&mode,&flag_disp);
+Pushbutton bt_inc(PIN_BTINC);
+Pushbutton bt_dec(PIN_BTDEC);
+
 string topL = "PUT SENSORS IN";
 string botL = "CALIBRATION SLOT";
 
@@ -59,51 +64,69 @@
         case OP_PLACEMENT:{
             topL = "PUT SENSOR ON";
             botL = "PANEL&REFLECTORS";
-            lcd.LCD_display(topL,botL);
+            if(flag_disp){
+                lcd.LCD_display(topL,botL);
+                flag_disp = 0;
+            }
             
             break;
-            }
+        }
 ////////////////////////////////////////////////////////////////////////////////
         case OP_NORMAL:{
             topL = "NORMAL";
             botL = "";
-            lcd.LCD_display(topL,botL);
+            if(flag_disp){
+                lcd.LCD_display(topL,botL);
+                flag_disp = 0;
+            }
             
             break;
-            }
+        }
 ////////////////////////////////////////////////////////////////////////////////
         case OP_WIND:{
             ane.checkWind(&mode);
             topL = "WIND SAFETY";
             botL = "";
-            lcd.LCD_display(topL,botL);
+            if(flag_disp){
+                lcd.LCD_display(topL,botL);
+                flag_disp = 0;
+            }
             
             break;
-            }
+        }
 ////////////////////////////////////////////////////////////////////////////////
         case OP_MANUAL1:{
             topL = "MANUAL: M1";
             botL = "";
-            lcd.LCD_display(topL,botL);
+            if(flag_disp){
+                lcd.LCD_display(topL,botL);
+                flag_disp = 0;
+            }
             
             break;
-            }
+        }
 ////////////////////////////////////////////////////////////////////////////////
         case OP_MANUAL2:{
             topL = "MANUAL: M2";
             botL = "";
-            lcd.LCD_display(topL,botL);
+            if(flag_disp){
+                lcd.LCD_display(topL,botL);
+                flag_disp = 0;
+            }
                         
             break;
-            }
+        }
 ////////////////////////////////////////////////////////////////////////////////
         case OP_WSETTING:{
             topL = "Threshold:";
             botL = "";
-            lcd.LCD_display(topL,botL);
+            if(flag_disp){
+                lcd.LCD_display(topL,botL);
+                flag_disp = 0;
+            }
             
             break;
-            }
+        }
     }
     wait_us(LOOP_DELAY);
 }