more G-Labs products

Author Topic: Raspberry#  (Read 1494 times)

December 30, 2015, 11:32:50 AM
Read 1494 times

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
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..

Code: [Select]
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

December 30, 2015, 12:08:48 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
change the code like this:

Code: [Select]
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.

December 30, 2015, 02:17:47 PM
Reply #2

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
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

it looks like a commit was made to support 4 line displays such as mine (20x4)

Code: [Select]
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