~ruther/qmk_firmware

65a80f411f03be466d0b74c5b1d44f161e19ac7e — Ryan 2 years ago 3c144fa
Clean up APA102 config and add DD mapping (#20159)

41 files changed, 106 insertions(+), 53 deletions(-)

M data/mappings/info_config.hjson
M data/schemas/keyboard.jsonschema
M docs/feature_rgb_matrix.md
M docs/feature_rgblight.md
M drivers/led/apa102.c
M keyboards/handwired/onekey/blackpill_f401/config.h
M keyboards/handwired/onekey/blackpill_f401/info.json
M keyboards/handwired/onekey/blackpill_f401_tinyuf2/config.h
M keyboards/handwired/onekey/blackpill_f401_tinyuf2/info.json
M keyboards/handwired/onekey/blackpill_f411/config.h
M keyboards/handwired/onekey/blackpill_f411/info.json
M keyboards/handwired/onekey/blackpill_f411_tinyuf2/config.h
M keyboards/handwired/onekey/blackpill_f411_tinyuf2/info.json
M keyboards/handwired/onekey/bluepill/config.h
M keyboards/handwired/onekey/bluepill/info.json
M keyboards/handwired/onekey/bluepill_f103c6/config.h
M keyboards/handwired/onekey/bluepill_f103c6/info.json
M keyboards/handwired/onekey/bluepill_uf2boot/config.h
M keyboards/handwired/onekey/bluepill_uf2boot/info.json
M keyboards/handwired/onekey/elite_c/config.h
M keyboards/handwired/onekey/elite_c/info.json
M keyboards/handwired/onekey/evb_wb32f3g71/config.h
M keyboards/handwired/onekey/evb_wb32f3g71/info.json
M keyboards/handwired/onekey/evb_wb32fq95/config.h
M keyboards/handwired/onekey/evb_wb32fq95/info.json
M keyboards/handwired/onekey/nucleo_f446re/config.h
M keyboards/handwired/onekey/nucleo_f446re/info.json
M keyboards/handwired/onekey/nucleo_l432kc/config.h
M keyboards/handwired/onekey/nucleo_l432kc/info.json
M keyboards/handwired/onekey/promicro/config.h
M keyboards/handwired/onekey/promicro/info.json
M keyboards/handwired/onekey/proton_c/config.h
M keyboards/handwired/onekey/proton_c/info.json
M keyboards/handwired/onekey/sipeed_longan_nano/config.h
M keyboards/handwired/onekey/sipeed_longan_nano/info.json
M keyboards/handwired/onekey/stm32f0_disco/config.h
M keyboards/handwired/onekey/stm32f0_disco/info.json
M keyboards/handwired/onekey/teensy_2/config.h
M keyboards/handwired/onekey/teensy_2/info.json
M keyboards/handwired/onekey/teensy_2pp/config.h
M keyboards/handwired/onekey/teensy_2pp/info.json
M data/mappings/info_config.hjson => data/mappings/info_config.hjson +3 -0
@@ 10,6 10,9 @@
    // deprecated: Default `false`. Set to `true` to turn on warning when a value exists
    // invalid: Default `false`. Set to `true` to generate errors when a value exists
    // replace_with: use with a key marked deprecated or invalid to designate a replacement
    "APA102_DI_PIN": {"info_key": "apa102.data_pin"},
    "APA102_CI_PIN": {"info_key": "apa102.clock_pin"},
    "APA102_DEFAULT_BRIGHTNESS": {"info_key": "apa102.default_brightness", "value_type": "int"},
    "AUDIO_VOICES": {"info_key": "audio.voices", "value_type": "bool"},
    "BACKLIGHT_BREATHING": {"info_key": "backlight.breathing", "value_type": "bool"},
    "BREATHING_PERIOD": {"info_key": "backlight.breathing_period", "value_type": "int"},

M data/schemas/keyboard.jsonschema => data/schemas/keyboard.jsonschema +13 -0
@@ 96,6 96,19 @@
                "unknown"
            ]
        },
        "apa102": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "data_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
                "clock_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
                "default_brightness": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 31
                }
            }
        },
        "audio": {
            "type": "object",
            "additionalProperties": false,

M docs/feature_rgb_matrix.md => docs/feature_rgb_matrix.md +2 -2
@@ 383,9 383,9 @@ Configure the hardware via your `config.h`:

```c
// The pin connected to the data pin of the LEDs
#define RGB_DI_PIN D7
#define APA102_DI_PIN D7
// The pin connected to the clock pin of the LEDs
#define RGB_CI_PIN D6
#define APA102_CI_PIN D6
// The number of LEDs connected
#define RGB_MATRIX_LED_COUNT 70
```

M docs/feature_rgblight.md => docs/feature_rgblight.md +3 -2
@@ 35,8 35,9 @@ At minimum you must define the data pin your LED strip is connected to, and the 

|Define         |Description                                                                                              |
|---------------|---------------------------------------------------------------------------------------------------------|
|`RGB_DI_PIN`   |The pin connected to the data pin of the LEDs                                                            |
|`RGB_CI_PIN`   |The pin connected to the clock pin of the LEDs (APA102 only)                                             |
|`RGB_DI_PIN`   |The pin connected to the data pin of the LEDs (WS2812)                                                   |
|`APA102_DI_PIN`|The pin connected to the data pin of the LEDs (APA102)                                                   |
|`APA102_CI_PIN`|The pin connected to the clock pin of the LEDs (APA102)                                                  |
|`RGBLED_NUM`   |The number of LEDs connected                                                                             |
|`RGBLED_SPLIT` |(Optional) For split keyboards, the number of LEDs connected on each half directly wired to `RGB_DI_PIN` |


M drivers/led/apa102.c => drivers/led/apa102.c +13 -13
@@ 27,7 27,7 @@
#        if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) || defined(GD32VF103)
#            define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4))) // This calculates how many loops of 4 nops to run to delay 100 ns
#        else
#            error("APA102_NOPS configuration required")
#            error APA102_NOPS configuration required
#            define APA102_NOPS 0 // this just pleases the compile so the above error is easier to spot
#        endif
#    endif


@@ 43,14 43,14 @@
        }                                       \
    } while (0)

