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

Keypad 4x4

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



Joined: 15 Apr 2020
Posts: 4

View user's profile Send private message

Keypad 4x4
PostPosted: Wed Apr 15, 2020 1:02 pm     Reply with quote

Hello, I am new in pic c compiler, I was using MikroC and switched to CCS.

I am doing the program of the keypad 4x4 however I found the program of the keypad but it's not the one that I need to use.

I am going to change the program of the button " / " in keypad to clear all, the button " ON/C " delete one character not all, and the button " = " is to confirm.

Can anyone help me?
Ttelmah



Joined: 11 Mar 2010
Posts: 19497

View user's profile Send private message

PostPosted: Wed Apr 15, 2020 1:16 pm     Reply with quote

In the code library here:

<http://www.ccsinfo.com/forum/viewtopic.php?t=28022&start=14>

There is a more flexible version of the standard driver.
The value returned by each key is defined in the array 'KEYS'. You just change
the entries in this to what you want the keypad to return.
Salah



Joined: 15 Apr 2020
Posts: 4

View user's profile Send private message

PostPosted: Wed Apr 15, 2020 1:55 pm     Reply with quote

Ttelmah wrote:
In the code library here:

<http://www.ccsinfo.com/forum/viewtopic.php?t=28022&start=14>

There is a more flexible version of the standard driver.
The value returned by each key is defined in the array 'KEYS'. You just change
the entries in this to what you want the keypad to return.


I didn't find the ones I am looking for, could you help me more?

here is my program
Code:
void main ()
{//TRISA=0b010000;
port_b_pullups(true);
   kbd_init();
   lcd_init();
 
Trisc=0x00;
Portc=0x00;
T1CON=0b00110101;
TMR0=255;
OPTION_REG=0b00111000;
lcd_putc("Bonjour");
delay_ms(500);
lcd_putc('\f');
while (1)
{
c=kbd_getc();
      if(c!=0){
        if(c=='/')
          lcd_putc('\f');
        else
          lcd_putc(c);
       
      }


}


I already found the program of clear all, I just need to find now program to delete one character and add it here.
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 15, 2020 4:44 pm     Reply with quote

Since you're using an LCD module, there are at least 2 possible methods.

1) read the LCD module for the current cursor position, execute a 'backspace' command, then print the new character.

2) store the 'data' in an array (a buffer), when a 'backspace' is issued, subtract 1 from the index of the array, then insert the new character, you then have to print the entire array onto the LCD module.

#1 is easier BUT you need to be able to read the LCD module data.
#2 will be technically slower, but you may not notice that.

There may be more ways, everyone has their 'favorites'.

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 15, 2020 4:56 pm     Reply with quote

Do you want backspace ? It's this:
Code:

lcd_putc('\b');
Ttelmah



Joined: 11 Mar 2010
Posts: 19497

View user's profile Send private message

PostPosted: Thu Apr 16, 2020 12:35 am     Reply with quote

The point is you can change the definitions of the keys in the KEYS' array
to return the values to do what you actually 'want'. So change the key
you want to give backspace to be '\b', the one you want to clear screen
to '\f', and the one you want to be 'confirm' to '\n' (newline).
Then your code can just print every character till the '\n' is seen for
'confirm'.
However I have to query what you actually want to do?. Though this will
allow you to type to the LCD, if you want to actually 'do' anything with
this data you are going to have to store it while it is typed, so your program
can then use what has been typed....
Salah



Joined: 15 Apr 2020
Posts: 4

View user's profile Send private message

PostPosted: Thu Apr 16, 2020 10:08 am     Reply with quote

PCM programmer wrote:
Do you want backspace ? It's this:
Code:

lcd_putc('\b');


It doesn't work, this is how I typed it :

Code:

c=kbd_getc();
      if(c!=0){
        if(c=='/')
          lcd_putc('\b');
        else
          lcd_putc(c);
       
      }
Salah



Joined: 15 Apr 2020
Posts: 4

View user's profile Send private message

PostPosted: Thu Apr 16, 2020 10:31 am     Reply with quote

Here is the whole program guys, can you find the problem?
Code:

#include <16f877.h>
#use delay( clock= 4M)
#fuses XT, NOWDT
#byte INTCON = 0x0B
#bit GIE=INTCON.7
#bit TOIE=INTCON.5
#byte TMR0=0x01
#byte PORTB=0x06
#byte TRISB=0x86
#byte PORTA=0x05
#byte TRISA=0x85
#byte OPTION_REG=0x81
#byte PIE1=0x8C
#byte TMR1H=0x0F
#byte TMR1L=0x0E
#byte T1CON=0x10
#bit PEIE = INTCON.6
#bit INTE=INTCON.4
#bit TMR1IE=PIE1.0
#bit RBIE=INTCON.3
#byte trisc=0x87
#byte Portc=0x07
int k=0,i=0,j=0,y=0,k1=0;
char c;
char password[5];
char kp[16];
int T[7]={0x00,0x01,0x02,0x04,0x08,0x10,0x00};
#include "clavier16T.c"
#include <lcd.c>
#priority rtcc,timer1,rb
#int_rtcc
void F()
{
  TMR0=255;
k++;
if(k==2)
{k=0;
}
}
#int_timer1
void F2(){
  if(k==1)
  {
  TMR1H=11;
  TMR1L=220;
  k1++;
  Portc=T[j];
   if(k1==3)
     {k1=0;
      j++;
      if(j==1)
        {
        lcd_gotoxy(1,1);
        lcd_putc("Electrovanne 1 en marche ");
        }
        if(j==2)
        {lcd_gotoxy(1,1);
        lcd_putc("Electrovanne 2 en marche ");}
        if(j==3)
        {lcd_gotoxy(1,1);
        lcd_putc("Electrovanne 3 en marche ");}
        if(j==4)
        {lcd_gotoxy(1,1);
        lcd_putc("Electrovanne 4 en marche ");}
        if(j==5)
        {lcd_gotoxy(1,1);
        lcd_putc("Electrovanne 5 en marche ");}
      if(j==7)
        {j=0;k=0;
        lcd_gotoxy(1,1);
        lcd_putc("Electrovanne en repos. ");}
     }
  }
   //lcd_gotoxy(1,2);
   //printf(lcd_putc,"Electrovanne %u en marche",j);
 }
#int_rb
void F3(){

 c=kbd_getc();
      if(c!=0){
        if(c=='/')
          lcd_send_byte(0,1);
     
        else
        lcd_putc(c);
      }

   }
   i++;


}
 
void main ()
{//TRISA=0b010000;
port_b_pullups(true);
   kbd_init();
   lcd_init();
 
Trisc=0x00;
Portc=0x00;
T1CON=0b00110101;
TMR0=255;
OPTION_REG=0b00111000;
while (1)
{ GIE=1;
  TOIE=1;
  TMR1IE=1;
  PEIE=1;
  RBIE=1;
}
}
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Apr 16, 2020 11:20 am     Reply with quote

The biggest problem is that you're not using the easy to understand, easy to use CCS C language !
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