Nokia Pi LCD


251 posts   Page 2 of 11   1, 2, 3, 4, 5 ... 11
by sneakervdv » Fri Aug 24, 2012 8:07 am
I already tried with delay after the last print, but the screen was still empty.

I will rewire to 3v3 and try with that, and I will also disconnect the led to see if that makes any difference. I also have played around with the contrast value to no differ. My Pi is with standard clock.

Last night I tried the code maybe 30-40 times and at one point I tried to set the screen to invert. One run, that was no different from others, I could see little bit darker square in the screen that covered maybe 90% of the display, but I couldn't replicate that anymore.

Very weird, maybe faulty lcd?

Thanks for helping!
Posts: 2
Joined: Thu Aug 23, 2012 8:11 pm
by texy » Thu Sep 06, 2012 6:31 am
So did you end up getting this to work?

Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2210
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by JoeDaStudd » Tue Sep 18, 2012 7:59 am
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
Posts: 271
Joined: Fri Jan 27, 2012 1:34 pm
by texy » Wed Sep 19, 2012 6:42 am
JoeDaStudd 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


Sorry I don't - my laptop hard drive crashed recently so I,ve lost my eagle files - no backup d'oh :roll: . However you should be able to tell the wiring from the program listing. Remember that the LCD is a 3v3 device.
Cheers,
Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2210
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by JoeDaStudd » Wed Sep 19, 2012 8:49 am
Thanks, so no resistors or anything else just plug the 6 leads (4 documented ones in the script and power+ground) then run the script.
Sounds too easy :P
I'll have to try it tonight.

ps the SCE pin isn't used?
Posts: 271
Joined: Fri Jan 27, 2012 1:34 pm
by texy » Wed Sep 19, 2012 9:02 am
You'll only need resistors if you drive the backlight led.
I did this via a MOSFET. The SCE can go to GND.
Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2210
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by RaTTuS » Tue Oct 09, 2012 10:03 am
\o/
working....
ordered lasting thing on Friday
arrived 1st thing Monday [while I was at work - with my RPi which did not get home] so Tusday plugged it all in ....
things to get it working
sudo apt-get install git-core python-dev python-setup-tools build-essential -y
git clone https://github.com/WiringPi/WiringPi-Python.git
cd WiringPi-Python
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
edit setup.py and change
WiringPi to wiringPi
edit wiringpi_wrap.c and change
WiringPi to wiringPi
python setup.py build
sudo python setup.py install

run the above script and it works
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX - Prosliver FTW
"That's not right, the badgers have moved the goalposts."
User avatar
Posts: 4166
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by texy » Tue Oct 09, 2012 12:25 pm
Good stuff - thanks for the details installation for wiringpi. I think there is another way using 'pip' - see the wiringpi thread.
Note that the SCE line is not mentioned in my code, when it should be. As it defaults to an input, it is effectively low anyway (which it needs to be to write to the LCD), but it does need adding to the code. I am at work at the moment, but from memory, SCE is connected to GPIO21 (BCM). This can cause a problem for the new Pi v2 boards because the pin used becomes GPIO27, not GPIO21. However wiringpi should be able to deal with that automaticallly, but only if I use the 'wiringpi' pin labeling method, which my code above does not currently use (it uses BCM nomenclature). I will post a new version of the code later.
...or to put it another way I should use
Code: Select all
wiringpi.wiringPiSetupSys()
instead of
Code: Select all
wiringpi.wiringPiSetupGpio()

and the I/O lines should be

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



Then I,ll need to get a v2 Pi to prove it. Or ask someone with a v2 Pi to prove the theory.
Cheers,
Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2210
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by texy » Tue Oct 09, 2012 5:53 pm
Actually its not
Code: Select all
wiringpi.wiringPiSetupSys()


..but
Code: Select all
wiringpi.wiringPiSetup()



