コード例 #1
0
ファイル: uiViewInit.c プロジェクト: elmux/yacm
/**
 * run action of init view
 */
static void run(void) {
    char initMessage[40] = "Initializing";
    if (isTimerElapsed(initTimer)) {

        /* set new timer */
        initTimer = setUpTimer(RUN_INTERVAL);
        if (intervals < 25) {
            intervals++;
        }
        for (int i = 1; i < intervals; i++) {
            strcat(initMessage,".");
        }
        DisplayState *displaystate = getDisplayState();

        /* Select fonts */
        displaystate->font = GrCreateFont((unsigned char *) FONTNAME, 14, NULL);
        GrSetGCFont(displaystate->gContextID, displaystate->font);
        GrText(displaystate->gWinID, displaystate->gContextID, 120, 30, initMessage, -1, GR_TFASCII | GR_TFTOP);
        GrDestroyFont(displaystate->font);
    }
    /* Did someone turn the coffeemaker off? */
    if (getSwitchState(POWER_SWITCH) == switch_off) {
#ifdef DEBUG
        printf("Detected power switch to off\n");
#endif
        switchOff();
    }
}
コード例 #2
0
int EventHub::getSwitchState(int sw) const
{
#ifdef EV_SW
    if (sw >= 0 && sw <= SW_MAX) {
        int32_t devid = mSwitches[sw];
        if (devid != 0) {
            return getSwitchState(devid, sw);
        }
    }
#endif
    return -1;
}
コード例 #3
0
ファイル: SimpleSwitch.cpp プロジェクト: Gleeno/DomAlgo
Json::Value SimpleSwitch::getDataSensor() {
    Json::Value data;
    data["sensor"] = Sensor::getDataSensor();
    data["sensor"]["spec"]["switchState"] =  std::to_string(getSwitchState());
    return data;
}
コード例 #4
0
int debounce1() { //PTA1
	static uint16_t state = 0;  //holds present state
	state = (state << 1) | (!getSwitchState(1)) | 0xE000;
	if (state == 0xF000) return 1;
	return 0;
}
コード例 #5
0
int getPumpState()
{
	return getSwitchState(pumpSwitch);
}
コード例 #6
0
int getHeaterState()
{
	return getSwitchState(heaterSwitch);
}
コード例 #7
0
ファイル: main.c プロジェクト: ptueller/Embedded-MCU-Projects
int main(void)
{
	int counter = 0;
	
	
	int delay=1000000; //Set the initial delay to 1 second
	int LEDIndex;
	int winVal;
	//Initialize all the modules
	LEDInit();
	dipInit();
	switchInit();
	rngInit();
	timerInit();
	
	for(;;) {
		clearAll();
		LEDIndex=0;
		winVal=getRandom(); //Get a random value to be the winning value for this round
		LEDPutVal(winVal,1); //Display that winning value
		timerDelay(delay);
		if(!getDipState()) { //Random Game
			while(!getSwitchState(0)) { //While the button is not pressed
				clearAll();
				LEDIndex=getRandom();
				LEDPutVal(LEDIndex,1);
				timerDelay(delay);
			}
		}
		else { //Sequence Game
			while(!getSwitchState(0)) { //While the button is not pressed
				clearAll();
				LEDPutVal(LEDIndex++,1); //Increment the LED index so that it displays sequentially
				LEDIndex %= 4; //Keep the LED index within our domain
				timerDelay(delay);
			}
			//The following conditional statement is needed to bring the index back to the value that was clicked
			//We need this to compare to the winning value to see if the game has been won
			if(LEDIndex==0) {
				LEDIndex=3;
			}
			else {
				LEDIndex--;
			}
		}
		//If the chosen value is equal to the winning value
		if(LEDIndex==winVal) {
			winAnimation(); //If so, display the winning animation
			delay *= 0.85; //Decrease the delay
		}
		else {
			loseAnimation(); //Else, display the losing animation
			delay=1000000; //Reset the delay
		}
	}

#if (CONSOLE_IO_SUPPORT || ENABLE_UART_SUPPORT)
	printf("Hello World in C++ from MCF52259 derivative on TWR-MCF5225X board\n\r");
#endif
	for(;;) {	   
	   	counter++;
	}
}
コード例 #8
0
ファイル: AnalogSwitch.cpp プロジェクト: aladain/t5x
int16_t AnalogSwitch::update()
{
	return update(getSwitchState(m_source));
}