aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2020-07-04 15:01:25 +0000
committerQMK Bot <hello@qmk.fm>2020-07-04 15:01:25 +0000
commit355f075b5766da18129027128de9cdfbe674f6af (patch)
tree2f0880f649a6f206cac86757050e4efe99ede0cb
parentc2ca57c8f4defd8fc7b7911cc1ba1e49f3d483e1 (diff)
downloadqmk_firmware-355f075b5766da18129027128de9cdfbe674f6af.tar.gz
qmk_firmware-355f075b5766da18129027128de9cdfbe674f6af.zip
format code according to conventions [skip ci]
-rw-r--r--quantum/dip_switch.c17
-rw-r--r--quantum/matrix_common.c5
2 files changed, 9 insertions, 13 deletions
diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c
index 879326d21..cda69bd0e 100644
--- a/quantum/dip_switch.c
+++ b/quantum/dip_switch.c
@@ -42,12 +42,12 @@ typedef struct matrix_index_t {
42 42
43# define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(matrix_index_t)) 43# define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(matrix_index_t))
44static matrix_index_t dip_switch_pad[] = DIP_SWITCH_MATRIX_GRID; 44static matrix_index_t dip_switch_pad[] = DIP_SWITCH_MATRIX_GRID;
45extern bool peek_matrix(uint8_t row_index, uint8_t col_index, bool read_raw); 45extern bool peek_matrix(uint8_t row_index, uint8_t col_index, bool read_raw);
46static uint16_t scan_count; 46static uint16_t scan_count;
47#endif /* DIP_SWITCH_MATRIX_GRID */ 47#endif /* DIP_SWITCH_MATRIX_GRID */
48 48
49static bool dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; 49static bool dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0};
50static bool last_dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; 50static bool last_dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0};
51 51
52__attribute__((weak)) void dip_switch_update_user(uint8_t index, bool active) {} 52__attribute__((weak)) void dip_switch_update_user(uint8_t index, bool active) {}
53 53
@@ -74,13 +74,13 @@ void dip_switch_read(bool forced) {
74 uint32_t dip_switch_mask = 0; 74 uint32_t dip_switch_mask = 0;
75 75
76#ifdef DIP_SWITCH_MATRIX_GRID 76#ifdef DIP_SWITCH_MATRIX_GRID
77 bool read_raw = false; 77 bool read_raw = false;
78 78
79 if (scan_count < 500) { 79 if (scan_count < 500) {
80 scan_count ++; 80 scan_count++;
81 if (scan_count == 10) { 81 if (scan_count == 10) {
82 read_raw = true; 82 read_raw = true;
83 forced = true; /* First reading of the dip switch */ 83 forced = true; /* First reading of the dip switch */
84 } else { 84 } else {
85 return; 85 return;
86 } 86 }
@@ -92,8 +92,7 @@ void dip_switch_read(bool forced) {
92 dip_switch_state[i] = !readPin(dip_switch_pad[i]); 92 dip_switch_state[i] = !readPin(dip_switch_pad[i]);
93#endif 93#endif
94#ifdef DIP_SWITCH_MATRIX_GRID 94#ifdef DIP_SWITCH_MATRIX_GRID
95 dip_switch_state[i] = peek_matrix(dip_switch_pad[i].row, dip_switch_pad[i].col, 95 dip_switch_state[i] = peek_matrix(dip_switch_pad[i].row, dip_switch_pad[i].col, read_raw);
96 read_raw);
97#endif 96#endif
98 dip_switch_mask |= dip_switch_state[i] << i; 97 dip_switch_mask |= dip_switch_state[i] << i;
99 if (last_dip_switch_state[i] != dip_switch_state[i] || forced) { 98 if (last_dip_switch_state[i] != dip_switch_state[i] || forced) {
diff --git a/quantum/matrix_common.c b/quantum/matrix_common.c
index e7d2dbb29..15f1e0e82 100644
--- a/quantum/matrix_common.c
+++ b/quantum/matrix_common.c
@@ -113,7 +113,4 @@ __attribute__((weak)) uint8_t matrix_scan(void) {
113 return changed; 113 return changed;
114} 114}
115 115
116__attribute__((weak)) bool peek_matrix(uint8_t row_index, uint8_t col_index, bool raw) { 116__attribute__((weak)) bool peek_matrix(uint8_t row_index, uint8_t col_index, bool raw) { return 0 != ((raw ? raw_matrix[row_index] : matrix[row_index]) & (MATRIX_ROW_SHIFTER << col_index)); }
117 return 0 != ( (raw? raw_matrix[row_index]:matrix[row_index])
118 & (MATRIX_ROW_SHIFTER << col_index));
119}