cleaned up gpio and device code, implemented dummy/dry run mode
This commit is contained in:
@ -28,12 +28,12 @@ class Pcd8544Device extends Device
|
||||
$this
|
||||
->setName("pcd8544")
|
||||
->setDescription("Philips PCD8544 LCD Display Driver")
|
||||
->addLogicalPin(0, "dc", "data/command")
|
||||
->addLogicalPin(1, "sce", "chip select")
|
||||
->addLogicalPin(2, "scl", "clock")
|
||||
->addLogicalPin(3, "sda", "data")
|
||||
->addLogicalPin(4, "res", "reset")
|
||||
->addLogicalPin(9, "bl", "backlight")
|
||||
->addPin("dc", "data/command")
|
||||
->addPin("sce", "chip select")
|
||||
->addPin("scl", "clock")
|
||||
->addPin("sda", "data")
|
||||
->addPin("res", "reset")
|
||||
->addPin("bl", "backlight")
|
||||
;
|
||||
}
|
||||
|
||||
@ -46,4 +46,70 @@ class Pcd8544Device extends Device
|
||||
{
|
||||
$this->bl->setValue((bool)$state);
|
||||
}
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
$this->lcdInit();
|
||||
}
|
||||
|
||||
public function lcdSend($byte, $command=false)
|
||||
{
|
||||
// assume clk is hi
|
||||
// Enable display controller (active low).
|
||||
$this->sce->setValue(0);
|
||||
|
||||
$this->dc->setValue((int)$command); // command or data
|
||||
|
||||
$this->shiftOut($this->sda, $this->scl, $byte);
|
||||
|
||||
// Disable display controller.
|
||||
$this->sce->setValue(1);
|
||||
|
||||
/*
|
||||
if (!$command) {
|
||||
$this->cx++;
|
||||
if ($this->cx > (LCD_X_RES - 1)) {
|
||||
cx = 0; cy++;
|
||||
#ifdef PCD8544_FIX_YALIGN
|
||||
// Soft wrapping when FIX_YALIGN is defined
|
||||
lcd_cursor(cx,cy);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public function lcdInit()
|
||||
{
|
||||
$this->sce->setDirection("out");
|
||||
$this->res->setDirection("out");
|
||||
$this->dc->setDirection("out");
|
||||
$this->scl->setDirection("out");
|
||||
$this->sda->setDirection("out");
|
||||
|
||||
$this->res->setValue(1); // set RES
|
||||
$this->sce->setValue(0); // reset SCE
|
||||
$this->res->setValue(0); // pull RES low
|
||||
$this->res->setValue(0); // and back hick
|
||||
|
||||
|
||||
// Send sequence of command
|
||||
$this->lcdSend( 0x21, true ); // LCD Extended Commands.
|
||||
// lcd_send( 0xC8, true ); // Set LCD Vop (Contrast).
|
||||
$this->lcdSend( 0x80 | 0x70, true ); // Set LCD Vop (Contrast).
|
||||
$this->lcdSend( 0x06, true ); // Set Temp coefficent to 2.
|
||||
$this->lcdSend( 0x13, true ); // LCD bias mode 1:100.
|
||||
#ifdef PCD8544_FIX_YALIGN
|
||||
$this->lcdSend( 0x45, true ); // LCD blank - Shift LCD 5 up (row starts at 1)
|
||||
#endif
|
||||
$this->lcdSend( 0x20, true ); // LCD Standard Commands, Horizontal addressing mode.
|
||||
$this->lcdSend( 0x40, true ); // LCD blank
|
||||
$this->lcdSend( 0x08, true ); // LCD blank
|
||||
$this->lcdSend( 0x0C, true ); // LCD in inverse mode.
|
||||
|
||||
//$this->lcdClear();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user