Re: driving 2 displays

Usagi Yojimbo <[email protected]> Wed, 07 Nov 2012 06:46:37 +0100
Newsgroups gmane.comp.sysutils.lcdproc
Organization Y.V.S
Message-ID <[email protected]>
>> As the core already can load multiple driver (like you are using), I
>> believe teaching the core about a virtual display that may consist of
>> several physical ones fits better into the currrent design.

> I think, the simplest way to do this would be, that for all driver one could specify base co-ordinates, defaulting to 0,0.
> The driver would get the co-ordinates relative to that base (that is for driverY = originalY - baseY).
> This could be implemented in the core, where the driver gets called.

> This way no "really special" treating is necessary, nor the drivers had to be rewritten.
> (Maybe recompiled, for the base co-ordinates to be stored in the driver data space?)

Hi,

Yesterday, after seeing the release of 0.5.6 i made up my mind and 
started to work on this...

It took a few hours to figure things out (sorry, i am no C/C++ 
programmer myself), and finally i got a working version.

Attached is the output of the command: cvs diff -Nua

However i do consider it as a work in progress.
It is running with my 2 displays (iMon VFD and ModeCom MediaBay), but 
should be tested on other configurations, too.



Usagi

_______________________________________________
LCDproc mailing list
[email protected]
http://lists.omnipotent.net/mailman/listinfo/lcdproc
offset.diff (text/plain, 5.6 KB)
Index: server/driver.c
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/driver.c,v
retrieving revision 1.26
diff -u -a -r1.26 driver.c
--- server/driver.c	1 Sep 2012 21:24:39 -0000	1.26
+++ server/driver.c	7 Nov 2012 05:28:43 -0000
@@ -285,6 +285,11 @@
 	driver->request_display_width	= request_display_width;
 	driver->request_display_height	= request_display_height;
 
+	/* Display offset values */
+	driver->xOffset = config_get_int(driver->name, "xOffset", 0, 0);
+	driver->yOffset = config_get_int(driver->name, "yOffset", 0, 0);
+	report(RPT_INFO, "%s(driver=[%.40s],xOffset=%d,yOffset=%d)", __FUNCTION__, driver->name, driver->xOffset, driver->yOffset);
+
 	return 0;
 }
 
Index: server/drivers.c
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/drivers.c,v
retrieving revision 1.26
diff -u -a -r1.26 drivers.c
--- server/drivers.c	22 Feb 2012 22:25:32 -0000	1.26
+++ server/drivers.c	7 Nov 2012 05:28:43 -0000
@@ -120,6 +120,12 @@
 			display_props->cellheight = LCD_DEFAULT_CELLHEIGHT;
 	}
 
