Exemplo n.º 1
0
/*
  Fade from off to given color and back.
 */
void pulse(int w) {
  uint32_t c;
  //uint32_t c = Wheel(map(opt, 0, 1023, 0, 255)); 
  for(uint16_t j = 8; j <= getOpt(_pin_lev, 0, 255); j++) {
    if( checkButton() ){ return; };
    setBrightness(j);
    c = Wheel(map(opt, 0, 1023, 0, 255));
    for(uint16_t i = 0; i < numPixels(); i++) {
      setPixelColor(i, c);
    }
    show();
    delay(w);
  }
  delay(w*10+50);
  for(uint16_t j=getOpt(_pin_lev, 0, 255); j>8; j--) {
    if( checkButton() ){ return; };
    setBrightness(j);
    c = Wheel(map(opt, 0, 1023, 0, 255));
    for(uint16_t i = 0; i < numPixels(); i++) {
      setPixelColor(i, c);
    }
    show();
    delay(w);
  }
  delay(w*10+50);
}
void LEDControl::detectPath()
{
    qDebug() << "detectPath called";

    // get the name of this hardware from the /etc/hw-release file
    QSettings hwFile("/etc/hw-release", QSettings::IniFormat);
    QString name = hwFile.value("NAME").toString();
    qDebug() << "Name detected from /etc/hw-release is: " << name;

    // Use the name from /etc/hw-release to look up the control file location in controlfile.conf
    QSettings controlFileSettings("/usr/share/harbour-hammerhead-torch/controlfile.conf",QSettings::IniFormat);

    // Difficult to replace /usr/share/ with a variable, because QStandardPaths doesn't support an option that resolves to /usr/share/<APPNAME> yet
    //qDebug() << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); //QStandardPaths::AppDataLocation and QStandardPaths::AppLocalDataLocation added in Qt 5.4

    if ( controlFileSettings.contains(name) ) {
        setDevice( name );
        setPath( controlFileSettings.value(name).toString() );
    } else {
        qDebug() << "Hardware not recognised";
        setDevice("Unknown");
        setPath("Unknown");
    }

    // Use the name from /etc/hw-release to look up the brightness in brightness.conf
    QSettings brightnessSettings("/usr/share/harbour-hammerhead-torch/brightness.conf",QSettings::IniFormat);

    if ( brightnessSettings.contains(name) ) {
        setBrightness( brightnessSettings.value(name).toString() );
    } else {
        setBrightness(QString::number(1));
    }

}
Exemplo n.º 3
0
    void onInit()
    {
        setBrightness(3, -16);
        videoSetMode(MODE_5_2D);
        videoSetModeSub(MODE_0_2D);

        vramSetBankA(VRAM_A_MAIN_BG);
        vramSetBankC(VRAM_C_SUB_BG);

        int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0, 0);

        dmaCopy(splashBitmap, bgGetGfxPtr(bg3), 256*256);
        dmaCopy(splashPal, BG_PALETTE, 256*2);

        for(int i = 0; i < 128; i++)
        {
            setBrightness(3, -16+(i/8));
            swiWaitForVBlank();
        }
        for(int i = 0; i < 128; i++)
        {
            setBrightness(3, -(i/8));
            swiWaitForVBlank();
        }
    }
