🚸 Update Ender3 V2/S1 Pro UI (#23878)

This commit is contained in:
Miguel Risco-Castillo
2022-03-11 15:06:49 -05:00
committed by Scott Lahteine
parent b045c91f26
commit eabeac29fd
40 changed files with 1577 additions and 1211 deletions

View File

@ -45,12 +45,32 @@ typedef enum {
ENCODER_DIFF_ENTER = 3 // click
} EncoderState;
#define ENCODER_WAIT_MS 20
// Encoder initialization
void Encoder_Configuration();
// Analyze encoder value and return state
EncoderState Encoder_ReceiveAnalyze();
inline EncoderState get_encoder_state() {
static millis_t Encoder_ms = 0;
const millis_t ms = millis();
if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
const EncoderState state = Encoder_ReceiveAnalyze();
if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
return state;
}
template<typename T>
inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
if (encoder_diffState == ENCODER_DIFF_CW)
valref += EncoderRate.encoderMoveValue;
else if (encoder_diffState == ENCODER_DIFF_CCW)
valref -= EncoderRate.encoderMoveValue;
return encoder_diffState == ENCODER_DIFF_ENTER;
}
/*********************** Encoder LED ***********************/
#if PIN_EXISTS(LCD_LED)