Bachiochi-345-Listing-3

Listing 3
Key presses are returned via the graphics function gfx.CheckButtons(). Note: the resistive touch areas are mapped for each key by the graphic library.

void checkForKey()
{
  buttw = gfx.CheckButtons();
  if(buttw != lastbut && buttw > 0)
  {
    but = buttw;
  }
  if(modedelay > 0)
  {
    modedelay = modedelay -1;
  }
  skipchk = false;
  if(modedelay > 0 && but == 64)
  {
    skipchk = true;
  }
  if(modedelay > 0 && but == 95)
  {
    skipchk = true;
  }
  if(modedelay > 0 && but == 1)
  {
    skipchk = true;
  }
  if(modedelay > 0 && but == 2)
  {
    skipchk = true;
  }
  if(skipchk == false)
  {
    if(but > 31 && but < 127)
    {
      //gfx.TWwrite(but);
      Serial.write(but);
    }
    if(but == 13)
    {
      //gfx.TWwrite(but);
      Serial.write(but);
      gfx.ButtonUp(13);
    }
    if(but == 8 || but == 127)
    {
      //gfx.TWwrite(8);
      Serial.write(8);
    }
    if(but == 1)
    {
      keypad2landscape(112, bcolor, BLACK);
      but = 2;
      skipchk = true;
      modedelay = 30;
    }
    if(but == 2 && skipchk == false)
    {
      keypad1landscape(112, bcolor, BLACK);
      but = 1;
      skipchk = true;
      modedelay = 30;
    }
    if(but == 3 && skipchk == false)
    {
      keypad3landscape(112, bcolor, BLACK);
      modedelay = 30;
    }
  }
  lastbut = buttw;  
}
Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.


Note: We’ve made the May 2020 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2022 KCK Media Corp.