Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (Mode == 0) {
- // Standby code, works fine
- if (encoderPos > (modeMax+10)) encoderPos = modeMax; // check we haven't gone out of bounds below 0 and correct if we have
- else if (encoderPos > modeMax) encoderPos = 0; // check we haven't gone out of bounds above modeMax and correct if we have
- if (buttonPressed){
- Mode = encoderPos; // set the Mode to the current value of input if button has been pressed
- buttonPressed = 0; // reset the button status so one press results in one action
- if (Mode == 1) {
- // LCD printing
- lcd.clear();
- lcd.setBacklight(HIGH);
- lcd.setCursor(0, 0);
- lcd.print("Rezimas:"); // "Mode" in Lithuanian
- lcd.setCursor(2, 1);
- lcd.print("1");
- lcd.setCursor(13, 1);
- lcd.print("2");
- encoderPos = setting1; // start adjusting Imax from last set point
- Serial.print(encoderPos);
- // 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)
- if (setting1 == 0) {
- lcd.setCursor(11,1);
- lcd.write(" ");
- lcd.setCursor(0,1);
- lcd.write((uint8_t)0);
- }
- if (setting1 < 0) {
- lcd.setCursor(0,1);
- lcd.write(" ");
- lcd.setCursor(11,1);
- lcd.write((uint8_t)0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement