Using a HD44780/1602 character display over i2c

I have a very nice 1602 display with a green backlight, but it (unfortunately) has a PCF8574T module strapped to the back, so I have to port over a driver. I found a seemingly relatively simple one to port and this is my result: GitHub - QOTF-Alexi/TinyCLR_HD44780_i2c
Sadly it doesn’t go past a quick flash of the backlight, followed by an infinitely blinking cursor on the first character though… I’ve spent some time looking at my code, but cannot seem to find where I’m going wrong. Would really appreciate it if someone could steer me into the right direction.

Step in the code to see what line in code caused the backlight on/off

Try this code, you have to add your device, and I2C address.

using System.Threading;
using GHIElectronics.TinyCLR.Devices.I2c;
using GHIElectronics.TinyCLR.Pins;
var controller = I2cController
    .FromName(????device i2c);
var i2c = controller.GetDevice(
    new I2cConnectionSettings(????address, 100_000));
void Send(bool cmd, byte d)
{
    var ba = new byte[] {
        (byte)(cmd == true? 0x80 : 0x40), d };
    i2c.Write(ba);
}
Send(true, 0x20 | 0x08);//func: | 2line
Send(true, 0x0C);//on
Send(true, 0x01);//clear
Send(true, 0x02);//home
Send(false, (byte)'C');
Send(false, (byte)'#');
void Print(string str)
{
    for (int i = 0; i < str.Length; i++)
        //foreach (var c in str)
        Send(false, (byte)str[i]);
}
Send(true, 0x02);//home
Print("I LOVE C#");
void SetCursor(byte row, byte col)
    => Send(true, (byte)(0x80 | row << 6 | col));
int i = 0;
while (true)
{
    SetCursor(1, 0);
    Print(i++.ToString());
    Thread.Sleep(100);
}

Took a while for me to get to it, but I gave it a shot. Now all I get is a blinking backlight and nothing else.

Edit: I did find this, which is for .NET IoT but I don’t think this’ll work right out of the box on a SITCore SBC. I do wonder how difficult it would be to make it work though :thinking:

Blinking backlight should not happen when using Greg’s code. Does it blink if you pause the code? If yes then you do not have sufficient power.

Note that we do not know how your PCF8574T board is wired. The code Greg provided works fine with Gove module.

I’m just feeding it power directly from a FEZ Duino (should’ve clarified, sorry about that) and it worked with another display (just straight from pins instead of an i2c module) before so I doubt that’s the issue. I’m using a screen like this: https://ardushop.ro/473/lcd-display-1602-i2c-adapter.jpg (again, should’ve clarified, but I thought they were all the same)

C# Circuits LCD Hearing Test (youtube.com)