Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

printf() Function Library (rprintf.c)
[General Libraries]

Detailed Description

 #include "rprintf.h" 
The rprintf function library provides a simplified (reduced) version of the common C printf() function.  See the code files for details about which printf features are supported.  Also in this library are a variety of functions for fast printing of certain common data types (variable types).  Functions include print string from RAM, print string from ROM, print string snippet, print hex byte/short/long, and a custom-formatted number print, as well as an optional floating-point print routine.
All output from the rprintf library can be directed to any device or software which accepts characters.  This means that rprintf output can be sent to the UART (serial port) or can be used with the LCD display libraries to print formatted text on the screen.


#define STRING_IN_RAM   0
#define STRING_IN_ROM   1
#define rprintfProgStrM(string)   (rprintfProgStr(PSTR(string)))
#define rprintf1(format, args...)   rprintf1RamRom(STRING_IN_ROM, PSTR(format), ## args)
#define rprintf1RAM(format, args...)   rprintf1RamRom(STRING_IN_RAM, format, ## args)
#define rprintf(format, args...)   rprintf1RamRom(STRING_IN_ROM, PSTR(format), ## args)


void rprintfInit (void(*putchar_func)(unsigned char c))
void rprintfChar (unsigned char c)
 prints a single character to the current output device
void rprintfStr (char str[])
 prints a null-terminated string stored in RAM
void rprintfStrLen (char str[], unsigned int start, unsigned int len)
void rprintfProgStr (const prog_char str[])
void rprintfCRLF (void)
void rprintfu04 (unsigned char data)
 Print 4-bit hex number. Outputs a single hex character.
void rprintfu08 (unsigned char data)
 Print 8-bit hex number. Outputs two hex characters.
void rprintfu16 (unsigned short data)
 Print 16-bit hex number. Outputs four hex characters.
void rprintfu32 (unsigned long data)
 Print 32-bit hex number. Outputs eight hex characters.
void rprintfNum (char base, char numDigits, char isSigned, char padchar, long n)
int rprintf1RamRom (unsigned char stringInRom, const char *format,...)

Define Documentation

#define rprintfProgStrM string   )     (rprintfProgStr(PSTR(string)))

Using the function rprintfProgStrM(...) automatically causes your string to be stored in ROM, thereby not wasting precious RAM. Example usage:

    rprintfProgStrM("Hello, this string is stored in program rom");

Definition at line 93 of file rprintf.h.

Function Documentation

int rprintf1RamRom unsigned char  stringInRom,
const char *  format,

A simple printf routine. Called by rprintf() - does a simple printf (supports d, x, c). Supports:

  • d - decimal
  • x - hex
  • c - character

Definition at line 320 of file rprintf.c.

void rprintfCRLF void   ) 

Prints a carriage-return and line-feed. Useful when printing to serial ports/terminals.

Definition at line 134 of file rprintf.c.

void rprintfInit void(*)(unsigned char c)  putchar_func  ) 

Initializes the rprintf library for an output stream. You must call this initializer once before using any other rprintf function. The argument must be a character stream output function.

void rprintfNum char  base,
char  numDigits,
char  isSigned,
char  padchar,
long  n

A flexible integer-number printing routine. Print the number "n" in the given "base", using exactly "numDigits". Print +/- if signed flag "isSigned" is TRUE. The character specified in "padchar" will be used to pad extra characters.


    uartPrintfNum(10, 6,  TRUE, ' ',   1234);  -->  " +1234"
    uartPrintfNum(10, 6, FALSE, '0',   1234);  -->  "001234"
    uartPrintfNum(16, 6, FALSE, '.', 0x5AA5);  -->  "..5AA5"

Definition at line 194 of file rprintf.c.

void rprintfProgStr const prog_char  str[]  ) 

prints a string stored in program rom

This function does not actually store your string in program rom, but merely reads it assuming you stored it properly.

Definition at line 119 of file rprintf.c.

void rprintfStrLen char  str[],
unsigned int  start,
unsigned int  len

Prints a section of a string stored in RAM. Begins printing at position indicated by <start>, and prints number of characters indicated by <len>.

Definition at line 89 of file rprintf.c.

Generated on Sun Oct 29 03:41:09 2006 for Procyon AVRlib by  doxygen 1.4.2