use commands move and mvprintw in c language to code this binary clock that sleeps for one second and changes display. time in the format 'h:m:s:" will be provided by user input. i have a clock.sh that displays the time in "h:m:s" format every second. This is the code in clock.sh. while true; do current_time=$(date +"%T") # Get the current time in HH:MM:SS format echo "$current_time" sleep 1 done  Now, i need a display that looks like the below picture all this code will be put in a GitLab file named display-nopi.c. Here is my current code for this file.  #include #include "display-nopi.h" static int is_display_open = 0; int open_display(void) {     if (!is_display_open) {         initscr();         start_color();         init_pair(1, COLOR_RED, COLOR_BLACK);         init_pair(2, COLOR_GREEN, COLOR_BLACK);         init_pair(3, COLOR_BLUE, COLOR_BLACK);         is_display_open = 1;         return 1;     }     return 0; } void display_time(int hours, int minutes, int seconds) {     if (is_display_open) {         clear();         display_hours(hours);         display_colons();         display_minutes(minutes);         display_colons();         display_seconds(seconds);         refresh();     } } void display_colons(void) {     attron(COLOR_PAIR(1));     mvaddch(3, 16, ':');     mvaddch(3, 20, ':');     attroff(COLOR_PAIR(1)); } void display_hours(int hours) {     mvprintw(3, 14, "%02d", hours); } void display_minutes(int minutes) {     attron(COLOR_PAIR(2));     mvprintw(3, 17, "%02d", minutes);     attroff(COLOR_PAIR(2)); } void display_seconds(int seconds) {     attron(COLOR_PAIR(3));     mvprintw(3, 21, "%02d", seconds);     attroff(COLOR_PAIR(3)); } void close_display(void) {     if (is_display_open) {         endwin();         is_display_open = 0;     } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

use commands move and mvprintw in c language to code this binary clock that sleeps for one second and changes display. time in the format 'h:m:s:" will be provided by user input. i have a clock.sh that displays the time in "h:m:s" format every second. This is the code in clock.sh.

while true; do

current_time=$(date +"%T") # Get the current time in HH:MM:SS format

echo "$current_time"

sleep 1

done 

Now, i need a display that looks like the below picture

all this code will be put in a GitLab file named display-nopi.c. Here is my current code for this file. 

#include <ncurses.h>
#include "display-nopi.h"

static int is_display_open = 0;

int open_display(void) {
    if (!is_display_open) {
        initscr();
        start_color();
        init_pair(1, COLOR_RED, COLOR_BLACK);
        init_pair(2, COLOR_GREEN, COLOR_BLACK);
        init_pair(3, COLOR_BLUE, COLOR_BLACK);
        is_display_open = 1;
        return 1;
    }
    return 0;
}

void display_time(int hours, int minutes, int seconds) {
    if (is_display_open) {
        clear();
        display_hours(hours);
        display_colons();
        display_minutes(minutes);
        display_colons();
        display_seconds(seconds);
        refresh();
    }
}

void display_colons(void) {
    attron(COLOR_PAIR(1));
    mvaddch(3, 16, ':');
    mvaddch(3, 20, ':');
    attroff(COLOR_PAIR(1));
}

void display_hours(int hours) {
    mvprintw(3, 14, "%02d", hours);
}

void display_minutes(int minutes) {
    attron(COLOR_PAIR(2));
    mvprintw(3, 17, "%02d", minutes);
    attroff(COLOR_PAIR(2));
}

void display_seconds(int seconds) {
    attron(COLOR_PAIR(3));
    mvprintw(3, 21, "%02d", seconds);
    attroff(COLOR_PAIR(3));
}

void close_display(void) {
    if (is_display_open) {
        endwin();
        is_display_open = 0;
    }
}

The display will look something like this (displaying 21:10:37, using a 24-hour clock to display 21H, 10M, 37S):
HMS
<= Top two rows unused
<= 32s binary digit
<= Note: indicated by groups of four lit white LEDs
<= Ones binary digit
The hours, minutes, and seconds must be displayed in three distinct colors, and in any orientation. Note that if the
ones digit is on the bottom, the seconds must be on the right, while if the ones digit is at the top, the seconds must
be on the left. Here is a video showing the clock in operation on a Raspberry Pi: clock.mov
The main "clock" program compiled from C is designed to read times from stdin and display them as above. To
make a complete clock, a "shell script" called clock.sh must print the times to be displayed by the clock executable.
The complete project is broken into these two pieces so that each can be independently tested.
Transcribed Image Text:The display will look something like this (displaying 21:10:37, using a 24-hour clock to display 21H, 10M, 37S): HMS <= Top two rows unused <= 32s binary digit <= Note: indicated by groups of four lit white LEDs <= Ones binary digit The hours, minutes, and seconds must be displayed in three distinct colors, and in any orientation. Note that if the ones digit is on the bottom, the seconds must be on the right, while if the ones digit is at the top, the seconds must be on the left. Here is a video showing the clock in operation on a Raspberry Pi: clock.mov The main "clock" program compiled from C is designed to read times from stdin and display them as above. To make a complete clock, a "shell script" called clock.sh must print the times to be displayed by the clock executable. The complete project is broken into these two pieces so that each can be independently tested.
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY