Pages: [1]   Go Down
Author Topic: table setting display on a display 4 * 20  (Read 722 times)
0 Members and 1 Guest are viewing this topic.
FRANCE
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello ^ ^
I post my first topic;
I aim on the principle of scrolling, I want to display on a screen 4 * 20 a parameter list contained in a table, my materil: 4 * 20 display and four push buttons (Down Arrow, Up Arrow, Enter and Esc).
My program works correctly when I sent down the list but when I go up the list, I have a
concerns indexing. X after researching various forums, no forum is talking about scrolling on a display 4 * 20.
I put the code and I hope you put me on the track to fix the problem.

Thank you in advance for your participation likely.  smiley-fat

Joel (located in upper Normandy FRance)

/CODE

 
Code:
 PGM_P  PROGMEM paramMess[] = {   "Mess 0",  "Mess 1",   "Mess 2",   "Mess 3",   "Mess 4",   "Mess 5",   "Mess 6",   "Mess 7",
  "Mess 8",   "Mess 9",   "Mess 10",   "Mess 11"};

int iPosTabCourant=0;
int indiceScrolling=0;
int bMettreAjourScrollingBas=0;
int bMettreAjourScrollingHaut=0;
int iPositionCurseur=0;
int ifirstAff=0;

void loop()
{
  int iPos;
  int iNombreParam=12;
  int  iPosAffichage;
  int iPosCalculeIndex;

GestionKeyLcd(); //lecture des BP

iNombreParam=12;

if (iKeyPress==iKeyDOWN && (iPosTabCourant+indiceScrolling) <((iNombreParam)))
  {
   iPosTabCourant++;
   bMettreAjourScrollingBas=1;
   Serial.print("iPosTabCourant:");
   Serial.print(iPosTabCourant,DEC);
   Serial.print("    ");
   Serial.print("indiceScrolling:");
   Serial.println(indiceScrolling,DEC);
  }
else if ( iKeyPress==iKeyUP && iPosTabCourant>0)
  {
    iPosTabCourant--;
    bMettreAjourScrollingHaut=1;
   Serial.print("iPosTabCourant:");
   Serial.print(iPosTabCourant,DEC);
   Serial.print("    ");
   Serial.print("indiceScrolling:");
   Serial.println(indiceScrolling,DEC);
  }
 else
   {
     bMettreAjourScrollingHaut=0;
     bMettreAjourScrollingBas=0;
   }
if ( bMettreAjourScrollingHaut==1 || bMettreAjourScrollingBas==1)
  {
    lcd.clear();
    if ( bMettreAjourScrollingBas==1)
      {
       if (iPositionCurseur <3)
         {
           iPositionCurseur++;
         }
       else
         {
           iPositionCurseur=3;
           indiceScrolling++;
         }
      }
      
    if ( bMettreAjourScrollingHaut==1)
      {
       if (iPositionCurseur >0)
         {
           iPositionCurseur--;
         }
       else
         {
           iPositionCurseur=0;
           indiceScrolling--;
         }
      }
  }
if ( bMettreAjourScrollingHaut==0 && bMettreAjourScrollingBas==0)
  {
   lcd.setCursor(1,iPositionCurseur);  
  }

if(ifirstAff==0 || iKeyPress!=iKeyNoPress)
  {
  ifirstAff=1;
   for(iPosAffichage=0;iPosAffichage<4;iPosAffichage++)
    {
       if ( iPosTabCourant+iPosAffichage<iNombreParam)
       {
               lcd.setCursor(1,iPosAffichage);
               if( iPositionCurseur== iPosAffichage)
               {        //LA c le print de l'item selectionné
                 lcd.print(paramMess[iPosTabCourant-iPositionCurseur+indiceScrolling+iPosAffichage]);
               }
               else
               {        //la c le print des autres items
                  iPosCalculeIndex=iPosTabCourant-iPositionCurseur+indiceScrolling+iPosAffichage;
                  lcd.print(paramMess[iPosCalculeIndex]);
               }
                lcd.setCursor(1,iPosAffichage);
       }
    }
   }
  iKeyPress=iKeyNoPress;
delay(100);
//fin de la prémiere boucle de traitement du top depart
iFirstLoop=1;
}





* 4_20lcd.JPG (6.96 KB, 207x123 - viewed 20 times.)
« Last Edit: August 20, 2011, 10:34:48 am by joebarteamv » Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 653
Posts: 50901
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My program works correctly when I sent down the list but when I go up the list, I have a
concerns indexing.
What is that concern? What does the program do that you do not want? What does it not do that you do want?

Please modify your post. Select the code, and press the # button to add the proper code tags around it.
Logged

