5 * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
6 * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
7 * This file is part of DevLib - See devlib/README for information.
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.2 2004/06/03 11:27:09 bernie
21 * Add dual-license information.
23 * Revision 1.1 2004/05/23 15:43:16 bernie
24 * Import mware modules.
26 * Revision 1.2 2004/03/26 18:50:50 bernie
27 * Move _PROGMEM stuff to compiler.h
29 * Revision 1.1 2004/03/19 16:52:28 bernie
30 * Move printf() like functions from text.c to text_format.c and add PROGMEM versions.
35 #include "formatwr.h" /* _formatted_write() */
39 #include <string.h> /* strlen */
42 * Render string <code>str</code> in bitmap
44 int PGM_FUNC(text_puts)(const char * PGM_ATTR str, struct Bitmap *bm)
48 while ((c = PGM_READ_CHAR(str++)))
55 int PGM_FUNC(text_vprintf)(struct Bitmap *bm, const char * PGM_ATTR fmt, va_list ap)
57 return PGM_FUNC(_formatted_write)(fmt, (void (*)(char, void *))text_putchar, bm, ap);
61 int PGM_FUNC(text_printf)(struct Bitmap *bm, const char * PGM_ATTR fmt, ...)
67 len = PGM_FUNC(text_vprintf)(bm, fmt, ap);
74 int PGM_FUNC(text_xprintf)(struct Bitmap *bm,
75 uint8_t row, uint8_t col, uint8_t mode, const char * PGM_ATTR fmt, ...)
83 text_moveto(bm, row, col);
85 if (mode & TEXT_INVERT)
86 oldstyle = text_style(STYLEF_INVERT, STYLEF_INVERT);
88 if (mode & (TEXT_CENTER | TEXT_RIGHT))
92 pad = bm->width/FONT_WIDTH - PGM_FUNC(vsprintf)(NULL, fmt, ap);
94 if (mode & TEXT_CENTER)
98 text_putchar(' ', bm);
101 len = PGM_FUNC(text_vprintf)(bm, fmt, ap);
104 if (mode & (TEXT_FILL | TEXT_CENTER))
105 while (bm->penX + FONT_WIDTH < bm->width)
106 text_putchar(' ', bm);
108 if (mode & TEXT_INVERT)
109 text_style(oldstyle, STYLEF_MASK);