summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-02-11 22:58:16 +0100
committerFlorian Pritz <bluewind@xinu.at>2013-02-11 22:59:53 +0100
commit5b1afe32cf7496acea8182278aca83f59e8384e3 (patch)
treed1c0cadb01a5d638bb12251d488b7beef8a156d0 /src
parent4e50c8291bd83a3fbb24a209fd1f6c7cbdb5283c (diff)
downloadmpd-box-5b1afe32cf7496acea8182278aca83f59e8384e3.tar.gz
mpd-box-5b1afe32cf7496acea8182278aca83f59e8384e3.tar.xz
Make code launchpad/energia compatible
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 30f2b87..f246e3a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -9,10 +9,19 @@ void loop();
char buf[BUFFER_SIZE];
// initialize the library with the numbers of the interface pins
+#ifdef ENERGIA
+LiquidCrystal lcd(13, 12, 10, 9, 8, 7);
+#else
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
+#endif
-// A0 = prev; A1 = pause; A2 = next
+// indices: 0 = prev; 1 = pause; 2 = next
+#ifdef ENERGIA
+byte buttons[] = {15, 6, 5};
+#else
byte buttons[] = {A0, A1, A2};
+#endif
+
#define NUMBUTTONS sizeof(buttons)
#define DEBOUNCE 10
Bounce bounce_buttons[NUMBUTTONS];
@@ -20,16 +29,32 @@ Bounce bounce_buttons[NUMBUTTONS];
void setup() {
byte i;
lcd.begin(16, 2);
+
+// The usb chip hangs if it tries to send data and no-one listens
+// so we give the client time to start up first
+#ifdef ENERGIA
+ lcd.print("Waiting ...");
+ for (int i = 0; i < 20; i++) {
+ lcd.setCursor(0, 1);
+ lcd.print("Serial: ");
+ lcd.print(i);
+ lcd.print("/20");
+ delay(1000);
+ }
+ lcd.setCursor(0,0);
+ lcd.clear();
+#endif
+
Serial.begin(9600);
Serial.setTimeout(5000);
for (i = 0; i < NUMBUTTONS; i++) {
- pinMode(buttons[i], INPUT);
- digitalWrite(buttons[i], HIGH);
+ pinMode(buttons[i], INPUT_PULLUP);
bounce_buttons[i] = Bounce(buttons[i], DEBOUNCE);
}
Serial.println("ready");
+ lcd.print("Serial ready");
}
bool button_just_pressed(int i) {