Author: jsuijs
Date: Sun Mar  8 05:51:43 2009
New Revision: 839

Added:
    trunk/sample/test/peripheral/usart/serial_tc_header.jal
Modified:
    trunk/include/external/lcd/lcd_dog_m_4.jal
    trunk/include/external/lcd/lcd_dog_m_8.jal
    trunk/include/external/lcd/lcd_dog_m_spi.jal
    trunk/include/external/lcd/lcd_hd44780_common.jal
    trunk/sample/test/external/lcd/test_display_hd44780_4_line.jal
    trunk/sample/test/peripheral/usart/serial_testconsole.jal

Log:
dogm jsg fix + work on lcd/lcd_hd44780_common.jal

Modified: trunk/include/external/lcd/lcd_dog_m_4.jal
==============================================================================
--- trunk/include/external/lcd/lcd_dog_m_4.jal  (original)
+++ trunk/include/external/lcd/lcd_dog_m_4.jal  Sun Mar  8 05:51:43 2009
@@ -117,7 +117,7 @@
      asm nop                                      -- delay (> 400 ns)
      lcd_en = low                                 -- trigger off

-    delay_10uS(lcd_normal_delay)                         -- required normal 
delay
+    delay_10us(lcd_normal_delay)                         -- required normal 
delay

  end procedure

@@ -145,7 +145,7 @@
     _lcd_write( value )                      -- output byte

     if value < 4 then                                  -- "clear display' and 
'return home'
-      delay_10uS( lcd_long_delay )                     -- require extra delay
+      delay_10us( lcd_long_delay )                     -- require extra delay
     end if

  end procedure

Modified: trunk/include/external/lcd/lcd_dog_m_8.jal
==============================================================================
--- trunk/include/external/lcd/lcd_dog_m_8.jal  (original)
+++ trunk/include/external/lcd/lcd_dog_m_8.jal  Sun Mar  8 05:51:43 2009
@@ -103,7 +103,7 @@
     lcd_en = high                                -- trigger on
     asm nop                                      -- delay (> 400 ns)
     lcd_en = low                                 -- trigger off
-   delay_10uS(lcd_normal_delay)                  -- required normal delay
+   delay_10us(lcd_normal_delay)                  -- required normal delay
  end procedure


@@ -130,7 +130,7 @@
     _lcd_write( value )                      -- output byte

     if value < 4 then                                  -- "clear display' and 
'return home'
-      delay_10uS( lcd_long_delay )                       -- require extra delay
+      delay_10us( lcd_long_delay )                       -- require extra delay
     end if

  end procedure

Modified: trunk/include/external/lcd/lcd_dog_m_spi.jal
==============================================================================
--- trunk/include/external/lcd/lcd_dog_m_spi.jal        (original)
+++ trunk/include/external/lcd/lcd_dog_m_spi.jal        Sun Mar  8 05:51:43 2009
@@ -35,7 +35,7 @@
  --          var   bit  lcd_csb       is  pin_A3      -- 1 data pin
  --      or if csb is connected to gnd:
  --          var   bit  lcd_csb       is  not_connected
-
+-- --
  --    2. Include this library.
  --    and somewhere before actually using the lcd:
  --    3. Set the chosen LCD data and control pins to output:
@@ -47,22 +47,22 @@
  --          pin_b1_direction    = output
  --    4. Call lcd_init() to initialize the lcd controller.
  --    Above is an example for a 2x16 LCD:
---
+-- --
  --    Available functions for application programs:
---
---
+-- --
+-- --
  --      _lcd_write(<byte>)                     ends byte from value to
  --                                             register of the lcd  and
  --                                             shift cursor position 1  
right
---
+-- --
  --      _lcd_write_data(<byte>)                write data to lcd using
  --                                             _lcd_write(<byte>) lcd_rs  
high
---
+-- --
  --      _lcd_write_data(<byte>)                write command to lcd using
  --                                             _lcd_write(<byte>) lcd_rs  
low
---
+-- --
  --      lcd_init()                             initialize the LCD  
controller
---
+-- --
  --
  -- Dependencies: delay.jal
  --
@@ -118,7 +118,7 @@
            lcd_clk = low
            value = value << 1                  -- shift data to MSB
        end loop