Here is a full dump of the program using many of the code snippet improvements suggested by people much cleverer than me in this thread ;) :

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()


Thanks again to all of those who have contributed.

Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2210
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by RaTTuS » Thu Oct 11, 2012 11:41 am
OK this works great ...
now I've added a couple of extra things myself..
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)


I also do a
wiringpi.pwmWrite(LED,OFF)
at the end to switch off the LCD light
and altered my contrast value to be 0xbb - made this a value at the top of the file actually...
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX - Prosliver FTW
"That's not right, the badgers have moved the goalposts."
User avatar
Posts: 4166
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by texy » Thu Oct 11, 2012 11:51 am
Glad you found it useful RaTTuS. I found the displays needed either 0xb3 or 0xbc generally.
PS maybe 'OFF' is the same as '0' for the pmw.
Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2210
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by Boezelman » Thu Oct 11, 2012 3:45 pm
I bought a LCD of Ebay (€ 1,20) and hooked it up to my Pi.
When I run the script the display fills with al the characters & symbols so I guess it works :)

But... How do I display custom text and info on the LCD? :oops:

With my old 16x2 LCD it was something like:
[code]
lcd.lcd_puts('place text/or info here' ,1) #line 1
lcd.lcd_puts('and here' ,2) #line 2
etc.
[/code]
Posts: 40
Joined: Sun Aug 05, 2012 3:25 pm
by texy » Thu Oct 11, 2012 4:52 pm
Here is an example :


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()


Add the above code to the program after the loop in main.
BTW, can you show me the ebay link to the €1,20 LCD ??
Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2210
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by Boezelman » Thu Oct 11, 2012 7:06 pm
Thanks for the reply!
Can you epxplain what the code does?
Code: Select all
cls() = clears the screen?
gotorc = ??
text("") = puts text on line ...
etc.


I bought them in a larger order, so the price on Ebay is a bit higher but still very cheap.
Link to Ebay
Posts: 40
Joined: Sun Aug 05, 2012 3:25 pm
by texy » Thu Oct 11, 2012 7:52 pm
Hi,
CLS - yes, clears the screen by setting all pixels to '0'
gotorc - this moves the cursor to row, r and column c
Text - yes, print text at current cursor position

Hope this helps,
Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2210
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by Boezelman » Sat Oct 13, 2012 9:06 pm
RaTTuS wrote:OK this works great ...
now I've added a couple of extra things myself..


Thanks for this!
I've changed
"spd = tmp[0]+"."+tmp[1:4]+"Ghz"
to
"spd = tmp[0]+"."+tmp[2:[4]+"Ghz"
So that the LCD show 1,0Ghz

I also added a show IP adres from a old 16x2 LCD program I had.
The only thing missing (and I can't get to work) is date / time info.

Do you have any idea how to show "datetime.now() + .strftime" in the LCD?
Posts: 40
Joined: Sun Aug 05, 2012 3:25 pm
by dliloch » Mon Nov 05, 2012 1:00 pm
hello,
yesterday I saw the nokia pi lcd for sale @$11 in micro center . so I bought it .. I have not been disappointed .. very easy to install even for a complete noob like me .. I am using it to run my
pi headless .. and when it comes up it can now display its IP address and the time..
I have two questions..
1) I can tie the led pin to the 3.3 volt line and it lights up .. is there a way to control the led
via my python program?
2) the time is my last time the machine was shut down.. I have my script come up via init.d
defaults 19
and I put a 5 second wait in.. will increasing the sleep time eventually catch the clock after
it has synced?

thanks again ..
User avatar
Posts: 110
Joined: Wed Jun 27, 2012 6:28 pm
Location: cleveland, ohio usa
by texy » Mon Nov 05, 2012 1:27 pm
Hi,
regarding controlling the backlight, yes this can be done. I did it using a 2n7000 mosfet and is controlled via the Pi's hardware pwm capable GPIO pin.
Code is here :

