Project Autus - Automated Plant Chamber

Dependencies:   TextLCD mbed

Fork of keypad_test by Plamen Totev

Autus

This is the codebase accompanying the project Autus.

Autus is an automated growth chamber for plants.

Features

Control Humidity inside chamber wrt to external humidity. Control Temperature inside chamber. ( Peltier Heaters/Coolers ) Water and shower plants. Control soil humidity. Monitor water tanks level (Load Cell) /media/uploads/umairaftab/frdm_-_new_page1.png

Code Base Features

Fixed timing and CRC for DHT-11 Sensor. Fixed OneWire bug for ds18b20

Cyclic Executive Scheduler with Priority. Async IPC framework for PC App over bluetooth

Fake RTC systick, I was having some trouble with the on board rtc.

/media/uploads/umairaftab/download.png

Revision:
26:2f59456a7bad
Parent:
25:a6d1eaf2041c
Child:
27:24478764d4b2
diff -r a6d1eaf2041c -r 2f59456a7bad main.cpp
--- a/main.cpp	Sun Apr 13 00:11:46 2014 +0000
+++ b/main.cpp	Sun Apr 13 00:41:55 2014 +0000
@@ -177,6 +177,102 @@
         }
     
 }
+void settings_submenu(int counter_menu){
+    
+    char key_value2;
+    bool break_flag = false;
+    switch(counter_menu){
+        case 0:
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("Not Authorised");
+            wait(5);
+            break;
+        case 1:
+            break_flag = false;
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("Cur Air Humidity Lvl");
+            //lcd.locate(0,1);
+            //lcd.printf("%3.1f",setpoint_air_humidity);
+            while(!break_flag){
+                lcd.locate(0,1);
+                lcd.printf("%3.1f",setpoint_air_humidity);
+                key_value2 = Keypad();
+                wait(0.2);
+                if(key_value2 == 74){setpoint_air_humidity++;}
+                else if(key_value2 == 71){setpoint_air_humidity--;}
+                else if(key_value2 == 75){break_flag=true;} //enter
+                if (setpoint_air_humidity <0 || setpoint_air_humidity >99) {setpoint_air_humidity=30.00;}
+            }
+            
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("NEW Air Humid Setpoint");
+            lcd.locate(0,1);
+            lcd.printf("%3.1f",setpoint_air_humidity);
+            wait(5);
+            
+            break;
+        case 2:
+            break_flag = false;
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("Soil Humidity Setpoint");
+            
+            while(!break_flag){
+                lcd.locate(0,1);
+                lcd.printf("S1: %4.2f",setpoint_soil_humid1);
+                lcd.printf(" S2: %4.2f",setpoint_soil_humid2);
+                key_value2 = Keypad();
+                wait(0.2);
+                if(key_value2 == 60){ //up
+                    setpoint_soil_humid1++;
+                    setpoint_soil_humid2++;
+                }
+                else if(key_value2 == 62){//down
+                    setpoint_soil_humid1--;
+                    setpoint_soil_humid2--;
+                }
+                else if(key_value2 == 75){break_flag=true;}//enterkey
+                //if (setpoint_air_humidity <0 || setpoint_air_humidity >99) {setpoint_air_humidity=30.00;}
+            }
+            
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("New Soil Setpoints:");
+            lcd.locate(0,1);
+            lcd.printf("S1: %4.2f",setpoint_soil_humid1);
+            lcd.printf(" S2: %4.2f",setpoint_soil_humid2);
+            wait(5);
+            break;
+        case 3:
+        
+            break_flag = false;
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("Cur Air Tmp Setpoint");
+            while(!break_flag){
+                lcd.locate(0,1);
+                lcd.printf("%3.1f",setpoint_MAX_air_temp);
+                key_value2 = Keypad();
+                wait(0.2);
+                if(key_value2 == 60){setpoint_MAX_air_temp++;}
+                else if(key_value2 == 62){setpoint_MAX_air_temp--;}
+                else if(key_value2 == 75){break_flag=true;}
+                if (setpoint_MAX_air_temp <0 || setpoint_MAX_air_temp >99) {setpoint_MAX_air_temp=45.0;}
+            }
+            
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("NEW Air Tmp Setpoint");
+            lcd.locate(0,1);
+            lcd.printf("%3.1f",setpoint_MAX_air_temp);
+            wait(5);
+            break;
+    }//switch end
+    
+}
 //***************************************SETTINGS UI************************************* 
 void ui_settings(){
     
@@ -201,7 +297,9 @@
     lcd.cls();
     int counter_menu =0 ; 
     while(!exit_settings){
+        
         key_value = Keypad();
+        printf("Key %d",key_value);
         wait(0.5);
         if(key_value == 150){
             lcd.locate(0,0);
@@ -214,105 +312,14 @@
             else{
                 lcd.printf(" %s",menu[counter_menu+1].c_str());
             }
-            wait(0.2); 
+            //wait(0.2); 
         }//No Press If Block
         else if(key_value == 62){//Down Key Pressed if block
             lcd.cls();
             counter_menu++;
         }//Down Key Pressed if block end
         else if(key_value == 59){ //OK Key Pressed if block
-            char key_value2;
-            bool break_flag = false;
-            switch(counter_menu){
-                case 0:
-                    lcd.cls();
-                    lcd.locate(0,0);
-                    lcd.printf("Not Authorised");
-                    wait(5);
-                    break;
-                case 1:
-                    break_flag = false;
-                    lcd.cls();
-                    lcd.locate(0,0);
-                    lcd.printf("Cur Air Humidity Lvl");
-                    //lcd.locate(0,1);
-                    //lcd.printf("%3.1f",setpoint_air_humidity);
-                    while(!break_flag){
-                        lcd.locate(0,1);
-                        lcd.printf("%3.1f",setpoint_air_humidity);
-                        key_value2 = Keypad();
-                        wait(0.2);
-                        if(key_value2 == 74){setpoint_air_humidity++;}
-                        else if(key_value2 == 71){setpoint_air_humidity--;}
-                        else if(key_value2 == 75){break_flag=true;} //enter
-                        if (setpoint_air_humidity <0 || setpoint_air_humidity >99) {setpoint_air_humidity=30.00;}
-                    }
-                    
-                    lcd.cls();
-                    lcd.locate(0,0);
-                    lcd.printf("NEW Air Humid Setpoint");
-                    lcd.locate(0,1);
-                    lcd.printf("%3.1f",setpoint_air_humidity);
-                    wait(5);
-                    
-                    break;
-                case 2:
-                    break_flag = false;
-                    lcd.cls();
-                    lcd.locate(0,0);
-                    lcd.printf("Soil Humidity Setpoint");
-                    
-                    while(!break_flag){
-                        lcd.locate(0,1);
-                        lcd.printf("S1: %4.2f",setpoint_soil_humid1);
-                        lcd.printf(" S2: %4.2f",setpoint_soil_humid2);
-                        key_value2 = Keypad();
-                        wait(0.2);
-                        if(key_value2 == 60){ //up
-                            setpoint_soil_humid1++;
-                            setpoint_soil_humid2++;
-                        }
-                        else if(key_value2 == 62){//down
-                            setpoint_soil_humid1--;
-                            setpoint_soil_humid2--;
-                        }
-                        else if(key_value2 == 75){break_flag=true;}//enterkey
-                        //if (setpoint_air_humidity <0 || setpoint_air_humidity >99) {setpoint_air_humidity=30.00;}
-                    }
-                    
-                    lcd.cls();
-                    lcd.locate(0,0);
-                    lcd.printf("New Soil Setpoints:");
-                    lcd.locate(0,1);
-                    lcd.printf("S1: %4.2f",setpoint_soil_humid1);
-                    lcd.printf(" S2: %4.2f",setpoint_soil_humid2);
-                    wait(5);
-                    break;
-                case 3:
-                
-                    break_flag = false;
-                    lcd.cls();
-                    lcd.locate(0,0);
-                    lcd.printf("Cur Air Tmp Setpoint");
-                    while(!break_flag){
-                        lcd.locate(0,1);
-                        lcd.printf("%3.1f",setpoint_MAX_air_temp);
-                        key_value2 = Keypad();
-                        wait(0.2);
-                        if(key_value2 == 60){setpoint_MAX_air_temp++;}
-                        else if(key_value2 == 62){setpoint_MAX_air_temp--;}
-                        else if(key_value2 == 75){break_flag=true;}
-                        if (setpoint_MAX_air_temp <0 || setpoint_MAX_air_temp >99) {setpoint_MAX_air_temp=45.0;}
-                    }
-                    
-                    lcd.cls();
-                    lcd.locate(0,0);
-                    lcd.printf("NEW Air Tmp Setpoint");
-                    lcd.locate(0,1);
-                    lcd.printf("%3.1f",setpoint_MAX_air_temp);
-                    wait(5);
-                    break;
-            }//switch end
+            settings_submenu(counter_menu);
         } //OK button if block
         else if(key_value == 57){ //OK Button
             exit_settings = true;
@@ -326,6 +333,8 @@
     lcd.printf("Exit Settings");
     wait(5);
 }
+
+
 //Function to process keypad inputs
 void process_user_input(char keypad_value_in, int ui_current_screen_in){