Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Library for nokia 3310 LCD

Status
Not open for further replies.

IGIF16

Junior Member level 2
Joined
Dec 19, 2010
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Frince
Activity points
1,442
hi every one
i'd like to ask about Nokia 3310 LCD library to control it using mikroBASIC Pro
and my Uc is PIC16f877A.
 

hi
i get the library it was written by Anton and it is work very good but i need to write a variable on it like this

rs_temp = ADC_Read(1)
NOK_Out(1,0,"rs_temp")
i need to write the analog input and print it on the Nokia 3310 LCD not the rs_temp
s5aikk.jpg


here is the library

Code:
module NOKIA_3310_LCD_P16
'****************************************************************************'
' Written by ANTON RIECKERT
' anton@riecktron.co.za
' http:'www.riecktron.co.za
' Last updated  : 14 November 2008    - Added support for P16 and P18
'****************************************************************************'


' LCD Initialization
Sub Procedure NOK_Init(Dim Byref port as byte, Dim cs, reset_pin, sclk, dc, sda as byte)
'****************************************************************************
Sub Procedure NOK_Write (Dim datas, mode as byte)
'****************************************************************************'
' Draws a character on screen at current possition
Sub Procedure NOK_Chr(Dim symlcd as Byte)
'****************************************************************************'
' Set the current position for data (0<= x <= 84,  0<= y <= 5)
Sub Procedure NOK_GotoXY(Dim x,y as byte)
'****************************************************************************'
' Inverts Display - Here is still a bug. It only inverst once and doesn't
' want to invert back again
Sub Procedure NOK_Invert
'****************************************************************************'
' Clear the LCD Data memory
Sub Procedure NOK_Clear
'****************************************************************************'
' Writes a string at x, y position (maks 14 char per row)  (0 <= x <= 84 , 0 <= y <= 5)
Sub Procedure NOK_Out(Dim x, y as byte, Dim Byref sentance as char[14])
'****************************************************************************'
' Writes a string at current position
Sub Procedure NOK_Out_CP(Dim Byref sentance as char[14])
'****************************************************************************'[/color]

