a
Dependencies: 4DGL-uLCD-SE EthernetInterface mbed rtos
main.cpp@4:5780f46cbd63, 2016-06-25 (annotated)
- Committer:
- shekha_atrash
- Date:
- Sat Jun 25 03:29:49 2016 +0000
- Revision:
- 4:5780f46cbd63
- Parent:
- 3:7862ff3a9feb
a;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shekha_atrash | 0:d32f86ba2959 | 1 | #include "mbed.h" |
shekha_atrash | 1:40b4ffe15e4e | 2 | #include "uLCD_4DGL.h" |
shekha_atrash | 4:5780f46cbd63 | 3 | #include "EthernetInterface.h" |
shekha_atrash | 2:14a8a5475978 | 4 | |
shekha_atrash | 2:14a8a5475978 | 5 | uLCD_4DGL lcd(p9,p10,p11); |
shekha_atrash | 3:7862ff3a9feb | 6 | EthernetInterface eth; |
shekha_atrash | 2:14a8a5475978 | 7 | |
shekha_atrash | 2:14a8a5475978 | 8 | //void basicLCD(); |
shekha_atrash | 2:14a8a5475978 | 9 | //void BlinkLED(); |
shekha_atrash | 2:14a8a5475978 | 10 | |
shekha_atrash | 0:d32f86ba2959 | 11 | int main() |
shekha_atrash | 0:d32f86ba2959 | 12 | { |
shekha_atrash | 2:14a8a5475978 | 13 | lcd.printf("hi"); |
shekha_atrash | 3:7862ff3a9feb | 14 | |
shekha_atrash | 3:7862ff3a9feb | 15 | char buf[0x600]; |
shekha_atrash | 3:7862ff3a9feb | 16 | |
shekha_atrash | 3:7862ff3a9feb | 17 | while(1) |
shekha_atrash | 3:7862ff3a9feb | 18 | { |
shekha_atrash | 3:7862ff3a9feb | 19 | int size = eth.receive(); |
shekha_atrash | 3:7862ff3a9feb | 20 | if(size > 0) |
shekha_atrash | 3:7862ff3a9feb | 21 | { |
shekha_atrash | 3:7862ff3a9feb | 22 | eth.read(buf, size); |
shekha_atrash | 3:7862ff3a9feb | 23 | printf("Destxination: %02X:%02X:%02X:%02X:%02X:%02X\n", |
shekha_atrash | 3:7862ff3a9feb | 24 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); |
shekha_atrash | 3:7862ff3a9feb | 25 | printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\n", |
shekha_atrash | 3:7862ff3a9feb | 26 | buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]); |
shekha_atrash | 3:7862ff3a9feb | 27 | } |
shekha_atrash | 3:7862ff3a9feb | 28 | |
shekha_atrash | 3:7862ff3a9feb | 29 | wait(1); |
shekha_atrash | 3:7862ff3a9feb | 30 | } |
shekha_atrash | 2:14a8a5475978 | 31 | } |
shekha_atrash | 2:14a8a5475978 | 32 | |
shekha_atrash | 2:14a8a5475978 | 33 | |
shekha_atrash | 2:14a8a5475978 | 34 | void BlinkLED() |
shekha_atrash | 2:14a8a5475978 | 35 | { |
shekha_atrash | 2:14a8a5475978 | 36 | DigitalOut myled(LED1); |
shekha_atrash | 2:14a8a5475978 | 37 | |
shekha_atrash | 2:14a8a5475978 | 38 | while(1) |
shekha_atrash | 2:14a8a5475978 | 39 | { |
shekha_atrash | 2:14a8a5475978 | 40 | myled = 1; |
shekha_atrash | 2:14a8a5475978 | 41 | wait(0.2); |
shekha_atrash | 2:14a8a5475978 | 42 | myled = 0; |
shekha_atrash | 2:14a8a5475978 | 43 | wait(0.2); |
shekha_atrash | 2:14a8a5475978 | 44 | } |
shekha_atrash | 2:14a8a5475978 | 45 | } |
shekha_atrash | 2:14a8a5475978 | 46 | |
shekha_atrash | 2:14a8a5475978 | 47 | |
shekha_atrash | 2:14a8a5475978 | 48 | void receiveFromEthernet() |
shekha_atrash | 2:14a8a5475978 | 49 | { |
shekha_atrash | 4:5780f46cbd63 | 50 | EthernetInterface eth; |
shekha_atrash | 0:d32f86ba2959 | 51 | char buf[0x600]; |
shekha_atrash | 0:d32f86ba2959 | 52 | |
shekha_atrash | 0:d32f86ba2959 | 53 | while(1) |
shekha_atrash | 0:d32f86ba2959 | 54 | { |
shekha_atrash | 0:d32f86ba2959 | 55 | int size = eth.receive(); |
shekha_atrash | 0:d32f86ba2959 | 56 | if(size > 0) |
shekha_atrash | 0:d32f86ba2959 | 57 | { |
shekha_atrash | 0:d32f86ba2959 | 58 | eth.read(buf, size); |
shekha_atrash | 0:d32f86ba2959 | 59 | printf("Destination: %02X:%02X:%02X:%02X:%02X:%02X\n", |
shekha_atrash | 0:d32f86ba2959 | 60 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); |
shekha_atrash | 0:d32f86ba2959 | 61 | printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\n", |
shekha_atrash | 0:d32f86ba2959 | 62 | buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]); |
shekha_atrash | 0:d32f86ba2959 | 63 | } |
shekha_atrash | 0:d32f86ba2959 | 64 | |
shekha_atrash | 0:d32f86ba2959 | 65 | wait(1); |
shekha_atrash | 0:d32f86ba2959 | 66 | } |
shekha_atrash | 2:14a8a5475978 | 67 | } |
shekha_atrash | 2:14a8a5475978 | 68 | |
shekha_atrash | 2:14a8a5475978 | 69 | |
shekha_atrash | 2:14a8a5475978 | 70 | void basicLCD() |
shekha_atrash | 2:14a8a5475978 | 71 | { |
shekha_atrash | 2:14a8a5475978 | 72 | |
shekha_atrash | 2:14a8a5475978 | 73 | |
shekha_atrash | 2:14a8a5475978 | 74 | uLCD_4DGL lcd(p9,p10,p11); |
shekha_atrash | 2:14a8a5475978 | 75 | |
shekha_atrash | 2:14a8a5475978 | 76 | // Set our UART baudrate to something reasonable |
shekha_atrash | 2:14a8a5475978 | 77 | lcd.baudrate(115200); |
shekha_atrash | 2:14a8a5475978 | 78 | |
shekha_atrash | 2:14a8a5475978 | 79 | // Change background color (must be called before cls) |
shekha_atrash | 2:14a8a5475978 | 80 | lcd.background_color(WHITE); |
shekha_atrash | 2:14a8a5475978 | 81 | |
shekha_atrash | 2:14a8a5475978 | 82 | // Clear screen with background color |
shekha_atrash | 2:14a8a5475978 | 83 | lcd.cls(); |
shekha_atrash | 2:14a8a5475978 | 84 | lcd.printf("hello"); |
shekha_atrash | 2:14a8a5475978 | 85 | } |
shekha_atrash | 2:14a8a5475978 | 86 | |
shekha_atrash | 2:14a8a5475978 | 87 | void lcdFunction() |
shekha_atrash | 2:14a8a5475978 | 88 | { |
shekha_atrash | 2:14a8a5475978 | 89 | uLCD_4DGL lcd(p9,p10,p11); |
shekha_atrash | 2:14a8a5475978 | 90 | |
shekha_atrash | 2:14a8a5475978 | 91 | // Set our UART baudrate to something reasonable |
shekha_atrash | 2:14a8a5475978 | 92 | lcd.baudrate(115200); |
shekha_atrash | 2:14a8a5475978 | 93 | |
shekha_atrash | 2:14a8a5475978 | 94 | // Change background color (must be called before cls) |
shekha_atrash | 2:14a8a5475978 | 95 | lcd.background_color(WHITE); |
shekha_atrash | 2:14a8a5475978 | 96 | |
shekha_atrash | 2:14a8a5475978 | 97 | // Clear screen with background color |
shekha_atrash | 2:14a8a5475978 | 98 | lcd.cls(); |
shekha_atrash | 2:14a8a5475978 | 99 | |
shekha_atrash | 2:14a8a5475978 | 100 | // Change background color of text |
shekha_atrash | 2:14a8a5475978 | 101 | lcd.textbackground_color(WHITE); |
shekha_atrash | 2:14a8a5475978 | 102 | |
shekha_atrash | 2:14a8a5475978 | 103 | // Make some colorful text |
shekha_atrash | 2:14a8a5475978 | 104 | lcd.locate(4, 1); // Move cursor |
shekha_atrash | 2:14a8a5475978 | 105 | lcd.color(BLUE); |
shekha_atrash | 2:14a8a5475978 | 106 | lcd.printf("This is a\n"); |
shekha_atrash | 2:14a8a5475978 | 107 | lcd.locate(5, 3); // Move cursor |
shekha_atrash | 2:14a8a5475978 | 108 | lcd.text_width(2); // 2x normal size |
shekha_atrash | 2:14a8a5475978 | 109 | lcd.text_height(2); // 2x normal size |
shekha_atrash | 2:14a8a5475978 | 110 | lcd.color(RED); // Change text color |
shekha_atrash | 2:14a8a5475978 | 111 | lcd.printf("TEST"); |
shekha_atrash | 2:14a8a5475978 | 112 | lcd.text_width(1); // Normal size |
shekha_atrash | 2:14a8a5475978 | 113 | lcd.text_height(1); // Normal size |
shekha_atrash | 2:14a8a5475978 | 114 | lcd.locate(3, 6); // Move cursor |
shekha_atrash | 2:14a8a5475978 | 115 | lcd.color(BLACK); // Change text color |
shekha_atrash | 2:14a8a5475978 | 116 | lcd.printf("of my new LCD"); |
shekha_atrash | 2:14a8a5475978 | 117 | } |