Beispiel #1
0
 void updateDisplay()
 {
   if (FMode == FM_SEMI)
   {
     #ifdef FUNC_SETRGB
       setRGB(FM_SEMI_COLOR);
     #endif
   }
   else if (FMode == FM_RBND)
   {
     #ifdef FUNC_SETRGB
       setRGB(FM_RBND_COLOR);
     #endif
   }
   else if (FMode == FM_BRST)
   {
     #ifdef FUNC_SETRGB
       setRGB(FM_BRST_COLOR);
     #endif
   }
   else if (FMode == FM_AUTO)
   {
     #ifdef FUNC_SETRGB
       setRGB(FM_AUTO_COLOR);
     #endif
   }
 }
Beispiel #2
0
void main() {
  initLEDs(); // initialisation of strand, as defined in ws2812b.h --> port pin needs to be set there ! ! !
  setRGB(0,0,0xFF0000); // pixel 0,0 as red
  setRGB(1,0,0x00FF00); // pixel 1,0 as green 
  setRGB(2,0,0x0000FF); // pixel 2,0 as blue
  setMaxBrightness(5); // dim down to 5 = low brightness
  showLEDs(); // display all color values now
}
void loop() {
  // Green
  setRGB(0, 255, 0);
  delay(1);
  // Yellow
  setRGB(210, 219, 29);
  delay(1);
  // Red
  setRGB(255, 0, 0);
  delay(2);
}
Beispiel #4
0
void main() {
  initLEDs(); // initialisation of strand, as defined in ws2812b.h --> port pin needs to be set there ! ! !
  setMaxBrightness(10); // relatively low, good for the eyes
  // repeat endlessly for blinking:
  while (1) {				 
    setRGB(0,0,0xFF9922);showLEDs(); // "on" -  some color
    _delay_ms(200);									 // pause a little
    setRGB(0,0,0x000000);showLEDs(); // "off" - might as well use clearLEDs();
    _delay_ms(500);									 // pause a little more
  }
}
Beispiel #5
0
void DrasculaEngine::loadPic(const char *NamePcc, byte *targetSurface, int colorCount) {
	debug(5, "loadPic(%s)", NamePcc);

	uint dataSize = 0;
	byte *pcxData;

	Common::SeekableReadStream *stream = _archives.open(NamePcc);
	if (!stream)
		error("missing game data %s %c", NamePcc, 7);

	dataSize = stream->size() - 128 - (256 * 3);
	pcxData = (byte *)malloc(dataSize);

	stream->seek(128, SEEK_SET);
	stream->read(pcxData, dataSize);

	decodeRLE(pcxData, targetSurface);
	free(pcxData);

	for (int i = 0; i < 256; i++) {
		cPal[i * 3 + 0] = stream->readByte();
		cPal[i * 3 + 1] = stream->readByte();
		cPal[i * 3 + 2] = stream->readByte();
	}

	delete stream;

	setRGB((byte *)cPal, colorCount);
}
Beispiel #6
0
/*EDU US*/ void rgb_lcd::branch(void){
	NBR_ROWS=2;
	NBR_COLS=16;

	begin(NBR_COLS, NBR_ROWS);
	setRGB(255, 255, 255);
	delay(1000);
	//---- Configuration mémoire à 0
	  //-- Memory => remplissage par défaut
	  for(int8_t i=0;i<NBR_COLS;i++){
		m_memory[i][0]='=';
	  }
	  for(int8_t i=0;i<NBR_COLS;i++){
		m_memory[i][1]='.';
	  }
	  
	//--- Affichage de memory => Serial
	DEBUG_TAB2("MEMORY contient initialement : ", m_memory,0,15,0,1);
		
	//----- Position curseur par défaut
	  m_curentRow=0;
	  m_curentCol=0;
	//----- Initialisation de la taille max du nombre attaché à la position
		// 0 = pas de nbr attaché à la position
		// 4 = le nombre attaché à la position à au moins 4 chiffres
	  for(int8_t m=0;m<NBR_ROWS;m++){
		for(int8_t i=0;i<NBR_COLS;i++){
			m_maxLength[i][m]=0;
		}
	  }
}
Beispiel #7
0
void mpxlcol_load (FORM* form) 
{	
	//Wenn noch kein Colorset gespeichert wurde, wird das Default Colorset
	//Abgespeichert. Sonst wird das COlorset aus dem Speicher geladen.
 	if((BFS_LoadFile(BFS_ID_RGB_Colors, sizeof(struct Colorset), (unsigned char*) &colors))	
 		!= sizeof(struct Colorset)) 
 	{
 		colors = default_Colorset;
 		BFS_SaveFile(BFS_ID_RGB_Colors, sizeof(struct Colorset), (unsigned char*) &colors);
 		msgbox(50,BC_OKOnly | BC_DefaultButton1,"Defaults geladen");
 	}

	pointer = 0;
	//Controls mit den Werten im Speicher initialisieren.
	memcpy(((TXTBOX*)form->controls[3])->text,colors.Name[pointer],20);
	((TRACKBAR*)form->controls[4])->actval = colors.color[pointer].Red;
	((TRACKBAR*)form->controls[5])->actval = colors.color[pointer].Green;
	((TRACKBAR*)form->controls[6])->actval = colors.color[pointer].Blue;
	//und zeichnen
	control_draw(form->controls[3], 0);
	control_draw(form->controls[4], 0);
	control_draw(form->controls[5], 0);
	control_draw(form->controls[6], 0);	

	//setzen der ersten Farbe im Speicher
	cc1100_init();
	setRGB(colors.color[0]);
	//Einschalten des LED-Stacks
	led_state(mpxl_state_on);
}
Beispiel #8
0
OGL_Box::OGL_Box(Box* hvkBox) : HvkOGLObj(hvkBox){
	setSize(hvkBox->sx, hvkBox->sy, hvkBox->sz);
	setRGB();
	mx = hvkBox->sx;
	my = hvkBox->sy;
	mz = hvkBox->sz;
}
Beispiel #9
0
/*** Blink LED ***/
void RGB::blink(int numberOfTimes, int Delay_OnTime, int Delay_OffTime)
{
	int i = 0;
	int rgb[] = {red, green, blue};
	//for loop for blinking
	for(i=0; i<numberOfTimes; i++)
	{
		setRGB(0,0,0);
		_delay(Delay_OnTime);
		setRGB(rgb[0],rgb[1],rgb[2]);
		_delay(int Delay_OffTime);
	}
	
	// bring back to previous state
	setRGB(rgb[0],rgb[1],rgb[2]);
}
Beispiel #10
0
void intersectRP(vec4 is, float ax, float ay, float az, float bx, float by, float bz, RGB *ci, RGB ca, RGB cb, float ix){

  float my, qy, mz, qz, iy, iz;
  int rda, rdb, gra, grb, bla, blb, ird, igr, ibl, mrd, mgr, mbl, qrd, qgr, qbl;

  getRGB(ca, &rda, &gra, &bla);
  getRGB(cb, &rdb, &grb, &blb);
  if (ax==bx) {
    return;
  }
  else {
    my = (by - ay)/(bx - ax);
    qy = ay - (my*ax);
    mz = (bz - az)/(bx - ax);
    qz = az - (mz*ax);
    mrd = (int) ((rdb - rda)/(bx - ax)); 
    qrd = (int) (rdb - (mrd*ax));
    mgr = (int) ((grb - gra)/(bx - ax));
    qgr = (int) (grb - (mgr*ax));
    mbl = (int) ((blb - bla)/(bx - ax));
    qbl = (int) (blb - (mbl*ax));
    iy = my*ix + qy;
    iz = mz*ix + qz;
    ird = (int) (mrd*ix + qrd);
    igr = (int) (mgr*ix + qgr);
    ibl = (int) (mbl*ix + qbl);
    setRGB(ci, ird, igr, ibl);
    initVec4Norm(ix, iy, iz, is);
  }
}
Beispiel #11
0
void MatrixOpData::MatrixArray::expandFrom3x3To4x4()
{
    const Values oldValues = getValues();

    resize(4, 4);

    setRGB(oldValues.data());
}
Beispiel #12
0
static PyObject* pySetRGB(PyObject *self, PyObject *args) {
	int r,g,b;
	if(!PyArg_ParseTuple(args, "iii", &r,&g,&b))
      return NULL;
  
	setRGB(r,g,b);
	Py_RETURN_NONE;
}
Beispiel #13
0
Color::Color( unsigned int mode, double v0, double v1, double v2, double alpha) {
  if ( mode == MODE_RGB ) {
    setRGB( v0, v1, v2 );
  } else if ( mode == MODE_HSV ) {
    setHSV( v0, v1, v2 );
  }
  setAlpha( alpha );
}
// Constructor
Image::Image(Mat image_src) :
image_mat_(image_src)
{
	// Initiate RGB and HSV for this image
	setRGB(image_src);
	setHSV(image_src);

	// Set the histogram of this Image
	setHistogram(image_src);
}
Beispiel #15
0
void Image::emotion(int x, int y, float degree){
    int imageWidth = m_width;
    int imageHeight = m_height;
    long pixelCount = imageHeight * imageWidth;
    
    long tapPixelIndex = getIndexOfPoint(x, y);
    int step = m_channels;
    
    struct HSL baseHSL;
    struct RGB baseRGB;
    setRGB(m_imageData[tapPixelIndex*step + 0], m_imageData[tapPixelIndex*step + 1], m_imageData[tapPixelIndex*step + 2], &baseRGB);
    rgb2HSL(&baseRGB, &baseHSL);
    
    struct HSL hsl;
    struct RGB rgb;
    for (long index = 0; index < pixelCount; index++) {
        long arrayIndex = index*step;
        int red = m_imageData[arrayIndex + 0];
        int green = m_imageData[arrayIndex + 1];
        int blue = m_imageData[arrayIndex + 2];
        setRGB(red, green, blue, &rgb);
        rgb2HSL(&rgb, &hsl);
        
        float rate = analogicalRateWithBaseHSL(&baseHSL, &hsl, degree);
        if (rate < 0) {
            setHSL(0, 0, hsl.Lummiance, &hsl);
            hsl2RGB(&hsl, &rgb);
            m_imageData[arrayIndex + 0] = rgb.Red;
            m_imageData[arrayIndex + 1] = rgb.Green;
            m_imageData[arrayIndex + 2] = rgb.Blue;
        }else if(rate > 0.001f){
            int newSa = rate * hsl.Saturation;
            setHSL(hsl.Hue, newSa, hsl.Lummiance, &hsl);
            hsl2RGB(&hsl, &rgb);
            m_imageData[arrayIndex + 0] = rgb.Red;
            m_imageData[arrayIndex + 1] = rgb.Green;
            m_imageData[arrayIndex + 2] = rgb.Blue;
        }
    }

}
	bool initWithString(const char *string, const char *fontName,
			float fontSize, const cocos2d::Size& dimensions,
			cocos2d::TextHAlignment hAlignment,
			cocos2d::TextVAlignment vAlignment,
			float red, float green, float blue)
	{
		if (!cocos2d::LabelTTF::initWithString(string,
				fontName, fontSize, dimensions, hAlignment, vAlignment))
			return false;

		setFlippedY(true);
		setRGB(red, green, blue);
		return true;
	}
