void PowerPageComponent::buttonClicked(Button *button) {
  if (button == backButton) {
    getMainStack().popPage(PageStackComponent::kTransitionTranslateHorizontalLeft);
  } else if (button == powerOffButton) {
    showPowerSpinner();
    child.start("systemctl poweroff");
  } else if (button == rebootButton) {
    showPowerSpinner();
    child.start("systemctl reboot");
  } else if (button == sleepButton) {
    setSleep();
  } else if (button == felButton) {
    getMainStack().pushPage(felPage, PageStackComponent::kTransitionTranslateHorizontalLeft);
  } else if(button == updateButton){
    updateWindow->setVisible(true);
    resized();
    //Downloading rev number information
    StringArray cmd{"wget", "-O", "version", 
                    "https://drive.google.com/uc?export=download&id=0B1jRc4IqT9kiNC12WVpoUUtCRUE"};
    ChildProcess download;
    bool ok = download.start(cmd, ChildProcess::StreamFlags::wantStdErr);
    if(!ok) printf("Process not launched\n");
    else printf("Process launched !\n");
    String output = download.readAllProcessOutput();
    updateWindow->setMessage("Download successful !");
  }
}
Exemplo n.º 2
0
int main(){
	// setup functions
	pwmSetup();
	adcSetup();
	ADC::Sync_result result;

	// begin I2C, slave address 0x01
	// register event on receive
	Wire.begin(I2CADDR);
	Wire.onReceive(rxEvent);

	//Serial.begin(9600);

	while(1){
		// read the adc
		result = adc->readSynchronizedContinuous();
		adc1Val = (uint16_t)result.result_adc0;
		adc2Val = (uint16_t)result.result_adc1;

		// update outputs
		setSleep(SLPA, SLPB, sleepFlag);
		setDirection(DIRA, dirAflag);
		setDirection(DIRB, dirBflag);
		setPWM(PWMA, pwmAval);
		setPWM(PWMB, pwmBval);
	}
}
Exemplo n.º 3
0
void faceThread::run()
{
    static int eyeFlag = 0;
    static float scale = 0.5;
    while(true)
    {
        if(runFlag)
        {
            switch (MODE)
            {
                case SLEEP_MODE:
                    setSleep();
                    break;
                case SMILE_MODE:
                    setSmile();
                    break;
                case ANGER_MODE:
                    setAnger();
                    break;
                case TRACK_MODE:
                    setTrack();
                    scale = 1;
                    break;
                default:
                    break;
            }
            if( eyeFlag == 0 )
            {
                scale -= CHANGE_SPEED;
                if(scale <= LOWBOUND)
                {
                    eyeFlag = 1;
                }
            }
            else
            {
                scale += CHANGE_SPEED;
                if(scale >= UPBOUND)
                {
                    eyeFlag = 0;
                    if(UPBOUND > 0.8)
                    {
                        scale = 0.8;
                    }
                    else
                    {
                        scale = UPBOUND;
                    }

                }
            }
            facesketch->reset();
            facesketch->setEyeScale(scale);
            facesketch->sketchWholeFace();
            setRunFlag(false);
            emit resultReady();
        }

    }
}
Exemplo n.º 4
0
void ST7735::init()
{
	reset();
	setSleep(false);
	setInverse(false);
	setIdle(false);
	on();
}
Exemplo n.º 5
0
faceThread::faceThread(QObject *parent) :
    QThread(parent)
{
    facesketch = new faceSketch();
    runFlag = 1;
    CHANGE_SPEED = 0.1;
    UPBOUND = 1;
    LOWBOUND = -1;
    timer = new QTimer();
    connect(timer,SIGNAL(timeout()),this,SLOT(setRun()));
    timer->start(100);
    setSleep();
}
Exemplo n.º 6
0
Player :: Player(Dungeon *pp, int r, int c)
: Actor (pp, r, c)
{
    max_health = 20;
    setHealth(20);
    setDexterity(2);
    setSleep(0);
    setArmor(2);
    setStrength(2);
    
    equiped = new ShortSword(r,c);
    Inventory.push_back(equiped);
    
}
Exemplo n.º 7
0
void Player::move(char c){
    
    //heal the player
    if(trueWithProbability(.1)){
        if( health() < max_health)
            setHealth(health()+1);
    }
    
    //check if the player is asleep
    if( asleep() < 1){
    
        
        switch (c) {
            case 'h':
                //if there is a monster above the player attack it
                if(checkForMonster("UP"))
                    attack(dungeon()->returnMonster(row(), col()-1));
                
                //if the next space is something the player can move onto(empty space or item) then move
                else if(dungeon()->gameGrid[row()][col()-1] == ' '|| dungeon()->gameGrid[row()][col()-1] == '>' || dungeon()->gameGrid[row()][col()-1] == '&')
                    setCol(col()-1);
                break;
                
            case 'l':
                //if there is a monster below the player attack it
                if(checkForMonster("DOWN"))
                    attack(dungeon()->returnMonster(row(), col()+1));
                
                else if(dungeon()->gameGrid[row()][col()+1] == ' ' || dungeon()->gameGrid[row()][col()+1] == '>'|| dungeon()->gameGrid[row()][col()-1] == '&')
                    setCol(col()+1);
                break;
                
            case 'k':
                //if there is a monster to the left of the player attack it
                if(checkForMonster("LEFT"))
                    attack(dungeon()->returnMonster(row()-1, col()));
                
                else if(dungeon()->gameGrid[row()-1][col()] == ' '|| dungeon()->gameGrid[row()-1][col()] == '>'|| dungeon()->gameGrid[row()][col()-1] == '&')
                    setRow(row()-1);
                break;
                
            case 'j':
                //if there is a monster to the right of the player attack it
                if(checkForMonster("RIGHT"))
                    attack(dungeon()->returnMonster(row()+1, col()));
                
                else if(dungeon()->gameGrid[row()+1][col()] == ' '|| dungeon()->gameGrid[row()+1][col()] == '>'|| dungeon()->gameGrid[row()][col()-1] == '&')
                    setRow(row() +1);
                break;
                
            default:
                break;
        
        }
    }
    else{
        //if the player is asleep then each move reduce his sleepTime by 1 point
        setSleep(asleep()-1);
        dungeon()->action_vector.push_back("Player is asleep");
    }
}