Arteffects! 128x64 LCD ST7920

5th:

void draw(void) {
    u8g.setColorIndex(1);
  // graphic commands to redraw the complete screen should be placed here  
  u8g.setFont(u8g_font_unifont);
  u8g.setFont(u8g_font_u8glib_4);
}

  void draw1(void) {  
 u8g.drawXBMP( x, y, width, height, logo1);  
}

  void draw2(void) {
 u8g.drawXBMP( x, y, width, height, logo2);  
}
  void draw3(void) { 
 u8g.drawXBMP( x, y, width, height, logo3);   
}
  void draw4(void) { 
 u8g.drawXBMP( x, y, width, height, logo4);  
}

void draw5(void) {
  u8g.setColorIndex(0);
 u8g.drawBox( 0, 0, 128, 64);
}

long readVcc() {
  long result;
  // Read 1.1V reference against AVcc
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = 1126400L / result; // Back-calculate AVcc in mV
  return result;
}

void wakeUp()
{
    // Just a handler for the pin interrupt.
}

void uiSetup(void) {
  // configure input keys 
  
  pinMode(uiKeyPrev, INPUT);                // set pin to input
  
  pinMode(uiKeyNext, INPUT);                // set pin to input
  
  pinMode(uiKeySelect, INPUT);              // set pin to input
  
  pinMode(uiKeyBack, INPUT);                // set pin to input
  
}

void uiStep(void) {
  uiKeyCodeSecond = uiKeyCodeFirst;
  if ( key>=450 && key<550 )
    uiKeyCodeFirst = KEY_PREV;
  else if ( key>=870 && key<960 )
    uiKeyCodeFirst = KEY_NEXT;
  else if ( key>=970 && key<1050 )
    uiKeyCodeFirst = KEY_SELECT;
  else if ( key>=270 && key<330 )
    uiKeyCodeFirst = KEY_BACK;
  else 
    uiKeyCodeFirst = KEY_NONE;
  
  if ( uiKeyCodeSecond == uiKeyCodeFirst )
    uiKeyCode = uiKeyCodeFirst;
  else
    uiKeyCode = KEY_NONE;
}


#define MENU_ITEMS 6
char *menu_strings[MENU_ITEMS] = { "Spider Control", "Area Map", "Sensors", "Manipulators", "Video Surveilance", "System Info" };

uint8_t menu_current = 0;
uint8_t menu_redraw_required = 0;
uint8_t last_key_code = KEY_NONE;


void drawMenu(void) {
        u8g.firstPage();
    do  {
  uint8_t i, h;
  u8g_uint_t w, d;

  u8g.setFont(u8g_font_6x12);
  u8g.setFontRefHeightText();
  u8g.setFontPosTop();
  
  h = u8g.getFontAscent()-u8g.getFontDescent();
  w = u8g.getWidth();
  for( i = 0; i < MENU_ITEMS; i++ ) {
    d = (w-u8g.getStrWidth(menu_strings[i]))/2;
    u8g.setDefaultForegroundColor();
    if ( i == menu_current ) {
      u8g.drawBox(0, i*h+1, w, h);
      u8g.setDefaultBackgroundColor();
    }
    u8g.drawStr(d, i*h, menu_strings[i]);
  }
      } while( u8g.nextPage() );
    menu_redraw_required = 0;
}

