Exemple #1
0
int main(int argc, char *argv[])
{
  if ( argc != 2 ) /* argc should be 2 for correct execution */
  {
    /* We print argv[0] assuming it is the program name */
    printf( "usage: %s red|green|bell|various\n", argv[0] );
  }
  else 
  {
    int ret = load_device();
    if(ret == 1)
      lamp_shutdown();
    return 1;
    char* argument = argv[1];
    if(strcmp(argument, "green") == 0){
      set_green();
    } else if (strcmp(argument, "red") == 0){
      red_with_no_bell();
    } else if (strcmp(argument, "off") == 0){
      set_lights_off();
    } else if (strcmp(argument, "various") == 0){
      set_colors_with_bell();
    } else if (strcmp(argument, "bell") == 0){
      only_bell_on();
    }
  }
  lamp_shutdown();
  return 0;
}
Exemple #2
0
void set_color(SDL_Surface *surface, int x, int y, SDL_Color color)
{
	set_red(surface, x, y, color.r);
	set_green(surface, x, y, color.g);
	set_blue(surface, x, y, color.g);
	set_alpha(surface, x, y, color.a);
}
Exemple #3
0
 std::unique_ptr<ElVis::Serialization::Color> Color::Serialize() const
 {
   auto pResult = std::unique_ptr<ElVis::Serialization::Color>(new ElVis::Serialization::Color());
   pResult->set_red(m_red);
   pResult->set_green(m_green);
   pResult->set_blue(m_blue);
   pResult->set_alpha(m_alpha);
   return pResult;
 }
Exemple #4
0
void init() {
	LED_1_DDR |= (1 << LED_1_PINNUM);
	LED_1_PORT |= (1 << LED_1_PINNUM);
	LED_2_DDR |= (1 << LED_2_PINNUM);
	LED_2_PORT |= (1 << LED_2_PINNUM);
	LED_3_DDR |= (1 << LED_3_PINNUM);
	LED_3_PORT |= (1 << LED_3_PINNUM);

	/* Turn on PLL - 48 MHz; send 48 MHz to counter and USB */
	PLLFRQ =  (1 << PLLTM0) | (1 << PDIV2);
	PLLCSR = (1 << PINDIV);
	PLLCSR = (1 << PINDIV) | (1 << PLLE);
	while (!(PLLCSR & (1 << PLOCK)));

	/* Set up timer 1 for diode PWM */
	LASER_R_DDR |= (1 << LASER_R_PINNUM);
	LASER_G_DDR |= (1 << LASER_G_PINNUM);
	LASER_B_DDR |= (1 << LASER_B_PINNUM);
	LASER_R_PORT |= (1 << LASER_R_PINNUM);
	LASER_G_PORT |= (1 << LASER_G_PINNUM);
	LASER_B_PORT |= (1 << LASER_B_PINNUM);
	_delay_ms(1);
	set_red(0);
	set_green(0);
	set_blue(0);
	TCCR1A = (1 << COM1A1) | (1 << COM1B1) | (1 << COM1C1) | (1 << WGM10);
	TCCR1B = (1 << WGM12) | (1 << CS10);

	/* Set up timers 0 and 3 for motor PWM */
	TCCR0A = (1 << COM0B1) | (1 << WGM01) | (1 << WGM00);
	TCCR0B = (1 << CS00);
	TCCR3A = (1 << COM3A1) | (1 << WGM30);
	TCCR3B = (1 << WGM32) | (1 << CS30);
	M1_DDR |= (1 << M1_PINNUM);
	M2_DDR |= (1 << M2_PINNUM);

	/* Set up timer 4 for TEC PWM at 94 kHz */
	/* Low-order bits are falling edge, high-order are rising edge */
	DT4 = 4 | (7 << 4);
	TCCR4A = 0;
	TCCR4C = (1 << COM4D0) | (1 << PWM4D);
	TCCR4D = 0;
	TCCR4E = (1 << ENHC4);
	TC4H = 1;
	OCR4C = 0xFF;
	TC4H = 3;
	OCR4D = 0xE0;
	TEC_PWM_DDR |= TEC_PWM_MASK;
	TEC_FIXED_DDR |= TEC_FIXED_MASK;
	TEC_FIXED_PORT &= ~TEC_FIXED_UP;
	TEC_FIXED_PORT |= TEC_FIXED_DOWN;
	TCCR4B = (1 << CS40);

	LED_1_DDR |= (1 << LED_1_PINNUM);
	LED_1_PORT |= (1 << LED_1_PINNUM);
}
Exemple #5
0
void bmp_image::plot_with_brightness(int x, int y, rgba_color_t color, double brightness) {
    if ( brightness < 0.0 ) {
        brightness = 0.0;
    }
    if ( brightness > 1.0 ) {
        brightness = 1.0;
    }

    brightness = 1.0 - brightness;   

    color = set_red(color,      std::min(255, round_half_up( 255. * brightness + get_red(color) )) );
    color = set_green(color,    std::min(255, round_half_up( 255. * brightness + get_green(color) )) );
    color = set_blue(color,     std::min(255, round_half_up( 255. * brightness + get_blue(color) )) );

    pixels.set_if_inbounds(x, y, color);
}
Exemple #6
0
void test_colors() {
  printf("testing colors\n");
  int r = 25;
  int g = 225;
  int b = 200;
  int a = 255;
  color c = get_color(r,g,b,a);
  assert(c == 0x19E1C8FF);
  assert(get_red(c) == r);
  assert(get_green(c) == g);
  assert(get_blue(c) == b);
  assert(get_alpha(c) == a);
  assert(set_red(c,0xAA) == 0xAAE1C8FF);
  assert(set_green(c,0xAA) == 0x19AAC8FF);
  assert(set_blue(c,0xAA) == 0x19E1AAFF);
  assert(set_alpha(c,0xAA) == 0x19E1C8AA);
}
Exemple #7
0
/* Change la couleur utilisee pour les traces */
void ChangerCouleur(int couleur) {
   switch (couleur) {
      case Rouge :
         set_red(fenetreCourante); 
         break;
      case Bleu :
         set_blue(fenetreCourante); 
         break;
      case Vert:
         set_green(fenetreCourante); 
         break;
      case Jaune:
         set_yellow(fenetreCourante); 
         break;
      case Blanc:
         set_white(fenetreCourante);
         break;
      default:
         set_black(fenetreCourante); 
         break;      
   }
}
Exemple #8
0
void FixtureRGB::set_rgb(uint8_t r, uint8_t g, uint8_t b)
{
    set_red(r);
    set_green(g);
    set_blue(b);
}