initial commit

Dependencies:   mbed

Fork of empc_pdu_v3 by gami

Revision:
1:1686fedb8e0a
Parent:
0:d58e47b3cc7e
--- a/main.cpp	Tue Jun 28 18:29:49 2016 +0000
+++ b/main.cpp	Fri Apr 07 16:12:08 2017 +0000
@@ -1,13 +1,53 @@
 #include "mbed.h"
-I2C i2c(D14, D15);        // sda, scl
-Serial pc(USBTX, USBRX); // tx, rx
+#include "TLC59116.h"
+#include "SWITCH.h"
+
+Serial pc(PA_9, PA_10);                 // USB over serial USBTX, USBRX
+DigitalOut led(PA_5);                   // Nucleo-F303RE LED
+TLC59116 pdu(PB_7, PA_15, PB_11);       // TLC59116 LED driver in pdu SDA, SCL, CS
+SWITCH sw(PB_15, PB_13, PB_1, PB_14);
+bool fault = false;
 
 int main()
 {
-    pc.printf("RUN\r\n");
-    for(int i = 0; i < 128 ; i++) {
-        i2c.start();
-        if(i2c.write(i << 1)) pc.printf("0x%x ACK \r\n",i); // Send command string
-        i2c.stop();
+    pdu.Enable();
+    pdu.SWRST();
+    pdu.init();
+    #define DELAY 20
+    
+    pdu.SetBrightness(128);
+
+    while(1)
+    {
+        pdu.SetPower(true);
+        fault = !fault;
+        pdu.SetFault(fault);
+        if (sw.GetMode() == 1)
+        {
+            pdu.SetAuto(true);
+            pdu.SetManual(false);
+        }
+        if (sw.GetMode() == 2)
+        {
+            pdu.SetAuto(false);
+            pdu.SetManual(true);
+        }
+        
+
+        pc.printf("GetMode = %x\r\n", sw.GetMode());
+        pc.printf("GetMove = %x\r\n", sw.GetMove());        
+        pc.printf("\r\n");
+        
+        for (int i = 0; i <= 10; i++)
+        {
+            pdu.SetBarGraph(i);
+            wait_ms(DELAY);
+        }
+        
+        for (int i = 10; i >= 0; i--)
+        {
+            pdu.SetBarGraph(i);
+            wait_ms(DELAY);
+        }
     }
 }
\ No newline at end of file