#define APA102_SEND_BIT(byte, bit)               \
    do {                                         \
        writePin(RGB_DI_PIN, (byte >> bit) & 1); \
        io_wait;                                 \
        writePinHigh(RGB_CI_PIN);                \
        io_wait;                                 \
        writePinLow(RGB_CI_PIN);                 \
        io_wait;                                 \
#define APA102_SEND_BIT(byte, bit)                  \
    do {                                            \
        writePin(APA102_DI_PIN, (byte >> bit) & 1); \
        io_wait;                                    \
        writePinHigh(APA102_CI_PIN);                \
        io_wait;                                    \
        writePinLow(APA102_CI_PIN);                 \
        io_wait;                                    \
    } while (0)

uint8_t apa102_led_brightness = APA102_DEFAULT_BRIGHTNESS;


@@ 77,11 77,11 @@ void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) {
}

void static apa102_init(void) {
    setPinOutput(RGB_DI_PIN);
    setPinOutput(RGB_CI_PIN);
    setPinOutput(APA102_DI_PIN);
    setPinOutput(APA102_CI_PIN);

    writePinLow(RGB_DI_PIN);
    writePinLow(RGB_CI_PIN);
    writePinLow(APA102_DI_PIN);
    writePinLow(APA102_CI_PIN);
}

void apa102_set_brightness(uint8_t brightness) {

M keyboards/handwired/onekey/blackpill_f401/config.h => keyboards/handwired/onekey/blackpill_f401/config.h +0 -2
@@ 23,8 23,6 @@

#define ADC_PIN A0

#define RGB_CI_PIN A2

#define SOLENOID_PIN B12
#define SOLENOID_PINS { B12, B13, B14, B15 }
#define SOLENOID_PINS_ACTIVE_STATE { high, high, low }

M keyboards/handwired/onekey/blackpill_f401/info.json => keyboards/handwired/onekey/blackpill_f401/info.json +4 -0
@@ 10,5 10,9 @@
    },
    "rgblight": {
        "pin": "A1"
    },
    "apa102": {
        "data_pin": "A1",
        "clock_pin": "A2"
    }
}

