logo

qmk_firmware

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

matrix.c (1539B)


  1. /* Copyright 2022 durken (https://github.com/durken1/)
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "matrix.h"
  17. #include "i2c_slave.h"
  18. #define MY_I2C_ADDRESS (0x20U << 1)
  19. void matrix_init_custom(void) {
  20. i2c_slave_init(MY_I2C_ADDRESS);
  21. }
  22. bool matrix_scan_custom(matrix_row_t current_matrix[]) {
  23. bool matrix_has_changed = false;
  24. matrix_row_t current_row_value;
  25. for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
  26. current_row_value = 0; // Start with empty row
  27. current_row_value |= (((matrix_row_t)(i2c_slave_reg[current_row+4])) << 5); // Add left half scan
  28. current_row_value |= ((matrix_row_t)i2c_slave_reg[current_row]); // Add right half scan
  29. if (current_matrix[current_row] != current_row_value) {
  30. matrix_has_changed = true;
  31. }
  32. current_matrix[current_row] = current_row_value;
  33. }
  34. return matrix_has_changed;
  35. }