Browse Source

Cipulot Updates (#24539)

Cipulot 1 year ago
parent
commit
2aa186873e
68 changed files with 292 additions and 171 deletions
  1. 4 0
      keyboards/cipulot/common/common_cipulot.mk
  2. 10 0
      keyboards/cipulot/common/ec_board.c
  3. 42 6
      keyboards/cipulot/common/ec_switch_matrix.c
  4. 13 2
      keyboards/cipulot/common/ec_switch_matrix.h
  5. 52 8
      keyboards/cipulot/common/via_ec.c
  6. 1 3
      keyboards/cipulot/ec_23u/post_rules.mk
  7. 0 4
      keyboards/cipulot/ec_23u/rules.mk
  8. 2 0
      keyboards/cipulot/ec_60/config.h
  9. 1 3
      keyboards/cipulot/ec_60/post_rules.mk
  10. 0 4
      keyboards/cipulot/ec_60/rules.mk
  11. 2 0
      keyboards/cipulot/ec_60x/config.h
  12. 1 3
      keyboards/cipulot/ec_60x/post_rules.mk
  13. 0 4
      keyboards/cipulot/ec_60x/rules.mk
  14. 2 0
      keyboards/cipulot/ec_660c/config.h
  15. 1 3
      keyboards/cipulot/ec_660c/post_rules.mk
  16. 0 4
      keyboards/cipulot/ec_660c/rules.mk
  17. 2 0
      keyboards/cipulot/ec_980c/config.h
  18. 2 0
      keyboards/cipulot/ec_980c/ec_980c.c
  19. 42 7
      keyboards/cipulot/ec_980c/ec_switch_matrix.c
  20. 8 2
      keyboards/cipulot/ec_980c/ec_switch_matrix.h
  21. 2 0
      keyboards/cipulot/ec_alveus/1_0_0/config.h
  22. 1 3
      keyboards/cipulot/ec_alveus/1_0_0/post_rules.mk
  23. 0 4
      keyboards/cipulot/ec_alveus/1_0_0/rules.mk
  24. 2 0
      keyboards/cipulot/ec_alveus/1_2_0/config.h
  25. 1 3
      keyboards/cipulot/ec_alveus/1_2_0/post_rules.mk
  26. 0 4
      keyboards/cipulot/ec_alveus/1_2_0/rules.mk
  27. 2 0
      keyboards/cipulot/ec_dolice/config.h
  28. 1 3
      keyboards/cipulot/ec_dolice/post_rules.mk
  29. 0 4
      keyboards/cipulot/ec_dolice/rules.mk
  30. 2 0
      keyboards/cipulot/ec_menhir/config.h
  31. 1 3
      keyboards/cipulot/ec_menhir/post_rules.mk
  32. 2 0
      keyboards/cipulot/ec_pro2/config.h
  33. 1 3
      keyboards/cipulot/ec_pro2/post_rules.mk
  34. 0 4
      keyboards/cipulot/ec_pro2/rules.mk
  35. 2 0
      keyboards/cipulot/ec_prox/ansi_iso/config.h
  36. 1 3
      keyboards/cipulot/ec_prox/ansi_iso/post_rules.mk
  37. 0 4
      keyboards/cipulot/ec_prox/ansi_iso/rules.mk
  38. 2 0
      keyboards/cipulot/ec_prox/jis/config.h
  39. 1 3
      keyboards/cipulot/ec_prox/jis/post_rules.mk
  40. 0 4
      keyboards/cipulot/ec_prox/jis/rules.mk
  41. 2 0
      keyboards/cipulot/ec_theca/config.h
  42. 1 3
      keyboards/cipulot/ec_theca/post_rules.mk
  43. 0 4
      keyboards/cipulot/ec_theca/rules.mk
  44. 2 0
      keyboards/cipulot/ec_tkl/config.h
  45. 1 3
      keyboards/cipulot/ec_tkl/post_rules.mk
  46. 0 4
      keyboards/cipulot/ec_tkl/rules.mk
  47. 2 0
      keyboards/cipulot/ec_typeb/config.h
  48. 1 3
      keyboards/cipulot/ec_typeb/post_rules.mk
  49. 0 4
      keyboards/cipulot/ec_typeb/rules.mk
  50. 2 0
      keyboards/cipulot/ec_typek/config.h
  51. 42 7
      keyboards/cipulot/ec_typek/ec_switch_matrix.c
  52. 15 9
      keyboards/cipulot/ec_typek/ec_switch_matrix.h
  53. 3 1
      keyboards/cipulot/ec_typek/ec_typek.c
  54. 2 0
      keyboards/cipulot/ec_vero/config.h
  55. 1 3
      keyboards/cipulot/ec_vero/post_rules.mk
  56. 0 4
      keyboards/cipulot/ec_vero/rules.mk
  57. 2 0
      keyboards/cipulot/ec_virgo/config.h
  58. 1 3
      keyboards/cipulot/ec_virgo/post_rules.mk
  59. 0 4
      keyboards/cipulot/ec_virgo/rules.mk
  60. 2 0
      keyboards/cipulot/mnk_60_ec/config.h
  61. 1 3
      keyboards/cipulot/mnk_60_ec/post_rules.mk
  62. 0 4
      keyboards/cipulot/mnk_60_ec/rules.mk
  63. 2 0
      keyboards/cipulot/mnk_65_ec/config.h
  64. 1 3
      keyboards/cipulot/mnk_65_ec/post_rules.mk
  65. 0 4
      keyboards/cipulot/mnk_65_ec/rules.mk
  66. 2 0
      keyboards/cipulot/rf_r1_8_9xu/config.h
  67. 1 3
      keyboards/cipulot/rf_r1_8_9xu/post_rules.mk
  68. 0 4
      keyboards/cipulot/rf_r1_8_9xu/rules.mk

+ 4 - 0
keyboards/cipulot/ec_menhir/rules.mk → keyboards/cipulot/common/common_cipulot.mk

@@ -2,3 +2,7 @@ CUSTOM_MATRIX = lite
 ANALOG_DRIVER_REQUIRED = yes
 VPATH += keyboards/cipulot/common
 SRC += matrix.c ec_board.c ec_switch_matrix.c
+
+ifeq ($(strip $(VIA_ENABLE)), yes)
+    SRC += via_ec.c
+endif

+ 10 - 0
keyboards/cipulot/common/ec_board.c

@@ -17,6 +17,10 @@
 #include "ec_switch_matrix.h"
 #include "keyboard.h"
 
+#ifdef SPLIT_KEYBOARD
+#    include "transactions.h"
+#endif
+
 void eeconfig_init_kb(void) {
     // Default values
     eeprom_ec_config.actuation_mode                 = DEFAULT_ACTUATION_MODE;
@@ -57,8 +61,14 @@ void keyboard_post_init_kb(void) {
             ec_config.rescaled_mode_0_actuation_threshold[row][col]     = rescale(ec_config.mode_0_actuation_threshold, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
             ec_config.rescaled_mode_0_release_threshold[row][col]       = rescale(ec_config.mode_0_release_threshold, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
             ec_config.rescaled_mode_1_initial_deadzone_offset[row][col] = rescale(ec_config.mode_1_initial_deadzone_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
+            ec_config.rescaled_mode_1_actuation_offset[row][col]        = rescale(ec_config.mode_1_actuation_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
+            ec_config.rescaled_mode_1_release_offset[row][col]          = rescale(ec_config.mode_1_release_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
         }
     }
 
+#ifdef SPLIT_KEYBOARD
+    transaction_register_rpc(RPC_ID_VIA_CMD, via_cmd_slave_handler);
+#endif
+
     keyboard_post_init_user();
 }

+ 42 - 6
keyboards/cipulot/common/ec_switch_matrix.c

@@ -37,8 +37,14 @@ const pin_t amux_en_pins[]                             = AMUX_EN_PINS;
 const pin_t amux_n_col_sizes[]                         = AMUX_COL_CHANNELS_SIZES;
 const pin_t amux_n_col_channels[][AMUX_MAX_COLS_COUNT] = {AMUX_COL_CHANNELS};
 
+#ifdef UNUSED_POSITIONS_LIST
+const uint8_t UNUSED_POSITIONS[][2] = UNUSED_POSITIONS_LIST;
+#    define UNUSED_POSITIONS_COUNT ARRAY_SIZE(UNUSED_POSITIONS)
+#endif
+
 #define AMUX_SEL_PINS_COUNT ARRAY_SIZE(amux_sel_pins)
 #define EXPECTED_AMUX_SEL_PINS_COUNT ceil(log2(AMUX_MAX_COLS_COUNT)
+
 // Checks for the correctness of the configuration
 _Static_assert(ARRAY_SIZE(amux_en_pins) == AMUX_COUNT, "AMUX_EN_PINS doesn't have the minimum number of bits required to enable all the multiplexers available");
 // Check that number of select pins is enough to select all the channels
@@ -70,6 +76,16 @@ void init_amux(void) {
     }
 }
 
+// Disable all the unused rows
+void disable_unused_row(uint8_t row) {
+    // disable all the other rows apart from the current selected one
+    for (uint8_t idx = 0; idx < MATRIX_ROWS; idx++) {
+        if (idx != row) {
+            gpio_write_pin_low(row_pins[idx]);
+        }
+    }
+}
+
 // Select the multiplexer channel of the specified multiplexer
 void select_amux_channel(uint8_t channel, uint8_t col) {
     // Get the channel for the specified multiplexer
@@ -158,6 +174,10 @@ void ec_noise_floor(void) {
                     sum += amux_n_col_sizes[i];
                 uint8_t adjusted_col = col + sum;
                 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+#ifdef UNUSED_POSITIONS_LIST
+                    if (is_unused_position(row, adjusted_col)) continue;
+#endif
+                    disable_unused_row(row);
                     ec_config.noise_floor[row][adjusted_col] += ec_readkey_raw(amux, row, col);
                 }
             }
@@ -180,11 +200,15 @@ bool ec_matrix_scan(matrix_row_t current_matrix[]) {
     for (uint8_t amux = 0; amux < AMUX_COUNT; amux++) {
         disable_unused_amux(amux);
         for (uint8_t col = 0; col < amux_n_col_sizes[amux]; col++) {
+            uint8_t sum = 0;
+            for (uint8_t i = 0; i < (amux > 0 ? amux : 0); i++)
+                sum += amux_n_col_sizes[i];
+            uint8_t adjusted_col = col + sum;
             for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
-                uint8_t sum = 0;
-                for (uint8_t i = 0; i < (amux > 0 ? amux : 0); i++)
-                    sum += amux_n_col_sizes[i];
-                uint8_t adjusted_col        = col + sum;
+#ifdef UNUSED_POSITIONS_LIST
+                if (is_unused_position(row, adjusted_col)) continue;
+#endif
+                disable_unused_row(row);
                 sw_value[row][adjusted_col] = ec_readkey_raw(amux, row, col);
 
                 if (ec_config.bottoming_calibration) {
@@ -266,7 +290,7 @@ bool ec_update_key(matrix_row_t* current_row, uint8_t row, uint8_t col, uint16_t
                     uprintf("Key pressed: %d, %d, %d\n", row, col, sw_value);
                 }
                 // Has key moved up enough to be released?
-                else if (sw_value < ec_config.extremum[row][col] - ec_config.mode_1_release_offset) {
+                else if (sw_value < ec_config.extremum[row][col] - ec_config.rescaled_mode_1_release_offset[row][col]) {
                     ec_config.extremum[row][col] = sw_value;
                     *current_row &= ~(1 << col);
                     uprintf("Key released: %d, %d, %d\n", row, col, sw_value);
@@ -280,7 +304,7 @@ bool ec_update_key(matrix_row_t* current_row, uint8_t row, uint8_t col, uint16_t
                     ec_config.extremum[row][col] = sw_value;
                 }
                 // Has key moved down enough to be pressed?
-                else if (sw_value > ec_config.extremum[row][col] + ec_config.mode_1_actuation_offset) {
+                else if (sw_value > ec_config.extremum[row][col] + ec_config.rescaled_mode_1_actuation_offset[row][col]) {
                     ec_config.extremum[row][col] = sw_value;
                     *current_row |= (1 << col);
                     uprintf("Key pressed: %d, %d, %d\n", row, col, sw_value);
@@ -312,6 +336,18 @@ void ec_print_matrix(void) {
     print("\n");
 }
 
+// Check if the position is unused
+#ifdef UNUSED_POSITIONS_LIST
+bool is_unused_position(uint8_t row, uint8_t col) {
+    for (uint8_t i = 0; i < UNUSED_POSITIONS_COUNT; i++) {
+        if (UNUSED_POSITIONS[i][0] == row && UNUSED_POSITIONS[i][1] == col) {
+            return true;
+        }
+    }
+    return false;
+}
+#endif
+
 // Rescale the value to a different range
 uint16_t rescale(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max) {
     return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

+ 13 - 2
keyboards/cipulot/common/ec_switch_matrix.h

@@ -37,11 +37,13 @@ typedef struct {
     uint16_t mode_0_actuation_threshold;                                        // threshold for key press in mode 0
     uint16_t mode_0_release_threshold;                                          // threshold for key release in mode 0
     uint16_t mode_1_initial_deadzone_offset;                                    // threshold for key press in mode 1 (initial deadzone)
+    uint8_t  mode_1_actuation_offset;                                           // offset for key press in mode 1 (1-255)
+    uint8_t  mode_1_release_offset;                                             // offset for key release in mode 1 (1-255)
     uint16_t rescaled_mode_0_actuation_threshold[MATRIX_ROWS][MATRIX_COLS];     // threshold for key press in mode 0 rescaled to actual scale
     uint16_t rescaled_mode_0_release_threshold[MATRIX_ROWS][MATRIX_COLS];       // threshold for key release in mode 0 rescaled to actual scale
     uint16_t rescaled_mode_1_initial_deadzone_offset[MATRIX_ROWS][MATRIX_COLS]; // threshold for key press in mode 1 (initial deadzone) rescaled to actual scale
-    uint8_t  mode_1_actuation_offset;                                           // offset for key press in mode 1 (1-255)
-    uint8_t  mode_1_release_offset;                                             // offset for key release in mode 1 (1-255)
+    uint8_t  rescaled_mode_1_actuation_offset[MATRIX_ROWS][MATRIX_COLS];        // offset for key press in mode 1 rescaled to actual scale
+    uint8_t  rescaled_mode_1_release_offset[MATRIX_ROWS][MATRIX_COLS];          // offset for key release in mode 1 rescaled to actual scale
     uint16_t extremum[MATRIX_ROWS][MATRIX_COLS];                                // extremum values for mode 1
     uint16_t noise_floor[MATRIX_ROWS][MATRIX_COLS];                             // noise floor detected during startup
     bool     bottoming_calibration;                                             // calibration mode for bottoming out values (true: calibration mode, false: normal mode)
@@ -58,6 +60,7 @@ extern ec_config_t ec_config;
 
 void init_row(void);
 void init_amux(void);
+void disable_unused_row(uint8_t row);
 void select_amux_channel(uint8_t channel, uint8_t col);
 void disable_unused_amux(uint8_t channel);
 void discharge_capacitor(void);
@@ -71,3 +74,11 @@ bool     ec_update_key(matrix_row_t* current_row, uint8_t row, uint8_t col, uint
 void     ec_print_matrix(void);
 
 uint16_t rescale(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max);
+
+#ifdef UNUSED_POSITIONS_LIST
+bool is_unused_position(uint8_t row, uint8_t col);
+#endif
+
+#ifdef SPLIT_KEYBOARD
+void via_cmd_slave_handler(uint8_t m2s_size, const void* m2s_buffer, uint8_t s2m_size, void* s2m_buffer);
+#endif

+ 52 - 8
keyboards/cipulot/common/via_ec.c

@@ -19,6 +19,10 @@
 #include "print.h"
 #include "via.h"
 
+#ifdef SPLIT_KEYBOARD
+#    include "transactions.h"
+#endif
+
 #ifdef VIA_ENABLE
 
 void ec_rescale_values(uint8_t item);
@@ -50,6 +54,12 @@ void via_config_set_value(uint8_t *data) {
     uint8_t *value_id   = &(data[0]);
     uint8_t *value_data = &(data[1]);
 
+#    ifdef SPLIT_KEYBOARD
+    if (is_keyboard_master()) {
+        transaction_rpc_send(RPC_ID_VIA_CMD, 30, data);
+    }
+#    endif
+
     switch (*value_id) {
         case id_actuation_mode: {
             eeprom_ec_config.actuation_mode = value_data[0];
@@ -115,6 +125,8 @@ void via_config_set_value(uint8_t *data) {
                 ec_rescale_values(0);
                 ec_rescale_values(1);
                 ec_rescale_values(2);
+                ec_rescale_values(3);
+                ec_rescale_values(4);
                 uprintf("#############################\n");
                 uprintf("# Noise floor data acquired #\n");
                 uprintf("#############################\n");
@@ -124,13 +136,14 @@ void via_config_set_value(uint8_t *data) {
         case id_show_calibration_data: {
             if (value_data[0] == 0) {
                 ec_show_calibration_data();
-                break;
             }
+            break;
         }
         case id_clear_bottoming_calibration_data: {
             if (value_data[0] == 0) {
                 ec_clear_bottoming_calibration_data();
             }
+            break;
         }
         default: {
             // Unhandled value.
@@ -240,6 +253,22 @@ void ec_rescale_values(uint8_t item) {
                 }
             }
             break;
+        // Rescale the Rapid Trigger mode actuation offsets
+        case 3:
+            for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+                for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+                    ec_config.rescaled_mode_1_actuation_offset[row][col] = rescale(ec_config.mode_1_actuation_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
+                }
+            }
+            break;
+        // Rescale the Rapid Trigger mode release offsets
+        case 4:
+            for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+                for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+                    ec_config.rescaled_mode_1_release_offset[row][col] = rescale(ec_config.mode_1_release_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
+                }
+            }
+            break;
 
         default:
             // Unhandled item.
@@ -258,9 +287,11 @@ void ec_save_threshold_data(uint8_t option) {
     // Save Rapid Trigger mode thresholds and rescale them for runtime usage
     else if (option == 1) {
         eeprom_ec_config.mode_1_initial_deadzone_offset = ec_config.mode_1_initial_deadzone_offset;
-        eeprom_ec_config.mode_1_actuation_offset   = ec_config.mode_1_actuation_offset;
-        eeprom_ec_config.mode_1_release_offset     = ec_config.mode_1_release_offset;
+        eeprom_ec_config.mode_1_actuation_offset        = ec_config.mode_1_actuation_offset;
+        eeprom_ec_config.mode_1_release_offset          = ec_config.mode_1_release_offset;
         ec_rescale_values(2);
+        ec_rescale_values(3);
+        ec_rescale_values(4);
     }
     eeconfig_update_kb_datablock(&eeprom_ec_config);
     uprintf("####################################\n");
@@ -272,11 +303,12 @@ void ec_save_threshold_data(uint8_t option) {
 void ec_save_bottoming_reading(void) {
     for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
         for (uint8_t col = 0; col < MATRIX_COLS; col++) {
-            // If the bottom reading doesn't go over the noise floor by BOTTOMING_CALIBRATION_THRESHOLD, it is likely that:
-            // 1. The key is not actually in the matrix
-            // 2. The key is on an alternative layout, therefore not being pressed
-            // 3. The key in in the current layout but not being pressed
-            if (ec_config.bottoming_reading[row][col] < (ec_config.noise_floor[row][col] + BOTTOMING_CALIBRATION_THRESHOLD)) {
+            // If the calibration starter flag is still set on the key, it indicates that the key was skipped during the scan because it is not physically present.
+            // If the flag is not set, it means a bottoming reading was taken. If this reading doesn't exceed the noise floor by the BOTTOMING_CALIBRATION_THRESHOLD, it likely indicates one of the following:
+            // 1. The key is part of an alternative layout and is not being pressed.
+            // 2. The key is in the current layout but is not being pressed.
+            // In both conditions we should set the bottoming reading to the maximum value to avoid false positives.
+            if (ec_config.bottoming_calibration_starter[row][col] || ec_config.bottoming_reading[row][col] < (ec_config.noise_floor[row][col] + BOTTOMING_CALIBRATION_THRESHOLD)) {
                 eeprom_ec_config.bottoming_reading[row][col] = 1023;
             } else {
                 eeprom_ec_config.bottoming_reading[row][col] = ec_config.bottoming_reading[row][col];
@@ -287,6 +319,8 @@ void ec_save_bottoming_reading(void) {
     ec_rescale_values(0);
     ec_rescale_values(1);
     ec_rescale_values(2);
+    ec_rescale_values(3);
+    ec_rescale_values(4);
     eeconfig_update_kb_datablock(&eeprom_ec_config);
 }
 
@@ -360,4 +394,14 @@ void ec_clear_bottoming_calibration_data(void) {
     uprintf("######################################\n");
 }
 
+#    ifdef SPLIT_KEYBOARD
+void via_cmd_slave_handler(uint8_t m2s_size, const void *m2s_buffer, uint8_t s2m_size, void *s2m_buffer) {
+    if (m2s_size == (RAW_EPSIZE-2)) {
+        via_config_set_value((uint8_t *)m2s_buffer);
+    } else {
+        uprintf("Unexpected response in slave handler\n");
+    }
+}
+#    endif
+
 #endif // VIA_ENABLE

+ 1 - 3
keyboards/cipulot/ec_23u/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_23u/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 2

+ 2 - 0
keyboards/cipulot/ec_60/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 15
 
+#define UNUSED_POSITIONS_LIST { {1, 14}, {2, 14}, {4, 3}, {4, 8} }
+
 #define MATRIX_ROW_PINS \
     { B15, A8, B0, A7, B1 }
 

+ 1 - 3
keyboards/cipulot/ec_60/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_60/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 3

+ 2 - 0
keyboards/cipulot/ec_60x/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 15
 
+#define UNUSED_POSITIONS_LIST { {2, 14}, {4, 3}, {4, 5}, {4, 7}, {4, 9}, {4, 14} }
+
 #define MATRIX_ROW_PINS \
     { A8, A15, B12, B8, B9}
 

+ 1 - 3
keyboards/cipulot/ec_60x/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_60x/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 2

+ 2 - 0
keyboards/cipulot/ec_660c/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 15
 
+#define UNUSED_POSITIONS_LIST { {3, 14}, {4, 3}, {4, 4}, {4, 5}, {4, 7}, {4, 8} }
+
 #define MATRIX_ROW_PINS \
     { B1, B10, B0, A1, A0 }
 

+ 1 - 3
keyboards/cipulot/ec_660c/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_660c/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 3

+ 2 - 0
keyboards/cipulot/ec_980c/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 6
 #define MATRIX_COLS 19
 
+#define UNUSED_POSITIONS_LIST { {0, 1}, {0, 10}, {3, 14}, {4, 13}, {5, 4}, {5, 7}, {5, 12} }
+
 #define MATRIX_ROW_PINS \
     { B13, B12, B14, A9, B6, B7 }
 

+ 2 - 0
keyboards/cipulot/ec_980c/ec_980c.c

@@ -69,6 +69,8 @@ void keyboard_post_init_kb(void) {
             ec_config.rescaled_mode_0_actuation_threshold[row][col]     = rescale(ec_config.mode_0_actuation_threshold, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
             ec_config.rescaled_mode_0_release_threshold[row][col]       = rescale(ec_config.mode_0_release_threshold, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
             ec_config.rescaled_mode_1_initial_deadzone_offset[row][col] = rescale(ec_config.mode_1_initial_deadzone_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
+            ec_config.rescaled_mode_1_actuation_offset[row][col]        = rescale(ec_config.mode_1_actuation_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
+            ec_config.rescaled_mode_1_release_offset[row][col]          = rescale(ec_config.mode_1_release_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
         }
     }
 

+ 42 - 7
keyboards/cipulot/ec_980c/ec_switch_matrix.c

@@ -37,6 +37,11 @@ const pin_t amux_en_pins[]                             = AMUX_EN_PINS;
 const pin_t amux_n_col_sizes[]                         = AMUX_COL_CHANNELS_SIZES;
 const pin_t amux_n_col_channels[][AMUX_MAX_COLS_COUNT] = {AMUX_COL_CHANNELS};
 
+#ifdef UNUSED_POSITIONS_LIST
+const uint8_t UNUSED_POSITIONS[][2] = UNUSED_POSITIONS_LIST;
+#    define UNUSED_POSITIONS_COUNT (sizeof(UNUSED_POSITIONS) / sizeof(UNUSED_POSITIONS[0]))
+#endif
+
 #define AMUX_SEL_PINS_COUNT ARRAY_SIZE(amux_sel_pins)
 #define EXPECTED_AMUX_SEL_PINS_COUNT ceil(log2(AMUX_MAX_COLS_COUNT)
 // Checks for the correctness of the configuration
@@ -70,6 +75,16 @@ void init_amux(void) {
     }
 }
 
+// Disable all the unused rows
+void disable_unused_row(uint8_t row) {
+    // disable all the other rows apart from the current selected one
+    for (uint8_t idx = 0; idx < MATRIX_ROWS; idx++) {
+        if (idx != row) {
+            gpio_write_pin_low(row_pins[idx]);
+        }
+    }
+}
+
 // Select the multiplexer channel of the specified multiplexer
 void select_amux_channel(uint8_t channel, uint8_t col) {
     // Get the channel for the specified multiplexer
@@ -158,6 +173,10 @@ void ec_noise_floor(void) {
                     sum += amux_n_col_sizes[i];
                 uint8_t adjusted_col = col + sum;
                 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+#ifdef UNUSED_POSITIONS_LIST
+                    if (is_unused_position(row, adjusted_col)) continue;
+#endif
+                    disable_unused_row(row);
                     ec_config.noise_floor[row][adjusted_col] += ec_readkey_raw(amux, row, col);
                 }
             }
@@ -180,11 +199,15 @@ bool ec_matrix_scan(matrix_row_t current_matrix[]) {
     for (uint8_t amux = 0; amux < AMUX_COUNT; amux++) {
         disable_unused_amux(amux);
         for (uint8_t col = 0; col < amux_n_col_sizes[amux]; col++) {
+            uint8_t sum = 0;
+            for (uint8_t i = 0; i < (amux > 0 ? amux : 0); i++)
+                sum += amux_n_col_sizes[i];
+            uint8_t adjusted_col = col + sum;
             for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
-                uint8_t sum = 0;
-                for (uint8_t i = 0; i < (amux > 0 ? amux : 0); i++)
-                    sum += amux_n_col_sizes[i];
-                uint8_t adjusted_col        = col + sum;
+#ifdef UNUSED_POSITIONS_LIST
+                if (is_unused_position(row, adjusted_col)) continue;
+#endif
+                disable_unused_row(row);
                 sw_value[row][adjusted_col] = ec_readkey_raw(amux, row, col);
 
                 if (ec_config.bottoming_calibration) {
@@ -229,7 +252,7 @@ uint16_t ec_readkey_raw(uint8_t channel, uint8_t row, uint8_t col) {
 }
 
 // Update press/release state of key
-bool ec_update_key(matrix_row_t* current_row, uint8_t row, uint8_t col, uint16_t sw_value) {
+bool ec_update_key(matrix_row_t *current_row, uint8_t row, uint8_t col, uint16_t sw_value) {
     bool current_state = (*current_row >> col) & 1;
 
     // Real Time Noise Floor Calibration
@@ -266,7 +289,7 @@ bool ec_update_key(matrix_row_t* current_row, uint8_t row, uint8_t col, uint16_t
                     uprintf("Key pressed: %d, %d, %d\n", row, col, sw_value);
                 }
                 // Has key moved up enough to be released?
-                else if (sw_value < ec_config.extremum[row][col] - ec_config.mode_1_release_offset) {
+                else if (sw_value < ec_config.extremum[row][col] - ec_config.rescaled_mode_1_release_offset[row][col]) {
                     ec_config.extremum[row][col] = sw_value;
                     *current_row &= ~(1 << col);
                     uprintf("Key released: %d, %d, %d\n", row, col, sw_value);
@@ -280,7 +303,7 @@ bool ec_update_key(matrix_row_t* current_row, uint8_t row, uint8_t col, uint16_t
                     ec_config.extremum[row][col] = sw_value;
                 }
                 // Has key moved down enough to be pressed?
-                else if (sw_value > ec_config.extremum[row][col] + ec_config.mode_1_actuation_offset) {
+                else if (sw_value > ec_config.extremum[row][col] + ec_config.rescaled_mode_1_actuation_offset[row][col]) {
                     ec_config.extremum[row][col] = sw_value;
                     *current_row |= (1 << col);
                     uprintf("Key pressed: %d, %d, %d\n", row, col, sw_value);
@@ -312,6 +335,18 @@ void ec_print_matrix(void) {
     print("\n");
 }
 
+// Check if the position is unused
+#ifdef UNUSED_POSITIONS_LIST
+bool is_unused_position(uint8_t row, uint8_t col) {
+    for (uint8_t i = 0; i < UNUSED_POSITIONS_COUNT; i++) {
+        if (UNUSED_POSITIONS[i][0] == row && UNUSED_POSITIONS[i][1] == col) {
+            return true;
+        }
+    }
+    return false;
+}
+#endif
+
 // Rescale the value to a different range
 uint16_t rescale(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max) {
     return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

+ 8 - 2
keyboards/cipulot/ec_980c/ec_switch_matrix.h

@@ -47,11 +47,13 @@ typedef struct {
     uint16_t mode_0_actuation_threshold;                                        // threshold for key press in mode 0
     uint16_t mode_0_release_threshold;                                          // threshold for key release in mode 0
     uint16_t mode_1_initial_deadzone_offset;                                    // threshold for key press in mode 1 (initial deadzone)
+    uint8_t  mode_1_actuation_offset;                                           // offset for key press in mode 1 (1-255)
+    uint8_t  mode_1_release_offset;                                             // offset for key release in mode 1 (1-255)
     uint16_t rescaled_mode_0_actuation_threshold[MATRIX_ROWS][MATRIX_COLS];     // threshold for key press in mode 0 rescaled to actual scale
     uint16_t rescaled_mode_0_release_threshold[MATRIX_ROWS][MATRIX_COLS];       // threshold for key release in mode 0 rescaled to actual scale
     uint16_t rescaled_mode_1_initial_deadzone_offset[MATRIX_ROWS][MATRIX_COLS]; // threshold for key press in mode 1 (initial deadzone) rescaled to actual scale
-    uint8_t  mode_1_actuation_offset;                                           // offset for key press in mode 1 (1-255)
-    uint8_t  mode_1_release_offset;                                             // offset for key release in mode 1 (1-255)
+    uint8_t  rescaled_mode_1_actuation_offset[MATRIX_ROWS][MATRIX_COLS];        // offset for key press in mode 1 rescaled to actual scale
+    uint8_t  rescaled_mode_1_release_offset[MATRIX_ROWS][MATRIX_COLS];          // offset for key release in mode 1 rescaled to actual scale
     uint16_t extremum[MATRIX_ROWS][MATRIX_COLS];                                // extremum values for mode 1
     uint16_t noise_floor[MATRIX_ROWS][MATRIX_COLS];                             // noise floor detected during startup
     bool     bottoming_calibration;                                             // calibration mode for bottoming out values (true: calibration mode, false: normal mode)
@@ -81,3 +83,7 @@ bool     ec_update_key(matrix_row_t* current_row, uint8_t row, uint8_t col, uint
 void     ec_print_matrix(void);
 
 uint16_t rescale(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max);
+
+#ifdef UNUSED_POSITIONS_LIST
+bool is_unused_position(uint8_t row, uint8_t col);
+#endif

+ 2 - 0
keyboards/cipulot/ec_alveus/1_0_0/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 16
 
+#define UNUSED_POSITIONS_LIST { {2, 12}, {3, 11}, {3, 12}, {4, 3}, {4, 4}, {4, 6}, {4, 7}, {4, 8}, {4, 9}, {4, 10} }
+
 #define MATRIX_ROW_PINS \
     { A14, B3, A15, B5, B4 }
 

+ 1 - 3
keyboards/cipulot/ec_alveus/1_0_0/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_alveus/1_0_0/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 3

+ 2 - 0
keyboards/cipulot/ec_alveus/1_2_0/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 16
 
+#define UNUSED_POSITIONS_LIST { {3, 11}, {3, 12}, {4, 3}, {4, 4}, {4, 6}, {4, 7}, {4, 8}, {4, 9}, {4, 10} }
+
 #define MATRIX_ROW_PINS \
     { A14, B3, A15, B5, B4 }
 

+ 1 - 3
keyboards/cipulot/ec_alveus/1_2_0/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_alveus/1_2_0/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 3

+ 2 - 0
keyboards/cipulot/ec_dolice/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 15
 
+#define UNUSED_POSITIONS_LIST { {2, 14}, {4, 0}, {4, 2}, {4, 4}, {4, 7}, {4, 9}, {4, 11}, {4, 12}, {4, 13} }
+
 #define MATRIX_ROW_PINS \
     { B13, A8, B12, B14, B15 }
 

+ 1 - 3
keyboards/cipulot/ec_dolice/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_dolice/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 3

+ 2 - 0
keyboards/cipulot/ec_menhir/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 4
 #define MATRIX_COLS 12
 
+#define UNUSED_POSITIONS_LIST { {2, 11}, {3, 0}, {3, 3}, {3, 7}, {3, 10}, {3, 11} }
+
 #define MATRIX_ROW_PINS \
     { A0, A3, A2, A1 }
 

+ 1 - 3
keyboards/cipulot/ec_menhir/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 2 - 0
keyboards/cipulot/ec_pro2/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 15
 
+#define UNUSED_POSITIONS_LIST { {1, 14}, {2, 14}, {3, 12}, {4, 0}, {4, 3}, {4, 4}, {4, 5}, {4, 7}, {4, 8}, {4, 11}, {4, 12}, {4, 13}, {4, 14} }
+
 #define MATRIX_ROW_PINS \
     { B15, A8, B0, A7, B1 }
 

+ 1 - 3
keyboards/cipulot/ec_pro2/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_pro2/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 2

+ 2 - 0
keyboards/cipulot/ec_prox/ansi_iso/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 15
 
+#define UNUSED_POSITIONS_LIST { {1, 14}, {2, 14}, {3, 12}, {4, 0}, {4, 3}, {4, 4}, {4, 5}, {4, 7}, {4, 8}, {4, 11}, {4, 12}, {4, 13}, {4, 14} }
+
 #define MATRIX_ROW_PINS \
     { A7, B0, A4, A5, A6 }
 

+ 1 - 3
keyboards/cipulot/ec_prox/ansi_iso/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_prox/ansi_iso/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 2

+ 2 - 0
keyboards/cipulot/ec_prox/jis/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 14
 
+#define UNUSED_POSITIONS_LIST { {4, 6} }
+
 #define MATRIX_ROW_PINS \
     { A7, B0, A4, A5, A6 }
 

+ 1 - 3
keyboards/cipulot/ec_prox/jis/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_prox/jis/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 2

+ 2 - 0
keyboards/cipulot/ec_theca/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 6
 #define MATRIX_COLS 16
 
+#define UNUSED_POSITIONS_LIST { {3, 12}, {4, 11}, {4, 12}, {5, 3}, {5, 4}, {5, 6}, {5, 7}, {5, 8}, {5, 9} }
+
 #define MATRIX_ROW_PINS \
     { B4, A14, B3, A15, B6, B5 }
 

+ 1 - 3
keyboards/cipulot/ec_theca/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_theca/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 3

+ 2 - 0
keyboards/cipulot/ec_tkl/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 6
 #define MATRIX_COLS 16
 
+#define UNUSED_POSITIONS_LIST { {5, 3}, {5, 5} }
+
 #define MATRIX_ROW_PINS \
     { B6, B5, B12, B10, B13, B7 }
 

+ 1 - 3
keyboards/cipulot/ec_tkl/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_tkl/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 2

+ 2 - 0
keyboards/cipulot/ec_typeb/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 15
 
+#define UNUSED_POSITIONS_LIST { {1, 14}, {2, 12}, {2, 14}, {3, 1}, {3, 12}, {4, 0}, {4, 3}, {4, 4}, {4, 5}, {4, 7}, {4, 8}, {4, 11}, {4, 12}, {4, 13}, {4, 14} }
+
 #define MATRIX_ROW_PINS \
     { A7, B0, A4, A5, A6 }
 

+ 1 - 3
keyboards/cipulot/ec_typeb/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_typeb/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 3

+ 2 - 0
keyboards/cipulot/ec_typek/config.h

@@ -17,6 +17,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 15
 
+#define UNUSED_POSITIONS_LIST { {2, 13}, {4, 2}, {4, 4}, {4, 9}, {4, 11}, {4, 12}, {4, 14} }
+
 #define MATRIX_ROW_PINS \
     { B14, B13, B12, A6, A7 }
 

+ 42 - 7
keyboards/cipulot/ec_typek/ec_switch_matrix.c

@@ -37,6 +37,11 @@ const pin_t amux_en_pins[]                             = AMUX_EN_PINS;
 const pin_t amux_n_col_sizes[]                         = AMUX_COL_CHANNELS_SIZES;
 const pin_t amux_n_col_channels[][AMUX_MAX_COLS_COUNT] = {AMUX_COL_CHANNELS};
 
+#ifdef UNUSED_POSITIONS_LIST
+const uint8_t UNUSED_POSITIONS[][2] = UNUSED_POSITIONS_LIST;
+#    define UNUSED_POSITIONS_COUNT (sizeof(UNUSED_POSITIONS) / sizeof(UNUSED_POSITIONS[0]))
+#endif
+
 #define AMUX_SEL_PINS_COUNT ARRAY_SIZE(amux_sel_pins)
 #define EXPECTED_AMUX_SEL_PINS_COUNT ceil(log2(AMUX_MAX_COLS_COUNT)
 // Checks for the correctness of the configuration
@@ -70,6 +75,16 @@ void init_amux(void) {
     }
 }
 
+// Disable all the unused rows
+void disable_unused_row(uint8_t row) {
+    // disable all the other rows apart from the current selected one
+    for (uint8_t idx = 0; idx < MATRIX_ROWS; idx++) {
+        if (idx != row) {
+            gpio_write_pin_low(row_pins[idx]);
+        }
+    }
+}
+
 // Select the multiplexer channel of the specified multiplexer
 void select_amux_channel(uint8_t channel, uint8_t col) {
     // Get the channel for the specified multiplexer
@@ -158,6 +173,10 @@ void ec_noise_floor(void) {
                     sum += amux_n_col_sizes[i];
                 uint8_t adjusted_col = col + sum;
                 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+#ifdef UNUSED_POSITIONS_LIST
+                    if (is_unused_position(row, adjusted_col)) continue;
+#endif
+                    disable_unused_row(row);
                     ec_config.noise_floor[row][adjusted_col] += ec_readkey_raw(amux, row, col);
                 }
             }
@@ -180,11 +199,15 @@ bool ec_matrix_scan(matrix_row_t current_matrix[]) {
     for (uint8_t amux = 0; amux < AMUX_COUNT; amux++) {
         disable_unused_amux(amux);
         for (uint8_t col = 0; col < amux_n_col_sizes[amux]; col++) {
+            uint8_t sum = 0;
+            for (uint8_t i = 0; i < (amux > 0 ? amux : 0); i++)
+                sum += amux_n_col_sizes[i];
+            uint8_t adjusted_col = col + sum;
             for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
-                uint8_t sum = 0;
-                for (uint8_t i = 0; i < (amux > 0 ? amux : 0); i++)
-                    sum += amux_n_col_sizes[i];
-                uint8_t adjusted_col        = col + sum;
+#ifdef UNUSED_POSITIONS_LIST
+                if (is_unused_position(row, adjusted_col)) continue;
+#endif
+                disable_unused_row(row);
                 sw_value[row][adjusted_col] = ec_readkey_raw(amux, row, col);
 
                 if (ec_config.bottoming_calibration) {
@@ -229,7 +252,7 @@ uint16_t ec_readkey_raw(uint8_t channel, uint8_t row, uint8_t col) {
 }
 
 // Update press/release state of key
-bool ec_update_key(matrix_row_t* current_row, uint8_t row, uint8_t col, uint16_t sw_value) {
+bool ec_update_key(matrix_row_t *current_row, uint8_t row, uint8_t col, uint16_t sw_value) {
     bool current_state = (*current_row >> col) & 1;
 
     // Real Time Noise Floor Calibration
@@ -266,7 +289,7 @@ bool ec_update_key(matrix_row_t* current_row, uint8_t row, uint8_t col, uint16_t
                     uprintf("Key pressed: %d, %d, %d\n", row, col, sw_value);
                 }
                 // Has key moved up enough to be released?
-                else if (sw_value < ec_config.extremum[row][col] - ec_config.mode_1_release_offset) {
+                else if (sw_value < ec_config.extremum[row][col] - ec_config.rescaled_mode_1_release_offset[row][col]) {
                     ec_config.extremum[row][col] = sw_value;
                     *current_row &= ~(1 << col);
                     uprintf("Key released: %d, %d, %d\n", row, col, sw_value);
@@ -280,7 +303,7 @@ bool ec_update_key(matrix_row_t* current_row, uint8_t row, uint8_t col, uint16_t
                     ec_config.extremum[row][col] = sw_value;
                 }
                 // Has key moved down enough to be pressed?
-                else if (sw_value > ec_config.extremum[row][col] + ec_config.mode_1_actuation_offset) {
+                else if (sw_value > ec_config.extremum[row][col] + ec_config.rescaled_mode_1_actuation_offset[row][col]) {
                     ec_config.extremum[row][col] = sw_value;
                     *current_row |= (1 << col);
                     uprintf("Key pressed: %d, %d, %d\n", row, col, sw_value);
@@ -312,6 +335,18 @@ void ec_print_matrix(void) {
     print("\n");
 }
 
+// Check if the position is unused
+#ifdef UNUSED_POSITIONS_LIST
+bool is_unused_position(uint8_t row, uint8_t col) {
+    for (uint8_t i = 0; i < UNUSED_POSITIONS_COUNT; i++) {
+        if (UNUSED_POSITIONS[i][0] == row && UNUSED_POSITIONS[i][1] == col) {
+            return true;
+        }
+    }
+    return false;
+}
+#endif
+
 // Rescale the value to a different range
 uint16_t rescale(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max) {
     return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

+ 15 - 9
keyboards/cipulot/ec_typek/ec_switch_matrix.h

@@ -33,13 +33,13 @@ typedef struct PACKED {
     indicator_config num;
     indicator_config caps;
     indicator_config scroll;
-    uint8_t          actuation_mode;                              // 0: normal board-wide APC, 1: Rapid trigger from specific board-wide actuation point, 2: Rapid trigger from resting point
-    uint16_t         mode_0_actuation_threshold;                  // threshold for key press in mode 0
-    uint16_t         mode_0_release_threshold;                    // threshold for key release in mode 0
-    uint16_t         mode_1_initial_deadzone_offset;              // threshold for key press in mode 1
-    uint8_t          mode_1_actuation_offset;                // offset for key press in mode 1 and 2 (1-255)
-    uint8_t          mode_1_release_offset;                  // offset for key release in mode 1 and 2 (1-255)
-    uint16_t         bottoming_reading[MATRIX_ROWS][MATRIX_COLS]; // bottoming reading
+    uint8_t  actuation_mode;                              // 0: normal board-wide APC, 1: Rapid trigger from specific board-wide actuation point, 2: Rapid trigger from resting point
+    uint16_t mode_0_actuation_threshold;                  // threshold for key press in mode 0
+    uint16_t mode_0_release_threshold;                    // threshold for key release in mode 0
+    uint16_t mode_1_initial_deadzone_offset;              // threshold for key press in mode 1
+    uint8_t  mode_1_actuation_offset;                     // offset for key press in mode 1 and 2 (1-255)
+    uint8_t  mode_1_release_offset;                       // offset for key release in mode 1 and 2 (1-255)
+    uint16_t bottoming_reading[MATRIX_ROWS][MATRIX_COLS]; // bottoming reading
 } eeprom_ec_config_t;
 
 typedef struct {
@@ -47,11 +47,13 @@ typedef struct {
     uint16_t mode_0_actuation_threshold;                                        // threshold for key press in mode 0
     uint16_t mode_0_release_threshold;                                          // threshold for key release in mode 0
     uint16_t mode_1_initial_deadzone_offset;                                    // threshold for key press in mode 1 (initial deadzone)
+    uint8_t  mode_1_actuation_offset;                                           // offset for key press in mode 1 (1-255)
+    uint8_t  mode_1_release_offset;                                             // offset for key release in mode 1 (1-255)
     uint16_t rescaled_mode_0_actuation_threshold[MATRIX_ROWS][MATRIX_COLS];     // threshold for key press in mode 0 rescaled to actual scale
     uint16_t rescaled_mode_0_release_threshold[MATRIX_ROWS][MATRIX_COLS];       // threshold for key release in mode 0 rescaled to actual scale
     uint16_t rescaled_mode_1_initial_deadzone_offset[MATRIX_ROWS][MATRIX_COLS]; // threshold for key press in mode 1 (initial deadzone) rescaled to actual scale
-    uint8_t  mode_1_actuation_offset;                                      // offset for key press in mode 1 (1-255)
-    uint8_t  mode_1_release_offset;                                        // offset for key release in mode 1 (1-255)
+    uint8_t  rescaled_mode_1_actuation_offset[MATRIX_ROWS][MATRIX_COLS];        // offset for key press in mode 1 rescaled to actual scale
+    uint8_t  rescaled_mode_1_release_offset[MATRIX_ROWS][MATRIX_COLS];          // offset for key release in mode 1 rescaled to actual scale
     uint16_t extremum[MATRIX_ROWS][MATRIX_COLS];                                // extremum values for mode 1
     uint16_t noise_floor[MATRIX_ROWS][MATRIX_COLS];                             // noise floor detected during startup
     bool     bottoming_calibration;                                             // calibration mode for bottoming out values (true: calibration mode, false: normal mode)
@@ -82,3 +84,7 @@ void     ec_print_matrix(void);
 
 uint16_t rescale(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max);
 bool indicators_callback(void);
+
+#ifdef UNUSED_POSITIONS_LIST
+bool is_unused_position(uint8_t row, uint8_t col);
+#endif

+ 3 - 1
keyboards/cipulot/ec_typek/ec_typek.c

@@ -69,6 +69,8 @@ void keyboard_post_init_kb(void) {
             ec_config.rescaled_mode_0_actuation_threshold[row][col]     = rescale(ec_config.mode_0_actuation_threshold, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
             ec_config.rescaled_mode_0_release_threshold[row][col]       = rescale(ec_config.mode_0_release_threshold, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
             ec_config.rescaled_mode_1_initial_deadzone_offset[row][col] = rescale(ec_config.mode_1_initial_deadzone_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
+            ec_config.rescaled_mode_1_actuation_offset[row][col]        = rescale(ec_config.mode_1_actuation_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
+            ec_config.rescaled_mode_1_release_offset[row][col]          = rescale(ec_config.mode_1_release_offset, 0, 1023, ec_config.noise_floor[row][col], eeprom_ec_config.bottoming_reading[row][col]);
         }
     }
 
@@ -82,7 +84,7 @@ void keyboard_post_init_kb(void) {
 
 // This function gets called when caps, num, scroll change
 bool led_update_kb(led_t led_state) {
-    if(led_update_user(led_state)) {
+    if (led_update_user(led_state)) {
         indicators_callback();
     }
     return true;

+ 2 - 0
keyboards/cipulot/ec_vero/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 15
 
+#define UNUSED_POSITIONS_LIST { {2, 14}, {3, 12}, {4, 0}, {4, 3}, {4, 4}, {4, 5}, {4, 7}, {4, 8}, {4, 9}, {4, 12}, {4, 13}, {4, 14} }
+
 #define MATRIX_ROW_PINS \
     { B7, B6, A9, A10, B3 }
 

+ 1 - 3
keyboards/cipulot/ec_vero/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_vero/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 3

+ 2 - 0
keyboards/cipulot/ec_virgo/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 6
 #define MATRIX_COLS 18
 
+#define UNUSED_POSITIONS_LIST { {0, 6}, {0, 14}, {3, 14}, {3, 15}, {3, 16}, {3, 17}, {4, 12}, {4, 15}, {4, 17}, {5, 1}, {5, 4}, {5, 8}, {5, 11}, {5, 12}, {5, 14} }
+
 #define MATRIX_ROW_PINS \
     { B6, B7, B5, B4, B3, A15 }
 

+ 1 - 3
keyboards/cipulot/ec_virgo/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/ec_virgo/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 3

+ 2 - 0
keyboards/cipulot/mnk_60_ec/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 14
 
+#define UNUSED_POSITIONS_LIST { {3, 13}, {4, 3}, {4, 4}, {4, 6}, {4, 7}, {4, 8}, {4, 9}, {4, 13} }
+
 #define MATRIX_ROW_PINS \
     { B13, B14, B15, A8, A15 }
 

+ 1 - 3
keyboards/cipulot/mnk_60_ec/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/mnk_60_ec/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 3

+ 2 - 0
keyboards/cipulot/mnk_65_ec/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 15
 
+#define UNUSED_POSITIONS_LIST { {2, 13}, {3, 13}, {4, 3}, {4, 4}, {4, 6}, {4, 7}, {4, 8}, {4, 10}, {4, 13} }
+
 #define MATRIX_ROW_PINS \
     { B14, B15, A8, B12, A15 }
 

+ 1 - 3
keyboards/cipulot/mnk_65_ec/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/mnk_65_ec/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 3

+ 2 - 0
keyboards/cipulot/rf_r1_8_9xu/config.h

@@ -19,6 +19,8 @@
 #define MATRIX_ROWS 6
 #define MATRIX_COLS 16
 
+#define UNUSED_POSITIONS_LIST { {5, 3}, {5, 5} }
+
 #define MATRIX_ROW_PINS \
     { B15, A8, B13, B12, B14, B0 }
 

+ 1 - 3
keyboards/cipulot/rf_r1_8_9xu/post_rules.mk

@@ -1,3 +1 @@
-ifeq ($(strip $(VIA_ENABLE)), yes)
-    SRC += keyboards/cipulot/common/via_ec.c
-endif
+include keyboards/cipulot/common/common_cipulot.mk

+ 0 - 4
keyboards/cipulot/rf_r1_8_9xu/rules.mk

@@ -1,5 +1 @@
-CUSTOM_MATRIX = lite
-ANALOG_DRIVER_REQUIRED = yes
-VPATH += keyboards/cipulot/common
-SRC += matrix.c ec_board.c ec_switch_matrix.c
 OPT = 2