buttons: Remove MCU_ADC_buttons debug capability
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
2d5c761101
commit
d40f951d6f
|
@ -1746,10 +1746,6 @@
|
|||
#analog_pullup_resistor: 4700
|
||||
# The resistance (in ohms) of the pullup attached to the analog button.
|
||||
# The default is 4700 ohms.
|
||||
#analog_pin_debug:
|
||||
# When enabled it will output analog (ADC) button readings to the log.
|
||||
# It's useful for finding analog button resistance range values.
|
||||
# The default is False (disabled)
|
||||
#analog_range_click_pin:
|
||||
# The resistance range for a 'enter' button. Range minimum and maximum
|
||||
# comma-separated values must be provided when using analog button.
|
||||
|
|
|
@ -93,14 +93,13 @@ ADC_SAMPLE_TIME = 0.001
|
|||
ADC_SAMPLE_COUNT = 6
|
||||
|
||||
class MCU_ADC_buttons:
|
||||
def __init__(self, printer, pin, pullup, debug=False):
|
||||
def __init__(self, printer, pin, pullup):
|
||||
self.reactor = printer.get_reactor()
|
||||
self.buttons = []
|
||||
self.last_button = None
|
||||
self.last_pressed = None
|
||||
self.last_debouncetime = 0
|
||||
self.pullup = pullup
|
||||
self.debug = debug
|
||||
self.pin = pin
|
||||
self.min_value = self.max_value = None
|
||||
ppins = printer.lookup_object('pins')
|
||||
|
@ -155,9 +154,6 @@ class MCU_ADC_buttons:
|
|||
self.last_pressed = btn
|
||||
|
||||
self.last_button = btn
|
||||
if self.debug is True:
|
||||
logging.info(
|
||||
"analog pin: %s value: %d" % (self.pin, int(value)))
|
||||
|
||||
def call_button(self, eventtime, button, state):
|
||||
if button < len(self.buttons):
|
||||
|
@ -223,19 +219,17 @@ class PrinterButtons:
|
|||
self.printer = config.get_printer()
|
||||
self.mcu_buttons = {}
|
||||
self.adc_buttons = {}
|
||||
def register_adc_button(
|
||||
self, pin, min_val, max_val, pullup, callback, debug=False):
|
||||
def register_adc_button(self, pin, min_val, max_val, pullup, callback):
|
||||
adc_buttons = self.adc_buttons.get(pin)
|
||||
if adc_buttons is None:
|
||||
self.adc_buttons[pin] = adc_buttons = MCU_ADC_buttons(
|
||||
self.printer, pin, pullup, debug)
|
||||
self.printer, pin, pullup)
|
||||
adc_buttons.setup_button(min_val, max_val, callback)
|
||||
def register_adc_button_push(
|
||||
self, pin, min_val, max_val, pullup, callback, debug=False):
|
||||
def register_adc_button_push(self, pin, min_val, max_val, pullup, callback):
|
||||
def helper(eventtime, state, callback=callback):
|
||||
if state:
|
||||
callback(eventtime)
|
||||
self.register_adc_button(pin, min_val, max_val, pullup, helper, debug)
|
||||
self.register_adc_button(pin, min_val, max_val, pullup, helper)
|
||||
def register_buttons(self, pins, callback):
|
||||
# Parse pins
|
||||
ppins = self.printer.lookup_object('pins')
|
||||
|
|
|
@ -1014,7 +1014,6 @@ class MenuManager:
|
|||
self._last_click_press = 0
|
||||
self.analog_pullup = config.getfloat(
|
||||
'analog_pullup_resistor', 4700., above=0.)
|
||||
self.analog_pin_debug = config.getboolean('analog_pin_debug', False)
|
||||
self._encoder_fast_rate = config.getfloat(
|
||||
'encoder_fast_rate', .03, above=0.)
|
||||
self._last_encoder_cw_eventtime = 0
|
||||
|
@ -1045,7 +1044,7 @@ class MenuManager:
|
|||
"Unable to parse analog_range_click_pin")
|
||||
self.buttons.register_adc_button(
|
||||
self.click_pin, p_min, p_max, self.analog_pullup,
|
||||
self.click_callback, self.analog_pin_debug)
|
||||
self.click_callback)
|
||||
else:
|
||||
self.buttons.register_buttons(
|
||||
[self.click_pin], self.click_callback)
|
||||
|
@ -1059,7 +1058,7 @@ class MenuManager:
|
|||
"Unable to parse analog_range_back_pin")
|
||||
self.buttons.register_adc_button_push(
|
||||
self.back_pin, p_min, p_max, self.analog_pullup,
|
||||
self.back_callback, self.analog_pin_debug)
|
||||
self.back_callback)
|
||||
else:
|
||||
self.buttons.register_button_push(
|
||||
self.back_pin, self.back_callback)
|
||||
|
@ -1073,7 +1072,7 @@ class MenuManager:
|
|||
"Unable to parse analog_range_up_pin")
|
||||
self.buttons.register_adc_button_push(
|
||||
self.up_pin, p_min, p_max, self.analog_pullup,
|
||||
self.up_callback, self.analog_pin_debug)
|
||||
self.up_callback)
|
||||
else:
|
||||
self.buttons.register_button_push(
|
||||
self.up_pin, self.up_callback)
|
||||
|
@ -1087,7 +1086,7 @@ class MenuManager:
|
|||
"Unable to parse analog_range_down_pin")
|
||||
self.buttons.register_adc_button_push(
|
||||
self.down_pin, p_min, p_max, self.analog_pullup,
|
||||
self.down_callback, self.analog_pin_debug)
|
||||
self.down_callback)
|
||||
else:
|
||||
self.buttons.register_button_push(
|
||||
self.down_pin, self.down_callback)
|
||||
|
@ -1101,7 +1100,7 @@ class MenuManager:
|
|||
"Unable to parse analog_range_kill_pin")
|
||||
self.buttons.register_adc_button_push(
|
||||
self.kill_pin, p_min, p_max, self.analog_pullup,
|
||||
self.kill_callback, self.analog_pin_debug)
|
||||
self.kill_callback)
|
||||
else:
|
||||
self.buttons.register_button_push(
|
||||
self.kill_pin, self.kill_callback)
|
||||
|
|
Loading…
Reference in New Issue