Page 4 of 11

Re: Nokia Pi LCD

Posted: Tue Dec 11, 2012 9:43 pm
by texy
Hi RaTTuS,
Oops. Yes I can, but too late for tonight.
Remind me if it doesn't appear in the next few days, I've a few displays to build....

Texy

Re: Nokia Pi LCD

Posted: Fri Dec 14, 2012 9:26 am
by RaTTuS
/me pokes texy ;-p

Re: Nokia Pi LCD

Posted: Fri Dec 14, 2012 10:04 am
by texy
Weekend job now, sorry. Although you should be able to work things out from the program listing. You could be asking about the backlight driving circuitry ;)

Texy

Re: Nokia Pi LCD

Posted: Fri Dec 14, 2012 10:06 am
by RaTTuS
no worries,

I was just going to build my own version ....

Re: Nokia Pi LCD

Posted: Fri Dec 14, 2012 10:14 am
by texy
I can sell some more to you ;-)

Texy

Re: Nokia Pi LCD

Posted: Fri Dec 14, 2012 11:28 am
by RaTTuS
well if you make them connect directly ontop of the GPIO without a cable top toward the HDMI with a 90deg female gpio extender then I'll take you up on the offer [well the 90Deg female option would be good but not necessary] :D

Re: Nokia Pi LCD

Posted: Fri Dec 14, 2012 12:52 pm
by texy
It has crossed my mind to do that, or have that option. It would also make it easier to produce.
Maybe a holiday project for me. Are the measurements critical?
Texy

Re: Nokia Pi LCD

Posted: Sat Dec 15, 2012 8:35 am
by RaTTuS
as long as it's mainly inside the RPi foot print ...

Re: Nokia Pi LCD

Posted: Sun Dec 16, 2012 10:19 am
by Rusakko
Is it possible to show picture on the screen, not just text?
Maybe with some black and white image file or just turnin pixel by pixel black or white from like txt file or some other way.

Re: Nokia Pi LCD

Posted: Sun Dec 16, 2012 10:44 am
by tzj
In the newer python code there are a few lines that allow you to load a bitmap image. Just use the variable in the main section.

Re: Nokia Pi LCD

Posted: Wed Dec 19, 2012 8:16 pm
by texy
Rusakko wrote:Is it possible to show picture on the screen, not just text?
Maybe with some black and white image file or just turnin pixel by pixel black or white from like txt file or some other way.
Here is some code that will display a bitmap image. You can create the image in Paint for windows, making the size 48 x 84 pixels and saving it as a monochrome bitmap. Here is an example :
Image
You'll need to save this on your Pi in the same directory as the following program, making sure the full filename of the bitmap is the same as in your program, in this case rasp.bmp :

Code: Select all

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# by Texy and the raspberry pi community 
# bitmap display routine by POSitality
#  19/12/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']

bitreverse =[
  0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, 
  0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, 
  0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, 
  0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, 
  0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, 
  0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,
  0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, 
  0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,
  0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
  0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, 
  0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
  0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
  0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, 
  0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
  0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, 
  0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
]


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


def led(led_value):
  wiringpi.digitalWrite(LED, led_value)


def load_bitmap(file):
  gotoxy(0,0)
  f = open(file,'r')
  for x in range(6):
    for y in range(84):
      f.seek(0x3e + y*8 + x)
      b = ord(f.read(1))
      rev = bitreverse[b]
      lcd_data(rev ^ 0xff)
  f.close()


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)
  load_bitmap('rasp.bmp')    # change this to the filename you want to load. Note it needs to be a 84 high x 48 wide, monochrome bitmap file.
  finish_time = time.time()
  print 'Init, LED on, %d chars, total time = %.2f' % (
    end - start, finish_time - start_time
    )
  print


if __name__ == '__main__':
  main()
Hope this helps,
Texy

Re: Nokia Pi LCD

Posted: Wed Dec 19, 2012 8:27 pm
by Rusakko
Thanks
I still waiting for my lcd, but it's nice to know that pictures are possible. Hopefully i can start my project soon and maybe post result here too.

Re: Nokia Pi LCD

Posted: Thu Jan 10, 2013 6:30 pm
by texy
RaTTuS wrote:as long as it's mainly inside the RPi foot print ...
Image

Ignore the fact that the holes aren't in the right place. This is the first draft of a 'nokia shield' add on board. It will fit directly on the Pi's GPIO port, no ribbon cable in between. It has an expansion breakout port for the GPIO lines not used by the Nokia display. It will also have 5 switches fitted. They utilise the Pi's internal pull-up resistors, so if you don't want to use them, the 5 GPIO lines are still available via the expansion port. It is 75mm wide and 50mm high, so it sits on top of the composite video, audio jack connectors and ethernet connector, but does not hit the USB connector.
Open to suggestions on changes or improvements ;)

Texy

Re: Nokia Pi LCD

Posted: Fri Jan 11, 2013 11:07 am
by RaTTuS
Awesome !!
if you make it so that the top is on the HDMI side I'll be happy ;-p

Re: Nokia Pi LCD

Posted: Fri Jan 11, 2013 12:02 pm
by texy
I believe it is, but will double check ;-)
T.

