Revision: 1704
Author: jsuijs
Date: Thu Feb 25 06:42:09 2010
Log: add nokia lib to enable bughunt
http://code.google.com/p/jallib/source/detail?r=1704
Added:
/trunk/include/external/lcd/lcd_nokia3310.jal
=======================================
--- /dev/null
+++ /trunk/include/external/lcd/lcd_nokia3310.jal Thu Feb 25 06:42:09 2010
@@ -0,0 +1,286 @@
+--
-----------------------------------------------------------------------------
+-- Title: library for GLCD with pcd8544 controller used in Nokia 3310
+-- Author: Andre Miller Copyright (c) 2008..2010, all rights reserved.
+-- Adapted-by: Richard Zengerink
+-- Compiler: >=2.4n
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the ZLIB license
(http://www.opensource.org/licenses/zlib-license.html)
+--
+-- Sources: http://www.amontec.com/lcd_nokia_3310.shtml
+--
+-- Description: library for Nokia 3310 display with pcd8544 controller
+--
+-- Dependencies: delay.jal
+--
+--
+
+
+include delay
+
+
+const byte FontLookup[] =
+ {
+ 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
+ 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
+ }
+
+
+
+procedure _lcd_write (byte in value) is
+-- Clock in 8 bits of data
+ for 8 loop
+ nok_sclk = low
+ if ( (value & 0x80) == 0 )then
+ nok_sda = low
+ else
+ nok_sda = high
+ end if
+ nok_sclk = high
+ value = value << 1
+ delay_1us -- max dataspeed is 4Mhz so delay for safety
+ end loop
+end procedure
+
+
+-- Write a data byte to the LCD
+procedure _lcd_write_data (byte in value) is
+ nok_dc = high -- d/c line high for data
+ _lcd_write (value)
+end procedure
+
+
+
+-- Write a command byte to the LCD
+procedure _lcd_write_command (byte in value) is
+ nok_dc = low -- d/c line low for command
+ _lcd_write (value)
+ nok_dc = high -- set d/c to data
+end procedure
+
+
+
+
+-- Set the current position for data (x = 0->83, y = 0->5)
+procedure lcd_gotoxy (byte in xnokia, byte in ynokia) is
+ _lcd_write_command ( 0x40 | ( ynokia & 0x07 ))
+ _lcd_write_command ( 0x80 | ( xnokia & 0x7f ))
+end procedure
+
+
+
+
+--Clear the LCD data memory
+procedure lcd_clear_screen() is
+ nok_sda = low ;; Data bit is low
+ nok_dc = high ;; Data mode
+ nok_cs = low
+ for 6 loop -- 6 rows
+ for 84 loop -- 84 columns or 'pages'
+ for 8 loop --Clock for the 8 bits of the 'page'
+ nok_sclk = low
+ nok_sclk = high
+ end loop
+ end loop
+ end loop
+end procedure
+
+-- Send LCD Initialization
+procedure lcd_Init() is
+-- Set initial status of LCD pins
+ nok_sclk = low
+ nok_sda = low
+ nok_dc = low
+ nok_cs = low
+ nok_res = low
+-- Toggle LCD Reset
+ delay_1ms (10)
+ nok_res = low
+ delay_1ms (250)
+ nok_res = high
+-- nok_cs = high
+ _lcd_write_command (0x21) -- Extended commands
+ _lcd_write_command (0xc5) -- LCD Vop
+ _lcd_write_command (0x06) -- Temp coef
+ _lcd_write_command (0x13) -- LCD Bias 1:48
+ _lcd_write_command (0x20) -- Standard commands
+ _lcd_write_command (0x0c) -- Normal Mode
+-- Clear and position at top of LCD
+ lcd_clear_screen()
+ lcd_gotoxy (0,0);
+end procedure
+
+
+
+-- Writes a character to the display
+procedure print_char_5x7 (byte in letter) is
+ var word index = 0
+ var byte offset
+ var byte x
+
+ offset = letter - 32 ;; Fix for ascii value
+
+ for offset loop
+ index = index + 5
+ end loop
+
+ for 5 loop
+ x = FontLookup[index]
+ _lcd_write_data (x)
+ index = index + 1
+ end loop
+
+ _lcd_write_data (0) ; Add blank space between characters
+end procedure
+
+
+
+
+-- Writes an inverted character to the display
+procedure print_char_5x7_i (byte in letter) is
+ var word index = 0
+ var byte offset
+ var byte x
+
+ offset = letter - 32 ;; Fix for ascii value
+
+ for offset loop
+ index = index + 5
+ end loop
+
+ for 5 loop
+ x = FontLookup[index]
+ x = x ^ 0xFF
+ _lcd_write_data (x)
+ index = index + 1
+ end loop
+
+ _lcd_write_data (0xFF) ; Add blank space between characters
+end procedure
+
+
+-- print string to lcd
+-- same idea as print_string in print.jal library only this one works
+-- and with print.jal unfortunately not
+
+procedure char_string_to_nokia( byte in str[]) is
+ var word len = count(str)
+ var byte i
+
+ for len using i loop
+ print_char_5x7 (str[i])
+ end loop
+
+end procedure
+
+-- prints any bitmap graphics (for instance created with fastLCD
+-- http://www.amontec.com/lcd_nokia_3310.shtml) to lcd
+-- just create: const byte graphic[] = { graphic max 504 bytes} and call
+-- graphic_to_nokia( graphic)
+
+procedure graphic_to_nokia( byte in graph[]) is
+ var word len = count(graph)
+ var word i
+
+ for len using i loop
+ _lcd_write_data(graph[i])
+ end loop
+
+end procedure
+
+--
----------------------------------------------------------------------------
+-- lcd'put - write one char to screen (pseudo var, enables streams)
+--
----------------------------------------------------------------------------
+procedure lcd'put(byte in data) is
+; pragma inline -- disabled due to complier bug with inline +
pseudovar/arrays.
+ _lcd_write_data(data)
+end procedure
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.