Exemplo n.º 4
0
void Brightness::dim()
{
    if(m_dimOff) setBrightness(0);
    else setBrightness(DIM_LEVEL);
    m_dimmed = true;
    // Speed up the updater a little
    m_mouseUpdate.start(500);
}
// Breath a color, for a total breathe time of...
void breathe(struct WS2812B_Strip *strip, uint32_t color, const uint32_t breathCycleTime)
{
  uint8_t oldBrightness = strip->brightness;
  uint16_t pixelIndex;
  uint8_t j;

  clear(strip);
  show(strip);

  for (pixelIndex = 0; pixelIndex < strip->numberOfPixels; pixelIndex++)
  {
    setPixelColor(strip, pixelIndex, color);
  }

  // Breathe in.
  for(j = 1; j < 255; j++)
  {
	if (strip->breakFromPattern == true)
	{
	  return;
	}

	setBrightness(strip, j);
    show(strip);
	delay_ms(breathCycleTime/512);
  }

  // pause in.
  delay_ms(breathCycleTime/16);

  // Breathe out.
  for(j = 255; j > 0; j--)
  {
	if (strip->breakFromPattern == true)
	{
	  return;
	}

    setBrightness(strip, j);
    show(strip);
	delay_ms(breathCycleTime/512);
  }

  // pause out.
  delay_ms(breathCycleTime/16);

  strip->brightness = oldBrightness;
  return;
}
void S60CameraImageProcessingControl::setProcessingParameter(
    QCameraImageProcessingControl::ProcessingParameter parameter, QVariant value)
{
    switch (parameter) {
        case QCameraImageProcessingControl::Contrast:
            setContrast(value.toInt());
            break;
        case QCameraImageProcessingControl::Saturation:
            setSaturation(value.toInt());
            break;
        case QCameraImageProcessingControl::Brightness:
            setBrightness(value.toInt());
            break;
        case QCameraImageProcessingControl::Sharpening:
            if (isSharpeningSupported())
                setSharpeningLevel(value.toInt());
            break;
        case QCameraImageProcessingControl::Denoising:
            if (isDenoisingSupported())
                setDenoisingLevel(value.toInt());
            break;
        case QCameraImageProcessingControl::ColorTemperature:
            setManualWhiteBalance(value.toInt());
            break;

        default:
            break;
    }
}
Exemplo n.º 7
0
void OSD::hw_init() {
    max7456_on();

    //read black level register
    byte osdbl_r = MAX_read(MAX7456_OSDBL_reg_read);//black level read register

    MAX_write(MAX7456_VM0_reg, MAX7456_RESET | video_mode);
    delay_150();

    //set black level
    MAX_write(MAX7456_OSDBL_reg, (osdbl_r & 0xef)); //black level write register - Set bit 4 to zero 11101111 - Enable automatic OSD black level control

// set position - may be EEPROM.read(OSD_SHIFT_X)
    MAX_write(MAX7456_HOS_reg, 0x20); // 0x20 default
    MAX_write(MAX7456_VOS_reg, 0x10); // 0x10 default


    MAX_write(MAX7456_OSDM_reg, 0b00010010); // 0x00011011 default

    setBrightness();

    // define sync (auto,int,ext)
//      MAX_write(MAX7456_VM0_reg, MAX7456_DISABLE_display | video_mode);
    MAX_write(MAX7456_VM0_reg, (MAX7456_ENABLE_display_vert | video_mode) | MAX7456_SYNC_internal);

    delay_150();

    MAX_write(MAX7456_VM0_reg, (MAX7456_ENABLE_display_vert | video_mode) | MAX7456_SYNC_autosync);

    max7456_off();

}
Exemplo n.º 8
0
Matrix::Matrix(uint8_t data, uint8_t clock, uint8_t load, uint8_t screens /* = 1 */)
{
  // record pins for sw spi
  _pinData = data;
  _pinClock = clock;
  _pinLoad = load;

  // set ddr for sw spi pins
  pinMode(_pinClock, OUTPUT);
  pinMode(_pinData, OUTPUT);
  pinMode(_pinLoad, OUTPUT);

  // allocate screenbuffers
  _screens = screens;
  _buffer = (uint8_t*)calloc(_screens, 64);
  _maximumX = (_screens * 8);

  // initialize registers
  clear();             // clear display
  setScanLimit(0x07);  // use all rows/digits
  setBrightness(0x0F); // maximum brightness
  setRegister(REG_SHUTDOWN, 0x01);    // normal operation
  setRegister(REG_DECODEMODE, 0x00);  // pixels not integers
  setRegister(REG_DISPLAYTEST, 0x00); // not in test mode
}
Exemplo n.º 9
0
      //! Initialize resources.
      void
      onResourceInitialization(void)
      {
        if (!getConstantParameters())
          throw RestartNeeded(DTR("failed to get constant parameters"), c_restart_delay);

        setConfig();

        std::map<std::string, LED*>::iterator itr = m_led_by_name.begin();
        for (unsigned i = 0; i < c_led_count; ++i)
          setBrightness(itr->second, 0);

        if (!m_args.led_patterns.empty())
        {
          uint8_t count = m_args.led_patterns.size();

          UCTK::Frame frame;
          frame.setId(PKT_ID_LED_PATTERN);
          frame.setPayloadSize(1 + (count * 2));
          frame.set(count, 0);
          for (size_t i = 0; i < count; ++i)
            frame.set<uint16_t>(m_args.led_patterns[i], 1 + i * 2);
          if (!m_ctl->sendFrame(frame))
            throw RestartNeeded(DTR("failed to set LED patterns"), c_restart_delay);
        }

        m_wdog.reset();
        setEntityState(IMC::EntityState::ESTA_NORMAL, Status::CODE_ACTIVE);
      }
