4 * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
5 * This file is part of DevLib - See README.devlib for information.
10 * \author Bernardo Innocenti <bernie@develer.com>
12 * \brief Custom control for graphics LCD emulation (interface)
17 *#* Revision 1.9 2006/07/19 12:56:25 bernie
18 *#* Convert to new Doxygen style.
20 *#* Revision 1.8 2006/05/28 12:17:57 bernie
21 *#* Drop almost all the Qt3 cruft.
23 *#* Revision 1.7 2006/04/27 05:43:08 bernie
24 *#* Fix naming conventions.
26 *#* Revision 1.6 2006/02/20 02:00:40 bernie
29 *#* Revision 1.5 2006/02/15 09:13:16 bernie
30 *#* Switch to BITMAP_FMT_PLANAR_V_LSB.
32 *#* Revision 1.4 2006/02/10 12:33:49 bernie
33 *#* Make emulator display a bit larger.
35 *#* Revision 1.3 2006/01/23 23:11:07 bernie
36 *#* Use RASTER_SIZE() to compute... err... the raster size.
38 *#* Revision 1.2 2006/01/17 02:30:43 bernie
39 *#* Fix QImage format.
41 *#* Revision 1.1 2006/01/16 03:51:35 bernie
42 *#* Add LCD Qt emulator.
45 #include "lcd_gfx_qt.h"
46 #include <emul/emul.h>
47 #include <cfg/debug.h>
48 #include <gfx/gfx.h> // CONFIG_BITMAP_FMT
50 #include <QtGui/QPainter>
51 #include <QtGui/QImage>
52 #include <QtGui/QSizePolicy>
53 #include <QtCore/QSize>
56 #define LCD_FG_COLOR 0x0, 0x0, 0x0
57 #define LCD_BG_COLOR 0xBB, 0xCC, 0xBB
60 EmulLCD::EmulLCD(QWidget *parent, const char *name) :
61 QFrame(parent, name, Qt::WRepaintNoErase | Qt::WResizeNoErase),
62 fg_color(LCD_FG_COLOR),
63 bg_color(LCD_BG_COLOR)
66 memset(raster, 0xAA, sizeof(raster));
69 setFrameStyle(QFrame::Panel | QFrame::Sunken);
70 frame_width = frameWidth();
80 QSizePolicy EmulLCD::sizePolicy() const
82 return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed, false);
86 QSize EmulLCD::sizeHint() const
89 WIDTH + frame_width * 2,
90 HEIGHT + frame_width * 2);
94 void EmulLCD::paintEvent(QPaintEvent * /*event*/)
97 QImage img(raster, WIDTH, HEIGHT, 1, NULL, 0, QImage::BigEndian);
99 p.setBackgroundMode(Qt::OpaqueMode);
101 p.setBackgroundColor(bg_color);
102 p.drawImage(frame_width, frame_width, img);
105 void EmulLCD::writeRaster(uint8_t *new_raster)
107 #if CONFIG_BITMAP_FMT == BITMAP_FMT_PLANAR_H_MSB
110 memcpy(raster, new_raster, sizeof(raster));
112 #elif CONFIG_BITMAP_FMT == BITMAP_FMT_PLANAR_V_LSB
115 for (int y = 0; y < HEIGHT; ++y)
117 for (int xbyte = 0; xbyte < WIDTH/8; ++xbyte)
120 for (int xbit = 0; xbit < 8; ++xbit)
121 v |= (new_raster[(xbyte * 8 + xbit) + (y / 8) * WIDTH] & (1 << (y%8)) )
122 ? 0 : (1 << (7 - xbit));
124 raster[y * ((WIDTH + 7) / 8) + xbyte] = v;
129 #error Unsupported bitmap format
138 #include <cfg/debug.h>
140 DECLARE_WALL(wall_before_raster, WALL_SIZE)
142 * Raster buffer to draw into.
144 * Bits in the bitmap bytes have vertical orientation,
145 * as required by the LCD driver.
147 static uint8_t lcd_raster[RASTER_SIZE(EmulLCD::WIDTH, EmulLCD::HEIGHT)];
148 DECLARE_WALL(wall_after_raster, WALL_SIZE)
150 /** Default LCD bitmap */
151 struct Bitmap lcd_bitmap;
153 /*extern "C"*/ void lcd_init(void)
155 //FIXME INIT_WALL(wall_before_raster);
156 //FIXME INIT_WALL(wall_after_raster);
157 gfx_bitmapInit(&lcd_bitmap, lcd_raster, EmulLCD::WIDTH, EmulLCD::HEIGHT);
158 gfx_bitmapClear(&lcd_bitmap);
161 /*extern "C"*/ void lcd_blitBitmap(Bitmap *bm)
163 //FIXME CHECK_WALL(wall_before_raster);
164 //FIXME CHECK_WALL(wall_after_raster);
165 emul->emulLCD->writeRaster(bm->raster);
168 #include "lcd_gfx_qt_moc.cpp"