LCD implementation of our project.
Dependencies: mbed mbed-rtos MLX90614
main.cpp@3:688b62ff6474, 2015-04-26 (annotated)
- Committer:
- ovidiup13
- Date:
- Sun Apr 26 16:29:53 2015 +0000
- Revision:
- 3:688b62ff6474
- Parent:
- 2:fcde41900fa5
- Child:
- 4:024e6a9c2ebf
added screens for interacting with other components. i.e. distance, thermo, gyro, compass, etc. Need to complete settings screen and create threads for interacting with other code
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 | 3:688b62ff6474 | 24 | Menu * main_menu = new Menu(" Main Menu", &st7565); |
ovidiup13 | 3:688b62ff6474 | 25 | |
ovidiup13 | 3:688b62ff6474 | 26 | //create distance screens |
ovidiup13 | 3:688b62ff6474 | 27 | Measure *distance = new Measure(" Distance", &st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 28 | distance->setDescription("Select Start from the menu below to start laser."); |
ovidiup13 | 3:688b62ff6474 | 29 | Measure *distance2 = new Measure(" Distance", &st7565, distance); |
ovidiup13 | 3:688b62ff6474 | 30 | distance2->setDescription("Press select button to fix target."); |
ovidiup13 | 3:688b62ff6474 | 31 | Measure *distance3 = new Measure(" Distance", &st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 32 | distance3->setDescription("Distance to target is:"); |
ovidiup13 | 3:688b62ff6474 | 33 | distance3->setResult(true); |
ovidiup13 | 3:688b62ff6474 | 34 | |
ovidiup13 | 3:688b62ff6474 | 35 | distance->setNext(" Start", distance2); |
ovidiup13 | 3:688b62ff6474 | 36 | distance2->setNext(" Select", distance3); |
ovidiup13 | 3:688b62ff6474 | 37 | distance3->setNext(" Start again", distance); |
ovidiup13 | 3:688b62ff6474 | 38 | main_menu->addItem(distance); |
ovidiup13 | 0:1e597b0f8b3b | 39 | |
ovidiup13 | 3:688b62ff6474 | 40 | //create point-to-point screens |
ovidiup13 | 3:688b62ff6474 | 41 | Measure *p2p = new Measure(" Point-to-Point", &st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 42 | p2p->setDescription("Select Start from the menu to start laser for #1 target."); |
ovidiup13 | 3:688b62ff6474 | 43 | Measure *p2p2 = new Measure(" Point-to-Point", &st7565, p2p); |
ovidiup13 | 3:688b62ff6474 | 44 | p2p2->setDescription("Press select button to fix target #1."); |
ovidiup13 | 3:688b62ff6474 | 45 | Measure *p2p3 = new Measure(" Point-to-Point", &st7565, p2p2); |
ovidiup13 | 3:688b62ff6474 | 46 | p2p3->setDescription("Press select button to fix target #2."); |
ovidiup13 | 3:688b62ff6474 | 47 | Measure *p2p4 = new Measure(" Point-to-Point", &st7565, p2p3); |
ovidiup13 | 3:688b62ff6474 | 48 | p2p4->setDescription("Distance between targets is:"); |
ovidiup13 | 3:688b62ff6474 | 49 | p2p4->setResult(true); //result screen |
ovidiup13 | 0:1e597b0f8b3b | 50 | |
ovidiup13 | 3:688b62ff6474 | 51 | p2p->setNext(" Start", p2p2); |
ovidiup13 | 3:688b62ff6474 | 52 | p2p2->setNext(" Select", p2p3); |
ovidiup13 | 3:688b62ff6474 | 53 | p2p3->setNext(" Select", p2p4); |
ovidiup13 | 3:688b62ff6474 | 54 | p2p4->setNext(" Start again", p2p); |
ovidiup13 | 3:688b62ff6474 | 55 | main_menu->addItem(p2p); |
ovidiup13 | 0:1e597b0f8b3b | 56 | |
ovidiup13 | 2:fcde41900fa5 | 57 | //create level meter screen |
ovidiup13 | 3:688b62ff6474 | 58 | LevelMeter *lvl = new LevelMeter(&st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 59 | main_menu->addItem(lvl); |
ovidiup13 | 0:1e597b0f8b3b | 60 | |
ovidiup13 | 2:fcde41900fa5 | 61 | //create compass screen |
ovidiup13 | 3:688b62ff6474 | 62 | Compass *compass = new Compass(&st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 63 | main_menu->addItem(compass); |
ovidiup13 | 2:fcde41900fa5 | 64 | |
ovidiup13 | 3:688b62ff6474 | 65 | //create thermo screen |
ovidiup13 | 3:688b62ff6474 | 66 | Measure *thermo = new Measure(" Thermometer", &st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 67 | thermo->setDescription("Press Start from the menu to start laser."); |
ovidiup13 | 3:688b62ff6474 | 68 | Measure *thermo2 = new Measure(" Thermometer", &st7565, thermo); |
ovidiup13 | 3:688b62ff6474 | 69 | thermo2->setDescription("Press select button to fix target."); |
ovidiup13 | 3:688b62ff6474 | 70 | Measure *thermo3 = new Measure(" Thermometer", &st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 71 | thermo3->setDescription("Target temperature is:"); |
ovidiup13 | 3:688b62ff6474 | 72 | thermo3->setResult(true); |
ovidiup13 | 3:688b62ff6474 | 73 | |
ovidiup13 | 3:688b62ff6474 | 74 | thermo->setNext(" Start", thermo2); |
ovidiup13 | 3:688b62ff6474 | 75 | thermo2->setNext(" Start", thermo3); |
ovidiup13 | 3:688b62ff6474 | 76 | thermo3->setNext(" Start", thermo); |
ovidiup13 | 3:688b62ff6474 | 77 | main_menu->addItem(thermo); |
ovidiup13 | 2:fcde41900fa5 | 78 | |
ovidiup13 | 2:fcde41900fa5 | 79 | //create settings menu |
ovidiup13 | 3:688b62ff6474 | 80 | Menu *settings = new Menu(" Settings", &st7565); |
ovidiup13 | 0:1e597b0f8b3b | 81 | main_menu->addItem(settings); |
ovidiup13 | 2:fcde41900fa5 | 82 | |
ovidiup13 | 2:fcde41900fa5 | 83 | //create header object |
ovidiup13 | 2:fcde41900fa5 | 84 | Header * header = new Header(70, "", &st7565); |
ovidiup13 | 2:fcde41900fa5 | 85 | |
ovidiup13 | 2:fcde41900fa5 | 86 | //set header and current menu |
ovidiup13 | 2:fcde41900fa5 | 87 | ui->setCurrent(main_menu); |
ovidiup13 | 2:fcde41900fa5 | 88 | ui->setHeader(header); |
ovidiup13 | 2:fcde41900fa5 | 89 | ui->init(); |
ovidiup13 | 0:1e597b0f8b3b | 90 | |
ovidiup13 | 0:1e597b0f8b3b | 91 | while(1) { |
ovidiup13 | 2:fcde41900fa5 | 92 | if(down){ |
ovidiup13 | 2:fcde41900fa5 | 93 | ui->update('s'); |
ovidiup13 | 2:fcde41900fa5 | 94 | wait(0.2); |
ovidiup13 | 2:fcde41900fa5 | 95 | } |
ovidiup13 | 2:fcde41900fa5 | 96 | else if(select){ |
ovidiup13 | 2:fcde41900fa5 | 97 | ui->update('y'); |
ovidiup13 | 2:fcde41900fa5 | 98 | wait(0.2); |
ovidiup13 | 2:fcde41900fa5 | 99 | } |
ovidiup13 | 2:fcde41900fa5 | 100 | /* |
ovidiup13 | 2:fcde41900fa5 | 101 | else{ |
ovidiup13 | 2:fcde41900fa5 | 102 | char c = pc.getc(); |
ovidiup13 | 2:fcde41900fa5 | 103 | ui->update(c); |
ovidiup13 | 2:fcde41900fa5 | 104 | } |
ovidiup13 | 2:fcde41900fa5 | 105 | */ |
ovidiup13 | 0:1e597b0f8b3b | 106 | } |
ovidiup13 | 0:1e597b0f8b3b | 107 | } |