Uses the SRF02 UDS and displays distance in a variety of ways on the N5110 LCD.
Dependencies: N5110WN PowerControl SRF02 mbed
main.cpp@11:2b3d646e3bfb, 2015-05-08 (annotated)
- Committer:
- JakBlackburn
- Date:
- Fri May 08 09:08:25 2015 +0000
- Revision:
- 11:2b3d646e3bfb
- Parent:
- 10:a32b1216d4ed
updated docs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JakBlackburn | 1:7f151ab172cb | 1 | /** |
JakBlackburn | 1:7f151ab172cb | 2 | @file main.cpp |
JakBlackburn | 1:7f151ab172cb | 3 | @brief Program implementation |
JakBlackburn | 0:73bfbe8729d4 | 4 | |
JakBlackburn | 1:7f151ab172cb | 5 | */ |
JakBlackburn | 1:7f151ab172cb | 6 | #include "main.h" |
JakBlackburn | 0:73bfbe8729d4 | 7 | |
JakBlackburn | 3:00933efbe463 | 8 | int main() |
JakBlackburn | 3:00933efbe463 | 9 | { |
JakBlackburn | 7:962b5f044a9b | 10 | PHY_PowerDown(); |
JakBlackburn | 8:ffcde84b8cf3 | 11 | //semihost_powerdown(); |
JakBlackburn | 7:962b5f044a9b | 12 | pc.baud(9600); ///sets baud rate |
JakBlackburn | 7:962b5f044a9b | 13 | timer.attach(&timerExpired,0.2); /// Sets the speed of the timer and attaches a function to run |
JakBlackburn | 7:962b5f044a9b | 14 | timer2.attach(&timer2Expired,1); /// Sets the speed of the timer and attaches a function to run |
JakBlackburn | 7:962b5f044a9b | 15 | timer3.attach(&timer3Expired,2); /// Sets the speed of the timer and attaches a function to run |
JakBlackburn | 7:962b5f044a9b | 16 | LogTog.rise(&logToggle); /// attaches a function to the rise of the LogTog button |
JakBlackburn | 7:962b5f044a9b | 17 | UnitTog.rise(&unitToggle); /// attaches a function to the rise of the UnitTog button |
JakBlackburn | 7:962b5f044a9b | 18 | VisTog.rise(&visToggle); /// attaches a function to the rise of the VisTog button |
JakBlackburn | 7:962b5f044a9b | 19 | pc.attach(&serialISR); /// attach serial ISR |
JakBlackburn | 7:962b5f044a9b | 20 | BLED.period(0.02); ///sets the frequency of the Backlight at 50Hz |
JakBlackburn | 7:962b5f044a9b | 21 | BLED=BLEDLevel.read(); ///sets the brightness |
JakBlackburn | 8:ffcde84b8cf3 | 22 | lcd.init(); ///initilizes the display |
JakBlackburn | 7:962b5f044a9b | 23 | introTune(); /// plays the intro tune |
JakBlackburn | 8:ffcde84b8cf3 | 24 | lcd.printString("---+--+--+---",3,0);/// Displays an introduction message |
JakBlackburn | 7:962b5f044a9b | 25 | lcd.printString("Distance",18,1); |
JakBlackburn | 7:962b5f044a9b | 26 | lcd.printString("Sensor",25,2); |
JakBlackburn | 7:962b5f044a9b | 27 | lcd.printString("By Jakobi",16,3); |
JakBlackburn | 2:a1eaa4d74b63 | 28 | lcd.printString("Blackburn",16,4); |
JakBlackburn | 7:962b5f044a9b | 29 | lcd.printString("---+--+--+---",3,5); |
JakBlackburn | 3:00933efbe463 | 30 | wait(2); |
JakBlackburn | 7:962b5f044a9b | 31 | lcd.clear(); /// clears the opening message |
JakBlackburn | 0:73bfbe8729d4 | 32 | while(1) { |
JakBlackburn | 7:962b5f044a9b | 33 | if (setTimeFlag) { /// if updated time has been sent |
JakBlackburn | 7:962b5f044a9b | 34 | setTimeFlag = 0; /// clear flag |
JakBlackburn | 7:962b5f044a9b | 35 | setTime(); /// update time |
JakBlackburn | 1:7f151ab172cb | 36 | } |
JakBlackburn | 7:962b5f044a9b | 37 | if(distance>=100) { /// uses the 2 second timer if the distance is above 100 |
JakBlackburn | 7:962b5f044a9b | 38 | if(timer3Flag) { /// 2 second timer's flag |
JakBlackburn | 7:962b5f044a9b | 39 | pc.printf("Scan Speed = 0.5 \n"); /// prints the scan speed across the serial port |
JakBlackburn | 7:962b5f044a9b | 40 | theMain(); /// Contains the main code |
JakBlackburn | 5:f9b97f057836 | 41 | |
JakBlackburn | 5:f9b97f057836 | 42 | } |
JakBlackburn | 7:962b5f044a9b | 43 | } else if(distance>=50) { /// uses the 1 second timer if the distance is above 50 and less than 100 |
JakBlackburn | 7:962b5f044a9b | 44 | if(timer2Flag) {/// 1 second timer's flag |
JakBlackburn | 7:962b5f044a9b | 45 | pc.printf("Scan Speed = 1 \n"); /// prints the scan speed across the serial port |
JakBlackburn | 7:962b5f044a9b | 46 | theMain(); /// Contains the main code |
JakBlackburn | 5:f9b97f057836 | 47 | } |
JakBlackburn | 7:962b5f044a9b | 48 | } else if(distance<50) { /// uses the 0.2 second timer if the distance is less than 50 |
JakBlackburn | 7:962b5f044a9b | 49 | if(timerFlag) {/// 0.2 second timer's flag |
JakBlackburn | 7:962b5f044a9b | 50 | pc.printf("Scan Speed = 5 \n"); /// prints the scan speed across the serial port |
JakBlackburn | 7:962b5f044a9b | 51 | theMain(); /// Contains the main code |
JakBlackburn | 5:f9b97f057836 | 52 | } |
JakBlackburn | 8:ffcde84b8cf3 | 53 | } else { /// otherwise |
JakBlackburn | 8:ffcde84b8cf3 | 54 | error(1); /// displays an error message across the mBed leds |
JakBlackburn | 5:f9b97f057836 | 55 | } |
JakBlackburn | 5:f9b97f057836 | 56 | |
JakBlackburn | 8:ffcde84b8cf3 | 57 | Sleep();/// Whilst the code is not doing anything else, it will sleep |
JakBlackburn | 0:73bfbe8729d4 | 58 | } |
JakBlackburn | 0:73bfbe8729d4 | 59 | } |
JakBlackburn | 0:73bfbe8729d4 | 60 | |
JakBlackburn | 3:00933efbe463 | 61 | void timerExpired() |
JakBlackburn | 3:00933efbe463 | 62 | { |
JakBlackburn | 8:ffcde84b8cf3 | 63 | timerFlag=1; /// sets the timer flag high |
JakBlackburn | 0:73bfbe8729d4 | 64 | } |
JakBlackburn | 0:73bfbe8729d4 | 65 | |
JakBlackburn | 5:f9b97f057836 | 66 | void timer2Expired() |
JakBlackburn | 5:f9b97f057836 | 67 | { |
JakBlackburn | 8:ffcde84b8cf3 | 68 | timer2Flag=1;/// sets the timer flag high |
JakBlackburn | 5:f9b97f057836 | 69 | } |
JakBlackburn | 5:f9b97f057836 | 70 | void timer3Expired() |
JakBlackburn | 5:f9b97f057836 | 71 | { |
JakBlackburn | 8:ffcde84b8cf3 | 72 | timer3Flag=1;/// sets the timer flag high |
JakBlackburn | 5:f9b97f057836 | 73 | } |
JakBlackburn | 5:f9b97f057836 | 74 | |
JakBlackburn | 5:f9b97f057836 | 75 | void theMain() |
JakBlackburn | 5:f9b97f057836 | 76 | { |
JakBlackburn | 7:962b5f044a9b | 77 | BLED=BLEDLevel.read(); ///sets the brightness |
JakBlackburn | 8:ffcde84b8cf3 | 78 | timerFlag =0; ///resets the timer flags |
JakBlackburn | 5:f9b97f057836 | 79 | timer2Flag=0; |
JakBlackburn | 5:f9b97f057836 | 80 | timer3Flag=0; |
JakBlackburn | 8:ffcde84b8cf3 | 81 | time_t seconds = time(NULL); /// gets the current time |
JakBlackburn | 8:ffcde84b8cf3 | 82 | /// formats that time into a string (time and date) |
JakBlackburn | 5:f9b97f057836 | 83 | strftime(buffer, 30 , "%d/%m/%y %R", localtime(&seconds)); |
JakBlackburn | 9:163159830eaf | 84 | strftime(Gbuffer, 30 , "%R", localtime(&seconds)); |
JakBlackburn | 7:962b5f044a9b | 85 | float dist = getDistance()*unitX; ///reads the distance and sets it to a float value. |
JakBlackburn | 7:962b5f044a9b | 86 | ///prints the value to the serial port. |
JakBlackburn | 8:ffcde84b8cf3 | 87 | if(state==1) { |
JakBlackburn | 8:ffcde84b8cf3 | 88 | pc.printf("%s , Distance = %.2f %s \n",buffer,dist,units); |
JakBlackburn | 5:f9b97f057836 | 89 | } else if(state !=1) { |
JakBlackburn | 8:ffcde84b8cf3 | 90 | pc.printf("%s , Distance = %.0f %s \n",buffer,dist,units); |
JakBlackburn | 5:f9b97f057836 | 91 | } |
JakBlackburn | 8:ffcde84b8cf3 | 92 | logging(buffer,distance); /// runs the logging function |
JakBlackburn | 8:ffcde84b8cf3 | 93 | if(visual==0) { /// if the visual toggle is set in the first mode, |
JakBlackburn | 8:ffcde84b8cf3 | 94 | LCDVis0(); /// runs the first Visual function, Changing the Display |
JakBlackburn | 8:ffcde84b8cf3 | 95 | } else if(visual==1) {/// if the visual toggle is set in the second mode, |
JakBlackburn | 8:ffcde84b8cf3 | 96 | LCDVis1(); /// runs the second Visual function, Changing the Display |
JakBlackburn | 8:ffcde84b8cf3 | 97 | } else if(visual==2) {/// if the visual toggle is set in the third mode, |
JakBlackburn | 8:ffcde84b8cf3 | 98 | LCDVis2(); /// runs the third Visual function, Changing the Display |
JakBlackburn | 8:ffcde84b8cf3 | 99 | } else if(visual==3) {/// if the visual toggle is set in the forth mode, |
JakBlackburn | 8:ffcde84b8cf3 | 100 | LCDVis3(); /// runs the forth Visual function, Changing the Display |
JakBlackburn | 9:163159830eaf | 101 | } else if(visual==4) {/// if the visual toggle is set in the forth mode, |
JakBlackburn | 9:163159830eaf | 102 | LCDVis4(); /// runs the forth Visual function, Changing the Display |
JakBlackburn | 9:163159830eaf | 103 | }else { /// if there is no Visual mode selected then |
JakBlackburn | 8:ffcde84b8cf3 | 104 | error(2); /// there is an error and so the error function runs |
JakBlackburn | 5:f9b97f057836 | 105 | } |
JakBlackburn | 5:f9b97f057836 | 106 | } |
JakBlackburn | 5:f9b97f057836 | 107 | |
JakBlackburn | 0:73bfbe8729d4 | 108 | |
JakBlackburn | 3:00933efbe463 | 109 | void warnings() |
JakBlackburn | 3:00933efbe463 | 110 | { |
JakBlackburn | 8:ffcde84b8cf3 | 111 | WLED=1;/// Warning LED is turned on |
JakBlackburn | 8:ffcde84b8cf3 | 112 | volume= BuzVol.read(); /// sets the volume of the buzzer |
JakBlackburn | 8:ffcde84b8cf3 | 113 | if(distance<20) { /// if the distance is less than 20 cm |
JakBlackburn | 8:ffcde84b8cf3 | 114 | Buzzer.ContNote(1000.0, volume); /// uses the new member to create a continuous note |
JakBlackburn | 8:ffcde84b8cf3 | 115 | ///(new member was written and added to speaker.h) |
JakBlackburn | 6:a5cd7eb72264 | 116 | |
JakBlackburn | 8:ffcde84b8cf3 | 117 | } else {/// if the distance isnt less than 20 |
JakBlackburn | 8:ffcde84b8cf3 | 118 | Buzzer.PlayNote(1000.0, 0.1, volume);/// plays a note for 0.1 seconds |
JakBlackburn | 8:ffcde84b8cf3 | 119 | WLED=0;/// and turns off the warning LED (creating a beep and a flash) |
JakBlackburn | 5:f9b97f057836 | 120 | } |
JakBlackburn | 0:73bfbe8729d4 | 121 | } |
JakBlackburn | 8:ffcde84b8cf3 | 122 | |
JakBlackburn | 3:00933efbe463 | 123 | float getDistance() |
JakBlackburn | 3:00933efbe463 | 124 | { |
JakBlackburn | 8:ffcde84b8cf3 | 125 | int dist0 = sensor.getDistanceCm(); /// gets the distance 10 times |
JakBlackburn | 0:73bfbe8729d4 | 126 | int dist1 = sensor.getDistanceCm(); |
JakBlackburn | 0:73bfbe8729d4 | 127 | int dist2 = sensor.getDistanceCm(); |
JakBlackburn | 0:73bfbe8729d4 | 128 | int dist3 = sensor.getDistanceCm(); |
JakBlackburn | 0:73bfbe8729d4 | 129 | int dist4 = sensor.getDistanceCm(); |
JakBlackburn | 0:73bfbe8729d4 | 130 | int dist5 = sensor.getDistanceCm(); |
JakBlackburn | 8:ffcde84b8cf3 | 131 | int dist6 = sensor.getDistanceCm(); |
JakBlackburn | 8:ffcde84b8cf3 | 132 | int dist7 = sensor.getDistanceCm(); |
JakBlackburn | 8:ffcde84b8cf3 | 133 | int dist8 = sensor.getDistanceCm(); |
JakBlackburn | 8:ffcde84b8cf3 | 134 | int dist9 = sensor.getDistanceCm(); |
JakBlackburn | 8:ffcde84b8cf3 | 135 | distance=(dist0+dist1+dist2+dist3+dist4+dist5+dist6+dist7+dist8+dist9)/10;/// averages those distances |
JakBlackburn | 5:f9b97f057836 | 136 | |
JakBlackburn | 8:ffcde84b8cf3 | 137 | warnings(); /// runs the warnings function |
JakBlackburn | 8:ffcde84b8cf3 | 138 | return distance; /// returns the average distance |
JakBlackburn | 0:73bfbe8729d4 | 139 | } |
JakBlackburn | 0:73bfbe8729d4 | 140 | |
JakBlackburn | 3:00933efbe463 | 141 | void unitToggle() |
JakBlackburn | 3:00933efbe463 | 142 | { |
JakBlackburn | 8:ffcde84b8cf3 | 143 | state = fsm[state].nextState[UnitTog]; /// reads the input and updates the current state |
JakBlackburn | 8:ffcde84b8cf3 | 144 | unitX = fsm[state].unitMultiple; /// sets the unit multiple depending on the current state |
JakBlackburn | 8:ffcde84b8cf3 | 145 | units= fsm[state].Unit; /// sets the unit depending on the current state |
JakBlackburn | 1:7f151ab172cb | 146 | wait(0.2); |
JakBlackburn | 1:7f151ab172cb | 147 | pc.printf("unit multiple = %.2f \n",unitX); |
JakBlackburn | 2:a1eaa4d74b63 | 148 | pc.printf("Units = %s \n",units); |
JakBlackburn | 1:7f151ab172cb | 149 | } |
JakBlackburn | 1:7f151ab172cb | 150 | |
JakBlackburn | 5:f9b97f057836 | 151 | |
JakBlackburn | 8:ffcde84b8cf3 | 152 | void error(int E) /// has up to 14 possible errors. |
JakBlackburn | 8:ffcde84b8cf3 | 153 | { ///If a 15 is shown it is a ack bit error for the SRF02 |
JakBlackburn | 8:ffcde84b8cf3 | 154 | while(1) { /// loops flashing the error number on the onboard LED's |
JakBlackburn | 1:7f151ab172cb | 155 | leds=0; |
JakBlackburn | 1:7f151ab172cb | 156 | wait(0.2); |
JakBlackburn | 1:7f151ab172cb | 157 | leds=E; |
JakBlackburn | 1:7f151ab172cb | 158 | wait(0.2); |
JakBlackburn | 1:7f151ab172cb | 159 | } |
JakBlackburn | 0:73bfbe8729d4 | 160 | } |
JakBlackburn | 0:73bfbe8729d4 | 161 | |
JakBlackburn | 4:2e9aa626a02c | 162 | void logToggle() |
JakBlackburn | 1:7f151ab172cb | 163 | { |
JakBlackburn | 8:ffcde84b8cf3 | 164 | logButtonFlag = !logButtonFlag; ///flips the flag |
JakBlackburn | 8:ffcde84b8cf3 | 165 | if(logButtonFlag) { /// if flag is high the device is logging so |
JakBlackburn | 8:ffcde84b8cf3 | 166 | LLED=1; /// Logging LED will be on |
JakBlackburn | 8:ffcde84b8cf3 | 167 | pc.printf("-------\n Data Logging\n\r");/// prints a message to the serial port |
JakBlackburn | 8:ffcde84b8cf3 | 168 | } else { /// if flag is low the device isn't logging so |
JakBlackburn | 8:ffcde84b8cf3 | 169 | LLED=0; /// Logging LED is turned off |
JakBlackburn | 8:ffcde84b8cf3 | 170 | pc.printf("-------\n Stopped Logging Data\n\r");/// prints a message to the serial port |
JakBlackburn | 0:73bfbe8729d4 | 171 | } |
JakBlackburn | 1:7f151ab172cb | 172 | wait(0.2); |
JakBlackburn | 1:7f151ab172cb | 173 | } |
JakBlackburn | 1:7f151ab172cb | 174 | |
JakBlackburn | 1:7f151ab172cb | 175 | void logging(char* data,float data1) |
JakBlackburn | 1:7f151ab172cb | 176 | { |
JakBlackburn | 8:ffcde84b8cf3 | 177 | if(logButtonFlag) { //if the logging flag is high |
JakBlackburn | 8:ffcde84b8cf3 | 178 | FILE *fp = fopen("/local/log.csv", "a"); /// opens 'log.csv' for appending |
JakBlackburn | 7:962b5f044a9b | 179 | /// if the file doesn't exist it is created, if it exists, data is appended to the end |
JakBlackburn | 7:962b5f044a9b | 180 | fprintf(fp," %s , %.2f\n ",data,data1); /// print string to file |
JakBlackburn | 7:962b5f044a9b | 181 | fclose(fp); /// close file |
JakBlackburn | 8:ffcde84b8cf3 | 182 | pc.printf("Data Logged\n");/// prints a message to the serial port |
JakBlackburn | 7:962b5f044a9b | 183 | LLED=1; /// keeps the led on if it is logging |
JakBlackburn | 8:ffcde84b8cf3 | 184 | } else {/// otherwise |
JakBlackburn | 8:ffcde84b8cf3 | 185 | pc.printf("WARNING : Unlogged Data\n");/// prints a message to the serial port |
JakBlackburn | 8:ffcde84b8cf3 | 186 | LLED=0; ///sets the logging LED to off |
JakBlackburn | 0:73bfbe8729d4 | 187 | } |
JakBlackburn | 1:7f151ab172cb | 188 | } |
JakBlackburn | 1:7f151ab172cb | 189 | |
JakBlackburn | 1:7f151ab172cb | 190 | void setTime() |
JakBlackburn | 1:7f151ab172cb | 191 | { |
JakBlackburn | 8:ffcde84b8cf3 | 192 | /// prints Unix time for debugging |
JakBlackburn | 8:ffcde84b8cf3 | 193 | pc.printf("\n \r Unix set time - %s\n",rxString); |
JakBlackburn | 7:962b5f044a9b | 194 | /// atoi() converts a string to an integer |
JakBlackburn | 1:7f151ab172cb | 195 | int time = atoi(rxString); |
JakBlackburn | 7:962b5f044a9b | 196 | /// update the time |
JakBlackburn | 1:7f151ab172cb | 197 | set_time(time); |
JakBlackburn | 8:ffcde84b8cf3 | 198 | pc.printf("Set time - %s \n \r ",buffer);///prints the time to the serial port |
JakBlackburn | 1:7f151ab172cb | 199 | } |
JakBlackburn | 1:7f151ab172cb | 200 | void serialISR() |
JakBlackburn | 1:7f151ab172cb | 201 | { |
JakBlackburn | 7:962b5f044a9b | 202 | /// when a serial interrupt occurs, read rx string into buffer |
JakBlackburn | 1:7f151ab172cb | 203 | pc.gets(rxString,16); |
JakBlackburn | 7:962b5f044a9b | 204 | /// set flag |
JakBlackburn | 1:7f151ab172cb | 205 | setTimeFlag = 1; |
JakBlackburn | 2:a1eaa4d74b63 | 206 | } |
JakBlackburn | 2:a1eaa4d74b63 | 207 | |
JakBlackburn | 2:a1eaa4d74b63 | 208 | void introTune() |
JakBlackburn | 8:ffcde84b8cf3 | 209 | {/// plays several notes to create a tune |
JakBlackburn | 2:a1eaa4d74b63 | 210 | Buzzer.PlayNote(1319.0,0.084,1.0); |
JakBlackburn | 2:a1eaa4d74b63 | 211 | wait(0.01); |
JakBlackburn | 2:a1eaa4d74b63 | 212 | Buzzer.PlayNote(1319.0,0.084,1.0); |
JakBlackburn | 2:a1eaa4d74b63 | 213 | wait(0.094); |
JakBlackburn | 2:a1eaa4d74b63 | 214 | Buzzer.PlayNote(1319.0,0.084,1.0); |
JakBlackburn | 2:a1eaa4d74b63 | 215 | wait(0.094); |
JakBlackburn | 2:a1eaa4d74b63 | 216 | Buzzer.PlayNote(1047.0,0.084,1.0); |
JakBlackburn | 2:a1eaa4d74b63 | 217 | wait(0.01); |
JakBlackburn | 2:a1eaa4d74b63 | 218 | Buzzer.PlayNote(1319.0,0.084,1.0); |
JakBlackburn | 2:a1eaa4d74b63 | 219 | wait(0.094); |
JakBlackburn | 2:a1eaa4d74b63 | 220 | Buzzer.PlayNote(1568.0,0.084,1.0); |
JakBlackburn | 2:a1eaa4d74b63 | 221 | wait(0.26); |
JakBlackburn | 2:a1eaa4d74b63 | 222 | Buzzer.PlayNote(784.0,0.084,1.0); |
JakBlackburn | 2:a1eaa4d74b63 | 223 | } |
JakBlackburn | 2:a1eaa4d74b63 | 224 | |
JakBlackburn | 3:00933efbe463 | 225 | |
JakBlackburn | 8:ffcde84b8cf3 | 226 | void LCDVis0() /// the max range is 249 (according to the data sheet) |
JakBlackburn | 8:ffcde84b8cf3 | 227 | {///and there are 84 pixels wide on the LCD so this can be used to map the amount of cm for each pixel |
JakBlackburn | 8:ffcde84b8cf3 | 228 | lcd.clear();/// clears the screen |
JakBlackburn | 8:ffcde84b8cf3 | 229 | if(logButtonFlag) { /// if the logging flag is high |
JakBlackburn | 8:ffcde84b8cf3 | 230 | lcd.printString("-L-",0,5); /// prints an L onto the botton left of the screen |
JakBlackburn | 6:a5cd7eb72264 | 231 | } |
JakBlackburn | 6:a5cd7eb72264 | 232 | |
JakBlackburn | 7:962b5f044a9b | 233 | int I = distance*0.337; /// and then multiplies the current distance by that value as (84/249) =0.337... |
JakBlackburn | 6:a5cd7eb72264 | 234 | I=I+3; |
JakBlackburn | 6:a5cd7eb72264 | 235 | if(I>=79){I=79;} |
JakBlackburn | 8:ffcde84b8cf3 | 236 | pc.printf("bar width - %d pixels \n",I);/// prints the width to the serial port |
JakBlackburn | 8:ffcde84b8cf3 | 237 | lcd.drawRect(0,16,83,16,0); ///draws a frame for the bar |
JakBlackburn | 8:ffcde84b8cf3 | 238 | lcd.drawRect(2,18,I,12,1); /// draws a rectangle inside the frame at the calculated width |
JakBlackburn | 8:ffcde84b8cf3 | 239 | if(state==1) { |
JakBlackburn | 8:ffcde84b8cf3 | 240 | sprintf(Dbuffer, "%.2f", distance*unitX); /// prints the value to the serial port. |
JakBlackburn | 8:ffcde84b8cf3 | 241 | } else if(state !=1) { |
JakBlackburn | 8:ffcde84b8cf3 | 242 | sprintf(Dbuffer, "%.0f", distance*unitX); |
JakBlackburn | 8:ffcde84b8cf3 | 243 | } |
JakBlackburn | 8:ffcde84b8cf3 | 244 | lcd.printString (buffer,0,0);/// prints the time and date at the top of the screen |
JakBlackburn | 8:ffcde84b8cf3 | 245 | lcd.printString (Dbuffer,26,5); /// prints the distance |
JakBlackburn | 8:ffcde84b8cf3 | 246 | lcd.printString (units,50,5); /// and the units |
JakBlackburn | 8:ffcde84b8cf3 | 247 | lcd.refresh();/// it then refreshes the screen |
JakBlackburn | 8:ffcde84b8cf3 | 248 | } |
JakBlackburn | 8:ffcde84b8cf3 | 249 | |
JakBlackburn | 8:ffcde84b8cf3 | 250 | void LCDVis1() /// the max range is 249 (according to the data sheet) |
JakBlackburn | 8:ffcde84b8cf3 | 251 | {///and there are 48 pixels high on the LCD so this can be used to map the amount of cm for each pixel |
JakBlackburn | 8:ffcde84b8cf3 | 252 | lcd.clear(); /// clears the screen |
JakBlackburn | 8:ffcde84b8cf3 | 253 | if(logButtonFlag) {/// if the logging flag is high |
JakBlackburn | 8:ffcde84b8cf3 | 254 | lcd.printString("-L-",0,5);/// prints an L onto the botton left of the screen |
JakBlackburn | 8:ffcde84b8cf3 | 255 | } |
JakBlackburn | 8:ffcde84b8cf3 | 256 | |
JakBlackburn | 8:ffcde84b8cf3 | 257 | int J = distance*0.14; /// and then multiplies the current distance by that value as (36/249) = 0.14..(as top 12 pixels are for time) |
JakBlackburn | 8:ffcde84b8cf3 | 258 | if(J>=36) { |
JakBlackburn | 8:ffcde84b8cf3 | 259 | J=36; |
JakBlackburn | 8:ffcde84b8cf3 | 260 | } |
JakBlackburn | 8:ffcde84b8cf3 | 261 | pc.printf("bar height - %d pixels \n",J);// prints the height to the serial port |
JakBlackburn | 8:ffcde84b8cf3 | 262 | lcd.drawRect(24,9,34,38,0);///draws a frame for the bar |
JakBlackburn | 8:ffcde84b8cf3 | 263 | lcd.drawRect(26,47-J,30,J-2,1);/// draws a rectangle inside the frame at the calculated height |
JakBlackburn | 8:ffcde84b8cf3 | 264 | if(state==1) { |
JakBlackburn | 8:ffcde84b8cf3 | 265 | sprintf(Dbuffer, "%.2f", distance*unitX); /// prints the value to the serial port. |
JakBlackburn | 8:ffcde84b8cf3 | 266 | } else if(state !=1) { |
JakBlackburn | 8:ffcde84b8cf3 | 267 | sprintf(Dbuffer, "%.0f", distance*unitX); |
JakBlackburn | 8:ffcde84b8cf3 | 268 | } |
JakBlackburn | 8:ffcde84b8cf3 | 269 | lcd.printString (buffer,0,0);/// prints the time and date at the top of the screen |
JakBlackburn | 8:ffcde84b8cf3 | 270 | lcd.printString (Dbuffer,60,3);/// prints the distance |
JakBlackburn | 8:ffcde84b8cf3 | 271 | lcd.printString (units,64,4);/// and the units |
JakBlackburn | 8:ffcde84b8cf3 | 272 | lcd.refresh(); /// it then refreshes the screen |
JakBlackburn | 8:ffcde84b8cf3 | 273 | } |
JakBlackburn | 8:ffcde84b8cf3 | 274 | |
JakBlackburn | 8:ffcde84b8cf3 | 275 | void LCDVis2() |
JakBlackburn | 8:ffcde84b8cf3 | 276 | { |
JakBlackburn | 8:ffcde84b8cf3 | 277 | lcd.clear();/// clears the screen |
JakBlackburn | 8:ffcde84b8cf3 | 278 | if(logButtonFlag) {/// if the logging flag is high |
JakBlackburn | 8:ffcde84b8cf3 | 279 | lcd.printString("-L-",0,5);/// prints an L onto the botton left of the screen |
JakBlackburn | 8:ffcde84b8cf3 | 280 | } |
JakBlackburn | 8:ffcde84b8cf3 | 281 | car(); /// displays a small car shape |
JakBlackburn | 8:ffcde84b8cf3 | 282 | int I = distance*0.277; /// and then multiplies the current distance by that value as (69/249) =0.277... |
JakBlackburn | 8:ffcde84b8cf3 | 283 | if(I>=84) { |
JakBlackburn | 8:ffcde84b8cf3 | 284 | I=84; |
JakBlackburn | 8:ffcde84b8cf3 | 285 | } |
JakBlackburn | 4:2e9aa626a02c | 286 | pc.printf("bar width - %d pixels \n",I); |
JakBlackburn | 8:ffcde84b8cf3 | 287 | lcd.drawRect(I+15,9,69,29,1); /// draws a rectangle inside the frame at the calculated width |
JakBlackburn | 6:a5cd7eb72264 | 288 | if(state==1) { |
JakBlackburn | 7:962b5f044a9b | 289 | sprintf(Dbuffer, "%.2f", distance*unitX); /// prints the value to the serial port. |
JakBlackburn | 6:a5cd7eb72264 | 290 | } else if(state !=1) { |
JakBlackburn | 7:962b5f044a9b | 291 | sprintf(Dbuffer, "%.0f", distance*unitX); /// prints the value to the serial port. |
JakBlackburn | 6:a5cd7eb72264 | 292 | } |
JakBlackburn | 8:ffcde84b8cf3 | 293 | lcd.printString (buffer,0,0);/// prints the time and date at the top of the screen |
JakBlackburn | 8:ffcde84b8cf3 | 294 | lcd.printString (Dbuffer,26,5);///prints the distance |
JakBlackburn | 8:ffcde84b8cf3 | 295 | lcd.printString (units,50,5);///and the units |
JakBlackburn | 8:ffcde84b8cf3 | 296 | lcd.refresh(); /// it then refreshes the screen |
JakBlackburn | 4:2e9aa626a02c | 297 | } |
JakBlackburn | 5:f9b97f057836 | 298 | void LCDVis3() |
JakBlackburn | 5:f9b97f057836 | 299 | { |
JakBlackburn | 8:ffcde84b8cf3 | 300 | lcd.clear(); /// clears the screen |
JakBlackburn | 8:ffcde84b8cf3 | 301 | if(logButtonFlag) {/// if the logging flag is high |
JakBlackburn | 8:ffcde84b8cf3 | 302 | lcd.printString("-L-",0,5);/// prints an L onto the botton left of the screen |
JakBlackburn | 6:a5cd7eb72264 | 303 | } |
JakBlackburn | 9:163159830eaf | 304 | lcd.printString (buffer,0,0); ///prints the time and date |
JakBlackburn | 8:ffcde84b8cf3 | 305 | int Dist=distance; /// assigns each digit of the distance |
JakBlackburn | 8:ffcde84b8cf3 | 306 | if(state==0) { /// to an integer and then depending on the value of that integer |
JakBlackburn | 8:ffcde84b8cf3 | 307 | lcd.printString("CM",54,3); /// prints a large number to a position on the screen |
JakBlackburn | 8:ffcde84b8cf3 | 308 | } /// (large numbers designed and added to the N5110 library) |
JakBlackburn | 5:f9b97f057836 | 309 | if(state==1) { |
JakBlackburn | 5:f9b97f057836 | 310 | lcd.decimal(); |
JakBlackburn | 5:f9b97f057836 | 311 | lcd.printString("M",54,3); |
JakBlackburn | 4:2e9aa626a02c | 312 | } |
JakBlackburn | 5:f9b97f057836 | 313 | if(state==2) { |
JakBlackburn | 5:f9b97f057836 | 314 | lcd.number0(57); |
JakBlackburn | 4:2e9aa626a02c | 315 | lcd.printString("MM",73,3); |
JakBlackburn | 4:2e9aa626a02c | 316 | } |
JakBlackburn | 4:2e9aa626a02c | 317 | int S=Dist %10; |
JakBlackburn | 4:2e9aa626a02c | 318 | pc.printf("singles - %d \n",S); |
JakBlackburn | 5:f9b97f057836 | 319 | if(S==0) { |
JakBlackburn | 5:f9b97f057836 | 320 | lcd.number0(38); |
JakBlackburn | 5:f9b97f057836 | 321 | } else if(S==1) { |
JakBlackburn | 5:f9b97f057836 | 322 | lcd.number1(38); |
JakBlackburn | 5:f9b97f057836 | 323 | } else if(S==2) { |
JakBlackburn | 5:f9b97f057836 | 324 | lcd.number2(38); |
JakBlackburn | 5:f9b97f057836 | 325 | } else if(S==3) { |
JakBlackburn | 5:f9b97f057836 | 326 | lcd.number3(38); |
JakBlackburn | 5:f9b97f057836 | 327 | } else if(S==4) { |
JakBlackburn | 5:f9b97f057836 | 328 | lcd.number4(38); |
JakBlackburn | 5:f9b97f057836 | 329 | } else if(S==5) { |
JakBlackburn | 5:f9b97f057836 | 330 | lcd.number5(38); |
JakBlackburn | 5:f9b97f057836 | 331 | } else if(S==6) { |
JakBlackburn | 5:f9b97f057836 | 332 | lcd.number6(38); |
JakBlackburn | 5:f9b97f057836 | 333 | } else if(S==7) { |
JakBlackburn | 5:f9b97f057836 | 334 | lcd.number7(38); |
JakBlackburn | 5:f9b97f057836 | 335 | } else if(S==8) { |
JakBlackburn | 5:f9b97f057836 | 336 | lcd.number8(38); |
JakBlackburn | 5:f9b97f057836 | 337 | } else if(S==9) { |
JakBlackburn | 5:f9b97f057836 | 338 | lcd.number9(38); |
JakBlackburn | 5:f9b97f057836 | 339 | } else { |
JakBlackburn | 5:f9b97f057836 | 340 | error(4); |
JakBlackburn | 3:00933efbe463 | 341 | } |
JakBlackburn | 5:f9b97f057836 | 342 | |
JakBlackburn | 4:2e9aa626a02c | 343 | int T=Dist/10 %10; |
JakBlackburn | 5:f9b97f057836 | 344 | pc.printf("tens - %d \n",T); |
JakBlackburn | 5:f9b97f057836 | 345 | if(T==0) { |
JakBlackburn | 5:f9b97f057836 | 346 | lcd.number0(19); |
JakBlackburn | 5:f9b97f057836 | 347 | } else if(T==1) { |
JakBlackburn | 5:f9b97f057836 | 348 | lcd.number1(19); |
JakBlackburn | 5:f9b97f057836 | 349 | } else if(T==2) { |
JakBlackburn | 5:f9b97f057836 | 350 | lcd.number2(19); |
JakBlackburn | 5:f9b97f057836 | 351 | } else if(T==3) { |
JakBlackburn | 5:f9b97f057836 | 352 | lcd.number3(19); |
JakBlackburn | 5:f9b97f057836 | 353 | } else if(T==4) { |
JakBlackburn | 5:f9b97f057836 | 354 | lcd.number4(19); |
JakBlackburn | 5:f9b97f057836 | 355 | } else if(T==5) { |
JakBlackburn | 5:f9b97f057836 | 356 | lcd.number5(19); |
JakBlackburn | 5:f9b97f057836 | 357 | } else if(T==6) { |
JakBlackburn | 5:f9b97f057836 | 358 | lcd.number6(19); |
JakBlackburn | 5:f9b97f057836 | 359 | } else if(T==7) { |
JakBlackburn | 5:f9b97f057836 | 360 | lcd.number7(19); |
JakBlackburn | 5:f9b97f057836 | 361 | } else if(T==8) { |
JakBlackburn | 5:f9b97f057836 | 362 | lcd.number8(19); |
JakBlackburn | 5:f9b97f057836 | 363 | } else if(T==9) { |
JakBlackburn | 5:f9b97f057836 | 364 | lcd.number9(19); |
JakBlackburn | 5:f9b97f057836 | 365 | } else { |
JakBlackburn | 5:f9b97f057836 | 366 | error(4); |
JakBlackburn | 4:2e9aa626a02c | 367 | } |
JakBlackburn | 4:2e9aa626a02c | 368 | int H=Dist/100 %10; |
JakBlackburn | 4:2e9aa626a02c | 369 | pc.printf("Hundreds - %d \n",H); |
JakBlackburn | 5:f9b97f057836 | 370 | if(H==0) { |
JakBlackburn | 8:ffcde84b8cf3 | 371 | if(state==1){ lcd.number0(0);} |
JakBlackburn | 5:f9b97f057836 | 372 | } else if(H==1) { |
JakBlackburn | 5:f9b97f057836 | 373 | lcd.number1(0); |
JakBlackburn | 5:f9b97f057836 | 374 | } else if(H==2) { |
JakBlackburn | 5:f9b97f057836 | 375 | lcd.number2(0); |
JakBlackburn | 5:f9b97f057836 | 376 | } else if(H==3) { |
JakBlackburn | 5:f9b97f057836 | 377 | lcd.number3(0); |
JakBlackburn | 5:f9b97f057836 | 378 | } else if(H==4) { |
JakBlackburn | 5:f9b97f057836 | 379 | lcd.number4(0); |
JakBlackburn | 5:f9b97f057836 | 380 | } else if(H==5) { |
JakBlackburn | 5:f9b97f057836 | 381 | lcd.number5(0); |
JakBlackburn | 5:f9b97f057836 | 382 | } else if(H==6) { |
JakBlackburn | 5:f9b97f057836 | 383 | lcd.number6(0); |
JakBlackburn | 5:f9b97f057836 | 384 | } else if(H==7) { |
JakBlackburn | 5:f9b97f057836 | 385 | lcd.number7(0); |
JakBlackburn | 5:f9b97f057836 | 386 | } else if(H==8) { |
JakBlackburn | 5:f9b97f057836 | 387 | lcd.number8(0); |
JakBlackburn | 5:f9b97f057836 | 388 | } else if(H==9) { |
JakBlackburn | 5:f9b97f057836 | 389 | lcd.number9(0); |
JakBlackburn | 5:f9b97f057836 | 390 | } else { |
JakBlackburn | 5:f9b97f057836 | 391 | error(4); |
JakBlackburn | 4:2e9aa626a02c | 392 | } |
JakBlackburn | 5:f9b97f057836 | 393 | lcd.refresh(); |
JakBlackburn | 4:2e9aa626a02c | 394 | } |
JakBlackburn | 4:2e9aa626a02c | 395 | |
JakBlackburn | 4:2e9aa626a02c | 396 | |
JakBlackburn | 4:2e9aa626a02c | 397 | |
JakBlackburn | 4:2e9aa626a02c | 398 | |
JakBlackburn | 5:f9b97f057836 | 399 | void car() |
JakBlackburn | 8:ffcde84b8cf3 | 400 | { /// sets pixels in the design of a car |
JakBlackburn | 7:962b5f044a9b | 401 | lcd.setPixel(4,19);lcd.setPixel(5,19);lcd.setPixel(6,19);lcd.setPixel(10,19);lcd.setPixel(11,19);lcd.setPixel(12,19); |
JakBlackburn | 7:962b5f044a9b | 402 | lcd.setPixel(4,20);lcd.setPixel(5,20);lcd.setPixel(6,20);lcd.setPixel(10,20);lcd.setPixel(11,20);lcd.setPixel(12,20); |
JakBlackburn | 7:962b5f044a9b | 403 | lcd.setPixel(1,21);lcd.setPixel(2,21);lcd.setPixel(3,21);lcd.setPixel(4,21);lcd.setPixel(5,21);lcd.setPixel(6,21); |
JakBlackburn | 7:962b5f044a9b | 404 | lcd.setPixel(7,21);lcd.setPixel(8,21);lcd.setPixel(9,21);lcd.setPixel(10,21);lcd.setPixel(11,21);lcd.setPixel(12,21); |
JakBlackburn | 7:962b5f044a9b | 405 | lcd.setPixel(13,21);lcd.setPixel(0,22);lcd.setPixel(1,22);lcd.setPixel(2,22);lcd.setPixel(3,22);lcd.setPixel(4,22); |
JakBlackburn | 7:962b5f044a9b | 406 | lcd.setPixel(6,22);lcd.setPixel(7,22);lcd.setPixel(8,22);lcd.setPixel(9,22);lcd.setPixel(10,22);lcd.setPixel(12,22); |
JakBlackburn | 7:962b5f044a9b | 407 | lcd.setPixel(13,22);lcd.setPixel(0,23);lcd.setPixel(1,23);lcd.setPixel(2,23);lcd.setPixel(3,23);lcd.setPixel(6,23); |
JakBlackburn | 7:962b5f044a9b | 408 | lcd.setPixel(7,23);lcd.setPixel(8,23);lcd.setPixel(9,23);lcd.setPixel(10,23);lcd.setPixel(12,23);lcd.setPixel(13,23); |
JakBlackburn | 7:962b5f044a9b | 409 | lcd.setPixel(0,24);lcd.setPixel(1,24);lcd.setPixel(2,24);lcd.setPixel(3,24);lcd.setPixel(6,24);lcd.setPixel(7,24); |
JakBlackburn | 7:962b5f044a9b | 410 | lcd.setPixel(8,24);lcd.setPixel(9,24);lcd.setPixel(10,24);lcd.setPixel(12,24);lcd.setPixel(13,24);lcd.setPixel(0,25); |
JakBlackburn | 7:962b5f044a9b | 411 | lcd.setPixel(1,25);lcd.setPixel(2,25);lcd.setPixel(3,25);lcd.setPixel(6,25);lcd.setPixel(7,25);lcd.setPixel(8,25); |
JakBlackburn | 7:962b5f044a9b | 412 | lcd.setPixel(9,25);lcd.setPixel(10,25);lcd.setPixel(12,25);lcd.setPixel(13,25);lcd.setPixel(0,26);lcd.setPixel(1,26); |
JakBlackburn | 7:962b5f044a9b | 413 | lcd.setPixel(2,26);lcd.setPixel(3,26);lcd.setPixel(4,26);lcd.setPixel(6,26);lcd.setPixel(7,26);lcd.setPixel(8,26); |
JakBlackburn | 7:962b5f044a9b | 414 | lcd.setPixel(9,26);lcd.setPixel(10,26);lcd.setPixel(12,26);lcd.setPixel(13,26);lcd.setPixel(1,27);lcd.setPixel(2,27); |
JakBlackburn | 7:962b5f044a9b | 415 | lcd.setPixel(3,27);lcd.setPixel(4,27);lcd.setPixel(5,27);lcd.setPixel(6,27);lcd.setPixel(7,27);lcd.setPixel(8,27); |
JakBlackburn | 7:962b5f044a9b | 416 | lcd.setPixel(9,27);lcd.setPixel(10,27);lcd.setPixel(11,27);lcd.setPixel(12,27);lcd.setPixel(13,27);lcd.setPixel(4,28); |
JakBlackburn | 7:962b5f044a9b | 417 | lcd.setPixel(5,28);lcd.setPixel(6,28);lcd.setPixel(10,28);lcd.setPixel(11,28);lcd.setPixel(12,28);lcd.setPixel(4,29); |
JakBlackburn | 7:962b5f044a9b | 418 | lcd.setPixel(5,29);lcd.setPixel(6,29);lcd.setPixel(10,29);lcd.setPixel(11,29);lcd.setPixel(12,29); |
JakBlackburn | 3:00933efbe463 | 419 | } |
JakBlackburn | 3:00933efbe463 | 420 | |
JakBlackburn | 3:00933efbe463 | 421 | void visToggle() |
JakBlackburn | 3:00933efbe463 | 422 | { |
JakBlackburn | 8:ffcde84b8cf3 | 423 | lcd.init(); |
JakBlackburn | 7:962b5f044a9b | 424 | Vstate = Vfsm[Vstate].nextState[VisTog]; /// read input and update current state |
JakBlackburn | 7:962b5f044a9b | 425 | visual = Vfsm[Vstate].visual; /// set output depending on current state |
JakBlackburn | 3:00933efbe463 | 426 | wait(0.2); |
JakBlackburn | 5:f9b97f057836 | 427 | if(visual==0) { |
JakBlackburn | 8:ffcde84b8cf3 | 428 | pc.printf("----Left to Right----\n\r"); /// prints to the serial which mode is selected |
JakBlackburn | 3:00933efbe463 | 429 | } |
JakBlackburn | 3:00933efbe463 | 430 | if(visual==1) { |
JakBlackburn | 3:00933efbe463 | 431 | pc.printf("----Up to Down----\n\r"); |
JakBlackburn | 3:00933efbe463 | 432 | } |
JakBlackburn | 3:00933efbe463 | 433 | if(visual==2) { |
JakBlackburn | 4:2e9aa626a02c | 434 | pc.printf("----Car & Wall----\n\r"); |
JakBlackburn | 4:2e9aa626a02c | 435 | } |
JakBlackburn | 4:2e9aa626a02c | 436 | if(visual==3) { |
JakBlackburn | 4:2e9aa626a02c | 437 | pc.printf("----Numbers----\n\r"); |
JakBlackburn | 3:00933efbe463 | 438 | } |
JakBlackburn | 7:962b5f044a9b | 439 | } |
JakBlackburn | 7:962b5f044a9b | 440 | int semihost_powerdown(){ |
JakBlackburn | 7:962b5f044a9b | 441 | uint32_t arg; |
JakBlackburn | 7:962b5f044a9b | 442 | return __semihost(USR_POWERDOWN, &arg); |
JakBlackburn | 9:163159830eaf | 443 | } |
JakBlackburn | 9:163159830eaf | 444 | |
JakBlackburn | 9:163159830eaf | 445 | void LCDVis4() |
JakBlackburn | 9:163159830eaf | 446 | { |
JakBlackburn | 9:163159830eaf | 447 | lcd.clear();/// clears the screen |
JakBlackburn | 9:163159830eaf | 448 | if(logButtonFlag) {/// if the logging flag is high |
JakBlackburn | 9:163159830eaf | 449 | lcd.printString("-L-",36,0);/// prints an L onto the botton left of the screen |
JakBlackburn | 9:163159830eaf | 450 | } |
JakBlackburn | 9:163159830eaf | 451 | int J = distance*0.14; /// and then multiplies the current distance by that value as (36/249) = 0.14.. |
JakBlackburn | 9:163159830eaf | 452 | if(J>39) { ///(as top 12 pixels are for time) |
JakBlackburn | 9:163159830eaf | 453 | J=39; /// limits the value so that it leaves space at the top for the distance |
JakBlackburn | 9:163159830eaf | 454 | } |
JakBlackburn | 10:a32b1216d4ed | 455 | array[83]= J; /// sets the latest plot into the array |
JakBlackburn | 9:163159830eaf | 456 | for (int i=0; i<84; i++) { /// loops through the array |
JakBlackburn | 9:163159830eaf | 457 | lcd.setPixel(i,48 - array[i]); ///setting the plots. as 0,0 is top left so must be taken from 47 |
JakBlackburn | 9:163159830eaf | 458 | for(int fill=47; fill>(48 - array[i]); fill--){ |
JakBlackburn | 9:163159830eaf | 459 | lcd.setPixel(i,fill);// then filling the whole line from the plot to the bottom of the screen |
JakBlackburn | 9:163159830eaf | 460 | } |
JakBlackburn | 11:2b3d646e3bfb | 461 | } |
JakBlackburn | 9:163159830eaf | 462 | for (int i=83; i>-1; i--) { /// loops through the array |
JakBlackburn | 9:163159830eaf | 463 | PrevArray[i]= array[i]; |
JakBlackburn | 9:163159830eaf | 464 | array[i]=PrevArray[i+1]; |
JakBlackburn | 9:163159830eaf | 465 | } |
JakBlackburn | 9:163159830eaf | 466 | if(state==1) { |
JakBlackburn | 9:163159830eaf | 467 | sprintf(Dbuffer, "%.2f", distance*unitX); /// prints the value to the serial port. |
JakBlackburn | 9:163159830eaf | 468 | } else if(state !=1) { |
JakBlackburn | 9:163159830eaf | 469 | sprintf(Dbuffer, "%.0f", distance*unitX); |
JakBlackburn | 9:163159830eaf | 470 | } |
JakBlackburn | 9:163159830eaf | 471 | lcd.printString (Gbuffer,55,0);/// prints the time at the top of the screen |
JakBlackburn | 9:163159830eaf | 472 | lcd.printString (Dbuffer,0,0);///prints the distance |
JakBlackburn | 9:163159830eaf | 473 | lcd.printString (units,24,0);///and the units |
JakBlackburn | 9:163159830eaf | 474 | lcd.refresh(); /// it then refreshes the screen |
JakBlackburn | 0:73bfbe8729d4 | 475 | } |