standalone sx1276 demo program

Dependencies:   SX1276Lib mbed

Fork of SX1276_GPS by CaryCoders

Revision:
6:a6be2aede8f2
Parent:
5:6c9ee7e3a20c
Child:
7:d087e901b74b
diff -r 6c9ee7e3a20c -r a6be2aede8f2 main.cpp
--- a/main.cpp	Sat Aug 02 14:16:30 2014 +0000
+++ b/main.cpp	Sat Aug 02 16:05:40 2014 +0000
@@ -6,15 +6,7 @@
 Serial pc(SERIAL_TX, SERIAL_RX);
 
 MCP23017 mcp23017 = MCP23017(I2C_SDA, I2C_SCL, 0x40);
-Adafruit_RGBLCDShield lcd(mcp23017);
-
-#define RED 0x1
-#define YELLOW 0x3
-#define GREEN 0x2
-#define TEAL 0x6
-#define BLUE 0x4
-#define VIOLET 0x5
-#define WHITE 0x7
+Adafruit_RGBLCDShield lcd(mcp23017,pc);
     
 // Allows to set the backlight, if the LCD backpack is used
 void SetBacklight(unsigned char status)
@@ -30,10 +22,15 @@
 {
     // set the cursor to column 0, line 1
     // (note: line 1 is the second row, since counting begins with 0):
-    lcd.setCursor(0, 1);
+    lcd.setCursor(10, 1);
+    
+    //lcd.cursor();
+    //lcd.blink();
         
     uint8_t buttons = lcd.readButtons();
     
+    lcd.setBacklight(buttons ? 1 : 0);    
+    
     if (buttons)
     {
         lcd.clear();
@@ -44,7 +41,6 @@
             pc.printf("UP ");
             
             lcd.printf("UP ");
-            lcd.setBacklight(RED);
         }
         
         if (buttons & BUTTON_DOWN)
@@ -52,7 +48,6 @@
             pc.printf("DOWN ");
             
             lcd.printf("DOWN ");
-            lcd.setBacklight(YELLOW);
         }
         
         if (buttons & BUTTON_LEFT)
@@ -60,7 +55,6 @@
             pc.printf("LEFT ");
             
             lcd.printf("LEFT ");
-            lcd.setBacklight(GREEN);
         }
         
         if (buttons & BUTTON_RIGHT)
@@ -68,7 +62,6 @@
             pc.printf("RIGHT ");
             
             lcd.printf("RIGHT ");            
-            lcd.setBacklight(TEAL);
         }
         
         if (buttons & BUTTON_SELECT)
@@ -76,9 +69,13 @@
             pc.printf("SELECT ");
             
             lcd.printf("SELECT ");            
-            lcd.setBacklight(VIOLET);
         }
     }
+    
+    lcd.setCursor(0,0);
+    lcd._putc('A');
+    
+    lcd.display();
 }
 
 int main()
@@ -86,25 +83,13 @@
     pc.printf("\n\rSTART\n\r");
 
     // Take MCP out of reset to show its backlight
-    pc.printf("mcp23017.config(0,1,0);\n\r");
-    mcp23017.config(0,1,0);
-    
-    wait(0.5);
-
-    pc.printf("\n\rInitialise LCD\n\r");
-    lcd.begin(16,2);
+    //pc.printf("mcp23017.config(0,1,0);\n\r");
+    //mcp23017.config(0,1,0);    
+    //wait(0.5);
 
-    pc.printf("\n\rShow a letter\n\r");
-    lcd._putc('A');
-    
-    wait(0.5);
-    
-    pc.printf("\n\rPrint Hello World\n\r");
-    lcd.printf("Hello, world!");
-    lcd.setBacklight(GREEN);
-    
-    wait(0.5);
-    
+    pc.printf("\n\rInitialise LCD\n\r");    
+    lcd.begin(16,2);
+        
     pc.printf("\n\rEntering key tracking loop\n\r");
     while (true)
     {