-    delay_10uS(lcd_normal_delay)               -- required normal delay
+    delay_10us(lcd_normal_delay)               -- required normal delay
      lcd_csb = low                             -- unselect lcd (let him sleep)
  end procedure

@@ -146,7 +146,7 @@
     _lcd_write( value )                      -- output byte

     if value < 4 then                                  -- "clear display' and 
'return home'
-      delay_10uS( lcd_long_delay )                     -- require extra delay
+      delay_10us( lcd_long_delay )                     -- require extra delay
     end if

  end procedure

Modified: trunk/include/external/lcd/lcd_hd44780_common.jal
==============================================================================
--- trunk/include/external/lcd/lcd_hd44780_common.jal   (original)
+++ trunk/include/external/lcd/lcd_hd44780_common.jal   Sun Mar  8 05:51:43  
2009
@@ -32,8 +32,8 @@
  --   writes 'value' to lcd
  --   example: lcd = "E"  or lcd = 69
  --        ---------------
--- * lcd_new_line_cursor_position(byte in line, byte in pos):
---   places the cursor on position (pos) in line (line)
+-- * lcd_cursor_position(byte in line, byte in pos):
+--   places the cursor on position (pos) in line (line) (zero based!)
  --   example: lcd_new_line_cursor_position (1, 8)
  --         --------------
  -- * lcd_shift_left(byte in value):
@@ -58,15 +58,13 @@
  --   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_clear:
+--   Write "20H" to DDRAM and set DDRAM address to "00H" from AC
+--   This will clear the display.
  --
  -- * 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.
+--   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),
@@ -229,7 +227,12 @@
  --  
----------------------------------------------------------------------------

  --  
----------------------------------------------------------------------------
--- lcd_cursor_blink_display - (re)sets cursor blink and puts display on/off
+-- lcd_cursor_blink_display - (re)sets cursor blink and puts display on/off
+--  
----------------------------------------------------------------------------
+-- params:
+--    cursor:  enable or disable the cursor
+--    blink:   enable or disable blinking of the cursor
+--    display: enable or disable the whole display
  --  
----------------------------------------------------------------------------
  procedure lcd_cursor_blink_display(bit in cursor, bit in blink, bit in  
display) is
    var byte reg

Modified: trunk/sample/test/external/lcd/test_display_hd44780_4_line.jal
==============================================================================
--- trunk/sample/test/external/lcd/test_display_hd44780_4_line.jal       
(original)
+++ trunk/sample/test/external/lcd/test_display_hd44780_4_line.jal      Sun Mar 
  
8 05:51:43 2009
@@ -30,6 +30,12 @@
  ;@jallib use lcd_hd44780_4
  ;@jallib use led

+--  
----------------------------------------------------------------------------
+-- optionally include this file to gain access to the tc_var* variables
+--  
----------------------------------------------------------------------------
+include serial_tc_header
+
+
  -- setup libs, io etc
  lcd_rs_direction        = output
  lcd_en_direction        = output
@@ -74,6 +80,17 @@
  -- (testname string constants are optional)
  --  
-----------------------------------------------------------------------------

+-- test support function
+var byte testchar = "a"
+procedure increment_testchar() is
+   testchar = testchar + 1;
+   if (testchar > "z") then
+      testchar = "a"
+   end if
+end procedure
+-- test support function end
+
+

  const byte testname_a[] = "clear screen"
  procedure unit_test_a() is
@@ -82,7 +99,7 @@

  const byte testname_b[] = "home"
  procedure unit_test_b() is
-   lcd_clear_screen()
+   lcd_home()
  end procedure

  const byte testname_c[] = "set cursor position to 0,0 (start line 0)"
@@ -105,43 +122,50 @@
     lcd_cursor_position(3,0)
  end procedure

-const byte testname_g[] = "set cursor position to 0,5"
+const byte testname_g[] = "set cursor position to tc_var0, tc_var1"
  procedure unit_test_g() is
-   lcd_cursor_position(0,5)
+   lcd_cursor_position(tc_var0, tc_var1)
  end procedure

-const byte testname_h[] = "print 'abcd' to cursor pos with lcd_write_char"
+const byte testname_h[] = "print 4 incremening chars to cursor pos with  
lcd_write_char"
  procedure unit_test_h() is