+	/* Modify display size with offset */
+	int x = driver->width(driver) + driver->xOffset;
+	if(x > display_props->width) display_props->width  = x;
+	int y = driver->height(driver) + driver->yOffset;
+	if(y > display_props->height) display_props->height  = x;
+
 	/* Return the driver type */
 	if (driver_does_output(driver)) {
 		if (driver_stay_in_foreground(driver))
@@ -219,11 +225,11 @@
 {
 	Driver *drv;
 
-	debug(RPT_DEBUG, "%s(x=%d, y=%d, string=\"%.40s\")", __FUNCTION__, x, y, string);
+	debug(RPT_DEBUG, "%s(x=%d, y=%d, string=\"%.40s\")", __FUNCTION__, x - drv->xOffset, y - drv->yOffset, string);
 
 	ForAllDrivers(drv) {
 		if (drv->string)
-			drv->string(drv, x, y, string);
+			drv->string(drv, x - drv->xOffset, y - drv->yOffset, string);
 	}
 }
 
@@ -240,11 +246,11 @@
 {
 	Driver *drv;
 
-	debug(RPT_DEBUG, "%s(x=%d, y=%d, c='%c')", __FUNCTION__, x, y, c);
+	debug(RPT_DEBUG, "%s(x=%d, y=%d, c='%c')", __FUNCTION__, x - drv->xOffset, y - drv->yOffset, c);
 
 	ForAllDrivers(drv) {
 		if (drv->chr)
-			drv->chr(drv, x, y, c);
+			drv->chr(drv, x - drv->xOffset, y - drv->yOffset, c);
 	}
 }
 
@@ -265,7 +271,7 @@
 	Driver *drv;
 
 	debug(RPT_DEBUG, "%s(x=%d, y=%d, len=%d, promille=%d, pattern=%d)",
-	      __FUNCTION__, x, y, len, promille, pattern);
+	      __FUNCTION__, x - drv->xOffset, y - drv->yOffset, len, promille, pattern);
 
 	/* NEW FUNCTIONS
 	 *
@@ -275,9 +281,9 @@
 
 	ForAllDrivers(drv) {
 		if (drv->vbar)
-			drv->vbar(drv, x, y, len, promille, pattern);
+			drv->vbar(drv, x - drv->xOffset, y - drv->yOffset, len, promille, pattern);
 		else
-			driver_alt_vbar(drv, x, y, len, promille, pattern);
+			driver_alt_vbar(drv, x - drv->xOffset, y - drv->yOffset, len, promille, pattern);
 	}
 }
 
@@ -298,13 +304,13 @@
 	Driver *drv;
 
 	debug(RPT_DEBUG, "%s(x=%d, y=%d, len=%d, promille=%d, pattern=%d)",
-	      __FUNCTION__, x, y, len, promille, pattern);
+	      __FUNCTION__, x - drv->xOffset, y - drv->yOffset, len, promille, pattern);
 
 	ForAllDrivers(drv) {
 		if (drv->hbar)
-			drv->hbar(drv, x, y, len, promille, pattern);
+			drv->hbar(drv, x - drv->xOffset, y - drv->yOffset, len, promille, pattern);
 		else
-			driver_alt_hbar(drv, x, y, len, promille, pattern);
+			driver_alt_hbar(drv, x - drv->xOffset, y - drv->yOffset, len, promille, pattern);
 	}
 }
 
@@ -321,13 +327,13 @@
 {
 	Driver *drv;
 
-	debug(RPT_DEBUG, "%s(x=%d, num=%d)", __FUNCTION__, x, num);
+	debug(RPT_DEBUG, "%s(x=%d, num=%d)", __FUNCTION__, x - drv->xOffset, num);
 
 	ForAllDrivers(drv) {
 		if (drv->num)
-			drv->num(drv, x, num);
+			drv->num(drv, x - drv->xOffset, num);
 		else
-			driver_alt_num(drv, x, num);
+			driver_alt_num(drv, x - drv->xOffset, num);
 	}
 }
 
@@ -369,19 +375,19 @@
 {
 	Driver *drv;
 
-	debug(RPT_DEBUG, "%s(x=%d, y=%d, icon=ICON_%s)", __FUNCTION__, x, y, widget_icon_to_iconname(icon));
+	debug(RPT_DEBUG, "%s(x=%d, y=%d, icon=ICON_%s)", __FUNCTION__, x - drv->xOffset, y - drv->yOffset, 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) {
+			if (drv->icon(drv, x - drv->xOffset, y - drv->yOffset, icon) == -1) {
 				/* do alternative call if driver's function does not know the icon */
-				driver_alt_icon(drv, x, y, icon);
+				driver_alt_icon(drv, x - drv->xOffset, y - drv->yOffset, icon);
 			}
 		} else {
 			/* Also do alternative call if the driver does not have icon function */
-			driver_alt_icon(drv, x, y, icon);
+			driver_alt_icon(drv, x - drv->xOffset, y - drv->yOffset, icon);
 		}
 	}
 }
@@ -400,13 +406,13 @@
 {
 	Driver *drv;
 
-	debug(RPT_DEBUG, "%s(x=%d, y=%d, state=%d)", __FUNCTION__, x, y, state);
+	debug(RPT_DEBUG, "%s(x=%d, y=%d, state=%d)", __FUNCTION__, x - drv->xOffset, y - drv->yOffset, state);
 
 	ForAllDrivers(drv) {
 		if (drv->cursor)
-			drv->cursor(drv, x, y, state);
+			drv->cursor(drv, x - drv->xOffset, y - drv->yOffset, state);
 		else
-			driver_alt_cursor(drv, x, y, state);
+			driver_alt_cursor(drv, x - drv->xOffset, y - drv->yOffset, state);
 	}
 }
 
Index: server/drivers/lcd.h
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/drivers/lcd.h,v
retrieving revision 1.29
diff -u -a -r1.29 lcd.h
--- server/drivers/lcd.h	15 Nov 2011 21:40:23 -0000	1.29
+++ server/drivers/lcd.h	7 Nov 2012 05:28:43 -0000
@@ -214,6 +214,10 @@
 	int (*request_display_width) ();
 	int (*request_display_height) ();
 
+	/**************** Offset values used by the core ****************/
+	int xOffset;
+	int yOffset;
+
 } Driver;
 
 #endif