C · Local Linux terminal
Draw a line one terminal cell at a time
Online version: https://fpga.labsland.com/altera/embedded-systems/lab-05/part-02/
Your computer
Build an integer line plotter for a Linux terminal of at least 32 columns by 14 rows. The C program accepts a first and a last cell as column/row pairs. Its drawing loop keeps an error term to decide whether to move horizontally, vertically, or both.
From the extracted starter directory run:
cc -std=c11 -O2 -Wall -Wextra -Werror terminal.c -o terminal
./terminal
Press Enter after each drawing. The default picture contains a cyan shallow line and a yellow steep line. Supply coordinates to draw one line. For example, run ./terminal 2 3 7 3. Count the marks before pressing Enter.
| Requested endpoints | Predicted cell count | Last cell shown by starter | After repair |
|---|---|---|---|
| (2,3) to (7,3) | |||
| (7,8) to (7,3) | |||
| (9,9) to (3,1) | |||
| (5,5) to (5,5) |
Both endpoints belong to the segment. Decide which loop exit drops a cell, repair it and retest all four rows. For the steep line, explain which coordinate changes on every iteration. Finish by reversing both endpoints of each test and checking the count. Compare the number of characters with the larger of the horizontal and vertical distances.
Original LabsLand activity following FPGAcademy Embedded Systems Lab 5, Part II. Original handout · MIT
