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:
25:a6d1eaf2041c
Parent:
24:03e27d9e7aaa
Child:
26:2f59456a7bad
diff -r 03e27d9e7aaa -r a6d1eaf2041c main.cpp
--- a/main.cpp	Sat Apr 12 22:56:41 2014 +0000
+++ b/main.cpp	Sun Apr 13 00:11:46 2014 +0000
@@ -202,24 +202,25 @@
     int counter_menu =0 ; 
     while(!exit_settings){
         key_value = Keypad();
-        if(key_value == 100){
+        wait(0.5);
+        if(key_value == 150){
             lcd.locate(0,0);
             lcd.printf(">%s",menu[counter_menu].c_str());
             lcd.locate(0,1);
             if(counter_menu ==3){
-            counter_menu = 0;
-            lcd.printf(" %s",menu[counter_menu].c_str());
+                counter_menu = 0;
+                lcd.printf(" %s",menu[counter_menu].c_str());
             }
             else{
-            lcd.printf(" %s",menu[counter_menu+1].c_str());
+                lcd.printf(" %s",menu[counter_menu+1].c_str());
             }
             wait(0.2); 
         }//No Press If Block
-        else if(key_value == 44){//Down Key Pressed 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 == 41){ //OK Key Pressed if block
+        else if(key_value == 59){ //OK Key Pressed if block
             char key_value2;
             bool break_flag = false;
             switch(counter_menu){
@@ -241,9 +242,9 @@
                         lcd.printf("%3.1f",setpoint_air_humidity);
                         key_value2 = Keypad();
                         wait(0.2);
-                        if(key_value2 == 50){setpoint_air_humidity++;}
-                        else if(key_value2 == 47){setpoint_air_humidity--;}
-                        else if(key_value2 == 51){break_flag=true;}
+                        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;}
                     }
                     
@@ -267,15 +268,15 @@
                         lcd.printf(" S2: %4.2f",setpoint_soil_humid2);
                         key_value2 = Keypad();
                         wait(0.2);
-                        if(key_value2 == 50){
+                        if(key_value2 == 60){ //up
                             setpoint_soil_humid1++;
                             setpoint_soil_humid2++;
                         }
-                        else if(key_value2 == 47){
+                        else if(key_value2 == 62){//down
                             setpoint_soil_humid1--;
                             setpoint_soil_humid2--;
                         }
-                        else if(key_value2 == 51){break_flag=true;}
+                        else if(key_value2 == 75){break_flag=true;}//enterkey
                         //if (setpoint_air_humidity <0 || setpoint_air_humidity >99) {setpoint_air_humidity=30.00;}
                     }
                     
@@ -298,9 +299,9 @@
                         lcd.printf("%3.1f",setpoint_MAX_air_temp);
                         key_value2 = Keypad();
                         wait(0.2);
-                        if(key_value2 == 50){setpoint_MAX_air_temp++;}
-                        else if(key_value2 == 47){setpoint_MAX_air_temp--;}
-                        else if(key_value2 == 51){break_flag=true;}
+                        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;}
                     }
                     
@@ -313,7 +314,7 @@
                     break;
             }//switch end
         } //OK button if block
-        else if(key_value == 57){
+        else if(key_value == 57){ //OK Button
             exit_settings = true;
             lcd.cls();
             lcd.printf("SAVE Config");
@@ -323,7 +324,7 @@
     }//While settings loop exit 
     lcd.cls();
     lcd.printf("Exit Settings");
-    wait(2);
+    wait(5);
 }
 //Function to process keypad inputs
 void process_user_input(char keypad_value_in, int ui_current_screen_in){
@@ -466,8 +467,9 @@
     
     startup_flag = false ;
     timer1ms.attach(&timer1, 0.001); //interrupt attached function(timer) with interval (1 ms)  
-        led_blue_pulsewidth=50;
-        led_blue.period_us(1000);
+    led_blue_pulsewidth=50;
+    led_blue.period_us(1000);
+    
     while(1) {
        
         
@@ -475,26 +477,39 @@
         
         keypad_value = Keypad();
         wait(0.1);
-        //timer1ms.detach();
-        //something
+        
         //lcd_timeout_check();
         //process_user_input(keypad_value,ui_current_screen);
-        if (keypad_value==61) {
+        
+        if ( (keypad_value==62) && (ui_current_screen==1) ) {
             ui_screen2();
+            ui_current_screen=2;
             wait(5);
-            led_blue_pulsewidth=led_blue_pulsewidth+100;
-            led_blue.pulsewidth_us(led_blue_pulsewidth);
-            printf("%c\n\r",keypad_value);
+            //led_blue_pulsewidth=led_blue_pulsewidth+100;
+            //led_blue.pulsewidth_us(led_blue_pulsewidth);
+            //printf("%c\n\r",keypad_value);
         }
-        else if (keypad_value==58) {
+        else if ( (keypad_value==62) && (ui_current_screen==2)) {
             ui_screen3();
+            ui_current_screen=1;
             wait(5);
-            led_blue_pulsewidth=led_blue_pulsewidth-100;
-            led_blue.pulsewidth_us(led_blue_pulsewidth);
-            printf("%c\n\r",keypad_value);
+            //printf("%c\n\r",keypad_value);
+        }
+        else if ( (keypad_value==62) && (ui_current_screen==3)) {
+            ui_screen4();
+            ui_current_screen=1;
+            wait(5);
+            //printf("%c\n\r",keypad_value);
+        }
+        else if ( (keypad_value==75) ) {
+            ui_settings();
+            ui_current_screen=1;
+            //wait(5);
+            //printf("%c\n\r",keypad_value);
         }
         else {
             ui_screen1();
+            wait(0.1);
         }
         printf("%d\n\r",keypad_value);