Hi Wayne,

First of all, the filename itself should contain "lcd". I think
"lcd_k107.jal" would be ok, following this section from JSG (
http://code.google.com/p/jallib/wiki/JallibStyleGuide, section "Rules of
Thumb/Filenames"):

"""
<device-family>_<device>.jal for external libraries [this is the case here,
right ?]. device-family describes the device family (...), and is often the
directory name where the lib is. device precisely sets the part.

Ex: lcd_hd44780_4.jal, rtc_ds1302.jal, co2_t6603.jal
"""


JSG validator also says ("jallib validate k107.jal"):

"""
File: k107.jal
2 errors found
        ERROR: Cannot find end of field content Description
        ERROR: 105: Found Capitals in token: 'k107_CR'

0 warnings found
"""

Mmmh... OK, so "k107_CR" should be "k107_cr". This other error is trickier:
it can't find "Description" field, while there's one ! Why ? Actually, it
can find the end of the section, so the whole section is ignored. Adding a
"--" at the end fixes the problem:

--    Directions for use of this library in application programs
--    (in this sequence):
--    <==== THIS ONE :)


About k107_init, it takes an argument for the geometry. I guess it describes
the number of rows and columns. Ex: 416 is a 4 rows and 16 columns LCD,
right ? I would have preferred specifying rows and cols separately, maybe
more user-friendly. But that's a matter of taste !

Thinking again about your "case" impl., I wonder how defining both "var byte
cmd[]" and "const byte cmd[]" behaves... More, if "geo" can be 416 or 420,
then it must be a "word", not a "byte". And here I've found interesting
things... Here's a program I've written including unittest:

  - test_orig.jal: I took your case, and adapt it so I can run unittests on
it. Basically, I removed arrays

 If you have last jallib from trunk, jallib.py and PICShell installed with
correct PYTHONPATH, you can run:

    python jallib.py unittest test_orig.jal

this will give:

test_orig.jal compiled, running tests...
test_test : OK
test_geo : FAIL, 416 != 0


(you can also use PICShell's GUI)

Mmmh... cmd is 0, that is the initialized value. Weird. Does "var byte cmd"
and "const byte cmd" are allowed on the same scope ? It seems not, and it
seems logical. When using block... end block, a new scope is created. Looks
like your const assignement has fade away.

Another test:

  - test_noconst.jal : I remove "const", that I directly assign to "cmd"
being declared as "var byte cmd" before the "case". Also converted byte to
word as needed.

Results are:

test_noconst.jal compiled, running tests...
test_test : OK
test_geo : OK


Good ! Another test...

  - test_noconst_noassign.jal : removed cmd assignement to 0.

Results:

test_noconst_noassign.jal compiled, running tests...
test_test : OK
test_geo : FAIL, 416 != 160


Weird ! Looks like it ate some of the bits, just as though it couldn't
handle "word" in the case. Last test

  - test_byteonly.jal: same as before, but with "byte"

Results:

test_byteonly.jal compiled, running tests...
test_test : OK
test_geo : OK


It works !

This should be tested for real to check, but if I were you, I would dig this
"case", there are weird things about it.

Sorry for this very long and cryptic mail :) Hope it helps though.


Cheers,
Seb

2009/6/10 Wayne Topa <[email protected]>

