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.3 2004/08/03 15:57:18 aleph
21 * Add include to fix warning for vsprintf()
23 * Revision 1.2 2004/06/03 11:27:09 bernie
24 * Add dual-license information.
26 * Revision 1.1 2004/05/23 15:43:16 bernie
27 * Import mware modules.
29 * Revision 1.2 2004/03/26 18:50:50 bernie
30 * Move _PROGMEM stuff to compiler.h
32 * Revision 1.1 2004/03/19 16:52:28 bernie
33 * Move printf() like functions from text.c to text_format.c and add PROGMEM versions.
38 #include "formatwr.h" /* _formatted_write() */
41 #include <stdio.h> /* vsprintf() */
43 #include <string.h> /* strlen() */
46 * Render string <code>str</code> in bitmap
48 int PGM_FUNC(text_puts)(const char * PGM_ATTR str, struct Bitmap *bm)
52 while ((c = PGM_READ_CHAR(str++)))
59 int PGM_FUNC(text_vprintf)(struct Bitmap *bm, const char * PGM_ATTR fmt, va_list ap)
61 return PGM_FUNC(_formatted_write)(fmt, (void (*)(char, void *))text_putchar, bm, ap);
65 int PGM_FUNC(text_printf)(struct Bitmap *bm, const char * PGM_ATTR fmt, ...)
71 len = PGM_FUNC(text_vprintf)(bm, fmt, ap);
78 int PGM_FUNC(text_xprintf)(struct Bitmap *bm,
79 uint8_t row, uint8_t col, uint8_t mode, const char * PGM_ATTR fmt, ...)
87 text_moveto(bm, row, col);
89 if (mode & TEXT_INVERT)
90 oldstyle = text_style(STYLEF_INVERT, STYLEF_INVERT);
92 if (mode & (TEXT_CENTER | TEXT_RIGHT))
96 pad = bm->width/FONT_WIDTH - PGM_FUNC(vsprintf)(NULL, fmt, ap);
98 if (mode & TEXT_CENTER)
102 text_putchar(' ', bm);
105 len = PGM_FUNC(text_vprintf)(bm, fmt, ap);
108 if (mode & (TEXT_FILL | TEXT_CENTER))
109 while (bm->penX + FONT_WIDTH < bm->width)
110 text_putchar(' ', bm);
112 if (mode & TEXT_INVERT)
113 text_style(oldstyle, STYLEF_MASK);