Explorar el Código

hook ws2812 arm stuff up to rgblight stuff

Jack Humbert hace 7 años
padre
commit
05af481c00
Se han modificado 4 ficheros con 25 adiciones y 7 borrados
  1. 12 2
      drivers/arm/ws2812.c
  2. 3 1
      keyboards/planck/rev6/config.h
  3. 9 3
      keyboards/planck/rev6/rev6.c
  4. 1 1
      quantum/rgblight.c

+ 12 - 2
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) {
 
 }

+ 3 - 1
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

+ 9 - 3
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();
 }

+ 1 - 1
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();
 }