Sorry I don't - my laptop hard drive crashed recently so I,ve lost my eagle files - no backup d'ohJoeDaStudd wrote:Hi,
I just found this project. Do you have a wiring diagram as the image is a little small and hard to tell whats going on.
As far as I can well its wire for wire, but I'm not 100% sure and don't want to damage my RasPi or screen.
Thanks,
Joe
Code: Select all
wiringpi.wiringPiSetupSys()
Code: Select all
wiringpi.wiringPiSetupGpio()
Code: Select all
SCLK = 5# gpio pin 18
DIN = 4 # gpio pin 16
DC = 3 # gpio pin 15
RST = 1 # gpio pin 12
LED = 0 # gpio pin 11
Code: Select all
wiringpi.wiringPiSetupSys()
Code: Select all
wiringpi.wiringPiSetup()
Code: Select all
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# code improvements
# 9/10/12
import time
import wiringpi
ROWS = 6
COLUMNS = 14
PIXELS_PER_ROW = 6
ON = 1
OFF = 0
#gpio's :
SCE = 2 # gpio pin 13 = wiringpi no. 2
SCLK = 5 # gpio pin 18 = wiringpi no. 5
DIN = 4 # gpio pin 16 = wiringpi no. 4
DC = 3 # gpio pin 15 = wiringpi no. 3
RST = 0 # gpio pin 11 = wiringpi no. 0
LED = 1 # gpio pin 12 = wiringpi no. 1
FONT = {
' ': [0x00, 0x00, 0x00, 0x00, 0x00],
'!': [0x00, 0x00, 0x5f, 0x00, 0x00],
'"': [0x00, 0x07, 0x00, 0x07, 0x00],
'#': [0x14, 0x7f, 0x14, 0x7f, 0x14],
'$': [0x24, 0x2a, 0x7f, 0x2a, 0x12],
'%': [0x23, 0x13, 0x08, 0x64, 0x62],
'&': [0x36, 0x49, 0x55, 0x22, 0x50],
"'": [0x00, 0x05, 0x03, 0x00, 0x00],
'(': [0x00, 0x1c, 0x22, 0x41, 0x00],
')': [0x00, 0x41, 0x22, 0x1c, 0x00],
'*': [0x14, 0x08, 0x3e, 0x08, 0x14],
'+': [0x08, 0x08, 0x3e, 0x08, 0x08],
',': [0x00, 0x50, 0x30, 0x00, 0x00],
'-': [0x08, 0x08, 0x08, 0x08, 0x08],
'.': [0x00, 0x60, 0x60, 0x00, 0x00],
'/': [0x20, 0x10, 0x08, 0x04, 0x02],
'0': [0x3e, 0x51, 0x49, 0x45, 0x3e],
'1': [0x00, 0x42, 0x7f, 0x40, 0x00],
'2': [0x42, 0x61, 0x51, 0x49, 0x46],
'3': [0x21, 0x41, 0x45, 0x4b, 0x31],
'4': [0x18, 0x14, 0x12, 0x7f, 0x10],
'5': [0x27, 0x45, 0x45, 0x45, 0x39],
'6': [0x3c, 0x4a, 0x49, 0x49, 0x30],
'7': [0x01, 0x71, 0x09, 0x05, 0x03],
'8': [0x36, 0x49, 0x49, 0x49, 0x36],
'9': [0x06, 0x49, 0x49, 0x29, 0x1e],
':': [0x00, 0x36, 0x36, 0x00, 0x00],
';': [0x00, 0x56, 0x36, 0x00, 0x00],
'<': [0x08, 0x14, 0x22, 0x41, 0x00],
'=': [0x14, 0x14, 0x14, 0x14, 0x14],
'>': [0x00, 0x41, 0x22, 0x14, 0x08],
'?': [0x02, 0x01, 0x51, 0x09, 0x06],
'@': [0x32, 0x49, 0x79, 0x41, 0x3e],
'A': [0x7e, 0x11, 0x11, 0x11, 0x7e],
'B': [0x7f, 0x49, 0x49, 0x49, 0x36],
'C': [0x3e, 0x41, 0x41, 0x41, 0x22],
'D': [0x7f, 0x41, 0x41, 0x22, 0x1c],
'E': [0x7f, 0x49, 0x49, 0x49, 0x41],
'F': [0x7f, 0x09, 0x09, 0x09, 0x01],
'G': [0x3e, 0x41, 0x49, 0x49, 0x7a],
'H': [0x7f, 0x08, 0x08, 0x08, 0x7f],
'I': [0x00, 0x41, 0x7f, 0x41, 0x00],
'J': [0x20, 0x40, 0x41, 0x3f, 0x01],
'K': [0x7f, 0x08, 0x14, 0x22, 0x41],
'L': [0x7f, 0x40, 0x40, 0x40, 0x40],
'M': [0x7f, 0x02, 0x0c, 0x02, 0x7f],
'N': [0x7f, 0x04, 0x08, 0x10, 0x7f],
'O': [0x3e, 0x41, 0x41, 0x41, 0x3e],
'P': [0x7f, 0x09, 0x09, 0x09, 0x06],
'Q': [0x3e, 0x41, 0x51, 0x21, 0x5e],
'R': [0x7f, 0x09, 0x19, 0x29, 0x46],
'S': [0x46, 0x49, 0x49, 0x49, 0x31],
'T': [0x01, 0x01, 0x7f, 0x01, 0x01],
'U': [0x3f, 0x40, 0x40, 0x40, 0x3f],
'V': [0x1f, 0x20, 0x40, 0x20, 0x1f],
'W': [0x3f, 0x40, 0x38, 0x40, 0x3f],
'X': [0x63, 0x14, 0x08, 0x14, 0x63],
'Y': [0x07, 0x08, 0x70, 0x08, 0x07],
'Z': [0x61, 0x51, 0x49, 0x45, 0x43],
'[': [0x00, 0x7f, 0x41, 0x41, 0x00],
'\\': [0x02, 0x04, 0x08, 0x10, 0x20],
']': [0x00, 0x41, 0x41, 0x7f, 0x00],
'^': [0x04, 0x02, 0x01, 0x02, 0x04],
'_': [0x40, 0x40, 0x40, 0x40, 0x40],
'`': [0x00, 0x01, 0x02, 0x04, 0x00],
'a': [0x20, 0x54, 0x54, 0x54, 0x78],
'b': [0x7f, 0x48, 0x44, 0x44, 0x38],
'c': [0x38, 0x44, 0x44, 0x44, 0x20],
'd': [0x38, 0x44, 0x44, 0x48, 0x7f],
'e': [0x38, 0x54, 0x54, 0x54, 0x18],
'f': [0x08, 0x7e, 0x09, 0x01, 0x02],
'g': [0x0c, 0x52, 0x52, 0x52, 0x3e],
'h': [0x7f, 0x08, 0x04, 0x04, 0x78],
'i': [0x00, 0x44, 0x7d, 0x40, 0x00],
'j': [0x20, 0x40, 0x44, 0x3d, 0x00],
'k': [0x7f, 0x10, 0x28, 0x44, 0x00],
'l': [0x00, 0x41, 0x7f, 0x40, 0x00],
'm': [0x7c, 0x04, 0x18, 0x04, 0x78],
'n': [0x7c, 0x08, 0x04, 0x04, 0x78],
'o': [0x38, 0x44, 0x44, 0x44, 0x38],
'p': [0x7c, 0x14, 0x14, 0x14, 0x08],
'q': [0x08, 0x14, 0x14, 0x18, 0x7c],
'r': [0x7c, 0x08, 0x04, 0x04, 0x08],
's': [0x48, 0x54, 0x54, 0x54, 0x20],
't': [0x04, 0x3f, 0x44, 0x40, 0x20],
'u': [0x3c, 0x40, 0x40, 0x20, 0x7c],
'v': [0x1c, 0x20, 0x40, 0x20, 0x1c],
'w': [0x3c, 0x40, 0x30, 0x40, 0x3c],
'x': [0x44, 0x28, 0x10, 0x28, 0x44],
'y': [0x0c, 0x50, 0x50, 0x50, 0x3c],
'z': [0x44, 0x64, 0x54, 0x4c, 0x44],
'{': [0x00, 0x08, 0x36, 0x41, 0x00],
'|': [0x00, 0x00, 0x7f, 0x00, 0x00],
'}': [0x00, 0x41, 0x36, 0x08, 0x00],
'~': [0x10, 0x08, 0x08, 0x10, 0x08],
'\x7f': [0x00, 0x7e, 0x42, 0x42, 0x7e],
}
ORIGINAL_CUSTOM = FONT['\x7f']
def bit_reverse(value, width=8):
result = 0
for _ in xrange(width):
result = (result << 1) | (value & 1)
value >>= 1
return result
BITREVERSE = map(bit_reverse, xrange(256))
def setup():
# Set pin directions.
wiringpi.wiringPiSetup()
# wiringpi.wiringPiGpioMode(ON)
for pin in [DIN, SCLK, DC, RST, SCE]:
wiringpi.pinMode(pin, ON)
wiringpi.pinMode(LED,2)
wiringpi.pwmWrite(LED,128)
def SPI(value):
# data = DIN
# clock = SCLK
# MSB first
for i in reversed(xrange(8)):
wiringpi.digitalWrite(DIN, (value >> i) & 1)
wiringpi.digitalWrite(SCLK, ON)
wiringpi.digitalWrite(SCLK, OFF)
def lcd_cmd(value):
wiringpi.digitalWrite(DC, OFF)
SPI(value)
def lcd_data(value):
wiringpi.digitalWrite(DC, ON)
SPI(value)
def gotoxy(x, y):
lcd_cmd(x + 128)
lcd_cmd(y + 64)
def cls():
gotoxy(0, 0)
for _ in xrange(ROWS * COLUMNS * PIXELS_PER_ROW):
lcd_data(0)
def begin(contrast):
setup()
# Toggle RST low to reset.
wiringpi.digitalWrite(SCE, OFF)
wiringpi.digitalWrite(RST, OFF)
wiringpi.digitalWrite(LED, ON)
time.sleep(0.100)
wiringpi.digitalWrite(RST, ON)
# Extended mode, bias, vop, basic mode, non-inverted display.
for value in [0x21, 0x14, contrast, 0x20, 0x0c]:
lcd_cmd(value) # extended mode
cls()
def init():
begin(0xb3)
def led(led_value):
wiringpi.digitalWrite(LED, led_value)
def load_bitmap(filename, reverse=False):
mask = 0xff if reverse else 0x00
gotoxy(0, 0)
with open(filename, 'rb') as bitmap_file:
for x in xrange(6):
for y in xrange(84):
bitmap_file.seek(0x3e + y * 8 + x)
lcd_data(BITREVERSE[ord(bitmap_file.read(1))] ^ mask)
def show_custom(font=FONT):
display_char('\x7f', font)
def define_custom(values):
FONT['\x7f'] = values
def restore_custom():
define_custom(ORIGINAL_CUSTOM)
def alt_custom():
define_custom([0x00, 0x50, 0x3C, 0x52, 0x44])
def pi_custom():
define_custom([0x19, 0x25, 0x5A, 0x25, 0x19])
def display_char(char, font=FONT):
try:
for value in font[char]:
lcd_data(value)
lcd_data(0) # Space inbetween characters.
except KeyError:
pass # Ignore undefined characters.
def text(string, font=FONT):
for char in string:
display_char(char, font)
def gotorc(r, c):
lcd_cmd(c * 6 + 128)
lcd_cmd(r + 64)
def centre_word(r, word):
gotorc(r, max(0, (COLUMNS - len(word)) // 2))
text(word)
def main():
start, end = 32, 116
print 'LCD Display Test: ASCII %d to %d' % (start, end)
start_time = time.time()
init()
led(1)
for i in xrange(start, end + 1):
display_char(chr(i))
finish_time = time.time()
print 'Init, LED on, %d chars, total time = %.2f' % (
end - start, finish_time - start_time
)
print
if __name__ == '__main__':
main()
Code: Select all
TempFile = "/sys/class/thermal/thermal_zone0/temp"
CPUsFile = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"
#
#We get the temp as a 5 digit sting measured in 1000's of a degree C
#we display it as xx.xx ignoring the bottom digit
#
def showtemp(r,c):
with open(TempFile, 'r') as f:
tmp = f.readline()
gotorc(r,c)
if len(tmp) == 6: #this is normal
tmp2 = tmp[0:2]+"."+tmp[2:4]
text(tmp2)
else:
test(tmp)
#
#We get the current cpu speed as a 6 or 7 digit number, the idea being to display it
#as xxx.xMhz or x.xxxGhz
#
def showspeed(r,c):
with open(CPUsFile, 'r') as f:
tmp=f.readline()
gotorc(r,c)
if len(tmp) == 7: #<1Ghz
spd = tmp[0:3]+"."+tmp[3]+"Mhz"
if len(tmp) == 8: #>1Ghz
spd = tmp[0]+"."+tmp[1:4]+"Ghz"
text(spd)
And in main() do
cls()
showtemp(0,0)
showspeed(0,6)
Code: Select all
time.sleep(2)
cls()
gotorc(1,5)
text("Hello")
gotorc(4,3)
text("Boezelman")
gotorc(5,1)
show_custom()
define_custom([1,2,3,4,5])
show_custom()
Code: Select all
cls() = clears the screen?
gotorc = ??
text("") = puts text on line ...
etc.
Thanks for this!RaTTuS wrote:OK this works great ...
now I've added a couple of extra things myself..
it appears that I should use gpio pin 18 unless I control it via a program and I want todliloch wrote:well micro center had 2n3906 pnp transistors .. so I tried that .. now i used physical pin 11 gpio 17 or wiring pi 0 .. I also used a 270 ohm resistor .. because if I did not use a resistor the machine would reset.. but now even when I do sudo gpio mode 0 out and then a write 1 the light stays on ..
I've tried to reverse the transistor thinking maybe the direction was wrong .. but no effect... the wire off the gpio 17 pin goes to the base (middle pin) of the transistor ... so what is going on??
besides the fact that I don't know what I am doing!
for the 22N3906 ...
R1 = Supply Voltage / ( Maximum Current Required / Minimum HFE * 1.3 )
R1 = 3.3 / (.1 / 100 * 1.3)
2538 so a 2k ohm resistor ?
http://www.rason.org/Projects/transwit/transwit.htm
I,m confused - do you have wiringpi for python installed? All of the code in this thread need it, otherwise it will not work.paultnl wrote:Sorry for being a complete noob but can someone please post a simple guide to getting Texys display working. I know I need to install wiringPi but there are several slightly different examples none of which work.
Code: Select all
#!/usr/bin/python
# -*- coding: utf-8 -*-
# using wiringPI GPIO method
# also using PWM on gpio pin 12
# now using wiringpi and not BCM ID method
# this should work with both v1 and v2 Pi boards
import wiringpi
import time
#gpio's :
SCE = 2 # gpio pin 13 = wiringpi no. 2
SCLK = 5 # gpio pin 18 = wiringpi no. 5
DIN = 4 # gpio pin 16 = wiringpi no. 4
DC = 3 # gpio pin 15 = wiringpi no. 3
RST = 0 # gpio pin 11 = wiringpi no. 0
LED = 1 # gpio pin 12 = wiringpi no. 1
font =[
0x7E, 0x11, 0x11, 0x11, 0x7E, # A
0x7F, 0x49, 0x49, 0x49, 0x36, # B
0x3E, 0x41, 0x41, 0x41, 0x22, # C
0x7F, 0x41, 0x41, 0x22, 0x1C, # D
0x7F, 0x49, 0x49, 0x49, 0x41, # E
0x7F, 0x09, 0x09, 0x09, 0x01, # F
0x3E, 0x41, 0x49, 0x49, 0x7A, # G
0x7F, 0x08, 0x08, 0x08, 0x7F, # H
0x00, 0x41, 0x7F, 0x41, 0x00, # I
0x20, 0x40, 0x41, 0x3F, 0x01, # J
0x7F, 0x08, 0x14, 0x22, 0x41, # K
0x7F, 0x40, 0x40, 0x40, 0x40, # L
0x7F, 0x02, 0x0C, 0x02, 0x7F, # M
0x7F, 0x04, 0x08, 0x10, 0x7F, # N
0x3E, 0x41, 0x41, 0x41, 0x3E, # O
0x7F, 0x09, 0x09, 0x09, 0x06, # P
0x3E, 0x41, 0x51, 0x21, 0x5E, # Q
0x7F, 0x09, 0x19, 0x29, 0x46, # R
0x46, 0x49, 0x49, 0x49, 0x31, # S
0x01, 0x01, 0x7F, 0x01, 0x01, # T
0x3F, 0x40, 0x40, 0x40, 0x3F, # U
0x1F, 0x20, 0x40, 0x20, 0x1F, # V
0x3F, 0x40, 0x38, 0x40, 0x3F, # W
0x63, 0x14, 0x08, 0x14, 0x63, # X
0x07, 0x08, 0x70, 0x08, 0x07, # Y
0x61, 0x51, 0x49, 0x45, 0x43, # Z
]
def main():
start = time.time()
begin(0xbc) # contrast - may need tweaking for each display ( b3 )
gotoxy(28,0)
text("TAKE A")
gotoxy(18,2)
text("RASPBERRY")
gotoxy(26,4)
text("PI BYTE!")
finish = time.time()
print ("Total time : ",finish - start)
print
def gotoxy(x,y):
lcd_cmd(x+128)
lcd_cmd(y+64)
def text(words):
for i in range(len(words)):
display_char(words[i])
def display_char(char):
index=(ord(char)-65)*5
if ord(char) >=65 and ord(char) <=90:
for i in range(5):
lcd_data(font[index+i])
lcd_data(0) # space inbetween characters
elif ord(char)==32:
lcd_data(0)
lcd_data(0)
lcd_data(0)
lcd_data(0)
lcd_data(0)
lcd_data(0)
def cls():
gotoxy(0,0)
for i in range(84):
for j in range(6):
lcd_data(0)
def setup():
# set pin directions
wiringpi.wiringPiSetup()
wiringpi.pinMode(SCE, 1) # output
wiringpi.pinMode(DIN, 1) # output
wiringpi.pinMode(SCLK, 1) # output
wiringpi.pinMode(DC, 1) # output
wiringpi.pinMode(RST, 1) # output
wiringpi.pinMode(LED, 2) # LED set up as PWM
print ("setup ok")
wiringpi.pwmWrite(LED, 255)
def begin(contrast):
setup()
# toggle RST low to reset
wiringpi.digitalWrite(SCE, 0)
wiringpi.digitalWrite(RST, 0)
wiringpi.digitalWrite(LED, 0)
time.sleep(0.100)
wiringpi.digitalWrite(RST, 1)
lcd_cmd(0x21) # extended mode
lcd_cmd(0x14) # bias
lcd_cmd(contrast) # vop
lcd_cmd(0x20) # basic mode
lcd_cmd(0xc) # non-inverted display
cls()
def SPI(c):
# data = DIN
# clock = SCLK
# MSB first
# value = c
for i in xrange(8):
wiringpi.digitalWrite(DIN,((c & (1 << (7-i))) > 0))
wiringpi.digitalWrite(SCLK, 1)
wiringpi.digitalWrite(SCLK, 0)
def lcd_cmd(c):
wiringpi.digitalWrite(DC, 0)
SPI(c)
def lcd_data(c):
wiringpi.digitalWrite(DC, 1)
SPI(c)
if __name__ == "__main__":
main()
Code: Select all
[email protected] ~/WiringPi-Python $ python setup.py build
Traceback (most recent call last):
File "setup.py", line 3, in <module>
from setuptools import setup, find_packages, Extension
ImportError: No module named setuptools