Exemplo n.º 10
0
//Rainbow Program
void rainbowSingle() {
  setBrightness();
  //int wait = getOpt(_pin_opt, -20, 20);
  uint16_t i, j;
  for(j = 0; j < 256; j++) {

    // calculate wait based on volatile opt from interrupt
    int wait = (int) map(opt, 0, 1023, -100, 100);
    if( wait < 0 ) {
      // negative values make a huge apparent difference, so fake a larger spread
      // by having -100 to 100 instead of -20 to 100
      wait = floor( wait / 5 );
    }
    // kind of a hack to allow negative wait value to speed rainbow by
    // skipping colors, otherwise 0 would be fast as chip could process
    if(wait < 0 &&  j % ( -1 * wait ) != 0){
      continue; 
    }

    if( checkButton() ){ return; };
    for(i=0; i < numPixels(); i++) {
      setPixelColor(i, Wheel(j));
    }
    show();

    if(wait > 0){
      delay(wait);
    }

  }
}
/*
 * Called on device start
 */
void LcdController::setup()
{
    // Setup LCD
    serial = new QSerialPort(this);
    serial->setPortName(portName);

    status = serial->open(QIODevice::WriteOnly);

    if(status)
    {
        serial->setBaudRate(QSerialPort::Baud9600,QSerialPort::AllDirections);
        serial->setDataBits(QSerialPort::Data8);
        serial->setStopBits(QSerialPort::OneStop);
        serial->setFlowControl(QSerialPort::NoFLowControl);
        serial->setParity(QSerialPort::NoParity);

        // Set 16 Characters Wide
        serial->putChar(LCD_COMMAND);
        serial->putChar(4);

        // Set 2 Lines
        serial->putChar(LCD_COMMAND);
        serial->putChar(6);

        clearScreen();
    }

    // Setup brightness
    setBrightness(30);
}
Exemplo n.º 12
0
        void SettingsMenu::doSave()
        {
            auto settings = Game::getInstance()->settings();
            settings->setCombatDifficulty(((UI::MultistateImageButton*)getUI("combat_difficulty"))->state());
            settings->setGameDifficulty(((UI::MultistateImageButton*)getUI("game_difficulty"))->state());
            settings->setViolenceLevel(((UI::MultistateImageButton*)getUI("violence_level"))->state());
            settings->setTargetHighlight(((UI::MultistateImageButton*)getUI("target_highlight"))->state());
            settings->setCombatLooks(((UI::MultistateImageButton*)getUI("combat_looks"))->state());
            settings->setCombatMessages(((UI::MultistateImageButton*)getUI("combat_messages"))->state());
            settings->setCombatTaunts(((UI::MultistateImageButton*)getUI("combat_taunts"))->state());
            settings->setLanguageFilter(((UI::MultistateImageButton*)getUI("language_filter"))->state());
            settings->setRunning(((UI::MultistateImageButton*)getUI("running"))->state());
            settings->setSubtitles(((UI::MultistateImageButton*)getUI("subtitles"))->state());
            settings->setItemHighlight(((UI::MultistateImageButton*)getUI("item_highlight"))->state());

            settings->setMasterVolume(((UI::Slider*)getUI("master_volume"))->value());
            settings->setMusicVolume(((UI::Slider*)getUI("music_volume"))->value());
            settings->setVoiceVolume(((UI::Slider*)getUI("voice_volume"))->value());
            settings->setSfxVolume(((UI::Slider*)getUI("sfx_volume"))->value());

            settings->setTextDelay(((UI::Slider*)getUI("text_delay"))->value());
            settings->setCombatSpeed(((UI::Slider*)getUI("combat_speed"))->value());
            settings->setBrightness(((UI::Slider*)getUI("brightness"))->value());
            settings->setMouseSensitivity(((UI::Slider*)getUI("mouse_sensitivity"))->value());

            settings->setPlayerSpeedup(((UI::ImageButton*)getUI("player_speedup"))->checked());

            settings->save();
            Game::getInstance()->popState();
        }
