Author: jsuijs
Date: Sat Nov 1 07:59:44 2008
New Revision: 514
Removed:
trunk/unvalidated/sample/test/external/lcd/test_hello_world_lcd.jal
Modified:
trunk/unvalidated/sample/test/board/board_16f88_js.jal
trunk/unvalidated/sample/test/external/lcd/test_lcd_hd44780_4.jal
Log:
added ';@jallib' labels to a board and test file to enable sample
generation.
Modified: trunk/unvalidated/sample/test/board/board_16f88_js.jal
==============================================================================
--- trunk/unvalidated/sample/test/board/board_16f88_js.jal (original)
+++ trunk/unvalidated/sample/test/board/board_16f88_js.jal Sat Nov 1
07:59:44 2008
@@ -36,38 +36,43 @@
--
-- ------------------------------------------------------
+;@jallib section chipdef
-- chip setup
include 16f88
---
-- This program assumes a 20 MHz resonator or crystal
-- is connected to pins OSC1 and OSC2.
-pragma target OSC HS -- HS crystal or resonator
+pragma target OSC HS -- HS crystal or resonator
pragma target clock 20_000_000 -- oscillator frequency
-pragma target WDT disabled
-pragma target LVP disabled
-pragma target CCP1MUX RB3
+pragma target WDT disabled -- no watchdog
+pragma target LVP disabled -- no low-voltage programming
+pragma target CCP1MUX RB3 -- ccp1 pin on B3
--- LED setup
-var bit led is pin_b3 -- alias
+;@jallib section led
+-- LED IO definition
+var bit led is pin_b3 -- led pin
var bit led_direction is pin_b3_direction
--- LCD setup
-var bit lcd_rs is pin_b4 -- LCD command/data select.
+;@jallib section lcd_hd44780_4
+-- LCD IO definition
+var bit lcd_rs is pin_b4 -- LCD
command/data select.
var bit lcd_rs_direction is pin_b4_direction
-var bit lcd_en is pin_b0 -- LCD data trigger
+var bit lcd_en is pin_b0 -- LCD data
trigger
var bit lcd_en_direction is pin_b0_direction
-
-var byte lcd_dataport is porta_low -- LCD data port
-var byte lcd_dataport_direction is porta_low_direction -- LCD data port
-const byte LCD_ROWS = 2 -- 2 lines
-const byte LCD_CHARS = 16 -- 16 chars per line
--- I2C setup
-var volatile bit i2c_scl is pin_b4
+var byte lcd_dataport is porta_low -- LCD data port
+var byte lcd_dataport_direction is porta_low_direction
+
+const byte LCD_ROWS = 2 -- 2 lines
+const byte LCD_CHARS = 16 -- 16 chars per
line
+
+;@jallib section i2c
+-- I2C io definition
+var volatile bit i2c_scl is pin_b4 -- i2c scl pin
var volatile bit i2c_scl_direction is pin_b4_direction
-var volatile bit i2c_sda is pin_b3
+var volatile bit i2c_sda is pin_b3 -- i2c sda pin
var volatile bit i2c_sda_direction is pin_b3_direction
--- ccp setup
-var volatile bit pin_ccp1_direction is pin_b3_direction
+;@jallib section ccp1
+-- ccp1 setup
+var volatile bit pin_ccp1_direction is pin_b3_direction -- ccp1 pin
Modified: trunk/unvalidated/sample/test/external/lcd/test_lcd_hd44780_4.jal
==============================================================================
--- trunk/unvalidated/sample/test/external/lcd/test_lcd_hd44780_4.jal
(original)
+++ trunk/unvalidated/sample/test/external/lcd/test_lcd_hd44780_4.jal Sat
Nov 1 07:59:44 2008
@@ -1,17 +1,17 @@
-- ------------------------------------------------------
--- Title: Test program for i2c_software.jal
---
--- Author: Joep Suijs, Copyright (c) 2008..2008, all rights reserved.
---
--- Adapted-by:
---
+-- 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
--
-- This file is part of jallib (http://jallib.googlecode.com)
-- Released under the BSD license
(http://www.opensource.org/licenses/bsd-license.php)
--
--- Description: Level 0 i2c test program
--- interact with an i2c eeprom using the i2c primitives
+-- 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 .
@@ -22,48 +22,57 @@
-- setup: an hd44780 compatible display, used in 4-bit mode.
--
--
--------------------------------------------------------------------------
-include delay
+
+;@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_d4_direction = output
-;lcd_d5_direction = output
-;lcd_d6_direction = output
-;lcd_d7_direction = output
lcd_dataport_direction = output
-delay_1ms(10)
+include lcd_hd44780_4 -- LCD library with 4 data lines
+include print -- formatted output library
-include lcd_hd44780_4 -- LCD library
-include print -- output library
-
-led_direction = output
-for 4 loop
+for 4 loop -- blink LED 4 times to indicate
startup
LED = on
- delay_100ms(3)
+ delay_100ms(2)
LED = off
- delay_100ms(3)
+ delay_100ms(2)
end loop
-
-const byte str1[] = "Hello world" -- define a string
-print_string(lcd, str1) -- output string to LCD
+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
+forever loop -- loop forever
- lcd_setcursor(1, 0)
- print_byte_hex(lcd, counter) -- output in hex format
- counter = counter + 1
- delay_100ms(2)
+ counter = counter + 1 -- update counter
+ lcd_setcursor(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_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
-~----------~----~----~----~------~----~------~--~---