C代写-Lab #8 (Option 1): Implementing a Scrolling Display

Lab #8 (Option 1): Implementing a Scrolling Display

Problem Summary

You are given a system that consists of 8 LED displays and two toggle switches (the DAQ hardware module or the simulator). The 8 LED displays are arranged in a row and will be called an LED screen. You are to write a program in C that displays a scrolling message on the LED screen.

This option for the lab is divided up into two parts: a required part, and an optional part (for additional bonus marks). Both parts will display a scrolling message on the LED screen. The optional part also uses two switches to control how the message is scrolled and gives an option to the user to select the message.

Writing the Message to Display

You can choose the message that you want to display, but please note the following:

·ideally your message should be a short word or phrase.

·the message should be at least 4 characters long, where at least 3 of the characters should be English letters (not just digits, etc).

·there is no maximum length on your message as long as it can be used efficiently to test the functionality of the program as described, but shorter messages are preferred and will probably be easier to test.

·your message does not have to be unique; it is OK if you happen to have the same message as somebody else.

·note that not all English letters can be displayed, so you may need to mix upper and lower case letters to have a meaningful word. Do not use a word that has characters that you cannot display on the 7-segment displays.

·for each letter, you will have to determine the data value to write to the LED display in order to display the character.

·In your program you may use one particular message only. However, your algorithm should not be solely dependent on the message it is displaying (i.e. it must be algorithmic and it must be possible to change the message).

One way to do this is to store the data values for each character in a message array. Note that your message array would not normally be a String.

Problem – Required Part

In this part you only use the LED screen. The LED screen consists of 8 LED displays. The first display on the right is at position #0 and the last display on the left is at position #7.

Your program should update the LED screen once a second as follows:

·When your program first starts it should display the first character of your message, in the right-most position of the LED display (position 0).

·After one second it should update the display by scrolling your message one character to the left (i.e. first character at position 1, second character at position 0).

·Your program should continue to update the display by scrolling your message one character per second until it has completely scrolled off the left end of the display.

·Once your message has scrolled off the display, your program should start again at the first step above, i.e. first character at position 0.

·Your program should continue this process until you quit the program.

As an example, suppose your message is “dog”. The following would appear on the LED screen, where each column is the corresponding position on the LED screen, and each row represents the updated screen after one second has elapsed:

— note a completely blank display here for 1 second —
— etc —

Note that “dog” is not a valid message – while all the letters can be displayed on the LED screen, it does not meet the minimum length requirement.

Problem – Optional Part (for 25% extra bonus marks)

This part is optional, allowing you to get up to an additional 25% on this lab. Note that the bonus marks will not allow you to get more than 100% on your “overall” lab mark, it will help you though to improve your marks of earlier labs (for example lab 7, or/and lab 5, …). Note that you can also get partial mark if you implement only a part of the optional bonus part. You need to add a comment at the top of your program to indicate you are implementing the bonus part as well.

For the optional part, you will add the direction and speed control to your program and you also give the user the option to choose the displayed message.

A) This part uses both the LED screen as well as the two switches. The two switches are connected to input channels numbered 0 and 1.

·Switch #0 is connected to channel #0, and is called the DIRECTION switch.

·Switch #1 is connected to channel #1 and is called the SPEED switch.

For this part, your program should operate as described above with the following additions:

·When the SPEED switch is off, the display should be updated once every second. When the SPEED switch is on, the display should be updated once every 0.5 seconds.

·When the DIRECTION switch is off, the message should scroll to the left (as in the required part above). When the DIRECTION switch is on, the display should scroll to the right. When scrolling to the right, the operation is simply the reverse of scrolling to the left.

B) At the very beginning, the program should ask the user to choose between two pre-determined messages (of different sizes). Then your program will use the message user selected to display. Note this selection is done once at the very beginning when the program is run (No need for provision to change it after the message is selected). The two messages must be of two different sizes.

Example: An example for prompting the user for selecting between the two example messages SHOP and HELLO could be:

printf(“Please choose which message to display.\n”);
printf(“Message 1: SHOP,\n”);
printf(“Message 2: HELLO.\n”);
printf(“Please enter 1 or 2: “);
scanf(“%d”, &choice); /* choice is an int variable */

Using Simulator / Hardware Module

The simulator will allow you to test your program without the need for the actual hardware module. The program will be identical for either the simulator or the hardware. To access the simulator configuration for this problem, you should specify a setupNum of 4, when calling the setupDAQ() function. You will find the simulator under the “Part 2 – Lecture contents” page on your Connect home.

If you are working in a TA-supervised lab, you will be able to use the actual hardware module if you wish so. The hardware module also has 2 switches and 8 LED displays arranged in a row as an LED screen. To use the hardware module, you should specify a setupNum of 0, when calling the setupDAQ function. Note that you will only have access to the hardware module while a TA is present in the lab.

Algorithm development and coding

Carefully read the Problem Statement above and try to decompose the problem into smaller and manageable parts. Proceed step by step, and debug often. As before, you need to use good programming practices, and you need to add sufficient comments to your code.

Your program should include at least the main and scrollMessage functions. Your program should follow the same basic structure of the in-class examples, i.e. the main function should perform the necessary initialization and then call the scrollMessage function. You are allowed to use any code segment that you think you may need in your program from the in-class programming exercises E1 to E7 (solutions are posted on Connect).

The scrollMessage function (and any additional functions you define) should implement all of the logic of the message scrolling, and continue looping until the user decides to quit. You are free to define any additional functions that you may find useful.

Create a new project in Visual Studio to implement your program in programming language C. Compile your code regularly and remove any syntax errors as you go. Refer to the course notes for information on how to access the functions provided by the DAQ library.

Developing a test suite

You should also think about how to develop a test suite that can be used to test your program once it is written. Refer to the notes in earlier labs on how to choose appropriate test values.

Having chosen your test values, determine the expected output.

·Testing: Once your code has successfully compiled, verify that it produces correct results using the test suite that you developed earlier. If any of your tests fails, you must look for logic errors in your algorithm (which will, of course, have resulted in logic errors in your code).

·Debugging: Now that the programs that you are writing are becoming a little more complex, you might find it useful to use the debugger that is integrated into the Visual Studio environment.


电子邮件地址不会被公开。 必填项已用*标注