Skip to content

Commit

Permalink
Merge pull request qmk#6 from keychron-contrib/vr-q1-fix-led-matrix
Browse files Browse the repository at this point in the history
[Q1] pretty up RGB matrix code on ANSI boards
  • Loading branch information
KeychronMacro authored Jan 24, 2022
2 parents 955488a + 51254f1 commit 8a9cd29
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 92 deletions.
2 changes: 1 addition & 1 deletion keyboards/keychron/q1/q1_ansi_atmega32u4/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
/* RGB Matrix Configuration */
#define DRIVER_1_LED_TOTAL 59
#define DRIVER_2_LED_TOTAL 23
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
58 changes: 33 additions & 25 deletions keyboards/keychron/q1/q1_ansi_atmega32u4/q1_ansi_atmega32u4.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const matrix_row_t matrix_mask[] = {
0b0111111111111111,
};

#ifdef RGB_MATRIX_ENABLE

const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
/* Refer to IS31 manual for these locations
* driver
Expand Down Expand Up @@ -122,30 +124,36 @@ const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {

};

led_config_t g_led_config = {
{
{ 0, NO_LED, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14 },
{ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 },
{ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44 },
{ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 71, 57, 58 },
{ 59, NO_LED, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 80, 70, 13 },
{ 72, 73, 74, NO_LED, NO_LED, NO_LED, 75, NO_LED, NO_LED, NO_LED, 76, 77, 78, 79, 81 }
},
{
{0,0}, {30, 0}, {45, 0}, {60, 0}, {75, 0}, {90, 0}, {105, 0}, {120, 0}, {135, 0}, {150, 0}, {165, 0}, {180, 0}, {195, 0}, {210, 0}, {224, 0},
{0,13}, {15,13}, {30,13}, {45,13}, {60,13}, {75,13}, {90,13}, {105,13}, {120,13}, {135,13}, {150,13}, {165,13}, {180,13}, {195,13}, {224,13},
{0,26}, {15,26}, {30,26}, {45,26}, {60,26}, {75,26}, {90,26}, {105,26}, {120,26}, {135,26}, {150,26}, {165,26}, {180,26}, {195,26}, {224,26},
{0,39}, {15,39}, {30,39}, {45,39}, {60,39}, {75,39}, {90,39}, {105,39}, {120,39}, {135,39}, {150,39}, {165,39}, {195,39}, {224,39},
{0,52}, {30,52}, {45,52}, {60,52}, {75,52}, {90,52}, {105,52}, {120,52}, {135,52}, {150,52}, {165,52}, {195,52}, {210,52},
{0,64}, {15,64}, {30,64}, {90,64}, {150,64}, {165,64}, {180,64}, {195,64}, {210,64}, {224,64},
},
{
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4
#define __ NO_LED

}
led_config_t g_led_config = {
{
// Key Matrix to LED Index
{ 0, __, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14 },
{ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 },
{ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44 },
{ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 71, 57, 58 },
{ 59, __, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 80, 70, 13 },
{ 72, 73, 74, __, __, __, 75, __, __, __, 76, 77, 78, 79, 81 }
},
{
// LED Index to Physical Position
{0,0}, {18,0}, {33,0}, {48,0}, {62,0}, {81,0}, {95,0}, {110,0}, {125,0}, {143,0}, {158,0}, {173,0}, {187,0}, {206,0}, {224,0},
{0,15}, {15,15}, {29,15}, {44,15}, {59,15}, {73,15}, {88,15}, {103,15}, {118,15}, {132,15}, {147,15}, {162,15}, {176,15}, {198,15}, {224,15},
{4,26}, {22,26}, {37,26}, {51,26}, {66,26}, {81,26}, {95,26}, {110,26}, {125,26}, {140,26}, {154,26}, {169,26}, {184,26}, {202,26}, {224,26},
{6,38}, {26,38}, {40,38}, {55,38}, {70,38}, {84,38}, {99,38}, {114,38}, {129,38}, {143,38}, {158,38}, {173,38}, {196,38}, {224,38},
{9,49}, {33,49}, {48,49}, {62,49}, {77,49}, {92,49}, {106,49}, {121,49}, {136,49}, {151,49}, {165,49}, {185,49}, {209,49},
{2,57}, {20,57}, {39,57}, {94,57}, {147,57}, {162,57}, {176,57}, {195,64}, {209,64}, {224,64}
},
{
// RGB LED Index to Flag
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
9, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
1, 1, 1, 4, 1, 1, 1, 1, 1, 1,
}
};

#endif
2 changes: 1 addition & 1 deletion keyboards/keychron/q1/q1_ansi_atmega32u4_ec11/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define DRIVER_ADDR_2 0b1011111

/* RGB Matrix Configuration */
#define DRIVER_1_LED_TOTAL 59
#define DRIVER_1_LED_TOTAL 58 // -1, disable LED under EC11
#define DRIVER_2_LED_TOTAL 23
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const matrix_row_t matrix_mask[] = {
};

