Skip to content

Instantly share code, notes, and snippets.

@roboter
Created October 15, 2014 18:29
Show Gist options
  • Save roboter/19262e20a08ff47bfefa to your computer and use it in GitHub Desktop.
Save roboter/19262e20a08ff47bfefa to your computer and use it in GitHub Desktop.
int botton_h = 60;
int botton_w = 230;
int padding = 5;
int text_space_h=25;
int text_space_w=45;
void drawButton(char *text, unsigned int position_x, unsigned int position_y)
{
myGLCD.setColor(0, 0, 255); // blue
int x1 = padding * (position_x + 1) + position_x * botton_h;
int y1 = 240 - botton_w * position_y;
int x2 = padding * (position_x + 1) + botton_h * (position_x + 1);
int y2 = 240 - (padding * (position_y + 1)) - botton_w * (position_y + 1);
myGLCD.fillRoundRect (x1, y1, x2, y2);
myGLCD.setColor(255, 255, 255); //white
myGLCD.drawRoundRect (x1, y1, x2, y2);
myGLCD.setColor(126, 255, 126); //
myGLCD.setColor(126, 0, 126); //
myGLCD.print(text, text_space_h+x1, y1-text_space_h, 270);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment