Improve Zonestar keypad responsiveness (#14056)
This commit is contained in:
parent
402f1f7307
commit
3cd19a8ec0
|
@ -996,8 +996,8 @@ void MarlinUI::update() {
|
||||||
|
|
||||||
uint8_t get_ADC_keyValue(void) {
|
uint8_t get_ADC_keyValue(void) {
|
||||||
if (thermalManager.ADCKey_count >= 16) {
|
if (thermalManager.ADCKey_count >= 16) {
|
||||||
const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw >> 2;
|
const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw << 2;
|
||||||
thermalManager.current_ADCKey_raw = 0;
|
thermalManager.current_ADCKey_raw = 1024;
|
||||||
thermalManager.ADCKey_count = 0;
|
thermalManager.ADCKey_count = 0;
|
||||||
if (currentkpADCValue < 4000)
|
if (currentkpADCValue < 4000)
|
||||||
for (uint8_t i = 0; i < ADC_KEY_NUM; i++) {
|
for (uint8_t i = 0; i < ADC_KEY_NUM; i++) {
|
||||||
|
|
|
@ -310,7 +310,7 @@ temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0
|
||||||
// public:
|
// public:
|
||||||
|
|
||||||
#if HAS_ADC_BUTTONS
|
#if HAS_ADC_BUTTONS
|
||||||
uint32_t Temperature::current_ADCKey_raw = 0;
|
uint32_t Temperature::current_ADCKey_raw = 1024;
|
||||||
uint8_t Temperature::ADCKey_count = 0;
|
uint8_t Temperature::ADCKey_count = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2300,6 +2300,7 @@ void Temperature::isr() {
|
||||||
|
|
||||||
#if HAS_ADC_BUTTONS
|
#if HAS_ADC_BUTTONS
|
||||||
static unsigned int raw_ADCKey_value = 0;
|
static unsigned int raw_ADCKey_value = 0;
|
||||||
|
static bool ADCKey_pressed = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(SLOW_PWM_HEATERS)
|
#if ENABLED(SLOW_PWM_HEATERS)
|
||||||
|
@ -2702,16 +2703,19 @@ void Temperature::isr() {
|
||||||
next_sensor_state = adc_sensor_state; // redo this state
|
next_sensor_state = adc_sensor_state; // redo this state
|
||||||
else if (ADCKey_count < 16) {
|
else if (ADCKey_count < 16) {
|
||||||
raw_ADCKey_value = HAL_READ_ADC();
|
raw_ADCKey_value = HAL_READ_ADC();
|
||||||
if (raw_ADCKey_value > 900) {
|
if (raw_ADCKey_value <= 900) {
|
||||||
//ADC Key release
|
NOMORE(current_ADCKey_raw, raw_ADCKey_value);
|
||||||
ADCKey_count = 0;
|
|
||||||
current_ADCKey_raw = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
current_ADCKey_raw += raw_ADCKey_value;
|
|
||||||
ADCKey_count++;
|
ADCKey_count++;
|
||||||
}
|
}
|
||||||
|
else { //ADC Key release
|
||||||
|
if (ADCKey_count > 0) ADCKey_count++; else ADCKey_pressed = false;
|
||||||
|
if (ADCKey_pressed) {
|
||||||
|
ADCKey_count = 0;
|
||||||
|
current_ADCKey_raw = 1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (ADCKey_count == 16) ADCKey_pressed = true;
|
||||||
break;
|
break;
|
||||||
#endif // ADC_KEYPAD
|
#endif // ADC_KEYPAD
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue