Team Alpha / Mbed 2 deprecated UserIntefaceLCD

Dependencies:   mbed mbed-rtos MLX90614

Committer:
ovidiup13
Date:
Mon May 25 14:46:39 2015 +0000
Revision:
4:024e6a9c2ebf
Parent:
3:688b62ff6474
Child:
5:5b1a8ad6c187
updated compass with 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 4:024e6a9c2ebf 5 #define _MOSI p5
ovidiup13 4:024e6a9c2ebf 6 #define _SCLK p7
ovidiup13 4:024e6a9c2ebf 7 #define _RST p24
ovidiup13 4:024e6a9c2ebf 8 #define _A0 p8
ovidiup13 4:024e6a9c2ebf 9 #define _CS p6
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 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 settings menu
ovidiup13 3:688b62ff6474 76 Menu *settings = new Menu(" Settings", &st7565);
ovidiup13 0:1e597b0f8b3b 77 main_menu->addItem(settings);
ovidiup13 2:fcde41900fa5 78
ovidiup13 2:fcde41900fa5 79 //create header object
ovidiup13 2:fcde41900fa5 80 Header * header = new Header(70, "", &st7565);
ovidiup13 2:fcde41900fa5 81
ovidiup13 2:fcde41900fa5 82 //set header and current menu
ovidiup13 2:fcde41900fa5 83 ui->setCurrent(main_menu);
ovidiup13 2:fcde41900fa5 84 ui->setHeader(header);
ovidiup13 2:fcde41900fa5 85 ui->init();
ovidiup13 4:024e6a9c2ebf 86 }
ovidiup13 4:024e6a9c2ebf 87
ovidiup13 4:024e6a9c2ebf 88 int main(){
ovidiup13 4:024e6a9c2ebf 89 //create god UI object
ovidiup13 4:024e6a9c2ebf 90 UI * ui = new UI(&st7565);
ovidiup13 4:024e6a9c2ebf 91 //initialize configuration
ovidiup13 4:024e6a9c2ebf 92 init_config(ui);
ovidiup13 0:1e597b0f8b3b 93
ovidiup13 0:1e597b0f8b3b 94 while(1) {
ovidiup13 2:fcde41900fa5 95 if(down){
ovidiup13 2:fcde41900fa5 96 ui->update('s');
ovidiup13 2:fcde41900fa5 97 wait(0.2);
ovidiup13 2:fcde41900fa5 98 }
ovidiup13 2:fcde41900fa5 99 else if(select){
ovidiup13 2:fcde41900fa5 100 ui->update('y');
ovidiup13 2:fcde41900fa5 101 wait(0.2);
ovidiup13 2:fcde41900fa5 102 }
ovidiup13 2:fcde41900fa5 103 /*
ovidiup13 2:fcde41900fa5 104 else{
ovidiup13 2:fcde41900fa5 105 char c = pc.getc();
ovidiup13 2:fcde41900fa5 106 ui->update(c);
ovidiup13 2:fcde41900fa5 107 }
ovidiup13 2:fcde41900fa5 108 */
ovidiup13 0:1e597b0f8b3b 109 }
ovidiup13 0:1e597b0f8b3b 110 }