-   lcd_write_char("a")
-   lcd_write_char("b")
-   lcd_write_char("c")
-   lcd_write_char("d")
+   for 4 loop
+      lcd_write_char(testchar)
+      increment_testchar()
+   end loop
  end procedure

-const byte testname_i[] = "print 'abcd' to cursor pos with lcd'put"
+const byte testname_i[] = "print 4 incremening chars to cursor pos with  
lcd'put"
  procedure unit_test_i() is
-   lcd = "a"
-   lcd = "b"
-   lcd = "c"
-   lcd = "d"
+   for 4 loop
+      lcd = testchar
+      increment_testchar()
+   end loop
  end procedure

+-- this test shows a incrementing counter on the first line
+-- and a progress bar on the second line.
  const byte testname_p[] = "progress bar"
  procedure unit_test_p() is
     const byte bar_divider = (255 / (LCD_CHARS-1))

-   lcd_cursor_blink_display (off,off,on)
+   const byte tc_p[] = "progress      "
+   lcd_cursor_position(0,0)
+   print_string(lcd, tc_p);
+
+   lcd_cursor_blink_display (off,off,on) -- cursor off (blink off, display  
on)
     lcd_clear_line(1)
-   value = 0
-   while value < 255  loop
-;         lcd_bvalue_dp_line_pos_left_sign ( value, 0, 1, 5, true, false)
-      value = value + 1
-      delay_1ms(50)
-      lcd_progress(1, value/ bar_divider +1, 0xFF)
+   for 256 using value loop
+      -- print var
+      lcd_cursor_position(0,9)
+      print_byte_dec(lcd, value)
+
+      -- print coressponding progress bar
+      lcd_progress(1, value / bar_divider +1, 0xFF)
+
+      -- wait & increment
+      delay_1ms(20)
     end loop
-;      lcd_bvalue_dp_line_pos_left_sign ( value, 0, 1, 5, true, false)
-   delay_100ms (20)
-   lcd_clear_screen()
  end procedure



Added: trunk/sample/test/peripheral/usart/serial_tc_header.jal
==============================================================================
--- (empty file)
+++ trunk/sample/test/peripheral/usart/serial_tc_header.jal     Sun Mar  8  
05:51:43 2009
@@ -0,0 +1,58 @@
+-- ------------------------------------------------------
+-- Title: Serial tc header
+--
+-- Author: Joep Suijs, Copyright (c) 2009..2009, all rights reserved.
+--
+-- Adapted-by:
+--
+-- 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 file is used with serial_testconsole. Look there for  
more info.
+-- --
+--
+-- Sources:
+--
+-- Notes:
+--
+-- ------------------------------------------------------
+
+include serial_hardware
+include delay
+include print                       -- output library
+
+var word tc_var[10]
+
+var word tc_var0 at tc_var[0]
+var word tc_var1 at tc_var[1]
+var word tc_var2 at tc_var[2]
+var word tc_var3 at tc_var[3]
+var word tc_var4 at tc_var[4]
+var word tc_var5 at tc_var[5]
+var word tc_var6 at tc_var[6]
+var word tc_var7 at tc_var[7]
+var word tc_var8 at tc_var[8]
+var word tc_var9 at tc_var[9]
+
+
+procedure testconsole_init() is
+   var byte i
+
+   serial_hw_init()
+
+   led_direction = output
+   for 2 loop
+      LED = on
+      delay_100ms(1)
+      LED = off
+      delay_100ms(1)
+   end loop
+
+   for 10 using i loop
+      tc_var[i] = 0
+   end loop
+
+end procedure
+

Modified: trunk/sample/test/peripheral/usart/serial_testconsole.jal
==============================================================================
--- trunk/sample/test/peripheral/usart/serial_testconsole.jal   (original)
+++ trunk/sample/test/peripheral/usart/serial_testconsole.jal   Sun Mar  8  
05:51:43 2009
@@ -21,23 +21,12 @@
  -- setup: a terminal program connected to the serial port
  --
  -- ------------------------------------------------------
-
-include serial_hardware
-include delay
-include print                       -- output library
-
-procedure testconsole_init() is
-   serial_hw_init()
-
-   led_direction = output
-   for 2 loop
-      LED = on
-      delay_100ms(1)
-      LED = off
-      delay_100ms(1)
-   end loop
-
-end procedure
+
+-- The user could include this header before definition of the
+-- unit_test to gain access to tc_value* vars.
+-- To be sure it is included at least once, it is included here gain.
+-- And the compiler prevents multiple inclusion :)
+include serial_tc_header

  --  