M keyboards/handwired/onekey/blackpill_f401_tinyuf2/config.h => keyboards/handwired/onekey/blackpill_f401_tinyuf2/config.h +0 -2
@@ 23,8 23,6 @@

#define ADC_PIN A0

#define RGB_CI_PIN A2

#define SOLENOID_PIN B12
#define SOLENOID_PINS { B12, B13, B14, B15 }
#define SOLENOID_PINS_ACTIVE_STATE { high, high, low }

M keyboards/handwired/onekey/blackpill_f401_tinyuf2/info.json => keyboards/handwired/onekey/blackpill_f401_tinyuf2/info.json +4 -0
@@ 11,5 11,9 @@
    },
    "rgblight": {
        "pin": "A1"
    },
    "apa102": {
        "data_pin": "A1",
        "clock_pin": "A2"
    }
}

M keyboards/handwired/onekey/blackpill_f411/config.h => keyboards/handwired/onekey/blackpill_f411/config.h +0 -2
@@ 23,8 23,6 @@

#define ADC_PIN A0

#define RGB_CI_PIN A2

#define SOLENOID_PIN B12
#define SOLENOID_PINS { B12, B13, B14, B15 }
#define SOLENOID_PINS_ACTIVE_STATE { high, high, low }

M keyboards/handwired/onekey/blackpill_f411/info.json => keyboards/handwired/onekey/blackpill_f411/info.json +4 -0
@@ 10,5 10,9 @@
    },
    "rgblight": {
        "pin": "A1"
    },
    "apa102": {
        "data_pin": "A1",
        "clock_pin": "A2"
    }
}

M keyboards/handwired/onekey/blackpill_f411_tinyuf2/config.h => keyboards/handwired/onekey/blackpill_f411_tinyuf2/config.h +0 -2
@@ 23,8 23,6 @@

#define ADC_PIN A0

#define RGB_CI_PIN A2

#define SOLENOID_PIN B12
#define SOLENOID_PINS { B12, B13, B14, B15 }
#define SOLENOID_PINS_ACTIVE_STATE { high, high, low }

M keyboards/handwired/onekey/blackpill_f411_tinyuf2/info.json => keyboards/handwired/onekey/blackpill_f411_tinyuf2/info.json +4 -0
@@ 11,5 11,9 @@
    },
    "rgblight": {
        "pin": "A1"
    },
    "apa102": {
        "data_pin": "A1",
        "clock_pin": "A2"
    }
}

M keyboards/handwired/onekey/bluepill/config.h => keyboards/handwired/onekey/bluepill/config.h +0 -2
@@ 21,5 21,3 @@
#define BACKLIGHT_PWM_CHANNEL 1

#define ADC_PIN A0

#define RGB_CI_PIN A2

M keyboards/handwired/onekey/bluepill/info.json => keyboards/handwired/onekey/bluepill/info.json +4 -0
@@ 10,5 10,9 @@
    },
    "rgblight": {
        "pin": "A1"
    },
    "apa102": {
        "data_pin": "A1",
        "clock_pin": "A2"
    }
}

M keyboards/handwired/onekey/bluepill_f103c6/config.h => keyboards/handwired/onekey/bluepill_f103c6/config.h +0 -2
@@ 22,8 22,6 @@

#define ADC_PIN A0

#define RGB_CI_PIN A2

// This code does not fit into the really small flash of STM32F103x6 together
// with CONSOLE_ENABLE=yes, and the debugging console is probably more
// important for the "onekey" testing firmware.  In a real firmware you may be

M keyboards/handwired/onekey/bluepill_f103c6/info.json => keyboards/handwired/onekey/bluepill_f103c6/info.json +4 -0
@@ 11,5 11,9 @@
    },
    "rgblight": {
        "pin": "A1"
    },
    "apa102": {
        "data_pin": "A1",
        "clock_pin": "A2"
    }
}

M keyboards/handwired/onekey/bluepill_uf2boot/config.h => keyboards/handwired/onekey/bluepill_uf2boot/config.h +0 -2
@@ 21,5 21,3 @@
#define BACKLIGHT_PWM_CHANNEL 1

#define ADC_PIN A0

#define RGB_CI_PIN A2

