2. The C program in Figure 1 is to show the elapsed time on LCD display in seconds. The program uses a Ticker with a period of 10ms to control system timing. (1) Modify the program such that it uses a time base of 1 ms to drive the clock. (2) Modify the program in such a way displays elapsed time in hours, minutes and seconds.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter3: Assignment, Formatting, And Interactive Input
Section3.6: A Case Study: Acid Rain
Problem 9E
icon
Related questions
icon
Concept explainers
Question
#include "mbed.h"
#include "C12832_lcd.h"
int counter = 0, seconds = 0;
int flag = 0;
C12832_LCD lcd;
Ticker tick;
void T1_isr ()
{
counter++;
if (counter >= 100)
}
seconds++;
counter = 0;
flag = 1;
int main(){
// clock tick
//1 second has passed?
while(1) {
// Yes increment seconds
// reset counter
// set flag to update display
tick.attach_us(&T1_isr, 10000);
lcd.cls();
lcd.locate(0,0);
lcd.printf("Elapsed Time Monitor"); //print header
while (flag == 0);
lcd.locate(0,15);
lcd.printf("Elapsed Seconds: %d", seconds);
flag = 0; //reset flag
}
Figure 1
// wait for new data
Transcribed Image Text:#include "mbed.h" #include "C12832_lcd.h" int counter = 0, seconds = 0; int flag = 0; C12832_LCD lcd; Ticker tick; void T1_isr () { counter++; if (counter >= 100) } seconds++; counter = 0; flag = 1; int main(){ // clock tick //1 second has passed? while(1) { // Yes increment seconds // reset counter // set flag to update display tick.attach_us(&T1_isr, 10000); lcd.cls(); lcd.locate(0,0); lcd.printf("Elapsed Time Monitor"); //print header while (flag == 0); lcd.locate(0,15); lcd.printf("Elapsed Seconds: %d", seconds); flag = 0; //reset flag } Figure 1 // wait for new data
2. The C program in Figure 1 is to show the elapsed time on LCD display in seconds. The
program uses a Ticker with a period of 10ms to control system timing.
(1) Modify the program such that it uses a time base of 1 ms to drive the clock.
(2) Modify the program in such a way displays elapsed time in hours, minutes and seconds.
Transcribed Image Text:2. The C program in Figure 1 is to show the elapsed time on LCD display in seconds. The program uses a Ticker with a period of 10ms to control system timing. (1) Modify the program such that it uses a time base of 1 ms to drive the clock. (2) Modify the program in such a way displays elapsed time in hours, minutes and seconds.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning