[Lcdproc] Custom Icons
Francisco Javier Taboada Aguado
xavi@iesrodeira.com
Fri Apr 18 15:35:02 2008
--=-cMtpMpE4XAAqa+0VlRk8
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
I have a Shuttle SG33G5M and i am developing an irc controller with lcd
support. The LCDd driver is OK, but not support all shuttle's icon.
The patches included implements custom icons support for LCDd by
hexcodes:
widget_set x x x x 0x00000000
it is possible enable multiple icons at the same time with the
appropiate code.
Sorry for my english.
--=-cMtpMpE4XAAqa+0VlRk8
Content-Disposition: attachment; filename=driver_c.patch
Content-Type: text/x-patch; name=driver_c.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
--- lcdproc-CVS-current-20080403/server/driver.c 2007-06-18 09:00:25.000000000 +0200
+++ lcdproc-CVS-current-shuttle_v1/server/driver.c 2008-04-18 15:56:31.000000000 +0200
@@ -64,6 +64,7 @@
{ "num", offsetof(Driver, num), 0 },
{ "heartbeat", offsetof(Driver, heartbeat), 0 },
{ "icon", offsetof(Driver, icon), 0 },
+ { "custom_icon", offsetof(Driver, custom_icon), 0 }, //@FJTA dirty hack for custom icon(s) support
{ "cursor", offsetof(Driver, cursor), 0 },
{ "set_char", offsetof(Driver, set_char), 0 },
{ "get_free_chars", offsetof(Driver, get_free_chars), 0 },
--=-cMtpMpE4XAAqa+0VlRk8
Content-Disposition: attachment; filename=drivers_c.patch
Content-Type: text/x-patch; name=drivers_c.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
--- lcdproc-CVS-current-20080403/server/drivers.c 2007-06-18 09:00:25.000000000 +0200
+++ lcdproc-CVS-current-shuttle_v1/server/drivers.c 2008-04-18 16:13:57.000000000 +0200
@@ -367,26 +367,36 @@
* call the server core's driver_alt_icon().
* \param x Horizontal character position (column).
* \param y Vertical character position (row).
- * \param icon synbolic value representing the icon.
+ * \param icon symbolic value representing the icon.
+ * \parama user_icon if icon is ICON_USER_DEF, user_icon is the hex value of the user icon
*/
+//@@ FJTA dirty hack: user icons support
void
-drivers_icon(int x, int y, int icon)
+drivers_icon(int x, int y, int icon, char *user_icon)
{
Driver *drv;
debug(RPT_DEBUG, "%s(x=%d, y=%d, icon=ICON_%s)", __FUNCTION__, x, y, widget_icon_to_iconname(icon));
ForAllDrivers(drv) {
- /* Does the driver have the icon function ? */
- if (drv->icon) {
- /* Try driver call */
- if (drv->icon(drv, x, y, icon) == -1) {
- /* do alternative call if driver's function does not know the icon */
+ //@ FJTA dirty hack: ICON_USER_DEF not call driver function, set code directly
+ if ((user_icon!=NULL)&&(icon==ICON_USER_DEF))
+ {
+ drv->custom_icon(drv,x,y,user_icon);
+ }
+ else
+ {
+ /* Does the driver have the icon function ? */
+ if (drv->icon) {
+ /* Try driver call */
+ if (drv->icon(drv, x, y, icon) == -1) {
+ /* do alternative call if driver's function does not know the icon */
+ driver_alt_icon(drv, x, y, icon);
+ }
+ } else {
+ /* Also do alternative call if the driver does not have icon function */
driver_alt_icon(drv, x, y, icon);
}
- } else {
- /* Also do alternative call if the driver does not have icon function */
- driver_alt_icon(drv, x, y, icon);
}
}
}
--=-cMtpMpE4XAAqa+0VlRk8
Content-Disposition: attachment; filename=drivers_h.patch
Content-Type: text/x-patch; name=drivers_h.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
--- lcdproc-CVS-current-20080403/server/drivers.h 2007-04-03 09:00:19.000000000 +0200
+++ lcdproc-CVS-current-shuttle_v1/server/drivers.h 2008-04-18 16:30:19.000000000 +0200
@@ -63,7 +63,7 @@
drivers_heartbeat(int state);
void
-drivers_icon(int x, int y, int icon);
+drivers_icon(int x, int y, int icon,char *user_icon_code); // @FJTA: dirty hack for user defined icon(s) support);
void
drivers_set_char(char ch, char *dat);
--=-cMtpMpE4XAAqa+0VlRk8
Content-Disposition: attachment; filename=lcd_h.patch
Content-Type: text/x-patch; name=lcd_h.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
--- lcdproc-CVS-current-20080403/server/drivers/lcd.h 2007-04-03 09:00:26.000000000 +0200
+++ lcdproc-CVS-current-shuttle_v1/server/drivers/lcd.h 2008-04-18 15:59:09.000000000 +0200
@@ -47,6 +47,8 @@
/* Icons. If a driver does not support an icon, it can return -1 from the
* icon function, and let the core place a replacement character.
*/
+#define ICON_USER_DEF 0xFF //@@ FJTA Dirty hack for custom icons support
+
/* Icons below are one character wide */
#define ICON_BLOCK_FILLED 0x100
#define ICON_HEART_OPEN 0x108
@@ -147,6 +149,8 @@
void (*num) (struct lcd_logical_driver *drvthis, int x, int num);
void (*heartbeat) (struct lcd_logical_driver *drvthis, int state);
int (*icon) (struct lcd_logical_driver *drvthis, int x, int y, int icon);
+ //@ FJTA dirty hack: Custom icon(s) support
+ int (*custom_icon) (struct lcd_logical_driver *drvthis, int x, int y, char *icon);
void (*cursor) (struct lcd_logical_driver *drvthis, int x, int y, int type);
/* user-defined character functions, are those still supported ? */
--=-cMtpMpE4XAAqa+0VlRk8
Content-Disposition: attachment; filename=render_c.patch
Content-Type: text/x-patch; name=render_c.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
--- lcdproc-CVS-current-20080403/server/render.c 2008-02-11 09:00:48.000000000 +0100
+++ lcdproc-CVS-current-shuttle_v1/server/render.c 2008-04-18 16:16:48.000000000 +0200
@@ -230,7 +230,8 @@
render_vbar(w, left, top, right, bottom);
break;
case WID_ICON:
- drivers_icon(w->x, w->y, w->length);
+ //@ FJTA dirty hack: user defined icon(s) support
+ drivers_icon(w->x, w->y, w->length, w->text);
break;
case WID_TITLE: /* FIXME: Doesn't work quite right in frames... */
render_title(w, left, top, right, bottom, timer);
@@ -364,8 +365,8 @@
: max(TITLESPEED_MIN, TITLESPEED_MAX - titlespeed);
/* display leading fillers */
- drivers_icon(w->x + left, w->y + top, ICON_BLOCK_FILLED);
- drivers_icon(w->x + left + 1, w->y + top, ICON_BLOCK_FILLED);
+ drivers_icon(w->x + left, w->y + top, ICON_BLOCK_FILLED,NULL); //@ FJTA dirty hack for user defined icon(s)
+ drivers_icon(w->x + left + 1, w->y + top, ICON_BLOCK_FILLED,NULL);
length = min(length, sizeof(str));
if ((length <= width) || (delay == 0)) {
@@ -418,7 +419,7 @@
/* display trailing fillers */
for ( ; x < vis_width; x++) {
- drivers_icon(w->x + x + left, w->y + top, ICON_BLOCK_FILLED);
+ drivers_icon(w->x + x + left, w->y + top, ICON_BLOCK_FILLED,NULL); //@ FJTA dirty hack for user defined icon(s)
}
}
return 0;
--=-cMtpMpE4XAAqa+0VlRk8
Content-Disposition: attachment; filename=shuttleVFD_c.patch
Content-Type: text/x-patch; name=shuttleVFD_c.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
--- lcdproc-CVS-current-20080403/server/drivers/shuttleVFD.c 2007-11-12 09:01:07.000000000 +0100
+++ lcdproc-CVS-current-shuttle_v1/server/drivers/shuttleVFD.c 2008-04-18 16:01:18.000000000 +0200
@@ -267,6 +267,13 @@
}
}
+//@FJTA dirty hack: Custom Icon(s) support
+MODULE_EXPORT int shuttleVFD_custom_icon(Driver *drvthis, int x, int y, char *icon)
+{
+ PrivateData *p = drvthis->private_data;
+ sscanf(icon,"%X",&(p->icons));
+ return 0;
+}
MODULE_EXPORT int shuttleVFD_icon(Driver *drvthis, int x, int y, int icon) {
PrivateData *p = drvthis->private_data;
--=-cMtpMpE4XAAqa+0VlRk8
Content-Disposition: attachment; filename=shuttleVFD_h.patch
Content-Type: text/x-patch; name=shuttleVFD_h.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
--- lcdproc-CVS-current-20080403/server/drivers/shuttleVFD.h 2007-11-12 09:01:07.000000000 +0100
+++ lcdproc-CVS-current-shuttle_v1/server/drivers/shuttleVFD.h 2008-04-18 16:02:33.000000000 +0200
@@ -44,6 +44,9 @@
// extended output functions
MODULE_EXPORT int shuttleVFD_icon(Driver *drvthis, int x, int y, int icon);
+//@FJTA dirty hack: Custom Icon(s) support
+MODULE_EXPORT int shuttleVFD_custom_icon(Driver *drvthis, int x, int y, char *icon);
+
// user-defined character functions
MODULE_EXPORT int shuttleVFD_cellwidth(Driver *drvthis);
MODULE_EXPORT int shuttleVFD_cellheight(Driver *drvthis);
--=-cMtpMpE4XAAqa+0VlRk8
Content-Disposition: attachment; filename=widget_commands_c.patch
Content-Type: text/x-patch; name=widget_commands_c.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
--- lcdproc-CVS-current-20080403/server/commands/widget_commands.c 2007-06-24 09:00:26.000000000 +0200
+++ lcdproc-CVS-current-shuttle_v1/server/commands/widget_commands.c 2008-04-18 15:54:35.000000000 +0200
@@ -306,7 +306,20 @@
x = atoi(argv[i]);
y = atoi(argv[i + 1]);
- icon = widget_iconname_to_icon(argv[i + 2]);
+
+ //@@ FJTA Dirty hack: Support custom icons
+ if (!strncmp(argv[i+2],"0x",2))
+ {
+ icon=ICON_USER_DEF;
+ if (w->text != NULL) free(w->text);
+ w->text = strdup(argv[i + 2]); // in ICON_USER_DEF case, icon binary code
+ if (w->text == NULL) {
+ report(RPT_WARNING, "widget_set_func: Allocation error");
+ return -1;
+ }
+ }
+ else icon = widget_iconname_to_icon(argv[i + 2]);
+
if (icon == -1) {
sock_send_error(c->sock, "Invalid icon name\n");
}
--=-cMtpMpE4XAAqa+0VlRk8--