M keyboards/handwired/onekey/bluepill_uf2boot/info.json => keyboards/handwired/onekey/bluepill_uf2boot/info.json +4 -0
@@ 11,5 11,9 @@
    },
    "rgblight": {
        "pin": "A1"
    },
    "apa102": {
        "data_pin": "A1",
        "clock_pin": "A2"
    }
}

M keyboards/handwired/onekey/elite_c/config.h => keyboards/handwired/onekey/elite_c/config.h +0 -3
@@ 16,9 16,6 @@

#pragma once


#define RGB_CI_PIN B1

#define ADC_PIN F6

#define QMK_WAITING_TEST_BUSY_PIN F6

M keyboards/handwired/onekey/elite_c/info.json => keyboards/handwired/onekey/elite_c/info.json +4 -0
@@ 10,5 10,9 @@
    },
    "rgblight": {
        "pin": "F6"
    },
    "apa102": {
        "data_pin": "F6",
        "clock_pin": "B1"
    }
}

M keyboards/handwired/onekey/evb_wb32f3g71/config.h => keyboards/handwired/onekey/evb_wb32f3g71/config.h +0 -1
@@ 11,7 11,6 @@
#define BACKLIGHT_PAL_MODE    2

#define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4)))
#define RGB_CI_PIN B8

#define SOLENOID_PIN B12
#define SOLENOID_PINS { B12, B13, B14, B15 }

M keyboards/handwired/onekey/evb_wb32f3g71/info.json => keyboards/handwired/onekey/evb_wb32f3g71/info.json +4 -0
@@ 11,5 11,9 @@
    },
    "rgblight": {
        "pin": "A0"
    },
    "apa102": {
        "data_pin": "A0",
        "clock_pin": "B8"
    }
}

M keyboards/handwired/onekey/evb_wb32fq95/config.h => keyboards/handwired/onekey/evb_wb32fq95/config.h +0 -1
@@ 11,7 11,6 @@
#define BACKLIGHT_PAL_MODE    2

#define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4)))
#define RGB_CI_PIN B8

#define SOLENOID_PIN B12
#define SOLENOID_PINS { B12, B13, B14, B15 }

M keyboards/handwired/onekey/evb_wb32fq95/info.json => keyboards/handwired/onekey/evb_wb32fq95/info.json +4 -0
@@ 11,5 11,9 @@
    },
    "rgblight": {
        "pin": "A0"
    },
    "apa102": {
        "data_pin": "A0",
        "clock_pin": "B8"
    }
}

M keyboards/handwired/onekey/nucleo_f446re/config.h => keyboards/handwired/onekey/nucleo_f446re/config.h +0 -2
@@ 7,8 7,6 @@
#define BACKLIGHT_PWM_CHANNEL 3
#define BACKLIGHT_PAL_MODE    2

#define RGB_CI_PIN B13

#define ADC_PIN A0

#define SOLENOID_PINS { B12, B13, B14, B15 }

M keyboards/handwired/onekey/nucleo_f446re/info.json => keyboards/handwired/onekey/nucleo_f446re/info.json +4 -0
@@ 11,5 11,9 @@
    },
    "rgblight": {
        "pin": "A0"
    },
    "apa102": {
        "data_pin": "A0",
        "clock_pin": "B13"
    }
}

M keyboards/handwired/onekey/nucleo_l432kc/config.h => keyboards/handwired/onekey/nucleo_l432kc/config.h +0 -2
@@ 7,6 7,4 @@
#define BACKLIGHT_PWM_CHANNEL 3
#define BACKLIGHT_PAL_MODE    2

#define RGB_CI_PIN B13

#define ADC_PIN A0

M keyboards/handwired/onekey/nucleo_l432kc/info.json => keyboards/handwired/onekey/nucleo_l432kc/info.json +4 -0
@@ 11,5 11,9 @@
    },
    "rgblight": {
        "pin": "A0"
    },
    "apa102": {
        "data_pin": "A0",
        "clock_pin": "B13"
    }
}

M keyboards/handwired/onekey/promicro/config.h => keyboards/handwired/onekey/promicro/config.h +0 -3
@@ 16,9 16,6 @@

#pragma once


#define RGB_CI_PIN B1

#define ADC_PIN F6