Exemplo n.º 13
0
void Graphics::fadein(int duration)
{
	FBO::unbind();

	float curr = p->brightness;
	float diff = 255.0f - curr;

	for (int i = 1; i <= duration; ++i)
	{
		setBrightness(curr + (diff / duration) * i);

		if (p->frozen)
		{
			GLMeta::blitBeginScreen(p->scSize);
			GLMeta::blitSource(p->frozenScene);

			FBO::clear();
			p->metaBlitBufferFlippedScaled();

			GLMeta::blitEnd();

			p->swapGLBuffer();
		}
		else
		{
			update();
		}
	}
}
Exemplo n.º 14
0
 YarpManager::YarpManager():
 m_acuity(0),
 m_brightness(0),
 m_fov(0),
 m_threshold(0)
 {
     std::cout<<"## YarpManager Initialisation ##"<<std::endl;
     std::cout<<"- Setting default parameters value"<<std::endl;
     setAcuity(3);
     setFov(100);
     setBrightness(50);
     setTreshold(150);
     
     std::cout<<"- Setting up YARP network"<<std::endl;
     yarp::os::Network::init();
     std::cout<<"- Opening YARP port"<<std::endl;
     std::cout<<"    * /target/module"<<std::endl;
     m_modulePort.open("/target/module");
     m_modulePort.setStrict();
     m_modulePort.useCallback(*this);
     
     std::cout<<"    * /target/parameter"<<std::endl;
     m_parameterPort.open("/target/parameter");
     m_parameterPort.setStrict();
     m_parameterPort.useCallback(*this);
 }