viewtopic.php?f=32&t=9814&start=25#p190918

Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2210
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by dliloch » Tue Nov 06, 2012 11:31 am
ok so I go to my local radio shack and try to purchase a 2n7000 but they have nothing like that or
even a substitute part! so I look online and they are 8cents but of course $5-6 shipping!
my question is this.. now remember I am a complete noob in this area.. I have tons of old outdated circuit boards that I have been pulling off leds and other parts from .. to practice my soldering .. I've started to look them up where possible .. lots of things packaged in to-92 format but most of them are
for voltage regulation on old power supplies ..
so my question is there a fairly common chip that I would find on my old boards that I could use for
the 2n7000? do you have to use all of the functions of the chip? for example on a broken ethernet switch I found an ap30463 which does far more than the 2n7000 but could I just use 3 of the 6 leads?
thanks...
User avatar
Posts: 110
Joined: Wed Jun 27, 2012 6:28 pm
Location: cleveland, ohio usa
by dliloch » Wed Nov 07, 2012 3:44 am
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
User avatar
Posts: 110
Joined: Wed Jun 27, 2012 6:28 pm
Location: cleveland, ohio usa
by dliloch » Wed Nov 07, 2012 11:22 am
dliloch 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

it appears that I should use gpio pin 18 unless I control it via a program and I want to
use the gpio commands
but.. gpio -g mode 18 pwm blanks the screen ..
maybe I need to go out and get a 2k resistor?
I was expecting this to work like gordon's simple led experiment .. but maybe the leds on the
display operate differently..
User avatar
Posts: 110
Joined: Wed Jun 27, 2012 6:28 pm
Location: cleveland, ohio usa
by paultnl » Wed Nov 07, 2012 4:31 pm
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.
I don't like Russian dolls, they are so full of themselves
Posts: 93
Joined: Fri Oct 12, 2012 6:25 pm
Location: Cambridge
by BillyBag2 » Wed Nov 07, 2012 4:50 pm
I wrote some code for this device. It wrote to SPI device as a stream and also controlled the GPIO. You have to be careful to flush all SPI before changing the GPIO. If you do not flush you are still sending old data to the new new GPIO setting. If you remember the GPIO state then it is quickest to only flush the SPI stream just before the GPIO state actually changes. Do not flush between each data message or between each command message, only flush just before switching from data to command or switching from command to data. I used the Pi 3v3 supply and it worked OK for me. No back light. It should be good for displaying IP addess on a headless system. Also ideal for working outside in daylight where a standard screen would struggle. I think placed on a white background it may not need a backlight for well lit rooms or outside.
Pi N Chips - pinchips.blogspot.co.uk
User avatar
Posts: 32
Joined: Fri Jun 15, 2012 7:11 am
by texy » Wed Nov 07, 2012 7:06 pm
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.


I,m confused - do you have wiringpi for python installed? All of the code in this thread need it, otherwise it will not work.
This code displays a message on the screen :

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()


For help installing wiringpi for python, see this page :
http://blogs.foomatic.org/blink-away-the-tears/
alternatively here :
viewtopic.php?f=32&t=10010&start=100#p159384

Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2210
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by paultnl » Wed Nov 07, 2012 8:32 pm
Texy

Sorry I didn't make it clear, the problem is installing wiringpi
The first link that you gave http://blogs.foomatic.org/blink-away-the-tears/
Gives the following error when you get to Step 3
Code: Select all
pi@raspberrypi ~/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


The second link [url]viewtopic.php?f=32&t=10010&start=100#p159384[/url] is a long and confusing discussion that will take some time to work out.

If there is not a simple and up to date installation guide, I will muddle through (with guidance) and try to write one when I have got it working but I do not want to reinvent the wheel if it has already been done.
I don't like Russian dolls, they are so full of themselves
Posts: 93
Joined: Fri Oct 12, 2012 6:25 pm
Location: Cambridge