From nobody Fri Oct 22 08:25:32 2021 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0BD851806D62 for ; Fri, 22 Oct 2021 08:25:36 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HbHV76zzhz3tMj; Fri, 22 Oct 2021 08:25:35 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from [192.168.0.88] (unknown [195.64.148.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: avg/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 7BB592E934; Fri, 22 Oct 2021 08:25:35 +0000 (UTC) (envelope-from avg@FreeBSD.org) To: Olivier , freebsd-arm@freebsd.org References: From: Andriy Gapon Subject: Re: Using 20x4 LCD display Message-ID: <2c56fffe-327b-dd56-fa08-bc013a8881cd@FreeBSD.org> Date: Fri, 22 Oct 2021 11:25:32 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-ThisMailContainsUnwantedMimeParts: N On 22/10/2021 09:52, Olivier wrote: > Hello, > > I would like to use a 20x4 LCD display attached to a Raspberry Pi > running FreeBSd 12.2. > > 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. > > What I cannot find is the sequence of codes to send in order to write a > character on te screen, to move the cursor around, etc. > > All documentation I could find so far relate to Raspbian or Arduino and > are always using high level libraries (I could not find such on FreeBSD, > equivalent to WiringPi). > > Whatever random characters I send to the screen, it persistently shows > alternating empty lines and lines or black boxes. > > Any help pointing me in the right direction will be greatly appreciated. I have a small utility for talking to a character LCD display via gpio. I am not sure about your exact hardware, but typically the I2C interface is just a GPIO-over-I2C (aka an I2C I/O expander). The utility is here: https://github.com/avg-I/gpiolcd It's based on ppilcd utility written for driving such LCDs connected to a parallel port. That utility can be found at share/examples/ppi/ppilcd.c. It uses parallel port ioctl-s for the job. To use my utility you need the LCD to be presented as a gpio device. For that you need a driver for a specific I2C to I/O port expander that you have. In my case it's PCF8574. You can search the internet for information about how HD44780 (and similar) works. https://www.exploreembedded.com/wiki/LCD_16_x_2_Basics http://web.alfredstate.edu/faculty/weimandn/lcd/lcd_addressing/lcd_addressing_index.html https://www.ti.com/product/PCF8574 P.S. In case you also have PCF8574 or compatible, I have a driver for it but I haven't committed it yet. You can find it here: https://github.com/avg-I/freebsd/commit/fb31fe9a933d62c7af96b0ab830b98cbfeed5309 -- Andriy Gapon