Re: imonlcd 0x0 command turning off progress bar

Eric Pooch <[email protected]>
Newsgroups gmane.comp.sysutils.lcdproc
Message-ID <[email protected]>
Here is the patch to fix the issues raise by Yura.


I noticed a few things:
1) The IMON_OUTPUT_PBARS_MASK captures an output value of -1 because  
of the binary value of negative numbers.  I don't think this was  
expected in the previous version and resulted in not all of the icons  
coming on.
2) an output value of -1 includes the CD spinning bit, so the driver  
would continue to send commands to set the icons even if nothing was  
changing.  I accounted for that in the cache check:
if (state == p->last_output_state && !(state != -1 && (state &  
IMON_OUTPUT_CD_MASK)))

3)The left-most bar on the top and bottom does not light up due to a  
pre-existing bug .  I will have a patch for that shortly.

--Eric

On Oct 16, 2011, at 10:06 AM, Yura Scheglyuk wrote:

> 		Hi!
>
> On 16.10.2011 15:36, Markus Dolze wrote:
>
>>> Now imonlcd driver assuming that 0x0 clear icons only. The simple
>>> solution is to modify driver that on 0x0 command it should clear the
>>> bar state too.
>>
>> Currently there are two options:
>>
>>     1. '-1' will turn all icons _and_ bars on. '0x0' will turn all  
>> icons
>>        _and_ bars off.
>>     2. '-1' will _not_ turn on the bars and '0x0' will _not_ turn  
>> them off.
>>
>> 1.) This Is current behavior and has not been changed since 0.5.4.  
>> The
>> bug is that bars do not turn on again after '0x0' if the same bar  
>> state
>> is sent again. This will be easy to fix.
>>
>> 2.) This is a change in the meaning of '-1' and '0x0' and will  
>> require
>> applications to be updated to additionally set and clear the bars.
>>
>> I suggest to stay with 1.) and to just reset the  
>> last_output_bar_state
>> upon '-1' or '0x0'.
>
> Yes, I think option 1 is more preferable.
>
> -- 
> Best regards, Yura.
> _______________________________________________
> LCDproc mailing list
> [email protected]
> http://lists.omnipotent.net/mailman/listinfo/lcdproc

_______________________________________________
LCDproc mailing list
[email protected]
http://lists.omnipotent.net/mailman/listinfo/lcdproc
imonlcd_output_allon.patch (application/octet-stream, 1.6 KB)
--- ./server/drivers/imonlcd.orig.c	2011-06-27 00:00:14.000000000 -0700
+++ ./server/drivers/imonlcd.c	2011-10-17 11:37:32.000000000 -0700
@@ -850,7 +850,7 @@
 	uint64_t icon = 0x0;
 
 	/* bit 28 : Abuse this for progress bars. See above for usage. */
-	if (state & IMON_OUTPUT_PBARS_MASK) {
+	if ( state & IMON_OUTPUT_PBARS_MASK || state == 0 ) {
 		if (state != p->last_output_bar_state) {
 			p->last_output_bar_state = state;
 
@@ -868,12 +868,19 @@
 			setLineLength(topLine, botLine, topProgress, botProgress, p);
 
 		}
-		/* Update the icons also. */
-		state = p->last_output_state;
+		/* If the current output state is 'all on' (-1) or 'all off' (0), update
+		 * the icons with that state. Otherwise, update the icons with the last
+		 * icon output state (this is only used to keep the CD spinning).
+		 */
+		if (state != 0 && state != -1 )
+		{
+			state = p->last_output_state;
+		}
 	}
 
 	/* Don't update if no icons need to be changed. */
-	if (state == p->last_output_state && !(state & IMON_OUTPUT_CD_MASK)) {
+	if (state == p->last_output_state && !(state != -1 && (state & IMON_OUTPUT_CD_MASK)))
+	{
 		return;
 	}
 	p->last_output_state = state;
@@ -881,14 +888,6 @@
 	if (state == -1) {	/* the value for "on" in the lcdproc-protocol */
 		icon = (uint64_t) IMON_ICON_ALL;
 		send_command_data(COMMANDS_SET_ICONS | icon, p);
-		setLineLength(32, 32, 32, 32, p);
-		return;
-
-	} else if (state == 0x0) {	/* the value for "off" in the
-					 * lcdproc-protocol */
-		icon = (uint64_t) 0x0;;
-		send_command_data(COMMANDS_SET_ICONS | icon, p);
-		setLineLength(0, 0, 0, 0, p);
 		return;
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.