> Most honorable JalList Guru's
>
> I have attached my draft library for the k107.  I still have to put in
> the descriptive text but the library does compile but is, as of today,
> untested.
>
> I am sending it now so that TPTB (The Powers That Be) can make
> suggestions as to what has to be changed to conform to your standards.
>
> Please be critical!  I want to learn! I won't mind a kick in the butt if
> I deserve it.
>
> Thanks
>
> Wayne
>
> >
>
> --
> -----------------------------------------------------------------------------
> -- Title: LCD library for the k107 Serial Backpack
> -- Author: Wayne Topa, Copyright (c) 2008..2009, all rights reserved.
> -- Adapted-by:
> -- Compiler:  >=2.4k
> --
> -- 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:
> --    Serial interface for K107 (and similar) serial LCD backpack for
> -- 2x16 to 4x20 HD44780 compatible alphanumeric LCD displays.
> -- .
> --    Expects: - 1 pin from Pic to K107
> -- .
> --    Directions for use of this library in application programs
> --    (in this sequence):
>
>
> -- define in calling program or here ???
> const byte K107_CHARS = 20
> var byte i
> -- var byte cmd[]
>
> procedure k107_init(byte in  geo) is
>    var byte cmd[]
>    case geo of
>        216: block const byte cmd[] = "?G216" end block
>        220: block const byte cmd[] = "?G220" end block
>        224: block const byte cmd[] = "?G224" end block
>        240: block const byte cmd[] = "?G240" end block
>        416: block const byte cmd[] = "?G416" end block
>        420: block const byte cmd[] = "?G420" end block
>    end case
>    for 5 using i loop
>        serial_sw_write(cmd[i])
>    end loop
> --  delay required when writing to K107 EEPROM
>    delay_100ms(2)
> end procedure
>
> -- Tab size can be 1-8
> procedure k107_tabsize(byte in tab) is
>    serial_sw_write("?")
>    serial_sw_write("s")
>    serial_sw_write(tab)
>    delay_100ms(2)
> end procedure
>
> procedure k107_cursor_style(byte in c_style) is
>    serial_sw_write("?")
>    serial_sw_write("c")
>    serial_sw_write(c_style)
>    delay_100ms(2)
> end procedure
>
> -- Back Light settings 00 to FF hex. Use 80 or less normally
> procedure k107_backlight(byte in bl) is
>    serial_sw_write("?")
>    serial_sw_write("s")
>    serial_sw_write(bl)
> end procedure
>
> -- goto line
>
> procedure k107_goto_line(byte in ln) is
>    serial_sw_write("?")
>    serial_sw_write("y")
>    serial_sw_write(ln)
> end procedure
>
> -- goto column
>
> procedure k107_goto_column(byte in cl) is
>    serial_sw_write("?")
>    serial_sw_write("x")
>    serial_sw_write(cl)
> end procedure
>
> --  home cursor
>
> procedure k107_home() is
>    serial_sw_write("?")
>    serial_sw_write("a")
> end procedure
>
> -- CLRF, cursor at start of line, line cleared
>
> procedure k107_clrf() is
>        serial_sw_write("?")
>        serial_sw_write("n")
> end procedure
>
> -- tab, advances display one tab postiion
>
> procedure k107_tab() is
>    serial_sw_write("?")
>    serial_sw_write("t")
> end procedure
>
> -- carrage return, cursor to start of current line
>
> procedure k107_CR() is
>    serial_sw_write("?")
>    serial_sw_write("m")
> end procedure
>
> -- clear current line, cursor to start of current line
>
> procedure k107_clr_line_home() is
>    serial_sw_write("?")
>    serial_sw_write("l")
> end procedure
>
>
> -- clear screen and leave cursor at home position
>
> procedure k107_clear() is
>    serial_sw_write("?")
>    serial_sw_write("f")
> end procedure
>
> -- Non-destructive backspace
>
> procedure k107_cur_back_1_no_del() is
>    serial_sw_write("?")
>    serial_sw_write("h")
> end procedure
>
> -- destructive backspace
>
> procedure k107_cur_back_1_del() is
>    serial_sw_write("?")
>    serial_sw_write("b")
> end procedure
>
> -- forward cursor
>
> procedure k107_cur_forward_1() is
>    serial_sw_write("?")
>    serial_sw_write("i")
> end procedure
>
> -- down cursor
>
> procedure k107_cur_down_1() is
>    serial_sw_write("?")
>    serial_sw_write("j")
> end procedure
>
> -- up cursor
>
> procedure k107_cur_up_1() is
>    serial_sw_write("?")
>    serial_sw_write("k")
> end procedure
>
>
>
>


-- 
Sébastien Lelong
http://www.sirloon.net
http://sirbot.org

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

Attachment: test_orig.jal
Description: Binary data

Attachment: test_noconst.jal
Description: Binary data

Attachment: test_noconst_noassign.jal
Description: Binary data

Attachment: test_byteonly.jal
Description: Binary data

Reply via email to