oled 1.0
OLED Graphics Control Library
|
Source file with implementation of TTY text output interface on OLED display. More...
#include "tty.h"
Functions | |
void | tty_init (void) |
Initializes the TTY text output interface. | |
void | tty_clear_line (unsigned char line) |
Clears a specific text line on the TTY interface. | |
void | tty_cursor (unsigned char column, unsigned char line) |
Sets the cursor position in the TTY text interface. | |
char | tty_putchar (char character) |
Writes a single character to the TTY text interface on the OLED display. | |
void | tty_string (const char *string) |
Writes a null-terminated string to the TTY text interface. | |
int | tty_printf (char data, FILE *stream) |
Writes a single character to the TTY interface (used as a printf output function). |
Source file with implementation of TTY text output interface on OLED display.
This file contains the implementation of functions for text rendering on a graphical OLED display. It supports cursor positioning, character and string output, line clearing, and optional printf-style formatted output. The interface handles autoscrolling and dynamic character spacing for improved readability. The TTY layer relies on the OLED display driver and font data modules. It abstracts text rendering as characters drawn via pixel data segments using the configured font, respecting display size and constraints. Compile-time options toggle support for autoscroll, dynamic text spacing, and printf functionality.
void tty_clear_line | ( | unsigned char | line | ) |
Clears a specific text line on the TTY interface.
line | The line number (0-based) to clear. Must be less than TTY_HEIGHT. |
This function checks if the specified line is within the valid range of the display. If it is, the function clears the corresponding page on the OLED display associated with that text line.
void tty_cursor | ( | unsigned char | column, |
unsigned char | line ) |
Sets the cursor position in the TTY text interface.
column | The column index (0-based) to move the cursor to. Must be less than TTY_WIDTH. |
line | The line index (0-based) to move the cursor to. Must be less than TTY_HEIGHT. |
This function validates the requested cursor position to ensure it's within the display bounds. If valid, it updates the internal cursor tracking variables for character column and line. It then sets the corresponding pixel position on the OLED display by converting the column to pixel coordinates based on the font width and updating the OLED cursor to that position.
void tty_init | ( | void | ) |
Initializes the TTY text output interface.
This function initializes internal state variables for cursor position and scrolling, resets dynamic text spacing if enabled, and initializes the underlying OLED display. It clears the OLED screen to prepare for new text output. If printf support is enabled, it also configures the standard output stream stdout to use the TTY's printf handler function, allowing formatted output via standard C library functions.
int tty_printf | ( | char | data, |
FILE * | stream ) |
Writes a single character to the TTY interface (used as a printf output function).
data | The character to output. |
stream | Pointer to the output stream (unused, required by standard library interface). |
This function acts as a character output handler compatible with the standard C library printf mechanism. It redirects characters from formatted output to the TTY text rendering function tty_putchar.
char tty_putchar | ( | char | character | ) |
Writes a single character to the TTY text interface on the OLED display.
character | The ASCII character to display. |
This function validates the input character against the supported font ASCII range, ignoring characters outside this range except newline (‘’
'). If the character is a newline, it triggers a line break via tty_newline(). For printable characters, it retrieves the pixel data bitmap from the font module. When dynamic text spacing (TTY_DYNAMIC_TEXT) is enabled, the function adjusts horizontal spacing to minimize large gaps between characters by manipulating tty_dynamic_text_rstrip. It draws the character on the current line and position using oled_page_segment`. When dynamic spacing is disabled, fixed character width spacing is used.
void tty_string | ( | const char * | string | ) |
Writes a null-terminated string to the TTY text interface.
string | Pointer to the null-terminated character array (C-string) to display. |
This function iterates through each character of the input string until it encounters the string terminator (‘’\0'). Each character is passed to tty_putchar` for rendering on the OLED display, thereby displaying the entire string sequentially.