From 05af481c00dabde2e701bc272316dc5ddff12620 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 15 Sep 2018 18:35:46 -0400 Subject: [PATCH] hook ws2812 arm stuff up to rgblight stuff --- drivers/arm/ws2812.c | 14 ++++++++++++-- keyboards/planck/rev6/config.h | 4 +++- keyboards/planck/rev6/rev6.c | 12 +++++++++--- quantum/rgblight.c | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/arm/ws2812.c b/drivers/arm/ws2812.c index d55e2c2f47..a176755098 100644 --- a/drivers/arm/ws2812.c +++ b/drivers/arm/ws2812.c @@ -21,7 +21,7 @@ void setColor(uint8_t color, uint8_t *buf,uint32_t mask){ } } -void setColorRGB(Color c, uint8_t *buf, uint32_t mask){ +void setColorRGB(Color c, uint8_t *buf, uint32_t mask) { setColor(c.G,buf, mask); setColor(c.R,buf+8, mask); setColor(c.B,buf+16, mask); @@ -49,6 +49,10 @@ void ledDriverInit(int leds, stm32_gpio_t *port, uint32_t mask, uint8_t **o_fb) sMask=mask; palSetGroupMode(port, sMask, 0, PAL_MODE_OUTPUT_PUSHPULL|PAL_STM32_OSPEED_HIGHEST|PAL_STM32_PUPDR_FLOATING); + // maybe don't do whole port? + // palSetPadMode(port, 8, PAL_MODE_OUTPUT_PUSHPULL|PAL_STM32_OSPEED_HIGHEST|PAL_STM32_PUPDR_FLOATING); + + // configure pwm timers - // timer 2 as master, active for data transmission and inactive to disable transmission during reset period (50uS) // timer 3 as slave, during active time creates a 1.25 uS signal, with duty cycle controlled by frame buffer values @@ -151,9 +155,15 @@ void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds) { // ws2812_write_led(i, ledarray[i].r, ledarray[i].g, ledarray[i].b); // i++; // } + uint8_t i = 0; + while (i < number_of_leds) { + setColor(ledarray[i].g, (fb+24*i), sMask); + setColor(ledarray[i].r, (fb+24*i)+8, sMask); + setColor(ledarray[i].b, (fb+24*i)+16, sMask); + i++; + } } - void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds) { } diff --git a/keyboards/planck/rev6/config.h b/keyboards/planck/rev6/config.h index 0e462180bd..8c8da2cea2 100644 --- a/keyboards/planck/rev6/config.h +++ b/keyboards/planck/rev6/config.h @@ -125,7 +125,9 @@ /* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ //#define MIDI_TONE_KEYCODE_OCTAVES 1 -#define WS2812_LED_N 2 +#define RGBLIGHT_ANIMATIONS + +#define WS2812_LED_N 9 #define RGBLED_NUM WS2812_LED_N #define WS2812_TIM_N 2 #define WS2812_TIM_CH 2 diff --git a/keyboards/planck/rev6/rev6.c b/keyboards/planck/rev6/rev6.c index 0011d3e789..f1d0a17038 100644 --- a/keyboards/planck/rev6/rev6.c +++ b/keyboards/planck/rev6/rev6.c @@ -18,18 +18,24 @@ uint8_t *o_fb; +uint16_t counterst = 0; + void matrix_init_kb(void) { // rgblight_enable(); // rgblight_mode(1); // rgblight_setrgb(0xFF, 0xFF, 0xFF); - ledDriverInit(2, GPIOA, 0b00000010, &o_fb); - testPatternFB(o_fb); + ledDriverInit(9, GPIOA, 0b00000010, &o_fb); + //testPatternFB(o_fb); matrix_init_user(); } void matrix_scan_kb(void) { matrix_scan_user(); - testPatternFB(o_fb); + if (counterst == 0) { + //testPatternFB(o_fb); + } + counterst = (counterst + 1) % 1024; + rgblight_task(); } diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 2490a1d9f3..6f920f6c85 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -329,7 +329,7 @@ void rgblight_disable_noeeprom(void) { #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_disable(); #endif - _delay_ms(50); + wait_ms(50); rgblight_set(); }