[lcdproc] LEDs

Philip Pokorny ppokorny@penguincomputing.com
Tue, 04 Sep 2001 08:36:04 -0700


Rene Wagner wrote:
> 
> Hi!
> 
> Philip Pokorny wrote:
> 
> >> Is there a way of adding a function to switch the LEDs on/off?
> >
> > You want to look at the "output" function in the LCD driver and the
> > "output" command in the network protocol.
> >
> > Basically, you would pass a value which is interpreted bitwise.  Bit 0
> > controls LED 0, Bit 1 -> LED 1.  If a bit is on, then the LED is turned
> > on, if the bit is off, the LED is turned off.
> 
> OK that's exactly the way the LCD device wants the LEDs to be turned
> on/off.
> I've just modified the driver so that I can control the first 8 LEDs.
> But the device expects two 8bit values. So how do I split one 16bit
> value into two 8bit values?

Bit shifting and masking is commonly used to divide larger quantities
into smaller ones.

  low_8bits = full_16bits & 0xff ;
  high_8bits = (full_16bits >> 8) & 0xff
 
> There also is another problem: Why doesn't LCDd accept 0 as an argument
> for "output"? Of course I can use 256 to turn all LEDs off, but again
> this causes trouble with the last two ones.

The keyword 'off' is equivalent to all bits off (0).  The reason 0 isn't
accepted, is because the error detection logic in the output_func()
function isn't very sophisticated.  It looks for a 0 return value from
strtol and assumes that indicates and unsuccessful conversion.

It shouldn't be too hard to fix output_func to accept 0.  Read up on the
strtol function and the meaning of the second argument to it and see if
you can patch it to make it more intelligent.  Submit a patch when
you're done.

:v)

-- 
Philip Pokorny, Senior Engineer
Tel: 415-358-2635   Fax: 415-358-2646   Toll Free: 888-PENGUIN
PENGUIN COMPUTING - Simplifying the Solution Process [tm]
www.penguincomputing.com


-----------------------------------------------------------
To unsubscribe from this list send a blank message to
lcdproc-unsubscribe@lists.omnipotent.net