C · Local Linux terminal
Bounce a line between two terminal rows
Online version: https://fpga.labsland.com/altera/embedded-systems/lab-05/part-03/
Your computer
How can you tell a real bounce from a line that simply misses the boundary? Write down the last three row numbers you expect before and after the lower turn. The display is 12 rows high. A twelve-character bar moves one row per frame, starting at row 1.
Use a Linux terminal with at least 32 columns and 14 rows. From the extracted starter directory run:
cc -std=c11 -O2 -Wall -Wextra -Werror terminal.c -o terminal
./terminal 28 350
The arguments select the number of frames and the delay in milliseconds. Use a second terminal or a screen recording if you want to count at your own pace. The program restores your cursor when it finishes. Running ./terminal animates continuously until Ctrl-C.
| Observation | Your prediction | Starter | Repaired program |
|---|---|---|---|
| Lowest row reached | |||
| Rows around the lower turn | |||
| Frames between visits to row 1 |
Read the test that decides whether to reverse the direction. Repair it so every row from 1 through 12 is visited and the bar never crosses either edge. Compare ./terminal 20 50 with ./terminal 20 200. Predict the elapsed time for each, measure with time, and explain small differences. Check the cursor after interrupting one continuous run.
Original LabsLand activity following FPGAcademy Embedded Systems Lab 5, Part III. Original handout · MIT
