ucglib_xmega_hal  4.0
Xmega Hardware Abstraction Layer for Ucglib
ucg_print.c File Reference

Print facilities for ucglib from Oli Kraus. More...

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "ucg.h"

Functions

void ucg_PrintInit (ucg_t *ucg)
 Initializes the printing facilities compatible with Arduino/C++ version of library. More...
 
void ucg_GetPrintPos (ucg_t *ucg, ucg_int_t *x, ucg_int_t *y)
 Gets the current position of the 'print cursor'. More...
 
void ucg_SetPrintPos (ucg_t *ucg, ucg_int_t x, ucg_int_t y)
 Sets the position for next "print" command. More...
 
void ucg_SetPrintDir (ucg_t *ucg, uint8_t dir)
 Sets the direction for next "print" command. More...
 
int ucg_Print (ucg_t *ucg, char *fmt,...)
 Put a formatted string to the display at the current position and in the current direction. More...
 

Detailed Description

Print facilities for ucglib from Oli Kraus.

Author
Wim Dolman (w.e.dolman@hva.nl)
Date
30-09-2020
Version
4.0

This is an addition to the c-implementation of Oli Kraus.

The Arduino/C++ implementation of ucglib contains extra printing facilities. This file contains a bunch of functions that implements the same facilities. So you can use ucg_SetPrintPos(), ucg_SetPrintDir() and in stead of print and println you can use ucg_Print() which prints a formatstring.

This print facility uses the user pointer in the struct ucg_t. To use this pointer you need to remove the comment (at line 100 in ucg.h), before the macrodefinition of WITH_USER_PTR

         / * Define this for an additional user pointer inside the ucg data struct * /
         #define WITH_USER_PTR

Originally these functionality was added in the Xmega Hardware Abstraction Layer (version 2.0, 2.1 and 3.0). From vesion 4.0 this functionality is separated from the HAL.

Function Documentation

◆ ucg_GetPrintPos()

void ucg_GetPrintPos ( ucg_t *  ucg,
ucg_int_t *  x,
ucg_int_t *  y 
)

Gets the current position of the 'print cursor'.

Parameters
ucgpointer to struct for the display
xpointer to a variable for the x-coordinate of the current position
ypointer to a variable for the y-coordinate of the current position
Returns
void

◆ ucg_Print()

int ucg_Print ( ucg_t *  ucg,
char *  fmt,
  ... 
)

Put a formatted string to the display at the current position and in the current direction.

This replaces print and println from the Arduino implementation of ucg_lib

The Arduino style:

*          ucg.print("text ");
*          ucg.print(x);     // x is an int
*          ucg.print(" more text ");
*          ucg.print(y);     // y is a float
*          ucg.println(";"); 

The replacement in Xmega style:

*          ucg_Print(&ucg, "text %d more text %f;\n", x, y); 
Parameters
ucgpointer to struct for the display
fmtformatstring with escape sequences
...variables that are printed
Returns
number of printed characters

◆ ucg_PrintInit()

void ucg_PrintInit ( ucg_t *  ucg)

Initializes the printing facilities compatible with Arduino/C++ version of library.

Parameters
ucgpointer to struct for the display
Returns
void

◆ ucg_SetPrintDir()

void ucg_SetPrintDir ( ucg_t *  ucg,
uint8_t  dir 
)

Sets the direction for next "print" command.

Parameters
ucgpointer to struct for the display
dirthe direction
Returns
void

◆ ucg_SetPrintPos()

void ucg_SetPrintPos ( ucg_t *  ucg,
ucg_int_t  x,
ucg_int_t  y 
)

Sets the position for next "print" command.

Parameters
ucgpointer to struct for the display
xx-coordinate of the position
yy-coordinate of the position
Returns
void