wip: Adapt for RGBed
This commit is contained in:
		
							parent
							
								
									08a2581297
								
							
						
					
					
						commit
						d5ac0d7277
					
				@ -2,8 +2,8 @@
 | 
				
			|||||||
#define _CCCONFIG_H
 | 
					#define _CCCONFIG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CCEMBEDDED
 | 
					#define CCEMBEDDED
 | 
				
			||||||
#define NUM_LIN_LEDS 60
 | 
					#define NUM_LIN_LEDS 66
 | 
				
			||||||
#define USE_NUM_LIN_LEDS 60
 | 
					#define USE_NUM_LIN_LEDS NUM_LIN_LEDS
 | 
				
			||||||
#define DFREQ (40000)
 | 
					#define DFREQ (40000)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -179,7 +179,7 @@ int main(void)
 | 
				
			|||||||
			this_samp = (this_samp+1)%CIRCBUFSIZE;
 | 
								this_samp = (this_samp+1)%CIRCBUFSIZE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			wf++;
 | 
								wf++;
 | 
				
			||||||
			if( wf == 128 )
 | 
								if( wf == 128 * 2)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				NewFrame();
 | 
									NewFrame();
 | 
				
			||||||
				wf = 0; 
 | 
									wf = 0; 
 | 
				
			||||||
 | 
				
			|||||||
@ -282,13 +282,14 @@ void SendSPI2812( unsigned char * lightarray, int length )
 | 
				
			|||||||
	static const uint8_t aoarray[4] = { 0b10001000, 0b10001110, 0b11101000, 0b11101110 };
 | 
						static const uint8_t aoarray[4] = { 0b10001000, 0b10001110, 0b11101000, 0b11101110 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
	if( length > SPI2812_MAX_LEDS ) length = SPI2812_MAX_LEDS;
 | 
						int subdiv = 0;
 | 
				
			||||||
 | 
						uint8_t * buffbase = &MyBuffer[ZERO_BUFFER];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	MyBuffer[0] = 0;
 | 
						if( length * SPI2812_LED_SCALING > SPI2812_MAX_LEDS ) length = SPI2812_MAX_LEDS;
 | 
				
			||||||
	for( i = 0; i < length; i++ )
 | 
					
 | 
				
			||||||
 | 
						for( i = 0; i < length;)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		uint8_t * colorbase = &lightarray[i*3];
 | 
							uint8_t * colorbase = &lightarray[i*3];
 | 
				
			||||||
		uint8_t * buffbase = &MyBuffer[i*24/2+ZERO_BUFFER];
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		int j;
 | 
							int j;
 | 
				
			||||||
		for( j = 0; j < 3; j++ )
 | 
							for( j = 0; j < 3; j++ )
 | 
				
			||||||
@ -300,11 +301,17 @@ void SendSPI2812( unsigned char * lightarray, int length )
 | 
				
			|||||||
			*(buffbase++) = aoarray[(c>>2)&3];
 | 
								*(buffbase++) = aoarray[(c>>2)&3];
 | 
				
			||||||
			*(buffbase++) = aoarray[(c>>0)&3];
 | 
								*(buffbase++) = aoarray[(c>>0)&3];
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (++subdiv == SPI2812_LED_SCALING) {
 | 
				
			||||||
 | 
								subdiv = 0;
 | 
				
			||||||
 | 
								i++;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for( i = 0; i < ZERO_BUFFER; i++ )
 | 
						for( i = 0; i < ZERO_BUFFER; i++ )
 | 
				
			||||||
		MyBuffer[i] = 0;
 | 
							MyBuffer[i] = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						length *= SPI2812_LED_SCALING;
 | 
				
			||||||
	length *= 24/2;
 | 
						length *= 24/2;
 | 
				
			||||||
	length += ZERO_BUFFER;
 | 
						length += ZERO_BUFFER;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -6,6 +6,7 @@
 | 
				
			|||||||
//24 bits per LED, can fit two bits per byte of output.
 | 
					//24 bits per LED, can fit two bits per byte of output.
 | 
				
			||||||
#define SPI2812_BUFFSIZE (SPI2812_MAX_LEDS*24/2)
 | 
					#define SPI2812_BUFFSIZE (SPI2812_MAX_LEDS*24/2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define SPI2812_LED_SCALING 3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void InitSPI2812();
 | 
					void InitSPI2812();
 | 
				
			||||||
void SendSPI2812( unsigned char * lightarray, int leds ); //Need one R, G, B per element.
 | 
					void SendSPI2812( unsigned char * lightarray, int leds ); //Need one R, G, B per element.
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user