Exemplo n.º 15
0
void LevelState::Init()
{
	setBrightness(2, 0);
    //Création du worldmanager
	worldMan = new WorldManagerOffline();
	worldMan->Init();
}
Exemplo n.º 16
0
int main(int argc, char *argv[])
{
	int mFd = open("/dev/fb0", O_RDWR);
	if (!strcmp(argv[1], "contrast")) {
		setContrast(mFd, atoi(argv[2]));
		printf("please enter a number (0 ~ 100)\n");
	}

	if (!strcmp(argv[1], "brightness")) {
		setBrightness(mFd, atoi(argv[2]));
		printf("please enter a number (0 ~ 100)\n");
	}

	if (!strcmp(argv[1], "hue")) {
		setHue(mFd, atoi(argv[2]));
		printf("please enter a number (0 ~ 100)\n");
	}

	if (!strcmp(argv[1], "saturation")) {
		setSaturation(mFd, atoi(argv[2]));
		printf("please enter a number (0 ~ 100)\n");
	}

	if (!strcmp(argv[1], "gamma")) {
		setGamma(mFd, atoi(argv[2]));
		printf("please enter a number (0 ~ 100)\n");
	}

	if (!strcmp(argv[1], "vee")) {
		setVee(mFd, atoi(argv[2]));
		printf("please enter a number (0 ~ 100)\n");
	}

	return 0;
}
Exemplo n.º 17
0
void Dispositif::parseMessage(String code)
{
  if(orderZone)
  {
    //Serial.println(code);
    //int temp = code.toInt();
    // we check we are in the good zone, if it's true, the next part can be read
    if(code == zone)
    {
      zoneMatch = true;
    }
    else
    {
      zoneMatch = false;
    }
    orderZone = false; 
  }
  else
  { 
    orderZone = true;
    // if we are in the right zone, we can update the brightness
    if(zoneMatch)
    {
       //int p = code.toInt();  // Code is a string
       setBrightness(0, code.toInt());
    }
  }
}
Exemplo n.º 18
0
void airbear::hatch(){
  Serial.begin(115200);
  memoryStatus();
  delay(5000);

  while(!vs1053.begin()){

  }

  SD.begin(CARDCS);    // initialise the SD card
  vs1053.setVolume(5,5);  // Set volume for left, right channels. lower numbers == louder volume!
  vs1053.useInterrupt(DREQ);  // DREQ int
  vs1053.playFullFile("Sounds/orbstart.mp3");



  neopixelbegin();
  setBrightness(MatrixBrightness);

  pinMode(heartpin,INPUT);
  pinMode(circlepin,INPUT);
  pinMode(crosspin,INPUT);
  pinMode(squarepin,INPUT);
  connection();

  tail4 = PositionRandomizer(random(7));
  tail3 = PositionRandomizer(tail4);
  tail2 = PositionRandomizer(tail3);
  tail1 = PositionRandomizer(tail2);
  head = PositionRandomizer(tail1);
  memoryStatus();
}
Exemplo n.º 19
0
/*
|| @constructor
|| | Initializes the digital pins and the Max7219
|| #
|| 
|| @parameter data    The data pin connected to the Max7219
|| @parameter clock   The clock pin connected to the Max7219
|| @parameter load    The load pin connected to the Max7219
|| @parameter screens The number of screens
*/
Matrix::Matrix(byte data, byte clock, byte load, byte screens /* = 1 */)
{
  // record pins for sw spi
  dataPin = data;
  clockPin = clock;
  loadPin = load;

  // set ddr for sw spi pins
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(loadPin, OUTPUT);

  // allocate screenbuffers
  numberOfScreens = numberOfScreens;
  buf = (byte*)calloc(numberOfScreens, 64);
  maximumX = (numberOfScreens * 8);

  // initialize registers
  clear();             // clear display
  setScanLimit(0x07);  // use all rows/digits
  setBrightness(0x0F); // maximum brightness
  setRegister(REG_SHUTDOWN, 0x01);    // normal operation
  setRegister(REG_DECODEMODE, 0x00);  // pixels not integers
  setRegister(REG_DISPLAYTEST, 0x00); // not in test mode
}
Exemplo n.º 20
0
void OSD::init()
{
  pinMode(MAX7456_SELECT,OUTPUT);
  pinMode(MAX7456_VSYNC, INPUT);
  digitalWrite(MAX7456_VSYNC,HIGH); //enabling pull-up resistor

  detectMode();

  digitalWrite(MAX7456_SELECT,LOW);
  //read black level register
  Spi.transfer(MAX7456_OSDBL_reg_read);//black level read register
  byte osdbl_r = Spi.transfer(0xff);
  Spi.transfer(MAX7456_VM0_reg);
  Spi.transfer(MAX7456_RESET | video_mode);
  delay(50);
  //set black level
  byte osdbl_w = (osdbl_r & 0xef); //Set bit 4 to zero 11101111
  Spi.transfer(MAX7456_OSDBL_reg); //black level write register
  Spi.transfer(osdbl_w);

  setBrightness();
  // define sync (auto,int,ext) and
  // making sure the Max7456 is enabled
  control(1);
}
Exemplo n.º 21
0
void ChangeMode(ModeType mode)
{
	//dim screen
	if (Mode::sCurrentMode != NULL)
	{
		for (s32 b = 0; b >= -16; --b)
		{
			setBrightness(1, b);
			swiWaitForVBlank();
		}
	}
	else
	{
		setBrightness(1, -16);
	}
	
	TextManager::Bottom().Clear();
	TextManager::Top().Clear();
	
	//must reset clock before calling constructors
	//otherwise bad things happen with sprites
	GameClock::Clock().Reset();
	
	if (Mode::sCurrentMode != NULL)
		delete Mode::sCurrentMode;
	
	switch (mode)
	{
		case MODE_PLAYER:
			Mode::sCurrentMode = new Player();
			break;
		case MODE_SONGSELECT:
			Mode::sCurrentMode = new SongSelect();
			break;
	}
	
	swiWaitForVBlank();
	Mode::CurrentMode().Update();
	glFlush(1);
	
	//return screen to full brightness
	for (s32 b = -16; b <= 0; ++b)
	{
		setBrightness(1, b);
		swiWaitForVBlank();
	}
}
Exemplo n.º 22
0
//--------------------------------------------------------------
void ofApp::update(){

    
    fbo.begin();
    mClient.draw(0, 0);
    fbo.end();
    
    fbo.readToPixels(pixels);
    
    fboTour.begin();
    tClient.draw(0, 0);
    fboTour.end();
    
    fboTour.readToPixels(pixTour);
    
    while(receiver.hasWaitingMessages()){
        // get the next message
        ofxOscMessage m;
        receiver.getNextMessage(m);
        
        if(m.getAddress() == "/b"){
            //ofLog() << "b" << m.getArgAsInt32(0);
            for (int i=0; i<3; i++){
                setBrightness(i, m.getArgAsInt32(0));
            }
        }
        else if(m.getAddress() == "/t"){
            //ofLog() << "t" << m.getArgAsInt32(0);
            setBrightness(3, m.getArgAsInt32(0));
        }
        else if(m.getAddress() == "/d"){
            for (int i=0; i<3; i++){
                setDither(i, m.getArgAsInt32(0));
            }
            //ofLog() << "d" << m.getArgAsInt32(0);
        }
        else if(m.getAddress() == "/dt"){
            setDither(3, m.getArgAsInt32(0));
            //ofLog() << "d" << m.getArgAsInt32(0);
        }
    }
  
    for (int i=0; i<4; i++) {
    sendLine(i);
    }
    
}
Exemplo n.º 23
0
void ExtendedRotary::subCounter()
{
    if(count > COUNT_MIN )
    {
        count--;
    }
    setBrightness();
}
Exemplo n.º 24
0
void ExtendedRotary::addCounter()
{
    if( count < COUNT_MAX)
    {
        count++;
    }
    setBrightness();
}
Exemplo n.º 25
0
void BCGFilter::filterImage()
{
    setGamma(d->settings.gamma);
    setBrightness(d->settings.brightness);
    setContrast(d->settings.contrast);
    applyBCG(m_orgImage);
    m_destImage = m_orgImage;
}
Exemplo n.º 26
0
      void
      consume(const IMC::SetLedBrightness* msg)
      {
        std::map<std::string, LED*>::iterator itr = m_led_by_name.find(msg->name);
        if (itr == m_led_by_name.end())
          return;

        setBrightness(itr->second, msg->value);
      }
