--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999, 2000, 2001, 2003 Bernardo Innocenti <bernie@develer.com>
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \brief Simple charts on top of mware/gfx routines (implementation).
+ *
+ * Sample usage:
+ *
+ * \code
+ * bm = chart_init(0, ymax, N_POINTS_CURVE, ymin);
+ *
+ * chart_drawCurve(bm, curve_y, curve_points + 1);
+ * gfx_setViewRect(bm, xmin, ymax, xmax, ymin);
+ * chart_drawDots(bm, samples_x, samples_y, samples_cnt);
+ *
+ * print_bitmap(bm);
+ * \endcode
+ *
+ * \version $Id$
+ * \author Bernardo Innocenti <bernie@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/11/04 18:11:35 bernie
+ *#* Move graphics stuff from mware/ to gfx/.
+ *#*
+ *#* Revision 1.7 2005/11/04 16:20:02 bernie
+ *#* Fix reference to README.devlib in header.
+ *#*
+ *#* Revision 1.6 2004/11/16 21:04:23 bernie
+ *#* Update to new naming scheme in mware/gfx.c.
+ *#*
+ *#* Revision 1.5 2004/09/14 20:56:39 bernie
+ *#* Make more generic and adapt to new gfx functions.
+ *#*
+ *#* Revision 1.3 2004/08/11 19:39:12 bernie
+ *#* Use chart_x_t and chart_y_t for the input dataset.
+ *#*
+ *#* Revision 1.1 2004/08/04 03:16:30 bernie
+ *#* Import simple chart drawing code.
+ *#*
+ *#*/
+
+#include "charts.h"
+#include <mware/gfx.h>
+
+
+#ifndef CONFIG_CHART_ARROWS
+#define CONFIG_CHART_ARROWS 0
+#endif
+
+
+void chart_init(Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax)
+{
+ /* Clear the chart area */
+ gfx_rectClear(bm, xmin, ymin, xmax, ymax);
+
+ gfx_setClipRect(bm, xmin + CHART_BORDERLEFT, ymin + CHART_BORDERTOP,
+ xmax - CHART_BORDERRIGHT, ymax - CHART_BORDERBOTTOM);
+
+ chart_drawAxis(bm);
+}
+
+
+void chart_setScale(Bitmap *bm, chart_x_t xmin, chart_y_t ymin, chart_x_t xmax, chart_y_t ymax)
+{
+ gfx_setViewRect(bm, xmin, ymin, xmax, ymax);
+}
+
+
+/*!
+ * Draw the chart axes
+ */
+void chart_drawAxis(Bitmap *bm)
+{
+#if CONFIG_CHART_ARROWS
+
+ /* Draw axis */
+ gfx_moveTo(bm, bm->cr.xmin, bm->cr.ymin + 4);
+ gfx_lineTo(bm, bm->cr.xmin, bm->cr.ymax - 1);
+ gfx_lineTo(bm, bm->cr.xmax - 4 - 1, bm->cr.ymax - 1);
+
+ /* Draw up arrow */
+ gfx_moveTo(bm, bm->cr.xmin - 2, bm->cr.ymin + 3);
+ gfx_lineTo(bm, bm->cr.xmin + 2, bm->cr.ymin + 3);
+ gfx_lineTo(bm, bm->cr.xmin, bm->cr.ymin);
+ gfx_lineTo(bm, bm->cr.xmin - 2, bm->cr.ymin + 3);
+
+ /* Draw right arrow */
+ gfx_moveTo(bm, bm->cr.xmax - 4, bm->cr.ymax - 3);
+ gfx_lineTo(bm, bm->cr.xmax - 4, bm->cr.ymax + 1);
+ gfx_lineTo(bm, bm->cr.xmax - 1, bm->cr.ymax - 1);
+ gfx_lineTo(bm, bm->cr.xmax - 4, bm->cr.ymax - 3);
+
+#else /* CONFIG_CHART_ARROWS */
+
+ /* Draw a box around the chart */
+ gfx_rectDraw(bm, bm->cr.xmin, bm->cr.ymin, bm->cr.xmax, bm->cr.ymax);
+
+#endif /* CONFIG_CHART_ARROWS */
+
+ //CHECK_WALL(wall_before_raster, WALL_SIZE);
+ //CHECK_WALL(wall_after_raster, WALL_SIZE);
+}
+
+
+/*!
+ * Draw a set of \a curve_cnt connected segments, whose Y coordinates
+ * are identified by the \a curve_y array and X-coordinates are
+ * are evenly spaced by one virtual unit.
+ */
+void chart_drawCurve(Bitmap *bm, const chart_y_t *curve_y, int curve_cnt)
+{
+ int i;
+
+ gfx_moveTo(bm, gfx_transformX(bm, 0), gfx_transformY(bm, curve_y[0]));
+
+ for (i = 1; i < curve_cnt; i++)
+ gfx_lineTo(bm, gfx_transformX(bm, i), gfx_transformY(bm, curve_y[i]));
+
+ //CHECK_WALL(wall_before_raster, WALL_SIZE);
+ //CHECK_WALL(wall_after_raster, WALL_SIZE);
+}
+
+
+/*!
+ * Disegna dei dot in corrispondenza delle coppie (dotsx[i];dotsy[i])
+ * Se dotsx e' NULL, i punti vengono disegnati ad intervalli regolari.
+ */
+void chart_drawDots(Bitmap *bm, const chart_x_t *dots_x, const chart_y_t *dots_y, int cnt)
+{
+ int i;
+ coord_t x, y;
+
+ for (i = 0; i < cnt; i++)
+ {
+ if (dots_x)
+ x = gfx_transformX(bm, dots_x[i]);
+ else
+ x = gfx_transformX(bm, i);
+
+ y = gfx_transformY(bm, dots_y[i]);
+
+ /* Draw tick over the curve */
+ gfx_rectFill(bm,
+ x - TICKS_WIDTH / 2, y - TICKS_HEIGHT / 2,
+ x + (TICKS_WIDTH + 1) / 2, y + (TICKS_HEIGHT + 1) / 2);
+
+ /* Draw vertical line from the curve to the X-axis */
+ //gfx_drawLine(bm, x, y, x, bm->cr.ymax - 1);
+ }
+
+ //CHECK_WALL(wall_before_raster, WALL_SIZE);
+ //CHECK_WALL(wall_after_raster, WALL_SIZE);
+}
+
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999, 2000, 2001, 2003 Bernardo Innocenti <bernie@develer.com>
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \brief Simple charts on top of mware/gfx routines (interface).
+ *
+ * Configuration:
+ * - \c CONFIG_CHART_TYPE_X: type for the input dataset of X-coordinates
+ * - \c CONFIG_CHART_TYPE_Y: type for the input dataset of Y-coordinates
+ *
+ * \version $Id$
+ * \author Bernardo Innocenti <bernie@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/11/04 18:11:35 bernie
+ *#* Move graphics stuff from mware/ to gfx/.
+ *#*
+ *#* Revision 1.7 2005/11/04 16:20:02 bernie
+ *#* Fix reference to README.devlib in header.
+ *#*
+ *#* Revision 1.6 2005/04/11 19:10:28 bernie
+ *#* Include top-level headers from cfg/ subdir.
+ *#*
+ *#* Revision 1.5 2004/09/14 20:56:39 bernie
+ *#* Make more generic and adapt to new gfx functions.
+ *#*
+ *#* Revision 1.3 2004/08/11 19:39:12 bernie
+ *#* Use chart_x_t and chart_y_t for the input dataset.
+ *#*
+ *#* Revision 1.1 2004/08/04 03:16:30 bernie
+ *#* Import simple chart drawing code.
+ *#*
+ *#*/
+#ifndef MWARE_CHARTS_H
+#define MWARE_CHARTS_H
+
+#include <mware/gfx.h> /* vcoord_t */
+#include <cfg/config.h> /* CONFIG_ stuff */
+
+/*!
+ * \name Width/height of the small ticks drawn over the axes
+ * \{
+ */
+#define TICKS_HEIGHT 2
+#define TICKS_WIDTH 2
+/*\}*/
+
+/*!
+ * \name Chart frame dimensions
+ * \{
+ */
+#define CHART_BORDERTOP 0
+#define CHART_BORDERBOTTOM 0
+#define CHART_BORDERLEFT 0
+#define CHART_BORDERRIGHT 0
+/*\}*/
+
+#ifndef CONFIG_CHART_TYPE_X
+#define CONFIG_CHART_TYPE_X vcoord_t
+#endif
+#ifndef CONFIG_CHART_TYPE_Y
+#define CONFIG_CHART_TYPE_Y vcoord_t
+#endif
+
+
+typedef CONFIG_CHART_TYPE_X chart_x_t;
+typedef CONFIG_CHART_TYPE_Y chart_y_t;
+
+
+/* Public function protos */
+void chart_init(Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax);
+void chart_setScale(Bitmap *bm, chart_x_t xmin, chart_y_t ymin, chart_x_t xmax, chart_y_t ymax);
+void chart_drawAxis(Bitmap *bm);
+void chart_drawCurve(Bitmap *bm, const chart_y_t *curve_y, int curve_cnt);
+void chart_drawDots(Bitmap *bm, const chart_x_t *dots_x, const chart_y_t *dots_y, int cnt);
+
+#endif /* MWARE_CHARTS_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright (C) 2001 Bernardo Innocenti <bernie@codewiz.org>
+ * Copyright (C) 2003,2004 Develer S.r.l. (http://www.develer.com/)
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Bernardo Innocenti <bernie@develer.com>
+ *
+ * \brief Font 8x6 IBM-PC 8bit
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/11/04 18:11:35 bernie
+ *#* Move graphics stuff from mware/ to gfx/.
+ *#*
+ *#* Revision 1.6 2005/11/04 16:20:02 bernie
+ *#* Fix reference to README.devlib in header.
+ *#*
+ *#* Revision 1.5 2005/01/08 09:20:38 bernie
+ *#* Add missing type in declaration.
+ *#*
+ *#* Revision 1.4 2004/12/31 16:42:55 bernie
+ *#* Sanitize for non-Harvard processors.
+ *#*
+ *#* Revision 1.3 2004/08/25 14:12:09 rasky
+ *#* Aggiornato il comment block dei log RCS
+ *#*
+ *#* Revision 1.2 2004/06/03 11:27:09 bernie
+ *#* Add dual-license information.
+ *#*
+ *#* Revision 1.1 2004/05/23 15:43:16 bernie
+ *#* Import mware modules.
+ *#*
+ *#* Revision 1.5 2004/03/24 15:48:53 bernie
+ *#* Remove Copyright messages from Doxygen output
+ *#*
+ *#* Revision 1.4 2004/03/03 18:30:17 bernie
+ *#* Substitute left triangle glyph with left arrow
+ *#*
+ *#* Revision 1.3 2004/02/28 14:48:33 aleph
+ *#* Improve arrow glyphs
+ *#*
+ *#* Revision 1.2 2004/01/13 12:15:28 aleph
+ *#* Move font table in program memory; add font.h
+ *#*
+ *#* Revision 1.1 2004/01/07 23:31:54 aleph
+ *#* Add text routines
+ *#*
+ *#*/
+
+#include "font.h"
+
+const PROGMEM uint8_t font[256 * 6] =
+{
+/* 0x00 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* */
+ 0x3E, 0x45, 0x51, 0x45, 0x3E, 0x00, /* */
+ 0x3E, 0x7B, 0x6F, 0x7B, 0x3E, 0x00, /* */
+ 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, /* */
+ 0x08, 0x1C, 0x3E, 0x1C, 0x08, 0x00, /* */
+ 0x18, 0x5A, 0x67, 0x5A, 0x18, 0x00, /* */
+ 0x0C, 0x5E, 0x6F, 0x5E, 0x0C, 0x00, /* */
+ 0x08, 0x1C, 0x3E, 0x1C, 0x08, 0x00, /* */
+/* 0x08 */
+ 0x77, 0x63, 0x41, 0x63, 0x77, 0x00, /* */
+ 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00, /* */
+ 0x77, 0x63, 0x41, 0x63, 0x77, 0x00, /* */
+ 0x20, 0x50, 0x5A, 0x56, 0x2E, 0x00, /* */
+ 0x06, 0x29, 0x79, 0x29, 0x06, 0x00, /* */
+ 0x60, 0x60, 0x7F, 0x05, 0x07, 0x00, /* */
+ 0x18, 0x1F, 0x01, 0x61, 0x7F, 0x00, /* */
+ 0x15, 0x0E, 0x1B, 0x0E, 0x15, 0x00, /* */
+/* 0x10 */
+ 0x00, 0x08, 0x1C, 0x3E, 0x08, 0x08, /* */
+ 0x7F, 0x3E, 0x1C, 0x08, 0x00, 0x00, /* */
+ 0x14, 0x36, 0x7F, 0x36, 0x14, 0x00, /* */
+ 0x00, 0x5F, 0x00, 0x5F, 0x00, 0x00, /* */
+ 0x02, 0x05, 0x7F, 0x01, 0x7F, 0x00, /* */
+ 0x20, 0x4A, 0x55, 0x29, 0x02, 0x00, /* */
+ 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, /* */
+ 0x54, 0x76, 0x7F, 0x76, 0x54, 0x00, /* */
+/* 0x18 */
+ 0x08, 0x0C, 0x7E, 0x0C, 0x08, 0x00, /* */
+ 0x10, 0x30, 0x7E, 0x30, 0x10, 0x00, /* */
+ 0x08, 0x08, 0x3E, 0x1C, 0x08, 0x00, /* */
+ 0x08, 0x1C, 0x3E, 0x08, 0x08, 0x00, /* */
+ 0x1C, 0x10, 0x10, 0x10, 0x10, 0x00, /* */
+ 0x08, 0x1C, 0x08, 0x1C, 0x08, 0x00, /* */
+ 0x18, 0x1C, 0x1E, 0x1C, 0x18, 0x00, /* */
+ 0x0C, 0x1C, 0x3C, 0x1C, 0x0C, 0x00, /* */
+/* 0x20 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* */
+ 0x00, 0x00, 0x4F, 0x00, 0x00, 0x00, /* ! */
+ 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, /* " */
+ 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, /* # */
+ 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, /* $ */
+ 0x63, 0x13, 0x08, 0x64, 0x63, 0x00, /* % */
+ 0x36, 0x49, 0x55, 0x22, 0x50, 0x00, /* & */
+ 0x00, 0x05, 0x03, 0x00, 0x00, 0x00, /* ' */
+/* 0x28 */
+ 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, /* ( */
+ 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, /* ) */
+ 0x14, 0x08, 0x3E, 0x08, 0x14, 0x00, /* * */
+ 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, /* + */
+ 0x00, 0x50, 0x30, 0x00, 0x00, 0x00, /* , */
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, /* - */
+ 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, /* . */
+ 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, /* / */
+/* 0x30 */
+ 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, /* 0 */
+ 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, /* 1 */
+ 0x62, 0x51, 0x49, 0x49, 0x46, 0x00, /* 2 */
+ 0x21, 0x41, 0x45, 0x4B, 0x31, 0x00, /* 3 */
+ 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, /* 4 */
+ 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, /* 5 */
+ 0x3C, 0x4A, 0x49, 0x49, 0x30, 0x00, /* 6 */
+ 0x01, 0x71, 0x09, 0x05, 0x03, 0x00, /* 7 */
+/* 0x38 */
+ 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, /* 8 */
+ 0x06, 0x49, 0x49, 0x29, 0x1E, 0x00, /* 9 */
+ 0x00, 0x36, 0x36, 0x00, 0x00, 0x00, /* : */
+ 0x00, 0x56, 0x36, 0x00, 0x00, 0x00, /* ; */
+ 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, /* < */
+ 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, /* = */
+ 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, /* > */
+ 0x02, 0x01, 0x51, 0x09, 0x06, 0x00, /* ? */
+/* 0x40 */
+ 0x32, 0x49, 0x79, 0x41, 0x3E, 0x00, /* @ */
+ 0x7E, 0x09, 0x09, 0x09, 0x7E, 0x00, /* A */
+ 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, /* B */
+ 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, /* C */
+ 0x7F, 0x41, 0x41, 0x22, 0x1C, 0x00, /* D */
+ 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, /* E */
+ 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, /* F */
+ 0x3E, 0x41, 0x49, 0x49, 0x7A, 0x00, /* G */
+/* 0x48 */
+ 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, /* H */
+ 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, /* I */
+ 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, /* J */
+ 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, /* K */
+ 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, /* L */
+ 0x7F, 0x02, 0x0C, 0x02, 0x7F, 0x00, /* M */
+ 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, /* N */
+ 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, /* O */
+/* 0x50 */
+ 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, /* P */
+ 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, /* Q */
+ 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, /* R */
+ 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, /* S */
+ 0x01, 0x01, 0x7F, 0x01, 0x01, 0x00, /* T */
+ 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, /* U */
+ 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, /* V */
+ 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, /* W */
+/* 0x58 */
+ 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, /* X */
+ 0x07, 0x08, 0x70, 0x08, 0x07, 0x00, /* Y */
+ 0x61, 0x51, 0x49, 0x45, 0x43, 0x00, /* Z */
+ 0x00, 0x7F, 0x41, 0x41, 0x00, 0x00, /* [ */
+ 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, /* \ */
+ 0x00, 0x41, 0x41, 0x7F, 0x00, 0x00, /* ] */
+ 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, /* ^ */
+ 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, /* _ */
+/* 0x60 */
+ 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, /* ` */
+ 0x00, 0x74, 0x54, 0x54, 0x78, 0x00, /* a */
+ 0x7F, 0x44, 0x44, 0x44, 0x38, 0x00, /* b */
+ 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, /* c */
+ 0x38, 0x44, 0x44, 0x44, 0x7F, 0x00, /* d */
+ 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, /* e */
+ 0x08, 0x7E, 0x09, 0x01, 0x02, 0x00, /* f */
+ 0x08, 0x54, 0x54, 0x54, 0x3C, 0x00, /* g */
+/* 0x68 */
+ 0x7F, 0x04, 0x04, 0x04, 0x78, 0x00, /* h */
+ 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, /* i */
+ 0x20, 0x40, 0x44, 0x3D, 0x00, 0x00, /* j */
+ 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, /* k */
+ 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, /* l */
+ 0x7C, 0x04, 0x18, 0x04, 0x78, 0x00, /* m */
+ 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, /* n */
+ 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, /* o */
+/* 0x70 */
+ 0x7C, 0x14, 0x14, 0x14, 0x08, 0x00, /* p */
+ 0x08, 0x14, 0x14, 0x14, 0x7C, 0x00, /* q */
+ 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, /* r */
+ 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, /* s */
+ 0x04, 0x3F, 0x44, 0x40, 0x20, 0x00, /* t */
+ 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, /* u */
+ 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, /* v */
+ 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, /* w */
+/* 0x78 */
+ 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, /* x */
+ 0x0C, 0x50, 0x50, 0x50, 0x3C, 0x00, /* y */
+ 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, /* z */
+ 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, /* { */
+ 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, /* | */
+ 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, /* } */
+ 0x02, 0x01, 0x02, 0x01, 0x00, 0x00, /* ~ */
+ 0x70, 0x48, 0x44, 0x48, 0x70, 0x00, /* \7f */
+/* 0x80 */
+ 0x38, 0xC4, 0xC4, 0x44, 0x28, 0x00, /* \80 */
+ 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x00, /* \81 */
+ 0x38, 0x54, 0x54, 0x55, 0x19, 0x00, /* \82 */
+ 0x22, 0x55, 0x55, 0x55, 0x78, 0x00, /* \83 */
+ 0x20, 0x55, 0x54, 0x54, 0x79, 0x00, /* \84 */
+ 0x21, 0x75, 0x55, 0x54, 0x78, 0x00, /* \85 */
+ 0x20, 0x74, 0x57, 0x54, 0x78, 0x00, /* \86 */
+ 0x08, 0x54, 0x54, 0x74, 0x14, 0x00, /* \87 */
+/* 0x88 */
+ 0x3A, 0x55, 0x55, 0x55, 0x1A, 0x00, /* \88 */
+ 0x39, 0x54, 0x54, 0x55, 0x18, 0x00, /* \89 */
+ 0x39, 0x55, 0x55, 0x54, 0x18, 0x00, /* \8a */
+ 0x00, 0x45, 0x7C, 0x41, 0x00, 0x00, /* \8b */
+ 0x02, 0x45, 0x7D, 0x42, 0x00, 0x00, /* \8c */
+ 0x01, 0x45, 0x7D, 0x40, 0x00, 0x00, /* \8d */
+ 0x79, 0x14, 0x12, 0x14, 0x79, 0x00, /* \8e */
+ 0x70, 0x2B, 0x2B, 0x2B, 0x70, 0x00, /* \8f */
+/* 0x90 */
+ 0x7C, 0x54, 0x55, 0x55, 0x45, 0x00, /* \90 */
+ 0x20, 0x54, 0x38, 0x54, 0x48, 0x00, /* \91 */
+ 0x7E, 0x09, 0x7F, 0x49, 0x49, 0x00, /* \92 */
+ 0x32, 0x49, 0x49, 0x49, 0x32, 0x00, /* \93 */
+ 0x32, 0x48, 0x48, 0x48, 0x32, 0x00, /* \94 */
+ 0x32, 0x4A, 0x4A, 0x48, 0x30, 0x00, /* \95 */
+ 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x00, /* \96 */
+ 0x3A, 0x42, 0x42, 0x20, 0x78, 0x00, /* \97 */
+/* 0x98 */
+ 0x0D, 0x50, 0x50, 0x50, 0x3D, 0x00, /* \98 */
+ 0x19, 0x24, 0x42, 0x24, 0x19, 0x00, /* \99 */
+ 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x00, /* \9a */
+ 0x18, 0x24, 0x7E, 0x24, 0x24, 0x00, /* \9b */
+ 0x28, 0x5E, 0x29, 0x42, 0x20, 0x00, /* \9c */
+ 0x09, 0x2A, 0x7C, 0x2A, 0x09, 0x00, /* \9d */
+ 0x7F, 0x05, 0x15, 0x3D, 0x52, 0x00, /* \9e */
+ 0x20, 0x48, 0x3E, 0x09, 0x02, 0x00, /* \9f */
+/* 0xa0 */
+ 0x20, 0x74, 0x55, 0x55, 0x79, 0x00, /* */
+ 0x01, 0x45, 0x7D, 0x40, 0x00, 0x00, /* ¡ */
+ 0x30, 0x48, 0x4A, 0x4A, 0x32, 0x00, /* ¢ */
+ 0x38, 0x40, 0x42, 0x22, 0x7A, 0x00, /* £ */
+ 0x7A, 0x12, 0x0A, 0x0A, 0x72, 0x00, /* ¤ */
+ 0x7D, 0x09, 0x11, 0x21, 0x7D, 0x00, /* ¥ */
+ 0x02, 0x15, 0x15, 0x12, 0x04, 0x00, /* ¦ */
+ 0x02, 0x15, 0x15, 0x15, 0x02, 0x00, /* § */
+/* 0xa8 */
+ 0x30, 0x48, 0x45, 0x40, 0x20, 0x00, /* ¨ */
+ 0x00, 0x38, 0x08, 0x08, 0x08, 0x00, /* © */
+ 0x00, 0x08, 0x08, 0x08, 0x38, 0x00, /* ª */
+ 0x0B, 0x04, 0x6A, 0x55, 0x48, 0x00, /* « */
+ 0x0B, 0x24, 0x32, 0x79, 0x20, 0x00, /* ¬ */
+ 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, /* */
+ 0x08, 0x14, 0x2A, 0x14, 0x22, 0x00, /* ® */
+ 0x22, 0x14, 0x2A, 0x14, 0x08, 0x00, /* ¯ */
+/* 0xb0 */
+ 0x2A, 0x55, 0x00, 0x2A, 0x55, 0x00, /* ° */
+ 0x2A, 0x55, 0x2A, 0x55, 0x2A, 0x55, /* ± */
+ 0x55, 0x2A, 0x7F, 0x55, 0x2A, 0x7F, /* ² */
+ 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, /* ³ */
+ 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, /* ´ */
+ 0x14, 0x14, 0xFF, 0x00, 0x00, 0x00, /* µ */
+ 0x08, 0xFF, 0x00, 0xFF, 0x00, 0x00, /* ¶ */
+ 0x08, 0xF8, 0x08, 0xF8, 0x00, 0x00, /* · */
+/* 0xb8 */
+ 0x14, 0x14, 0xFC, 0x00, 0x00, 0x00, /* ¸ */
+ 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, /* ¹ */
+ 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, /* º */
+ 0x14, 0xF4, 0x04, 0xFC, 0x00, 0x00, /* » */
+ 0x14, 0x17, 0x10, 0x1F, 0x00, 0x00, /* ¼ */
+ 0x08, 0x0F, 0x08, 0x0F, 0x00, 0x00, /* ½ */
+ 0x14, 0x14, 0x1F, 0x00, 0x00, 0x00, /* ¾ */
+ 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, /* ¿ */
+/* 0xc0 */
+ 0x00, 0x00, 0x0F, 0x08, 0x08, 0x08, /* À */
+ 0x08, 0x08, 0x0F, 0x08, 0x08, 0x08, /* Á */
+ 0x08, 0x08, 0xF8, 0x08, 0x08, 0x08, /* Â */
+ 0x00, 0x00, 0xFF, 0x08, 0x08, 0x08, /* Ã */
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* Ä */
+ 0x08, 0x08, 0xFF, 0x08, 0x08, 0x08, /* Å */
+ 0x00, 0x00, 0xFF, 0x14, 0x14, 0x14, /* Æ */
+ 0x00, 0xFF, 0x00, 0xFF, 0x08, 0x08, /* Ç */
+/* 0xc8 */
+ 0x00, 0x1F, 0x10, 0x17, 0x14, 0x14, /* È */
+ 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, /* É */
+ 0x28, 0x2F, 0x20, 0x2F, 0x28, 0x28, /* Ê */
+ 0x14, 0xF4, 0x04, 0xF4, 0x14, 0x14, /* Ë */
+ 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, /* Ì */
+ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, /* Í */
+ 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, /* Î */
+ 0x14, 0x14, 0xF7, 0x14, 0x14, 0x14, /* Ï */
+/* 0xd0 */
+ 0x08, 0x0F, 0x08, 0x0F, 0x08, 0x08, /* Ð */
+ 0x14, 0x14, 0xF4, 0x14, 0x14, 0x14, /* Ñ */
+ 0x08, 0x08, 0xF8, 0x08, 0x08, 0x08, /* Ò */
+ 0x08, 0x0F, 0x08, 0x0F, 0x08, 0x08, /* Ó */
+ 0x00, 0x00, 0x1F, 0x14, 0x14, 0x14, /* Ô */
+ 0x00, 0x00, 0xFC, 0x14, 0x14, 0x14, /* Õ */
+ 0x00, 0xF8, 0x08, 0xF8, 0x08, 0x08, /* Ö */
+ 0x08, 0xFF, 0x08, 0xFF, 0x08, 0x08, /* × */
+/* 0xd8 */
+ 0x14, 0x14, 0xFF, 0x14, 0x14, 0x14, /* Ø */
+ 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, /* Ù */
+ 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, /* Ú */
+ 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, /* Û */
+ 0x70, 0x70, 0x70, 0x70, 0x70, 0x00, /* Ü */
+ 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, /* Ý */
+ 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x00, /* Þ */
+ 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, /* ß */
+/* 0xe0 */
+ 0x30, 0x48, 0x48, 0x30, 0x48, 0x00, /* à */
+ 0x7E, 0x11, 0x25, 0x25, 0x1A, 0x00, /* á */
+ 0x7E, 0x02, 0x02, 0x02, 0x06, 0x00, /* â */
+ 0x04, 0x7C, 0x04, 0x7C, 0x04, 0x00, /* ã */
+ 0x41, 0x63, 0x55, 0x49, 0x63, 0x00, /* ä */
+ 0x3C, 0x42, 0x4A, 0x4A, 0x31, 0x00, /* å */
+ 0x40, 0x7C, 0x20, 0x20, 0x1C, 0x00, /* æ */
+ 0x08, 0x04, 0x7C, 0x08, 0x04, 0x00, /* ç */
+/* 0xe8 */
+ 0x49, 0x55, 0x77, 0x55, 0x49, 0x00, /* è */
+ 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x00, /* é */
+ 0x4C, 0x72, 0x02, 0x72, 0x4C, 0x00, /* ê */
+ 0x30, 0x4A, 0x45, 0x49, 0x31, 0x00, /* ë */
+ 0x18, 0x24, 0x18, 0x24, 0x18, 0x00, /* ì */
+ 0x5C, 0x72, 0x2A, 0x27, 0x1D, 0x00, /* í */
+ 0x1C, 0x2A, 0x49, 0x49, 0x00, 0x00, /* î */
+ 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x00, /* ï */
+/* 0xf0 */
+ 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x00, /* ð */
+ 0x24, 0x24, 0x2E, 0x24, 0x24, 0x00, /* ñ */
+ 0x40, 0x51, 0x4A, 0x44, 0x00, 0x00, /* ò */
+ 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, /* ó */
+ 0x00, 0x00, 0xFE, 0x01, 0x02, 0x00, /* ô */
+ 0x20, 0x40, 0x3F, 0x00, 0x00, 0x00, /* õ */
+ 0x08, 0x08, 0x2A, 0x08, 0x08, 0x00, /* ö */
+ 0x24, 0x12, 0x24, 0x12, 0x00, 0x00, /* ÷ */
+/* 0xf8 */
+ 0x06, 0x09, 0x09, 0x09, 0x06, 0x00, /* ø */
+ 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, /* ù */
+ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, /* ú */
+ 0x10, 0x30, 0x7F, 0x01, 0x01, 0x00, /* û */
+ 0x01, 0x0E, 0x01, 0x01, 0x0E, 0x00, /* ü */
+ 0x0A, 0x09, 0x0D, 0x0A, 0x00, 0x00, /* ý */
+ 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x00, /* þ */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* ÿ */
+};
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Stefano Fedrigo <aleph@develer.com>
+ *
+ * \brief Font 8x6 IBM-PC 8bit
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/11/04 18:11:35 bernie
+ *#* Move graphics stuff from mware/ to gfx/.
+ *#*
+ *#* Revision 1.6 2005/04/11 19:10:28 bernie
+ *#* Include top-level headers from cfg/ subdir.
+ *#*
+ *#* Revision 1.5 2005/03/01 23:26:45 bernie
+ *#* Use new CPU-neutral program-memory API.
+ *#*
+ *#* Revision 1.4 2004/12/31 16:42:55 bernie
+ *#* Sanitize for non-Harvard processors.
+ *#*
+ *#* Revision 1.3 2004/08/25 14:12:09 rasky
+ *#* Aggiornato il comment block dei log RCS
+ *#*
+ *#* Revision 1.2 2004/06/03 11:27:09 bernie
+ *#* Add dual-license information.
+ *#*
+ *#* Revision 1.1 2004/05/23 15:43:16 bernie
+ *#* Import mware modules.
+ *#*
+ *#* Revision 1.2 2004/03/24 15:48:53 bernie
+ *#* Remove Copyright messages from Doxygen output
+ *#*
+ *#* Revision 1.1 2004/01/13 12:15:28 aleph
+ *#* Move font table in program memory; add font.h
+ *#*
+ *#*/
+#ifndef MWARE_FONT_H
+#define MWARE_FONT_H
+
+#include <cfg/compiler.h> /* uint8_t */
+#include <mware/pgm.h> /* PROGMEM */
+
+/*!
+ * \name Font size (in pixel)
+ * \{
+ */
+#define FONT_WIDTH 6
+#define FONT_HEIGHT 8
+/* \} */
+
+/*! Font table */
+extern const PROGMEM uint8_t font[256 * FONT_WIDTH];
+
+#endif /* MWARE_FONT_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Stefano Fedrigo <aleph@develer.com>
+ *
+ * \brief General pourpose graphics routines
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/11/04 18:11:35 bernie
+ *#* Move graphics stuff from mware/ to gfx/.
+ *#*
+ *#* Revision 1.14 2005/11/04 16:20:02 bernie
+ *#* Fix reference to README.devlib in header.
+ *#*
+ *#* Revision 1.13 2005/04/11 19:10:28 bernie
+ *#* Include top-level headers from cfg/ subdir.
+ *#*
+ *#* Revision 1.12 2005/03/01 23:26:45 bernie
+ *#* Use new CPU-neutral program-memory API.
+ *#*
+ *#* Revision 1.11 2004/12/08 08:06:16 bernie
+ *#* Remove done todo.
+ *#*
+ *#* Revision 1.10 2004/11/01 15:14:07 bernie
+ *#* Update to current coding conventions.
+ *#*
+ *#* Revision 1.9 2004/10/21 10:58:33 bernie
+ *#* Add a TODO item.
+ *#*
+ *#* Revision 1.8 2004/09/20 03:29:22 bernie
+ *#* Relax assertion.
+ *#*
+ *#* Revision 1.7 2004/09/14 21:01:08 bernie
+ *#* Rename rectangle drawing functions; Unify filled/cleared implementations.
+ *#*
+ *#* Revision 1.4 2004/08/24 16:53:10 bernie
+ *#* Use new-style config macros.
+ *#*
+ *#* Revision 1.3 2004/08/04 03:16:59 bernie
+ *#* Switch to new DevLib CONFIG_ convention.
+ *#*
+ *#* Revision 1.2 2004/06/03 11:27:09 bernie
+ *#* Add dual-license information.
+ *#*/
+
+#include "gfx.h"
+#include <cfg/config.h> /* CONFIG_GFX_CLIPPING */
+#include <cfg/debug.h>
+#include <cfg/cpu.h> /* CPU_HARVARD */
+#include <cfg/macros.h> /* SWAP() */
+
+#include <string.h>
+
+
+/*!
+ * Plot a point in bitmap \a bm.
+ *
+ * \note bm is evaluated twice
+ */
+#define BM_PLOT(bm, x, y) \
+ ( *((bm)->raster + ((y) / 8) * (bm)->width + (x)) |= 1 << ((y) % 8) )
+
+/*!
+ * Clear a point in bitmap \a bm.
+ *
+ * \note bm is evaluated twice
+ */
+#define BM_CLEAR(bm, x, y) \
+ ( *((bm)->raster + ((y) / 8) * (bm)->width + (x)) &= ~(1 << ((y) % 8)) )
+
+/*!
+ * Set a point in bitmap \a bm to the specified color.
+ *
+ * \note bm is evaluated twice
+ * \note This macro is somewhat slower than BM_PLOT and BM_CLEAR.
+ * \see BM_PLOT BM_CLEAR
+ */
+#define BM_DRAWPIXEL(bm, x, y, fg_pen) \
+ do { \
+ uint8_t *p = (bm)->raster + ((y) / 8) * (bm)->width + (x); \
+ uint8_t mask = 1 << ((y) % 8); \
+ *p = (*p & ~mask) | ((fg_pen) ? mask : 0); \
+ } while (0)
+
+/*!
+ * Initialize a Bitmap structure with the provided parameters.
+ *
+ * \note The pen position is reset to the origin.
+ */
+void gfx_bitmapInit(Bitmap *bm, uint8_t *raster, coord_t w, coord_t h)
+{
+ bm->raster = raster;
+ bm->width = w;
+ bm->height = h;
+ bm->penX = 0;
+ bm->penY = 0;
+}
+
+
+/*!
+ * Clear the whole bitmap surface to the background color.
+ *
+ * \note This function does \b not update the current pen position
+ */
+void gfx_bitmapClear(Bitmap *bm)
+{
+ memset(bm->raster, 0, (bm->width * bm->height) / 8);
+}
+
+
+#if CPU_HARVARD
+
+#include <avr/pgmspace.h> /* FIXME: memcpy_P() */
+
+/*!
+ * Copy a raster picture located in program memory in the bitmap.
+ * The size of the raster to copy *must* be the same of the raster bitmap.
+ *
+ * \note This function does \b not update the current pen position
+ */
+void gfx_blit_P(Bitmap *bm, const pgm_uint8_t *raster)
+{
+ memcpy_P(bm->raster, raster, (bm->height / 8) * bm->width);
+}
+#endif /* CPU_HARVARD */
+
+
+/*!
+ * Draw a line on the bitmap \a bm using the specified start and end
+ * coordinates.
+ *
+ * \note This function does \b not update the current pen position.
+ *
+ * \todo Optimize for vertical and horiziontal lines.
+ */
+void gfx_line(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
+{
+ int x, y, e, len, adx, ady, signx, signy;
+
+
+#if CONFIG_GFX_CLIPPING
+ /* FIXME: broken */
+
+ #define XMIN 0
+ #define YMIN 0
+ #define XMAX (bm->width - 1)
+ #define YMAX (bm->height - 1)
+
+ /* Clipping */
+ if (x1 < XMIN)
+ {
+ y1 = y2 - ((x2 - XMIN) * (y2 - y1)) / (x2 - x1);
+ x1 = XMIN;
+ }
+ if (y1 < YMIN)
+ {
+ x1 = x2 - ((y2 - YMIN) * (x2 - x1)) / (y2 - y1);
+ y1 = YMIN;
+ }
+ if (x2 < XMIN)
+ {
+ y2 = y2 - ((XMIN - x1) * (y2 - y1)) / (x2 - x1);
+ x2 = XMIN;
+ }
+ if (y2 < YMIN)
+ {
+ x2 = x2 - ((YMIN - y1) * (x2 - x1)) / (y2 - y1);
+ y2 = YMIN;
+ }
+
+ if (x1 > XMAX)
+ {
+ y1 = ((x2 - XMAX) * (y2 - y1)) / (x2 - x1);
+ x1 = XMAX;
+ }
+ if (y1 > YMAX)
+ {
+ x1 = ((y2 - YMAX) * (x2 - x1)) / (y2 - y1);
+ y1 = YMAX;
+ }
+ if (x2 > XMAX)
+ {
+ y2 = ((XMAX - x1) * (y2 - y1)) / (x2 - x1);
+ x2 = XMAX;
+ }
+ if (y2 > YMAX)
+ {
+ x2 = ((YMAX - y1) * (x2 - x1)) / (y2 - y1);
+ y2 = YMAX;
+ }
+
+ #undef XMIN
+ #undef YMIN
+ #undef XMAX
+ #undef YMAX
+
+#endif /* CONFIG_GFX_CLIPPING */
+
+
+ if (x2 > x1)
+ {
+ /* left to right */
+ signx = +1;
+ adx = x2 - x1;
+ }
+ else
+ {
+ /* right to left */
+ signx = -1;
+ adx = x1 - x2;
+ }
+
+ if (y2 > y1)
+ {
+ /* top to bottom */
+ signy = +1;
+ ady = y2 - y1;
+ }
+ else
+ {
+ /* bottom to top */
+ signy = -1;
+ ady = y1 - y2;
+ }
+
+ x = x1;
+ y = y1;
+
+ if (adx > ady)
+ {
+ /* X-major line (octants 1/4/5/8) */
+
+ len = adx;
+ e = -adx;
+ while (len--)
+ {
+ /* Sanity check */
+ if ((x >= 0) && (x < bm->width) && (y >= 0) && (y < bm->height))
+ BM_PLOT(bm, x, y);
+ x += signx;
+ e += ady;
+ if (e >= 0)
+ {
+ y += signy;
+ e -= adx;
+ }
+ }
+ }
+ else
+ {
+ /* Y-major line (octants 2/3/6/7) */
+
+ len = ady;
+ e = -ady;
+ while (len--)
+ {
+ /* Sanity check */
+ if ((x >= 0) && (x < bm->width) && (y >= 0) && (y < bm->height))
+ BM_PLOT(bm, x, y);
+ y += signy;
+ e += adx;
+ if (e >= 0)
+ {
+ x += signx;
+ e -= ady;
+ }
+ }
+ }
+}
+
+
+/*!
+ * Move the current pen position to the specified coordinates.
+ */
+void gfx_moveTo(Bitmap *bm, coord_t x, coord_t y)
+{
+ bm->penX = x;
+ bm->penY = y;
+}
+
+/*!
+ * Draw a line from the current pen position to the new coordinates.
+ *
+ * \note This function moves the current pen position to the
+ * new coordinates.
+ */
+void gfx_lineTo(Bitmap *bm, coord_t x, coord_t y)
+{
+ gfx_line(bm, bm->penX, bm->penY, x, y);
+ gfx_moveTo(bm, x, y);
+}
+
+
+/*!
+ * Draw an the outline of an hollow rectangle.
+ *
+ * \note The bottom-right border of the rectangle is not drawn.
+ * \note This function does \b not update the current pen position
+ */
+void gfx_rectDraw(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
+{
+ /* Sort coords (needed for correct bottom-right semantics) */
+ if (x1 > x2) SWAP(x1, x2);
+ if (y1 > y2) SWAP(y1, y2);
+
+ /* Draw rectangle */
+ gfx_line(bm, x1, y1, x2-1, y1);
+ gfx_line(bm, x2-1, y1, x2-1, y2-1);
+ gfx_line(bm, x2-1, y2-1, x1, y2-1);
+ gfx_line(bm, x1, y2-1, x1, y1);
+}
+
+
+/*!
+ * Fill a rectangular area with \a color.
+ *
+ * \note The bottom-right border of the rectangle is not drawn.
+ *
+ * \note This function does \b not update the current pen position
+ */
+void gfx_rectFillC(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t color)
+{
+ coord_t x, y;
+
+ /* Sort coords */
+ if (x1 > x2) SWAP(x1, x2);
+ if (y1 > y2) SWAP(y1, y2);
+
+ /* Clip rect to bitmap bounds */
+ if (x1 < 0) x1 = 0;
+ if (x2 < 0) x2 = 0;
+ if (x1 > bm->width) x1 = bm->width;
+ if (x2 > bm->width) x2 = bm->width;
+ if (y1 < 0) y1 = 0;
+ if (y2 < 0) y2 = 0;
+ if (y1 > bm->width) y1 = bm->width;
+ if (y2 > bm->width) y2 = bm->width;
+
+ /*
+ * Draw rectangle
+ * NOTE: Code paths are duplicated for efficiency
+ */
+ if (color) /* fill */
+ {
+ for (x = x1; x < x2; x++)
+ for (y = y1; y < y2; y++)
+ BM_PLOT(bm, x, y);
+ }
+ else /* clear */
+ {
+ for (x = x1; x < x2; x++)
+ for (y = y1; y < y2; y++)
+ BM_CLEAR(bm, x, y);
+ }
+}
+
+
+/*!
+ * Draw a filled rectangle.
+ *
+ * \note The bottom-right border of the rectangle is not drawn.
+ *
+ * \note This function does \b not update the current pen position
+ */
+void gfx_rectFill(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
+{
+ gfx_rectFillC(bm, x1, y1, x2, y2, 0xFF);
+}
+
+
+/*!
+ * Clear a rectangular area.
+ *
+ * \note The bottom-right border of the rectangle is not drawn.
+ *
+ * \note This function does \b not update the current pen position
+ */
+void gfx_rectClear(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
+{
+ gfx_rectFillC(bm, x1, y1, x2, y2, 0x00);
+}
+
+
+/*!
+ * Imposta un rettangolo di clipping per il disegno nella bitmap.
+ */
+void gfx_setClipRect(Bitmap *bm, coord_t minx, coord_t miny, coord_t maxx, coord_t maxy)
+{
+ ASSERT(minx < maxx);
+ ASSERT(miny < maxy);
+ ASSERT(miny >= 0);
+ ASSERT(minx >= 0);
+ ASSERT(maxx <= bm->width);
+ ASSERT(maxy <= bm->height);
+
+ bm->cr.xmin = minx;
+ bm->cr.ymin = miny;
+ bm->cr.xmax = maxx;
+ bm->cr.ymax = maxy;
+
+/* DB(kprintf("cr.xmin = %d, cr.ymin = %d, cr.xmax = %d, cr.ymax = %d\n",
+ bm->cr.xMin, bm->cr.ymin, bm->cr.xmax, bm->cr.ymax);)
+*/
+}
+
+
+#if CONFIG_GFX_VCOORDS
+/*!
+ * Imposta gli estremi del sistema di coordinate cartesiane rispetto
+ * al rettangolo di clipping della bitmap.
+ */
+void gfx_setViewRect(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2)
+{
+ ASSERT(x1 != x2);
+ ASSERT(y1 != y2);
+
+ bm->orgX = x1;
+ bm->orgY = y1;
+ bm->scaleX = (vcoord_t)(bm->cr.xmax - bm->cr.xmin - 1) / (vcoord_t)(x2 - x1);
+ bm->scaleY = (vcoord_t)(bm->cr.ymax - bm->cr.ymin - 1) / (vcoord_t)(y2 - y1);
+
+/* DB(kprintf("orgX = %f, orgY = %f, scaleX = %f, scaleY = %f\n",
+ bm->orgX, bm->orgY, bm->scaleX, bm->scaleY);)
+*/
+}
+
+
+/*!
+ * Transform a coordinate from the current reference system to a
+ * pixel offset within the bitmap.
+ */
+coord_t gfx_transformX(Bitmap *bm, vcoord_t x)
+{
+ return bm->cr.xmin + (coord_t)((x - bm->orgX) * bm->scaleX);
+}
+
+/*!
+ * Transform a coordinate from the current reference system to a
+ * pixel offset within the bitmap.
+ */
+coord_t gfx_transformY(Bitmap *bm, vcoord_t y)
+{
+ return bm->cr.ymin + (coord_t)((y - bm->orgY) * bm->scaleY);
+}
+
+
+/*!
+ * Draw a line from (x1;y1) to (x2;y2).
+ */
+void gfx_vline(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2)
+{
+ gfx_line(bm,
+ gfx_transformX(bm, x1), gfx_transformY(bm, y1),
+ gfx_transformY(bm, x2), gfx_transformY(bm, y2));
+}
+#endif /* CONFIG_GFX_VCOORDS */
--- /dev/null
+/*!
+ * \file
+ * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
+ * This file is part of DevLib - See README.devlib for information.
+ *
+ * \version $Id$
+ *
+ * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Stefano Fedrigo <aleph@develer.com>
+ *
+ * \brief General pourpose graphics routines
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/11/04 18:11:35 bernie
+ *#* Move graphics stuff from mware/ to gfx/.
+ *#*
+ *#* Revision 1.12 2005/11/04 16:20:02 bernie
+ *#* Fix reference to README.devlib in header.
+ *#*
+ *#* Revision 1.11 2005/04/11 19:10:28 bernie
+ *#* Include top-level headers from cfg/ subdir.
+ *#*
+ *#* Revision 1.10 2005/03/01 23:26:45 bernie
+ *#* Use new CPU-neutral program-memory API.
+ *#*
+ *#* Revision 1.9 2005/01/20 18:46:31 aleph
+ *#* Fix progmem includes.
+ *#*
+ *#* Revision 1.8 2004/11/01 15:14:07 bernie
+ *#* Update to current coding conventions.
+ *#*
+ *#* Revision 1.7 2004/09/20 03:29:06 bernie
+ *#* Conditionalize AVR-specific code.
+ *#*
+ *#* Revision 1.6 2004/09/14 21:01:08 bernie
+ *#* Rename rectangle drawing functions; Unify filled/cleared implementations.
+ *#*
+ *#* Revision 1.4 2004/08/10 07:00:16 bernie
+ *#* Add missing header.
+ *#*
+ *#* Revision 1.3 2004/08/04 03:16:59 bernie
+ *#* Switch to new DevLib CONFIG_ convention.
+ *#*
+ *#* Revision 1.2 2004/06/03 11:27:09 bernie
+ *#* Add dual-license information.
+ *#*
+ *#* Revision 1.1 2004/05/23 15:43:16 bernie
+ *#* Import mware modules.
+ *#*/
+
+#ifndef MWARE_GFX_H
+#define MWARE_GFX_H
+
+#include <cfg/config.h>
+#include <cfg/compiler.h>
+#include <cfg/cpu.h>
+
+
+/*! Common type for coordinates expressed in pixel units */
+typedef int coord_t;
+
+#if CONFIG_GFX_VCOORDS
+/*! Common type for coordinates expressed in logical units */
+typedef float vcoord_t;
+#endif /* CONFIG_GFX_VCOORDS */
+
+
+typedef struct Rect { coord_t xmin, ymin, xmax, ymax; } Rect;
+
+
+/*!
+ * Control structure to draw in a bitmap
+ */
+typedef struct Bitmap
+{
+ uint8_t *raster; /*!< Pointer to byte array to hold the data */
+ coord_t width, height; /*!< Width/Height in pixels */
+ coord_t penX, penY; /*!< Current pen position MoveTo()/LineTo() */
+
+ Rect cr; /*!< Clip drawing inside this rectangle */
+
+#if CONFIG_GFX_VCOORDS
+ /*!
+ * \name Logical coordinate system
+ * \{
+ */
+ vcoord_t orgX, orgY;
+ vcoord_t scaleX, scaleY;
+ /*\}*/
+#endif /* CONFIG_GFX_VCOORDS */
+
+} Bitmap;
+
+
+/* Function prototypes */
+extern void gfx_bitmapInit (Bitmap *bm, uint8_t *raster, coord_t w, coord_t h);
+extern void gfx_bitmapClear(Bitmap *bm);
+extern void gfx_line (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
+extern void gfx_rectDraw (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
+extern void gfx_rectFillC (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t color);
+extern void gfx_rectFill (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
+extern void gfx_rectClear (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
+extern void gfx_moveTo (Bitmap *bm, coord_t x, coord_t y);
+extern void gfx_lineTo (Bitmap *bm, coord_t x, coord_t y);
+extern void gfx_setClipRect(Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax);
+
+#if CPU_HARVARD
+ #include <mware/pgm.h>
+ extern void gfx_blit_P(Bitmap *bm, const pgm_uint8_t *raster);
+#endif
+
+
+#if CONFIG_GFX_VCOORDS
+extern void gfx_setViewRect(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2);
+extern coord_t gfx_transformX(Bitmap *bm, vcoord_t x);
+extern coord_t gfx_transformY(Bitmap *bm, vcoord_t y);
+extern void gfx_vline(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2);
+#endif /* CONFIG_GFX_VCOORDS */
+
+#endif /* MWARE_GFX_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \brief Text graphic routines
+ *
+ * \version $Id$
+ * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Stefano Fedrigo <aleph@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/11/04 18:11:35 bernie
+ *#* Move graphics stuff from mware/ to gfx/.
+ *#*
+ *#* Revision 1.13 2005/11/04 16:20:02 bernie
+ *#* Fix reference to README.devlib in header.
+ *#*
+ *#* Revision 1.12 2005/04/11 19:10:28 bernie
+ *#* Include top-level headers from cfg/ subdir.
+ *#*
+ *#* Revision 1.11 2005/01/20 18:46:31 aleph
+ *#* Fix progmem includes.
+ *#*
+ *#* Revision 1.10 2005/01/08 09:20:12 bernie
+ *#* Really make it work on both architectures.
+ *#*
+ *#* Revision 1.9 2004/12/31 16:44:29 bernie
+ *#* Sanitize for non-Harvard processors.
+ *#*
+ *#* Revision 1.8 2004/11/16 21:16:28 bernie
+ *#* Update to new naming scheme in mware/gfx.c.
+ *#*
+ *#* Revision 1.7 2004/09/20 03:28:28 bernie
+ *#* Fix header.
+ *#*
+ *#* Revision 1.6 2004/09/14 20:57:15 bernie
+ *#* Use debug.h instead of kdebug.h.
+ *#*
+ *#* Revision 1.5 2004/09/06 21:51:26 bernie
+ *#* Extend interface to allow any algorithmic style.
+ *#*
+ *#* Revision 1.2 2004/06/03 11:27:09 bernie
+ *#* Add dual-license information.
+ *#*
+ *#* Revision 1.1 2004/05/23 15:43:16 bernie
+ *#* Import mware modules.
+ *#*
+ *#* Revision 1.17 2004/05/15 16:57:01 aleph
+ *#* Fixes for non-DEBUG build
+ *#*
+ *#* Revision 1.16 2004/04/03 20:42:49 aleph
+ *#* Add text_clear()
+ *#*
+ *#* Revision 1.15 2004/03/24 15:03:45 bernie
+ *#* Use explicit include paths; clean Doxygen comments
+ *#*
+ *#* Revision 1.14 2004/03/19 16:52:28 bernie
+ *#* Move printf() like functions from text.c to text_format.c and add PROGMEM versions.
+ *#*
+ *#* Revision 1.13 2004/03/17 18:23:32 bernie
+ *#* Oops.
+ *#*
+ *#* Revision 1.12 2004/03/17 18:03:22 bernie
+ *#* Make diagnostic message shorter
+ *#*
+ *#* Revision 1.11 2004/03/13 22:52:54 aleph
+ *#* documentation fixes
+ *#*/
+
+#include "gfx.h"
+#include "font.h"
+#include "text.h"
+
+#include <cfg/debug.h>
+
+
+/*!
+ * Flags degli stili algoritmici
+ *
+ * La routine di rendering del testo e' in grado di applicare
+ * delle semplici trasformazioni al font interno per generare
+ * automaticamente degli stili predefiniti (bold, italic,
+ * underline) a partire dal set di caratteri plain.
+ */
+static uint8_t text_styles;
+
+/*! ANSI escape sequences flag: true for ESC state on */
+static bool ansi_mode = false;
+
+
+/*!
+ * Move (imaginary) cursor to column and row specified.
+ * Next text write will start a that row and col.
+ */
+void text_moveto(struct Bitmap *bm, int row, int col)
+{
+ ASSERT(col >= 0);
+ ASSERT(col < bm->width / FONT_WIDTH);
+ ASSERT(row >= 0);
+ ASSERT(row < bm->height / FONT_HEIGHT);
+
+ bm->penX = col * FONT_WIDTH;
+ bm->penY = row * FONT_HEIGHT;
+}
+
+
+/*!
+ * Move (imaginary) cursor to coordinates specified.
+ */
+void text_setcoord(struct Bitmap *bm, int x, int y)
+{
+ bm->penX = x;
+ bm->penY = y;
+}
+
+
+/*!
+ * Render char \a c on Bitmap \a bm
+ */
+static int text_putglyph(char c, struct Bitmap *bm)
+{
+ const uint8_t * PROGMEM glyph; /* font is in progmem */
+ uint8_t glyph_width;
+ uint8_t i;
+ uint8_t *buf;
+
+ /*
+ * Il carattere da stampare viene usato come indice per prelevare
+ * la prima colonna di dots del glyph all'interno del font.
+ */
+ glyph = font + (((unsigned char)c) * FONT_WIDTH);
+ glyph_width = FONT_WIDTH;
+
+ if (text_styles & STYLEF_CONDENSED)
+ --glyph_width;
+
+ if (text_styles & STYLEF_EXPANDED)
+ glyph_width *= 2;
+
+ /* The y coord is rounded at multiples of 8 for simplicity */
+ bm->penY &= ~((coord_t)7);
+
+ /* Check if glyph to write fits in the bitmap */
+ if ((bm->penX < 0) || (bm->penX + glyph_width > bm->width) ||
+ (bm->penY < 0) || (bm->penY + FONT_HEIGHT > bm->height))
+ {
+ DB(kprintf("bad coords x=%d y=%d\n", bm->penX, bm->penY);)
+ return 0;
+ }
+
+ /* Locate position where to write in the raster */
+ buf = bm->raster + bm->penY / 8 * bm->width + bm->penX;
+
+ bm->penX += glyph_width;
+
+ /* If some styles are set */
+ if (text_styles)
+ {
+ uint8_t prev_dots = 0, italic_prev_dots = 0, new_dots;
+ uint8_t dots;
+
+ /* Per ogni colonna di dot del glyph... */
+ for (i = 0; i < glyph_width; ++i)
+ {
+ dots = PGM_READ_CHAR(glyph);
+
+ /* Advance to next column in glyph.
+ * Expand: advances only once every two columns
+ */
+ if (!(text_styles & STYLEF_EXPANDED) || (i & 1))
+ glyph++;
+
+ /* Italic: get lower 4 dots from previous column */
+ if (text_styles & STYLEF_ITALIC)
+ {
+ new_dots = dots;
+ dots = (dots & 0xF0) | italic_prev_dots;
+ italic_prev_dots = new_dots & 0x0F;
+ }
+
+ /* Bold: "or" pixels with the previous column */
+ if (text_styles & STYLEF_BOLD)
+ {
+ new_dots = dots;
+ dots |= prev_dots;
+ prev_dots = new_dots;
+ }
+
+ /* Underlined: turn on base pixel */
+ if (text_styles & STYLEF_UNDERLINE)
+ dots |= 0x80;
+
+ /* Inverted: invert pixels */
+ if (text_styles & STYLEF_INVERT)
+ dots = ~dots;
+
+ /* Output dots */
+ *buf++ = dots;
+ }
+ }
+ else /* No style: fast vanilla copy of glyph to line buffer */
+ while (glyph_width--)
+ *buf++ = PGM_READ_CHAR(glyph++);
+
+ return c;
+}
+
+
+/*!
+ * Render char \c c, with (currently) limited ANSI escapes
+ * emulation support and '\n' for newline.
+ */
+int text_putchar(char c, struct Bitmap *bm)
+{
+ /* Handle ANSI escape sequences */
+ if (ansi_mode)
+ {
+ switch (c)
+ {
+ case ANSI_ESC_CLEARSCREEN:
+ gfx_bitmapClear(bm);
+ bm->penX = 0;
+ bm->penY = 0;
+ text_style(0, STYLEF_MASK);
+ break;
+ DB(default:
+ kprintf("Unknown ANSI esc code: %x\n", c);)
+ }
+ ansi_mode = false;
+ }
+ else if (c == '\033') /* Enter ANSI ESC mode */
+ {
+ ansi_mode = true;
+ }
+ else if (c == '\n') /* Go one line down on a line-feed */
+ {
+ if (bm->penY + FONT_HEIGHT < bm->height)
+ {
+ bm->penY += FONT_HEIGHT;
+ bm->penX = 0;
+ }
+ }
+ else
+ {
+ text_putglyph(c, bm);
+ }
+ return c;
+}
+
+
+/*!
+ * Clear the screen and reset cursor position
+ */
+void text_clear(struct Bitmap *bmp)
+{
+ text_putchar('\x1b', bmp);
+ text_putchar('c', bmp);
+}
+
+
+void text_clearLine(struct Bitmap *bmp, int line)
+{
+ gfx_rectClear(bmp, 0, line * FONT_HEIGHT, bmp->width, (line + 1) * FONT_HEIGHT);
+}
+
+
+/*!
+ * Set/clear algorithmic font style bits.
+ *
+ * \param flags Style flags to set
+ * \param mask Mask of flags to modify
+ * \return Old style flags
+ *
+ * Examples:
+ * Turn on bold, leave other styles alone
+ * \code prt_style(STYLEF_BOLD, STYLEF_BOLD); \endcode
+ *
+ * Turn off bold and turn on italic, leave others as they are
+ * \code prt_style(STYLEF_ITALIC, STYLEF_BOLD | STYLEF_ITALIC); \endcode
+ *
+ * Query current style without chaning it
+ * \code style = prt_style(0, 0); \endcode
+ *
+ * Reset all styles (plain text)
+ * \code prt_style(0, STYLE_MASK); \endcode
+ */
+uint8_t text_style(uint8_t flags, uint8_t mask)
+{
+ uint8_t old = text_styles;
+ text_styles = (text_styles & ~mask) | flags;
+ return old;
+}
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \brief Text graphic routines (interface)
+ *
+ * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Stefano Fedrigo <aleph@develer.com>
+ * \version $Id$
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/11/04 18:11:35 bernie
+ *#* Move graphics stuff from mware/ to gfx/.
+ *#*
+ *#* Revision 1.11 2005/04/11 19:10:28 bernie
+ *#* Include top-level headers from cfg/ subdir.
+ *#*
+ *#* Revision 1.10 2005/03/01 23:26:46 bernie
+ *#* Use new CPU-neutral program-memory API.
+ *#*
+ *#* Revision 1.9 2004/12/31 16:44:29 bernie
+ *#* Sanitize for non-Harvard processors.
+ *#*
+ *#* Revision 1.8 2004/10/03 20:43:37 bernie
+ *#* Import changes from project_ks.
+ *#*
+ *#* Revision 1.7 2004/09/20 03:28:49 bernie
+ *#* Fix header; Conditionalize AVR-specific code.
+ *#*
+ *#* Revision 1.6 2004/09/14 20:57:30 bernie
+ *#* Reformat.
+ *#*
+ *#* Revision 1.5 2004/09/06 21:51:26 bernie
+ *#* Extend interface to allow any algorithmic style.
+ *#*
+ *#* Revision 1.4 2004/08/25 14:12:09 rasky
+ *#* Aggiornato il comment block dei log RCS
+ *#*
+ *#* Revision 1.3 2004/08/05 18:46:44 bernie
+ *#* Documentation improvements.
+ *#*
+ *#* Revision 1.2 2004/06/03 11:27:09 bernie
+ *#* Add dual-license information.
+ *#*
+ *#*/
+
+#ifndef MWARE_TEXT_H
+#define MWARE_TEXT_H
+
+#include <cfg/compiler.h>
+#include <cfg/macros.h> /* BV() */
+#include <cfg/cpu.h> /* CPU_HARVARD */
+
+#include <stdarg.h>
+
+/*!
+ * \name Style flags
+ * \see text_style()
+ * \{
+ */
+#define STYLEF_BOLD BV(0)
+#define STYLEF_ITALIC BV(1)
+#define STYLEF_UNDERLINE BV(2)
+#define STYLEF_INVERT BV(3)
+#define STYLEF_EXPANDED BV(4)
+#define STYLEF_CONDENSED BV(5)
+#define STYLEF_STRIKEOUT BV(6) /*<! Not implemented */
+
+#define STYLEF_MASK \
+ (STYLEF_BOLD | STYLEF_ITALIC | STYLEF_UNDERLINE | \
+ STYLEF_EXPANDED | STYLEF_CONDENSED | STYLEF_INVERT)
+/*\}*/
+
+/*!
+ * \name Formatting flags for text rendering
+ * \see text_xprintf()
+ * \{
+ */
+#define TEXT_NORMAL 0 /*!< Normal mode */
+#define TEXT_FILL BV(7) /*!< Fill rest of line with spaces */
+#define TEXT_CENTER BV(8) /*!< Center string in line */
+#define TEXT_RIGHT BV(9) /*!< Right aligned */
+/*\}*/
+
+/*! Escape sequences codes */
+#define ANSI_ESC_CLEARSCREEN 'c'
+
+
+/* Fwd decl */
+struct Bitmap;
+
+/* Low-level text functions (mware/text.c) */
+void text_moveto(struct Bitmap *bm, int row, int col);
+void text_setcoord(struct Bitmap *bm, int x, int y);
+int text_putchar(char c, struct Bitmap *bm);
+uint8_t text_style(uint8_t flags, uint8_t mask);
+void text_clear(struct Bitmap *bm);
+void text_clearLine(struct Bitmap *bm, int line);
+
+/* Text formatting functions (mware/text_format.c) */
+int text_puts(const char *str, struct Bitmap *bm);
+int text_vprintf(struct Bitmap *bm, const char *fmt, va_list ap);
+int text_printf(struct Bitmap *bm, const char *fmt, ...) FORMAT(__printf__, 2, 3);
+int text_xprintf(struct Bitmap *bm, uint8_t row, uint8_t col, uint16_t mode, const char *fmt, ...) FORMAT(__printf__, 5, 6);
+int text_vwidthf(struct Bitmap *bm, const char * fmt, va_list ap);
+int text_widthf(struct Bitmap *bm, const char * fmt, ...) FORMAT(__printf__, 2, 3);
+
+/* Text formatting functions for program-memory strings (mware/text_format.c) */
+#if CPU_HARVARD
+#include <mware/pgm.h>
+int text_puts_P(const char * PROGMEM str, struct Bitmap *bm);
+int text_vprintf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap);
+int text_printf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...) FORMAT(__printf__, 2, 3);
+int text_xprintf_P(struct Bitmap *bm, uint8_t row, uint8_t col, uint16_t mode, const char * PROGMEM fmt, ...) FORMAT(__printf__, 5, 6);
+int text_vwidthf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap);
+int text_widthf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...);
+#endif /* CPU_HARVARD */
+
+#endif /* MWARE_TEXT_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \brief printf-family routines for text output
+ *
+ * \version $Id$
+ * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Stefano Fedrigo <aleph@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/11/04 18:11:35 bernie
+ *#* Move graphics stuff from mware/ to gfx/.
+ *#*
+ *#* Revision 1.10 2005/11/04 16:20:02 bernie
+ *#* Fix reference to README.devlib in header.
+ *#*
+ *#* Revision 1.9 2004/12/31 17:47:45 bernie
+ *#* Rename UNUSED() to UNUSED_ARG().
+ *#*
+ *#* Revision 1.8 2004/11/16 21:16:56 bernie
+ *#* Update to new naming scheme in mware/gfx.c.
+ *#*
+ *#* Revision 1.7 2004/10/03 19:05:04 bernie
+ *#* text_widthf(), text_vwidthf(): New functions.
+ *#*
+ *#* Revision 1.6 2004/09/14 20:59:04 bernie
+ *#* text_xprintf(): Support all styles; Pixel-wise text centering.
+ *#*
+ *#* Revision 1.5 2004/08/25 14:12:09 rasky
+ *#* Aggiornato il comment block dei log RCS
+ *#*
+ *#* Revision 1.4 2004/08/05 18:46:44 bernie
+ *#* Documentation improvements.
+ *#*
+ *#* Revision 1.3 2004/08/03 15:57:18 aleph
+ *#* Add include to fix warning for vsprintf()
+ *#*
+ *#* Revision 1.2 2004/06/03 11:27:09 bernie
+ *#* Add dual-license information.
+ *#*
+ *#* Revision 1.1 2004/05/23 15:43:16 bernie
+ *#* Import mware modules.
+ *#*
+ *#* Revision 1.2 2004/03/26 18:50:50 bernie
+ *#* Move _PROGMEM stuff to compiler.h
+ *#*
+ *#* Revision 1.1 2004/03/19 16:52:28 bernie
+ *#* Move printf() like functions from text.c to text_format.c and add PROGMEM versions.
+ *#*
+ *#*/
+
+#include "text.h"
+#include "formatwr.h" /* _formatted_write() */
+#include "font.h"
+#include "gfx.h"
+#include <stdio.h> /* vsprintf() */
+#include <stdarg.h>
+#include <string.h> /* strlen() */
+
+/*!
+ * Render string \a str in Bitmap \a bm at current cursor position
+ *
+ * \note Text formatting functions are also available with an _P suffix
+ * accepting the source string from program memory. This feature
+ * is only available (and useful) on Harvard microprocessors such
+ * as the AVR.
+ *
+ * \see text_putchar()
+ */
+int PGM_FUNC(text_puts)(const char * PGM_ATTR str, struct Bitmap *bm)
+{
+ char c;
+
+ while ((c = PGM_READ_CHAR(str++)))
+ text_putchar(c, bm);
+
+ return 0;
+}
+
+
+/*!
+ * vprintf()-like formatter to render text in a Bitmap.
+ *
+ * Perform vprintf()-like formatting on the \a fmt format string using the
+ * variable-argument list \a ap.
+ * Render the resulting string in Bitmap \a bm starting at the current
+ * cursor position.
+ *
+ * \see text_puts() text_putchar() text_printf()
+ */
+int PGM_FUNC(text_vprintf)(struct Bitmap *bm, const char * PGM_ATTR fmt, va_list ap)
+{
+ return PGM_FUNC(_formatted_write)(fmt, (void (*)(char, void *))text_putchar, bm, ap);
+}
+
+/*!
+ * printf()-like formatter to render text in a Bitmap.
+ *
+ * Perform printf()-like formatting on the \a fmt format string.
+ * Render the resulting string in Bitmap \a bm starting at the
+ * current cursor position.
+ *
+ * \see text_puts() text_putchar() text_vprintf()
+ */
+int PGM_FUNC(text_printf)(struct Bitmap *bm, const char * PGM_ATTR fmt, ...)
+{
+ int len;
+
+ va_list ap;
+ va_start(ap, fmt);
+ len = PGM_FUNC(text_vprintf)(bm, fmt, ap);
+ va_end(ap);
+
+ return len;
+}
+
+
+/*!
+ * Render the result of printf()-like formatting in a specified position
+ * of a Bitmap.
+ *
+ * \param bm Bitmap where to render the text
+ * \param row Starting row in character units (zero based)
+ * \param col Starting column in character units (zero based)
+ * \param style Formatting style to use. In addition to any STYLEF_
+ * flag, it can be TEXT_NORMAL, TEXT_FILL, TEXT_INVERT or
+ * TEXT_RIGHT, or a combination of these flags ORed together.
+ * \param fmt String possibly containing printf() formatting commands.
+ *
+ * \see text_puts() text_putchar() text_printf() text_vprintf()
+ * \see text_moveto() text_style()
+ */
+int PGM_FUNC(text_xprintf)(struct Bitmap *bm,
+ uint8_t row, uint8_t col, uint16_t style, const char * PGM_ATTR fmt, ...)
+{
+ int len;
+ uint8_t oldstyle = 0;
+ va_list ap;
+
+ va_start(ap, fmt);
+
+ text_moveto(bm, row, col);
+
+ if (style & STYLEF_MASK)
+ oldstyle = text_style(style, STYLEF_MASK);
+
+ if (style & (TEXT_CENTER | TEXT_RIGHT))
+ {
+ uint8_t pad = bm->width - PGM_FUNC(text_vwidthf)(bm, fmt, ap);
+
+ if (style & TEXT_CENTER)
+ pad /= 2;
+
+ if (style & TEXT_FILL)
+ gfx_rectFillC(bm, 0, row * FONT_HEIGHT, pad, (row + 1) * FONT_HEIGHT,
+ (style & STYLEF_INVERT) ? 0xFF : 0x00);
+
+ text_setcoord(bm, pad, row * FONT_HEIGHT);
+ }
+
+ len = PGM_FUNC(text_vprintf)(bm, fmt, ap);
+ va_end(ap);
+
+ if (style & TEXT_FILL)
+ gfx_rectFillC(bm, bm->penX, row * FONT_HEIGHT, bm->width, (row + 1) * FONT_HEIGHT,
+ (style & STYLEF_INVERT) ? 0xFF : 0x00);
+
+ /* Restore old style */
+ if (style & STYLEF_MASK)
+ text_style(oldstyle, STYLEF_MASK);
+
+ return len;
+}
+
+
+/*!
+ * Return the width in pixels of a vprintf()-formatted string.
+ */
+int PGM_FUNC(text_vwidthf)(
+ UNUSED_ARG(struct Bitmap *, bm),
+ const char * PGM_ATTR fmt,
+ va_list ap)
+{
+ return PGM_FUNC(vsprintf)(NULL, fmt, ap) * FONT_WIDTH;
+}
+
+
+/*!
+ * Return the width in pixels of a printf()-formatted string.
+ */
+int PGM_FUNC(text_widthf)(struct Bitmap *bm, const char * PGM_ATTR fmt, ...)
+{
+ int width;
+
+ va_list ap;
+ va_start(ap, fmt);
+ width = PGM_FUNC(text_vwidthf)(bm, fmt, ap);
+ va_end(ap);
+
+ return width;
+}
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999, 2000, 2001, 2003 Bernardo Innocenti <bernie@develer.com>
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \brief Simple charts on top of mware/gfx routines (implementation).
- *
- * Sample usage:
- *
- * \code
- * bm = chart_init(0, ymax, N_POINTS_CURVE, ymin);
- *
- * chart_drawCurve(bm, curve_y, curve_points + 1);
- * gfx_setViewRect(bm, xmin, ymax, xmax, ymin);
- * chart_drawDots(bm, samples_x, samples_y, samples_cnt);
- *
- * print_bitmap(bm);
- * \endcode
- *
- * \version $Id$
- * \author Bernardo Innocenti <bernie@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.7 2005/11/04 16:20:02 bernie
- *#* Fix reference to README.devlib in header.
- *#*
- *#* Revision 1.6 2004/11/16 21:04:23 bernie
- *#* Update to new naming scheme in mware/gfx.c.
- *#*
- *#* Revision 1.5 2004/09/14 20:56:39 bernie
- *#* Make more generic and adapt to new gfx functions.
- *#*
- *#* Revision 1.3 2004/08/11 19:39:12 bernie
- *#* Use chart_x_t and chart_y_t for the input dataset.
- *#*
- *#* Revision 1.1 2004/08/04 03:16:30 bernie
- *#* Import simple chart drawing code.
- *#*
- *#*/
-
-#include "charts.h"
-#include <mware/gfx.h>
-
-
-#ifndef CONFIG_CHART_ARROWS
-#define CONFIG_CHART_ARROWS 0
-#endif
-
-
-void chart_init(Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax)
-{
- /* Clear the chart area */
- gfx_rectClear(bm, xmin, ymin, xmax, ymax);
-
- gfx_setClipRect(bm, xmin + CHART_BORDERLEFT, ymin + CHART_BORDERTOP,
- xmax - CHART_BORDERRIGHT, ymax - CHART_BORDERBOTTOM);
-
- chart_drawAxis(bm);
-}
-
-
-void chart_setScale(Bitmap *bm, chart_x_t xmin, chart_y_t ymin, chart_x_t xmax, chart_y_t ymax)
-{
- gfx_setViewRect(bm, xmin, ymin, xmax, ymax);
-}
-
-
-/*!
- * Draw the chart axes
- */
-void chart_drawAxis(Bitmap *bm)
-{
-#if CONFIG_CHART_ARROWS
-
- /* Draw axis */
- gfx_moveTo(bm, bm->cr.xmin, bm->cr.ymin + 4);
- gfx_lineTo(bm, bm->cr.xmin, bm->cr.ymax - 1);
- gfx_lineTo(bm, bm->cr.xmax - 4 - 1, bm->cr.ymax - 1);
-
- /* Draw up arrow */
- gfx_moveTo(bm, bm->cr.xmin - 2, bm->cr.ymin + 3);
- gfx_lineTo(bm, bm->cr.xmin + 2, bm->cr.ymin + 3);
- gfx_lineTo(bm, bm->cr.xmin, bm->cr.ymin);
- gfx_lineTo(bm, bm->cr.xmin - 2, bm->cr.ymin + 3);
-
- /* Draw right arrow */
- gfx_moveTo(bm, bm->cr.xmax - 4, bm->cr.ymax - 3);
- gfx_lineTo(bm, bm->cr.xmax - 4, bm->cr.ymax + 1);
- gfx_lineTo(bm, bm->cr.xmax - 1, bm->cr.ymax - 1);
- gfx_lineTo(bm, bm->cr.xmax - 4, bm->cr.ymax - 3);
-
-#else /* CONFIG_CHART_ARROWS */
-
- /* Draw a box around the chart */
- gfx_rectDraw(bm, bm->cr.xmin, bm->cr.ymin, bm->cr.xmax, bm->cr.ymax);
-
-#endif /* CONFIG_CHART_ARROWS */
-
- //CHECK_WALL(wall_before_raster, WALL_SIZE);
- //CHECK_WALL(wall_after_raster, WALL_SIZE);
-}
-
-
-/*!
- * Draw a set of \a curve_cnt connected segments, whose Y coordinates
- * are identified by the \a curve_y array and X-coordinates are
- * are evenly spaced by one virtual unit.
- */
-void chart_drawCurve(Bitmap *bm, const chart_y_t *curve_y, int curve_cnt)
-{
- int i;
-
- gfx_moveTo(bm, gfx_transformX(bm, 0), gfx_transformY(bm, curve_y[0]));
-
- for (i = 1; i < curve_cnt; i++)
- gfx_lineTo(bm, gfx_transformX(bm, i), gfx_transformY(bm, curve_y[i]));
-
- //CHECK_WALL(wall_before_raster, WALL_SIZE);
- //CHECK_WALL(wall_after_raster, WALL_SIZE);
-}
-
-
-/*!
- * Disegna dei dot in corrispondenza delle coppie (dotsx[i];dotsy[i])
- * Se dotsx e' NULL, i punti vengono disegnati ad intervalli regolari.
- */
-void chart_drawDots(Bitmap *bm, const chart_x_t *dots_x, const chart_y_t *dots_y, int cnt)
-{
- int i;
- coord_t x, y;
-
- for (i = 0; i < cnt; i++)
- {
- if (dots_x)
- x = gfx_transformX(bm, dots_x[i]);
- else
- x = gfx_transformX(bm, i);
-
- y = gfx_transformY(bm, dots_y[i]);
-
- /* Draw tick over the curve */
- gfx_rectFill(bm,
- x - TICKS_WIDTH / 2, y - TICKS_HEIGHT / 2,
- x + (TICKS_WIDTH + 1) / 2, y + (TICKS_HEIGHT + 1) / 2);
-
- /* Draw vertical line from the curve to the X-axis */
- //gfx_drawLine(bm, x, y, x, bm->cr.ymax - 1);
- }
-
- //CHECK_WALL(wall_before_raster, WALL_SIZE);
- //CHECK_WALL(wall_after_raster, WALL_SIZE);
-}
-
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999, 2000, 2001, 2003 Bernardo Innocenti <bernie@develer.com>
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \brief Simple charts on top of mware/gfx routines (interface).
- *
- * Configuration:
- * - \c CONFIG_CHART_TYPE_X: type for the input dataset of X-coordinates
- * - \c CONFIG_CHART_TYPE_Y: type for the input dataset of Y-coordinates
- *
- * \version $Id$
- * \author Bernardo Innocenti <bernie@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.7 2005/11/04 16:20:02 bernie
- *#* Fix reference to README.devlib in header.
- *#*
- *#* Revision 1.6 2005/04/11 19:10:28 bernie
- *#* Include top-level headers from cfg/ subdir.
- *#*
- *#* Revision 1.5 2004/09/14 20:56:39 bernie
- *#* Make more generic and adapt to new gfx functions.
- *#*
- *#* Revision 1.3 2004/08/11 19:39:12 bernie
- *#* Use chart_x_t and chart_y_t for the input dataset.
- *#*
- *#* Revision 1.1 2004/08/04 03:16:30 bernie
- *#* Import simple chart drawing code.
- *#*
- *#*/
-#ifndef MWARE_CHARTS_H
-#define MWARE_CHARTS_H
-
-#include <mware/gfx.h> /* vcoord_t */
-#include <cfg/config.h> /* CONFIG_ stuff */
-
-/*!
- * \name Width/height of the small ticks drawn over the axes
- * \{
- */
-#define TICKS_HEIGHT 2
-#define TICKS_WIDTH 2
-/*\}*/
-
-/*!
- * \name Chart frame dimensions
- * \{
- */
-#define CHART_BORDERTOP 0
-#define CHART_BORDERBOTTOM 0
-#define CHART_BORDERLEFT 0
-#define CHART_BORDERRIGHT 0
-/*\}*/
-
-#ifndef CONFIG_CHART_TYPE_X
-#define CONFIG_CHART_TYPE_X vcoord_t
-#endif
-#ifndef CONFIG_CHART_TYPE_Y
-#define CONFIG_CHART_TYPE_Y vcoord_t
-#endif
-
-
-typedef CONFIG_CHART_TYPE_X chart_x_t;
-typedef CONFIG_CHART_TYPE_Y chart_y_t;
-
-
-/* Public function protos */
-void chart_init(Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax);
-void chart_setScale(Bitmap *bm, chart_x_t xmin, chart_y_t ymin, chart_x_t xmax, chart_y_t ymax);
-void chart_drawAxis(Bitmap *bm);
-void chart_drawCurve(Bitmap *bm, const chart_y_t *curve_y, int curve_cnt);
-void chart_drawDots(Bitmap *bm, const chart_x_t *dots_x, const chart_y_t *dots_y, int cnt);
-
-#endif /* MWARE_CHARTS_H */
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright (C) 2001 Bernardo Innocenti <bernie@codewiz.org>
- * Copyright (C) 2003,2004 Develer S.r.l. (http://www.develer.com/)
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \version $Id$
- *
- * \author Bernardo Innocenti <bernie@develer.com>
- *
- * \brief Font 8x6 IBM-PC 8bit
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.6 2005/11/04 16:20:02 bernie
- *#* Fix reference to README.devlib in header.
- *#*
- *#* Revision 1.5 2005/01/08 09:20:38 bernie
- *#* Add missing type in declaration.
- *#*
- *#* Revision 1.4 2004/12/31 16:42:55 bernie
- *#* Sanitize for non-Harvard processors.
- *#*
- *#* Revision 1.3 2004/08/25 14:12:09 rasky
- *#* Aggiornato il comment block dei log RCS
- *#*
- *#* Revision 1.2 2004/06/03 11:27:09 bernie
- *#* Add dual-license information.
- *#*
- *#* Revision 1.1 2004/05/23 15:43:16 bernie
- *#* Import mware modules.
- *#*
- *#* Revision 1.5 2004/03/24 15:48:53 bernie
- *#* Remove Copyright messages from Doxygen output
- *#*
- *#* Revision 1.4 2004/03/03 18:30:17 bernie
- *#* Substitute left triangle glyph with left arrow
- *#*
- *#* Revision 1.3 2004/02/28 14:48:33 aleph
- *#* Improve arrow glyphs
- *#*
- *#* Revision 1.2 2004/01/13 12:15:28 aleph
- *#* Move font table in program memory; add font.h
- *#*
- *#* Revision 1.1 2004/01/07 23:31:54 aleph
- *#* Add text routines
- *#*
- *#*/
-
-#include "font.h"
-
-const PROGMEM uint8_t font[256 * 6] =
-{
-/* 0x00 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* */
- 0x3E, 0x45, 0x51, 0x45, 0x3E, 0x00, /* */
- 0x3E, 0x7B, 0x6F, 0x7B, 0x3E, 0x00, /* */
- 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, /* */
- 0x08, 0x1C, 0x3E, 0x1C, 0x08, 0x00, /* */
- 0x18, 0x5A, 0x67, 0x5A, 0x18, 0x00, /* */
- 0x0C, 0x5E, 0x6F, 0x5E, 0x0C, 0x00, /* */
- 0x08, 0x1C, 0x3E, 0x1C, 0x08, 0x00, /* */
-/* 0x08 */
- 0x77, 0x63, 0x41, 0x63, 0x77, 0x00, /* */
- 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00, /* */
- 0x77, 0x63, 0x41, 0x63, 0x77, 0x00, /* */
- 0x20, 0x50, 0x5A, 0x56, 0x2E, 0x00, /* */
- 0x06, 0x29, 0x79, 0x29, 0x06, 0x00, /* */
- 0x60, 0x60, 0x7F, 0x05, 0x07, 0x00, /* */
- 0x18, 0x1F, 0x01, 0x61, 0x7F, 0x00, /* */
- 0x15, 0x0E, 0x1B, 0x0E, 0x15, 0x00, /* */
-/* 0x10 */
- 0x00, 0x08, 0x1C, 0x3E, 0x08, 0x08, /* */
- 0x7F, 0x3E, 0x1C, 0x08, 0x00, 0x00, /* */
- 0x14, 0x36, 0x7F, 0x36, 0x14, 0x00, /* */
- 0x00, 0x5F, 0x00, 0x5F, 0x00, 0x00, /* */
- 0x02, 0x05, 0x7F, 0x01, 0x7F, 0x00, /* */
- 0x20, 0x4A, 0x55, 0x29, 0x02, 0x00, /* */
- 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, /* */
- 0x54, 0x76, 0x7F, 0x76, 0x54, 0x00, /* */
-/* 0x18 */
- 0x08, 0x0C, 0x7E, 0x0C, 0x08, 0x00, /* */
- 0x10, 0x30, 0x7E, 0x30, 0x10, 0x00, /* */
- 0x08, 0x08, 0x3E, 0x1C, 0x08, 0x00, /* */
- 0x08, 0x1C, 0x3E, 0x08, 0x08, 0x00, /* */
- 0x1C, 0x10, 0x10, 0x10, 0x10, 0x00, /* */
- 0x08, 0x1C, 0x08, 0x1C, 0x08, 0x00, /* */
- 0x18, 0x1C, 0x1E, 0x1C, 0x18, 0x00, /* */
- 0x0C, 0x1C, 0x3C, 0x1C, 0x0C, 0x00, /* */
-/* 0x20 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* */
- 0x00, 0x00, 0x4F, 0x00, 0x00, 0x00, /* ! */
- 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, /* " */
- 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, /* # */
- 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, /* $ */
- 0x63, 0x13, 0x08, 0x64, 0x63, 0x00, /* % */
- 0x36, 0x49, 0x55, 0x22, 0x50, 0x00, /* & */
- 0x00, 0x05, 0x03, 0x00, 0x00, 0x00, /* ' */
-/* 0x28 */
- 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, /* ( */
- 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, /* ) */
- 0x14, 0x08, 0x3E, 0x08, 0x14, 0x00, /* * */
- 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, /* + */
- 0x00, 0x50, 0x30, 0x00, 0x00, 0x00, /* , */
- 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, /* - */
- 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, /* . */
- 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, /* / */
-/* 0x30 */
- 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, /* 0 */
- 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, /* 1 */
- 0x62, 0x51, 0x49, 0x49, 0x46, 0x00, /* 2 */
- 0x21, 0x41, 0x45, 0x4B, 0x31, 0x00, /* 3 */
- 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, /* 4 */
- 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, /* 5 */
- 0x3C, 0x4A, 0x49, 0x49, 0x30, 0x00, /* 6 */
- 0x01, 0x71, 0x09, 0x05, 0x03, 0x00, /* 7 */
-/* 0x38 */
- 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, /* 8 */
- 0x06, 0x49, 0x49, 0x29, 0x1E, 0x00, /* 9 */
- 0x00, 0x36, 0x36, 0x00, 0x00, 0x00, /* : */
- 0x00, 0x56, 0x36, 0x00, 0x00, 0x00, /* ; */
- 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, /* < */
- 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, /* = */
- 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, /* > */
- 0x02, 0x01, 0x51, 0x09, 0x06, 0x00, /* ? */
-/* 0x40 */
- 0x32, 0x49, 0x79, 0x41, 0x3E, 0x00, /* @ */
- 0x7E, 0x09, 0x09, 0x09, 0x7E, 0x00, /* A */
- 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, /* B */
- 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, /* C */
- 0x7F, 0x41, 0x41, 0x22, 0x1C, 0x00, /* D */
- 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, /* E */
- 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, /* F */
- 0x3E, 0x41, 0x49, 0x49, 0x7A, 0x00, /* G */
-/* 0x48 */
- 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, /* H */
- 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, /* I */
- 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, /* J */
- 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, /* K */
- 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, /* L */
- 0x7F, 0x02, 0x0C, 0x02, 0x7F, 0x00, /* M */
- 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, /* N */
- 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, /* O */
-/* 0x50 */
- 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, /* P */
- 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, /* Q */
- 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, /* R */
- 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, /* S */
- 0x01, 0x01, 0x7F, 0x01, 0x01, 0x00, /* T */
- 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, /* U */
- 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, /* V */
- 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, /* W */
-/* 0x58 */
- 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, /* X */
- 0x07, 0x08, 0x70, 0x08, 0x07, 0x00, /* Y */
- 0x61, 0x51, 0x49, 0x45, 0x43, 0x00, /* Z */
- 0x00, 0x7F, 0x41, 0x41, 0x00, 0x00, /* [ */
- 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, /* \ */
- 0x00, 0x41, 0x41, 0x7F, 0x00, 0x00, /* ] */
- 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, /* ^ */
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, /* _ */
-/* 0x60 */
- 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, /* ` */
- 0x00, 0x74, 0x54, 0x54, 0x78, 0x00, /* a */
- 0x7F, 0x44, 0x44, 0x44, 0x38, 0x00, /* b */
- 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, /* c */
- 0x38, 0x44, 0x44, 0x44, 0x7F, 0x00, /* d */
- 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, /* e */
- 0x08, 0x7E, 0x09, 0x01, 0x02, 0x00, /* f */
- 0x08, 0x54, 0x54, 0x54, 0x3C, 0x00, /* g */
-/* 0x68 */
- 0x7F, 0x04, 0x04, 0x04, 0x78, 0x00, /* h */
- 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, /* i */
- 0x20, 0x40, 0x44, 0x3D, 0x00, 0x00, /* j */
- 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, /* k */
- 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, /* l */
- 0x7C, 0x04, 0x18, 0x04, 0x78, 0x00, /* m */
- 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, /* n */
- 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, /* o */
-/* 0x70 */
- 0x7C, 0x14, 0x14, 0x14, 0x08, 0x00, /* p */
- 0x08, 0x14, 0x14, 0x14, 0x7C, 0x00, /* q */
- 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, /* r */
- 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, /* s */
- 0x04, 0x3F, 0x44, 0x40, 0x20, 0x00, /* t */
- 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, /* u */
- 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, /* v */
- 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, /* w */
-/* 0x78 */
- 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, /* x */
- 0x0C, 0x50, 0x50, 0x50, 0x3C, 0x00, /* y */
- 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, /* z */
- 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, /* { */
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, /* | */
- 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, /* } */
- 0x02, 0x01, 0x02, 0x01, 0x00, 0x00, /* ~ */
- 0x70, 0x48, 0x44, 0x48, 0x70, 0x00, /* \7f */
-/* 0x80 */
- 0x38, 0xC4, 0xC4, 0x44, 0x28, 0x00, /* \80 */
- 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x00, /* \81 */
- 0x38, 0x54, 0x54, 0x55, 0x19, 0x00, /* \82 */
- 0x22, 0x55, 0x55, 0x55, 0x78, 0x00, /* \83 */
- 0x20, 0x55, 0x54, 0x54, 0x79, 0x00, /* \84 */
- 0x21, 0x75, 0x55, 0x54, 0x78, 0x00, /* \85 */
- 0x20, 0x74, 0x57, 0x54, 0x78, 0x00, /* \86 */
- 0x08, 0x54, 0x54, 0x74, 0x14, 0x00, /* \87 */
-/* 0x88 */
- 0x3A, 0x55, 0x55, 0x55, 0x1A, 0x00, /* \88 */
- 0x39, 0x54, 0x54, 0x55, 0x18, 0x00, /* \89 */
- 0x39, 0x55, 0x55, 0x54, 0x18, 0x00, /* \8a */
- 0x00, 0x45, 0x7C, 0x41, 0x00, 0x00, /* \8b */
- 0x02, 0x45, 0x7D, 0x42, 0x00, 0x00, /* \8c */
- 0x01, 0x45, 0x7D, 0x40, 0x00, 0x00, /* \8d */
- 0x79, 0x14, 0x12, 0x14, 0x79, 0x00, /* \8e */
- 0x70, 0x2B, 0x2B, 0x2B, 0x70, 0x00, /* \8f */
-/* 0x90 */
- 0x7C, 0x54, 0x55, 0x55, 0x45, 0x00, /* \90 */
- 0x20, 0x54, 0x38, 0x54, 0x48, 0x00, /* \91 */
- 0x7E, 0x09, 0x7F, 0x49, 0x49, 0x00, /* \92 */
- 0x32, 0x49, 0x49, 0x49, 0x32, 0x00, /* \93 */
- 0x32, 0x48, 0x48, 0x48, 0x32, 0x00, /* \94 */
- 0x32, 0x4A, 0x4A, 0x48, 0x30, 0x00, /* \95 */
- 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x00, /* \96 */
- 0x3A, 0x42, 0x42, 0x20, 0x78, 0x00, /* \97 */
-/* 0x98 */
- 0x0D, 0x50, 0x50, 0x50, 0x3D, 0x00, /* \98 */
- 0x19, 0x24, 0x42, 0x24, 0x19, 0x00, /* \99 */
- 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x00, /* \9a */
- 0x18, 0x24, 0x7E, 0x24, 0x24, 0x00, /* \9b */
- 0x28, 0x5E, 0x29, 0x42, 0x20, 0x00, /* \9c */
- 0x09, 0x2A, 0x7C, 0x2A, 0x09, 0x00, /* \9d */
- 0x7F, 0x05, 0x15, 0x3D, 0x52, 0x00, /* \9e */
- 0x20, 0x48, 0x3E, 0x09, 0x02, 0x00, /* \9f */
-/* 0xa0 */
- 0x20, 0x74, 0x55, 0x55, 0x79, 0x00, /* */
- 0x01, 0x45, 0x7D, 0x40, 0x00, 0x00, /* ¡ */
- 0x30, 0x48, 0x4A, 0x4A, 0x32, 0x00, /* ¢ */
- 0x38, 0x40, 0x42, 0x22, 0x7A, 0x00, /* £ */
- 0x7A, 0x12, 0x0A, 0x0A, 0x72, 0x00, /* ¤ */
- 0x7D, 0x09, 0x11, 0x21, 0x7D, 0x00, /* ¥ */
- 0x02, 0x15, 0x15, 0x12, 0x04, 0x00, /* ¦ */
- 0x02, 0x15, 0x15, 0x15, 0x02, 0x00, /* § */
-/* 0xa8 */
- 0x30, 0x48, 0x45, 0x40, 0x20, 0x00, /* ¨ */
- 0x00, 0x38, 0x08, 0x08, 0x08, 0x00, /* © */
- 0x00, 0x08, 0x08, 0x08, 0x38, 0x00, /* ª */
- 0x0B, 0x04, 0x6A, 0x55, 0x48, 0x00, /* « */
- 0x0B, 0x24, 0x32, 0x79, 0x20, 0x00, /* ¬ */
- 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, /* */
- 0x08, 0x14, 0x2A, 0x14, 0x22, 0x00, /* ® */
- 0x22, 0x14, 0x2A, 0x14, 0x08, 0x00, /* ¯ */
-/* 0xb0 */
- 0x2A, 0x55, 0x00, 0x2A, 0x55, 0x00, /* ° */
- 0x2A, 0x55, 0x2A, 0x55, 0x2A, 0x55, /* ± */
- 0x55, 0x2A, 0x7F, 0x55, 0x2A, 0x7F, /* ² */
- 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, /* ³ */
- 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, /* ´ */
- 0x14, 0x14, 0xFF, 0x00, 0x00, 0x00, /* µ */
- 0x08, 0xFF, 0x00, 0xFF, 0x00, 0x00, /* ¶ */
- 0x08, 0xF8, 0x08, 0xF8, 0x00, 0x00, /* · */
-/* 0xb8 */
- 0x14, 0x14, 0xFC, 0x00, 0x00, 0x00, /* ¸ */
- 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, /* ¹ */
- 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, /* º */
- 0x14, 0xF4, 0x04, 0xFC, 0x00, 0x00, /* » */
- 0x14, 0x17, 0x10, 0x1F, 0x00, 0x00, /* ¼ */
- 0x08, 0x0F, 0x08, 0x0F, 0x00, 0x00, /* ½ */
- 0x14, 0x14, 0x1F, 0x00, 0x00, 0x00, /* ¾ */
- 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, /* ¿ */
-/* 0xc0 */
- 0x00, 0x00, 0x0F, 0x08, 0x08, 0x08, /* À */
- 0x08, 0x08, 0x0F, 0x08, 0x08, 0x08, /* Á */
- 0x08, 0x08, 0xF8, 0x08, 0x08, 0x08, /* Â */
- 0x00, 0x00, 0xFF, 0x08, 0x08, 0x08, /* Ã */
- 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* Ä */
- 0x08, 0x08, 0xFF, 0x08, 0x08, 0x08, /* Å */
- 0x00, 0x00, 0xFF, 0x14, 0x14, 0x14, /* Æ */
- 0x00, 0xFF, 0x00, 0xFF, 0x08, 0x08, /* Ç */
-/* 0xc8 */
- 0x00, 0x1F, 0x10, 0x17, 0x14, 0x14, /* È */
- 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, /* É */
- 0x28, 0x2F, 0x20, 0x2F, 0x28, 0x28, /* Ê */
- 0x14, 0xF4, 0x04, 0xF4, 0x14, 0x14, /* Ë */
- 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, /* Ì */
- 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, /* Í */
- 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, /* Î */
- 0x14, 0x14, 0xF7, 0x14, 0x14, 0x14, /* Ï */
-/* 0xd0 */
- 0x08, 0x0F, 0x08, 0x0F, 0x08, 0x08, /* Ð */
- 0x14, 0x14, 0xF4, 0x14, 0x14, 0x14, /* Ñ */
- 0x08, 0x08, 0xF8, 0x08, 0x08, 0x08, /* Ò */
- 0x08, 0x0F, 0x08, 0x0F, 0x08, 0x08, /* Ó */
- 0x00, 0x00, 0x1F, 0x14, 0x14, 0x14, /* Ô */
- 0x00, 0x00, 0xFC, 0x14, 0x14, 0x14, /* Õ */
- 0x00, 0xF8, 0x08, 0xF8, 0x08, 0x08, /* Ö */
- 0x08, 0xFF, 0x08, 0xFF, 0x08, 0x08, /* × */
-/* 0xd8 */
- 0x14, 0x14, 0xFF, 0x14, 0x14, 0x14, /* Ø */
- 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, /* Ù */
- 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, /* Ú */
- 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, /* Û */
- 0x70, 0x70, 0x70, 0x70, 0x70, 0x00, /* Ü */
- 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, /* Ý */
- 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x00, /* Þ */
- 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, /* ß */
-/* 0xe0 */
- 0x30, 0x48, 0x48, 0x30, 0x48, 0x00, /* à */
- 0x7E, 0x11, 0x25, 0x25, 0x1A, 0x00, /* á */
- 0x7E, 0x02, 0x02, 0x02, 0x06, 0x00, /* â */
- 0x04, 0x7C, 0x04, 0x7C, 0x04, 0x00, /* ã */
- 0x41, 0x63, 0x55, 0x49, 0x63, 0x00, /* ä */
- 0x3C, 0x42, 0x4A, 0x4A, 0x31, 0x00, /* å */
- 0x40, 0x7C, 0x20, 0x20, 0x1C, 0x00, /* æ */
- 0x08, 0x04, 0x7C, 0x08, 0x04, 0x00, /* ç */
-/* 0xe8 */
- 0x49, 0x55, 0x77, 0x55, 0x49, 0x00, /* è */
- 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x00, /* é */
- 0x4C, 0x72, 0x02, 0x72, 0x4C, 0x00, /* ê */
- 0x30, 0x4A, 0x45, 0x49, 0x31, 0x00, /* ë */
- 0x18, 0x24, 0x18, 0x24, 0x18, 0x00, /* ì */
- 0x5C, 0x72, 0x2A, 0x27, 0x1D, 0x00, /* í */
- 0x1C, 0x2A, 0x49, 0x49, 0x00, 0x00, /* î */
- 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x00, /* ï */
-/* 0xf0 */
- 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x00, /* ð */
- 0x24, 0x24, 0x2E, 0x24, 0x24, 0x00, /* ñ */
- 0x40, 0x51, 0x4A, 0x44, 0x00, 0x00, /* ò */
- 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, /* ó */
- 0x00, 0x00, 0xFE, 0x01, 0x02, 0x00, /* ô */
- 0x20, 0x40, 0x3F, 0x00, 0x00, 0x00, /* õ */
- 0x08, 0x08, 0x2A, 0x08, 0x08, 0x00, /* ö */
- 0x24, 0x12, 0x24, 0x12, 0x00, 0x00, /* ÷ */
-/* 0xf8 */
- 0x06, 0x09, 0x09, 0x09, 0x06, 0x00, /* ø */
- 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, /* ù */
- 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, /* ú */
- 0x10, 0x30, 0x7F, 0x01, 0x01, 0x00, /* û */
- 0x01, 0x0E, 0x01, 0x01, 0x0E, 0x00, /* ü */
- 0x0A, 0x09, 0x0D, 0x0A, 0x00, 0x00, /* ý */
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x00, /* þ */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* ÿ */
-};
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \version $Id$
- *
- * \author Stefano Fedrigo <aleph@develer.com>
- *
- * \brief Font 8x6 IBM-PC 8bit
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.6 2005/04/11 19:10:28 bernie
- *#* Include top-level headers from cfg/ subdir.
- *#*
- *#* Revision 1.5 2005/03/01 23:26:45 bernie
- *#* Use new CPU-neutral program-memory API.
- *#*
- *#* Revision 1.4 2004/12/31 16:42:55 bernie
- *#* Sanitize for non-Harvard processors.
- *#*
- *#* Revision 1.3 2004/08/25 14:12:09 rasky
- *#* Aggiornato il comment block dei log RCS
- *#*
- *#* Revision 1.2 2004/06/03 11:27:09 bernie
- *#* Add dual-license information.
- *#*
- *#* Revision 1.1 2004/05/23 15:43:16 bernie
- *#* Import mware modules.
- *#*
- *#* Revision 1.2 2004/03/24 15:48:53 bernie
- *#* Remove Copyright messages from Doxygen output
- *#*
- *#* Revision 1.1 2004/01/13 12:15:28 aleph
- *#* Move font table in program memory; add font.h
- *#*
- *#*/
-#ifndef MWARE_FONT_H
-#define MWARE_FONT_H
-
-#include <cfg/compiler.h> /* uint8_t */
-#include <mware/pgm.h> /* PROGMEM */
-
-/*!
- * \name Font size (in pixel)
- * \{
- */
-#define FONT_WIDTH 6
-#define FONT_HEIGHT 8
-/* \} */
-
-/*! Font table */
-extern const PROGMEM uint8_t font[256 * FONT_WIDTH];
-
-#endif /* MWARE_FONT_H */
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \version $Id$
- *
- * \author Bernardo Innocenti <bernie@develer.com>
- * \author Stefano Fedrigo <aleph@develer.com>
- *
- * \brief General pourpose graphics routines
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.14 2005/11/04 16:20:02 bernie
- *#* Fix reference to README.devlib in header.
- *#*
- *#* Revision 1.13 2005/04/11 19:10:28 bernie
- *#* Include top-level headers from cfg/ subdir.
- *#*
- *#* Revision 1.12 2005/03/01 23:26:45 bernie
- *#* Use new CPU-neutral program-memory API.
- *#*
- *#* Revision 1.11 2004/12/08 08:06:16 bernie
- *#* Remove done todo.
- *#*
- *#* Revision 1.10 2004/11/01 15:14:07 bernie
- *#* Update to current coding conventions.
- *#*
- *#* Revision 1.9 2004/10/21 10:58:33 bernie
- *#* Add a TODO item.
- *#*
- *#* Revision 1.8 2004/09/20 03:29:22 bernie
- *#* Relax assertion.
- *#*
- *#* Revision 1.7 2004/09/14 21:01:08 bernie
- *#* Rename rectangle drawing functions; Unify filled/cleared implementations.
- *#*
- *#* Revision 1.4 2004/08/24 16:53:10 bernie
- *#* Use new-style config macros.
- *#*
- *#* Revision 1.3 2004/08/04 03:16:59 bernie
- *#* Switch to new DevLib CONFIG_ convention.
- *#*
- *#* Revision 1.2 2004/06/03 11:27:09 bernie
- *#* Add dual-license information.
- *#*/
-
-#include "gfx.h"
-#include <cfg/config.h> /* CONFIG_GFX_CLIPPING */
-#include <cfg/debug.h>
-#include <cfg/cpu.h> /* CPU_HARVARD */
-#include <cfg/macros.h> /* SWAP() */
-
-#include <string.h>
-
-
-/*!
- * Plot a point in bitmap \a bm.
- *
- * \note bm is evaluated twice
- */
-#define BM_PLOT(bm, x, y) \
- ( *((bm)->raster + ((y) / 8) * (bm)->width + (x)) |= 1 << ((y) % 8) )
-
-/*!
- * Clear a point in bitmap \a bm.
- *
- * \note bm is evaluated twice
- */
-#define BM_CLEAR(bm, x, y) \
- ( *((bm)->raster + ((y) / 8) * (bm)->width + (x)) &= ~(1 << ((y) % 8)) )
-
-/*!
- * Set a point in bitmap \a bm to the specified color.
- *
- * \note bm is evaluated twice
- * \note This macro is somewhat slower than BM_PLOT and BM_CLEAR.
- * \see BM_PLOT BM_CLEAR
- */
-#define BM_DRAWPIXEL(bm, x, y, fg_pen) \
- do { \
- uint8_t *p = (bm)->raster + ((y) / 8) * (bm)->width + (x); \
- uint8_t mask = 1 << ((y) % 8); \
- *p = (*p & ~mask) | ((fg_pen) ? mask : 0); \
- } while (0)
-
-/*!
- * Initialize a Bitmap structure with the provided parameters.
- *
- * \note The pen position is reset to the origin.
- */
-void gfx_bitmapInit(Bitmap *bm, uint8_t *raster, coord_t w, coord_t h)
-{
- bm->raster = raster;
- bm->width = w;
- bm->height = h;
- bm->penX = 0;
- bm->penY = 0;
-}
-
-
-/*!
- * Clear the whole bitmap surface to the background color.
- *
- * \note This function does \b not update the current pen position
- */
-void gfx_bitmapClear(Bitmap *bm)
-{
- memset(bm->raster, 0, (bm->width * bm->height) / 8);
-}
-
-
-#if CPU_HARVARD
-
-#include <avr/pgmspace.h> /* FIXME: memcpy_P() */
-
-/*!
- * Copy a raster picture located in program memory in the bitmap.
- * The size of the raster to copy *must* be the same of the raster bitmap.
- *
- * \note This function does \b not update the current pen position
- */
-void gfx_blit_P(Bitmap *bm, const pgm_uint8_t *raster)
-{
- memcpy_P(bm->raster, raster, (bm->height / 8) * bm->width);
-}
-#endif /* CPU_HARVARD */
-
-
-/*!
- * Draw a line on the bitmap \a bm using the specified start and end
- * coordinates.
- *
- * \note This function does \b not update the current pen position.
- *
- * \todo Optimize for vertical and horiziontal lines.
- */
-void gfx_line(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
-{
- int x, y, e, len, adx, ady, signx, signy;
-
-
-#if CONFIG_GFX_CLIPPING
- /* FIXME: broken */
-
- #define XMIN 0
- #define YMIN 0
- #define XMAX (bm->width - 1)
- #define YMAX (bm->height - 1)
-
- /* Clipping */
- if (x1 < XMIN)
- {
- y1 = y2 - ((x2 - XMIN) * (y2 - y1)) / (x2 - x1);
- x1 = XMIN;
- }
- if (y1 < YMIN)
- {
- x1 = x2 - ((y2 - YMIN) * (x2 - x1)) / (y2 - y1);
- y1 = YMIN;
- }
- if (x2 < XMIN)
- {
- y2 = y2 - ((XMIN - x1) * (y2 - y1)) / (x2 - x1);
- x2 = XMIN;
- }
- if (y2 < YMIN)
- {
- x2 = x2 - ((YMIN - y1) * (x2 - x1)) / (y2 - y1);
- y2 = YMIN;
- }
-
- if (x1 > XMAX)
- {
- y1 = ((x2 - XMAX) * (y2 - y1)) / (x2 - x1);
- x1 = XMAX;
- }
- if (y1 > YMAX)
- {
- x1 = ((y2 - YMAX) * (x2 - x1)) / (y2 - y1);
- y1 = YMAX;
- }
- if (x2 > XMAX)
- {
- y2 = ((XMAX - x1) * (y2 - y1)) / (x2 - x1);
- x2 = XMAX;
- }
- if (y2 > YMAX)
- {
- x2 = ((YMAX - y1) * (x2 - x1)) / (y2 - y1);
- y2 = YMAX;
- }
-
- #undef XMIN
- #undef YMIN
- #undef XMAX
- #undef YMAX
-
-#endif /* CONFIG_GFX_CLIPPING */
-
-
- if (x2 > x1)
- {
- /* left to right */
- signx = +1;
- adx = x2 - x1;
- }
- else
- {
- /* right to left */
- signx = -1;
- adx = x1 - x2;
- }
-
- if (y2 > y1)
- {
- /* top to bottom */
- signy = +1;
- ady = y2 - y1;
- }
- else
- {
- /* bottom to top */
- signy = -1;
- ady = y1 - y2;
- }
-
- x = x1;
- y = y1;
-
- if (adx > ady)
- {
- /* X-major line (octants 1/4/5/8) */
-
- len = adx;
- e = -adx;
- while (len--)
- {
- /* Sanity check */
- if ((x >= 0) && (x < bm->width) && (y >= 0) && (y < bm->height))
- BM_PLOT(bm, x, y);
- x += signx;
- e += ady;
- if (e >= 0)
- {
- y += signy;
- e -= adx;
- }
- }
- }
- else
- {
- /* Y-major line (octants 2/3/6/7) */
-
- len = ady;
- e = -ady;
- while (len--)
- {
- /* Sanity check */
- if ((x >= 0) && (x < bm->width) && (y >= 0) && (y < bm->height))
- BM_PLOT(bm, x, y);
- y += signy;
- e += adx;
- if (e >= 0)
- {
- x += signx;
- e -= ady;
- }
- }
- }
-}
-
-
-/*!
- * Move the current pen position to the specified coordinates.
- */
-void gfx_moveTo(Bitmap *bm, coord_t x, coord_t y)
-{
- bm->penX = x;
- bm->penY = y;
-}
-
-/*!
- * Draw a line from the current pen position to the new coordinates.
- *
- * \note This function moves the current pen position to the
- * new coordinates.
- */
-void gfx_lineTo(Bitmap *bm, coord_t x, coord_t y)
-{
- gfx_line(bm, bm->penX, bm->penY, x, y);
- gfx_moveTo(bm, x, y);
-}
-
-
-/*!
- * Draw an the outline of an hollow rectangle.
- *
- * \note The bottom-right border of the rectangle is not drawn.
- * \note This function does \b not update the current pen position
- */
-void gfx_rectDraw(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
-{
- /* Sort coords (needed for correct bottom-right semantics) */
- if (x1 > x2) SWAP(x1, x2);
- if (y1 > y2) SWAP(y1, y2);
-
- /* Draw rectangle */
- gfx_line(bm, x1, y1, x2-1, y1);
- gfx_line(bm, x2-1, y1, x2-1, y2-1);
- gfx_line(bm, x2-1, y2-1, x1, y2-1);
- gfx_line(bm, x1, y2-1, x1, y1);
-}
-
-
-/*!
- * Fill a rectangular area with \a color.
- *
- * \note The bottom-right border of the rectangle is not drawn.
- *
- * \note This function does \b not update the current pen position
- */
-void gfx_rectFillC(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t color)
-{
- coord_t x, y;
-
- /* Sort coords */
- if (x1 > x2) SWAP(x1, x2);
- if (y1 > y2) SWAP(y1, y2);
-
- /* Clip rect to bitmap bounds */
- if (x1 < 0) x1 = 0;
- if (x2 < 0) x2 = 0;
- if (x1 > bm->width) x1 = bm->width;
- if (x2 > bm->width) x2 = bm->width;
- if (y1 < 0) y1 = 0;
- if (y2 < 0) y2 = 0;
- if (y1 > bm->width) y1 = bm->width;
- if (y2 > bm->width) y2 = bm->width;
-
- /*
- * Draw rectangle
- * NOTE: Code paths are duplicated for efficiency
- */
- if (color) /* fill */
- {
- for (x = x1; x < x2; x++)
- for (y = y1; y < y2; y++)
- BM_PLOT(bm, x, y);
- }
- else /* clear */
- {
- for (x = x1; x < x2; x++)
- for (y = y1; y < y2; y++)
- BM_CLEAR(bm, x, y);
- }
-}
-
-
-/*!
- * Draw a filled rectangle.
- *
- * \note The bottom-right border of the rectangle is not drawn.
- *
- * \note This function does \b not update the current pen position
- */
-void gfx_rectFill(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
-{
- gfx_rectFillC(bm, x1, y1, x2, y2, 0xFF);
-}
-
-
-/*!
- * Clear a rectangular area.
- *
- * \note The bottom-right border of the rectangle is not drawn.
- *
- * \note This function does \b not update the current pen position
- */
-void gfx_rectClear(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
-{
- gfx_rectFillC(bm, x1, y1, x2, y2, 0x00);
-}
-
-
-/*!
- * Imposta un rettangolo di clipping per il disegno nella bitmap.
- */
-void gfx_setClipRect(Bitmap *bm, coord_t minx, coord_t miny, coord_t maxx, coord_t maxy)
-{
- ASSERT(minx < maxx);
- ASSERT(miny < maxy);
- ASSERT(miny >= 0);
- ASSERT(minx >= 0);
- ASSERT(maxx <= bm->width);
- ASSERT(maxy <= bm->height);
-
- bm->cr.xmin = minx;
- bm->cr.ymin = miny;
- bm->cr.xmax = maxx;
- bm->cr.ymax = maxy;
-
-/* DB(kprintf("cr.xmin = %d, cr.ymin = %d, cr.xmax = %d, cr.ymax = %d\n",
- bm->cr.xMin, bm->cr.ymin, bm->cr.xmax, bm->cr.ymax);)
-*/
-}
-
-
-#if CONFIG_GFX_VCOORDS
-/*!
- * Imposta gli estremi del sistema di coordinate cartesiane rispetto
- * al rettangolo di clipping della bitmap.
- */
-void gfx_setViewRect(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2)
-{
- ASSERT(x1 != x2);
- ASSERT(y1 != y2);
-
- bm->orgX = x1;
- bm->orgY = y1;
- bm->scaleX = (vcoord_t)(bm->cr.xmax - bm->cr.xmin - 1) / (vcoord_t)(x2 - x1);
- bm->scaleY = (vcoord_t)(bm->cr.ymax - bm->cr.ymin - 1) / (vcoord_t)(y2 - y1);
-
-/* DB(kprintf("orgX = %f, orgY = %f, scaleX = %f, scaleY = %f\n",
- bm->orgX, bm->orgY, bm->scaleX, bm->scaleY);)
-*/
-}
-
-
-/*!
- * Transform a coordinate from the current reference system to a
- * pixel offset within the bitmap.
- */
-coord_t gfx_transformX(Bitmap *bm, vcoord_t x)
-{
- return bm->cr.xmin + (coord_t)((x - bm->orgX) * bm->scaleX);
-}
-
-/*!
- * Transform a coordinate from the current reference system to a
- * pixel offset within the bitmap.
- */
-coord_t gfx_transformY(Bitmap *bm, vcoord_t y)
-{
- return bm->cr.ymin + (coord_t)((y - bm->orgY) * bm->scaleY);
-}
-
-
-/*!
- * Draw a line from (x1;y1) to (x2;y2).
- */
-void gfx_vline(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2)
-{
- gfx_line(bm,
- gfx_transformX(bm, x1), gfx_transformY(bm, y1),
- gfx_transformY(bm, x2), gfx_transformY(bm, y2));
-}
-#endif /* CONFIG_GFX_VCOORDS */
+++ /dev/null
-/*!
- * \file
- * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
- * This file is part of DevLib - See README.devlib for information.
- *
- * \version $Id$
- *
- * \author Bernardo Innocenti <bernie@develer.com>
- * \author Stefano Fedrigo <aleph@develer.com>
- *
- * \brief General pourpose graphics routines
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.12 2005/11/04 16:20:02 bernie
- *#* Fix reference to README.devlib in header.
- *#*
- *#* Revision 1.11 2005/04/11 19:10:28 bernie
- *#* Include top-level headers from cfg/ subdir.
- *#*
- *#* Revision 1.10 2005/03/01 23:26:45 bernie
- *#* Use new CPU-neutral program-memory API.
- *#*
- *#* Revision 1.9 2005/01/20 18:46:31 aleph
- *#* Fix progmem includes.
- *#*
- *#* Revision 1.8 2004/11/01 15:14:07 bernie
- *#* Update to current coding conventions.
- *#*
- *#* Revision 1.7 2004/09/20 03:29:06 bernie
- *#* Conditionalize AVR-specific code.
- *#*
- *#* Revision 1.6 2004/09/14 21:01:08 bernie
- *#* Rename rectangle drawing functions; Unify filled/cleared implementations.
- *#*
- *#* Revision 1.4 2004/08/10 07:00:16 bernie
- *#* Add missing header.
- *#*
- *#* Revision 1.3 2004/08/04 03:16:59 bernie
- *#* Switch to new DevLib CONFIG_ convention.
- *#*
- *#* Revision 1.2 2004/06/03 11:27:09 bernie
- *#* Add dual-license information.
- *#*
- *#* Revision 1.1 2004/05/23 15:43:16 bernie
- *#* Import mware modules.
- *#*/
-
-#ifndef MWARE_GFX_H
-#define MWARE_GFX_H
-
-#include <cfg/config.h>
-#include <cfg/compiler.h>
-#include <cfg/cpu.h>
-
-
-/*! Common type for coordinates expressed in pixel units */
-typedef int coord_t;
-
-#if CONFIG_GFX_VCOORDS
-/*! Common type for coordinates expressed in logical units */
-typedef float vcoord_t;
-#endif /* CONFIG_GFX_VCOORDS */
-
-
-typedef struct Rect { coord_t xmin, ymin, xmax, ymax; } Rect;
-
-
-/*!
- * Control structure to draw in a bitmap
- */
-typedef struct Bitmap
-{
- uint8_t *raster; /*!< Pointer to byte array to hold the data */
- coord_t width, height; /*!< Width/Height in pixels */
- coord_t penX, penY; /*!< Current pen position MoveTo()/LineTo() */
-
- Rect cr; /*!< Clip drawing inside this rectangle */
-
-#if CONFIG_GFX_VCOORDS
- /*!
- * \name Logical coordinate system
- * \{
- */
- vcoord_t orgX, orgY;
- vcoord_t scaleX, scaleY;
- /*\}*/
-#endif /* CONFIG_GFX_VCOORDS */
-
-} Bitmap;
-
-
-/* Function prototypes */
-extern void gfx_bitmapInit (Bitmap *bm, uint8_t *raster, coord_t w, coord_t h);
-extern void gfx_bitmapClear(Bitmap *bm);
-extern void gfx_line (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
-extern void gfx_rectDraw (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
-extern void gfx_rectFillC (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t color);
-extern void gfx_rectFill (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
-extern void gfx_rectClear (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2);
-extern void gfx_moveTo (Bitmap *bm, coord_t x, coord_t y);
-extern void gfx_lineTo (Bitmap *bm, coord_t x, coord_t y);
-extern void gfx_setClipRect(Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax);
-
-#if CPU_HARVARD
- #include <mware/pgm.h>
- extern void gfx_blit_P(Bitmap *bm, const pgm_uint8_t *raster);
-#endif
-
-
-#if CONFIG_GFX_VCOORDS
-extern void gfx_setViewRect(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2);
-extern coord_t gfx_transformX(Bitmap *bm, vcoord_t x);
-extern coord_t gfx_transformY(Bitmap *bm, vcoord_t y);
-extern void gfx_vline(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2);
-#endif /* CONFIG_GFX_VCOORDS */
-
-#endif /* MWARE_GFX_H */
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \brief Text graphic routines
- *
- * \version $Id$
- * \author Bernardo Innocenti <bernie@develer.com>
- * \author Stefano Fedrigo <aleph@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.13 2005/11/04 16:20:02 bernie
- *#* Fix reference to README.devlib in header.
- *#*
- *#* Revision 1.12 2005/04/11 19:10:28 bernie
- *#* Include top-level headers from cfg/ subdir.
- *#*
- *#* Revision 1.11 2005/01/20 18:46:31 aleph
- *#* Fix progmem includes.
- *#*
- *#* Revision 1.10 2005/01/08 09:20:12 bernie
- *#* Really make it work on both architectures.
- *#*
- *#* Revision 1.9 2004/12/31 16:44:29 bernie
- *#* Sanitize for non-Harvard processors.
- *#*
- *#* Revision 1.8 2004/11/16 21:16:28 bernie
- *#* Update to new naming scheme in mware/gfx.c.
- *#*
- *#* Revision 1.7 2004/09/20 03:28:28 bernie
- *#* Fix header.
- *#*
- *#* Revision 1.6 2004/09/14 20:57:15 bernie
- *#* Use debug.h instead of kdebug.h.
- *#*
- *#* Revision 1.5 2004/09/06 21:51:26 bernie
- *#* Extend interface to allow any algorithmic style.
- *#*
- *#* Revision 1.2 2004/06/03 11:27:09 bernie
- *#* Add dual-license information.
- *#*
- *#* Revision 1.1 2004/05/23 15:43:16 bernie
- *#* Import mware modules.
- *#*
- *#* Revision 1.17 2004/05/15 16:57:01 aleph
- *#* Fixes for non-DEBUG build
- *#*
- *#* Revision 1.16 2004/04/03 20:42:49 aleph
- *#* Add text_clear()
- *#*
- *#* Revision 1.15 2004/03/24 15:03:45 bernie
- *#* Use explicit include paths; clean Doxygen comments
- *#*
- *#* Revision 1.14 2004/03/19 16:52:28 bernie
- *#* Move printf() like functions from text.c to text_format.c and add PROGMEM versions.
- *#*
- *#* Revision 1.13 2004/03/17 18:23:32 bernie
- *#* Oops.
- *#*
- *#* Revision 1.12 2004/03/17 18:03:22 bernie
- *#* Make diagnostic message shorter
- *#*
- *#* Revision 1.11 2004/03/13 22:52:54 aleph
- *#* documentation fixes
- *#*/
-
-#include "gfx.h"
-#include "font.h"
-#include "text.h"
-
-#include <cfg/debug.h>
-
-
-/*!
- * Flags degli stili algoritmici
- *
- * La routine di rendering del testo e' in grado di applicare
- * delle semplici trasformazioni al font interno per generare
- * automaticamente degli stili predefiniti (bold, italic,
- * underline) a partire dal set di caratteri plain.
- */
-static uint8_t text_styles;
-
-/*! ANSI escape sequences flag: true for ESC state on */
-static bool ansi_mode = false;
-
-
-/*!
- * Move (imaginary) cursor to column and row specified.
- * Next text write will start a that row and col.
- */
-void text_moveto(struct Bitmap *bm, int row, int col)
-{
- ASSERT(col >= 0);
- ASSERT(col < bm->width / FONT_WIDTH);
- ASSERT(row >= 0);
- ASSERT(row < bm->height / FONT_HEIGHT);
-
- bm->penX = col * FONT_WIDTH;
- bm->penY = row * FONT_HEIGHT;
-}
-
-
-/*!
- * Move (imaginary) cursor to coordinates specified.
- */
-void text_setcoord(struct Bitmap *bm, int x, int y)
-{
- bm->penX = x;
- bm->penY = y;
-}
-
-
-/*!
- * Render char \a c on Bitmap \a bm
- */
-static int text_putglyph(char c, struct Bitmap *bm)
-{
- const uint8_t * PROGMEM glyph; /* font is in progmem */
- uint8_t glyph_width;
- uint8_t i;
- uint8_t *buf;
-
- /*
- * Il carattere da stampare viene usato come indice per prelevare
- * la prima colonna di dots del glyph all'interno del font.
- */
- glyph = font + (((unsigned char)c) * FONT_WIDTH);
- glyph_width = FONT_WIDTH;
-
- if (text_styles & STYLEF_CONDENSED)
- --glyph_width;
-
- if (text_styles & STYLEF_EXPANDED)
- glyph_width *= 2;
-
- /* The y coord is rounded at multiples of 8 for simplicity */
- bm->penY &= ~((coord_t)7);
-
- /* Check if glyph to write fits in the bitmap */
- if ((bm->penX < 0) || (bm->penX + glyph_width > bm->width) ||
- (bm->penY < 0) || (bm->penY + FONT_HEIGHT > bm->height))
- {
- DB(kprintf("bad coords x=%d y=%d\n", bm->penX, bm->penY);)
- return 0;
- }
-
- /* Locate position where to write in the raster */
- buf = bm->raster + bm->penY / 8 * bm->width + bm->penX;
-
- bm->penX += glyph_width;
-
- /* If some styles are set */
- if (text_styles)
- {
- uint8_t prev_dots = 0, italic_prev_dots = 0, new_dots;
- uint8_t dots;
-
- /* Per ogni colonna di dot del glyph... */
- for (i = 0; i < glyph_width; ++i)
- {
- dots = PGM_READ_CHAR(glyph);
-
- /* Advance to next column in glyph.
- * Expand: advances only once every two columns
- */
- if (!(text_styles & STYLEF_EXPANDED) || (i & 1))
- glyph++;
-
- /* Italic: get lower 4 dots from previous column */
- if (text_styles & STYLEF_ITALIC)
- {
- new_dots = dots;
- dots = (dots & 0xF0) | italic_prev_dots;
- italic_prev_dots = new_dots & 0x0F;
- }
-
- /* Bold: "or" pixels with the previous column */
- if (text_styles & STYLEF_BOLD)
- {
- new_dots = dots;
- dots |= prev_dots;
- prev_dots = new_dots;
- }
-
- /* Underlined: turn on base pixel */
- if (text_styles & STYLEF_UNDERLINE)
- dots |= 0x80;
-
- /* Inverted: invert pixels */
- if (text_styles & STYLEF_INVERT)
- dots = ~dots;
-
- /* Output dots */
- *buf++ = dots;
- }
- }
- else /* No style: fast vanilla copy of glyph to line buffer */
- while (glyph_width--)
- *buf++ = PGM_READ_CHAR(glyph++);
-
- return c;
-}
-
-
-/*!
- * Render char \c c, with (currently) limited ANSI escapes
- * emulation support and '\n' for newline.
- */
-int text_putchar(char c, struct Bitmap *bm)
-{
- /* Handle ANSI escape sequences */
- if (ansi_mode)
- {
- switch (c)
- {
- case ANSI_ESC_CLEARSCREEN:
- gfx_bitmapClear(bm);
- bm->penX = 0;
- bm->penY = 0;
- text_style(0, STYLEF_MASK);
- break;
- DB(default:
- kprintf("Unknown ANSI esc code: %x\n", c);)
- }
- ansi_mode = false;
- }
- else if (c == '\033') /* Enter ANSI ESC mode */
- {
- ansi_mode = true;
- }
- else if (c == '\n') /* Go one line down on a line-feed */
- {
- if (bm->penY + FONT_HEIGHT < bm->height)
- {
- bm->penY += FONT_HEIGHT;
- bm->penX = 0;
- }
- }
- else
- {
- text_putglyph(c, bm);
- }
- return c;
-}
-
-
-/*!
- * Clear the screen and reset cursor position
- */
-void text_clear(struct Bitmap *bmp)
-{
- text_putchar('\x1b', bmp);
- text_putchar('c', bmp);
-}
-
-
-void text_clearLine(struct Bitmap *bmp, int line)
-{
- gfx_rectClear(bmp, 0, line * FONT_HEIGHT, bmp->width, (line + 1) * FONT_HEIGHT);
-}
-
-
-/*!
- * Set/clear algorithmic font style bits.
- *
- * \param flags Style flags to set
- * \param mask Mask of flags to modify
- * \return Old style flags
- *
- * Examples:
- * Turn on bold, leave other styles alone
- * \code prt_style(STYLEF_BOLD, STYLEF_BOLD); \endcode
- *
- * Turn off bold and turn on italic, leave others as they are
- * \code prt_style(STYLEF_ITALIC, STYLEF_BOLD | STYLEF_ITALIC); \endcode
- *
- * Query current style without chaning it
- * \code style = prt_style(0, 0); \endcode
- *
- * Reset all styles (plain text)
- * \code prt_style(0, STYLE_MASK); \endcode
- */
-uint8_t text_style(uint8_t flags, uint8_t mask)
-{
- uint8_t old = text_styles;
- text_styles = (text_styles & ~mask) | flags;
- return old;
-}
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \brief Text graphic routines (interface)
- *
- * \author Bernardo Innocenti <bernie@develer.com>
- * \author Stefano Fedrigo <aleph@develer.com>
- * \version $Id$
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.11 2005/04/11 19:10:28 bernie
- *#* Include top-level headers from cfg/ subdir.
- *#*
- *#* Revision 1.10 2005/03/01 23:26:46 bernie
- *#* Use new CPU-neutral program-memory API.
- *#*
- *#* Revision 1.9 2004/12/31 16:44:29 bernie
- *#* Sanitize for non-Harvard processors.
- *#*
- *#* Revision 1.8 2004/10/03 20:43:37 bernie
- *#* Import changes from project_ks.
- *#*
- *#* Revision 1.7 2004/09/20 03:28:49 bernie
- *#* Fix header; Conditionalize AVR-specific code.
- *#*
- *#* Revision 1.6 2004/09/14 20:57:30 bernie
- *#* Reformat.
- *#*
- *#* Revision 1.5 2004/09/06 21:51:26 bernie
- *#* Extend interface to allow any algorithmic style.
- *#*
- *#* Revision 1.4 2004/08/25 14:12:09 rasky
- *#* Aggiornato il comment block dei log RCS
- *#*
- *#* Revision 1.3 2004/08/05 18:46:44 bernie
- *#* Documentation improvements.
- *#*
- *#* Revision 1.2 2004/06/03 11:27:09 bernie
- *#* Add dual-license information.
- *#*
- *#*/
-
-#ifndef MWARE_TEXT_H
-#define MWARE_TEXT_H
-
-#include <cfg/compiler.h>
-#include <cfg/macros.h> /* BV() */
-#include <cfg/cpu.h> /* CPU_HARVARD */
-
-#include <stdarg.h>
-
-/*!
- * \name Style flags
- * \see text_style()
- * \{
- */
-#define STYLEF_BOLD BV(0)
-#define STYLEF_ITALIC BV(1)
-#define STYLEF_UNDERLINE BV(2)
-#define STYLEF_INVERT BV(3)
-#define STYLEF_EXPANDED BV(4)
-#define STYLEF_CONDENSED BV(5)
-#define STYLEF_STRIKEOUT BV(6) /*<! Not implemented */
-
-#define STYLEF_MASK \
- (STYLEF_BOLD | STYLEF_ITALIC | STYLEF_UNDERLINE | \
- STYLEF_EXPANDED | STYLEF_CONDENSED | STYLEF_INVERT)
-/*\}*/
-
-/*!
- * \name Formatting flags for text rendering
- * \see text_xprintf()
- * \{
- */
-#define TEXT_NORMAL 0 /*!< Normal mode */
-#define TEXT_FILL BV(7) /*!< Fill rest of line with spaces */
-#define TEXT_CENTER BV(8) /*!< Center string in line */
-#define TEXT_RIGHT BV(9) /*!< Right aligned */
-/*\}*/
-
-/*! Escape sequences codes */
-#define ANSI_ESC_CLEARSCREEN 'c'
-
-
-/* Fwd decl */
-struct Bitmap;
-
-/* Low-level text functions (mware/text.c) */
-void text_moveto(struct Bitmap *bm, int row, int col);
-void text_setcoord(struct Bitmap *bm, int x, int y);
-int text_putchar(char c, struct Bitmap *bm);
-uint8_t text_style(uint8_t flags, uint8_t mask);
-void text_clear(struct Bitmap *bm);
-void text_clearLine(struct Bitmap *bm, int line);
-
-/* Text formatting functions (mware/text_format.c) */
-int text_puts(const char *str, struct Bitmap *bm);
-int text_vprintf(struct Bitmap *bm, const char *fmt, va_list ap);
-int text_printf(struct Bitmap *bm, const char *fmt, ...) FORMAT(__printf__, 2, 3);
-int text_xprintf(struct Bitmap *bm, uint8_t row, uint8_t col, uint16_t mode, const char *fmt, ...) FORMAT(__printf__, 5, 6);
-int text_vwidthf(struct Bitmap *bm, const char * fmt, va_list ap);
-int text_widthf(struct Bitmap *bm, const char * fmt, ...) FORMAT(__printf__, 2, 3);
-
-/* Text formatting functions for program-memory strings (mware/text_format.c) */
-#if CPU_HARVARD
-#include <mware/pgm.h>
-int text_puts_P(const char * PROGMEM str, struct Bitmap *bm);
-int text_vprintf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap);
-int text_printf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...) FORMAT(__printf__, 2, 3);
-int text_xprintf_P(struct Bitmap *bm, uint8_t row, uint8_t col, uint16_t mode, const char * PROGMEM fmt, ...) FORMAT(__printf__, 5, 6);
-int text_vwidthf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap);
-int text_widthf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...);
-#endif /* CPU_HARVARD */
-
-#endif /* MWARE_TEXT_H */
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \brief printf-family routines for text output
- *
- * \version $Id$
- * \author Bernardo Innocenti <bernie@develer.com>
- * \author Stefano Fedrigo <aleph@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.10 2005/11/04 16:20:02 bernie
- *#* Fix reference to README.devlib in header.
- *#*
- *#* Revision 1.9 2004/12/31 17:47:45 bernie
- *#* Rename UNUSED() to UNUSED_ARG().
- *#*
- *#* Revision 1.8 2004/11/16 21:16:56 bernie
- *#* Update to new naming scheme in mware/gfx.c.
- *#*
- *#* Revision 1.7 2004/10/03 19:05:04 bernie
- *#* text_widthf(), text_vwidthf(): New functions.
- *#*
- *#* Revision 1.6 2004/09/14 20:59:04 bernie
- *#* text_xprintf(): Support all styles; Pixel-wise text centering.
- *#*
- *#* Revision 1.5 2004/08/25 14:12:09 rasky
- *#* Aggiornato il comment block dei log RCS
- *#*
- *#* Revision 1.4 2004/08/05 18:46:44 bernie
- *#* Documentation improvements.
- *#*
- *#* Revision 1.3 2004/08/03 15:57:18 aleph
- *#* Add include to fix warning for vsprintf()
- *#*
- *#* Revision 1.2 2004/06/03 11:27:09 bernie
- *#* Add dual-license information.
- *#*
- *#* Revision 1.1 2004/05/23 15:43:16 bernie
- *#* Import mware modules.
- *#*
- *#* Revision 1.2 2004/03/26 18:50:50 bernie
- *#* Move _PROGMEM stuff to compiler.h
- *#*
- *#* Revision 1.1 2004/03/19 16:52:28 bernie
- *#* Move printf() like functions from text.c to text_format.c and add PROGMEM versions.
- *#*
- *#*/
-
-#include "text.h"
-#include "formatwr.h" /* _formatted_write() */
-#include "font.h"
-#include "gfx.h"
-#include <stdio.h> /* vsprintf() */
-#include <stdarg.h>
-#include <string.h> /* strlen() */
-
-/*!
- * Render string \a str in Bitmap \a bm at current cursor position
- *
- * \note Text formatting functions are also available with an _P suffix
- * accepting the source string from program memory. This feature
- * is only available (and useful) on Harvard microprocessors such
- * as the AVR.
- *
- * \see text_putchar()
- */
-int PGM_FUNC(text_puts)(const char * PGM_ATTR str, struct Bitmap *bm)
-{
- char c;
-
- while ((c = PGM_READ_CHAR(str++)))
- text_putchar(c, bm);
-
- return 0;
-}
-
-
-/*!
- * vprintf()-like formatter to render text in a Bitmap.
- *
- * Perform vprintf()-like formatting on the \a fmt format string using the
- * variable-argument list \a ap.
- * Render the resulting string in Bitmap \a bm starting at the current
- * cursor position.
- *
- * \see text_puts() text_putchar() text_printf()
- */
-int PGM_FUNC(text_vprintf)(struct Bitmap *bm, const char * PGM_ATTR fmt, va_list ap)
-{
- return PGM_FUNC(_formatted_write)(fmt, (void (*)(char, void *))text_putchar, bm, ap);
-}
-
-/*!
- * printf()-like formatter to render text in a Bitmap.
- *
- * Perform printf()-like formatting on the \a fmt format string.
- * Render the resulting string in Bitmap \a bm starting at the
- * current cursor position.
- *
- * \see text_puts() text_putchar() text_vprintf()
- */
-int PGM_FUNC(text_printf)(struct Bitmap *bm, const char * PGM_ATTR fmt, ...)
-{
- int len;
-
- va_list ap;
- va_start(ap, fmt);
- len = PGM_FUNC(text_vprintf)(bm, fmt, ap);
- va_end(ap);
-
- return len;
-}
-
-
-/*!
- * Render the result of printf()-like formatting in a specified position
- * of a Bitmap.
- *
- * \param bm Bitmap where to render the text
- * \param row Starting row in character units (zero based)
- * \param col Starting column in character units (zero based)
- * \param style Formatting style to use. In addition to any STYLEF_
- * flag, it can be TEXT_NORMAL, TEXT_FILL, TEXT_INVERT or
- * TEXT_RIGHT, or a combination of these flags ORed together.
- * \param fmt String possibly containing printf() formatting commands.
- *
- * \see text_puts() text_putchar() text_printf() text_vprintf()
- * \see text_moveto() text_style()
- */
-int PGM_FUNC(text_xprintf)(struct Bitmap *bm,
- uint8_t row, uint8_t col, uint16_t style, const char * PGM_ATTR fmt, ...)
-{
- int len;
- uint8_t oldstyle = 0;
- va_list ap;
-
- va_start(ap, fmt);
-
- text_moveto(bm, row, col);
-
- if (style & STYLEF_MASK)
- oldstyle = text_style(style, STYLEF_MASK);
-
- if (style & (TEXT_CENTER | TEXT_RIGHT))
- {
- uint8_t pad = bm->width - PGM_FUNC(text_vwidthf)(bm, fmt, ap);
-
- if (style & TEXT_CENTER)
- pad /= 2;
-
- if (style & TEXT_FILL)
- gfx_rectFillC(bm, 0, row * FONT_HEIGHT, pad, (row + 1) * FONT_HEIGHT,
- (style & STYLEF_INVERT) ? 0xFF : 0x00);
-
- text_setcoord(bm, pad, row * FONT_HEIGHT);
- }
-
- len = PGM_FUNC(text_vprintf)(bm, fmt, ap);
- va_end(ap);
-
- if (style & TEXT_FILL)
- gfx_rectFillC(bm, bm->penX, row * FONT_HEIGHT, bm->width, (row + 1) * FONT_HEIGHT,
- (style & STYLEF_INVERT) ? 0xFF : 0x00);
-
- /* Restore old style */
- if (style & STYLEF_MASK)
- text_style(oldstyle, STYLEF_MASK);
-
- return len;
-}
-
-
-/*!
- * Return the width in pixels of a vprintf()-formatted string.
- */
-int PGM_FUNC(text_vwidthf)(
- UNUSED_ARG(struct Bitmap *, bm),
- const char * PGM_ATTR fmt,
- va_list ap)
-{
- return PGM_FUNC(vsprintf)(NULL, fmt, ap) * FONT_WIDTH;
-}
-
-
-/*!
- * Return the width in pixels of a printf()-formatted string.
- */
-int PGM_FUNC(text_widthf)(struct Bitmap *bm, const char * PGM_ATTR fmt, ...)
-{
- int width;
-
- va_list ap;
- va_start(ap, fmt);
- width = PGM_FUNC(text_vwidthf)(bm, fmt, ap);
- va_end(ap);
-
- return width;
-}