logo

qmk_firmware

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

keymap.c (1333B)


  1. #include QMK_KEYBOARD_H
  2. #include "i2c_master.h"
  3. #include "debug.h"
  4. #define TIMEOUT 50
  5. // TODO: remove patch
  6. #ifdef PROTOCOL_CHIBIOS
  7. # pragma message("ChibiOS is currently 'best effort' and might not report accurate results")
  8. #endif
  9. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  10. LAYOUT_ortho_1x1(KC_A)
  11. };
  12. void do_scan(void) {
  13. uint8_t nDevices = 0;
  14. dprintf("Scanning...\n");
  15. for (uint8_t address = 1; address < 127; address++) {
  16. // The i2c_scanner uses the return value of
  17. // i2c_ping_address to see if a device did acknowledge to the address.
  18. i2c_status_t error = i2c_ping_address(address << 1, TIMEOUT);
  19. if (error == I2C_STATUS_SUCCESS) {
  20. dprintf(" I2C device found at address 0x%02X\n", address);
  21. nDevices++;
  22. } else {
  23. // dprintf(" Unknown error (%u) at address 0x%02X\n", error, address);
  24. }
  25. }
  26. if (nDevices == 0)
  27. dprintf("No I2C devices found\n");
  28. else
  29. dprintf("done\n");
  30. }
  31. uint16_t scan_timer = 0;
  32. void matrix_scan_user(void) {
  33. if (timer_elapsed(scan_timer) > 5000) {
  34. do_scan();
  35. scan_timer = timer_read();
  36. }
  37. }
  38. void keyboard_post_init_user(void) {
  39. debug_enable = true;
  40. debug_matrix = true;
  41. i2c_init();
  42. scan_timer = timer_read();
  43. }