Advertisement
Guest User

LCD that doesn't refresh

a guest
Jan 13th, 2017
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. if (Mode == 0) {
  2.     // Standby code, works fine  
  3.  
  4.     if (encoderPos > (modeMax+10)) encoderPos = modeMax; // check we haven't gone out of bounds below 0 and correct if we have
  5.     else if (encoderPos > modeMax) encoderPos = 0; // check we haven't gone out of bounds above modeMax and correct if we have
  6.     if (buttonPressed){
  7.       Mode = encoderPos; // set the Mode to the current value of input if button has been pressed
  8.       buttonPressed = 0; // reset the button status so one press results in one action
  9.       if (Mode == 1) {
  10.  
  11.         // LCD printing
  12.         lcd.clear();
  13.         lcd.setBacklight(HIGH);
  14.         lcd.setCursor(0, 0);
  15.         lcd.print("Rezimas:"); // "Mode" in Lithuanian
  16.         lcd.setCursor(2, 1);
  17.         lcd.print("1");
  18.         lcd.setCursor(13, 1);
  19.         lcd.print("2");
  20.         encoderPos = setting1; // start adjusting Imax from last set point
  21.         Serial.print(encoderPos);
  22.  
  23.         // Detecting setting (I should've added a code that would limit the setting1 to go over 1, but i've done that, but it didn't worked anyway)
  24.         if (setting1 == 0) {
  25.           lcd.setCursor(11,1);
  26.           lcd.write(" ");
  27.           lcd.setCursor(0,1);
  28.           lcd.write((uint8_t)0);
  29.         }
  30.         if (setting1 < 0) {
  31.           lcd.setCursor(0,1);
  32.           lcd.write(" ");
  33.           lcd.setCursor(11,1);
  34.           lcd.write((uint8_t)0);
  35.         }
  36.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement