5 * Copyright (C) 1999 Bernardo Innocenti <bernie@develer.com>
6 * Copyright (C) 2003,2004 Develer S.r.l. (http://www.develer.com/)
12 * \author Bernardo Innocenti <bernie@develer.com>
13 * \author Stefano Fedrigo <aleph@develer.com>
15 * \brief printf-family routines for text output
20 * Revision 1.1 2004/05/23 15:43:16 bernie
21 * Import mware modules.
23 * Revision 1.2 2004/03/26 18:50:50 bernie
24 * Move _PROGMEM stuff to compiler.h
26 * Revision 1.1 2004/03/19 16:52:28 bernie
27 * Move printf() like functions from text.c to text_format.c and add PROGMEM versions.
32 #include "formatwr.h" /* _formatted_write() */
36 #include <string.h> /* strlen */
39 * Render string <code>str</code> in bitmap
41 int PGM_FUNC(text_puts)(const char * PGM_ATTR str, struct Bitmap *bm)
45 while ((c = PGM_READ_CHAR(str++)))
52 int PGM_FUNC(text_vprintf)(struct Bitmap *bm, const char * PGM_ATTR fmt, va_list ap)
54 return PGM_FUNC(_formatted_write)(fmt, (void (*)(char, void *))text_putchar, bm, ap);
58 int PGM_FUNC(text_printf)(struct Bitmap *bm, const char * PGM_ATTR fmt, ...)
64 len = PGM_FUNC(text_vprintf)(bm, fmt, ap);
71 int PGM_FUNC(text_xprintf)(struct Bitmap *bm,
72 uint8_t row, uint8_t col, uint8_t mode, const char * PGM_ATTR fmt, ...)
80 text_moveto(bm, row, col);
82 if (mode & TEXT_INVERT)
83 oldstyle = text_style(STYLEF_INVERT, STYLEF_INVERT);
85 if (mode & (TEXT_CENTER | TEXT_RIGHT))
89 pad = bm->width/FONT_WIDTH - PGM_FUNC(vsprintf)(NULL, fmt, ap);
91 if (mode & TEXT_CENTER)
95 text_putchar(' ', bm);
98 len = PGM_FUNC(text_vprintf)(bm, fmt, ap);
101 if (mode & (TEXT_FILL | TEXT_CENTER))
102 while (bm->penX + FONT_WIDTH < bm->width)
103 text_putchar(' ', bm);
105 if (mode & TEXT_INVERT)
106 text_style(oldstyle, STYLEF_MASK);