Mac Lobdell
/
testSerialDisplay
simple tests of serial displays such as a sparkfun ADM1602K-NSW-FBS/3.3V
main.cpp@1:3eabffe99403, 2016-08-12 (annotated)
- Committer:
- maclobdell
- Date:
- Fri Aug 12 15:13:28 2016 +0000
- Revision:
- 1:3eabffe99403
- Parent:
- 0:7c02f96b0f96
initial commit - not working - need to change sendbyte to a supported call (maybe write((uint16_t*) xxx,1);)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maclobdell | 0:7c02f96b0f96 | 1 | #include "mbed.h" |
maclobdell | 0:7c02f96b0f96 | 2 | |
maclobdell | 1:3eabffe99403 | 3 | #define LOLSHIELDSERIALDISPLAY 0 |
maclobdell | 1:3eabffe99403 | 4 | #define SFSERIALDISPLAY 1 |
maclobdell | 1:3eabffe99403 | 5 | |
maclobdell | 0:7c02f96b0f96 | 6 | int display(char* buffer); |
maclobdell | 0:7c02f96b0f96 | 7 | |
maclobdell | 0:7c02f96b0f96 | 8 | DigitalOut myled(LED1); |
maclobdell | 0:7c02f96b0f96 | 9 | |
maclobdell | 0:7c02f96b0f96 | 10 | Serial lcd(D1,D0); |
maclobdell | 0:7c02f96b0f96 | 11 | |
maclobdell | 0:7c02f96b0f96 | 12 | |
maclobdell | 0:7c02f96b0f96 | 13 | int main() { |
maclobdell | 0:7c02f96b0f96 | 14 | |
maclobdell | 0:7c02f96b0f96 | 15 | char buffer[32]; |
maclobdell | 0:7c02f96b0f96 | 16 | |
maclobdell | 0:7c02f96b0f96 | 17 | lcd.baud(9600); //default |
maclobdell | 0:7c02f96b0f96 | 18 | |
maclobdell | 1:3eabffe99403 | 19 | #if LOLSHIELDSERIALDISPLAY |
maclobdell | 1:3eabffe99403 | 20 | /* Serial Interface to Arduino R3 w/ firmware to drive LOLShield*/ |
maclobdell | 1:3eabffe99403 | 21 | /* LOLShield library only handles upper case and doesn't handle ? */ |
maclobdell | 0:7c02f96b0f96 | 22 | |
maclobdell | 1:3eabffe99403 | 23 | sprintf(buffer, " HOLA MUNDO, WHATS UP \n"); |
maclobdell | 0:7c02f96b0f96 | 24 | |
maclobdell | 1:3eabffe99403 | 25 | lcd.printf(buffer); |
maclobdell | 1:3eabffe99403 | 26 | #endif |
maclobdell | 1:3eabffe99403 | 27 | |
maclobdell | 1:3eabffe99403 | 28 | #if SFSERIALDISPLAY |
maclobdell | 0:7c02f96b0f96 | 29 | |
maclobdell | 0:7c02f96b0f96 | 30 | /*test of spark fun serial display */ |
maclobdell | 0:7c02f96b0f96 | 31 | |
maclobdell | 1:3eabffe99403 | 32 | /* you can move the cursor!*/ |
maclobdell | 0:7c02f96b0f96 | 33 | /* https://www.sparkfun.com/tutorials/246 */ |
maclobdell | 0:7c02f96b0f96 | 34 | |
maclobdell | 0:7c02f96b0f96 | 35 | //turn on the display |
maclobdell | 0:7c02f96b0f96 | 36 | //can I have a FET turn on the display power? |
maclobdell | 0:7c02f96b0f96 | 37 | |
maclobdell | 0:7c02f96b0f96 | 38 | //turn off the splash screen |
maclobdell | 0:7c02f96b0f96 | 39 | lcd.sendbyte(124); //send special character |
maclobdell | 0:7c02f96b0f96 | 40 | lcd.sendbyte(9);// send special character to turn off splash screen |
maclobdell | 0:7c02f96b0f96 | 41 | |
maclobdell | 0:7c02f96b0f96 | 42 | wait (0.5); //wait for display to boot up |
maclobdell | 0:7c02f96b0f96 | 43 | |
maclobdell | 0:7c02f96b0f96 | 44 | //change cursor location |
maclobdell | 0:7c02f96b0f96 | 45 | lcd.sendbyte(254); //send special character to change cursor location |
maclobdell | 0:7c02f96b0f96 | 46 | lcd.sendbyte(128);// send special character to set cursor to beginning of first line |
maclobdell | 0:7c02f96b0f96 | 47 | |
maclobdell | 0:7c02f96b0f96 | 48 | //display message |
maclobdell | 0:7c02f96b0f96 | 49 | sprintf(buffer, " BYE FROM MAC \n"); |
maclobdell | 0:7c02f96b0f96 | 50 | lcd.printf(buffer); |
maclobdell | 0:7c02f96b0f96 | 51 | |
maclobdell | 0:7c02f96b0f96 | 52 | lcd.sendbyte(124); //send special character to change cursor location |
maclobdell | 0:7c02f96b0f96 | 53 | lcd.sendbyte(9);// send special character to change brightnes 128 - 157 |
maclobdell | 0:7c02f96b0f96 | 54 | |
maclobdell | 0:7c02f96b0f96 | 55 | lcd.sendbyte(254); //send special character to change cursor location |
maclobdell | 0:7c02f96b0f96 | 56 | lcd.sendbyte(1);// send special character to clear display |
maclobdell | 1:3eabffe99403 | 57 | #endif |
maclobdell | 0:7c02f96b0f96 | 58 | |
maclobdell | 0:7c02f96b0f96 | 59 | while(1) { |
maclobdell | 0:7c02f96b0f96 | 60 | |
maclobdell | 0:7c02f96b0f96 | 61 | myled = 1; |
maclobdell | 0:7c02f96b0f96 | 62 | wait(0.5); |
maclobdell | 0:7c02f96b0f96 | 63 | myled = 0; |
maclobdell | 0:7c02f96b0f96 | 64 | wait(0.5); |
maclobdell | 0:7c02f96b0f96 | 65 | } |
maclobdell | 0:7c02f96b0f96 | 66 | } |
maclobdell | 0:7c02f96b0f96 | 67 | /* |
maclobdell | 0:7c02f96b0f96 | 68 | int display(char* buffer) |
maclobdell | 0:7c02f96b0f96 | 69 | { |
maclobdell | 0:7c02f96b0f96 | 70 | uint32_t i = 0; |
maclobdell | 0:7c02f96b0f96 | 71 | for (i = 0; i<32; i++) |
maclobdell | 0:7c02f96b0f96 | 72 | { lcd.printf(" "); |
maclobdell | 0:7c02f96b0f96 | 73 | } |
maclobdell | 0:7c02f96b0f96 | 74 | for (i = 0; i<32; i++) |
maclobdell | 0:7c02f96b0f96 | 75 | { lcd.printf("\b"); |
maclobdell | 0:7c02f96b0f96 | 76 | } |
maclobdell | 0:7c02f96b0f96 | 77 | for (i = 0; i<32; i++) |
maclobdell | 0:7c02f96b0f96 | 78 | { lcd.printf("%s",buffer[i]); |
maclobdell | 0:7c02f96b0f96 | 79 | } |
maclobdell | 0:7c02f96b0f96 | 80 | } |
maclobdell | 0:7c02f96b0f96 | 81 | */ |
maclobdell | 0:7c02f96b0f96 | 82 | |
maclobdell | 0:7c02f96b0f96 | 83 |