My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
-- ------------------------------------------------------
-- Title: Test program for lcd_hd44780_4.jal
-- Author: Eur Van Andel, Copyright (c) 2008, all rights reserved.
-- Adapted-by: Rob Hamerling, Joep Suijs
-- Compiler: >=2.4g
-- Revision: $Revision$
--
-- 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.
--
-- --------------------------------------------------------------------------
--
-- This file has been generated on Sun Jan 25 12:30:33 2009, from:
-- * board: board_16f88_sl.jal
-- * test : test_lcd_hd44780_4.jal
--


;@jallib section chipdef
-- chip setup
include 16f88

;--
-- We'll use internal oscillator. It work @ 8MHz
pragma target clock 8_000_000
pragma target OSC INTOSC_NOCLKOUT
-- Specify no postscaler, ie. really runs @8MHz
OSCCON_IRCF = 0b_111
pragma target WDT disabled -- no watchdog
pragma target LVP disabled -- no low-voltage programming
pragma target CCP1MUX RB0 -- ccp1 pin on B0
pragma bootloader long_start -- for TinyBootloader

;@jallib section lcd_hd44780_4
-- LCD IO definition
var bit lcd_rs is pin_a6 -- LCD command/data select.
var bit lcd_rs_direction is pin_a6_direction
var bit lcd_en is pin_a7 -- LCD data trigger
var bit lcd_en_direction is pin_a7_direction

var byte lcd_dataport is porta_low -- LCD data port
var byte lcd_dataport_direction is porta_low_direction
const byte LCD_ROWS = 4 -- 4 lines
const byte LCD_CHARS = 20 -- 20 chars per line
;@jallib section led
-- LED IO definition
var bit led is pin_b3
var bit led_direction is pin_b3_direction
var bit led2 is pin_b1
var bit led2_direction is pin_b1_direction

enable_digital_io()

led_direction = output


lcd_rs_direction = output
lcd_en_direction = output
lcd_dataport_direction = output

include lcd_hd44780_4 -- LCD library with 4 data lines
include print -- formatted output library

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


Change log

r2760 by sebastien.lelong on Jul 31, 2011   Diff
added Revision: field + svn:keywords
Revision property on all existing *.jal
files. Also add to normalize EOL chars to
avoid mixed ones
Go to: 
Project members, sign in to write a code review

Older revisions

r1342 by sebastien.lelong on Sep 24, 2009   Diff
LCD tutorial, updated PDF and fix some
links & API updates
All revisions of this file

File info

Size: 3759 bytes, 114 lines

File properties

svn:keywords
Revision
Powered by Google Project Hosting