MJG300
Posts: 1
Joined: Fri Jul 05, 2019 3:05 pm

cursor_position problem

Fri Jul 05, 2019 3:31 pm

Hello Everyone,
Beginner programmer here. I have a problem that maybe someone can help with. I have a raspberry pi 2 B+ with an Adafruit lcd backpack w/ a 20 x 4 display. I have it working but I would like to display things in a nice and orderly fashion. I have read about the cursor_position command, but I can not get this function to work. I have seen all (and I do mean ALL of their documentation) and cannot find an example of this command.
I have posted this on Adafruit's forum but nobody has given a response yet. If anyone sees a problem with my sample program, please let me know.

Thank you
Mark

The following test code still displays both numbers in the home position(0,0).

import time
import board
import busio
import adafruit_character_lcd.character_lcd_i2c as character_lcd

lcd_column = 20
lcd_row = 4

i2c = busio.I2C(board.SCL, board.SDA)

lcd = character_lcd.Character_LCD_I2C(i2c, lcd_column, lcd_row)

lcd.backlight = True
lcd.home()

lcd.message ='1'

time.sleep(1)

lcd.clear()

time.sleep(1)

lcd.cursor_position(5,2)
lcd.message='2'

time.sleep(1)

ghp
Posts: 1393
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: cursor_position problem

Fri Jul 05, 2019 6:42 pm

Hello, the adafruit sources are on github. There is an embedded sample in https://github.com/adafruit/Adafruit_Ci ... ter_lcd.py, line 228. The truth lies in the code... hopefully.

Code: Select all

           import time
            import board
            import busio
            import adafruit_character_lcd.character_lcd_i2c as character_lcd
            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)
            lcd.cursor = True
            lcd.message = "Cursor! "
            time.sleep(5)

Return to “Python”