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.3 2006/01/23 23:11:07 bernie
18 *#* Use RASTER_SIZE() to compute... err... the raster size.
20 *#* Revision 1.2 2006/01/17 02:30:43 bernie
21 *#* Fix QImage format.
23 *#* Revision 1.1 2006/01/16 03:51:35 bernie
24 *#* Add LCD Qt emulator.
28 #include "lcd_gfx_qt.h"
29 #include <emul/emul.h>
30 #include <cfg/debug.h>
34 #include <qsizepolicy.h>
38 #define LCD_FG_COLOR 0x0, 0x0, 0x0
39 #define LCD_BG_COLOR 0xBB, 0xCC, 0xBB
42 EmulLCD::EmulLCD(QWidget *parent, const char *name) :
43 QFrame(parent, name, WRepaintNoErase | WResizeNoErase),
44 fg_color(LCD_FG_COLOR),
45 bg_color(LCD_BG_COLOR)
48 memset(raster, 0xAA, sizeof(raster));
51 setFrameStyle(QFrame::Panel | QFrame::Sunken);
52 frame_width = frameWidth();
62 QSizePolicy EmulLCD::sizePolicy() const
64 return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed, false);
68 QSize EmulLCD::sizeHint() const
71 WIDTH + frame_width * 2,
72 HEIGHT + frame_width * 2);
76 void EmulLCD::drawContents(QPainter *p)
78 QImage img(raster, WIDTH, HEIGHT, 1, NULL, 0, QImage::BigEndian);
80 p->setBackgroundMode(OpaqueMode);
82 p->setBackgroundColor(bg_color);
83 p->drawImage(frame_width, frame_width, img);
86 void EmulLCD::writeRaster(uint8_t *new_raster)
88 memcpy(raster, new_raster, sizeof(raster));
97 #include <cfg/debug.h>
100 * Raster buffer to draw into.
101 * Bits in the bitmap bytes have vertical orientation,
102 * as required by the LCD driver.
104 DECLARE_WALL(wall_before_raster, WALL_SIZE)
105 static uint8_t lcd_raster[RASTER_SIZE(EmulLCD::WIDTH, EmulLCD::HEIGHT)];
106 DECLARE_WALL(wall_after_raster, WALL_SIZE)
108 /*! Default LCD bitmap */
109 struct Bitmap lcd_bitmap;
111 extern "C" void lcd_init(void)
113 //INIT_WALL(wall_before_raster);
114 //INIT_WALL(wall_after_raster);
115 gfx_bitmapInit(&lcd_bitmap, lcd_raster, EmulLCD::WIDTH, EmulLCD::HEIGHT);
116 gfx_bitmapClear(&lcd_bitmap);
119 extern "C" void lcd_blit_bitmap(Bitmap *bm)
121 //CHECK_WALL(wall_before_raster);
122 //CHECK_WALL(wall_after_raster);
123 emul->emulLCD->writeRaster(bm->raster);
126 #include "lcd_gfx_qt_moc.cpp"