Beispiel #17
0
//---------- Gestion des int
/*EDU FR*/ void rgb_lcd::retroeclairage(long r, long g, long b){
	unsigned char rUC;
	unsigned char gUC;
	unsigned char bUC;
	if(r<0){r=0;}
	if(g<0){r=0;}
	if(b<0){r=0;}
	if(r>1000){r=1000;}
	if(g>1000){g=1000;}
	if(b>1000){b=1000;}
	rUC = map(r,0,1000,0,255);
	gUC = map(g,0,1000,0,255);
	bUC = map(b,0,1000,0,255);
	setRGB(rUC,gUC,bUC);
}
Beispiel #18
0
void PNGImage::saveImage(const char* outpath) {
  int error_code = 0;
  FILE* file_descriptor = nullptr;
  png_structp png_ptr = nullptr;
  png_infop info_ptr = nullptr;
  png_bytep row = nullptr;

  file_descriptor = fopen(outpath, "wb");
  if (file_descriptor == nullptr) { error_code = 101; goto ERROR_PNG_write; }

  png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
  if (png_ptr == nullptr) { error_code = 10; goto ERROR_PNG_write; }
  info_ptr = png_create_info_struct(png_ptr);
  if (info_ptr == nullptr) { error_code = 5; goto ERROR_PNG_write; }

  if (setjmp(png_jmpbuf(png_ptr))) { error_code = 6; goto ERROR_PNG_write; }

  png_init_io(png_ptr, file_descriptor);

  // Write header (8 bit colour depth)
  png_set_IHDR(png_ptr, info_ptr, m_width, m_height,
        8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
        PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);

  png_write_info(png_ptr, info_ptr);

  // Allocate memory for one row (3 bytes per pixel - RGB)
  row = (png_bytep) malloc(3 * m_width * sizeof(png_byte));

  for (int y = 0; y < m_height; ++y) {
    for (int x = 0; x < m_width; ++x) {
      setRGB(&(row[x * 3]), m_buffer[y * m_width + x]);
    }
    png_write_row(png_ptr, row);
  }

  png_write_end(png_ptr, nullptr);

  ERROR_PNG_write:
    if (error_code != 0) {
      m_error_code = error_code;
      ERR("Error while writing PNG file: %s, code %i", outpath, m_error_code);
    }
    if (file_descriptor != nullptr) fclose(file_descriptor);
    if (info_ptr != nullptr) png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
    if (png_ptr != nullptr) png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
    if (row != nullptr) free(row);
}
Beispiel #19
0
// hue is between 0 and 1024
void MIYbot::setColorByHue(int hue){
    int r;
    int g;
    int b;
    float h = ((float)hue)/1024;
    h2rgb(h, r, g, b);
    setRGB( r,  g,  b);
    Serial.print (h) ;
    Serial.print ("  ") ;
    Serial.print (r) ;
    Serial.print ("  ") ;
    Serial.print (g) ;
    Serial.print ("  ") ;
    Serial.print (b) ;
    Serial.println ("  ") ;

}
Beispiel #20
0
void mpxlcol_nb_change(FORM *form, CONTROL *control)
{
	//Speicherstelle lesen und Controls entsprechend setzen
	pointer = ((NUMBOX*)control)->value;

	memcpy(((TXTBOX*)form->controls[3])->text,colors.Name[pointer],20);
	((TRACKBAR*)form->controls[4])->actval = colors.color[pointer].Red;
	((TRACKBAR*)form->controls[5])->actval = colors.color[pointer].Green;
	((TRACKBAR*)form->controls[6])->actval = colors.color[pointer].Blue;
	
	control_draw(form->controls[3], 0);
	control_draw(form->controls[4], 0);
	control_draw(form->controls[5], 0);
	control_draw(form->controls[6], 0);
	
	setRGB(colors.color[pointer]);
}
Beispiel #21
0
	bool initWithString(const char *string, const char *fontPath,
		float fontHeight, float width, float height,
		cocos2d::TextHAlignment hAlignment, cocos2d::TextVAlignment vAlignment,
		float red, float green, float blue)
	{
		if (!cocos2d::LabelBMFont::initWithString("", fontPath))
			return false;

		m_fontHeight =
			((cocos2d::Label *)getChildren().front())->getCommonLineHeight();
		m_height = height;
		m_scale = fontHeight / m_fontHeight;
		m_vAlignment = vAlignment;
		setAlignment(hAlignment);
		setWidth(width / m_scale);
		setString(string);
		setRGB(red, green, blue);
		return true;
	}
