Hi-
I've been trying to add a NHD-C160100DiZ to my Raspberry Pi. I have interfaced the display using I2C with CSB tied low and RST tied high (always selected, not reset). The I2C bus detect finds the address (0x3F). Using the following program (which I hope is a faithful adaptation of the example code), I get nothing on the screen:
import time
import smbus
bus = smbus.SMBus(1) # Bus declaration
#=============================================================================
# I2C
# I2C communication class
# I2C.write(Dev, Length, Reg, Val) - writes to a device via I2C
# I2C.read(Dev, Length, Reg) - reads from a device via I2C
#
# Dev - Device I2C address, Length - "Block"|"Word"|"Byte"|"None"
# Reg - Register address for device, Val - Value to be set in the Dev/Reg
# http://erazor-zone.de/wiki:linux:python:smbus:doc
# https://www.kernel.org/doc/Documentation/i2c/smbus-protocol
#=============================================================================
class I2C(object):
"""I2C Communication Class"""
#-----------------------------------------------------------------------------
# I2C.write
def write(self, Dev, Length, Reg, Val):
if Length == "Block": # Block - uses addressed reg, array
bus.write_block_data(Dev, Reg, Val)
elif Length == "Word": # Word - uses addressed reg, 16-bit
bus.write_word_data(Dev, Reg, Val)
elif Length == "Byte": # Byte - uses addressed reg, 8-bit
bus.write_byte_data(Dev, Reg, Val)
elif Length == "None": # None - no addressed reg, 8-bit
bus.write_quick(Dev)
return -1
#-----------------------------------------------------------------------------
# I2C.read
def read(self, Dev, Length, Reg):
if Length == "Block": # Block - uses addressed reg, array
value = bus.read_block_data(Dev, Reg)
elif Length == "Word": # Word - uses addressed reg, 16-bit
value = bus.read_word_data(Dev, Reg)
elif Length == "Byte": # Byte - uses addressed reg, 8-bit
value = bus.read_byte_data(Dev, Reg)
elif Length == "None": # None - no addressed reg, 8-bit
value = bus.read_byte(Dev)
return value
#=============================================================================
# Main
RC = [0 for x in range(13)] # Initializes RC
I = I2C()
Adr = 0x3F
Com = 0x00
Dat = 0x40
I.write(Adr, "Block", Com, [0xE2])
I.write(Adr, "Block", Com, [0x48, 0x64, 0xA0, 0xC8, 0x44, 0x00, 0xAB, 0x26, 0x81, 0x15, 0x56, 0x64])
time.sleep(2)
I.write(Adr, "Block", Com, [0x2C, 0x66])
time.sleep(2)
I.write(Adr, "Block", Com, [0x2E])
time.sleep(2)
I.write(Adr, "Block", Com, [0x2F, 0xF3, 0x00, 0x96, 0x38, 0x75, 0x97])
i = 0
j = 0
gs = [0x00, 0x06, 0x0B, 0x10, 0x15, 0x1A, 0x1E, 0x23, 0x27, 0x2B, 0x2F, 0x32, 0x35, 0x38, 0x3A, 0x3C]
for x in range(0x80, 0xC0):
i = i + 1
# print("%02X %02X %02X %02X" % (Adr, Com, x, gs[j]))
I.write(0x3F, "Block", Com, [x, gs[j]])
if (i % 4) == 0:
j = j + 1
I.write(Adr, "Block", Com, [0x38, 0x74, 0xAF])
I.write(Adr, "Block", Dat, [0x26, 0x26, 0x26, 0x26, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x31, 0x31, 0x31, 0x31])
Can anyone please direct me on how to resolve this?
Thanks!