buttons: Remove MCU_ADC_buttons debug capability

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-11-07 18:32:26 -05:00
parent 2d5c761101
commit d40f951d6f
3 changed files with 10 additions and 21 deletions

View File

@ -1746,10 +1746,6 @@
#analog_pullup_resistor: 4700 #analog_pullup_resistor: 4700
# The resistance (in ohms) of the pullup attached to the analog button. # The resistance (in ohms) of the pullup attached to the analog button.
# The default is 4700 ohms. # 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: #analog_range_click_pin:
# The resistance range for a 'enter' button. Range minimum and maximum # The resistance range for a 'enter' button. Range minimum and maximum
# comma-separated values must be provided when using analog button. # comma-separated values must be provided when using analog button.

View File

@ -93,14 +93,13 @@ ADC_SAMPLE_TIME = 0.001
ADC_SAMPLE_COUNT = 6 ADC_SAMPLE_COUNT = 6
class MCU_ADC_buttons: class MCU_ADC_buttons:
def __init__(self, printer, pin, pullup, debug=False): def __init__(self, printer, pin, pullup):
self.reactor = printer.get_reactor() self.reactor = printer.get_reactor()
self.buttons = [] self.buttons = []
self.last_button = None self.last_button = None
self.last_pressed = None self.last_pressed = None
self.last_debouncetime = 0 self.last_debouncetime = 0
self.pullup = pullup self.pullup = pullup
self.debug = debug
self.pin = pin self.pin = pin
self.min_value = self.max_value = None self.min_value = self.max_value = None
ppins = printer.lookup_object('pins') ppins = printer.lookup_object('pins')
@ -155,9 +154,6 @@ class MCU_ADC_buttons:
self.last_pressed = btn self.last_pressed = btn
self.last_button = 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): def call_button(self, eventtime, button, state):
if button < len(self.buttons): if button < len(self.buttons):
@ -223,19 +219,17 @@ class PrinterButtons:
self.printer = config.get_printer() self.printer = config.get_printer()
self.mcu_buttons = {} self.mcu_buttons = {}
self.adc_buttons = {} self.adc_buttons = {}
def register_adc_button( def register_adc_button(self, pin, min_val, max_val, pullup, callback):
self, pin, min_val, max_val, pullup, callback, debug=False):
adc_buttons = self.adc_buttons.get(pin) adc_buttons = self.adc_buttons.get(pin)
if adc_buttons is None: if adc_buttons is None:
self.adc_buttons[pin] = adc_buttons = MCU_ADC_buttons( 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) adc_buttons.setup_button(min_val, max_val, callback)
def register_adc_button_push( def register_adc_button_push(self, pin, min_val, max_val, pullup, callback):
self, pin, min_val, max_val, pullup, callback, debug=False):
def helper(eventtime, state, callback=callback): def helper(eventtime, state, callback=callback):
if state: if state:
callback(eventtime) 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): def register_buttons(self, pins, callback):
# Parse pins # Parse pins
ppins = self.printer.lookup_object('pins') ppins = self.printer.lookup_object('pins')

View File

@ -1014,7 +1014,6 @@ class MenuManager:
self._last_click_press = 0 self._last_click_press = 0
self.analog_pullup = config.getfloat( self.analog_pullup = config.getfloat(
'analog_pullup_resistor', 4700., above=0.) 'analog_pullup_resistor', 4700., above=0.)
self.analog_pin_debug = config.getboolean('analog_pin_debug', False)
self._encoder_fast_rate = config.getfloat( self._encoder_fast_rate = config.getfloat(
'encoder_fast_rate', .03, above=0.) 'encoder_fast_rate', .03, above=0.)
self._last_encoder_cw_eventtime = 0 self._last_encoder_cw_eventtime = 0
@ -1045,7 +1044,7 @@ class MenuManager:
"Unable to parse analog_range_click_pin") "Unable to parse analog_range_click_pin")
self.buttons.register_adc_button( self.buttons.register_adc_button(
self.click_pin, p_min, p_max, self.analog_pullup, self.click_pin, p_min, p_max, self.analog_pullup,
self.click_callback, self.analog_pin_debug) self.click_callback)
else: else:
self.buttons.register_buttons( self.buttons.register_buttons(
[self.click_pin], self.click_callback) [self.click_pin], self.click_callback)
@ -1059,7 +1058,7 @@ class MenuManager:
"Unable to parse analog_range_back_pin") "Unable to parse analog_range_back_pin")
self.buttons.register_adc_button_push( self.buttons.register_adc_button_push(
self.back_pin, p_min, p_max, self.analog_pullup, self.back_pin, p_min, p_max, self.analog_pullup,
self.back_callback, self.analog_pin_debug) self.back_callback)
else: else:
self.buttons.register_button_push( self.buttons.register_button_push(
self.back_pin, self.back_callback) self.back_pin, self.back_callback)
@ -1073,7 +1072,7 @@ class MenuManager:
"Unable to parse analog_range_up_pin") "Unable to parse analog_range_up_pin")
self.buttons.register_adc_button_push( self.buttons.register_adc_button_push(
self.up_pin, p_min, p_max, self.analog_pullup, self.up_pin, p_min, p_max, self.analog_pullup,
self.up_callback, self.analog_pin_debug) self.up_callback)
else: else:
self.buttons.register_button_push( self.buttons.register_button_push(
self.up_pin, self.up_callback) self.up_pin, self.up_callback)
@ -1087,7 +1086,7 @@ class MenuManager:
"Unable to parse analog_range_down_pin") "Unable to parse analog_range_down_pin")
self.buttons.register_adc_button_push( self.buttons.register_adc_button_push(
self.down_pin, p_min, p_max, self.analog_pullup, self.down_pin, p_min, p_max, self.analog_pullup,
self.down_callback, self.analog_pin_debug) self.down_callback)
else: else:
self.buttons.register_button_push( self.buttons.register_button_push(
self.down_pin, self.down_callback) self.down_pin, self.down_callback)
@ -1101,7 +1100,7 @@ class MenuManager:
"Unable to parse analog_range_kill_pin") "Unable to parse analog_range_kill_pin")
self.buttons.register_adc_button_push( self.buttons.register_adc_button_push(
self.kill_pin, p_min, p_max, self.analog_pullup, self.kill_pin, p_min, p_max, self.analog_pullup,
self.kill_callback, self.analog_pin_debug) self.kill_callback)
else: else:
self.buttons.register_button_push( self.buttons.register_button_push(
self.kill_pin, self.kill_callback) self.kill_pin, self.kill_callback)