Sebastien Lelong wrote: > 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 > """
I changed the sample progrms to comply, I hope. > 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 ! > Yes the init is to program the k107 16f628a/648a eeprom to set it up for a 4x20 LED (in this example). There are seperate row and col routines that go 'directly' to the LCD. the init, a 3 other routines, are ysed once to program the k107 eeprom and are not needed again unless you change LCDs. ie change a 4x20 to 2x24 requires a change in the k107 chip. I have added more information under the "Directions for use". > 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. Done! ??? dig = dump? as in throw away this junk code? :-) > Sorry for this very long and cryptic mail :) Hope it helps though. No need to be sorry. This is what I was hoping for. I have >> >> -- >> ----------------------------------------------------------------------------- >> -- 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[] This was removed and seperate routines to intitalize are put into the sample programs. see below >> 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 in addition to the init routine The 3 functions, below, have been removed from the library. They are used only when first initializing a particular LCD. Once initialized the code is no longer needed so why use the code space. >> -- 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 The column procedure is stumping me so is not included in the current library. I have to call the go to column routine with with bytes and I'm not happy with the methods I have tried. The column number is 2 digits 00 up to 49. This is why I did not use it in the samples. I have looked at & tried many variations but am still not satisfied with the results. it could be var byte ln_col[] = ("?y{0-3}?x{00-39}") so the use would be for COUNT(ln_col) using i loop serial_sw_write(ln_col[i]) end loop This could be done in a program but I can't figure out how to do it, nicely, in the library. >> -- goto column >> This prodedure does not work!!! DUMP IT >> procedure k107_goto_column(byte in cl) is >> serial_sw_write("?") >> serial_sw_write("x") >> serial_sw_write(cl) >> end procedure > serial_sw_write("a") >> end procedure Thank's for the comments, they are really appreciated!!! I am attaching a photo that shows the a static view of a display. The samples I have, for the 628a, 88 and 688 have the screen rewritten for Best Regards Wayne -- 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=.
-- ----------------------------------------------------------------------------- -- Title: LCD library for the k107 Serial Backpack -- Author: Wayne Topa, Copyright (c) 2008..2009, all rights reserved. -- Adapted-by: -- Compiler: >=2.4l -- -- 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, 20, 24 or 40 characters as well as 4x16 or 20 character -- HD44780 compatible alphanumeric LCD displays. -- . -- Expects: - 1 pin from Pic to K107 and +5 and Gnd. -- . -- Directions for use of this library in application programs -- (in this sequence): var byte i -- home cursor procedure lcd_k107_home() is serial_sw_write("?") serial_sw_write("a") end procedure -- CLRF, cursor at start of line, line cleared procedure lcd_k107_clrf() is serial_sw_write("?") serial_sw_write("n") end procedure -- tab, advances display one tab postiion procedure lcd_k107_tab() is serial_sw_write("?") serial_sw_write("t") end procedure -- carrage return, cursor to start of current line procedure lcd_k107_cr() is serial_sw_write("?") serial_sw_write("m") end procedure -- clear current line, cursor goes to start of current line procedure lcd_k107_clr_line_home() is serial_sw_write("?") serial_sw_write("l") end procedure -- clear screen and leave cursor at home position procedure lcd_k107_clear() is serial_sw_write("?") serial_sw_write("f") end procedure -- Non-destructive backspace procedure lcd_k107_cur_back_1_no_del() is serial_sw_write("?") serial_sw_write("h") end procedure -- destructive backspace procedure lcd_k107_cur_back_1_del() is serial_sw_write("?") serial_sw_write("b") end procedure -- forward cursor procedure lcd_k107_cur_forward_1() is serial_sw_write("?") serial_sw_write("i") end procedure -- down cursor procedure lcd_k107_cur_down_1() is serial_sw_write("?") serial_sw_write("j") end procedure -- up cursor procedure lcd_k107_cur_up_1() is serial_sw_write("?") serial_sw_write("k") end procedure
