logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

djinn_usbpd.c (781B)


  1. // Copyright 2018-2022 Nick Brassel (@tzarc)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "djinn.h"
  4. const char* usbpd_str(usbpd_allowance_t allowance) {
  5. switch (allowance) {
  6. default:
  7. case USBPD_500MA:
  8. return "500mA";
  9. case USBPD_1500MA:
  10. return "1500mA";
  11. case USBPD_3000MA:
  12. return "3000mA";
  13. }
  14. }
  15. void usbpd_update(void) {
  16. static uint32_t last_read = 0;
  17. if (timer_elapsed32(last_read) > 250) {
  18. usbpd_allowance_t allowance = usbpd_get_allowance();
  19. if (kb_state.current_setting != allowance) {
  20. dprintf("Transitioning UCPD1 %s -> %s\n", usbpd_str(kb_state.current_setting), usbpd_str(allowance));
  21. kb_state.current_setting = allowance;
  22. }
  23. }
  24. }