Team Alpha / Mbed 2 deprecated UserIntefaceLCD

Dependencies:   mbed mbed-rtos MLX90614

Committer:
ovidiup13
Date:
Thu May 28 16:07:00 2015 +0000
Revision:
5:5b1a8ad6c187
Parent:
4:024e6a9c2ebf
Child:
6:49a007861c76
added levelmeter functionality and threading

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