WS2812 bitbang: prefix for NOP_FUDGE define (#23110)

This commit is contained in:
Ryan 2024-02-20 21:13:18 +11:00 committed by GitHub
parent e198643d66
commit 865a8f42a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 7 deletions

View file

@ -40,4 +40,4 @@
#define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF #define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF
// Bitbang WS2812 // Bitbang WS2812
#define NOP_FUDGE 0.4 #define WS2812_BITBANG_NOP_FUDGE 0.4

View file

@ -42,4 +42,4 @@
#define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF #define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF
// Bitbang WS2812 // Bitbang WS2812
#define NOP_FUDGE 0.4 #define WS2812_BITBANG_NOP_FUDGE 0.4

View file

@ -3,18 +3,23 @@
#include "gpio.h" #include "gpio.h"
#include "chibios_config.h" #include "chibios_config.h"
// DEPRECATED - DO NOT USE
#if defined(NOP_FUDGE)
# define WS2812_BITBANG_NOP_FUDGE NOP_FUDGE
#endif
/* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */ /* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */
#ifndef NOP_FUDGE #ifndef WS2812_BITBANG_NOP_FUDGE
# if defined(STM32F0XX) || defined(STM32F1XX) || defined(GD32VF103) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) || defined(WB32F3G71xx) || defined(WB32FQ95xx) # if defined(STM32F0XX) || defined(STM32F1XX) || defined(GD32VF103) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) || defined(WB32F3G71xx) || defined(WB32FQ95xx)
# define NOP_FUDGE 0.4 # define WS2812_BITBANG_NOP_FUDGE 0.4
# else # else
# if defined(RP2040) # if defined(RP2040)
# error "Please use `vendor` WS2812 driver for RP2040" # error "Please use `vendor` WS2812 driver for RP2040"
# else # else
# error "NOP_FUDGE configuration required" # error "WS2812_BITBANG_NOP_FUDGE configuration required"
# endif # endif
# define NOP_FUDGE 1 // this just pleases the compile so the above error is easier to spot # define WS2812_BITBANG_NOP_FUDGE 1 // this just pleases the compile so the above error is easier to spot
# endif # endif
#endif #endif
@ -33,7 +38,7 @@
#endif #endif
#define NUMBER_NOPS 6 #define NUMBER_NOPS 6
#define CYCLES_PER_SEC (CPU_CLOCK / NUMBER_NOPS * NOP_FUDGE) #define CYCLES_PER_SEC (CPU_CLOCK / NUMBER_NOPS * WS2812_BITBANG_NOP_FUDGE)
#define NS_PER_SEC (1000000000L) // Note that this has to be SIGNED since we want to be able to check for negative values of derivatives #define NS_PER_SEC (1000000000L) // Note that this has to be SIGNED since we want to be able to check for negative values of derivatives
#define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) #define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC)
#define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) #define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE)