LCD implementation of our project.
Dependencies: mbed mbed-rtos MLX90614
main.cpp@7:11675c1dce4f, 2015-06-03 (annotated)
- Committer:
- ovidiup13
- Date:
- Wed Jun 03 12:22:46 2015 +0000
- Revision:
- 7:11675c1dce4f
- Parent:
- 6:49a007861c76
- Child:
- 8:81ed1135ba02
updated header, cleaned up menu, fixed controls for device
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 | 7:11675c1dce4f | 4 | #define WAIT_TIME 0.3 |
ovidiup13 | 7:11675c1dce4f | 5 | |
ovidiup13 | 0:1e597b0f8b3b | 6 | ST7565 st7565(_MOSI, _SCLK, _CS, _RST, _A0); // mosi, sclk, cs, rst, a0 |
ovidiup13 | 0:1e597b0f8b3b | 7 | Serial pc(USBTX, USBRX); //rx, tx |
ovidiup13 | 0:1e597b0f8b3b | 8 | |
ovidiup13 | 2:fcde41900fa5 | 9 | //buttons |
ovidiup13 | 7:11675c1dce4f | 10 | DigitalIn down(p19); |
ovidiup13 | 7:11675c1dce4f | 11 | DigitalIn select(p22); |
ovidiup13 | 6:49a007861c76 | 12 | DigitalIn up(p20); |
ovidiup13 | 2:fcde41900fa5 | 13 | |
ovidiup13 | 6:49a007861c76 | 14 | int main(){ |
ovidiup13 | 6:49a007861c76 | 15 | //create god UI object |
ovidiup13 | 6:49a007861c76 | 16 | UI * ui = new UI(&st7565); |
ovidiup13 | 6:49a007861c76 | 17 | //initialize configuration |
ovidiup13 | 0:1e597b0f8b3b | 18 | //create main menu |
ovidiup13 | 3:688b62ff6474 | 19 | Menu * main_menu = new Menu(" Main Menu", &st7565); |
ovidiup13 | 3:688b62ff6474 | 20 | |
ovidiup13 | 6:49a007861c76 | 21 | |
ovidiup13 | 3:688b62ff6474 | 22 | //create distance screens |
ovidiup13 | 3:688b62ff6474 | 23 | Measure *distance = new Measure(" Distance", &st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 24 | distance->setDescription("Select Start from the menu below to start laser."); |
ovidiup13 | 3:688b62ff6474 | 25 | Measure *distance2 = new Measure(" Distance", &st7565, distance); |
ovidiup13 | 3:688b62ff6474 | 26 | distance2->setDescription("Press select button to fix target."); |
ovidiup13 | 3:688b62ff6474 | 27 | Measure *distance3 = new Measure(" Distance", &st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 28 | distance3->setDescription("Distance to target is:"); |
ovidiup13 | 3:688b62ff6474 | 29 | distance3->setResult(true); |
ovidiup13 | 3:688b62ff6474 | 30 | |
ovidiup13 | 3:688b62ff6474 | 31 | distance->setNext(" Start", distance2); |
ovidiup13 | 3:688b62ff6474 | 32 | distance2->setNext(" Select", distance3); |
ovidiup13 | 3:688b62ff6474 | 33 | distance3->setNext(" Start again", distance); |
ovidiup13 | 3:688b62ff6474 | 34 | main_menu->addItem(distance); |
ovidiup13 | 0:1e597b0f8b3b | 35 | |
ovidiup13 | 3:688b62ff6474 | 36 | //create point-to-point screens |
ovidiup13 | 3:688b62ff6474 | 37 | Measure *p2p = new Measure(" Point-to-Point", &st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 38 | p2p->setDescription("Select Start from the menu to start laser for #1 target."); |
ovidiup13 | 3:688b62ff6474 | 39 | Measure *p2p2 = new Measure(" Point-to-Point", &st7565, p2p); |
ovidiup13 | 3:688b62ff6474 | 40 | p2p2->setDescription("Press select button to fix target #1."); |
ovidiup13 | 3:688b62ff6474 | 41 | Measure *p2p3 = new Measure(" Point-to-Point", &st7565, p2p2); |
ovidiup13 | 3:688b62ff6474 | 42 | p2p3->setDescription("Press select button to fix target #2."); |
ovidiup13 | 3:688b62ff6474 | 43 | Measure *p2p4 = new Measure(" Point-to-Point", &st7565, p2p3); |
ovidiup13 | 3:688b62ff6474 | 44 | p2p4->setDescription("Distance between targets is:"); |
ovidiup13 | 3:688b62ff6474 | 45 | p2p4->setResult(true); //result screen |
ovidiup13 | 0:1e597b0f8b3b | 46 | |
ovidiup13 | 3:688b62ff6474 | 47 | p2p->setNext(" Start", p2p2); |
ovidiup13 | 3:688b62ff6474 | 48 | p2p2->setNext(" Select", p2p3); |
ovidiup13 | 3:688b62ff6474 | 49 | p2p3->setNext(" Select", p2p4); |
ovidiup13 | 3:688b62ff6474 | 50 | p2p4->setNext(" Start again", p2p); |
ovidiup13 | 3:688b62ff6474 | 51 | main_menu->addItem(p2p); |
ovidiup13 | 0:1e597b0f8b3b | 52 | |
ovidiup13 | 2:fcde41900fa5 | 53 | //create level meter screen |
ovidiup13 | 3:688b62ff6474 | 54 | LevelMeter *lvl = new LevelMeter(&st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 55 | main_menu->addItem(lvl); |
ovidiup13 | 0:1e597b0f8b3b | 56 | |
ovidiup13 | 2:fcde41900fa5 | 57 | //create compass screen |
ovidiup13 | 3:688b62ff6474 | 58 | Compass *compass = new Compass(&st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 59 | main_menu->addItem(compass); |
ovidiup13 | 2:fcde41900fa5 | 60 | |
ovidiup13 | 3:688b62ff6474 | 61 | //create thermo screen |
ovidiup13 | 3:688b62ff6474 | 62 | Measure *thermo = new Measure(" Thermometer", &st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 63 | thermo->setDescription("Press Start from the menu to start laser."); |
ovidiup13 | 3:688b62ff6474 | 64 | Measure *thermo2 = new Measure(" Thermometer", &st7565, thermo); |
ovidiup13 | 3:688b62ff6474 | 65 | thermo2->setDescription("Press select button to fix target."); |
ovidiup13 | 3:688b62ff6474 | 66 | Measure *thermo3 = new Measure(" Thermometer", &st7565, main_menu); |
ovidiup13 | 3:688b62ff6474 | 67 | thermo3->setDescription("Target temperature is:"); |
ovidiup13 | 3:688b62ff6474 | 68 | thermo3->setResult(true); |
ovidiup13 | 3:688b62ff6474 | 69 | |
ovidiup13 | 3:688b62ff6474 | 70 | thermo->setNext(" Start", thermo2); |
ovidiup13 | 3:688b62ff6474 | 71 | thermo2->setNext(" Start", thermo3); |
ovidiup13 | 3:688b62ff6474 | 72 | thermo3->setNext(" Start", thermo); |
ovidiup13 | 3:688b62ff6474 | 73 | main_menu->addItem(thermo); |
ovidiup13 | 2:fcde41900fa5 | 74 | |
ovidiup13 | 2:fcde41900fa5 | 75 | //create header object |
ovidiup13 | 7:11675c1dce4f | 76 | Header * header = new Header("", &st7565); |
ovidiup13 | 2:fcde41900fa5 | 77 | |
ovidiup13 | 2:fcde41900fa5 | 78 | //set header and current menu |
ovidiup13 | 2:fcde41900fa5 | 79 | ui->setCurrent(main_menu); |
ovidiup13 | 2:fcde41900fa5 | 80 | ui->setHeader(header); |
ovidiup13 | 2:fcde41900fa5 | 81 | ui->init(); |
ovidiup13 | 0:1e597b0f8b3b | 82 | |
ovidiup13 | 0:1e597b0f8b3b | 83 | while(1) { |
ovidiup13 | 7:11675c1dce4f | 84 | if(select){ |
ovidiup13 | 7:11675c1dce4f | 85 | wait(0.1); |
ovidiup13 | 7:11675c1dce4f | 86 | printf("select\n"); |
ovidiup13 | 6:49a007861c76 | 87 | ui->update('y'); //ascii 121 |
ovidiup13 | 7:11675c1dce4f | 88 | wait(WAIT_TIME); |
ovidiup13 | 2:fcde41900fa5 | 89 | } |
ovidiup13 | 7:11675c1dce4f | 90 | else if(up){ |
ovidiup13 | 7:11675c1dce4f | 91 | wait(0.1); |
ovidiup13 | 7:11675c1dce4f | 92 | printf("up\n"); |
ovidiup13 | 6:49a007861c76 | 93 | ui->update('w'); //ascii 119 |
ovidiup13 | 7:11675c1dce4f | 94 | wait(WAIT_TIME); |
ovidiup13 | 7:11675c1dce4f | 95 | } |
ovidiup13 | 7:11675c1dce4f | 96 | else if(down){ |
ovidiup13 | 7:11675c1dce4f | 97 | wait(0.1); |
ovidiup13 | 7:11675c1dce4f | 98 | printf("down\n"); |
ovidiup13 | 7:11675c1dce4f | 99 | ui->update('s'); //ascii 115 |
ovidiup13 | 7:11675c1dce4f | 100 | wait(WAIT_TIME); |
ovidiup13 | 2:fcde41900fa5 | 101 | } |
ovidiup13 | 0:1e597b0f8b3b | 102 | } |
ovidiup13 | 0:1e597b0f8b3b | 103 | } |