wooffff, last part:
void updateMenu(void) {
if ( uiKeyCode != KEY_NONE && last_key_code == uiKeyCode ) {
return;
}
last_key_code = uiKeyCode;
switch ( uiKeyCode ) {
case KEY_NEXT:
menu_current++;
if ( menu_current >= MENU_ITEMS )
menu_current = 0;
menu_redraw_required = 1;
break;
case KEY_PREV:
if ( menu_current == 0 )
menu_current = MENU_ITEMS;
menu_current--;
menu_redraw_required = 1;
break;
}
}
void backlit(void){
//Serial.begin(9600);
key = analogRead(A3);
//Serial.println(key);
potValue = analogRead(potPin)/4; //Read the potentiometer, convert it to 0 - 255
if(potValue>255){
potValue = 255;
}
else if(potValue<10){
potValue = 10;
}
//Serial.println(potValue);
analogWrite(LEDPin, potValue); //Write the converted potentiometer value to LED pin
}
void setup() {
Serial.begin(9600);
// rotate screen, if required
// u8g.setRot180();
uiSetup(); // setup key detection and debounce algorithm
menu_redraw_required = 1; // force initial redraw
if ( u8g.getMode() == U8G_MODE_R3G3B2 )
u8g.setColorIndex(255); // white
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
u8g.setColorIndex(3); // max intensity
else if ( u8g.getMode() == U8G_MODE_BW )
u8g.setColorIndex(1); // pixel on
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte *)"clie1");
Mirf.payload = sizeof(vals);
Mirf.config();
pinMode(LEDPin, OUTPUT); //Set Pin 6 as an Output
potValue = analogRead(potPin)/4; //Read the potentiometer, convert it to 0 - 255
if(potValue>255){
potValue = 255;
}
else if(potValue<10){
potValue = 10;
}
//Serial.println(potValue);
analogWrite(LEDPin, potValue); //Write the converted potentiometer value to LED pin
u8g.firstPage();
do { draw();
u8g.setFont(u8g_font_courB12r);
//u8g.setFont(u8g_font_u8glib_4);
u8g.drawStr( 25, 39, "VOLTRANS");
}
while( u8g.nextPage() );
delay(1000);
u8g.firstPage();
do { draw1(); }
while( u8g.nextPage() );
delay(10);
u8g.firstPage();
do { draw2(); }
while( u8g.nextPage() );
delay(10);
u8g.firstPage();
do { draw3(); }
while( u8g.nextPage() );
delay(10);
u8g.firstPage();
do { draw4(); }
while( u8g.nextPage() );
delay(10);
u8g.firstPage();
do { draw5(); }
while( u8g.nextPage() );
delay(10);
u8g.firstPage();
do { draw(); }
while( u8g.nextPage() );
delay(1000);
u8g.firstPage();
do { draw();
u8g.setFont(u8g_font_unifont);
u8g.setFont(u8g_font_u8glib_4);
u8g.drawStr( 15, 35, "AN AZERBAIJAN COMPANY");
}
while( u8g.nextPage() );
delay(1000);
u8g.firstPage();
do { draw();
}
while( u8g.nextPage() );
}
void loop() {
backlit(); //initiate backlit control
uiStep(); // check for key press
if ( menu_redraw_required != 0 ){
drawMenu();
}
updateMenu(); // update menu bar
if ( menu_current == 0 && (analogRead(A3) > 1000) )
{
do{
drawSpiderControl();
Serial.println(uiKeyCode);
}while(analogRead(A3) <200);
drawMenu();
}
delay(10);
}