oled 1.0
OLED Graphics Control Library
|
Source file implementing frame management and drawing functions for OLED display. More...
#include "frame.h"
Functions | |
void | frame_init (void) |
Initializes the frame system and OLED display. | |
void | frame_draw_text (const char *text, DRAWING_Position position) |
Renders a text string on the OLED display at a specified position. | |
void | frame_draw_char (const char character, DRAWING_Position position) |
Renders a single character on the OLED display at a specified position. | |
void | frame_draw_number (const void *number, unsigned char length, NUMBER_Type type, NUMBER_Radix radix, DRAWING_Position position) |
Renders a formatted number on the OLED display at a specified position. | |
void | frame_draw_number_uint (const unsigned int number, unsigned char length, NUMBER_Radix radix, DRAWING_Position position) |
Inline helper function to draw an unsigned integer number on the OLED display. | |
void | frame_draw_number_int (const int number, unsigned char length, NUMBER_Radix radix, DRAWING_Position position) |
Inline helper function to draw a signed integer number on the OLED display. | |
void | frame_clear (void) |
Clears the entire display frame. | |
void | frame_draw_bar (DRAWING_Position position, DRAWING_Size size, unsigned char percent) |
Draws a horizontal progress bar on the OLED display. |
Variables | |
const unsigned char frame_background[8][128] | PROGMEM |
Source file implementing frame management and drawing functions for OLED display.
This file contains the implementation of functions to initialize the frame system, draw text and numbers with various numeric formats, render progress bars, and manage display areas. It supports an optional specific background image stored in program memory, which is drawn and maintained during display updates to ensure visual consistency. The rendering functions integrate with font data and OLED driver modules to output characters and graphical elements. Numeric drawing supports unsigned, signed, and optionally decimal numbers with configurable precision. The code is designed for embedded environments with memory constraints, utilizing PROGMEM for constant data storage and conditional compilation for feature configuration.
void frame_clear | ( | void | ) |
Clears the entire display frame.
This function resets the OLED display content to a blank state by calling oled_clear(). If the compile-time macro FRAME_SPECIFIC_BACKGROUND is defined, it additionally redraws the predefined background image stored in frame_background to maintain the visual context. Without FRAME_SPECIFIC_BACKGROUND, the screen is simply cleared to black.
The function's linkage depends on the background setting:
void frame_draw_bar | ( | DRAWING_Position | position, |
DRAWING_Size | size, | ||
unsigned char | percent ) |
Draws a horizontal progress bar on the OLED display.
This function renders a progress bar at the specified position with the given size, visually representing the completion percentage as a filled section of the bar. The filled area of the bar corresponds to the percentage value (0-100%), calculated as a width increment. The unfilled remainder of the bar is cleared to maintain visual clarity.
position | The starting coordinates (x, y) of the progress bar on the display. |
size | The width and height dimensions of the progress bar. |
percent | The completion percentage to display (0 to 100). |
void frame_draw_char | ( | const char | character, |
DRAWING_Position | position ) |
Renders a single character on the OLED display at a specified position.
This function draws a character bitmap starting at the coordinates specified by position. It determines which display pages are affected based on the font height and divides the character rendering across multiple OLED memory pages if necessary. For each column of the character, the corresponding font data is fetched from the font table and optionally combined with a predefined background buffer (if enabled). Bit shifting is applied to align the character correctly on display pages that do not align with the character boundaries. The final pixel data for each column is sent to the OLED driver via the oled_column function.
character | The ASCII character to be drawn. |
position | The starting position (x, y) on the display for the character. |
void frame_draw_number | ( | const void * | number, |
unsigned char | length, | ||
NUMBER_Type | type, | ||
NUMBER_Radix | radix, | ||
DRAWING_Position | position ) |
Renders a formatted number on the OLED display at a specified position.
This function receives a pointer to a number as any supported type (unsigned, signed, float, or double), converts it to a string representation according to the specified number type and radix (base), and draws the result as text at the given display position. The output can be padded with leading spaces (decimal) or zeros (other bases) to fit the desired field length. Supports decimal, hexadecimal, and other numeric bases, as well as fixed precision for floating-point numbers if FRAME_NUMBER_ENABLE_FLOATING_POINT is defined. Internally utilizes font rendering to display the formatted string.
number | Pointer to the value to display (type selected via the type argument). |
length | Minimum output width in characters (for padding). |
type | The type of the number (unsigned/signed int/long, or float/double if enabled). |
radix | Number base for formatting (e.g., decimal, hexadecimal). |
position | Display coordinates (x, y) for the output string. |
|
inline |
Inline helper function to draw a signed integer number on the OLED display.
This function is a simple wrapper around the generic frame_draw_number function, specifically for signed integers. It passes the address of the given number, the desired output length, radix, and position to the main number drawing function, specifying the type as signed int.
number | The signed integer value to draw. |
length | The minimum number of characters to display (with padding if necessary). |
radix | The numeric base (e.g., decimal, hexadecimal) for displaying the number. |
position | The screen coordinates (x, y) where the number will be rendered. |
|
inline |
Inline helper function to draw an unsigned integer number on the OLED display.
This function wraps the more general frame_draw_number function, providing a convenient interface specifically for unsigned integers. It forwards the number pointer, length, radix, and drawing position to the main number rendering function with the appropriate type parameter.
number | The unsigned integer value to draw. |
length | The minimum number of characters to display (padding as needed). |
radix | The numeric base (e.g., decimal, hexadecimal) for number display. |
position | The coordinates (x, y) on the display where the number will be rendered. |
void frame_draw_text | ( | const char * | text, |
DRAWING_Position | position ) |
Renders a text string on the OLED display at a specified position.
This function draws the given null-terminated string starting at the coordinates specified by position. It calculates affected display pages based on the character height and handles multi-page rendering for characters that span page boundaries. For each character in the string, the corresponding font bitmap is fetched and individual bytes are combined with the optional background pattern (if enabled) to preserve display background beneath the text. Bit-shifting is applied to properly align the character pixels vertically on partial pages. The function outputs the composed columns of pixel data to the OLED display using the lower-level oled_column function.
text | Pointer to the null-terminated string to be drawn. |
position | The starting position (x, y) on the display for the text. |
void frame_init | ( | void | ) |
Initializes the frame system and OLED display.
This function initializes the OLED display by calling the OLED driver initialization function (oled_init()) and then clears the display frame to prepare it for new content using frame_clear(). It should be called once during system startup before any text or graphics are drawn.
const unsigned char frame_background [8][128] PROGMEM |