Author: jsuijs
Date: Sat Mar 7 09:33:13 2009
New Revision: 834
Added:
trunk/project/
trunk/project/lcd_interface/
trunk/project/lcd_interface/lcd_interface.jal
trunk/sample/test/external/lcd/test_lcd_hd44780_serial.jal
Modified:
trunk/include/external/lcd/lcd_hd44780_serial_sw.jal
trunk/include/jal/jascii.jal
Log:
single pin LCD access is running! (library + application)
Modified: trunk/include/external/lcd/lcd_hd44780_serial_sw.jal
==============================================================================
--- trunk/include/external/lcd/lcd_hd44780_serial_sw.jal (original)
+++ trunk/include/external/lcd/lcd_hd44780_serial_sw.jal Sat Mar 7
09:33:13 2009
@@ -10,7 +10,7 @@
-- Sources:
--
-- Description:
--- Software serial interface for HD44780 compatible alphanumeric LCD
screens.
+-- Software serial interface for HD44780 compatible alphanumeric LCD
screens.
-- --
-- Directions for use of this library in application programs
-- (in this sequence):
@@ -33,6 +33,7 @@
--
-- Dependencies: delay.jal
-- serial_software
+-- lcd_interface.jal - the application that converts serial
to the LCD interface
--
--
-----------------------------------------------------------------------------
@@ -58,7 +59,7 @@
value = value | 0x10
end if
- serial_sw_write(value) -- interrupts are disabled by lib
+ serial_sw_write(value) -- interrupts are disabled by lib
end procedure
--
----------------------------------------------------------------------------
@@ -71,7 +72,7 @@
procedure __lcd_write( byte in value ) is
__lcd_write_nibble(value >> 4) -- write high nibble
__lcd_write_nibble(value) -- write low nibble
- ; delay of 37 us is not required, since each byte takes 170us to transer
+ ; delay of 37 us is not required, since each byte takes 170us to transer
end procedure
--
----------------------------------------------------------------------------
@@ -82,7 +83,7 @@
--
--
----------------------------------------------------------------------------
procedure _lcd_write_data(byte in value) is
- lcd_rs_shadow = high -- select
instruction
+ lcd_rs_shadow = high -- select instruction
__lcd_write( value ) -- output byte
end procedure
--
----------------------------------------------------------------------------
@@ -95,7 +96,7 @@
--
----------------------------------------------------------------------------
procedure _lcd_write_command(byte in value) is
; pragma inline
- lcd_rs_shadow = low -- select instruction
+ lcd_rs_shadow = low -- select instruction
__lcd_write( value ) -- output byte
end procedure
--
----------------------------------------------------------------------------
@@ -110,7 +111,7 @@
procedure lcd_init() is
-- first, init the interface
- lcd_rs_shadow = LOW -- set to control
char mode
+ lcd_rs_shadow = LOW -- set to control char mode
delay_1ms(25) -- power-up delay (> 15 ms)
__lcd_write_nibble(0b0000_0011) -- function set
delay_1ms(5) -- > 4.1 milliseconds
Modified: trunk/include/jal/jascii.jal
==============================================================================
--- trunk/include/jal/jascii.jal (original)
+++ trunk/include/jal/jascii.jal Sat Mar 7 09:33:13 2009
@@ -1,12 +1,17 @@
+--
----------------------------------------------------------------------------
-- Title: Now, initialises time and date in a PIC with an RTC
-- Author: Wouter van Ooijen, Copyright (c) 1998, all rights reserved.
--- Adapted-by:
+-- Adapted-by: Joep Suijs
-- Compiler: >=0.4
--
-- This file is part of jallib (http://jallib.googlecode.com)
-- Released under the ZLIB license
(http://www.opensource.org/licenses/zlib-license.html)
--
--- Description: ascii constants
+-- Description: ascii constants & toupper procedure
+-- --
+-- use of toupper
+-- var byte char = "b" -- assign lower case b to char
+-- toupper(char) -- char now contains "B"
--
const byte ASCII_NULL = 00
@@ -44,3 +49,16 @@
const byte ASCII_SP = 32
const byte ASCII_DEL = 127
+
+--
----------------------------------------------------------------------------
+-- toupper - convert param to upper case
+--
----------------------------------------------------------------------------
+--
----------------------------------------------------------------------------
+procedure toupper(byte in out char) is
+
+ if (char > "z") then return end if
+ if (char < "a") then return end if
+
+ char = char - "a" + "A"
+
+end procedure
\ No newline at end of file
Added: trunk/project/lcd_interface/lcd_interface.jal
==============================================================================
--- (empty file)
+++ trunk/project/lcd_interface/lcd_interface.jal Sat Mar 7 09:33:13 2009
@@ -0,0 +1,63 @@
+--
-----------------------------------------------------------------------------
+-- Title: LCD interface - interfaces to an HD44780 compatible LCDs
+-- Author: Joep Suijs, Copyright (c) 2008..2009, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4g
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the ZLIB license
(http://www.opensource.org/licenses/zlib-license.html)
+--
+-- Sources:
+--
+-- Description:
+-- This is an application that provides alternative interfaces to an
HD44780
+-- compatible LCD. Unlike other interfaces (like 'LCD Serial Backpack'
and K107),
+-- this app is not aware of the HD44780 command set.
+-- The corresponding jallib libraries are given transparent access to
the LCD in
+-- 4-bit mode so all current and future jallib HD44780 functionality is
supported.
+-- --
+-- Currently, only serial comms is supported (57600,8,1)
+-- todo:
+-- - i2c slave interface
+-- - backlight support
+--
-----------------------------------------------------------------------------
+-- lcd_app.jal
+
+include board_16f88_sl
+
+;@jallib use chipdef
+;@jallib use lcd_hd44780_4
+;@jallib use led
+
+enable_digital_io()
+
+;led_direction = output
+
+
+lcd_rs_direction = output
+lcd_en_direction = output
+lcd_dataport_direction = output
+
+include serial_hardware
+serial_hw_init()
+
+include lcd_hd44780_4
+
+-- define input byte & bitfiels
+var volatile byte inchar
+var volatile bit cmdfield at inchar : 5
+var volatile bit*5 datafield at inchar : 0
+
+forever loop
+
+ if (serial_hw_read(inchar) == true) then
+ if (cmdfield == 0) then
+ -- write to display
+ lcd_rs = ((inchar & 0x10) != 0) -- set rs if bit5 is set.
+ __lcd_write_nibble(datafield)
+ elsif (cmdfield == 1) then
+ -- 5 bit pwm value in datafield
+ end if
+ end if
+
+end loop
\ No newline at end of file
Added: trunk/sample/test/external/lcd/test_lcd_hd44780_serial.jal
==============================================================================
--- (empty file)
+++ trunk/sample/test/external/lcd/test_lcd_hd44780_serial.jal Sat Mar 7
09:33:13 2009
@@ -0,0 +1,82 @@
+--
--------------------------------------------------------------------------
+-- Title: Test program for lcd_hd44780_serial.jal (basic / interface test)
+-- Author: Eur Van Andel, Copyright (c) 2008, all rights reserved.
+-- Adapted-by: Rob Hamerling, Joep Suijs
+-- Compiler: >=2.4g
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description:
+-- This sample shows how to setup an LCD and writes
+-- "Hello World" to the first line, using a string and the print library.
+-- Line 3 and line 4 are used as well, but will work properly only on a
4x20 LCD.
+-- A counter is printed to show the running forever loop.
+-- --
+-- This file defines a test for JALLIB testing, using a test-board
+-- defined by a BOARD file .
+--
+-- Sources:
+--
+-- Notes:
+-- setup: an hd44780 compatible display, used in 4-bit mode.
+--
+--
--------------------------------------------------------------------------
+
+;@jallib use chipdef
+;@jallib use lcd_hd44780_serial
+;@jallib use led
+
+-- ok, now setup serial
+;@jallib use serial
+include serial_hardware
+serial_hw_init()
+
+enable_digital_io()
+
+led_direction = output
+
+
+var volatile bit serial_sw_tx_pin is i2c_scl
+i2c_scl_direction = output
+
+include print -- formatted output library
+include lcd_hd44780_serial_sw -- LCD lib with serial interface
+
+for 4 loop -- blink LED 4 times to indicate
startup
+ LED = on
+ delay_100ms(2)
+ LED = off
+ delay_100ms(2)
+end loop
+
+const byte str1[] = "Hello world!" -- define strings
+const byte str2[] = "third line"
+const byte str3[] = "fourth line"
+
+lcd_init() -- initialize LCD
+
+print_string(lcd, str1) -- show hello world!
+lcd_cursor_position(2,0) -- to 3rd line
+print_string(lcd, str2)
+lcd_cursor_position(3,0) -- to 4th line
+print_string(lcd, str3)
+
+var byte counter = 0
+
+forever loop -- loop forever
+
+ counter = counter + 1 -- update counter
+ lcd_cursor_position(1,0) -- second line, first column (0)
+ print_byte_hex(lcd, counter) -- output in hex format
+ delay_100ms(3) -- wait a little
+
+ if counter == 255 then -- counter wrap
+ lcd_cursor_position(1,1) -- 2nd line, 2nd char
+ lcd = " " -- clear 2nd char
+ lcd = " " -- clear 3rd char
+ end if
+
+end loop
+
+
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---