Some fixes after comments

This commit is contained in:
YARD2
2016-08-09 21:34:52 +02:00
parent e1dc01af31
commit 72e27fc718
+20 -9
View File
@@ -1,6 +1,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2009 by M. Feser * * Copyright (C) 2009 by M. Feser *
* Copyright (C) 1013 by R. Geigenberger (Update for YARD2) * * Copyright (C) 2013 by R. Geigenberger (Update for YARD2) *
* yard2lcdproc (.A.T.) yard2usb.de *
* * * *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@@ -171,11 +172,9 @@ yard_hwGotoXY(Driver *drvthis, unsigned char x, unsigned char y)
cmdBuf[2] = y - 1; cmdBuf[2] = y - 1;
return yard_hwWrite(drvthis, cmdBuf, 3); return yard_hwWrite(drvthis, cmdBuf, 3);
break;
} }
default: { default: {
return -1; return -1;
break;
} }
} }
} }
@@ -353,7 +352,7 @@ yard_init(Driver *drvthis)
report(RPT_ERR, "%s: Can't create framebuffer !", drvthis->name); report(RPT_ERR, "%s: Can't create framebuffer !", drvthis->name);
return -1; return -1;
} }
memset(p->framebuf, ' ', p->width * p->height); memset(p->framebuf, ' ', (p->width * p->height)*2);
/* not done yet /* not done yet
// Init size and graphical size // Init size and graphical size
@@ -362,8 +361,7 @@ yard_init(Driver *drvthis)
/* /*
// Init backlight-on brightness -> done by YARD2 normally in auto mode // Init backlight-on brightness -> done by YARD2 normally in auto mode
*/ */
tmp = DEFAULT_ON_BRIGHTNESS; p->on_brightness = DEFAULT_ON_BRIGHTNESS;
p->on_brightness = tmp;
/* /*
// Init backlight-off brightness -> done by YARD2 normally in auto mode // Init backlight-off brightness -> done by YARD2 normally in auto mode
*/ */
@@ -433,7 +431,7 @@ yard_clear(Driver *drvthis)
} }
/* /*
* Flushes a single frame to the VFD * Flushes a single frame to the LCD
*/ */
MODULE_EXPORT void MODULE_EXPORT void
yard_flush(Driver *drvthis) yard_flush(Driver *drvthis)
@@ -474,7 +472,7 @@ yard_flush(Driver *drvthis)
} }
/* /*
* Prints a string on the VFD * Prints a string on the LCD
*/ */
MODULE_EXPORT void MODULE_EXPORT void
yard_string(Driver *drvthis, int x, int y, const char string[]) yard_string(Driver *drvthis, int x, int y, const char string[])
@@ -493,6 +491,18 @@ yard_string(Driver *drvthis, int x, int y, const char string[])
x--; //start with 0,0 x--; //start with 0,0
y--; y--;
if ((y < 0) || (y >= p->height)) return;
for (i = 0; (string[i] != '\0') && (x < p->width); i++) //, x++)
{
if (x >= 0) // no write left of left border
p->framebuf[(y * p->width) + x + i] = string[i];
}
/*
for (i = 0; string[i] != '\0'; i++) for (i = 0; string[i] != '\0'; i++)
{ {
// Check for buffer overflow // Check for buffer overflow
@@ -500,10 +510,11 @@ yard_string(Driver *drvthis, int x, int y, const char string[])
break; break;
p->framebuf[(y * p->width) + x + i] = string[i]; p->framebuf[(y * p->width) + x + i] = string[i];
} }
*/
} }
/* /*
* Prints a single character on the VFD * Prints a single character on the LCD
*/ */
MODULE_EXPORT void MODULE_EXPORT void
yard_chr(Driver *drvthis, int x, int y, char c) yard_chr(Driver *drvthis, int x, int y, char c)