Breathalyzer running on the MBED 1768 Platform; EE4427 Group 3 Spring 2018

Dependencies:   4DGL-uLCD-SE mbed

Committer:
phred754
Date:
Mon Apr 23 22:18:27 2018 +0000
Revision:
0:35f90b280233
EE4427 Final Project Group 3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phred754 0:35f90b280233 1 //Written by Todd Clark
phred754 0:35f90b280233 2 #include "lcdOut.h"
phred754 0:35f90b280233 3
phred754 0:35f90b280233 4 uLCD_4DGL uLCD(p9,p10,p11); //Set up serial bus for LCD screen as an object using code library for LCD from https://os.mbed.com/users/sparkfun/code/4DGL-uLCD-SE/
phred754 0:35f90b280233 5 int textSize;
phred754 0:35f90b280233 6 float legalLimit;
phred754 0:35f90b280233 7
phred754 0:35f90b280233 8 void resetDisplay(){
phred754 0:35f90b280233 9 uLCD.background_color(BLACK);
phred754 0:35f90b280233 10 uLCD.cls();
phred754 0:35f90b280233 11 uLCD.textbackground_color(BLACK);
phred754 0:35f90b280233 12 displayStart();
phred754 0:35f90b280233 13 }
phred754 0:35f90b280233 14
phred754 0:35f90b280233 15 void displayTest(float out, bool isUtahMode){
phred754 0:35f90b280233 16 legalLimit = (isUtahMode) ? 0.05 : 0.08;
phred754 0:35f90b280233 17
phred754 0:35f90b280233 18 uLCD.baudrate(115200);
phred754 0:35f90b280233 19 uLCD.background_color(WHITE);
phred754 0:35f90b280233 20 uLCD.cls();
phred754 0:35f90b280233 21 uLCD.textbackground_color(WHITE);
phred754 0:35f90b280233 22
phred754 0:35f90b280233 23 textSize = 1;
phred754 0:35f90b280233 24 uLCD.locate(0, 1);
phred754 0:35f90b280233 25 uLCD.text_width(textSize);
phred754 0:35f90b280233 26 uLCD.text_height(textSize);
phred754 0:35f90b280233 27 uLCD.color(BLACK);
phred754 0:35f90b280233 28 uLCD.printf("Your BAC is:%.2f", out);
phred754 0:35f90b280233 29
phred754 0:35f90b280233 30 uLCD.locate(0, 3);
phred754 0:35f90b280233 31 uLCD.printf("The maximum legal limit is %.2f", legalLimit);
phred754 0:35f90b280233 32
phred754 0:35f90b280233 33 uLCD.locate(0, 6);
phred754 0:35f90b280233 34 if (out < legalLimit){
phred754 0:35f90b280233 35 uLCD.color(BLUE);
phred754 0:35f90b280233 36 uLCD.printf("You are under the legal limit.", legalLimit);
phred754 0:35f90b280233 37 }
phred754 0:35f90b280233 38 else{
phred754 0:35f90b280233 39 uLCD.color(RED);
phred754 0:35f90b280233 40 uLCD.printf("You are drunk! \nDo not Drive!");
phred754 0:35f90b280233 41 }
phred754 0:35f90b280233 42 }
phred754 0:35f90b280233 43
phred754 0:35f90b280233 44 void displayStart(){
phred754 0:35f90b280233 45 textSize = 1;
phred754 0:35f90b280233 46 uLCD.locate(3, 1);
phred754 0:35f90b280233 47 uLCD.text_width(textSize);
phred754 0:35f90b280233 48 uLCD.text_height(textSize);
phred754 0:35f90b280233 49 uLCD.color(RED);
phred754 0:35f90b280233 50 uLCD.printf("Breathalyzer \n");
phred754 0:35f90b280233 51
phred754 0:35f90b280233 52 uLCD.locate(0, 3);
phred754 0:35f90b280233 53 uLCD.text_width(textSize);
phred754 0:35f90b280233 54 uLCD.text_height(textSize);
phred754 0:35f90b280233 55 uLCD.color(BLUE);
phred754 0:35f90b280233 56 uLCD.printf("Press button to \nconduct test\n");
phred754 0:35f90b280233 57 }
phred754 0:35f90b280233 58
phred754 0:35f90b280233 59 void displayOut(float out, bool isUtahMode){
phred754 0:35f90b280233 60 if(out == -1.0){
phred754 0:35f90b280233 61 displayStart();
phred754 0:35f90b280233 62 }
phred754 0:35f90b280233 63 else{
phred754 0:35f90b280233 64 displayTest(out, isUtahMode);
phred754 0:35f90b280233 65 }
phred754 0:35f90b280233 66 }