poppy: Do not print base detection value if base stays connected
Reduces amount of spam during EC-EC communication.
BRANCH=none
TEST=Flash lux and wand, less spam on console
@@ -237,6 +237,11 @@ static int command_detach_base(int argc, char **argv)
DECLARE_CONSOLE_COMMAND(detachbase, command_detach_base,
NULL, "Simulate detach base");
+static void print_base_detect_value(int v, int tmp_pulse_width)
+{
+ CPRINTS("%s = %d (pulse %d)", adc_channels[ADC_BASE_DET].name,
+ v, tmp_pulse_width);
+}
static void base_detect_deferred(void)
{
@@ -253,14 +258,14 @@ static void base_detect_deferred(void)
v = adc_read_channel(ADC_BASE_DET);
if (v == ADC_READ_ERROR)
return;
- CPRINTS("%s = %d (pulse %d)", adc_channels[ADC_BASE_DET].name,
- v, tmp_pulse_width);
if (v >= BASE_DETECT_MIN_MV && v <= BASE_DETECT_MAX_MV) {
if (current_base_status != BASE_CONNECTED) {
+ print_base_detect_value(v, tmp_pulse_width);
base_detect_change(BASE_CONNECTED);
} else if (tmp_pulse_width >= BASE_DETECT_PULSE_MIN_US &&
tmp_pulse_width <= BASE_DETECT_PULSE_MAX_US) {
+ print_base_detect_value(v, tmp_pulse_width);
CPRINTS("Sending event to AP");
host_set_single_event(EC_HOST_EVENT_KEY_PRESSED);
}
@@ -268,6 +273,9 @@ static void base_detect_deferred(void)
v <= BASE_DETECT_REVERSE_MAX_MV) ||
v >= BASE_DETECT_DISCONNECT_MIN_MV) {
/* TODO(b/35585396): Handle reverse connection separately. */
+
+ print_base_detect_value(v, tmp_pulse_width);
+
base_detect_change(BASE_DISCONNECTED);
} else {
/* Unclear base status, schedule again in a while. */