void drawSpiderControl (void) {
  
         u8g.firstPage();
     do {  
  u8g.setColorIndex(1);
  // graphic commands to redraw the complete screen should be placed here  
  u8g.setFont(u8g_font_unifont);
  u8g.setFont(u8g_font_u8glib_4);
  
  //Serial.begin(9600);
  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
  
  val1 = analogRead(A1);
  val1 = map(val1, 0, 1023, 0, 179);
  vals[0] = val1;
  //Serial.println(val1);
  val2 = analogRead(A2);
  val2 = map(val2, 0, 1023, 0, 179);
  vals[1] = val2;
  //Serial.println(val2);
  //unsigned long time2 = 0;
  
  Mirf.setTADDR((byte *)"serv1");
  Mirf.send((byte *) &vals);
  while(Mirf.isSending()){
  }
  
  if(Mirf.dataReady()){
  time2 = millis();
  //Serial.print("time2:");
  //Serial.println(time2);
  }
  time1 = millis();
  //Serial.print("time1:");
  //Serial.println(time1);
  
  delayReply = (time1-time2);
  //Serial.print("delay:");
  // Serial.println(delayReply);
  
  Mirf.getData((byte *) &sens);
  
 
    //unsigned long currentMillis = millis();
//if(currentMillis - previousMillis > interval){
  //previousMillis = currentMillis;
  
   
      if (delayReply < 50 ) {
      u8g.drawBox(7, 4, 2, 1);
      u8g.drawBox(10, 3, 2, 2);
      u8g.drawBox(13, 2, 2, 3);
      u8g.drawBox(16, 1, 2, 4);
      u8g.drawBox(19, 0, 2, 5);
      u8g.drawStr( 22, 5, "G");
      }
      
      else if ( 50 <= delayReply &&  delayReply < 100 ) {                                 
      
      u8g.drawBox(7, 4, 2, 1);
      u8g.drawBox(10, 3, 2, 2);
      u8g.drawBox(13, 2, 2, 3);
      u8g.drawBox(16, 1, 2, 4);
      u8g.drawBox(19, 0, 2, 5);
      }
      
       else if ( 100 <= delayReply && delayReply < 200 ) {
      
      u8g.drawBox(7, 4, 2, 1);
      u8g.drawBox(10, 3, 2, 2);
      u8g.drawBox(13, 2, 2, 3);
      u8g.drawBox(16, 1, 2, 4);
      }
      
      else if ( 200 <= delayReply && delayReply < 400 ) {
      
      u8g.drawBox(7, 4, 2, 1);
      u8g.drawBox(10, 3, 2, 2);
      u8g.drawBox(13, 2, 2, 3);
      }
      
      else if ( 400 <= delayReply && delayReply < 600 ) {
      
      u8g.drawBox(7, 4, 2, 1);
      u8g.drawBox(10, 3, 2, 2);
      }
      
      else if ( 600 <= delayReply && delayReply < 800 ){
      
      u8g.drawBox(7, 4, 2, 1);
      }
      
      if (delayReply >= 800 ){
        u8g.drawStr( 8, 4, "lost sig!");
      }
//}

    u8g.drawStr( 45, 4, "My Joy_V1.0");
    u8g.drawStr( 24, 12, "JoyStick Pos");
    u8g.drawStr( 90, 12, "Spider");
    
    
    u8g.drawLine(3, 0, 3, 4);    //Anntena
    u8g.drawLine(2, 2, 0, 0);
    u8g.drawLine(4, 2, 6, 0);
    //u8g.drawFrame(13, 6, 115, 58);   //Menu Frame
    //u8g.drawLine(76, 6, 76, 63);
    
    u8g.drawStr( 69, 42, "x");
    u8g.drawLine (15, 35, 74, 35);   // X axel
    u8g.drawLine (16, 36, 18, 37);
    u8g.drawLine (16, 34, 18, 33);
    u8g.drawLine (73, 36, 71, 37);
    u8g.drawLine (73, 34, 71, 33);   
    
    u8g.drawStr( 49, 18, "y");
    u8g.drawLine (45, 13, 45, 61);   //Y axel
    u8g.drawLine (46, 14, 47, 16);
    u8g.drawLine (44, 14, 43, 16);
    u8g.drawLine (46, 60, 47, 58);
    u8g.drawLine (44, 60, 43, 58);
    
  //Serial.begin (9600);                    // Servo Position on coordinates
  PosX = analogRead(A1);
  PosX = map(PosX, 0, 1023, 0, 35);
  //Serial.println(PosX);
  PosY = analogRead(A2);
  PosY = map(PosY, 0, 1023, 0, 35);
  //Serial.println(PosY);
  u8g.drawFrame(PosX+28, PosY+18, 3, 3);
 
  u8g.setPrintPos(80,23);
  u8g.print("H Servo:");
  u8g.setPrintPos(113,23);
  u8g.print(sens[0]);
  u8g.setPrintPos(80,28);
  u8g.print("V Servo:");
  u8g.setPrintPos(113,28);
  u8g.print(sens[1]);
  
  u8g.setPrintPos(80,33);    //  Humidity data
  u8g.print("Hum(%): ");
  u8g.setPrintPos(113,33);
  u8g.print((float)sens[2]);
  u8g.setPrintPos(80,38);
  u8g.print("Temp C*: ");     //Temperature Sensor's readings
  u8g.setPrintPos(113,38);
  u8g.print(sens[3]);
  
  u8g.setPrintPos(80,43);
  u8g.print("Voltage: ");
  u8g.setPrintPos(113,43);
  float voltage = analogRead(batCheck);    //voltmeter
  //Serial.begin(9600);
  voltage = map(voltage,0,1023,0,1008);
  //Serial.println(voltage);
  u8g.print(voltage/100);
  u8g.setPrintPos(113,48);                   //Arduino Voltage
  u8g.print( (float) readVcc()/1000);
  
  
  u8g.drawLine(100, 0, 125, 0);    // Battery Bar
  u8g.drawLine(100, 5, 125, 5);
  u8g.drawLine(100, 0, 100, 5);
  u8g.drawLine(125, 0, 125, 1);
  u8g.drawLine(125, 1, 127, 1);
  u8g.drawLine(127, 1, 127, 4);
  u8g.drawLine(127, 4, 125, 4);
  u8g.drawLine(125, 4, 125, 5);
  
  int battery = voltage;
  battery = map( battery, 670, 820, 0, 27);
  u8g.drawBox(101, 1, battery, 4);
  
  
  if( voltage <660)
  {
   u8g.setColorIndex(0);
    u8g.drawBox(0, 0, 128, 64);
    u8g.setColorIndex(1);
    u8g.drawFrame(0, 0, 128, 64);
     u8g.setPrintPos(37,35);
     u8g.print("LOW BATTERY !!!");
     //u8g.setColorIndex(0);
     //u8g.print("LOW BATTERY !!!");
     //u8g.setColorIndex(1);
     //u8g.print("5sec..");
     /*
     digitalWrite(lcdbl, LOW);
     delay(5000);
    attachInterrupt(0, wakeUp, LOW);
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); 
    detachInterrupt(0);
    digitalWrite(lcdbl, HIGH);
    */ 

    } 
  
 
  }
  while( u8g.nextPage() );
  //delay(20);
  
}