LCD implementation of our project.

Dependencies:   mbed mbed-rtos MLX90614

Committer:
ovidiup13
Date:
Wed Jun 03 17:42:47 2015 +0000
Revision:
10:97389d774ae1
Parent:
9:4bed81856c2f
working version, comment out thermo in main;

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 10:97389d774ae1 61 /*
ovidiup13 3:688b62ff6474 62 //create thermo screen
ovidiup13 8:81ed1135ba02 63 Thermometer *thermo_screen = new Thermometer(&st7565, main_menu, &gyro, &thermo);
ovidiup13 8:81ed1135ba02 64 main_menu->addItem(thermo_screen);
ovidiup13 10:97389d774ae1 65 */
ovidiup13 8:81ed1135ba02 66
ovidiup13 8:81ed1135ba02 67 /*
ovidiup13 3:688b62ff6474 68 Measure *thermo = new Measure(" Thermometer", &st7565, main_menu);
ovidiup13 3:688b62ff6474 69 thermo->setDescription("Press Start from the menu to start laser.");
ovidiup13 3:688b62ff6474 70 Measure *thermo2 = new Measure(" Thermometer", &st7565, thermo);
ovidiup13 3:688b62ff6474 71 thermo2->setDescription("Press select button to fix target.");
ovidiup13 3:688b62ff6474 72 Measure *thermo3 = new Measure(" Thermometer", &st7565, main_menu);
ovidiup13 3:688b62ff6474 73 thermo3->setDescription("Target temperature is:");
ovidiup13 3:688b62ff6474 74 thermo3->setResult(true);
ovidiup13 3:688b62ff6474 75
ovidiup13 3:688b62ff6474 76 thermo->setNext(" Start", thermo2);
ovidiup13 3:688b62ff6474 77 thermo2->setNext(" Start", thermo3);
ovidiup13 3:688b62ff6474 78 thermo3->setNext(" Start", thermo);
ovidiup13 8:81ed1135ba02 79 */
ovidiup13 2:fcde41900fa5 80
ovidiup13 2:fcde41900fa5 81 //create header object
ovidiup13 7:11675c1dce4f 82 Header * header = new Header("", &st7565);
ovidiup13 2:fcde41900fa5 83
ovidiup13 2:fcde41900fa5 84 //set header and current menu
ovidiup13 2:fcde41900fa5 85 ui->setCurrent(main_menu);
ovidiup13 2:fcde41900fa5 86 ui->setHeader(header);
ovidiup13 2:fcde41900fa5 87 ui->init();
ovidiup13 0:1e597b0f8b3b 88
ovidiup13 0:1e597b0f8b3b 89 while(1) {
ovidiup13 7:11675c1dce4f 90 if(select){
ovidiup13 7:11675c1dce4f 91 wait(0.1);
ovidiup13 8:81ed1135ba02 92 //printf("select\n");
ovidiup13 6:49a007861c76 93 ui->update('y'); //ascii 121
ovidiup13 7:11675c1dce4f 94 wait(WAIT_TIME);
ovidiup13 2:fcde41900fa5 95 }
ovidiup13 7:11675c1dce4f 96 else if(up){
ovidiup13 7:11675c1dce4f 97 wait(0.1);
ovidiup13 8:81ed1135ba02 98 //printf("up\n");
ovidiup13 6:49a007861c76 99 ui->update('w'); //ascii 119
ovidiup13 7:11675c1dce4f 100 wait(WAIT_TIME);
ovidiup13 7:11675c1dce4f 101 }
ovidiup13 7:11675c1dce4f 102 else if(down){
ovidiup13 7:11675c1dce4f 103 wait(0.1);
ovidiup13 8:81ed1135ba02 104 //printf("down\n");
ovidiup13 7:11675c1dce4f 105 ui->update('s'); //ascii 115
ovidiup13 7:11675c1dce4f 106 wait(WAIT_TIME);
ovidiup13 2:fcde41900fa5 107 }
ovidiup13 0:1e597b0f8b3b 108 }
ovidiup13 0:1e597b0f8b3b 109 }