FRANCE
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thank you for interresting
So when I scroll down the list, no worries
but when I go up the list, it does not work^^
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 76
Posts: 7305
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Suggest you check out my phi-prompt library.
Here http://liudr.wordpress.com/phi_prompt/
I will read your code when I get home.
Logged


Germany
Offline Offline
Edison Member
*
Karma: 137
Posts: 1551
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your could should be cleaned up first.
- iPos is not used
- iFirstLoop and iKeyPress are not defined
- As far as I see, both pathes after "if( iPositionCurseur== iPosAffichage)" are identical

I guess we also need more information: What exactly did you do before the first iKeyUP?

1) no iKeyDOWN, then iKeyUP?
2) iKeyDOWN once, then iKeyUP?
3) 4x iKeyDOWN, then iKeyUP?

Which is your case which fails 1), 2) or 3) ?

Oliver

Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 76
Posts: 7305
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

GestionKeyLcd(); //lecture des BP

What does GestionKeyLcd() do?

If you could add English comment, that would help too. We don't exactly know what each part of your program is doing. I sense that you mixed LCD code with get key code, not a good way to isolate functions and problems. You will need to show the content of GestionKeyLcd().
Logged


FRANCE
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hey^^

thank you for your help, I attached the missing program, I use a pcf8574p for push button and a display for pcf8574p 4 * 20.
You can test the complete code thank you. Joel

Code:


int TabAdrPcf[2];
byte EtaTorBp[8];
byte EtaTorBpMem[8];
int TabDataPcf[2];
int TabDataMemPcf[2];
int TabErrPcf[2];
long debounceDelay = 100;    // the debounce time



void GestionKeyLcd()
{
  byte iTor;
  byte iNoKey;
 
  iNoKey=0;
 
  ReadPcf8574(1);
  DeciEnBinaire (TabDataPcf[1],8,EtaTorBp);
 
  // touche fleche haut
if (EtaTorBpMem[0]==1 && EtaTorBp[0]==0)
  {
  iKeyPress=iKeyUP;
  iNoKey=1;
  }
EtaTorBpMem[0]=EtaTorBp[0];
// touche fleche bas
 if (EtaTorBpMem[1]==1 && EtaTorBp[1]==0)
  {
   iKeyPress=iKeyDOWN;
   iNoKey=1;
  }
EtaTorBpMem[1]=EtaTorBp[1];

 //on relache sur enter
 if (EtaTorBpMem[2]==1 && EtaTorBp[2]==0)
  {
   iKeyPress=iKeyEnter;
   Serial.println("KeyEnter Press");
   iNoKey=1;
  }
  EtaTorBpMem[2]=EtaTorBp[2];
 
 
 //on relache Escape
 if (EtaTorBpMem[3]==1 && EtaTorBp[3]==0)
  {
   iKeyPress=iKeyESC;
   iNoKey=1;
  }
  EtaTorBpMem[3]=EtaTorBp[3];
 
 
 
 
 
//on a appuyé sur aucune touche
if(iNoKey==0)
  {
   iKeyPress=iKeyNoPress;
  }
 
}
/////////////////////////////////////////////////////////////////////////////////////////////////


void DeciEnBinaire(int valeur, int digit, byte nombre[])
{
int  i;
int temp;
temp=valeur;
for (i=0;i<digit;i++)
    {   // itère pour le nombre de digit attendus
       nombre[i]=temp & 1;  // prend le LSB et le sauve dans nombre
       temp = temp >> 1;    // décalage d'un bit sur la droite
    }
}



/////////////////////////////////////////////////////////////////////////////////////////////////

void ReadPcf8574( int iValPcf)
{
 byte data;
 byte iRx;
 iRx=0;
  Wire.requestFrom(TabAdrPcf[iValPcf], 1);
  if(Wire.available())
    {
    data = Wire.receive();
    iRx=1;
    TabErrPcf[iValPcf]==0;
    }
  if (iRx==1)
    {
    TabDataPcf[iValPcf]=data;
  //    Serial.println(data,BIN);
    }
  else
    {
      if (TabErrPcf[iValPcf]==0)
        {
        Serial.print("ERR PCF8574:");
        Serial.println(iValPcf,DEC);
        TabErrPcf[iValPcf]==1;
        }
    }
 
}


Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 76
Posts: 7305
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK after some reading, I found the following needs change:

bMettreAjourScrollingHaut and bMettreAjourScrollingBas

Besides their long names that maybe only fully meaningful in French (smiley), they were only assigned to 1 but never re-assigned to 0 in scroll up or down. That will be the problem. I've renamed them la_up and la_down for clarity:

In scroll up
la_up=1;
la_down=0; // You were missing this

In scroll down, do the opposite.
Logged


FRANCE
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hey^^
thank you for you participation
Cordialement
Joël    smiley
Logged

Pages: [1]   Go Up
Jump to: