Skip to content

Commit

Permalink
andrivet#345 Enable circular selection for preheat, pid, sensor screens
Browse files Browse the repository at this point in the history
  • Loading branch information
taligentx committed Sep 2, 2024
1 parent 4952f5e commit b9c9a1d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
1 change: 0 additions & 1 deletion LCD-Panel/Reset/DWIN_SET/CONFIG.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
RB=5A

12 changes: 8 additions & 4 deletions Marlin/src/advi3pp/screens/controls/preheat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,23 @@ bool Preheat::on_enter() {

//! Handle Previous command
void Preheat::previous_command() {
if(index_ <= 0)
if(index_ < 0)
return;
retrieve_presets();
--index_;
if (index_ == 0)
index_ = NB_PRESETS - 1;
else --index_;
send_presets();
}

//! Handle Next command
void Preheat::next_command() {
if(index_ >= NB_PRESETS - 1)
if(index_ > NB_PRESETS - 1)
return;
retrieve_presets();
++index_;
if(index_ == NB_PRESETS - 1)
index_ = 0;
else ++index_;
send_presets();
}

Expand Down
12 changes: 8 additions & 4 deletions Marlin/src/advi3pp/screens/settings/pid_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,23 @@ void PidSettings::bed_command() {

//! Handle the show previous PID values command
void PidSettings::previous_command() {
if(index_ <= 0)
if(index_ < 0)
return;
from_lcd();
index_ -= 1;
if(index_ == 0)
index_ = Pid::NB_PIDs - 1;
else index_ -= 1;
to_lcd();
}

//! Handle the show next PID values command
void PidSettings::next_command() {
if(index_ >= Pid::NB_PIDs - 1)
if(index_ > Pid::NB_PIDs - 1)
return;
from_lcd();
index_ += 1;
if(index_ == Pid::NB_PIDs - 1)
index_ = 0;
else index_ += 1;
to_lcd();
}

Expand Down
12 changes: 8 additions & 4 deletions Marlin/src/advi3pp/screens/settings/sensor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,21 @@ void SensorSettings::on_save_command() {

//! Show the previous settings.
void SensorSettings::previous_command() {
if(index_ <= 0) return;
index_ -= 1;
if(index_ < 0) return;
if(index_ == 0)
index_ = NB_SENSOR_POSITIONS;
else index_ -= 1;
send_name();
send_values();
}

//! Show the next settings.
void SensorSettings::next_command() {
if(index_ >= NB_SENSOR_POSITIONS) // not -1 because we have also index #0 not counted in NB_SENSOR_POSITIONS
if(index_ > NB_SENSOR_POSITIONS) // not -1 because we have also index #0 not counted in NB_SENSOR_POSITIONS
return;
index_ += 1;
if(index_ == NB_SENSOR_POSITIONS)
index_ = 0;
else index_ += 1;
send_name();
send_values();
}
Expand Down

0 comments on commit b9c9a1d

Please sign in to comment.