LCD implementation of our project.

Dependencies:   mbed mbed-rtos MLX90614

Committer:
ovidiup13
Date:
Sat May 30 14:58:44 2015 +0000
Revision:
6:49a007861c76
Parent:
5:5b1a8ad6c187
Child:
7:11675c1dce4f
integrated level meter functionality and added 3-way switch control

Who changed what in which revision?

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