for HTTP-3A

Dependencies:   mbed TextLCD

Revision:
5:1d817b3c42f1
Parent:
4:c1438ffd88dd
Child:
6:572219c7c378
--- a/main.cpp	Thu Jul 11 09:29:11 2019 +0000
+++ b/main.cpp	Thu Jul 11 12:24:29 2019 +0000
@@ -13,21 +13,25 @@
 CANMessage  can_msg_send;
 char data_msg[3] = {0x11,0x22,0x33};
 
+DigitalIn armSwitch(PF_7, PullDown);
+bool armed = false;
 
-bool armed = false;
 AnalogIn   res(PA_0);
 float volt = 0;
 
 
-I2C i2c_lcd(PB_7,PB_6); // SDA, SCL
+//I2C i2c_lcd(PB_7,PB_6); // SDA, SCL
+I2C i2c_lcd(PF_0,PF_1); // SDA, SCL
 TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD16x2); // I2C bus, PCF8574 Slaveaddress, LCD Type
 
 const char fill[] = {0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00};
 const char empty[] = {0x1F, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x00};
-
+const char cross[] = {0x00, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x00, 0x00};
 
 void showBar(void);
 
+void showArm(void);
+
 void CAN_RX1(void);
 
 void sendCMD(void)
@@ -55,12 +59,16 @@
     lcd.setBacklight(TextLCD::LightOn); 
     lcd.setUDC(0, (char *) fill);
     lcd.setUDC(1, (char *) empty);
+    lcd.setUDC(2, (char *) cross);
     pc.printf("set done\n\r");
     
     while(1)
     {   
         volt = res.read();
         showBar();
+        showArm();
+        
+        
     }
 
 }
@@ -84,15 +92,50 @@
     else if( bars < 0 )
         bars = 0; 
         
-        
-    for(int i = 0; i<bars ;i++)
+    if (armed)
     {
-        lcd.locate(i,0);
-        lcd.putc(0);    
-    }
-    for(int i = bars; i<16 ;i++)
+        for(int i = 0; i<bars ;i++)
+        {
+            lcd.locate(i,0);
+            lcd.putc(0);    
+        }
+        for(int i = bars; i<16 ;i++)
+        {
+            lcd.locate(i,0);
+            lcd.putc(1);    
+        }    
+    }    
+    else
     {
-        lcd.locate(i,0);
-        lcd.putc(1);    
+        for(int i = 0; i<bars ;i++)
+        {
+            lcd.locate(i,0);
+            lcd.putc(2);    
+        }
+        for(int i = bars; i<16 ;i++)
+        {
+            lcd.locate(i,0);
+            lcd.putc(1);    
+        } 
     }
 }
+
+void showArm(void)
+{
+    if (armSwitch)
+        armed = true;
+    else
+        armed = false;
+    
+    if (armed)
+    {
+        lcd.locate(0,1);
+        lcd.printf("ARMED   ");
+    }
+    else
+    {
+        lcd.locate(0,1);
+        lcd.printf("DISARMED");
+    }
+        
+}