Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Oct 2021 08:38:54 -0300
From:      "Dr. Rolf Jansen" <freebsd-rj@obsigna.com>
To:        freebsd-arm@freebsd.org
Subject:   Re: Using 20x4 LCD display
Message-ID:  <031FB1DF-6B2A-4122-AC5B-34E921995284@obsigna.com>
In-Reply-To: <wu7o87h1rhk.fsf@banyan.cs.ait.ac.th>
References:  <wu7o87h1rhk.fsf@banyan.cs.ait.ac.th>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_E0FE9533-D6FE-4CCA-A1C8-D86EA3735A40
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

> Am 22.10.2021 um 03:52 schrieb Olivier <Olivier.Nicole@cs.ait.ac.th>:
>=20
> I would like to use a 20x4 LCD display attached to a Raspberry Pi
> running FreeBSd 12.2.
>=20
> I can talk to the display through the I2C interface, when I send
> something the back light will turn off and on, so the link is
> established.

I use a 20x4 LCD (HD44780 type) over I2C (via PCF8574T) on a BeagleBone =
Black. For this, I manually transcribed one of the many Python libraries =
into plain C, and I wrote a minimalistic I2C glue interface in C, so it =
can be easily addressed.

I just put a .zip file for downloading it on my web site:

  https://obsigna.com/Downloads/LCD_20x4_over_I2C.zip

I added a Hello World test program (s. below). Perhaps you need to =
change the I2C device number and the I2C address in lcd.c. Here I have:

  uint8_t lcd_iicid =3D 1;
  uint8_t lcd_addr  =3D 0x27;

The Python code contained a lot of delays between various calls. This =
was not necessary for the BeagleBone Black, I removed this and it let me =
optimize the subroutines for transferring data to the display. I don=E2=80=
=99t know whether this would work on a Raspberry Pi, though.

Compile it with: cc i2c.c lcd.c hello.c -o hello
Run it with: ./hello

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>

#include "i2c.h"
#include "lcd.h"

int main(int argc, const char *argv[])
{
  lcd_begin();
  lcd_print("Hello, World!", 13);
  lcd_setCursor(0, 1);
  lcd_print("HD44780 over PCF8574", 20);
  lcd_setCursor(0, 2);
  lcd_print("If it does not work,", 20);
  lcd_setCursor(0, 3);
  lcd_print("do not ask me why.", 18);

  return 0;
}

Best regards

Rolf



Dr. Rolf Jansen
- -
Rua Reginaldo de Lima, 98
Parque S=C3=A3o Diogo
09732-550, S=C3=A3o Bernardo do Campo
S=C3=A3o Paulo - Brazil

Phone:	0055-11/4317-0974
Mobile:	0055-11/9 8141-1465
E-Mail:	rj@obsigna.com <mailto:rj@obsigna.com>
BLog:	obsigna.com <https://obsigna.com/>;

--Apple-Mail=_E0FE9533-D6FE-4CCA-A1C8-D86EA3735A40--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?031FB1DF-6B2A-4122-AC5B-34E921995284>