HomeGenie Forum
Automation Program Plugins and Wizard Scripting => Raspberry Pi GPIO/SPI/I2C => Topic started by: [email protected] on December 30, 2015, 11:32:50 AM
-
I'm trying to get a HD44780 working directly off the GPIO as per the sample on github,
However I can't get the configuration object to work, doing at as a dynamic doesn't work as per the PCF8574 example, nor does as per the ConfigurationLoader.cs method.
I get either missing an assembly or reference, or object doesnt contain definition for pins..
const ConnectorPin registerSelectPin = ConnectorPin.P1Pin22;
const ConnectorPin clockPin = ConnectorPin.P1Pin18;
var dataPins = new[]
{
ConnectorPin.P1Pin16,
ConnectorPin.P1Pin15,
ConnectorPin.P1Pin13,
ConnectorPin.P1Pin11
};
//var driver = GpioConnectionSettings.DefaultDriver;
Program.Notify ("LCD","1");
var driver = GpioConnectionSettings.DefaultDriver;
// dynamic configuration = new dynamic();
// configuration.Pins = new Hd44780Pins(
// driver.Out(registerSelectPin),
// driver.Out(clockPin),
// dataPins.Select(p => (IOutputBinaryPin)driver.Out(p)));
var configuration = new Hd44780Configuration
{
Pins = new Hd44780Pins(
driver.Out(registerSelectPin),
driver.Out(clockPin),
dataPins.Select(p => (IOutputBinaryPin)driver.Out(p)))
};
Program.Notify ("LCD","2");
var settings = new Hd44780LcdConnectionSettings
{
ScreenWidth = 40,
ScreenHeight = 4,
};
Program.Notify ("LCD","3");
using (var display = new Hd44780LcdConnection(settings, configuration.Pins))
{
Program.Notify ("LCD","4");
display.SetCustomCharacter(1, new byte[] {0x0, 0x0, 0x04, 0xe, 0x1f, 0x0, 0x0});
display.SetCustomCharacter(2, new byte[] {0x0, 0x0, 0x1f, 0xe, 0x04, 0x0, 0x0});
display.Clear();
display.WriteLine("R# IP Config");
}
// Bodge:
Program.GoBackground();
problem code is between notify for 1 and 2
-
change the code like this:
const ConnectorPin registerSelectPin = ConnectorPin.P1Pin22;
const ConnectorPin clockPin = ConnectorPin.P1Pin18;
var dataPins = new[]
{
ConnectorPin.P1Pin16,
ConnectorPin.P1Pin15,
ConnectorPin.P1Pin13,
ConnectorPin.P1Pin11
};
Program.Notify ("LCD","1");
var driver = GpioConnectionSettings.DefaultDriver;
var configPins = new Hd44780Pins(
driver.Out(registerSelectPin),
driver.Out(clockPin),
dataPins.Select(p => (IOutputBinaryPin)driver.Out(p)));
Program.Notify ("LCD","2");
var settings = new Hd44780LcdConnectionSettings
{
ScreenWidth = 40,
ScreenHeight = 4,
};
Program.Notify ("LCD","3");
using (var display = new Hd44780LcdConnection(settings, configPins))
{
Program.Notify ("LCD","4");
display.SetCustomCharacter(1, new byte[] {0x0, 0x0, 0x04, 0xe, 0x1f, 0x0, 0x0});
display.SetCustomCharacter(2, new byte[] {0x0, 0x0, 0x1f, 0xe, 0x04, 0x0, 0x0});
display.Clear();
display.WriteLine("R# IP Config");
}
// Bodge:
Program.GoBackground();
Cheers,
g.
-
Cheers Gene,
Are you referencing an older version of the Raspberry# Libraries, as looking at the file here: https://github.com/raspberry-sharp/raspberry-sharp-io/blob/master/Raspberry.IO.Components/Displays/Hd44780/Hd44780LcdConnection.cs (https://github.com/raspberry-sharp/raspberry-sharp-io/blob/master/Raspberry.IO.Components/Displays/Hd44780/Hd44780LcdConnection.cs)
it looks like a commit was made to support 4 line displays such as mine (20x4)
private const int MAX_HEIGHT = 4; // Allow for larger displays
private const int MAX_CHAR = 80; // This allows for setups such as 40x2 or a 20x4
when I try 20x4 it throws an error about the row count being higher than 2
(ignore the 40x4 in my example!)
Cheers
David