
USED IMAGE2GLCD
Dependencies: BLE_API SharpLCD_LucidaFont mbed nRF51822
Fork of Renard_UI_Only by
Diff: main.cpp
- Revision:
- 13:6def6e1fb69e
- Parent:
- 12:6bd7c00a0a93
--- a/main.cpp Wed Apr 29 07:41:08 2015 +0000 +++ b/main.cpp Wed May 13 08:15:01 2015 +0000 @@ -27,6 +27,7 @@ DigitalOut motor(P0_1); DigitalOut screen(P0_21); DigitalIn button(P0_16); +DigitalIn button2(P0_17); //a50,a60,a70,a80,a90,a100,a110,a120,a130,a140,a150,a160,a170 char strn[50]; // incoming tx data @@ -34,9 +35,12 @@ uint8_t* rings[2] = {a0,a10}; int set=0; int set2=0; +int set3=0; int pairing =1; int anim=0; int elip=0; +int flash=0; +int screenIndex = 0; int timeUpdate = 1; time_t unixTime; @@ -82,7 +86,7 @@ lcd.clear(); mainFont = searchFontFace("Square Head Black", 20); - subFont = searchFontFace("Century Gothic Black", 9); + subFont = searchFontFace("Droid Sans Mono Black", 9); exFont = searchFontFace("Lucida", 8); } @@ -103,11 +107,11 @@ wait(0.15); if (anim>=2) { - anim = 0; + anim = 0; } if (elip>=4) { - elip = 0; + elip = 0; } } @@ -168,16 +172,24 @@ fb.bitBlit(img, 96, 96, 0,0); fb.bitBlit(battery, 16, 16, 75, 0); - - fb.bitBlit(BLE, 16, 16, 0, 0); - - fb.printString(mainFont, 60, 65, user); - - fb.printString(mainFont, 5, 61, timeStr); - - fb.printString(subFont, 14, 78, dayStr); - - fb.printString(subFont, 43, 78, dateStr); + //fb.bitBlit(BLE, 16, 16, 0, 0); + if (screenIndex == 0) { + fb.printString(mainFont, 5, 61, timeStr); + + fb.printString(subFont, 14, 78, dayStr); + + fb.printString(subFont, 43, 78, dateStr); + } else if (screenIndex == 1) { + if (flash % 2 == 0) { + fb.printString(subFont, 10, 30, "Yo Received!"); + flash++; + } else { + flash = 0; + } + + fb.printString(subFont, 10, 60, "User:"); + fb.printString(subFont, 10, 80, user); + } lcd.drawFrameBuffer(fb); } @@ -212,18 +224,27 @@ mClock.start(); } else { strncpy(user, strn, sizeof(strn)); + screenIndex = 1; // force second screen } set = 0; } - if(!button && !set2){ - set2 = 1; + if(button && set2){ + set2 = 0; uint16_t bytesToSend = strlen(user); memcpy(rxPayload, user, bytesToSend); ble.updateCharacteristicValue(rxHandle, rxPayload, bytesToSend); pc.printf ("\n\r Sending %s", user); - } else if (button){ - set2 = 0; + } else if (!button){ + set2 = 1; + } + + if (button2 && set3) { + + set3 = 0; + screenIndex = screenIndex == 0 ? 1 : 0; // if 0 switch to 1, if 1 switch to 0 + } else if (!button2) { + set3 = 1; } clockOffset = mClock.read_ms();