#define QMK_WAITING_TEST_BUSY_PIN F6

M keyboards/handwired/onekey/promicro/info.json => keyboards/handwired/onekey/promicro/info.json +4 -0
@@ 10,5 10,9 @@
    },
    "rgblight": {
        "pin": "F6"
    },
    "apa102": {
        "data_pin": "F6",
        "clock_pin": "B1"
    }
}

M keyboards/handwired/onekey/proton_c/config.h => keyboards/handwired/onekey/proton_c/config.h +0 -2
@@ 21,6 21,4 @@
#define BACKLIGHT_PWM_CHANNEL 3
#define BACKLIGHT_PAL_MODE    2

#define RGB_CI_PIN B13

#define ADC_PIN A0

M keyboards/handwired/onekey/proton_c/info.json => keyboards/handwired/onekey/proton_c/info.json +4 -0
@@ 10,5 10,9 @@
    },
    "rgblight": {
        "pin": "A0"
    },
    "apa102": {
        "data_pin": "A0",
        "clock_pin": "B13"
    }
}

M keyboards/handwired/onekey/sipeed_longan_nano/config.h => keyboards/handwired/onekey/sipeed_longan_nano/config.h +0 -2
@@ 20,8 20,6 @@
#define BACKLIGHT_PWM_DRIVER PWMD5 /* GD32 numbering scheme starts from 0, TIMER4 on GD32 boards is TIMER5 on STM32 boards. */
#define BACKLIGHT_PWM_CHANNEL 2    /* GD32 numbering scheme starts from 0, Channel 1 on GD32 boards is Channel 2 on STM32 boards. */

#define RGB_CI_PIN B13

#define ADC_PIN A0

#define I2C1_CLOCK_SPEED 1000000 /* GD32VF103 supports fast mode plus. */

M keyboards/handwired/onekey/sipeed_longan_nano/info.json => keyboards/handwired/onekey/sipeed_longan_nano/info.json +4 -0
@@ 12,5 12,9 @@
    },
    "rgblight": {
        "pin": "A2"
    },
    "apa102": {
        "data_pin": "A2",
        "clock_pin": "B13"
    }
}

M keyboards/handwired/onekey/stm32f0_disco/config.h => keyboards/handwired/onekey/stm32f0_disco/config.h +0 -2
@@ 22,5 22,3 @@
#define BACKLIGHT_PAL_MODE    0

#define ADC_PIN A0

#define RGB_CI_PIN B13

M keyboards/handwired/onekey/stm32f0_disco/info.json => keyboards/handwired/onekey/stm32f0_disco/info.json +4 -0
@@ 11,5 11,9 @@
    },
    "rgblight": {
        "pin": "B15"
    },
    "apa102": {
        "data_pin": "B15",
        "clock_pin": "B13"
    }
}

M keyboards/handwired/onekey/teensy_2/config.h => keyboards/handwired/onekey/teensy_2/config.h +0 -2
@@ 19,7 19,5 @@

#define ADC_PIN F6

#define RGB_CI_PIN F7

#define QMK_WAITING_TEST_BUSY_PIN F6
#define QMK_WAITING_TEST_YIELD_PIN F7

M keyboards/handwired/onekey/teensy_2/info.json => keyboards/handwired/onekey/teensy_2/info.json +4 -0
@@ 11,5 11,9 @@
    },
    "rgblight": {
        "pin": "F6"
    },
    "apa102": {
        "data_pin": "F6",
        "clock_pin": "F7"
    }
}

M keyboards/handwired/onekey/teensy_2pp/config.h => keyboards/handwired/onekey/teensy_2pp/config.h +0 -2
@@ 19,7 19,5 @@

#define ADC_PIN F6

#define RGB_CI_PIN F7

#define QMK_WAITING_TEST_BUSY_PIN F6
#define QMK_WAITING_TEST_YIELD_PIN F7

M keyboards/handwired/onekey/teensy_2pp/info.json => keyboards/handwired/onekey/teensy_2pp/info.json +4 -0
@@ 11,5 11,9 @@
    },
    "rgblight": {
        "pin": "F6"
    },
    "apa102": {
        "data_pin": "F6",
        "clock_pin": "F7"
    }
}