/***Chequear que no queden "cuevas"***/ void DataBmp24::loadMatrix(char* data,int row_padded, int height,int width) { char tmp; for(int i = 0; i < height; i++) { for(int j = 0; j < width*3; j += 3) { // Convert (B, G, R) to (R, G, B) tmp = data[j+(row_padded*i)]; data[j+(row_padded*i)] = data[j+(row_padded*i)+2]; data[j+(row_padded*i)+2] = tmp; //carga de bits a la matriz char a=data[j+(row_padded*i)]; int red=(int)data[j+(row_padded*i)]; int green=(int)data[j +row_padded*i + 1]; int blue=(int)data[j +row_padded*i + 2]; unsigned int val=colorVal(red,green,blue,255); if(val==3) //tiene color { PixelBmp* aInvalidPixel = new PixelBmp(new Position(height-1-i,j/3), new ColorRgb(red,green,blue,255)); invalidPixels->push_back(aInvalidPixel); (*bitmap)[height-1-i]->push_back(false); ///*********************** //Avisar en el log el color encontrado } else //blanco o negro { if( (val==1) || (posValid(height-i, j/3) && getBit(height-i,j/3)==true) )//Si el bit debajo es blanco, pongo un blanco { (*bitmap)[height-1-i]->push_back(true); setWhitePosition(height-1-i,j/3); }else //negro { (*bitmap)[height-1-i]->push_back(false); setBlackPosition(height-1-i,j/3); } //setBit(height-1-i,j/3,val); } } } //evaluar lista de bits invalidos resetInvalidPixels(); }
/***Chequear que no queden "cuevas"***/ void DataBmp32::loadMatrix(char* data,int row_padded, int height,int width) { char tmp; for(int i = 0; i < height; i++) { for(int j = 0; j < width*4; j += 4) { // Convert (B, G, R) to (R, G, B) tmp = data[j+(row_padded*i)]; data[j+(row_padded*i)] = data[j+(row_padded*i)+2]; data[j+(row_padded*i)+2] = tmp; //carga de bits a la matriz char a=data[j+(row_padded*i)]; int red=(int)data[j+(row_padded*i)]; int green=(int)data[j +row_padded*i + 1]; int blue=(int)data[j +row_padded*i + 2]; int alpha=(int)data[j +row_padded*i + 3]; unsigned int val=colorVal(red,green,blue,alpha); if(val==2) //es transparente { (*bitmap)[height-1-i]->push_back(true); ///*********************** //Avisar en el log el color encontrado } else //color { if((posValid(height-i, j/4) && getBit(height-i,j/4)==true) )//Si el bit debajo es transparente, pongo un transparente { (*bitmap)[height-1-i]->push_back(true); }else //color { (*bitmap)[height-1-i]->push_back(false); setBlackPosition(height-1-i,j/4); } }//endif valor del color }//end for recorrido columnas }//end for recorrido de filas }
void loop() { while(modeButtonState == 1) //Used as an off mode, sets LED's off. { Serial.println("1"); //debugging setColorRGB(0, 0, 0); delay(500); checkModeButton(modeButton, mState); } while(modeButtonState == 2) //pick your own color using rgb buttons. 10 intensities of each color. { Serial.println("2"); //debugging int valRedLED, valGreenLED, valBlueLED; valRedLED = colorVal(redButtonState); valGreenLED = colorVal(greenButtonState); valBlueLED = colorVal(blueButtonState); setColorRGB(valRedLED, valGreenLED, valBlueLED); checkColorButton(redButton, rState); checkColorButton(greenButton, gState); checkColorButton(blueButton, bState); checkModeButton(modeButton, mState); delay(500); } while(modeButtonState == 3) //color fade, pick how fast they fade w/ 3 pre-determined speeds { Serial.println("3"); //debugging colorFader(); //create input variable for delay checkModeButton(modeButton, mState); delay(500); } while(modeButtonState == 4) //color fade different for each strip, pick speeds like above { Serial.println("4"); //debugging checkModeButton(modeButton, mState); delay(500); } while(modeButtonState == 5) //color changes with music { Serial.println("5"); //debugging checkModeButton(modeButton, mState); delay(500); } checkModeButton(modeButton, mState); delay(500); }