Skip to content

Commit

Permalink
Added button read commands to example code lcd.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
dehavenm authored May 30, 2019
1 parent 3b0170b commit ace4ee2
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion example/lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main() {

lcd.home();

lcd.setBacklight(BLUE);
lcd.setBacklight(WHITE);

lcd.cursor();

Expand All @@ -27,6 +27,40 @@ int main() {

lcd.print("Hello, world!\nJetson Xavier");

uint8_t button_data;

while (true) //press Ctrl-C to exit
{
//read button data
button_data = lcd.readButtons();

if (button_data) {
lcd.clearDisplay();
lcd.setCursor(0,0);
if (button_data & BUTTON_UP) {
lcd.print("UP ");
lcd.setBacklight(RED);
}
if (button_data & BUTTON_DOWN) {
lcd.print("DOWN ");
lcd.setBacklight(YELLOW);
}
if (button_data & BUTTON_LEFT) {
lcd.print("LEFT ");
lcd.setBacklight(GREEN);
}
if (button_data & BUTTON_RIGHT) {
lcd.print("RIGHT ");
lcd.setBacklight(TEAL);
}
if (button_data & BUTTON_SELECT) {
lcd.print("SELECT ");
lcd.setBacklight(VIOLET);
}
}

}



return 0;
Expand Down

0 comments on commit ace4ee2

Please sign in to comment.