CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

flexLCD driver and to provide fixed location on LCD

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pokiko



Joined: 27 Jul 2007
Posts: 33

View user's profile Send private message Send e-mail

flexLCD driver and to provide fixed location on LCD
PostPosted: Thu Apr 24, 2008 3:41 am     Reply with quote

Hi
Is there a way to provide cursor position to not increment or decrement when writing only one character in flex driver. When press on buttons when i want to write one character then the location of the cursor changes. Is there a way to control its location. Can we ensure this by making a little change in such part.


Code:
int8 const LCD_INIT_STRING[4] =
{
 0x20 | (lcd_type << 2), // Func set: 4-bit, 2 lines, 5x8 dots
 0xc,                    // Display on
 1,                      // Clear display
 6                       // Increment cursor
 };



or-and
I use 2x16 LCD with flexLCD driver. I have to read a character from the keypad and write it to the desired
LCD position. Especially columns 6,7,8,12,13,15,16 of the first row of the LCD. And i also have to store these
characters. When i do it like below, cursor goes to almost everywhere and it writes the last pressed character.
So, is there any ideas for this problem which i have to write the character only to desired location.
And cursor must still lie at that position.

Thanks
Code:

 #include <16F877A.H>
#fuses HS, NOWDT, NOPUT, PROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT           
#device  adc=10
#use delay(clock=16000000)

#include  "Flex_LCD_BlinkveShift_16F877A.c"


#define row1 pin_d4
#define row2 pin_d5
#define row3 pin_d6
#define row4 pin_d7

#define column1 pin_d0
#define column2 pin_d1
#define column3 pin_d2
#define column4 pin_d3
#define column5 pin_c3

char but=0;
signed int i;
int cursorPos[7]={6,7,8,12,13,15,16};




void init_MCU();
char keypad_read();






void main(){
     
      init_MCU();
      lcd_cursor_OnOff(1);
     
      lcd_gotoxy(1,1);
      printf(lcd_putc,"\fP1 A:051 T=22.22\n");
      printf(lcd_putc,"01   STP V=000  ");
     
     
      while(1){
     
      keypad_read();
      if(keypad_read()!='\0')
      {
         if(keypad_read()!='R'||keypad_read()!='L')
         {   lcd_gotoxy(cursorPos[i],1);   
             printf(lcd_putc,"%c", keypad_read());
             i--;
             delay_ms(1000);
         }
         
         else if(keypad_read()=='R'||keypad_read()=='L')    //R right L left
         {     if(keypad_read()=='R')
               {  i++;
                  if(i>6)
                  i=0;
               }   
               else if(keypad_read()=='L')
               {  i--;
                  if(i<0)
                  i=6;
               }     
         }
         
         
      }   
}}







char keypad_read()
{    output_d(0x00);
     
      output_high(row1);
      if(input(column1))
         {delay_ms(100); but='1';}
      if(input(column2))
         {delay_ms(100); but='2';}
      if(input(column3))
         {delay_ms(100); but='3';}
      if(input(column4))
         {delay_ms(100); but='P';}
      if(input(column5))
         {delay_ms(100); but='B';} 
      output_low(row1);
     
      output_high(row2);
      if(input(column1))
         {delay_ms(100); but='4';}
      if(input(column2))
         {delay_ms(100); but='5';}
      if(input(column3))
         {delay_ms(100); but='6';}
      if(input(column4))
         {delay_ms(100); but='S';} 
      if(input(column5))
         {delay_ms(100); but='C';} 
      output_low(row2);

      output_high(row3);
      if(input(column1))
         {delay_ms(100); but='7';}
      if(input(column2))
         {delay_ms(100); but='8';}
      if(input(column3))
         {delay_ms(100); but='9';}
      if(input(column4))
         {delay_ms(100); but='+';}   
      if(input(column5))
         {delay_ms(100); but='D';} 
      output_low(row3);

      output_high(row4);
      if(input(column1))
         {delay_ms(100); but='R';}
      if(input(column2))
         {delay_ms(100); but='0';}
      if(input(column3))
         {delay_ms(100); but='L';}
      if(input(column4))
         {delay_ms(100); but='-';}   
      if(input(column5))
         {delay_ms(100); but='G';} 
      output_low(row4);

      return but;
}


void init_MCU(){
   
            SETUP_TIMER_0(RTCC_INTERNAL);
            setup_timer_1( T1_DISABLED );           
            setup_timer_2(T2_DISABLED,0,1);           
            setup_comparator(NC_NC_NC_NC);
            setup_CCP1( CCP_OFF );
            setup_CCP2( CCP_OFF);     
            setup_psp(PSP_DISABLED);
            setup_spi(SPI_SS_DISABLED);
            ext_int_edge(L_TO_H);     
            enable_interrupts( INT_EXT );
            enable_interrupts( INT_CCP1 );
            enable_interrupts( INT_CCP2 );
            SETUP_ADC(ADC_CLOCK_DIV_2);           
            setup_adc_ports(AN0_AN1_AN3);
            delay_ms(20);
            lcd_init();
            delay_ms(500);
                 
          }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 24, 2008 12:07 pm     Reply with quote

Here is a demo program of one way to do it.

This program puts the cursor in the middle of the first line. Then it
displays numbers 0 to 9 in that location. It moves the cursor back to
the same position by sending a backspace character to the LCD.
It also makes the cursor turns off the display of the cursor so you
don't have to see it move. Try this program. See if it works for you.
Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT , NOLVP
#use delay(clock=4000000)

#include "flex_lcd.c"

void lcd_setcursor_vb(short visible, short blink)
{
lcd_send_byte(0, 0xC | (visible <<1 ) | blink);
}

//==========================
void main()
{
int8 i;
lcd_init();

lcd_gotoxy(8, 1); // Put cursor in middle of line 1

lcd_setcursor_vb(0, 0);   // Turn off cursor

// Display numbers from 0 to 9 in the same position
// on the LCD.   
for(i = 0; i < 10; i++)
   {
    lcd_putc('0' +i);  // Display number
    lcd_putc('\b');    // Backspace
    delay_ms(500);
   }

while(1);
}
pokiko



Joined: 27 Jul 2007
Posts: 33

View user's profile Send private message Send e-mail

Great!!!! It works.
PostPosted: Fri Apr 25, 2008 9:43 am     Reply with quote

Thank u PCM PROGRAMMER.You are a genius. Very well, also is there a way to control the blinking of the character at the desired location with a simple function?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 25, 2008 10:44 am     Reply with quote

Look at the little function above main() in the code that I posted.
That function is from the CCS Code Library forum. Note that it
has two parameters. The 2nd parameter controls the blinking
of the cursor. Use a parameter of 1 to enable it, and a parameter
of 0 to disable blinking.
pokiko



Joined: 27 Jul 2007
Posts: 33

View user's profile Send private message Send e-mail

thank you very much PCM PROGRAMMER
PostPosted: Tue Apr 29, 2008 1:46 am     Reply with quote

Yes that's great. thanks
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group