Author Topic: Example code  (Read 6540 times)

sk_uk

  • Hero Member
  • *****
  • Posts: 80
    • View Profile
    • http://www.skpang.co.uk
Example code
« on: November 27, 2006, 12:18:47 PM »
Any example code available to use these serial LCD displays?

mariusz

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Example code
« Reply #1 on: January 15, 2007, 12:28:44 AM »
Hi,

I am also interested, I ask for some examples...

Regards
Mariusz


modtro2

  • Administrator
  • Hero Member
  • *****
  • Posts: 564
    • View Profile
Re: Example code
« Reply #2 on: January 17, 2007, 02:32:44 AM »
I will soon be creating I2C versions of the current SPI examples on this forum. Will this be what you are after, or were you thinking of something else?

mariusz

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Example code
« Reply #3 on: January 18, 2007, 01:55:12 AM »
Hi,

1. Display string on LCD ("Hello world".....)
2. Read & display 4x4 keypad data.....
3. Upload & display custom character....
4. write parsed string (0x80), set startup screen (0x90)
5. Draw Bar Graph

for 16x2 and

6. write large number string to LCD for 4x20

all for I2C mode.

in ccs c ??.... please.

Regards,
Mariusz


 

OmarZ

  • Hero Member
  • *****
  • Posts: 243
    • View Profile
Re: Example code
« Reply #4 on: January 18, 2007, 11:54:49 AM »
i agree requests, but first for the standard MCC18 microchip compiler, than for others ....

Thanks

mariusz

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Example code
« Reply #5 on: February 04, 2007, 05:07:33 AM »
Hi,
Small demo... (CCS C, SBC44B,877A,20MHz):


I2C_LCD2S.C
-----------------------------------------------------------------------------------------------------------------------------------
#include <string.h>

#define adresLCD2S_1 0x50 // DIP switch 00
#define adresLCD2S_2 0x52 // DIP switch 01
#define adresLCD2S_3 0x54 // DIP switch 10

#define backlight_on_ 0x28
#define backlight_off_ 0x20
#define clear_display_ 0x8C
#define display_on_ 0x1A
#define display_off_ 0x12
#define cursor_forward_ 0x09
#define cursor_backwards_ 0x01
#define blinking_cursor_on_ 0x18
#define blinking_cursor_off_ 0x10
#define underline_cursor_on_ 0x19
#define underline_cursor_off_ 0x11
#define move_cursor_right_ 0x83
#define move_cursor_left_ 0x84
#define shift_display_right_ 0x85
#define shift_display_left_ 0x86
#define shift_display_up_ 0x87
#define shift_display_down_ 0x88
#define write_parsed_string_ 0x80
#define line1_ 0x0d
#define line2_ 0x0a

unsigned char i, max;

void command2lcd(BYTE adres, BYTE komenda)
{
   i2c_start();
   i2c_write(adres);
   i2c_write(komenda);
   i2c_stop();
}

void LCD_write(char * text,BYTE adres, BYTE komenda,BYTE linia)

   i2c_start();
   i2c_write(adres);
   i2c_write(komenda);
   i2c_write(linia);              //adres linii
   max=strlen(text);
   for(i=0; i<=max-1; i++)
   {
     i2c_write(text);
   }
   i2c_stop();
}

-----------------------------------------------------------------------------------------------------------------------------------

and LCD2SDEMO.C

-----------------------------------------------------------------------------------------------------------------------------------
#include "C:\Program Files\PICC\Projects\CCS\LCD2SDEMO.h"
#include "C:\Program Files\PICC\Drivers\I2C_LCD2S.c"
//#include "C:\Program Files\PICC\Drivers\MY_IOR5S.c"
//#include "C:\Program Files\PICC\Drivers\MY_SBC44B.c"

unsigned char bufor1[17];


void main()
{
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   delay_ms (500);
   command2lcd(adresLCD2S_1, backlight_off_);
   delay_ms (500);
   command2lcd(adresLCD2S_1, backlight_on_);
   delay_ms (500);
   command2lcd(adresLCD2S_1, display_off_);
   delay_ms (500);
   command2lcd(adresLCD2S_1, display_on_);
   delay_ms (500);
   command2lcd(adresLCD2S_1, clear_display_);
   delay_ms (1000);
     
   strcpy(buffer1,"First line");
   LCD_write(bufor1, adresLCD2S_1, write_parsed_string_,line1_);
   strcpy(buffer1,"Second line");
   LCD_write(bufor1, adresLCD2S_1, write_parsed_string_,line2_);
   while (1);
}

-----------------------------------------------------------------------------------------------------------------------------------


 :-D
Regards,
Mariusz