-----------------------------------------------------------------------------
  -- run_test -
@@ -124,6 +113,119 @@
     return false;
  end function

+
+procedure _serial_varmenu_printvar(byte in varnr) is
+   const byte test_vmp1[] = "tc_var"
+
+   print_string(serial_hw_data, test_vmp1)
+   serial_hw_data = "0" + varnr
+   serial_hw_data = " "
+   serial_hw_data = "="
+   serial_hw_data = " "
+   print_word_dec(serial_hw_data, tc_var[varnr])
+   serial_hw_data = " "
+   serial_hw_data = "("
+   print_prefix = true
+   print_word_hex(serial_hw_data, tc_var[varnr])
+   serial_hw_data = ")"
+   print_crlf(serial_hw_data)
+
+end procedure
+
+
+var byte tc_menu_index = 0
+
+--  
----------------------------------------------------------------------------
+-- _testconsole_varmenu - enable variable setting from serial console
+--  
----------------------------------------------------------------------------
+-- ! selects this menu
+-- ` exits this menu
+-- todo -- h set hex input mode
+-- todo -- d set decimal input mode
+-- space print all vars
+-- 0..9 select var
+-- todo i goto value input mode
+-- + increment var by 1
+-- = increment var by 1 (= is unshifted plus on my keyboard)
+-- - decrement var by 1
+--
+-- todo -- in value input mode:
+-- todo --    enter - store value
+-- todo --    space - abort value input
+-- todo --    0..9 A..F - input value (value = value * 10 + input)
+--  
----------------------------------------------------------------------------
+procedure _testconsole_varmenu() is
+   const byte test_varmenu_msg[] = "Testconsole variable menu.\r\n"
+   var byte ledcounter;
+   var bit print_all_vars = true
+   var bit print_active_var = true
+   var byte char, i
+
+   print_string(serial_hw_data, test_varmenu_msg)
+   forever loop
+
+      -- --------------
+      -- printing stuff
+      -- --------------
+      if (print_all_vars) then
+         for 10 using i loop
+            if (i ==  tc_menu_index) then
+               serial_hw_data = "*"
+            end if
+            _serial_varmenu_printvar(i)
+         end loop
+         print_all_vars = false
+      end if
+
+      if (print_active_var) then
+         serial_hw_data = "*"
+         _serial_varmenu_printvar(tc_menu_index)
+         print_active_var = false
+      end if
+
+      -- -----------------------
+      -- check for received char
+      -- -----------------------
+      if (serial_hw_read(char) == true) then
+         -- char received
+         if (char == "`") then
+            -- exit menu
+            return
+         end if
+
+         if (char == " ") then
+            print_all_vars = true
+         end if
+
+         if ((char == "+") | (char == "=")) then
+            -- increment var by 1
+            tc_var[tc_menu_index] = tc_var[tc_menu_index] + 1
+            print_active_var = true
+         end if
+
+         if (char == "-") then
+            -- decrement var by 1
+            tc_var[tc_menu_index] = tc_var[tc_menu_index] - 1
+            print_active_var = true
+         end if
+
+         if ((char >="0") & (char <= "9")) then
+            -- select var to change
+            tc_menu_index = char & 0x0F -- ascii to numeric
+            print_active_var = true
+         end if
+      end if
+
+      -- ---------------------------
+      -- blink led while in var menu
+      -- ---------------------------
+      ledcounter = ledcounter + 1
+      LED = (ledcounter > 127)
+
+   end loop
+
+end procedure
+
  --  
-----------------------------------------------------------------------------
  -- testconsole - this is the main test loop
  --  
-----------------------------------------------------------------------------
@@ -141,9 +243,13 @@
        -- wait for char
        LED = on
        while (serial_hw_read(char) == false) loop end loop
+          toupper(char)  -- convert testcmd to upper case
        LED = off

-          toupper(char)  -- convert testcmd to upper case
+      if (char == "!") then
+         _testconsole_varmenu()
+         char = 0 -- no more processing
+      end if
        if ((char >= "A") & (char <= "Z")) then
           -- valid test range
           testnr   = char               -- A...Z

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

Reply via email to