implements
'****************************************************************************'
const font5x7_1 as byte[230] = (
    0x00, 0x00, 0x00, 0x00, 0x00 ,  ' sp
    0x00, 0x00, 0x2f, 0x00, 0x00 ,  ' !
    0x00, 0x07, 0x00, 0x07, 0x00 ,  ' "
    0x14, 0x7f, 0x14, 0x7f, 0x14 ,  ' #
    0x24, 0x2a, 0x7f, 0x2a, 0x12 ,  ' $
    0xc4, 0xc8, 0x10, 0x26, 0x46 ,  ' %
    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, 0x00, 0x50, 0x30, 0x00 ,  ' ,
    0x10, 0x10, 0x10, 0x10, 0x10 ,  ' -
    0x00, 0x60, 0x60, 0x00, 0x00 ,  ' .
    0x20, 0x10, 0x08, 0x04, 0x02 ,  ' /
    0x3E, 0x51, 0x49, 0x45, 0x3E ,  ' 0
    0x00, 0x42, 0x7F, 0x40, 0x00 ,  ' 1
    0x42, 0x61, 0x51, 0x49, 0x46 ,  ' 2
    0x21, 0x41, 0x45, 0x4B, 0x31 ,  ' 3
    0x18, 0x14, 0x12, 0x7F, 0x10 ,  ' 4
    0x27, 0x45, 0x45, 0x45, 0x39 ,  ' 5
    0x3C, 0x4A, 0x49, 0x49, 0x30 ,  ' 6
    0x01, 0x71, 0x09, 0x05, 0x03 ,  ' 7
    0x36, 0x49, 0x49, 0x49, 0x36 ,  ' 8
    0x06, 0x49, 0x49, 0x29, 0x1E ,  ' 9
    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, 0x59, 0x51, 0x3E ,  ' @
    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

const font5x7_2 as byte[225] = (
    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
    0x00, 0x7F, 0x41, 0x41, 0x00 ,  ' [
    0x55, 0x2A, 0x55, 0x2A, 0x55 ,  ' 55
    0x00, 0x41, 0x41, 0x7F, 0x00 ,  ' ]
    0x04, 0x02, 0x01, 0x02, 0x04 ,  ' ^
    0x40, 0x40, 0x40, 0x40, 0x40 ,  ' _
    0x00, 0x01, 0x02, 0x04, 0x00 ,  ' '
    0x20, 0x54, 0x54, 0x54, 0x78 ,  ' a
    0x7F, 0x48, 0x44, 0x44, 0x38 ,  ' b
    0x38, 0x44, 0x44, 0x44, 0x20 ,  ' c
    0x38, 0x44, 0x44, 0x48, 0x7F ,  ' d
    0x38, 0x54, 0x54, 0x54, 0x18 ,  ' e
    0x08, 0x7E, 0x09, 0x01, 0x02 ,  ' f
    0x0C, 0x52, 0x52, 0x52, 0x3E ,  ' g
    0x7F, 0x08, 0x04, 0x04, 0x78 ,  ' h
    0x00, 0x44, 0x7D, 0x40, 0x00 ,  ' i
    0x20, 0x40, 0x44, 0x3D, 0x00 ,  ' j
    0x7F, 0x10, 0x28, 0x44, 0x00 ,  ' k
    0x00, 0x41, 0x7F, 0x40, 0x00 ,  ' l
    0x7C, 0x04, 0x18, 0x04, 0x78 ,  ' m
    0x7C, 0x08, 0x04, 0x04, 0x78 ,  ' n
    0x38, 0x44, 0x44, 0x44, 0x38 ,  ' o
    0x7C, 0x14, 0x14, 0x14, 0x08 ,  ' p
    0x08, 0x14, 0x14, 0x18, 0x7C ,  ' q
    0x7C, 0x08, 0x04, 0x04, 0x08 ,  ' r
    0x48, 0x54, 0x54, 0x54, 0x20 ,  ' s
    0x04, 0x3F, 0x44, 0x40, 0x20 ,  ' t
    0x3C, 0x40, 0x40, 0x20, 0x7C ,  ' u
    0x1C, 0x20, 0x40, 0x20, 0x1C ,  ' v
    0x3C, 0x40, 0x30, 0x40, 0x3C ,  ' w
    0x44, 0x28, 0x10, 0x28, 0x44 ,  ' x
    0x0C, 0x50, 0x50, 0x50, 0x3C ,  ' y
    0x44, 0x64, 0x54, 0x4C, 0x44)   ' z
'****************************************************************************
dim
     ___NCS,                 ' CS   - Chip Enable
     ___NRES,                ' RES  - Reset Input
     ___NSCLK,               ' SCLK - Serial Clock Input
     ___NDC,                 ' DC   - Data / Command
     ___NSDA   as byte       ' SDA  - Serial Data Input

#IFDEF P18 THEN
  Dim  portaddresse as word
#ELSE
  Dim  portaddresse as byte
#ENDIF
'****************************************************************************
' LCD Initialization
Sub Procedure NOK_Init(Dim Byref port as byte, Dim cs, reset_pin, sclk, dc, sda as byte)

    portaddresse = @port
     ___NCS   = cs
     ___NRES  = reset_pin
     ___NSCLK = sclk
     ___NDC   = dc
     ___NSDA  = sda

#IFDEF P18 THEN
    FSR0H = hi(portaddresse)
    FSR0L = lo(portaddresse)

    ' Set initial status of LCD pins
    ClearBit(INDF0,___NSCLK)          '    SCLK = low
    ClearBit(INDF0,___NSDA)           '    SDA  = low
    ClearBit(INDF0,___NDC)            '    DC   = low
    ClearBit(INDF0,___NCS)            '    CS   = low
    ClearBit(INDF0,___NRES)           '    RES  = low

    ' Toggle LCD reset
    Delay_ms(200)
    ClearBit(INDF0,___NRES)       '     RES = low
    Delay_ms(500)
    SetBit(INDF0,___NRES)         '     RES = high

    SetBit(INDF0,___NCS)         '     CS  = high
#ELSE
    FSRPtr = portaddresse

    ' Set initial status of LCD pins
    ClearBit(INDF,___NSCLK)          '    SCLK = low
    ClearBit(INDF,___NSDA)           '    SDA  = low
    ClearBit(INDF,___NDC)            '    DC   = low
    ClearBit(INDF,___NCS)            '    CS   = low
    ClearBit(INDF,___NRES)           '    RES  = low

    ' Toggle LCD reset
    Delay_ms(200)
    ClearBit(INDF,___NRES)       '     RES = low
    Delay_ms(500)
    SetBit(INDF,___NRES)         '     RES = high

    SetBit(INDF,___NCS)         '     CS  = high
#ENDIF

    NOK_Write(0x21,0)       '     Extended commands
    NOK_Write(0xc5,0)       '     LCD Vop
    NOK_Write(0x06,0)       '     Temp coef
    NOK_Write(0x13,0)       '     LCD Bias 1:48
    NOK_Write(0x20,0)       '     Standard commands
    NOK_Write(0x0c,0)       '     Normal Mode

    ' Clear and position at top of LCD
    NOK_Clear
    NOK_GotoXY(0,0)
End Sub
'****************************************************************************
Sub Procedure NOK_Write (Dim datas, mode as byte)
Dim i, k as byte

#IFDEF P18 THEN
  FSR0H = hi(portaddresse)
  FSR0L = lo(portaddresse)

  ' Pull DC high for DATA or low for COMMAND
  If (TestBit(mode,0) = 1) then SetBit(INDF0,___NDC) End If
  If (TestBit(mode,0) = 0) then ClearBit(INDF0,___NDC) End If

  ClearBit(INDF0,___NCS)   '       CS = low

  ' Clock in 8 bits of data - Highst bit first
  For i = 8 to 1 Step -1
    k = i - 1
    ClearBit(INDF0,___NSCLK)                             ' SCLK = low
    If TestBit(Datas,k) = 0 then ClearBit(INDF0,___NSDA)  ' SDA = low
                           else SetBit(INDF0,___NSDA)    ' SDA = high
    End If
    SetBit(INDF0,___NSCLK)                               ' SCLK = high
  Next i
  SetBit(INDF0,___NCS)     '        CS = high

#ELSE
  FSRPtr = portaddresse

  ' Pull DC high for DATA or low for COMMAND
  If (TestBit(mode,0) = 1) then SetBit(INDF,___NDC) End If
  If (TestBit(mode,0) = 0) then ClearBit(INDF,___NDC) End If

  ClearBit(INDF,___NCS)   '       CS = low

  ' Clock in 8 bits of data - Highst bit first
  For i = 8 to 1 Step -1
    k = i - 1
    ClearBit(INDF,___NSCLK)                             ' SCLK = low
    If TestBit(Datas,k) = 0 then ClearBit(INDF,___NSDA)  ' SDA = low
                           else SetBit(INDF,___NSDA)    ' SDA = high
    End If
    SetBit(INDF,___NSCLK)                               ' SCLK = high
  Next i
  SetBit(INDF,___NCS)     '        CS = high
#ENDIF

End Sub
'****************************************************************************'
' Draws a character on screen at current possition
Sub Procedure NOK_Chr(Dim symlcd as Byte)
Dim l, m as Byte

  NOK_Write(0x00,1)          ' Space between characters

  If (symlcd < 78) then
    For l = 1 to 5
      m = (symlcd - 32)
      m = m * 5
      m = m + l
      m = m - 1
      NOK_Write(Font5x7_1[m],1)
    Next l
  End If

  If (symlcd > 77) then
    symlcd = symlcd - 46
    For l = 1 to 5
      m = (symlcd - 32)
      m = m * 5
      m = m + l
      m = m - 1
      NOK_Write(Font5x7_2[m],1)
    Next l
  End If

End Sub
'****************************************************************************'
' Set the current position for data (0<= x <= 84,  0<= y <= 5)
Sub Procedure NOK_GotoXY(Dim x,y as byte)
Dim n, o as Byte

  n = x
  o = y
  SetBit(n,7)
  SetBit(o,6)
  NOK_Write (o,0)
  NOK_Write (n,0)

End Sub
'****************************************************************************'
' Inverts Display - Here is still a bug. It only inverst once and doesn't
' want to invert back again
Sub Procedure NOK_Invert

  NOK_Write(0x0D,0)

End Sub
'****************************************************************************'
' Clear the LCD Data memory
Sub Procedure NOK_Clear
Dim p, q, r as Byte

#IFDEF P18 THEN
  FSR0H = hi(portaddresse)
  FSR0L = lo(portaddresse)

  ClearBit(INDF0,___NSDA)  ' SDA = low - Data bit is low
  SetBit(INDF0,___NDC)     ' DC = high - Data mode
  ClearBit(INDF0,___NCS)   ' CS = low  - Chip Enable

  For p = 1 to 6           '  for 6 rows
    For q = 1 to 84        '    for 84 colums
      For r = 1 to 8       '   for 8 loop (8 bits)
        ClearBit(INDF0,___NSCLK)   '  SCLK = low  - Serial Clock Input
        SetBit(INDF0,___NSCLK)     '  SCLK = high - Serial Clock Input
      Next r
    Next q
  Next p
  SetBit(INDF0,___NCS)     ' CS = high  - Chip Enable
  NOK_GotoXY(0,0)

#ELSE
  FSRPtr = portaddresse

  ClearBit(INDF,___NSDA)   ' SDA = low - Data bit is low
  SetBit(INDF,___NDC)      ' DC = high - Data mode
  ClearBit(INDF,___NCS)    ' CS = low  - Chip Enable

  For p = 1 to 6           '  for 6 rows
    For q = 1 to 84        '    for 84 colums
      For r = 1 to 8       '   for 8 loop (8 bits)
        ClearBit(INDF,___NSCLK)   '  SCLK = low  - Serial Clock Input
        SetBit(INDF,___NSCLK)     '  SCLK = high - Serial Clock Input
      Next r
    Next q
  Next p
  SetBit(INDF,___NCS)      ' CS = high  - Chip Enable
  NOK_GotoXY(0,0)
#ENDIF

End Sub
'****************************************************************************'
' Writes a string at x, y position (maks 14 char per row)  (0 <= x <= 84 , 0 <= y <= 5)
Sub Procedure NOK_Out(Dim x, y as byte, Dim Byref sentance as char[14])
Dim v as byte

  NOK_GotoXY(x,y)
  For v = 0 to length(sentance) - 1
    NOK_Chr(sentance[v])
  Next v

End Sub
'****************************************************************************'
' Writes a string at current position
Sub Procedure NOK_Out_CP(Dim Byref sentance as char[14])
Dim v as byte

  For v = 0 to length(sentance) - 1
    NOK_Chr(sentance[v])
  Next v

End Sub
'****************************************************************************'

end.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top