 
 void keypad_button_draw(char ch, int x, int y)
 {
+  // draw the keypad button
   tft.drawRoundRect(KEYPAD_X+KEYPAD_MARGIN+(KEYPAD_MARGIN+KEYPAD_BUTTON_W)*x,
                     KEYPAD_Y+KEYPAD_MARGIN+(KEYPAD_MARGIN+KEYPAD_BUTTON_H)*y,
                     KEYPAD_BUTTON_H, KEYPAD_BUTTON_H,

  event_push(event_Down, last_x, last_y);
}

//-----------------------------------------------
// Fills the frequency char buffer from a given frequency.
//
//     buff  address of char buffer to fill
//     freq  the frequency to put into the buffer
//
// Fills the buffer from the left with MSB first.
//-----------------------------------------------

void freq_to_buff(char *buff, unsigned long freq)
{
  int rem;

  for (int i = NUM_F_CHAR - 1; i >= 0; --i)
  {
    rem = freq % 10;
    freq = freq / 10;
    buff[i] = '0' + rem;
  }
}

//-----------------------------------------------
// Draw the 'thousands' markers
//-----------------------------------------------

void draw_thousands(void)
{
  tft.fillRect(FREQ_OFFSET_X+CHAR_WIDTH*2, 44, 2, 6, FREQ_FG);
  tft.fillRect(FREQ_OFFSET_X+CHAR_WIDTH*5, 44, 2, 6, FREQ_FG);
}

//-----------------------------------------------
// Routines to draw GUI components on the screen
//-----------------------------------------------

void drawOnline(void)
{
  if (vfo_state == VFO_Standby)
  {
    tft.fillRoundRect(ONLINE_X, ONLINE_Y, ONLINE_WIDTH, ONLINE_HEIGHT, BUTTON_RADIUS, STANDBY_BG2);
    tft.fillRoundRect(ONLINE_X+1, ONLINE_Y+1, ONLINE_WIDTH-2, ONLINE_HEIGHT-2, BUTTON_RADIUS, STANDBY_BG);
    tft.setCursor(ONLINE_X + 7, SCREEN_HEIGHT - 10);
    tft.setFont(FONT_BUTTON);
    tft.setTextColor(STANDBY_FG);
    tft.print("Standby");
  }
  else
  {
    tft.fillRoundRect(ONLINE_X, ONLINE_Y, ONLINE_WIDTH, ONLINE_HEIGHT, BUTTON_RADIUS, ONLINE_BG2);
    tft.fillRoundRect(ONLINE_X+1, ONLINE_Y+1, ONLINE_WIDTH-2, ONLINE_HEIGHT-2, BUTTON_RADIUS, ONLINE_BG);
    tft.setCursor(ONLINE_X + 7, SCREEN_HEIGHT - 10);
    tft.setFont(FONT_BUTTON);
    tft.setTextColor(ONLINE_FG);
    tft.print("ONLINE");
  }
}

void drawMenu(void)
{
  tft.fillRoundRect(MENU_X, MENU_Y, MENU_WIDTH, MENU_HEIGHT, BUTTON_RADIUS, MENU_BG2);
  tft.fillRoundRect(MENU_X+1, MENU_Y+1, MENU_WIDTH-2, MENU_HEIGHT-2, BUTTON_RADIUS, MENU_BG);
  tft.setCursor(MENU_X + 22, SCREEN_HEIGHT - 10);
  tft.setFont(FONT_BUTTON);
  tft.setTextColor(MENU_FG);
  tft.print("Menu");
}

void draw_screen(void)
{
  tft.setFont(FONT_FREQ);

  // start drawing things that don't change
  tft.fillRect(0, DEPTH_FREQ_DISPLAY, tft.width(), SCREEN_HEIGHT-DEPTH_FREQ_DISPLAY, SCREEN_BG2);
  tft.setTextWrap(false);
  tft.fillRoundRect(0, 0, tft.width(), DEPTH_FREQ_DISPLAY, 5, FREQ_BG);
  tft.setCursor(MHZ_OFFSET_X, FREQ_OFFSET_Y);
  tft.setTextColor(FREQ_FG);
  tft.print("Hz");

  drawOnline();
  drawMenu();
}

//-----------------------------------------------
// Get touch information, if anyu.
//     x, y  pointers to cells to receive X and Y position
// Returns 'true' if touch found - X and Y cells updated.
// Returns 'false' if no touch - X and Y cells NOT updated.
//-----------------------------------------------
bool ts_read(int *x, int *y)
{
  // See if there's any touch data for us
  if (ts.bufferEmpty())
  {
    return false;
  }

  // Retrieve a point  
  TS_Point p = ts.getPoint();

  if (p.z < 100)
  {
    return false;
  }

  // Scale from ~0->4000 to tft.width using the calibration #'s
  *x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
  *y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());

  return true;
}

//-----------------------------------------------
// Draw the frequency byte buffer to the screen.


bool freq_hs_handler(HotSpot *hs_ptr)
{
  freq_digit_select = hs_ptr->arg;
  keypad_show(hs_ptr->arg);
  return true;
}
