Beispiel #1
0
void alphaRefreshScreen(void)
{
  uint8_t x, y;

  /* Draw keypad */
  for (y = 0; y < 6; y++)
  {
    for (x = 0; x < 5; x++)
    {
      alphaRenderButton(alphaPage, x, y, false);
    }
  }

  /* Render Text */
  drawRectangleFilled(0, 0, lcdGetWidth() - 1, ALPHA_KEYPAD_TOP - (ALPHA_BTN_SPACING * 2), 0xFFFF);
  drawString(ALPHA_BTN_SPACING, ALPHA_BTN_SPACING, COLOR_BLACK, &dejaVuSans9ptFontInfo, (char *)&alphaString);
}
void alphaRefreshScreen(void)
{
  uint8_t x, y;

  /* Draw keypad */
  for (y = 0; y < 6; y++)
  {
    for (x = 0; x < 5; x++)
    {
      alphaRenderButton(alphaPage, x, y, false);
    }
  }

  /* Render Text */
  drawRectangleRounded(ALPHA_BTN_SPACING, ALPHA_BTN_SPACING, lcdGetWidth() - 1 - ALPHA_BTN_SPACING, ALPHA_KEYPAD_TOP - ALPHA_BTN_SPACING, ALPHA_COLOR_INPUTFILL, 10, DRAW_ROUNDEDCORNERS_ALL);
  drawString(ALPHA_BTN_SPACING * 3, ALPHA_BTN_SPACING * 3, ALPHA_COLOR_INPUTTEXT, &dejaVuSans9ptFontInfo, (char *)&alphaString);
}
Beispiel #3
0
char alphaHandleTouchEvent(void)
{
  tsTouchData_t data;
  char result = '\0';
  uint8_t row, col;
  int32_t tsError = -1;

  // Blocking delay until a valie touch event occurs
  while (tsError)
  {
    tsError = tsWaitForEvent(&data, 0);
  }

  // Attempt to convert touch data to char
  if ((data.y < ALPHA_ROW1_TOP) || (data.y > ALPHA_ROW6_TOP + ALPHA_BTN_HEIGHT))
  {
    return result;
  }

  // Get column
  if ((data.x > alphaBtnX[0]) && (data.x < alphaBtnX[0] + ALPHA_BTN_WIDTH))
    col = 0;
  else if ((data.x > alphaBtnX[1]) && (data.x < alphaBtnX[1] + ALPHA_BTN_WIDTH))
    col = 1;
  else if ((data.x > alphaBtnX[2]) && (data.x < alphaBtnX[2] + ALPHA_BTN_WIDTH))
    col = 2;
  else if ((data.x > alphaBtnX[3]) && (data.x < alphaBtnX[3] + ALPHA_BTN_WIDTH))
    col = 3;
  else if ((data.x > ALPHA_COL5_LEFT) && (data.x < ALPHA_COL5_LEFT + ALPHA_BTN_WIDTH))
    col = 4;
  else
    return result;

  // Get row
  if ((data.y > ALPHA_ROW1_TOP) && (data.y < ALPHA_ROW1_TOP + ALPHA_BTN_HEIGHT))
    row = 0;
  else if ((data.y > ALPHA_ROW2_TOP) && (data.y < ALPHA_ROW2_TOP + ALPHA_BTN_HEIGHT))
    row = 1;
  else if ((data.y > ALPHA_ROW3_TOP) && (data.y < ALPHA_ROW3_TOP + ALPHA_BTN_HEIGHT))
    row = 2;
  else if ((data.y > ALPHA_ROW4_TOP) && (data.y < ALPHA_ROW4_TOP + ALPHA_BTN_HEIGHT))
    row = 3;
  else if ((data.y > ALPHA_ROW5_TOP) && (data.y < ALPHA_ROW5_TOP + ALPHA_BTN_HEIGHT))
    row = 4;
  else if ((data.y > ALPHA_ROW6_TOP) && (data.y < ALPHA_ROW6_TOP + ALPHA_BTN_HEIGHT))
    row = 5;
  else
    return result;

  // Match found ... update button and process the results
  alphaRenderButton(alphaPage, col, row, true);
  result = alphaKeys[alphaPage][row][col];
  
  if (result == '<')
  {
    // Trim character if backspace was pressed
    if (alphaString_ptr > alphaString)
    {
      alphaString_ptr--;
      *alphaString_ptr = '\0';
    }
  }
  else if (result == '*')
  {
    // Switch page if the shift button was pressed
    alphaPage++;
    if (alphaPage > 3)
    {
      alphaPage = 0;
    }
    // Update the UI
    alphaRefreshScreen();
  }
  else if (result == '>')
  {
    // OK button
    systickDelay(CFG_TFTLCD_TS_KEYPADDELAY);
    return '>';
  }
  else
  {
    // Add text to string buffer
    *alphaString_ptr++ = result;
  }

  // Brief delay
  systickDelay(CFG_TFTLCD_TS_KEYPADDELAY);

  // Return button to deselected state
  alphaRefreshScreen();
  return result;
}