Author: robhamerling
Date: Sun Oct 26 01:38:28 2008
New Revision: 475
Added:
trunk/unvalidated/sample/by_device/16f819/hello_world_lcd.jal
Log:
'Hellow world' sample with LCD and low power crystal for 16F818/819
Added: trunk/unvalidated/sample/by_device/16f819/hello_world_lcd.jal
==============================================================================
--- (empty file)
+++ trunk/unvalidated/sample/by_device/16f819/hello_world_lcd.jal Sun Oct
26 01:38:28 2008
@@ -0,0 +1,70 @@
+-- Title: Hello world with an LCD
+-- Author: Eur Van Andel, Copyright (c) 2008, all rights reserved.
+-- Adapted-by: Rob Hamerling
+-- 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.
+--
+-- Notes: - This sample uses a low power crystal oscillator which is not
+-- recommended for LCD control, which is rather CPU cycle
intensive!
+-- You may experience slow screen updates and longer delays.
+--
+
+include 16f819
+
+-- Note:
+pragma target CLOCK 32768 -- xtal freq
+pragma target OSC LP -- low power xtal
+pragma target WDT DISABLED
+
+enable_digital_io()
+
+const LCD_ROWS = 4 -- 4x20 LCD
+const LCD_CHARS = 20
+var bit LCD_RS is pin_B5 -- LCD command/data select.
+var bit LCD_EN is pin_B7 -- LCD data trigger
+var byte lcd_dataport is portA_low -- LCD data
+
+portA_low_direction = all_output -- LCD data on portA 0..3
+portB_direction = all_output -- LCD control on portB
+
+include lcd_hd44780_4 -- LCD library with 4 data lines
+include print -- formatted output library
+include delay_any_mc -- delay library
+
+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_setcursor(2,0) -- to 3rd line
+print_string(lcd, str2)
+lcd_setcursor(3,0) -- to 4th line
+print_string(lcd, str3)
+
+var byte counter = 0
+
+forever loop -- loop forever
+
+ counter = counter + 1 -- update counter
+ lcd_setcursor(1,0) -- second line
+ print_byte_dec(lcd, counter) -- output in hex format
+ delay_100ms(3) -- wait a little
+
+ if counter == 255 then -- counter wrap
+ lcd_setcursor(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
-~----------~----~----~----~------~----~------~--~---