Author: jsuijs
Date: Tue Mar 31 01:03:45 2009
New Revision: 900

Modified:
    trunk/include/external/lcd/lcd_hd44780_serial_sw.jal
    trunk/project/lcd_interface/lcd_interface.jal
    trunk/test/external/lcd/test_lcd_hd44780_serial.jal

Log:
lcd_interface now supports backlight.

Modified: trunk/include/external/lcd/lcd_hd44780_serial_sw.jal
==============================================================================
--- trunk/include/external/lcd/lcd_hd44780_serial_sw.jal        (original)
+++ trunk/include/external/lcd/lcd_hd44780_serial_sw.jal        Tue Mar 31  
01:03:45 2009
@@ -59,7 +59,7 @@
        value = value | 0x10
     end if

-   serial_sw_write(value) -- interrupts are disabled by lib
+   serial_sw_write(value) -- (interrupts are disabled by lib)
  end procedure
  --  
----------------------------------------------------------------------------

@@ -125,10 +125,6 @@
      -- init the API
      _hd44780_init()
  end procedure
-
-
-
-      procedure lcd_backlight_variable(byte in value) is

  --  
----------------------------------------------------------------------------
  -- lcd_backlight_variable - set backlight level
@@ -137,7 +133,7 @@

     value = value / 8       -- only use lower 5 bits
     value = value | (1<<5)  -- command 1 (in higher 3 bits)
-   serial_sw_write(0x20 | (value/8)) -- interrupts are disabled by lib
+   serial_sw_write(value)  -- (interrupts are disabled by lib)
  end procedure
  -- ------------

@@ -150,5 +146,5 @@
     else
        lcd_backlight_variable(0)
     end if
-end if
+end procedure


Modified: trunk/project/lcd_interface/lcd_interface.jal
==============================================================================
--- trunk/project/lcd_interface/lcd_interface.jal       (original)
+++ trunk/project/lcd_interface/lcd_interface.jal       Tue Mar 31 01:03:45 2009
@@ -14,12 +14,12 @@
  --    compatible LCD. Unlike other interfaces (like 'LCD Serial Backpack'  
and K107),
  --    this app is not aware of the HD44780 command set.
  --    The corresponding jallib libraries are given transparent access to  
the LCD in
---    4-bit mode so all current and future jallib HD44780 functionality is  
supported.
+--    4-bit mode so all current and future jallib HD44780 functionality is  
supported.
+--    In addition to this, variable backlight control is supported.
  -- --
  --    Currently, only serial comms is supported (57600,8,1)
  --    todo:
  --       - i2c slave interface
---       - backlight support
  --  
-----------------------------------------------------------------------------
  -- lcd_app.jal

@@ -27,13 +27,10 @@

  ;@jallib use chipdef
  ;@jallib use lcd_hd44780_4
-;@jallib use led
+;@jallib use serial

  enable_digital_io()

-;led_direction = output
-
-
  lcd_rs_direction        = output
  lcd_en_direction        = output
  lcd_dataport_direction  = output
@@ -48,13 +45,13 @@
  var volatile bit   cmdfield         at inchar : 5
  var volatile bit*5 datafield        at inchar : 0

-; setup pwm for backlight
+; setup pwm for backlight
+include pwm_hardware
  pin_ccp1_direction = output
  pwm_max_resolution(1)
  pwm1_on()
  pwm1_set_dutycycle(0)   -- backlight off

-
  forever loop

     if (serial_hw_read(inchar) == true) then
@@ -64,7 +61,7 @@
           __lcd_write_nibble(datafield)
        elsif (cmdfield == 1) then
           -- 5 bit pwm value in datafield
-          pwm1_set_dutycycle(datafield * 8)
+          pwm1_set_dutycycle((datafield * 8) + (datafield / 4))
        end if
     end if


Modified: trunk/test/external/lcd/test_lcd_hd44780_serial.jal
==============================================================================
--- trunk/test/external/lcd/test_lcd_hd44780_serial.jal (original)
+++ trunk/test/external/lcd/test_lcd_hd44780_serial.jal Tue Mar 31 01:03:45  
2009
@@ -64,17 +64,44 @@

  var byte counter = 0

-forever loop                            -- loop forever
+procedure backlight_slope is
+   var byte i

-   counter = counter + 1                -- update counter
-   lcd_cursor_position(1,0)             -- second line, first column (0)
-   print_byte_hex(lcd, counter)         -- output in hex format
-   delay_100ms(3)                       -- wait a little
-
-   if counter == 255 then               -- counter wrap
-      lcd_cursor_position(1,1)          -- 2nd line, 2nd char
-      lcd = " "                         -- clear 2nd char
-      lcd = " "                         -- clear 3rd char
+   -- slope increase
+   for 255 using i loop
+      lcd_backlight_variable(i)
+      delay_1ms(5)
+   end loop
+
+   -- slope decrease
+   for 255 using i loop
+      lcd_backlight_variable(255-i)
+      delay_1ms(5)
+   end loop
+
+   -- off for 2 secs
+   lcd_backlight_variable(0)
+   delay_100ms(20)
+
+
+end procedure
+
+
+forever loop                           -- loop forever
+
+   counter = counter + 1               -- update counter
+   lcd_cursor_position(1,0)            -- second line, first column (0)
+   print_byte_hex(lcd, counter)        -- output in hex format
+   delay_100ms(3)                      -- wait a little
+
+--   lcd_backlight_variable(counter)     -- test backlight
+
+   backlight_slope();
+
+   if counter == 255 then              -- counter wrap
+      lcd_cursor_position(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
-~----------~----~----~----~------~----~------~--~---

Reply via email to