CaryCoders
/
demo_SX1276_standalone
standalone sx1276 demo program
Fork of SX1276_GPS by
main.cpp
- Committer:
- vtraveller
- Date:
- 2014-08-02
- Revision:
- 5:6c9ee7e3a20c
- Parent:
- 4:d70e37f6c6bd
- Child:
- 6:a6be2aede8f2
File content as of revision 5:6c9ee7e3a20c:
#include "mbed.h" #include "Adafruit_RGBLCDShield.h" //#include "MCP23017.h" 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 // Allows to set the backlight, if the LCD backpack is used void SetBacklight(unsigned char status) { pc.printf("Backlight: %i\n\r", status); mcp23017.digitalWrite(8, (~(status >> 2) & 0x1)); mcp23017.digitalWrite(7, (~(status >> 1) & 0x1)); mcp23017.digitalWrite(6, (~status & 0x1)); } void loop() { // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(0, 1); uint8_t buttons = lcd.readButtons(); if (buttons) { lcd.clear(); lcd.setCursor(0,0); if (buttons & BUTTON_UP) { pc.printf("UP "); lcd.printf("UP "); lcd.setBacklight(RED); } if (buttons & BUTTON_DOWN) { pc.printf("DOWN "); lcd.printf("DOWN "); lcd.setBacklight(YELLOW); } if (buttons & BUTTON_LEFT) { pc.printf("LEFT "); lcd.printf("LEFT "); lcd.setBacklight(GREEN); } if (buttons & BUTTON_RIGHT) { pc.printf("RIGHT "); lcd.printf("RIGHT "); lcd.setBacklight(TEAL); } if (buttons & BUTTON_SELECT) { pc.printf("SELECT "); lcd.printf("SELECT "); lcd.setBacklight(VIOLET); } } } int main() { 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("\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\rEntering key tracking loop\n\r"); while (true) { loop(); wait(0.2); } }