components/core2forAWS/sk6812/sk6812.c
void np_show(pixel_settings_t *px, rmt_channel_t channel)
{
	float ratio = 40000000.0 / 1e9; 
	uint16_t blen = px->pixel_count * (px->nbits / 8) + 1;

	xSemaphoreTake(neopixel_sem, portMAX_DELAY);
	neopixel_t0h_ticks = (uint32_t)(ratio * px->timings.t0h);
    neopixel_t0l_ticks = (uint32_t)(ratio * px->timings.t0l);
    neopixel_t1h_ticks = (uint32_t)(ratio * px->timings.t1h);
    neopixel_t1l_ticks = (uint32_t)(ratio * px->timings.t1l);
	neopixel_reset_ticks = (uint32_t)(ratio * px->timings.reset);

	// Allocate neopixel buffer if needed
	if (neopixel_buffer == NULL) {
		neopixel_buffer = (uint8_t *)malloc(blen);
		if (neopixel_buffer == NULL) return;
		neopixel_buf_len = blen;
	}
	// Resize neopixel buffer if needed
	if (neopixel_buf_len < blen) {
		// larger buffer needed
		free(neopixel_buffer);
		neopixel_buffer = (uint8_t *)malloc(blen);
		if (neopixel_buffer == NULL) return;
	}

	memcpy(neopixel_buffer, px->pixels, blen);
	for (uint16_t i = 0; i < blen; i++) {
		float b = px->brightness / 255.0;
		neopixel_buffer[i] = b * neopixel_buffer[i]; 
	}
	rmt_write_sample(channel, neopixel_buffer, blen, true);
	xSemaphoreGive(neopixel_sem);
}
// Start the transfer of Neopixel color bytes from buffer
//=======================================================
Start the transfer of Neopixel color bytes from buffer
Start the transfer of Neopixel color bytes from buffer
void np_show(pixel_settings_t *px, rmt_channel_t channel)
{
	float ratio = 40000000.0 / 1e9; 
	uint16_t blen = px->pixel_count * (px->nbits / 8) + 1;
	xSemaphoreTake(neopixel_sem, portMAX_DELAY);
	neopixel_t0h_ticks = (uint32_t)(ratio * px->timings.t0h);
    neopixel_t0l_ticks = (uint32_t)(ratio * px->timings.t0l);
    neopixel_t1h_ticks = (uint32_t)(ratio * px->timings.t1h);
    neopixel_t1l_ticks = (uint32_t)(ratio * px->timings.t1l);
	neopixel_reset_ticks = (uint32_t)(ratio * px->timings.reset);
	if (neopixel_buffer == NULL) {
		neopixel_buffer = (uint8_t *)malloc(blen);
		if (neopixel_buffer == NULL) return;
		neopixel_buf_len = blen;
	}
	if (neopixel_buf_len < blen) {
		free(neopixel_buffer);
		neopixel_buffer = (uint8_t *)malloc(blen);
		if (neopixel_buffer == NULL) return;
	}
	memcpy(neopixel_buffer, px->pixels, blen);
	for (uint16_t i = 0; i < blen; i++) {
		float b = px->brightness / 255.0;
		neopixel_buffer[i] = b * neopixel_buffer[i]; 
	}
	rmt_write_sample(channel, neopixel_buffer, blen, true);
	xSemaphoreGive(neopixel_sem);
}
void np_show ( pixel_settings_t * px , rmt_channel_t channel ) { float ratio = 40000000.0 / 1e9 ; uint16_t blen = px -> pixel_count * ( px -> nbits / 8 ) + 1 ; xSemaphoreTake ( neopixel_sem , portMAX_DELAY ) ; neopixel_t0h_ticks = ( uint32_t ) ( ratio * px -> timings . t0h ) ; neopixel_t0l_ticks = ( uint32_t ) ( ratio * px -> timings . t0l ) ; neopixel_t1h_ticks = ( uint32_t ) ( ratio * px -> timings . t1h ) ; neopixel_t1l_ticks = ( uint32_t ) ( ratio * px -> timings . t1l ) ; neopixel_reset_ticks = ( uint32_t ) ( ratio * px -> timings . reset ) ; if ( neopixel_buffer == NULL ) { neopixel_buffer = ( uint8_t * ) malloc ( blen ) ; if ( neopixel_buffer == NULL ) return ; neopixel_buf_len = blen ; } if ( neopixel_buf_len < blen ) { free ( neopixel_buffer ) ; neopixel_buffer = ( uint8_t * ) malloc ( blen ) ; if ( neopixel_buffer == NULL ) return ; } memcpy ( neopixel_buffer , px -> pixels , blen ) ; for ( uint16_t i = 0 ; i < blen ; i ++ ) { float b = px -> brightness / 255.0 ; neopixel_buffer [ i ] = b * neopixel_buffer [ i ] ; } rmt_write_sample ( channel , neopixel_buffer , blen , true ) ; xSemaphoreGive ( neopixel_sem ) ; }
Start the transfer of Neopixel color bytes from buffer
Start the transfer of Neopixel color bytes from buffer
// Allocate neopixel buffer if needed // Resize neopixel buffer if needed // larger buffer needed