From dc3ce3a77713dfccb2a15071b409182922dd9e08 Mon Sep 17 00:00:00 2001 From: fruchti Date: Sun, 22 Dec 2019 19:42:18 +0100 Subject: [PATCH] Increase number of LEDs to 12 Caution: Disables SWD, makes flashing under reset necessary. --- build-number.txt | 2 +- src/led.c | 21 ++++++++++++++++----- src/led.h | 2 +- src/pinning.h | 3 +++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/build-number.txt b/build-number.txt index dde92dd..871727d 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -82 +84 diff --git a/src/led.c b/src/led.c index 47ac31c..430f1c6 100644 --- a/src/led.c +++ b/src/led.c @@ -5,19 +5,22 @@ | (1 << PIN_LED_B_0) | (1 << PIN_LED_R_1) \ | (1 << PIN_LED_G_1) | (1 << PIN_LED_B_1) \ | (1 << PIN_LED_R_2) | (1 << PIN_LED_G_2) \ - | (1 << PIN_LED_B_2)) + | (1 << PIN_LED_B_2) | (1 << PIN_LED_R_3) \ + | (1 << PIN_LED_G_3) | (1 << PIN_LED_B_3)) #define LED_MODER_MASK ((3 << PIN_LED_R_0 * 2) | (3 << PIN_LED_G_0 * 2) \ | (3 << PIN_LED_B_0 * 2) | (3 << PIN_LED_R_1 * 2) \ | (3 << PIN_LED_G_1 * 2) | (3 << PIN_LED_B_1 * 2) \ | (3 << PIN_LED_R_2 * 2) | (3 << PIN_LED_G_2 * 2) \ - | (3 << PIN_LED_B_2 * 2)) + | (3 << PIN_LED_B_2 * 2) | (3 << PIN_LED_R_3 * 2) \ + | (3 << PIN_LED_G_3 * 2) | (3 << PIN_LED_B_3 * 2)) #define LED_MODER ((1 << PIN_LED_R_0 * 2) | (1 << PIN_LED_G_0 * 2) \ | (1 << PIN_LED_B_0 * 2) | (1 << PIN_LED_R_1 * 2) \ | (1 << PIN_LED_G_1 * 2) | (1 << PIN_LED_B_1 * 2) \ | (1 << PIN_LED_R_2 * 2) | (1 << PIN_LED_G_2 * 2) \ - | (1 << PIN_LED_B_2 * 2)) + | (1 << PIN_LED_B_2 * 2) | (1 << PIN_LED_R_3 * 2) \ + | (1 << PIN_LED_G_3 * 2) | (1 << PIN_LED_B_3 * 2)) uint8_t LED_Data[LED_COUNT] = {0, 63, 200, 255}; @@ -29,6 +32,14 @@ static const uint16_t LED_BitLengths[LED_BITS - 4] = 16, 32, 64, 128, 256, 512, 1024, 2048 }; +static const int LED_Pins[LED_COUNT] = +{ + PIN_LED_R_0, PIN_LED_G_0, PIN_LED_B_0, + PIN_LED_R_1, PIN_LED_G_1, PIN_LED_B_1, + PIN_LED_R_2, PIN_LED_G_2, PIN_LED_B_2, + PIN_LED_R_3, PIN_LED_G_3, PIN_LED_B_3 +}; + static uint16_t LED_DMABuffer[LED_BITS + 1]; static void LED_RefreshDMABuffer(void) @@ -42,11 +53,11 @@ static void LED_RefreshDMABuffer(void) { if(gamma_corrected & (1 << j)) { - LED_DMABuffer[j] &= ~(1 << i); + LED_DMABuffer[j] &= ~(1 << LED_Pins[i]); } else { - LED_DMABuffer[j] |= 1 << i; + LED_DMABuffer[j] |= 1 << LED_Pins[i]; } } } diff --git a/src/led.h b/src/led.h index 051edf4..a0366ad 100644 --- a/src/led.h +++ b/src/led.h @@ -4,7 +4,7 @@ #include "pinning.h" #define LED_BITS 12 -#define LED_COUNT 9 +#define LED_COUNT 12 void LED_Init(void); diff --git a/src/pinning.h b/src/pinning.h index dc94431..41ee1a9 100644 --- a/src/pinning.h +++ b/src/pinning.h @@ -10,3 +10,6 @@ #define PIN_LED_R_2 6 #define PIN_LED_G_2 7 #define PIN_LED_B_2 9 +#define PIN_LED_R_3 10 +#define PIN_LED_G_3 13 +#define PIN_LED_B_3 14