Revision: 1124 Author: jsuijs Date: Sun Jul 26 14:57:13 2009 Log: backlight added for release. http://code.google.com/p/jallib/source/detail?r=1124
Added: /trunk/sample/16f648a_backlight.jal /trunk/sample/16f877a_backlight.jal /trunk/sample/16f88_backlight.jal Modified: /trunk/CHANGELOG /trunk/TORELEASE /trunk/test/external/lcd/test_backlight.jal ======================================= --- /dev/null +++ /trunk/sample/16f648a_backlight.jal Sun Jul 26 14:57:13 2009 @@ -0,0 +1,118 @@ +-- ------------------------------------------------------ +-- Title: Test program for lcd_backlight test (basic test) +-- +-- Author: Joep Suijs, Copyright (c) 2008..2008, 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: Testing lcd_backlight +-- -- +-- This file defines a test for JALLIB testing, using a test-board +-- defined by a BOARD file . +-- +-- Sources: +-- +-- Notes: +-- setup: A hd44780 compatible display, used in 4-bit mode with backlight +-- +-- ------------------------------------------------------ +-- +-- This file has been generated from: +-- * board: board_16f648a_js.jal +-- * test : test_backlight.jal +-- + +;@jallib section chipdef +-- chip setup +include 16f648a + +-- +-- This program assumes a 20 MHz resonator or crystal +-- is connected to pins OSC1 and OSC2. +pragma target OSC HS -- HS crystal or resonator +pragma target clock 20_000_000 -- oscillator frequency +pragma target WDT disabled +pragma target LVP disabled + +;@jallib section lcd_hd44780_4 +-- LCD IO definition +var bit lcd_rs is pin_b4 -- LCD command/data select. +var bit lcd_rs_direction is pin_b4_direction +var bit lcd_en is pin_b0 -- LCD data trigger +var bit lcd_en_direction is pin_b0_direction + +var byte lcd_dataport is porta_low -- LCD data port +var byte lcd_dataport_direction is porta_low_direction +const byte LCD_ROWS = 2 -- 2 lines +const byte LCD_CHARS = 16 -- 16 chars per line +;@jallib section led +-- LED IO definition +var bit led is pin_b3 +var bit led_direction is pin_b3_direction +var bit led2 is pin_b1 +var bit led2_direction is pin_b1_direction +;@jallib section ccp +-- backlight control (can be variable and digital on this pin) +var volatile bit lcd_bl is pin_b3 +var volatile bit lcd_bl_direction is pin_b3_direction +enable_digital_io() -- disable analog I/O (if any) + +-- setup libs, io etc +lcd_rs_direction = output +lcd_en_direction = output +lcd_dataport_direction = output + +include print +include lcd_hd44780_4 +include delay +lcd_init() -- initialize LCD + +lcd_clear_screen() +lcd_home() + +const byte teststring[] = "Backlight test." +print_string(lcd, teststring) + +const byte lcd_backlight_pwm = 1 -- by selecting the pwm pin, lcd_backlight_variable() is enabled. +lcd_bl_direction = output +;const bit lcd_bl_inverted = true -- define this when pin low turns backlight on + +-- include & init backlight lib +include lcd_backlight +pwm_backlight_init() + +var byte i +forever loop + + -- set backlight off for two seconds + lcd_backlight(off) + delay_100ms(20) + + -- set backlight on for two seconds + lcd_backlight(on) + delay_100ms(20) + + if(defined(lcd_backlight_pwm) == true) then + + -- we have variable backlight! + + -- first increase intensity + for 255 using i loop + lcd_backlight_variable(i) + delay_1ms(10) + end loop + + -- and decrease intensity + for 255 using i loop + lcd_backlight_variable(255-i) + delay_1ms(10) + end loop + + end if + +end loop ======================================= --- /dev/null +++ /trunk/sample/16f877a_backlight.jal Sun Jul 26 14:57:13 2009 @@ -0,0 +1,128 @@ +-- ------------------------------------------------------ +-- Title: Test program for lcd_backlight test (basic test) +-- +-- Author: Joep Suijs, Copyright (c) 2008..2008, 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: Testing lcd_backlight +-- -- +-- This file defines a test for JALLIB testing, using a test-board +-- defined by a BOARD file . +-- +-- Sources: +-- +-- Notes: +-- setup: A hd44780 compatible display, used in 4-bit mode with backlight +-- +-- ------------------------------------------------------ +-- +-- This file has been generated from: +-- * board: board_16f877a_dwarf.jal +-- * test : test_backlight.jal +-- + +;@jallib section chipdef +-- chip setup +include 16f877a + +pragma target clock 20_000_000 -- xtal frequency +pragma target OSC hs +pragma target LVP disabled +pragma target WDT disabled +;@jallib section lcd_hd44780_4 +-- LCD IO definition +var bit lcd_rs is pin_b5 -- LCD command/data select. +var bit lcd_rs_direction is pin_b5_direction +var bit lcd_en is pin_b4 -- LCD data trigger +var bit lcd_en_direction is pin_b4_direction + +-- primary dataport nibble: +var byte lcd_dataport is portb_low -- LCD data port +var byte lcd_dataport_direction is portb_low_direction + +-- alternative dataport bits: +var bit lcd_d4 is pin_b0 +var bit lcd_d5 is pin_b1 +var bit lcd_d6 is pin_b2 +var bit lcd_d7 is pin_b3 +var bit lcd_d4_direction is pin_b0_direction +var bit lcd_d5_direction is pin_b1_direction +var bit lcd_d6_direction is pin_b2_direction +var bit lcd_d7_direction is pin_b3_direction + +const byte LCD_ROWS = 2 -- 2 lines +const byte LCD_CHARS = 16 -- 16 chars per line + +;@jallib section led +-- LED IO definition +var bit led is pin_b6 +var bit led_direction is pin_b6_direction +var bit led2 is pin_a1 +var bit led2_direction is pin_a1_direction +;@jallib section ccp +-- backlight control (can be variable and digital on this pin) +var volatile bit lcd_bl is pin_c2 +var volatile bit lcd_bl_direction is pin_c2_direction + +enable_digital_io() -- disable analog I/O (if any) + +-- setup libs, io etc +lcd_rs_direction = output +lcd_en_direction = output +lcd_dataport_direction = output + +include print +include lcd_hd44780_4 +include delay +lcd_init() -- initialize LCD + +lcd_clear_screen() +lcd_home() + +const byte teststring[] = "Backlight test." +print_string(lcd, teststring) + +const byte lcd_backlight_pwm = 1 -- by selecting the pwm pin, lcd_backlight_variable() is enabled. +lcd_bl_direction = output +;const bit lcd_bl_inverted = true -- define this when pin low turns backlight on + +-- include & init backlight lib +include lcd_backlight +pwm_backlight_init() + +var byte i +forever loop + + -- set backlight off for two seconds + lcd_backlight(off) + delay_100ms(20) + + -- set backlight on for two seconds + lcd_backlight(on) + delay_100ms(20) + + if(defined(lcd_backlight_pwm) == true) then + + -- we have variable backlight! + + -- first increase intensity + for 255 using i loop + lcd_backlight_variable(i) + delay_1ms(10) + end loop + + -- and decrease intensity + for 255 using i loop + lcd_backlight_variable(255-i) + delay_1ms(10) + end loop + + end if + +end loop ======================================= --- /dev/null +++ /trunk/sample/16f88_backlight.jal Sun Jul 26 14:57:13 2009 @@ -0,0 +1,132 @@ +-- ------------------------------------------------------ +-- Title: Test program for lcd_backlight test (basic test) +-- +-- Author: Joep Suijs, Copyright (c) 2008..2008, 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: Testing lcd_backlight +-- -- +-- This file defines a test for JALLIB testing, using a test-board +-- defined by a BOARD file . +-- +-- Sources: +-- +-- Notes: +-- setup: A hd44780 compatible display, used in 4-bit mode with backlight +-- +-- ------------------------------------------------------ +-- +-- This file has been generated from: +-- * board: board_16f88_js.jal +-- * test : test_backlight.jal +-- + +;@jallib section chipdef +-- chip setup +include 16f88 + +;-- +;-- This setup assumes a 20 MHz resonator or crystal +;-- is connected to pins OSC1 and OSC2. +pragma target OSC HS -- HS crystal or resonator +pragma target clock 20_000_000 -- oscillator frequency +pragma target WDT disabled -- no watchdog +pragma target LVP disabled -- no low-voltage programming +pragma target CCP1MUX RB3 -- ccp1 pin on B3 + +-- +-- This setup uses the internal oscillator +;pragma target OSC INTOSC_NOCLKOUT -- HS crystal or resonator +;pragma target clock 8_000_000 -- oscillator frequency +;pragma target WDT disabled -- no watchdog +;pragma target LVP disabled -- no low-voltage programming +;pragma target CCP1MUX RB3 -- ccp1 pin on B3 +;OSCCON_IRCF = 7 -- set prescaler to 1 (8 MHz) + +;@jallib section lcd_hd44780_4 +-- LCD IO definition +var bit lcd_rs is pin_b4 -- LCD command/data select. +var bit lcd_rs_direction is pin_b4_direction +var bit lcd_en is pin_b0 -- LCD data trigger +var bit lcd_en_direction is pin_b0_direction + +var byte lcd_dataport is porta_low -- LCD data port +var byte lcd_dataport_direction is porta_low_direction +const byte LCD_ROWS = 2 -- 2 lines +const byte LCD_CHARS = 16 -- 16 chars per line +;@jallib section led +-- LED IO definition +var bit led is pin_b3 +var bit led_direction is pin_b3_direction +var bit led2 is pin_b1 +var bit led2_direction is pin_b1_direction +;@jallib section ccp +-- ccp setup: since CCP1 is multiplexed, we need to define +-- alias pointing to the active CCP1 pin +var volatile bit pin_ccp1_direction is pin_ccp1_rb3_direction + +-- backlight control (can be variable and digital on this pin) +var volatile bit lcd_bl is pin_b3 +var volatile bit lcd_bl_direction is pin_b3_direction +enable_digital_io() -- disable analog I/O (if any) + +-- setup libs, io etc +lcd_rs_direction = output +lcd_en_direction = output +lcd_dataport_direction = output + +include print +include lcd_hd44780_4 +include delay +lcd_init() -- initialize LCD + +lcd_clear_screen() +lcd_home() + +const byte teststring[] = "Backlight test." +print_string(lcd, teststring) + +const byte lcd_backlight_pwm = 1 -- by selecting the pwm pin, lcd_backlight_variable() is enabled. +lcd_bl_direction = output +;const bit lcd_bl_inverted = true -- define this when pin low turns backlight on + +-- include & init backlight lib +include lcd_backlight +pwm_backlight_init() + +var byte i +forever loop + + -- set backlight off for two seconds + lcd_backlight(off) + delay_100ms(20) + + -- set backlight on for two seconds + lcd_backlight(on) + delay_100ms(20) + + if(defined(lcd_backlight_pwm) == true) then + + -- we have variable backlight! + + -- first increase intensity + for 255 using i loop + lcd_backlight_variable(i) + delay_1ms(10) + end loop + + -- and decrease intensity + for 255 using i loop + lcd_backlight_variable(255-i) + delay_1ms(10) + end loop + + end if + +end loop ======================================= --- /trunk/CHANGELOG Mon Jul 20 08:38:26 2009 +++ /trunk/CHANGELOG Sun Jul 26 14:57:13 2009 @@ -24,7 +24,9 @@ externals: - - + - Added: Backlight API for LCD backlight on/off or pwm + - Keyboard updated: new one-shot function getkey_once() and configuration of + used pins without modification of the library peripherals: - adc: new ADC libraries available, handles more PICs than previous. ======================================= --- /trunk/TORELEASE Sun Jul 19 11:54:58 2009 +++ /trunk/TORELEASE Sun Jul 26 14:57:13 2009 @@ -147,6 +147,7 @@ include/device/chipdef_jallib.jal # Externals +include/external/co2/backlight.jal include/external/co2/co2_t6603.jal include/external/humidity/humidity_sht.jal include/external/keyboard/keyboard.jal @@ -241,7 +242,8 @@ sample/16f630_blink.jal sample/16f631_blink.jal sample/16f636_blink.jal -sample/16f639_blink.jal +sample/16f639_blink.jal +sample/16f648a_backlight.jal sample/16f648a_blink.jal sample/16f648a_data_eeprom.jal sample/16f648a_i2c_sw_l1.jal @@ -312,6 +314,7 @@ sample/16f877_adc.jal sample/16f877_blink.jal sample/16f877_pata_hard_disk.jal +sample/16f877a_backlight.jal sample/16f877a_blink.jal sample/16f877a_co2_t6603.jal sample/16f877a_i2c_hw_l1.jal @@ -336,6 +339,7 @@ sample/16f877a_serial_print.jal sample/16f88_adc_lowres.jal sample/16f88_adc_highres.jal +sample/16f88_backlight.jal sample/16f88_blink.jal sample/16f88_data_eeprom.jal sample/16f88_delay_basic.jal ======================================= --- /trunk/test/external/lcd/test_backlight.jal Sun Mar 29 07:31:29 2009 +++ /trunk/test/external/lcd/test_backlight.jal Sun Jul 26 14:57:13 2009 @@ -22,11 +22,12 @@ -- -- ------------------------------------------------------ -enable_digital_io() -- disable analog I/O (if any) - ;@jallib use chipdef ;@jallib use lcd_hd44780_4 -;@jallib use led +;@jallib use led +;@jallib use ccp + +enable_digital_io() -- disable analog I/O (if any) -- setup libs, io etc lcd_rs_direction = output --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
