//MENU iSword
#include "U8glib.h"
//variaveis globais
int opcao=0;
int x,y;
//
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);
//linhas na tela
void draw1()
{
u8g.drawFrame(1,1,125,10);
}
void draw2()
{
u8g.drawFrame(1,12,125,50);
}
//funções menu
void drawisword()
{
u8g.setFont(u8g_font_6x10);
u8g.drawStr(45,10,"iSWORD");
}
void drawversao(){
u8g.setFont(u8g_font_u8glib_4);
// u8g.setHiColorByRGB(255, 255, 0); //Não esta funcionando, a plataforma só exibe branco
u8g.drawStr(3,10,"v1.0");
u8g.drawStr(113,10,"000");
}
void drawinicio(){
u8g.setFont(u8g_font_4x6);
u8g.drawStr(50,22,"Novo Jogo");
}
void drawranking(){
u8g.setFont(u8g_font_4x6);
u8g.drawStr(50,32,"Ranking");
}
void drawby(){
u8g.setFont(u8g_font_4x6);
u8g.drawStr(50,42,"Creditos");
}
void drawexit(){
u8g.setFont(u8g_font_4x6);
u8g.drawStr(50,52,"Sair");
}
//Funções select
void drawselect1(){
y=18;
u8g.drawBox(43,y,3,3);
}
void drawselect2(){
y=28;
u8g.drawBox(43,y,3,3);
}
void drawselect3(){
y=38;
u8g.drawBox(43,y,3,3);
}
void drawselect4(){
y=48;
u8g.drawBox(43,y,3,3);
}
void setup() {
pinMode(8, INPUT_PULLUP); //botões usados para mudar as funçoes no menu
pinMode(9, INPUT_PULLUP);
Serial.begin(9600);
if (u8g.getMode() == U8G_MODE_R3G3B2){
u8g.setColorIndex(255);
}
else if (u8g.getMode() == U8G_MODE_GRAY2BIT){
u8g.setColorIndex(3);
}
else if (u8g.getMode() == U8G_MODE_BW){
u8g.setColorIndex(1);
}
else if (u8g.getMode() == U8G_MODE_HICOLOR){
u8g.setHiColorByRGB(255,255,255);
}
}
void loop(){
u8g.firstPage();
do
{
if(digitalRead(8)==LOW){
opcao++;
delay(400);
}
switch (opcao){
case 0:
drawselect1();
break;
case 1:
drawselect2();
break;
case 2:
drawselect3();
break;
case 3:
drawselect4();
break;
default:
opcao=0;
break;
}
draw1();
draw2();
drawisword();
drawversao();
drawinicio();
drawranking();
drawby();
drawexit();
} while(u8g.nextPage());
}