void
LightHouseHardware::setLightState(MenloLightHouseEventArgs* args)
{
  bool onState;

  m_lightState = args->lightState;

  //
  // args->rampUpPeriod
  // args->rampDownPeriod
  //

  //
  // Set the light state. Polarity determines whether
  // TRUE == ON (m_polarity == TRUE) or OFF (m_polarity == FALSE)
  //
  if (m_lightState) {
      // ON
      onState = m_lightPolarity;
  }
  else {
      // OFF
      onState = !m_lightPolarity;
  }

  if (m_whitePin != (-1)) {
      digitalWrite(m_whitePin, onState);
  }

  // Handle RGB. Polarity determines whether true == ON or OFF
  if (m_rgbEnabled) {

      m_redIntensity = args->redIntensity;
      m_greenIntensity = args->greenIntensity;
      m_blueIntensity = args->blueIntensity;

      setRGB(onState);
  }

  return;
}
Beispiel #23
0
void Mirobot::ledHandler(){
  long t = millis();
  uint32_t newLEDColour;
#ifdef AVR
  digitalWrite(STATUS_LED_PIN, (!((t / 100) % 10) || !(((t / 100) - 2) % 10)));
#endif //AVR
#ifdef ESP8266
  if(next_led_pulse < t){
    next_led_pulse = t + 50;

    // On for 300ms every 2000 ms
    if(!((t % 2000) / 300)){
      newLEDColour = marcel.wifi.online ? 0x002200 : 0x000022;
    }else{
      newLEDColour = 0x000000;
    }
    if(newLEDColour != lastLEDColour){
      lastLEDColour = newLEDColour;
      setRGB(newLEDColour, STATUS_LED_PIN);
    }
  }
#endif //ESP8266
}
Beispiel #24
0
void CameraFeed::setRGB(int x,int y,int R,int G,int B) {
	setRGB(&data[getPos(x,y)],R,G,B);
}
Beispiel #25
0
void CameraFeed::setColor(int x,int y,Color &C) {
	setRGB(x,y,C.GetR(),C.GetG(),C.GetB());
}
Beispiel #26
0
void CameraFeed::setColor(BYTE *Data,Color &C) {
	setRGB(Data,C.GetR(),C.GetG(),C.GetB());
}
Beispiel #27
0
Colour::Colour(uint8_t r, uint8_t g, uint8_t b) {
	setRGB(r, g, b);
}
Beispiel #28
0
Colour::Colour() {
	setRGB(0, 0, 0);
}
Beispiel #29
0
void RGBLed::setRGB(float red, float green, float blue)
{
	setRGB(int(red * 255), int(green * 255), int(blue * 255));
}
Beispiel #30
0
void RGBLed::setHSV(float hue, float saturation, float value)
{
	Color result = hsvToRGB(hue, saturation, value);
	setRGB(result.r, result.g, result.b);
}