All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
vexprintf.c File Reference

Lightweight printf with float support. More...

#include <string.h>
#include <stdarg.h>
#include "ch.h"
#include "hal.h"
#include "vex.h"

Data Structures

struct  _pdefs
 

Macros

#define vexStreamPut(stream, c)   chIOPut( stream, c );
 
#define PRINT_BUF_LEN   16
 
#define THROTTLE_DELAY   30
 move one character to output More...
 
#define THROTTLE_DELAY_4   8
 
#define PAD_NORMAL   0
 move string to output with padding More...
 
#define PAD_RIGHT   1
 
#define PAD_ZERO   2
 

Typedefs

typedef struct _pdefs pdefs
 

Functions

void vex_print_acquire (pdefs *p)
 acquire lock on print variables More...
 
void vex_print_release (pdefs *p)
 release lock on print variables More...
 
int vex_printf (const char *format,...)
 send formated string to the console More...
 
int vex_chprintf (vexStream *chp, const char *format,...)
 send formated string to a vexStream More...
 
int vex_vprintf (const char *format, va_list args)
 send formated string to a vexStream More...
 
int vex_vchprintf (vexStream *chp, const char *format, va_list args)
 send formated string to a vexStream More...
 
int vex_sprintf (char *out, const char *format,...)
 create formated string in a buffer More...
 
int vex_snprintf (char *out, uint16_t max_len, const char *format,...)
 create formated string in a buffer More...
 
int vex_vsprintf (char *out, const char *format, va_list args)
 create formated string in a buffer from a va_list More...
 
int vex_vsnprintf (char *out, uint16_t max_len, const char *format, va_list args)
 create formated string in a buffer from a va_list More...
 

Detailed Description

Lightweight printf with float support.

Macro Definition Documentation

#define vexStreamPut (   stream,
 
)    chIOPut( stream, c );
#define PRINT_BUF_LEN   16
#define THROTTLE_DELAY   30

move one character to output

Parameters
[in]ppointer to our working variables, a pdef structure
[in]cthe character to output

This function moves one character to the output buffer, if the buffer is NULL then the character is sent to the standard console

#define THROTTLE_DELAY_4   8
#define PAD_NORMAL   0

move string to output with padding

Parameters
[in]ppointer to our working variables, a pdef structure
[in]stringthe string to output
[in]widthrequired output width
[in]padtype of padding, left, right, zeros
Returns
the number of characters that were output

This function moves a string into the output buffer with required padding

#define PAD_RIGHT   1
#define PAD_ZERO   2

Typedef Documentation

typedef struct _pdefs pdefs

Function Documentation

void vex_print_acquire ( pdefs p)
inline

acquire lock on print variables

Parameters
[in]ppointer to our working variables, a pdef structure
void vex_print_release ( pdefs p)
inline

release lock on print variables

Parameters
[in]ppointer to our working variables, a pdef structure
int vex_printf ( const char *  format,
  ... 
)

send formated string to the console

Parameters
[in]formatThe format string
Returns
the number of characters that were output

This has similar but reduced functionality to the standard library function sprintf

int vex_chprintf ( vexStream chp,
const char *  format,
  ... 
)

send formated string to a vexStream

Parameters
[in]chpThe stream
[in]formatThe format string
Returns
the number of characters that were output

This function is used as a direct replacement for chprintf. It has similar but reduced functionality to the standard library function sprintf.

int vex_vprintf ( const char *  format,
va_list  args 
)

send formated string to a vexStream

Parameters
[in]formatThe format string
[in]argsvariable argument list
Returns
the number of characters that were output

This has similar but reduced functionality to the standard library function sprintf. This version takes a variable argument list directly.

int vex_vchprintf ( vexStream chp,
const char *  format,
va_list  args 
)

send formated string to a vexStream

Parameters
[in]chpThe stream
[in]formatThe format string
[in]argsvariable argument list
Returns
the number of characters that were output

This has similar but reduced functionality to the standard library function sprintf. This version takes a variable argument list directly and can also output to a stream that is not the CONSOLE.

int vex_sprintf ( char *  out,
const char *  format,
  ... 
)

create formated string in a buffer

Parameters
[out]outThe output buffer
[in]formatThe format string
Returns
the number of characters that were output

This has similar but reduced functionality to the standard library function sprintf

int vex_snprintf ( char *  out,
uint16_t  max_len,
const char *  format,
  ... 
)

create formated string in a buffer

Parameters
[out]outThe output buffer
[out]max_lenThe output buffer length
[in]formatThe format string
Returns
the number of characters that were output

This has similar but reduced functionality to the standard library function sprintf

int vex_vsprintf ( char *  out,
const char *  format,
va_list  args 
)

create formated string in a buffer from a va_list

Parameters
[out]outThe output buffer
[in]formatThe format string
[in]argsa variable argument list
Returns
the number of characters that were output

This has similar but reduced functionality to the standard library function sprintf

int vex_vsnprintf ( char *  out,
uint16_t  max_len,
const char *  format,
va_list  args 
)

create formated string in a buffer from a va_list

Parameters
[out]outThe output buffer
[out]max_lenThe output buffer length
[in]formatThe format string
[in]argsa variable argument list
Returns
the number of characters that were output

This has similar but reduced functionality to the standard library function sprintf