Core/Src/main.c
void WS2812_Send (void) {

	uint32_t indx=0;
	uint32_t color;

	for (int i = 0; i < MAX_LED; i++) {

		#if USE_BRIGHTNESS
		color = ((LED_Mod[i][1]<<16) | (LED_Mod[i][2]<<8) | (LED_Mod[i][3]));
		#else
		color = ((LED_Data[i][1]<<16) | (LED_Data[i][2]<<8) | (LED_Data[i][3]));
		#endif

		for (int i = 23; i >= 0; i--) {

			if (color&(1 << i)) {
				pwmData[indx] = 57; // duty cycle is 64% from datasheet
			}

			else pwmData[indx] = 28;  // if the bit is 0, the duty cycle is 32%
			indx++;
		}
	}

	for (int i = 0; i < 50; i++) { // reset code
		pwmData[indx] = 0;
		indx++;
	}

	HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)pwmData, indx);  // send to dma

	while (!datasentflag){};  // set flag when data has been transmitted
	datasentflag = 0;
}
// 24 bits leds + 50 eset code

24 bits leds + 50 eset code
24 bits leds + 50 eset code
void WS2812_Send (void) {
	uint32_t indx=0;
	uint32_t color;
	for (int i = 0; i < MAX_LED; i++) {
		#if USE_BRIGHTNESS
		color = ((LED_Mod[i][1]<<16) | (LED_Mod[i][2]<<8) | (LED_Mod[i][3]));
		#else
		color = ((LED_Data[i][1]<<16) | (LED_Data[i][2]<<8) | (LED_Data[i][3]));
		#endif
		for (int i = 23; i >= 0; i--) {
			if (color&(1 << i)) {
				pwmData[indx] = 57; 
			}
			else pwmData[indx] = 28;  
			indx++;
		}
	}
	for (int i = 0; i < 50; i++) { 
		pwmData[indx] = 0;
		indx++;
	}
	HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)pwmData, indx);  
	while (!datasentflag){};  
	datasentflag = 0;
}
void WS2812_Send ( void ) { uint32_t indx = 0 ; uint32_t color ; for ( int i = 0 ; i < MAX_LED ; i ++ ) { #if USE_BRIGHTNESS color = ( ( LED_Mod [ i ] [ 1 ] << 16 ) | ( LED_Mod [ i ] [ 2 ] << 8 ) | ( LED_Mod [ i ] [ 3 ] ) ) ; #else color = ( ( LED_Data [ i ] [ 1 ] << 16 ) | ( LED_Data [ i ] [ 2 ] << 8 ) | ( LED_Data [ i ] [ 3 ] ) ) ; #endif for ( int i = 23 ; i >= 0 ; i -- ) { if ( color & ( 1 << i ) ) { pwmData [ indx ] = 57 ; } else pwmData [ indx ] = 28 ; indx ++ ; } } for ( int i = 0 ; i < 50 ; i ++ ) { pwmData [ indx ] = 0 ; indx ++ ; } HAL_TIM_PWM_Start_DMA ( & htim1 , TIM_CHANNEL_1 , ( uint32_t * ) pwmData , indx ) ; while ( ! datasentflag ) { } ; datasentflag = 0 ; }
24 bits leds + 50 eset code
24 bits leds + 50 eset code
// duty cycle is 64% from datasheet
 // if the bit is 0, the duty cycle is 32%
 // reset code
 // send to dma
 // set flag when data has been transmitted
