Sun 19 Mar 2006 12:19:39 AM UTC, original submission:
As written, the four data bits of a HD44780 are restricted to bits 0 - 3. A small change can allow the low bit to be set to anywhere from bit 0 to bit 4 (with the other three bits just above the low bit). The four bits will still be restricted to being consecutive and sequential, but since this is the logical thing to do, it shouldn't be a problem.
The code would need to be changed in two places:
In hd44780_outnibble(), the line:
x = (HD44780_PORTOUT & ~HD44780_DATABITS) | (n & HD44780_DATABITS);
should be changed to:
x = (HD44780_PORTOUT & ~HD44780_DATABITS) | ( (n << HD44780_D4) & HD44780_DATABITS);
and in hd44780_innibble(), the line:
return x & HD44780_DATABITS;
should be changed to:
return x >> HD44780_D4;
It might also be wise to only allow the definition of the low bit, since the others are forced in relation to it anyways. If this is done, then the line:
#define HD44780_DATABITS \
(_BV(HD44780_D4)|_BV(HD44780_D5)|_BV(HD44780_D6)|_BV(HD44780_D7))
would have to be changed appropriately (and possibly some sanity checks).
|