Re: Nokia Pi LCD

Posted: Mon Jan 14, 2013 12:54 pm
by texy
PCB's ordered ;)
I,ve moved the backlight resistor and tranny to the other side of the board and also now on the bottom rather than the top. I think they will miss the HDMI port :)
I,d like to get away from the Nokia style LCD and go for something with a higher pixel count.......at the right price.

Texy

Re: Nokia Pi LCD

Posted: Mon Jan 14, 2013 3:25 pm
by tzj
A mini tft would be awesome.

Re: Nokia Pi LCD

Posted: Tue Jan 15, 2013 9:48 am
by RaTTuS
umm
I think all the higher resolution ones are 5V .... so addition hardware would be needed ...
umm
http://www.ebay.co.uk/itm/ST7920-Contro ... 1c29d30ecf
http://www.ebay.co.uk/itm/Graphic-ST756 ... 5899af35f1
http://www.ebay.co.uk/itm/0-96-128X64-O ... 2a24b0051f
http://www.ebay.co.uk/itm/12864-128x64- ... 4d026f2d32

are a few that pop up in my searches .. some say 3V

Re: Nokia Pi LCD

Posted: Tue Jan 15, 2013 12:29 pm
by texy
RaTTuS wrote:umm
I think all the higher resolution ones are 5V .... so addition hardware would be needed ...
umm
http://www.ebay.co.uk/itm/ST7920-Contro ... 1c29d30ecf
http://www.ebay.co.uk/itm/Graphic-ST756 ... 5899af35f1
http://www.ebay.co.uk/itm/0-96-128X64-O ... 2a24b0051f
http://www.ebay.co.uk/itm/12864-128x64- ... 4d026f2d32

are a few that pop up in my searches .. some say 3V
Yes, I've had a good look at eBay for displays, but not found the perfect one yet at the right price. I think anything ST7565 based is good as its a 3v3 device.
That OLED looks good, is 3v3 tolerant, has a nice price, but its very small.
The ST7565 as used by the OP in this thread is ideal :
http://www.raspberrypi.org/phpBB3/viewt ... 32&t=25029
..and if I could buy them for the $2.50 as quoted by him then it would be perfect, rather than the £17 quoted by the locals.
The search continues.......
Texy

Re: Nokia Pi LCD

Posted: Tue Jan 15, 2013 3:47 pm
by Rusakko
So i got my lcd today
Is it ok if i solder all lines in different pins and change the code accordingly. Like from pins 19 to 26. I have other stuff in the pins 12-18.
Should the ground be soldered to ground pin, like 25.

So like this:
Rst pin 19
Ce pin 21
Dc pin 22
Din pin 23
Clk pin 24
Vcc nothing?
Light pin 26, do i need resistor for that
Gnd pin 25?

Re: Nokia Pi LCD

Posted: Tue Jan 15, 2013 5:19 pm
by bgreat
In case you want to use SPI instead of bit banging the communication, I would use the following pins:

CE -- pin 24 (SPI_CE0) or pin 26 (SPI_CE1)
DIN -- pin 19 (SPI_MOSI)
CLK -- pin 23 (SPI_SCLK)
LED -- pin 12 (PWM0) to allow varying the brightness, otherwise any free GPIO
RST -- pin 8, otherwise any free GPIO
DC -- pin 10, otherwise any free GPIO
VCC -- pin 1 (3v3)
GND -- whichever pin is convenient

Update the LCD interface code you are using to reflect your pin choices and it should work fine. You can use the bit bang communication even when connected the standard SPI pins (just don't load/open spidev interface).

The LED pin will require a current limiting resistor at a minimum. If you use the PWM, then I recommend using either a FET or transistor to buffer the LED drive. If you want the LED always on, you can just use a resistor to GND sized to the brightness level you desire.

I am using the SPI interface via spidev for a relative fast interface with lower CPU load. I can get 30-100 updates per second depending on what I am displaying. Kind of silly to go over 30 fps since the LCD physical response is so slow.

Enjoy!
Bill

Re: Nokia Pi LCD

Posted: Tue Jan 15, 2013 5:40 pm
by tzj
Thanks bill, any advancement that reduces load is great in my book :)

Re: Nokia Pi LCD

Posted: Tue Jan 15, 2013 5:57 pm
by texy
FYI the displays I use have on board current limiting resistor for the backlight led.
Texy

Re: Nokia Pi LCD

Posted: Tue Jan 15, 2013 6:02 pm
by Rusakko
Great success!
Thank you. First text appeared on LCD. Next I have to implement something real use for it. And mount it to box. I'll be back when I have something more to show.

Re: Nokia Pi LCD

Posted: Tue Jan 15, 2013 8:48 pm
by alexeames
bgreat wrote:I am using the SPI interface via spidev for a relative fast interface with lower CPU load. I can get 30-100 updates per second depending on what I am displaying. Kind of silly to go over 30 fps since the LCD physical response is so slow.
Are you using this one Bill?
https://github.com/doceme/py-spidev

I've used it to read ADCs and Write to a DAC. Works well, but the documentation was a little sparse :lol: