LCD implementation of our project.
Dependencies: mbed mbed-rtos MLX90614
main.cpp@2:fcde41900fa5, 2015-04-04 (annotated)
- Committer:
- ovidiup13
- Date:
- Sat Apr 04 18:24:21 2015 +0000
- Revision:
- 2:fcde41900fa5
- Parent:
- 0:1e597b0f8b3b
- Child:
- 3:688b62ff6474
Cleaned up interface, added buttons.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ovidiup13 | 0:1e597b0f8b3b | 1 | #include "UserInterface.h" |
ovidiup13 | 0:1e597b0f8b3b | 2 | #include "st7565LCD.h" |
ovidiup13 | 0:1e597b0f8b3b | 3 | |
ovidiup13 | 0:1e597b0f8b3b | 4 | //define mbed pins |
ovidiup13 | 0:1e597b0f8b3b | 5 | #define _MOSI p11 |
ovidiup13 | 0:1e597b0f8b3b | 6 | #define _MISO p12 |
ovidiup13 | 0:1e597b0f8b3b | 7 | #define _SCLK p13 |
ovidiup13 | 0:1e597b0f8b3b | 8 | #define _RST p8 |
ovidiup13 | 0:1e597b0f8b3b | 9 | #define _A0 p25 |
ovidiup13 | 0:1e597b0f8b3b | 10 | #define _CS p26 |
ovidiup13 | 0:1e597b0f8b3b | 11 | |
ovidiup13 | 0:1e597b0f8b3b | 12 | ST7565 st7565(_MOSI, _SCLK, _CS, _RST, _A0); // mosi, sclk, cs, rst, a0 |
ovidiup13 | 0:1e597b0f8b3b | 13 | Serial pc(USBTX, USBRX); //rx, tx |
ovidiup13 | 0:1e597b0f8b3b | 14 | |
ovidiup13 | 2:fcde41900fa5 | 15 | //buttons |
ovidiup13 | 2:fcde41900fa5 | 16 | DigitalIn down(p18); |
ovidiup13 | 2:fcde41900fa5 | 17 | DigitalIn select(p19); |
ovidiup13 | 2:fcde41900fa5 | 18 | |
ovidiup13 | 0:1e597b0f8b3b | 19 | int main(){ |
ovidiup13 | 2:fcde41900fa5 | 20 | //create god UI object |
ovidiup13 | 0:1e597b0f8b3b | 21 | UI * ui = new UI(&st7565); |
ovidiup13 | 0:1e597b0f8b3b | 22 | |
ovidiup13 | 0:1e597b0f8b3b | 23 | //create main menu |
ovidiup13 | 0:1e597b0f8b3b | 24 | Menu * main_menu = new Menu(" Main Menu", &st7565, ui); |
ovidiup13 | 0:1e597b0f8b3b | 25 | |
ovidiup13 | 2:fcde41900fa5 | 26 | //create distance screen |
ovidiup13 | 2:fcde41900fa5 | 27 | Menu *distance = new Menu(" Distance", &st7565, ui); |
ovidiup13 | 2:fcde41900fa5 | 28 | distance->addItem(new Menu(" Back", main_menu, ui)); |
ovidiup13 | 0:1e597b0f8b3b | 29 | |
ovidiup13 | 2:fcde41900fa5 | 30 | //create point-to-point screen |
ovidiup13 | 2:fcde41900fa5 | 31 | Menu *p2p = new Menu(" Point2Point", &st7565, ui); |
ovidiup13 | 2:fcde41900fa5 | 32 | p2p->addItem(new Menu(" Back", main_menu, ui)); |
ovidiup13 | 0:1e597b0f8b3b | 33 | |
ovidiup13 | 2:fcde41900fa5 | 34 | //create level meter screen |
ovidiup13 | 0:1e597b0f8b3b | 35 | Menu *lvlm = new Menu(" Level meter", &st7565, ui); |
ovidiup13 | 0:1e597b0f8b3b | 36 | lvlm->addItem(new Menu(" Back", main_menu, ui)); |
ovidiup13 | 0:1e597b0f8b3b | 37 | |
ovidiup13 | 2:fcde41900fa5 | 38 | //create compass screen |
ovidiup13 | 2:fcde41900fa5 | 39 | Menu *compass = new Menu(" Compass", &st7565, ui); |
ovidiup13 | 2:fcde41900fa5 | 40 | compass->addItem(new Menu(" Back", main_menu, ui)); |
ovidiup13 | 2:fcde41900fa5 | 41 | |
ovidiup13 | 2:fcde41900fa5 | 42 | //create thermometer screen |
ovidiup13 | 2:fcde41900fa5 | 43 | Menu *thermo = new Menu(" Thermometer", &st7565, ui); |
ovidiup13 | 2:fcde41900fa5 | 44 | thermo->addItem(new Menu(" Back", main_menu, ui)); |
ovidiup13 | 2:fcde41900fa5 | 45 | |
ovidiup13 | 2:fcde41900fa5 | 46 | //create settings menu |
ovidiup13 | 0:1e597b0f8b3b | 47 | Menu *settings = new Menu(" Settings", &st7565, ui); |
ovidiup13 | 2:fcde41900fa5 | 48 | Menu *m_settings = new Menu(" Distance", &st7565, ui); |
ovidiup13 | 2:fcde41900fa5 | 49 | settings->addItem(m_settings); |
ovidiup13 | 0:1e597b0f8b3b | 50 | Menu *s_settings = new Menu(" Screen Colour", &st7565, ui); |
ovidiup13 | 0:1e597b0f8b3b | 51 | settings->addItem(s_settings); |
ovidiup13 | 2:fcde41900fa5 | 52 | Menu *b_settings = new Menu(" Brightness", &st7565, ui); |
ovidiup13 | 0:1e597b0f8b3b | 53 | settings->addItem(b_settings); |
ovidiup13 | 0:1e597b0f8b3b | 54 | settings->addItem(new Menu(" Back", main_menu, ui)); |
ovidiup13 | 0:1e597b0f8b3b | 55 | |
ovidiup13 | 0:1e597b0f8b3b | 56 | //add menus to main menu |
ovidiup13 | 2:fcde41900fa5 | 57 | main_menu->addItem(distance); |
ovidiup13 | 2:fcde41900fa5 | 58 | main_menu->addItem(p2p); |
ovidiup13 | 2:fcde41900fa5 | 59 | main_menu->addItem(lvlm); |
ovidiup13 | 0:1e597b0f8b3b | 60 | main_menu->addItem(compass); |
ovidiup13 | 2:fcde41900fa5 | 61 | main_menu->addItem(thermo); |
ovidiup13 | 0:1e597b0f8b3b | 62 | main_menu->addItem(settings); |
ovidiup13 | 2:fcde41900fa5 | 63 | |
ovidiup13 | 2:fcde41900fa5 | 64 | //create header object |
ovidiup13 | 2:fcde41900fa5 | 65 | Header * header = new Header(70, "", &st7565); |
ovidiup13 | 2:fcde41900fa5 | 66 | |
ovidiup13 | 2:fcde41900fa5 | 67 | //set header and current menu |
ovidiup13 | 2:fcde41900fa5 | 68 | ui->setCurrent(main_menu); |
ovidiup13 | 2:fcde41900fa5 | 69 | header->setTitle(main_menu->getTitle()); |
ovidiup13 | 2:fcde41900fa5 | 70 | ui->setHeader(header); |
ovidiup13 | 2:fcde41900fa5 | 71 | |
ovidiup13 | 2:fcde41900fa5 | 72 | //initialize the display |
ovidiup13 | 2:fcde41900fa5 | 73 | ui->init(); |
ovidiup13 | 0:1e597b0f8b3b | 74 | |
ovidiup13 | 0:1e597b0f8b3b | 75 | while(1) { |
ovidiup13 | 2:fcde41900fa5 | 76 | if(down){ |
ovidiup13 | 2:fcde41900fa5 | 77 | ui->update('s'); |
ovidiup13 | 2:fcde41900fa5 | 78 | wait(0.2); |
ovidiup13 | 2:fcde41900fa5 | 79 | } |
ovidiup13 | 2:fcde41900fa5 | 80 | else if(select){ |
ovidiup13 | 2:fcde41900fa5 | 81 | ui->update('y'); |
ovidiup13 | 2:fcde41900fa5 | 82 | wait(0.2); |
ovidiup13 | 2:fcde41900fa5 | 83 | } |
ovidiup13 | 2:fcde41900fa5 | 84 | /* |
ovidiup13 | 2:fcde41900fa5 | 85 | else{ |
ovidiup13 | 2:fcde41900fa5 | 86 | char c = pc.getc(); |
ovidiup13 | 2:fcde41900fa5 | 87 | ui->update(c); |
ovidiup13 | 2:fcde41900fa5 | 88 | } |
ovidiup13 | 2:fcde41900fa5 | 89 | */ |
ovidiup13 | 0:1e597b0f8b3b | 90 | } |
ovidiup13 | 0:1e597b0f8b3b | 91 | } |