-
1Step 1
160 MHz ( at the cost of just 50mW )
// https://github.com/cnlohr/ws2812esp8266/blob/master/user/user_main.c // user_init REG_SET_BIT(0x3ff00014, BIT(0)); os_update_cpu_frequency(160);
-
2Step 2
Update WS2812b driver to new CPU speed
// https://github.com/cnlohr/ws2812esp8266/blob/master/user/ws2812.c void ICACHE_FLASH_ATTR SEND_WS_0() { uint8_t time; time = 5; while(time--) WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(WSGPIO), 1 ); time = 17; while(time--) WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(WSGPIO), 0 ); } void ICACHE_FLASH_ATTR SEND_WS_1() { uint8_t time; time = 19; while(time--)WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR+GPIO_ID_PIN(WSGPIO),1); time = 7; while(time--) WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(WSGPIO), 0 ); }
-
3Step 3
Adjust udpserver_recv ( I have 14 leds , meaning N_LEDS=14 and the dB is scaled accordingly in the winamp plugin )
// https://github.com/cnlohr/ws2812esp8266/blob/master/user/user_main.c udpserver_recv(void *arg, char *pusrdata, unsigned short len) { struct espconn *pespconn = (struct espconn *)arg; if( len ==0 || len>20) return; s_inDb = atoi(pusrdata); if( s_inDb>N_LEDS) s_inDb = N_LEDS; // DBG ..... }
-
4Step 4
Udate WS2812B, the HSVtoHex is from the top routine made by cnlohr ( the base for this hack )
// https://github.com/cnlohr/ws2812esp8266/blob/master/user/user_main.c static void ICACHE_FLASH_ATTR procTask(os_event_t *events) { int i=0; uint32_t hex; // color system_os_post(procTaskPrio, 0, 0 ); if( events->sig == 0 && events->par == 0 ) { //Idle Event. } if( s_ledDb !=s_inDb) { s_ledDb = s_inDb; for( i = 0; i <s_ledDb; i++ ) { // see cnlohr top, to play with patterns hex=HSVtoHEX( i*.05 + frame*.01, 1, 1.0 ); buffer[0+i*3] = (hex>>8); buffer[1+i*3] = (hex); buffer[2+i*3] = (hex>>16); } // OFF for( i=s_ledDb; i<N_LEDS; ++i) { hex=0; //"black" buffer[0+i*3] = (hex>>8); buffer[1+i*3] = (hex); buffer[2+i*3] = (hex>>16); } WS2812OutBuffer( buffer, N_LEDS*3 ); frame++; } }
-
5Step 5
Hack a winamp plugin/ gstreamer ....or use ADC to produce "s_inDb"
// http://sourceforge.net/projects/vu-meter/ // In Svis.c by Boris Ribov // Analog VU Meter for Winamp - Version 1.50 // Global int client_s=0; // Client socket descriptor struct sockaddr_in server_addr; // Server Internet address int addr_len; // Internet address length char out_buf[4096]; // Output buffer for data WSADATA wsaData; // init WORD wVersionRequested = MAKEWORD(1,1); // Stuff for WSA functions WSAStartup(wVersionRequested, &wsaData); client_s = socket(AF_INET, SOCK_DGRAM, 0); server_addr.sin_family = AF_INET; // Address family to use server_addr.sin_port = htons(7777); // Port num to use server_addr.sin_addr.s_addr = inet_addr("192.168.4.1"); // IP address to use // render, UDP send dB // quick & dirty calculation to match 14 led aCurPeak = (5*log((output0+output1)/2 )+0.5)-8; if( aCurPeak<0 ) aCurPeak = 0; if( aPrevPeak != aCurPeak ) { aPrevPeak = aCurPeak; sprintf(out_buf,"%d",(int)aCurPeak); sendto(client_s, out_buf, (strlen(out_buf) + 1), 0, (struct sockaddr *)&server_addr, sizeof(server_addr)); }
-
6Step 6
Ip adress is default 192.168.4.1 and port 7777 since it is based on https://github.com/cnlohr/ws2812esp8266.
// https://github.com/cnlohr/ws2812esp8266/blob/master/user/user_main.c wifi_set_opmode( 2 ); //We broadcast our ESSID, wait for peopel to join.
Connect PC to Esp8266 and start Winamp + plugin .....ready to rock !!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.