LCD implementation of our project.

Dependencies:   mbed mbed-rtos MLX90614

Committer:
ovidiup13
Date:
Wed Jun 03 16:37:21 2015 +0000
Revision:
8:81ed1135ba02
Parent:
7:11675c1dce4f
Child:
9:4bed81856c2f
done something, idk what

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 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 8:81ed1135ba02 14 //laser
ovidiup13 8:81ed1135ba02 15 DigitalOut laser_mod(p21, 0);
ovidiup13 8:81ed1135ba02 16
ovidiup13 8:81ed1135ba02 17 //gyro and thermo digital out
ovidiup13 8:81ed1135ba02 18 DigitalOut gyro(P0_29, 0); //pin31
ovidiup13 8:81ed1135ba02 19 DigitalOut thermo(P0_30, 0); //pin32
ovidiup13 8:81ed1135ba02 20
ovidiup13 6:49a007861c76 21 int main(){
ovidiup13 6:49a007861c76 22 //create god UI object
ovidiup13 6:49a007861c76 23 UI * ui = new UI(&st7565);
ovidiup13 6:49a007861c76 24 //initialize configuration
ovidiup13 0:1e597b0f8b3b 25 //create main menu
ovidiup13 3:688b62ff6474 26 Menu * main_menu = new Menu(" Main Menu", &st7565);
ovidiup13 3:688b62ff6474 27
ovidiup13 6:49a007861c76 28
ovidiup13 3:688b62ff6474 29 //create distance screens
ovidiup13 8:81ed1135ba02 30 Measure *distance = new Measure(" Distance", &st7565, main_menu, &laser_mod);
ovidiup13 8:81ed1135ba02 31 distance->setDescription("Select Start from the menu below to start laser.");
ovidiup13 3:688b62ff6474 32 main_menu->addItem(distance);
ovidiup13 0:1e597b0f8b3b 33
ovidiup13 8:81ed1135ba02 34 /*
ovidiup13 3:688b62ff6474 35 //create point-to-point screens
ovidiup13 3:688b62ff6474 36 Measure *p2p = new Measure(" Point-to-Point", &st7565, main_menu);
ovidiup13 3:688b62ff6474 37 p2p->setDescription("Select Start from the menu to start laser for #1 target.");
ovidiup13 3:688b62ff6474 38 Measure *p2p2 = new Measure(" Point-to-Point", &st7565, p2p);
ovidiup13 3:688b62ff6474 39 p2p2->setDescription("Press select button to fix target #1.");
ovidiup13 3:688b62ff6474 40 Measure *p2p3 = new Measure(" Point-to-Point", &st7565, p2p2);
ovidiup13 3:688b62ff6474 41 p2p3->setDescription("Press select button to fix target #2.");
ovidiup13 3:688b62ff6474 42 Measure *p2p4 = new Measure(" Point-to-Point", &st7565, p2p3);
ovidiup13 3:688b62ff6474 43 p2p4->setDescription("Distance between targets is:");
ovidiup13 3:688b62ff6474 44 p2p4->setResult(true); //result screen
ovidiup13 0:1e597b0f8b3b 45
ovidiup13 3:688b62ff6474 46 p2p->setNext(" Start", p2p2);
ovidiup13 3:688b62ff6474 47 p2p2->setNext(" Select", p2p3);
ovidiup13 3:688b62ff6474 48 p2p3->setNext(" Select", p2p4);
ovidiup13 3:688b62ff6474 49 p2p4->setNext(" Start again", p2p);
ovidiup13 3:688b62ff6474 50 main_menu->addItem(p2p);
ovidiup13 8:81ed1135ba02 51 */
ovidiup13 0:1e597b0f8b3b 52
ovidiup13 2:fcde41900fa5 53 //create level meter screen
ovidiup13 8:81ed1135ba02 54 LevelMeter *lvl = new LevelMeter(&st7565, main_menu, &gyro, &thermo);
ovidiup13 3:688b62ff6474 55 main_menu->addItem(lvl);
ovidiup13 0:1e597b0f8b3b 56
ovidiup13 2:fcde41900fa5 57 //create compass screen
ovidiup13 8:81ed1135ba02 58 Compass *compass = new Compass(&st7565, main_menu, &gyro, &thermo);
ovidiup13 3:688b62ff6474 59 main_menu->addItem(compass);
ovidiup13 2:fcde41900fa5 60
ovidiup13 3:688b62ff6474 61 //create thermo screen
ovidiup13 8:81ed1135ba02 62 Thermometer *thermo_screen = new Thermometer(&st7565, main_menu, &gyro, &thermo);
ovidiup13 8:81ed1135ba02 63 main_menu->addItem(thermo_screen);
ovidiup13 8:81ed1135ba02 64
ovidiup13 8:81ed1135ba02 65 /*
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 8:81ed1135ba02 77 */
ovidiup13 2:fcde41900fa5 78
ovidiup13 2:fcde41900fa5 79 //create header object
ovidiup13 7:11675c1dce4f 80 Header * header = new Header("", &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 0:1e597b0f8b3b 86
ovidiup13 0:1e597b0f8b3b 87 while(1) {
ovidiup13 7:11675c1dce4f 88 if(select){
ovidiup13 7:11675c1dce4f 89 wait(0.1);
ovidiup13 8:81ed1135ba02 90 //printf("select\n");
ovidiup13 6:49a007861c76 91 ui->update('y'); //ascii 121
ovidiup13 7:11675c1dce4f 92 wait(WAIT_TIME);
ovidiup13 2:fcde41900fa5 93 }
ovidiup13 7:11675c1dce4f 94 else if(up){
ovidiup13 7:11675c1dce4f 95 wait(0.1);
ovidiup13 8:81ed1135ba02 96 //printf("up\n");
ovidiup13 6:49a007861c76 97 ui->update('w'); //ascii 119
ovidiup13 7:11675c1dce4f 98 wait(WAIT_TIME);
ovidiup13 7:11675c1dce4f 99 }
ovidiup13 7:11675c1dce4f 100 else if(down){
ovidiup13 7:11675c1dce4f 101 wait(0.1);
ovidiup13 8:81ed1135ba02 102 //printf("down\n");
ovidiup13 7:11675c1dce4f 103 ui->update('s'); //ascii 115
ovidiup13 7:11675c1dce4f 104 wait(WAIT_TIME);
ovidiup13 2:fcde41900fa5 105 }
ovidiup13 0:1e597b0f8b3b 106 }
ovidiup13 0:1e597b0f8b3b 107 }