#ifdef RGB_MATRIX_ENABLE

const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
/* Refer to IS31 manual for these locations
* driver
Expand All @@ -47,7 +48,7 @@ const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
{0, C_13, A_13, B_13},
{0, C_14, A_14, B_14},
{0, C_15, A_15, B_15},
{0, C_16, A_16, B_16},
// {0, C_16, A_16, B_16},

{0, F_1, D_1, E_1},
{0, F_2, D_2, E_2},
Expand Down Expand Up @@ -122,35 +123,42 @@ const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
{1, F_16, D_16, E_16}
};

#define __ NO_LED

led_config_t g_led_config = {
{
{ 0, NO_LED, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14 },
{ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 },
{ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44 },
{ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 71, 57, 58 },
{ 59, NO_LED, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 80, 70, 13 },
{ 72, 73, 74, NO_LED, NO_LED, NO_LED, 75, NO_LED, NO_LED, NO_LED, 76, 77, 78, 79, 81 }
// Key Matrix to LED Index
{ 0, __, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, __ },
{ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 },
{ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44 },
{ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 71, 57, 58 },
{ 59, __, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 80, 70, 13 },
{ 72, 73, 74, __, __, __, 75, __, __, __, 76, 77, 78, 79, 81 }
},
{
{0, 0}, {30, 0}, {45, 0}, {60, 0}, {75, 0}, {90, 0}, {105, 0}, {120, 0}, {135, 0}, {150, 0}, {165, 0}, {180, 0}, {195, 0}, {210, 0}, {224, 0},
{0,13}, {15,13}, {30,13}, {45,13}, {60,13}, {75,13}, {90,13}, {105,13}, {120,13}, {135,13}, {150,13}, {165,13}, {180,13}, {195,13}, {224,13},
{0,26}, {15,26}, {30,26}, {45,26}, {60,26}, {75,26}, {90,26}, {105,26}, {120,26}, {135,26}, {150,26}, {165,26}, {180,26}, {195,26}, {224,26},
{0,39}, {15,39}, {30,39}, {45,39}, {60,39}, {75,39}, {90,39}, {105,39}, {120,39}, {135,39}, {150,39}, {165,39}, {195,39}, {224,39},
{0,52}, {30,52}, {45,52}, {60,52}, {75,52}, {90,52}, {105,52}, {120,52}, {135,52}, {150,52}, {165,52}, {195,52}, {210,52},
{0,64}, {15,64}, {30,64}, {90,64}, {150,64}, {165,64}, {180,64}, {195,64}, {210,64}, {224,64}
// LED Index to Physical Position
{0,0}, {18,0}, {33,0}, {48,0}, {62,0}, {81,0}, {95,0}, {110,0}, {125,0}, {143,0}, {158,0}, {173,0}, {187,0}, {206,0},
{0,15}, {15,15}, {29,15}, {44,15}, {59,15}, {73,15}, {88,15}, {103,15}, {118,15}, {132,15}, {147,15}, {162,15}, {176,15}, {198,15}, {224,15},
{4,26}, {22,26}, {37,26}, {51,26}, {66,26}, {81,26}, {95,26}, {110,26}, {125,26}, {140,26}, {154,26}, {169,26}, {184,26}, {202,26}, {224,26},
{6,38}, {26,38}, {40,38}, {55,38}, {70,38}, {84,38}, {99,38}, {114,38}, {129,38}, {143,38}, {158,38}, {173,38}, {196,38}, {224,38},
{9,49}, {33,49}, {48,49}, {62,49}, {77,49}, {92,49}, {106,49}, {121,49}, {136,49}, {151,49}, {165,49}, {185,49}, {209,49},
{2,57}, {20,57}, {39,57}, {94,57}, {147,57}, {162,57}, {176,57}, {195,64}, {209,64}, {224,64}
},
{
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4
// RGB LED Index to Flag
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
9, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
1, 1, 1, 4, 1, 1, 1, 1, 1, 1,
}
};

#endif

#ifdef ENCODER_ENABLE

bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) { return false; }
if (index == 0) {
Expand All @@ -162,4 +170,5 @@ bool encoder_update_kb(uint8_t index, bool clockwise) {
}
return true;
}

#endif
4 changes: 2 additions & 2 deletions keyboards/keychron/q1/q1_ansi_stm32l432/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
/* Scan phase of led driver set as MSKPHASE_9CHANNEL(defined as 0x03 in CKLED2001.h) */
#define PHASE_CHANNEL MSKPHASE_9CHANNEL

/* Set the maxium brightness as 190 in order to limit the current to 450mA */
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 190
/* Set the maxium brightness as 192 in order to limit the current to 450mA */
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS (24 * 8) // 0 = RGB_MATRIX_VAL_STEP

/* Set USB polling rate as 1 milliseconds */
#define USB_POLLING_INTERVAL_MS 1
Expand Down
43 changes: 25 additions & 18 deletions keyboards/keychron/q1/q1_ansi_stm32l432/q1_ansi_stm32l432.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const matrix_row_t matrix_mask[] = {
};

