讲解:CSC 230、ASCII、Python,Java、c/c++SPSS|Haskell

CSC 230 Assignment 3Due Sunday, November 21, 2019 at 11:55pmLate submissions will not be graded.OverviewThe goal of this assignment is to implement the Collatz sequence explorer. Wehave already seen the Collatz sequence in Assignment 1, where we counted thenumber of elements in the sequence. To do this, we implemented an algorithmwhich computes each value in the sequence and counts how many there are. Forthis assignment, in addition to counting them, you are also expected to outputeach value and its position (or count) in the sequence on the liquid crystaldisplay (LCD).The initial starting value for the sequence will be obtained from the user via thebuttons on the LCD Shield (as described in Specifications below). Upon userconfirmation, the device should display the initial value, whatever it is, and itscount of 0 at the designated locations on LCD. After a short time-delay, thedevice will advance to the next value and display its corresponding count of1. The value and its count will continue advancing with a predetermined timedelaybetween them until the value reaches 1, at which point the last valueand its count will remain on the screen until the user selects another value.The time-delay period will be chosen by the user, as described in Specificationsbelow.While the Collatz sequence is advancing on the screen, the user should be ableto continue to interact with the input prompt using the LCD shield buttons.At any time, when the user changes the speed setting, the time-delay shouldbe adjusted accordingly and immediately. Similarly, when the user changes thestarting value and confirms the selection, immediately upon confirmation, thesequence display will update with the new starting value and start advancingfrom there.This assignment is composed of several sub-problems that can be completed andtested separately before combining them into the final solution. This assignmentbuilds on the previous assignments and labs. You are welcome to use your ownpreviously written code or the solutions provided to you on conneX duringthis course. If you use any of the solutions from conneX, you should referencethem appropriately in the comments. For example, if you copied and modifiedthe init to string function from Lab 7, then you could say: ”This function is amodified version of the function int to string from Lab 7, CSC 230, Fall 2019”in the comments.1Specifications• Program start:When the device starts, or when the reset button is pressed, the LCDscreen should display your first and last name and the phrase ”CSC 230 -Fall 2019” for a period of 1 second. Then, the screen should change to thesame as shown in the picture below. The cursor should be set to the leastsignificant digit of the initial Collatz value (“n=”). The speed should beinitialized at 0. The initial Collatz sequence value should be initialized at0, and its count should be initialized at 0.• The LCD screen layout:n = 0 0 0 * S P D : 0c n t : 0 v : 0The input fields are highlighted using boldface.– Top row is designated for prompting the user for the input.◦ The first three digits (initialized as zeroes), which are next tothe ”n=”, are designated for inputting the new starting value ofthe Collatz sequence to be displayed. These digits are updatedone at a time when the cursor is on each of them and the userpresses UP or DOWN buttons on the LCD shield. For example,if the cursor is on the first of the three digits and that digit iscurrently showing as ”5”, pressing UP will change it to ”6”.This initial starting value could range between 0 and 999.◦ The asterisk (*) is for confirming the starting value for the newCollatz sequence. When the cursor is on the asterisk and theuser presses UP or DOWN, the current value and its countwill be updated immediately to the new value and its initialnew count of zero. Then it will continue advancing (or not)according to the current speed setting.◦ The last digit (also initialized as zero), which is next to the”SPD:” is for controlling the amount of time to wait beforeadvancing to the next value in the given Collatz sequence. Thisspeed digit is updated when the cursor is on it and the userpresses UP or DOWN in a similar fashion as the first threedigits described above. This speed value could range between 0and 9.– Bottom row is designated for displaying the current value and itscount in the given Collatz sequence.◦ The numbers are periodically updated to the next value and itscount based on a user-determined time-delay.2◦ The time-delay between advances to the next value is determinedby speed value, which is displayed in the first row of theLCD screen and explained further below.◦ The maximum possible count could be 3 decimal digits longand the maximum possible value could be 6 decimal digits long,hence the corresponding space provided between “0” and “:” onthe second row in the picture above.Suggestion: Store two strings of length 171in memory and periodicallyupdate the LCD with those strings (lcd puts function). To change themessage being displayed, update these strings (e.g. via ISR), and not theLCD, as it will get updated as per previous sentence.• The cursor:◦ Since we have several values that can be updated by the user via thesame (shared) set of inpu代写CSC 230、代做ASCII、Python,Java程t controlls (UP and DOWN buttons), weneed some way to indicate specifically which value the user is aboutto change. To do that, we keep track which one is currently beingedited and make the corresponding location on the LCD blink. Theblinking effect can be achieved by repeatedly displaying the blank(space) character for a period of time and then the actual characterthat is supposed to be in that location for a period of time.◦ The user should be able to press the LEFT and RIGHT buttons tomove the cursor between the three digits for the initial Collatz value,the asterisk, and the sped value. So, 5 possible positions in total. Forexample, if the user navigated to the asterisk (*), the asterisk wouldblink; then, if a user was to press the RIGHT button, the cursorwould advance to the speed selection and the sped value would startto blink instead of the asterisk.• The starting value:The initial value for the next Collatz sequence to be computed is obtainedfrom the user.– Input is in range between 0 and 999 (three decimal digits).– Provided by the user via the UP and DOWN buttons. Each digit isupdated when the cursor is on that digit (on the LCD).– Specifies the starting value for the next Collatz sequence.• The delay/speed:The frequency at which the new Collatz value is computed and displayedis obtained from the user.1. 17 = 16 for each LCD character in one row + 1 for the terminating zero.3– Input is in range between 0 and 9 (one decimal digit).– Provided by the user via the UP and DOWN buttons, when thecursor is on the speed digit (on the LCD).– Specifies the delay between Collatz sequence value updates:1 = 1/16 sec. (max. speed of advancing to the next value)2 = 1/8 sec.3 = 1/4 sec.4 = 1/2 sec. ( = 2 Hz)5 = 1.0 sec. ( = 1 Hz)6 = 1.5 sec.7 = 2.0 sec. ( = 0.5 Hz)8 = 2.5 sec.9 = 3.0 sec.0 = full stop (no advancing when speed is 0)• Limits:– Max size of Collatz value (“v:”): 3 bytes.– Max size of Collatz value’s count/position (“cnt:”): 1 byte.– Decimal range of the displayed value (“v:”): 0-999999.– Decimal range of the displayed count (“cnt:”): 0-255.– Decimal range of the speed prompt (“SPD:”) : 0-9.– Decimal range of the starting value prompt (“n=”): 0-999.Additional notes and resourcesIn this assignment you will need to:• Add 24-bit numbers.• Display characters on the LCD screen.• Check which button is pressed on the LCD shield. Both the solution toLab 4 and the solution to Assignment 2 have a suitable starting functionthat can be modified to work for this assignment.• Convert between ASCII characters and binary integers that are as largeas 3 bytes (or 224). Lab 7 has a good starting algorithm that needs to beextended to handle larger values.• Use at least one timer and interrupts for controlling the frequency atwhich the Collatz sequence advances from one value to the next. Lab 8has a timer-driven interrupt example.• Online AVR Timer/Counter calculator: https://eleccelerator.com/avr-timercalculator/.• Online Collatz sequence calculator: https://www.dcode.fr/collatz-conjecture.4Grading guidelines.This assignment is worth 9% of your total grade, this value is distributed amongthe following categories:⇒ All functions must protect (back-up or preserve) registers.3% ⇒ Correct interrupt service routine (ISR). The timing speeds up and slowsdown as per specifications. Zero speed results in a complete stop. Thiscomponent requires knowledge of interrupts, timers, functions, and registerprotection.1% ⇒ At least one function written by you must receive and return a parametervia the stack. This component requires knowledge of functions and stack.5% ⇒ User interface. Marks are distributed in various proportions among thefollowing:– Credits screen (approximately one second).– Cursor blinking and moving based on user input.– Buttons operate as per specifications. Buttons are responsive. Holdingdown a button doesn’t result in multiple presses being registered.– Converting binary to ASCII or vice versa.– Correct Collatz values and counts (on LCD).BONUS (1% to the total course grade) if your program uses a second ISR and aseparate Timer/Counter for checking the button input, this has a prerequisitethat the buttons operate as per specifications and are responsive, and thatholding a button doesn’t register as multiple presses.SubmissionSubmit your solution via conneX. When doing so, verify that your file is actuallyuploaded correctly and is not corrupted. You can do so by navigating back tothe Assignments section, then downloading your a3.asm submission (which youjust uploaded), opening it in an editor and visually verifying its contents.It must be possible to build and run your program on the equipment providedin the labs (using the same procedure discussed in the lab sessions), otherwiseyour solution will not be graded.The solution is worth 9% of your final grade and must be your individualwork. You may discuss the assignment with your fellow students, but you mustwrite your own code from scratch. Sharing code in any way (or receiving sharedcode), either electronically or over the shoulder of another student, will beconsidered plagiarism, even if the code is modified after being shared.Late submissions will not be graded.5转自:http://www.6daixie.com/contents/9/4429.html

你可能感兴趣的:(讲解:CSC 230、ASCII、Python,Java、c/c++SPSS|Haskell)