From aa06893b58ac3ed88e796968d237f60f4c156875 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 20 Jun 2022 14:20:56 +1000 Subject: Add Djinn. (#17382) * Add Djinn. * Review comments. * Further cleanup. --- keyboards/tzarc/djinn/djinn_usbpd.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 keyboards/tzarc/djinn/djinn_usbpd.c (limited to 'keyboards/tzarc/djinn/djinn_usbpd.c') diff --git a/keyboards/tzarc/djinn/djinn_usbpd.c b/keyboards/tzarc/djinn/djinn_usbpd.c new file mode 100644 index 0000000000..b0bf166b7c --- /dev/null +++ b/keyboards/tzarc/djinn/djinn_usbpd.c @@ -0,0 +1,28 @@ +// Copyright 2018-2022 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#include +#include "quantum.h" +#include "djinn.h" + +const char* usbpd_str(usbpd_allowance_t allowance) { + switch (allowance) { + default: + case USBPD_500MA: + return "500mA"; + case USBPD_1500MA: + return "1500mA"; + case USBPD_3000MA: + return "3000mA"; + } +} + +void usbpd_update(void) { + static uint32_t last_read = 0; + if (timer_elapsed32(last_read) > 250) { + usbpd_allowance_t allowance = usbpd_get_allowance(); + if (kb_state.current_setting != allowance) { + dprintf("Transitioning UCPD1 %s -> %s\n", usbpd_str(kb_state.current_setting), usbpd_str(allowance)); + kb_state.current_setting = allowance; + } + } +} \ No newline at end of file -- cgit v1.2.1