#ifdef RGB_MATRIX_ENABLE

const ckled2001_led PROGMEM g_ckled2001_leds[DRIVER_LED_TOTAL] = {
/* Refer to IS31 manual for these locations
* driver
Expand Down Expand Up @@ -122,30 +123,36 @@ const ckled2001_led PROGMEM g_ckled2001_leds[DRIVER_LED_TOTAL] = {
{1, C_16, A_16, B_16},
};

#define __ NO_LED

led_config_t g_led_config = {
{
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, NO_LED, 14 },
{ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, NO_LED, 29 },
{ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, NO_LED, 44 },
{ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, NO_LED, 57, NO_LED, 58 },
{ 59, NO_LED, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, NO_LED, 70, 71, NO_LED },
{ 72, 73, 74, NO_LED, NO_LED, NO_LED, 75, NO_LED, NO_LED, NO_LED, 76, 77, 78, 79, 80, 81 },
// Key Matrix to LED Index
{ 0, __, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14 },
{ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 },
{ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44 },
{ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 71, 57, 58 },
{ 59, __, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 80, 70, 13 },
{ 72, 73, 74, __, __, __, 75, __, __, __, 76, 77, 78, 79, 81 }
},
{
{0, 0}, {15, 0}, {30, 0}, {45, 0}, {60, 0}, {75, 0}, {90, 0}, {105, 0}, {120, 0}, {135, 0}, {150, 0}, {165, 0}, {180, 0}, {195, 0}, {224, 0},
{0,13}, {15,13}, {30,13}, {45,13}, {60,13}, {75,13}, {90,13}, {105,13}, {120,13}, {135,13}, {150,13}, {165,13}, {180,13}, {195,13}, {224,13},
{0,26}, {15,26}, {30,26}, {45,26}, {60,26}, {75,26}, {90,26}, {105,26}, {120,26}, {135,26}, {150,26}, {165,26}, {180,26}, {195,26}, {224,26},
{0,39}, {15,39}, {30,39}, {45,39}, {60,39}, {75,39}, {90,39}, {105,39}, {120,39}, {135,39}, {150,39}, {165,39}, {195,39}, {224,39},
{0,52}, {30,52}, {45,52}, {60,52}, {75,52}, {90,52}, {105,52}, {120,52}, {135,52}, {150,52}, {165,52}, {195,52}, {210,52},
{0,64}, {15,64}, {30,64}, {90,64}, {150,64}, {165,64}, {180,64}, {195,64}, {210,64}, {224,64},
// LED Index to Physical Position
{0,0}, {18,0}, {33,0}, {48,0}, {62,0}, {81,0}, {95,0}, {110,0}, {125,0}, {143,0}, {158,0}, {173,0}, {187,0}, {206,0}, {224,0},
{0,15}, {15,15}, {29,15}, {44,15}, {59,15}, {73,15}, {88,15}, {103,15}, {118,15}, {132,15}, {147,15}, {162,15}, {176,15}, {198,15}, {224,15},
{4,26}, {22,26}, {37,26}, {51,26}, {66,26}, {81,26}, {95,26}, {110,26}, {125,26}, {140,26}, {154,26}, {169,26}, {184,26}, {202,26}, {224,26},
{6,38}, {26,38}, {40,38}, {55,38}, {70,38}, {84,38}, {99,38}, {114,38}, {129,38}, {143,38}, {158,38}, {173,38}, {196,38}, {224,38},
{9,49}, {33,49}, {48,49}, {62,49}, {77,49}, {92,49}, {106,49}, {121,49}, {136,49}, {151,49}, {165,49}, {185,49}, {209,49},
{2,57}, {20,57}, {39,57}, {94,57}, {147,57}, {162,57}, {176,57}, {195,64}, {209,64}, {224,64}
},
{
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
// RGB LED Index to Flag
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
9, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
1, 1, 1, 4, 1, 1, 1, 1, 1, 1,
}
};

#endif
6 changes: 3 additions & 3 deletions keyboards/keychron/q1/q1_ansi_stm32l432_ec11/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
#define DRIVER_ADDR_2 0b1110100

/* RGB Matrix Configuration */
#define DRIVER_1_LED_TOTAL 45
#define DRIVER_1_LED_TOTAL 44 // -1, no LED under EC11
#define DRIVER_2_LED_TOTAL 37
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)

/* Scan phase of led driver set as MSKPHASE_9CHANNEL(defined as 0x03 in CKLED2001.h) */
#define PHASE_CHANNEL MSKPHASE_9CHANNEL

/* Set the maxium brightness as 190 in order to limit the current to 450mA */
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 190
/* Set the maxium brightness as 192 in order to limit the current to 450mA */
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS (24 * 8) // 9 = RGB_MATRIX_VAL_STEP

/* Set USB polling rate as 1 milliseconds */
#define USB_POLLING_INTERVAL_MS 1
Expand Down
Loading

0 comments on commit 8a9cd29

Please sign in to comment.