Exemplo n.º 27
0
void Brightness::on_ui_brightness_valueChanged(int i)
{
    if(i<15) i=15; // dont let the user turn the screen completely off
    if(i<DIM_LEVEL) m_dimmer.stop();
    setBrightness(i);
    m_settings.setValue(BRIGHTNESS_KEY, i);
    m_settings.sync();
    m_brightness = i;
}
Exemplo n.º 28
0
 void Light::_rising() {
   if(_shouldBeRising()) {
     setBrightness(_risingValue(), false); // don't stop everything
   }
   else {
     _on_timer.restart();
     _state = _MAX;
   }
 }
Exemplo n.º 29
0
 void Light::_falling() {
   if(_shouldBeFalling()) {
     setBrightness(_fallingValue(), false); // don't stop everything
   }
   else {
     _off_timer.restart();
     _state = _MIN;
   }
 }
Exemplo n.º 30
0
static
void
handle_client(int client_socket) {
	uint8_t cmd;

	double bright;

	pos_t pos;
	col_t col;

	col_t pixels[64];
	
	int x, y;

	while (true) {
		recv_or_return(client_socket, &cmd, sizeof(char), 0);

		switch (cmd) {
			case UNICORND_CMD_SET_BRIGHTNESS:

				recv_or_return(client_socket, &bright, sizeof(double), 0);

				setBrightness(bright);
				break;

			case UNICORND_CMD_SET_PIXEL:

				recv_or_return(client_socket, &pos, sizeof(pos_t), 0);
				recv_or_return(client_socket, &col, sizeof(col_t), 0);

				setPixelColor(get_pixel_pos(pos.x, pos.y), col.r, col.g, col.b);
				break;

			case UNICORND_CMD_SET_ALL_PIXELS:
				recv_or_return(client_socket, &pixels, 64 * sizeof(col_t), 0);

				for (x = 0; x < 8; x++) {
					for (y = 0; y < 8; y++) {
						col_t *col = &pixels[x * 8 + y];
						setPixelColor(get_pixel_pos(x, y), col->r, col->g, col->b);
					}
				}

				break;

			case UNICORND_CMD_SHOW:

				show();
				break;

			default:

				close(client_socket);
				return;
		}
	}
}