Author: jsuijs
Date: Sun Feb 22 01:39:56 2009
New Revision: 804
Added:
trunk/include/external/lcd/js_hd44780_common.jal
trunk/include/external/lcd/js_interface_4bit.jal
trunk/include/external/lcd/js_replace.jal
Modified:
trunk/include/jal/print.jal
Log:
Temporary files as part of refactoring lcd libs. js_hd44780_common will be
the extended API.
Added: trunk/include/external/lcd/js_hd44780_common.jal
==============================================================================
--- (empty file)
+++ trunk/include/external/lcd/js_hd44780_common.jal Sun Feb 22 01:39:56
2009
@@ -0,0 +1,388 @@
+-- ------------------------------------------------------
+-- Title: common for HD44780 based LCD
+--
+-- Author: Richard Zengerink, Copyright (c) 2008..2008, all rights
reserved.
+--
+-- Adapted-by: Joep Suijs
+--
+-- Compiler: =2.4
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: Common API for HD44780 based LCD
+--
+-- Sources:
+--
+-- Notes:
+--
+--
+-- ------------------------------------------------------
+
+--
+-- ------------- place this below, in your MAIN file and add to
---------
+-- ------------- the pins which are not used the variable:
---------
+-- ------------- "not_connected" and change the other pins
---------
+-- ------------- according to your hardware.
---------
+-- ------------- (now selected as 4 line)
---------
+-- ------------- also remove the "--"
---------
+
+-- var bit not_connected
+
+-- var volatile bit lcd_rs is pin_e0 -- data/command select
+-- var volatile bit lcd_rw is pin_e1 -- read/write select
+-- var volatile bit lcd_enable is pin_e2 -- clock the data
+
+-- var volatile bit lcd_d0 is not_connected
+-- var volatile bit lcd_d1 is not_connected
+-- var volatile bit lcd_d2 is not_connected
+-- var volatile bit lcd_d3 is not_connected
+-- var volatile bit lcd_d4 is pin_d4
+-- var volatile bit lcd_d5 is pin_d5
+-- var volatile bit lcd_d6 is pin_d6
+-- var volatile bit lcd_d7 is pin_d7
+
+
+-- const lcd_hardware_4line = true ;true = 4 data line, false = 8 data
line
+-- const lcd_number_of_display_lines = 2 ; 1 = 1 line 2 = 2 line 4
= 4 line
+-- const lcd_number_of_display_characters = 16 ; number of digits per
line
+
+-- include lcd_hd44780_rz
+
+--
--------------------------------------------------------------------------
+--
--------------------------------------------------------------------------
+
+--
-------------------------------------------------------------------------
+-- procedures which can be used in your Main file
+--
-------------------------------------------------------------------------
+--
+-- * lcd_write_data( byte in value ):
+-- writes(byte) data to lcd
+-- example: lcd_write_data( "E" ) or lcd_write_data( 69 )
+-- ---------------
+-- * lcd_new_line_cursor_position(byte in line, byte in pos):
+-- places the cursor on position (pos) in line (line)
+-- example: lcd_new_line_cursor_position (1, 8)
+-- --------------
+-- * lcd_shift_left(byte in value):
+-- shifts the display [value] times to the left without changing DDRAM
data.
+-- example: lcd_shift_left(4)
+-- or lcd_shift_left(variable)
+--
+-- * lcd_shift_right(byte in value):
+-- shifts the display [value] times to the right without changing DDRAM
data.
+-- example: lcd_shift_right(12)
+-- or lcd_shift_right(variable)
+--
+-- * lcd_cursor_shift_left(byte in value):
+-- shifts the cursor [value] times to the left without changing display
+-- contents and DDRAM data.
+-- example: lcd_cursor_shift_left(8)
+-- or lcd_cursor_shift_left(variable)
+--
+-- * lcd_cursor_shift_right(byte in value):
+-- shifts the cursor [value] times to the right without changing display
+-- contents and DDRAM data.
+-- example: lcd_cursor_shift_right(3)
+-- or lcd_cursor_shift_right(variable)
+--
+-- * lcd_clear:
+-- Write "20H" to DDRAM. and set
+-- DDRAM address to "00H" from AC
+--
+-- * lcd_home:
+-- Set DDRAM address to "00H" from
+-- AC and return cursor to its original
+-- position if shifted. The contents of
+-- DDRAM are not changed.
+--
+-- * lcd_cursor_blink_display(bit in cursor,bit in blink,bit in display):
+-- sets the cursor on/off, let the cursor blink or not(if the cursor is
on),
+-- and puts the display on/off
+-- example: lcd_cursor_blink_display(on,off,on)
+--
+-- * lcd_clear_line ( byte in line )
+-- clears the line [line] of the lcd including DDRAM data of that line
+-- example: lcd_clear_line(1)
+--
+-- * lcd_progress(byte in line, byte in amount)
+-- create a progress bar on line [line] with a lenght of [amout]
+-- example: lcd_progress(2,12)
+--
+--
+-- * lcd_bvalue_dp_line_pos_left_sign( byte in value, byte in dp, byte in
line, byte in poskar, bit in left, bit in sign )
+-- displays a byte value with decimal point on position [dp] on line
[line] on position [pos] left alignment true/false,
+-- signed value true/false
+-- byte value = 0 to 255 as value or as variable, dp = 0 means 100 dp =
1 means 10.0 dp = 2 means 1.00 and dp > than 3 means 0.100
+--
+--
+-- example1: lcd_bvalue_dp_line_pos_left_sign(25,0,1,5,true,false)
+-- result on line 1 on position 5 you get 25
+--
+-- example2: lcd_bvalue_dp_line_pos_left_sign(25,0,1,5,false,false)
+-- result on line 1 on position 5 you get [space]25 (25 starts at
position 6)
+--
+-- example3: lcd_bvalue_dp_line_pos_left_sign(225,0,2,1,true,true)
+-- result on line 2 on position 1 you get -31
+--
+-- example4: lcd_bvalue_dp_line_pos_left_sign(225,0,2,1,true,false)
+-- result on line 2 on position 1 you get 225
+--
+--
+-- * lcd_wvalue_dp_line_pos_left_sign( word in value, byte in dp, byte in
line, byte in poskar, bit in left, bit in sign )
+--
+--
+--
+-- * lcd_time( byte in hrs, byte in minut, byte in second, byte in
seperator )
+--
+--
+--
+-- * lcd_date( byte in day, byte in mounth, word in year, byte in
seperator, bit in day_mounth_notation )
+--
+--
+-- * lcd_bvalue_hex( byte in value)
+--
+--
+-- * lcd_wvalue_hex( word in value)
+--
+--
+--
+-- * lcd_bvalue_bin( byte in value)
+--
+--
+--
+--
+
+--
-----------------------------------------------------------------------------
+-- some constants to control the lcd
+--
-----------------------------------------------------------------------------
+const lcd_clear_display = 0b_0000_0001
+const lcd_return_home = 0b_0000_0010
+const lcd_display_onoff = 0b_0000_1000
+const lcd_cursor_shift_r_val = 0b_0001_0100
+const lcd_cursor_shift_l_val = 0b_0001_0000
+const lcd_display_shift_right = 0b_0001_1100
+const lcd_display_shift_left = 0b_0001_1000
+
+const lcd_set_ddram_address = 0b_1000_0000
+--
-----------------------------------------------------------------------------
+
+var volatile byte lcd_pos = 0
+
+
+
+procedure lcd_writechar(byte in data) is
+ pragma inline
+ _lcd_write_data(data)
+end procedure
+
+procedure lcd'put(byte in data) is
+ pragma inline
+ _lcd_write_data(data)
+end procedure
+
+
+--
----------------------------------------------------------------------------
+-- sets the cursor of the LCD to the position in the shadow register
+-- (this routine is only used inside this file)
+--
----------------------------------------------------------------------------
+procedure lcd_restore_cursor() is
+ -- set LCD back to normal operation
+ _lcd_write_command( lcd_set_ddram_address | lcd_pos )
+end procedure
+--
----------------------------------------------------------------------------
+
+
+--
----------------------------------------------------------------------------
+-- sets the cursor of the LCD on "pos" position in line "line" in the
shadow register
+--
+--
----------------------------------------------------------------------------
+procedure lcd_new_line_cursor_position(byte in line, byte in pos) is
+ pos = pos -1
+ if lcd_number_of_display_lines == 1 then
+ lcd_pos = pos
+
+ elsif lcd_number_of_display_lines == 2 then
+ if line == 1 then
+ lcd_pos = pos
+ else
+ lcd_pos = pos + 0x40
+ end if
+ else -- 4 lines
+ if line == 1 then lcd_pos = pos
+ elsif line == 2 then lcd_pos = pos + 0x40
+ elsif line == 3 then lcd_pos = pos + 0x14
+ else line == 4 then lcd_pos = pos + 0x54
+ end if
+ end if
+
+ lcd_restore_cursor
+
+end procedure
+
+
+
+--
----------------------------------------------------------------------------
+-- shifts the coplete display one position to the left
+--
----------------------------------------------------------------------------
+procedure lcd_shift_left(byte in nr) is
+ -- set LCD back to normal operation
+
+ if nr != 0 then
+ for nr loop
+ _lcd_write_command( lcd_display_shift_left )
+ delay_10us( lcd_short_delay )
+ end loop
+ end if
+end procedure
+--
----------------------------------------------------------------------------
+
+--
----------------------------------------------------------------------------
+-- shifts the complete display one position to the right
+--
----------------------------------------------------------------------------
+procedure lcd_shift_right(byte in nr) is
+ if nr != 0 then
+ for nr loop
+ _lcd_write_command( lcd_display_shift_right )
+ delay_10us( lcd_short_delay )
+ end loop
+ end if
+end procedure
+--
----------------------------------------------------------------------------
+
+ --
----------------------------------------------------------------------------
+-- shifts cursor one position to the left
+--
----------------------------------------------------------------------------
+procedure lcd_cursor_shift_left(byte in nr) is
+ if nr != 0 then
+ for nr loop
+ _lcd_write_command( lcd_cursor_shift_l_val )
+ delay_10us( lcd_short_delay )
+ end loop
+ end if
+end procedure
+--
----------------------------------------------------------------------------
+
+--
----------------------------------------------------------------------------
+-- shifts cursor one position to the right
+--
----------------------------------------------------------------------------
+procedure lcd_cursor_shift_right(byte in nr) is
+ if nr != 0 then
+ for nr loop
+ _lcd_write_command( lcd_cursor_shift_r_val )
+ delay_10us( lcd_short_delay )
+ end loop
+ end if
+end procedure
+--
----------------------------------------------------------------------------
+
+--
----------------------------------------------------------------------------
+-- clears the LCD
+--
----------------------------------------------------------------------------
+procedure lcd_clearscreen() is
+ _lcd_write_command( lcd_clear_display )
+ delay_10us( lcd_long_delay )
+end procedure
+--
----------------------------------------------------------------------------
+
+--
----------------------------------------------------------------------------
+-- sets or resets cursor blink and puts display on or off
+--
----------------------------------------------------------------------------
+procedure lcd_cursor_blink_display(bit in cursor,bit in blink,bit in
display) is
+ var byte reg
+
+ reg = lcd_display_onoff
+ if display then reg = reg + 4 end if
+ if cursor then reg = reg + 2 end if
+ if blink then reg = reg + 1 end if
+ _lcd_write_command( reg )
+end procedure
+--
----------------------------------------------------------------------------
+
+
+
+--
----------------------------------------------------------------------------
+-- cursor returns home(line 1, position 1)
+--
----------------------------------------------------------------------------
+procedure lcd_home() is
+ _lcd_write_command( lcd_return_home )
+ delay_10us( lcd_long_delay )
+end procedure
+--
----------------------------------------------------------------------------
+
+
+--
----------------------------------------------------------------------------
+-- clears the line "line" of the LCD
+--
----------------------------------------------------------------------------
+procedure lcd_clear_line( byte in line ) is
+ -- set LCD-cursor at start of line
+ if line == 1 then lcd_pos = 0 end if
+ if line == 2 then lcd_pos = 40 end if
+
+ lcd_restore_cursor
+
+ -- now fill line with spaces
+ for 39 loop
+ lcd_writechar( " " )
+ end loop
+
+ -- set LCD back to normal operation
+ lcd_restore_cursor
+end procedure
+--
----------------------------------------------------------------------------
+
+
+
+--
-----------------------------------------------------------------------------
+-- Displays a progress bar
+--
+--
-----------------------------------------------------------------------------
+procedure lcd_progress(byte in line, byte in amount, byte in pattern) is
+
+ if lcd_number_of_display_lines == 1 then
+ lcd_pos = pos
+
+ elsif lcd_number_of_display_lines == 2 then
+ if line == 1 then
+ lcd_pos = 0
+ else
+ lcd_pos = 0x40
+ end if
+ else -- 4 lines
+ if line == 1 then lcd_pos = 0
+ elsif line == 2 then lcd_pos = 0x40
+ elsif line == 3 then lcd_pos = 0x14
+ else line == 4 then lcd_pos = 0x54
+ end if
+ end if
+
+ lcd_restore_cursor
+
+ for amount loop
+ lcd_writechar( pattern )
+ end loop
+
+ for ( lcd_number_of_display_characters - amount) loop
+ lcd_writechar( " " )
+ end loop
+
+end procedure
+--
----------------------------------------------------------------------------
+
+
+--
-----------------------------------------------------------------------------
+-- Initialise display
+--
-----------------------------------------------------------------------------
+procedure _hd44780_init() is
+
+ _lcd_write_command( 0b_0011_1000 )
+ _lcd_write_command( 0b_0001_1100 )
+ _lcd_write_command( 0b_0000_1100 )
+ _lcd_write_command( 0b_0000_0110 )
+ _lcd_write_command( 0b_0000_0110 )
+
+ delay_1ms( 10 )
+ lcd_clearscreen()
+ lcd_home()
+
+end procedure
Added: trunk/include/external/lcd/js_interface_4bit.jal
==============================================================================
--- (empty file)
+++ trunk/include/external/lcd/js_interface_4bit.jal Sun Feb 22 01:39:56
2009
@@ -0,0 +1,171 @@
+-- ------------------------------------------------------
+-- Title: LCD refactoring
+--
+-- Author: Richard Zengerink, Copyright (c) 2008..2008, all rights
reserved.
+--
+-- Adapted-by: Joep Suijs (refactoring)
+--
+-- Compiler: =2.4
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: LCD refactoring
+--
+-- Sources:
+--
+-- Notes:
+--
+--
+-- ------------------------------------------------------
+
+
+--
-----------------------------------------------------------------------------
+-- delay's necessary for initialisation and some commands
+--
-----------------------------------------------------------------------------
+const lcd_short_delay = 5 -- delay in 10 usec units
+
+const lcd_long_delay = 180 -- delay in 10 usec units
+
+--
----------------------------------------------------------------------------
+-- generate clockpuls
+-- (this routine is only used inside this file)
+--
----------------------------------------------------------------------------
+procedure __lcd_clock() is
+ -- generate clockpuls
+ lcd_enable = high -- enable high
+ delay_10us(4)
+ lcd_enable = low -- enable high --> low = clock data
+
+end procedure
+
+
+--
----------------------------------------------------------------------------
+-- sends low nibble from value to the LCD
+-- can be used for both commands and data
+-- (requires no wait cycli inbetween upper and lower nibble)
+-- (this routine is only used inside this file)
+--
----------------------------------------------------------------------------
+procedure __lcd_write_low_nibble( byte in value ) is
+ var bit bit0 at value : 0
+ var bit bit1 at value : 1
+ var bit bit2 at value : 2
+ var bit bit3 at value : 3
+
+ -- setup databits
+ lcd_d4 = bit0
+ lcd_d5 = bit1
+ lcd_d6 = bit2
+ lcd_d7 = bit3
+
+
+ -- generate clockpuls
+ __lcd_clock
+end procedure
+--
----------------------------------------------------------------------------
+
+
+--
----------------------------------------------------------------------------
+-- sends byte from value to register of the LCD
+-- (this procedure is only used inside this file)
+--
+--
----------------------------------------------------------------------------
+procedure __lcd_write( byte in value ) is
+
+ pragma inline
+
+
+ lcd_rw = low -- select write mode
+
+ if lcd_hardware_4line then
+ __lcd_write_low_nibble( value >> 4 ) -- output high nibble
+ __lcd_write_low_nibble( value ) -- output low nibble
+
+ else
+ var bit bit0 at value : 0
+ var bit bit1 at value : 1
+ var bit bit2 at value : 2
+ var bit bit3 at value : 3
+ var bit bit4 at value : 4
+ var bit bit5 at value : 5
+ var bit bit6 at value : 6
+ var bit bit7 at value : 7
+
+ -- setup databits
+ lcd_d0 = bit0
+ lcd_d1 = bit1
+ lcd_d2 = bit2
+ lcd_d3 = bit3
+ lcd_d4 = bit4
+ lcd_d5 = bit5
+ lcd_d6 = bit6
+ lcd_d7 = bit7
+
+ lcd_clock
+ end if
+
+end procedure
+--
----------------------------------------------------------------------------
+
+
+--
----------------------------------------------------------------------------
+-- sends data byte in value to LCD
+-- for slow commands an extra delay should be added
+--
+--
----------------------------------------------------------------------------
+procedure _lcd_write_data( byte in value ) is
+ lcd_rs = high -- select instruction
+ __lcd_write( value ) -- output byte
+ delay_10us( lcd_short_delay ) -- required delay
+end procedure
+--
----------------------------------------------------------------------------
+
+
+--
----------------------------------------------------------------------------
+-- sends command byte in value to LCD
+-- for slow commands an extra delay should be added
+--
+--
----------------------------------------------------------------------------
+procedure _lcd_write_command( byte in value ) is
+ lcd_rs = low -- select instruction
+ __lcd_write( value ) -- output byte
+ delay_10us( lcd_short_delay ) -- required delay
+end procedure
+--
----------------------------------------------------------------------------
+
+
+-- now we defined the interface, add the API
+include js_hd44780_common
+
+--
----------------------------------------------------------------------------
+--
----------------------------------------------------------------------------
+--
----------------------------------------------------------------------------
+procedure lcd_init() is
+
+ -- first, init the interface
+ lcd_enable = low
+ lcd_rw = low
+ delay_1ms ( 25 )
+ if lcd_hardware_4line then
+ __lcd_write_low_nibble( 0b_0000_0011 )
+ delay_1ms ( 6 )
+ __lcd_write_low_nibble( 0b_0000_0011 )
+ delay_10us ( 11 )
+ __lcd_write_low_nibble( 0b_0000_0011 )
+ delay_10us( 5 )
+
+ __lcd_write_low_nibble( 0b_0000_0010 )
+ delay_10us( 5 )
+ else
+ _lcd_write_command( 0b_0011_0000 )
+ delay_1ms ( 6 )
+ _lcd_write_command( 0b_0011_0000 )
+ delay_10us ( 11 )
+ _lcd_write_command( 0b_0011_0000 )
+ delay_10us( 11 )
+
+ end if
+
+ -- init the API
+ _hd44780_init()
+end procedure
\ No newline at end of file
Added: trunk/include/external/lcd/js_replace.jal
==============================================================================
--- (empty file)
+++ trunk/include/external/lcd/js_replace.jal Sun Feb 22 01:39:56 2009
@@ -0,0 +1,439 @@
+-- ------------------------------------------------------
+-- Title: LCD refactoring
+--
+-- Author: Richard Zengerink, Copyright (c) 2008..2008, all rights
reserved.
+--
+-- Adapted-by: Joep Suijs (refactoring)
+--
+-- Compiler: =2.4
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: LCD refactoring
+--
+-- Sources:
+--
+-- Notes:
+--
+--
+-- ------------------------------------------------------
+
+var byte lcd_maxdigit
+var byte lcd_nodigit
+
+;--
-----------------------------------------------------------------------------
+;-- Displays a byte value in Hex,
+;--
-----------------------------------------------------------------------------
+;procedure lcd_bvalue_hex( byte in value) is
+; pragma inline
+;
+; print_prefix = true;
+; print_byte_hex(lcd, value);
+;
+;end procedure
+;
+;--
----------------------------------------------------------------------------
+;
+;
+;--
-----------------------------------------------------------------------------
+;-- Displays a word value in Hex,
+;--
-----------------------------------------------------------------------------
+;procedure lcd_wvalue_hex( word in value) is
+; pragma inline
+;
+; print_prefix = true;
+; print_word_binary(lcd, value);
+;
+;end procedure
+;
+;--
----------------------------------------------------------------------------
+;
+;--
-----------------------------------------------------------------------------
+;-- Displays a byte value in binairy,
+;--
-----------------------------------------------------------------------------
+;procedure lcd_bvalue_bin( byte in value) is
+; pragma inline
+;
+; print_prefix = true;
+; print_byte_binary(lcd, value);
+;
+;end procedure
+;
+;--
----------------------------------------------------------------------------
+;
+;--
-----------------------------------------------------------------------------
+;-- Displays a string
+;--
-----------------------------------------------------------------------------
+;procedure lcd_string( byte in string[]) is
+; pragma inline
+;
+; print_string(lcd, string)
+;
+;end procedure
+
+
+--
----------------------------------------------------------------------------
+
+
+--
-----------------------------------------------------------------------------
+-- Displays a value (byte), whith or without Decimal Point, on specified
line
+-- and position , non leading zero ,with or without left alignment, signed
+-- or not signed.
+--
-----------------------------------------------------------------------------
+procedure lcd_bvalue_dp_line_pos_left_sign( word in value, byte in dp,
byte in line, byte in poskar, bit in left, bit in sign ) is
+ var word digit0 = 0
+ var byte digit1 = 0
+ var byte digit2 = 0
+ var bit negative = false
+
+ if sign then
+ if value >= 128 then
+ negative = true
+ value = 128 - (value - 128)
+ end if
+ end if
+
+ while value >= 100 loop
+ digit2 = digit2 + 1
+ value = value - 100
+ end loop
+
+ while value >= 10 loop
+ digit1 = digit1 + 1
+ value = value - 10
+ end loop
+
+ digit0 = value
+
+ if digit2 == 0 & dp < 2 then
+ digit2 = 32
+ else
+ digit2 = digit2 + 48
+ end if
+
+ if digit1 == 0 & digit2 == 32 & dp < 1 then
+ digit1 = 32
+ else
+ digit1 = digit1 + 48
+ end if
+
+ digit0 = digit0 + 48
+
+
+ lcd_new_line_cursor_position (line, poskar)
+
+ var bit decp = false
+ var byte counter = 0
+ lcd_nodigit = 0
+
+ for 5 loop
+
+ if negative then
+ lcd_writechar("-")
+ negative = false
+ lcd_nodigit = lcd_nodigit + 1
+ end if
+
+ if dp > 2 & !decp then
+ lcd_writechar(".")
+ decp = true
+ lcd_nodigit = lcd_nodigit + 1
+ else
+ if counter == 1 then
+ if !left | digit2 != 32 then
+ lcd_writechar(digit2)
+ lcd_nodigit = lcd_nodigit + 1
+ end if
+ end if
+ if counter == 2 then
+ if !left | digit1 != 32 then
+ lcd_writechar(digit1)
+ lcd_nodigit = lcd_nodigit + 1
+ end if
+ end if
+ if counter == 3 then
+ if !left | digit0 != 32 then
+ lcd_writechar(digit0)
+ lcd_nodigit = lcd_nodigit + 1
+ end if
+ end if
+ counter = counter + 1
+ end if
+
+ if dp != 0 then
+ dp = dp + 1
+ end if
+
+ end loop
+
+ if lcd_nodigit > lcd_maxdigit then
+ lcd_maxdigit = lcd_nodigit
+ else
+ while lcd_maxdigit > lcd_nodigit loop
+ lcd_writechar(32)
+ lcd_maxdigit = lcd_maxdigit - 1
+ end loop
+ end if
+
+end procedure
+--
----------------------------------------------------------------------------
+
+
+
+--
-----------------------------------------------------------------------------
+-- Displays a value (word), white or without Decimal Point, on specified
line
+-- and position, non leading zero ,with or without left alignment, signed
+-- or not signed
+--
-----------------------------------------------------------------------------
+
+procedure lcd_wvalue_dp_line_pos_left_sign( word in value, byte in dp,
byte in line, byte in poskar, bit in left, bit in sign ) is
+ var word digit0 = 0 ;l
+ var byte digit1 = 0 ;10
+ var byte digit2 = 0 ;100
+ var byte digit3 = 0 ;1000
+ var byte digit4 = 0 ;10000
+ var bit negative = false
+
+ if sign then
+ if value >= 32768 then
+ negative = true
+ value = 32768 - (value - 32768)
+ end if
+ end if
+
+ while value >= 10000 loop
+ digit4 = digit4 + 1
+ value = value - 10000
+ end loop
+
+ while value >= 1000 loop
+ digit3 = digit3 + 1
+ value = value - 1000
+ end loop
+
+ while value >= 100 loop
+ digit2 = digit2 + 1
+ value = value - 100
+ end loop
+
+ while value >= 10 loop
+ digit1 = digit1 + 1
+ value = value - 10
+ end loop
+
+ digit0 = value
+
+ if digit4 == 0 & dp < 4 then
+ digit4 = 32
+ else
+ digit4 = digit4 + 48
+ end if
+
+ if digit3 == 0 & digit4 == 32 & dp < 3 then
+ digit3 = 32
+ else
+ digit3 = digit3 + 48
+ end if
+
+ if digit2 == 0 & digit3 == 32 & digit4 == 32 & dp < 2 then
+ digit2 = 32
+ else
+ digit2 = digit2 + 48
+ end if
+
+ if digit1 == 0 & digit2 == 32 & digit3 == 32 & digit4 == 32 & dp < 1
then
+ digit1 = 32
+ else
+ digit1 = digit1 + 48
+ end if
+
+ digit0 = digit0 + 48
+
+ lcd_new_line_cursor_position (line, poskar)
+
+ var bit decp = false
+ var byte counter = 0
+ lcd_nodigit = 0
+
+ for 7 loop
+
+ if negative then
+ lcd_writechar("-")
+ negative = false
+ lcd_nodigit = lcd_nodigit + 1
+ end if
+
+ if dp > 5 & !decp then
+ lcd_writechar(".")
+ decp = true
+ lcd_nodigit = lcd_nodigit + 1
+ else
+ if counter == 1 then
+ if !left | digit4 != 32 then
+ lcd_writechar(digit4)
+ lcd_nodigit = lcd_nodigit + 1
+ end if
+ end if
+ if counter == 2 then
+ if !left | digit3 != 32 then
+ lcd_writechar(digit3)
+ lcd_nodigit = lcd_nodigit + 1
+ end if
+ end if
+ if counter == 3 then
+ if !left | digit2 != 32 then
+ lcd_writechar(digit2)
+ lcd_nodigit = lcd_nodigit + 1
+ end if
+ end if
+ if counter == 4 then
+ if !left | digit1 != 32 then
+ lcd_writechar(digit1)
+ lcd_nodigit = lcd_nodigit + 1
+ end if
+ end if
+ if counter == 5 then
+ lcd_writechar(digit0)
+ lcd_nodigit = lcd_nodigit + 1
+ end if
+ counter = counter + 1
+ end if
+
+ if dp != 0 then
+ dp = dp + 1
+ end if
+
+ end loop
+ if lcd_nodigit > lcd_maxdigit then
+ lcd_maxdigit = lcd_nodigit
+ else
+ while lcd_maxdigit > lcd_nodigit loop
+ lcd_writechar(32)
+ lcd_maxdigit = lcd_maxdigit - 1
+ end loop
+ end if
+end procedure
+--
----------------------------------------------------------------------------
+
+
+--
-----------------------------------------------------------------------------
+-- Displays a time (byte),
+--
-----------------------------------------------------------------------------
+procedure lcd_time( byte in hrs, byte in minut, byte in second, byte in
seperator ) is
+ var byte hrs_digit0 = 0 ;l
+ var byte hrs_digit1 = 0 ;10
+ var byte minut_digit0 = 0 ;1
+ var byte minut_digit1 = 0 ;10
+ var byte second_digit0 = 0 ;1
+ var byte second_digit1 = 0 ;10
+
+ while hrs >= 10 loop
+ hrs_digit1 = hrs_digit1 + 1
+ hrs = hrs - 10
+ end loop
+ hrs_digit0 = hrs + 48
+ hrs_digit1 = hrs_digit1 + 48
+ while minut >= 10 loop
+ minut_digit1 = minut_digit1 + 1
+ minut = minut - 10
+ end loop
+ minut_digit0 = minut +48
+ minut_digit1 = minut_digit1 + 48
+ while second >= 10 loop
+ second_digit1 = second_digit1 + 1
+ second = second - 10
+ end loop
+ second_digit0 = second + 48
+ second_digit1 = second_digit1 + 48
+
+ lcd_writechar(hrs_digit1 )
+ lcd_writechar(hrs_digit0)
+ lcd_writechar(seperator)
+ lcd_writechar(minut_digit1)
+ lcd_writechar(minut_digit0)
+ lcd_writechar(seperator)
+ lcd_writechar(second_digit1)
+ lcd_writechar(second_digit0)
+
+end procedure
+--
----------------------------------------------------------------------------
+
+--
-----------------------------------------------------------------------------
+-- Displays a date (byte),
+--
-----------------------------------------------------------------------------
+
+procedure lcd_date( byte in day, byte in mounth, word in year, byte in
seperator, bit in day_mounth_notation ) is
+ var byte day_digit0 = 0 ;l
+ var byte day_digit1 = 0 ;10
+ var byte mounth_digit0 = 0 ;1
+ var byte mounth_digit1 = 0 ;10
+ var word year_digit0 = 0 ;1
+ var byte year_digit1 = 0 ;10
+ var byte year_digit2 = 0 ;100
+ var byte year_digit3 = 0 ;1000
+ var word year_mem = year
+
+
+ while day >= 10 loop
+ day_digit1 = day_digit1 + 1
+ day = day - 10
+ end loop
+ day_digit0 = day + 48
+ day_digit1 = day_digit1 + 48
+ while mounth >= 10 loop
+ mounth_digit1 = mounth_digit1 + 1
+ mounth = mounth - 10
+ end loop
+ mounth_digit0 = mounth +48
+ mounth_digit1 = mounth_digit1 + 48
+
+ while year >= 1000 loop
+ year_digit3 = year_digit3 + 1
+ year = year - 1000
+ end loop
+
+ while year >= 100 loop
+ year_digit2 = year_digit2 + 1
+ year = year - 100
+ end loop
+
+ while year >= 10 loop
+ year_digit1 = year_digit1 + 1
+ year = year - 10
+ end loop
+ year_digit3 = year_digit3 + 48
+ year_digit2 = year_digit2 + 48
+ year_digit1 = year_digit1 + 48
+ year_digit0 = year + 48
+
+
+ if !day_mounth_notation then
+ lcd_writechar(mounth_digit1)
+ lcd_writechar(mounth_digit0)
+ lcd_writechar(seperator)
+ lcd_writechar(day_digit1 )
+ lcd_writechar(day_digit0)
+ lcd_writechar(seperator)
+ else
+ lcd_writechar(day_digit1 )
+ lcd_writechar(day_digit0)
+ lcd_writechar(seperator)
+ lcd_writechar(mounth_digit1)
+ lcd_writechar(mounth_digit0)
+ lcd_writechar(seperator)
+ end if
+
+ if year_mem > 100 then
+ lcd_writechar(year_digit3)
+ lcd_writechar(year_digit2)
+ else
+ lcd_writechar("'")
+ end if
+
+ lcd_writechar(year_digit1)
+ lcd_writechar(year_digit0)
+
+end procedure
+--
----------------------------------------------------------------------------
+
Modified: trunk/include/jal/print.jal
==============================================================================
--- trunk/include/jal/print.jal (original)
+++ trunk/include/jal/print.jal Sun Feb 22 01:39:56 2009
@@ -32,6 +32,7 @@
const byte nibble2hex[] = "0123456789ABCDEF" -- conversion string
+var bit print_prefix = false
procedure print_crlf(volatile byte out device) is
device = 13 -- ASCII CR (cariage return)
@@ -86,6 +87,11 @@
procedure print_dword_binary(volatile byte out device, dword in data) is
+ if (print_prefix) then
+ device = "0"
+ device = "b"
+ end if
+
print_byte_binary(device, byte(data>>24))
print_byte_binary(device, byte(data>>16))
print_byte_binary(device, byte(data>>8))
@@ -94,6 +100,11 @@
end procedure
procedure print_word_binary(volatile byte out device, word in data) is
+
+ if (print_prefix) then
+ device = "0"
+ device = "b"
+ end if
print_byte_binary(device, byte(data>>8))
print_byte_binary(device, byte(data))
@@ -102,7 +113,12 @@
procedure print_byte_binary(volatile byte out device, byte in data) is
- for 8 loop
+ if (print_prefix) then
+ device = "0"
+ device = "b"
+ end if
+
+ for 8 loop
if ((data & 0x80) != 0) then
device = "1"
else
@@ -115,7 +131,12 @@
end procedure
procedure print_dword_hex(volatile byte out device, dword in data) is
-
+
+ if (print_prefix) then
+ device = "0"
+ device = "x"
+ end if
+
device = nibble2hex[0x0F & (data>>28)]
device = nibble2hex[0x0F & (data>>24)]
device = nibble2hex[0x0F & (data>>20)]
@@ -128,6 +149,11 @@
end procedure
procedure print_word_hex(volatile byte out device, word in data) is
+
+ if (print_prefix) then
+ device = "0"
+ device = "x"
+ end if
device = nibble2hex[0x0F & (data>>12)]
device = nibble2hex[0x0F & (data>>8)]
@@ -136,7 +162,12 @@
end procedure
-procedure print_byte_hex(volatile byte out device, byte in data) is
+procedure print_byte_hex(volatile byte out device, byte in data) is
+
+ if (print_prefix) then
+ device = "0"
+ device = "x"
+ end if
device = nibble2hex[0x0F & (data>>4)]
device = nibble2hex[0x0F & (data)]
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---