26 #if (HARDWARE != SIMULATION)
41 #include <sys/ioctl.h>
51 #define FBCTL(cmd, arg) \
52 if(ioctl(UiInstance.DispFile, cmd, arg) == -1) { \
53 LogErrorNumber(LCD_DEVICE_FILE_NOT_FOUND); }
55 struct fb_var_screeninfo
var;
56 struct fb_fix_screeninfo
fix;
90 for (Y = 0;Y < 128;Y++)
94 Pixels = (
ULONG)*pSrc;
96 Pixels |= (
ULONG)*pSrc << 8;
98 Pixels |= (
ULONG)*pSrc << 16;
125 Pixels = (
ULONG)*pSrc;
127 Pixels |= (
ULONG)*pSrc << 8;
150 #ifdef MAX_FRAMES_PER_SEC
169 #ifdef MAX_FRAMES_PER_SEC
181 UiInstance.DispFile = open(LCD_DEVICE_NAME, O_RDWR);
192 fll = (
var.xres >> 3) + 1;
194 dbuf = (
unsigned char *)mmap(0,
var.yres *
dll, PROT_WRITE | PROT_READ, MAP_SHARED,
UiInstance.DispFile, 0);
216 #include <X11/Xlib.h>
218 #include <X11/Xutil.h>
224 #define DISPLAY_LEFT 10
225 #define DISPLAY_TOP 100
226 #define DISPLAY_WIDTH 366
227 #define DISPLAY_HEIGHT 557
274 #ifdef MAX_FRAMES_PER_SEC
293 #ifdef MAX_FRAMES_PER_SEC
305 XSetWindowAttributes WindowAttributes;
306 unsigned long WindowMask;
311 pDisplay = XOpenDisplay(
NULL);
312 if (pDisplay !=
NULL)
314 Background = BlackPixel(pDisplay,DefaultScreen(pDisplay));
315 Foreground = WhitePixel(pDisplay,DefaultScreen(pDisplay));
317 Depth = DefaultDepth(pDisplay,DefaultScreen(pDisplay));
318 ScreenNo = DefaultScreen(pDisplay);
319 CM = XDefaultColormap(pDisplay,ScreenNo);
320 colour_bk.flags = DoRed|DoGreen|DoBlue;
321 colour_bk.red = 32512;
322 colour_bk.green = 34304;
323 colour_bk.blue = 34560;
325 WindowAttributes.border_pixel = Background;
326 WindowAttributes.background_pixel = Foreground;
327 WindowAttributes.override_redirect = 1;
328 WindowMask = CWBackPixel|CWBorderPixel|CWOverrideRedirect;
329 hWindow = XCreateWindow(pDisplay,RootWindow(pDisplay,ScreenNo),DISPLAY_LEFT,DISPLAY_TOP,DISPLAY_WIDTH,DISPLAY_HEIGHT,0,Depth,InputOutput,CopyFromParent,WindowMask,&WindowAttributes);
333 if (XAllocColor(pDisplay,CM,&colour_bk) == 0)
335 printf(
"XAllocColor failure.\n");
337 if (XSetWindowBackground(pDisplay,hWindow, colour_bk.pixel) == BadGC)
339 printf(
"XSetBackground failure.\n");
342 snprintf(Buffer,255,
"%s V%4.2f",PROJECT,VERS);
343 XSetStandardProperties(pDisplay,hWindow,Buffer,Buffer,None,
NULL,0,
NULL);
345 XSelectInput(pDisplay,hWindow,StructureNotifyMask);
346 XMapWindow(pDisplay,hWindow);
348 hGC = XCreateGC(pDisplay,hWindow,0,
NULL);
349 XSetForeground(pDisplay,hGC,Background);
350 XSetBackground(pDisplay,hGC,colour_bk.pixel);
355 XNextEvent(pDisplay,&Event);
357 while (Event.type != MapNotify);
362 if (XpmReadFileToImage(pDisplay,
"body.xpm",&pImg,&pClp,
NULL) == 0)
364 XPutImage(pDisplay,hWindow,hGC,pImg,0,0,0,0,DISPLAY_WIDTH,DISPLAY_HEIGHT);
368 XSetForeground(pDisplay,hGC,Background);
369 XSetBackground(pDisplay,hGC,colour_bk.pixel);
377 Image.format = XYBitmap;
378 Image.data = (
char*)pImage;
379 Image.byte_order = LSBFirst;
380 Image.bitmap_unit = 8;
381 Image.bitmap_bit_order = LSBFirst;
382 Image.bitmap_pad = 8;
384 Image.bytes_per_line = (
LCD_WIDTH + 7) / 8;
385 Image.bits_per_pixel = 1;
391 XSelectInput(pDisplay,hWindow,ExposureMask | ButtonPressMask | ButtonReleaseMask);
401 if (XCheckMaskEvent(pDisplay,ExposureMask | ButtonPressMask | ButtonReleaseMask,&Event))
412 switch (Event.xbutton.button)
418 if ((X >= 162) && (X <= 205) && (Y >= 288) && (Y <= 327))
422 if ((X >= 162) && (X <= 205) && (Y >= 382) && (Y <= 421))
426 if ((X >= 230) && (X <= 264) && (Y >= 338) && (Y <= 371))
430 if ((X >= 98) && (X <= 137) && (Y >= 337) && (Y <= 370))
434 if ((X >= 162) && (X <= 202) && (Y >= 333) && (Y <= 375))
438 if ((X >= 51) && (X <= 120) && (Y >= 258) && (Y <= 295))
465 switch (Event.xbutton.button)
471 if ((X >= 162) && (X <= 205) && (Y >= 288) && (Y <= 327))
475 if ((X >= 162) && (X <= 205) && (Y >= 382) && (Y <= 421))
479 if ((X >= 230) && (X <= 264) && (Y >= 338) && (Y <= 371))
483 if ((X >= 98) && (X <= 137) && (Y >= 337) && (Y <= 370))
487 if ((X >= 162) && (X <= 202) && (Y >= 333) && (Y <= 375))
491 if ((X >= 51) && (X <= 120) && (Y >= 258) && (Y <= 295))
513 XFreePixmap(pDisplay,hLcd);
514 XFreeGC(pDisplay,hGC);
515 XCloseDisplay(pDisplay);
536 pImage[(X0 >> 3) + Y0 * ((
LCD_WIDTH + 7) >> 3)] |= (1 << (X0 % 8));
540 pImage[(X0 >> 3) + Y0 * ((
LCD_WIDTH + 7) >> 3)] &= ~(1 << (X0 % 8));
550 pImage[(X0 >> 3) + Y0 * ((
LCD_WIDTH + 7) >> 3)] ^= (1 << (X0 % 8));
561 if ((pImage[(X0 >> 3) + Y0 * ((
LCD_WIDTH + 7) >> 3)] & (1 << (X0 % 8))))
600 Diff = XLength - YLength;
604 while ((X0 != X1) || (Y0 != Y1))
607 if (Tmp > (-YLength))
632 if ((X0 != X1) && (Y0 != Y1))
658 Diff = XLength - YLength;
663 while ((X0 != X1) || (Y0 != Y1))
666 if (Tmp > (-YLength))
676 if (Count < (On + Off))
688 if (Count >= (On + Off))
725 P = P + 4 * (X - Y) + 10;
746 #include "normal_font.xbm"
747 #include "small_font.xbm"
748 #include "large_font.xbm"
749 #include "tiny_font.xbm"
755 .
pFontBits = (
const char*)normal_font_bits,
763 .pFontBits = (
const char*)small_font_bits,
771 .pFontBits = (
const char*)large_font_bits,
779 .pFontBits = (
const char*)tiny_font_bits,
792 return (FontInfo[Font].FontWidth);
798 return (FontInfo[Font].FontHeight);
815 if ((Char >= FontInfo[Font].FontFirst) && (Char <= FontInfo[Font].FontLast))
819 CharByteIndex = (Char % FontInfo[Font].
FontHorz) * ((CharWidth + 7) / 8);
820 CharByteIndex += ((Char / FontInfo[Font].
FontHorz) * ((CharWidth + 7) / 8) * CharHeight * FontInfo[Font].FontHorz);
822 if (((CharWidth % 8) == 0) && ((X0 % 8) == 0))
826 LcdByteIndex = (X0 >> 3) + Y0 * ((
LCD_WIDTH + 7) >> 3);
835 if (LcdByteIndex <
sizeof(LCD))
837 pImage[LcdByteIndex + Tmp] = FontInfo[Font].
pFontBits[CharByteIndex + Tmp];
841 while (Tmp < (CharWidth / 8));
843 CharByteIndex += (CharWidth * FontInfo[Font].
FontHorz) / 8;
855 if (LcdByteIndex <
sizeof(LCD))
857 pImage[LcdByteIndex + Tmp] = ~FontInfo[Font].
pFontBits[CharByteIndex + Tmp];
861 while (Tmp < (CharWidth / 8));
863 CharByteIndex += (CharWidth * FontInfo[Font].
FontHorz) / 8;
872 MaxX = X0 + CharWidth;
876 for (Y = 0;Y < CharHeight;Y++)
880 for (X = 0;X < ((CharWidth + 7) / 8);X++)
882 CharByte = FontInfo[Font].
pFontBits[CharByteIndex + X];
884 for (Tmp = 0;(Tmp < 8) && (TmpX < MaxX);Tmp++)
899 CharByteIndex += ((CharWidth + 7) / 8) * FontInfo[Font].
FontHorz;
905 for (Y = 0;Y < CharHeight;Y++)
909 for (X = 0;X < ((CharWidth + 7) / 8);X++)
911 CharByte = FontInfo[Font].
pFontBits[CharByteIndex + X];
913 for (Tmp = 0;(Tmp < 8) && (TmpX < MaxX);Tmp++)
928 CharByteIndex += ((CharWidth + 7) / 8) * FontInfo[Font].
FontHorz;
940 if (X0 < (
LCD_WIDTH - FontInfo[Font].FontWidth))
959 #include "normal_icons.xbm"
960 #include "small_icons.xbm"
961 #include "large_icons.xbm"
962 #include "menu_icons.xbm"
963 #include "arrow_icons.xbm"
970 .IconSize = normal_icons_height,
972 .IconWidth = normal_icons_width
975 .pIconBits = small_icons_bits,
976 .IconSize = small_icons_height,
978 .IconWidth = small_icons_width
981 .pIconBits = large_icons_bits,
982 .IconSize = large_icons_height,
984 .IconWidth = large_icons_width
987 .pIconBits = menu_icons_bits,
988 .IconSize = menu_icons_height,
990 .IconWidth = menu_icons_width
993 .pIconBits = arrow_icons_bits,
994 .IconSize = arrow_icons_height,
996 .IconWidth = arrow_icons_width
1005 pResult = (
UBYTE*)IconInfo[Type].pIconBits;
1013 return (IconInfo[Type].IconWidth);
1019 return (IconInfo[Type].IconHeight);
1025 return (IconInfo[Type].IconSize / IconInfo[Type].IconHeight);
1037 X0 = (X0 >> 3) << 3;
1038 LcdByteIndex = (X0 >> 3) + Y0 * ((
LCD_WIDTH + 7) >> 3);
1045 for (Tmp = 0;Tmp < (IconWidth / 8);Tmp++)
1047 pImage[LcdByteIndex + Tmp] = pIconBits[IconByteIndex + Tmp];
1050 IconByteIndex += IconWidth / 8;
1059 for (Tmp = 0;Tmp < (IconWidth / 8);Tmp++)
1061 pImage[LcdByteIndex + Tmp] = ~pIconBits[IconByteIndex + Tmp];
1064 IconByteIndex += IconWidth / 8;
1085 IconByteIndex = ((
DATA16)No * IconWidth * IconHeight) / 8;
1086 dLcdDrawPicture(pImage,Color,X0,Y0,IconWidth,IconHeight,&pIconBits[IconByteIndex]);
1099 *pWidth = (
DATA16)pBitmap[0];
1100 *pHeight = (
DATA16)pBitmap[1];
1110 UBYTE *pBitmapBytes;
1112 DATA16 Tmp,X,Y,TmpX,MaxX;
1119 BitmapWidth = (
DATA16)pBitmap[0];
1120 BitmapHeight = (
DATA16)pBitmap[1];
1121 MaxX = X0 + BitmapWidth;
1122 pBitmapBytes = &pBitmap[2];
1124 if ((BitmapWidth >=0) && (BitmapHeight >= 0))
1126 if ((X0 % 8) || (BitmapWidth % 8))
1129 BitmapWidth = ((BitmapWidth + 7) >> 3) << 3;
1133 for (Y = 0;Y < BitmapHeight;Y++)
1135 BitmapByteIndex = (Y * BitmapWidth) / 8;
1138 for (X = 0;X < (BitmapWidth / 8);X++)
1140 BitmapByte = pBitmapBytes[BitmapByteIndex + X];
1142 for (Tmp = 0;(Tmp < 8) && (TmpX < MaxX);Tmp++)
1161 for (Y = 0;Y < BitmapHeight;Y++)
1163 BitmapByteIndex = (Y * BitmapWidth) / 8;
1166 for (X = 0;X < (BitmapWidth / 8);X++)
1168 BitmapByte = pBitmapBytes[BitmapByteIndex + X];
1170 for (Tmp = 0;(Tmp < 8) && (TmpX < MaxX);Tmp++)
1192 BitmapByteIndex = 0;
1194 LcdByteIndex = (X0 >> 3) + Y0 * ((
LCD_WIDTH + 7) >> 3);
1198 while (BitmapHeight)
1201 for (Tmp = 0;Tmp < (BitmapWidth / 8);Tmp++)
1205 pImage[LcdByteIndex + Tmp] = pBitmapBytes[BitmapByteIndex + Tmp];
1210 BitmapByteIndex += BitmapWidth / 8;
1218 while (BitmapHeight)
1221 for (Tmp = 0;Tmp < (BitmapWidth / 8);Tmp++)
1225 pImage[LcdByteIndex + Tmp] = ~pBitmapBytes[BitmapByteIndex + Tmp];
1230 BitmapByteIndex += BitmapWidth / 8;
1264 for (;Y0 < MaxY;Y0++)
1266 for (X0 = StartX;X0 < MaxX;X0++)
1284 for (;Y0 < MaxY;Y0++)
1286 for (X0 = StartX;X0 < MaxX;X0++)
1296 dLcdDrawLine(pImage,Color,X0 - X1,Y0 + Y1,X0 + X1,Y0 + Y1);
1297 dLcdDrawLine(pImage,Color,X0 - X1,Y0 - Y1,X0 + X1,Y0 - Y1);
1298 dLcdDrawLine(pImage,Color,X0 - Y1,Y0 + X1,X0 + Y1,Y0 + X1);
1299 dLcdDrawLine(pImage,Color,X0 - Y1,Y0 - X1,X0 + Y1,Y0 - X1);
1318 P = P + 4 * (X - Y) + 10;
struct fb_var_screeninfo var
LCD LcdBuffer
Copy of last LCD update.
void dLcdScroll(UBYTE *pImage, DATA16 Y0)
SWORD DATA16
VM Type for 2 byte signed value.
DATA16 dLcdGetFontWidth(DATA8 Font)
void LogErrorNumber(ERR Err)
void dLcdExec(LCD *pDisp)
DATA8 LcdUpdated
LCD updated.
void dLcdInversePixel(UBYTE *pImage, DATA16 X0, DATA16 Y0)
void dLcdInit(UBYTE *pImage)
void dLcdDrawText(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA8 Font, DATA8 *pText)
void dLcdDrawIcon(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA8 Type, DATA8 No)
#define LCD_WIDTH
LCD horizontal pixels.
void dLcdDrawLine(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1)
IMGDATA * IP
Instruction pointer type.
void dLcdDrawChar(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA8 Font, DATA8 Char)
unsigned int ULONG
Basic Type used to symbolise 32 bit unsigned values.
DATA16 dLcdGetFontHeight(DATA8 Font)
struct fb_fix_screeninfo fix
void dLcdUpdate(LCD *pDisp)
DATA16 dLcdGetIconHeight(DATA8 Type)
DATA16 dLcdGetIconWidth(DATA8 Type)
UBYTE * dLcdGetIconBits(DATA8 Type)
void dLcdInverseRect(UBYTE *pImage, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1)
DATA8 dLcdReadPixel(UBYTE *pImage, DATA16 X0, DATA16 Y0)
unsigned char UBYTE
Basic Type used to symbolise 8 bit unsigned values.
void dLcdRect(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1)
DATA16 dLcdGetNoOfIcons(DATA8 Type)
unsigned short UWORD
Basic Type used to symbolise 16 bit unsigned values.
void dLcdDrawDotLine(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1, DATA16 On, DATA16 Off)
void dLcdAutoUpdate(void)
void dLcdFlodfill(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0)
void dLcdDrawCircle(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 R)
void dLcdPlotPoints(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1)
SBYTE DATA8
VM Type for 1 byte signed value.
void dLcdDrawBitmap(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, IP pBitmap)
void dLcdPlotLines(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1)
void dLcdGetBitmapSize(IP pBitmap, DATA16 *pWidth, DATA16 *pHeight)
void dLcdFillRect(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1)
void dLcdDrawFilledCircle(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 R)
void dLcdDrawPicture(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 IconWidth, DATA16 IconHeight, UBYTE *pIconBits)
void dLcdDrawPixel(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0)
#define LCD_HEIGHT
LCD vertical pixels.
DATA8 dLcdCheckPixel(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0)