Пример #1
0
/***********************************************************
 * Constructor
 ***********************************************************/
HDaemonApp::HDaemonApp():BApplication(APP_SIG)
	,fRunner(NULL)
	,fPopClient(NULL)
	,fAccountDirectory(NULL)
	,fHaveNewMails(false)
{
	// Load scooby preferences
	BPath path;
	::find_directory(B_USER_DIRECTORY,&path);
	path.Append("mail");
	path.Append( "Trash" );
	::create_directory(path.Path(),0777);
	char *pref_name = new char[::strlen("Scooby") + 12];
	::sprintf(pref_name,"%s %s","Scooby","preference");
	fPrefs = new HPrefs(pref_name,"Scooby");
	delete[] pref_name;
	fPrefs->LoadPrefs();
	// Get Account setting path
	::find_directory(B_USER_SETTINGS_DIRECTORY,&fSettingPath);
	fSettingPath.Append("Scooby");
	InstallDeskbarIcon();
	RunTimer();
}
Пример #2
0
void *run_timer(void *data)
{
	RunTimer(data);
	return NULL;
}
Пример #3
0
/*----------------------------------------------------------------------------
  Main Program
 *----------------------------------------------------------------------------*/
int main (void) {
	int i;
	char potOutput[20];
	char answer[10];

	//Following statement sets the timer interrupt frequency
	//The clock rate on this boards MCU is 72 Mhz - this means
	//every second there will be 72 million clocks. So, if use this
	//as the parameter to the function the interrupt rate is going
	//to be every second. If it is reduced to 100 times less then
	//it will do that many clocks in 100 times less time, i.e. 10 msecs.
	//NOTE: We could have chosen to generate a timer interrupt every 1 msec
	//if we wished and that would be quite acceptable in which case we would
	//need to modify the interrupt handler routine in IRQ.c file.
  	SysTick_Config(SystemCoreClock/10000);  /* Generate interrupt each 10 ms      */

   	
	LED_init(); /* LED Initialization                 */

	pin_PA4_For_Speaker(); //Function that initializes the Speaker
		
	ADC_init();  //Function that initializes ADC

	GLCD_Init(); /* Initialize graphical LCD display   */
  		
	joyStick_Init(); // Initialise the joystick

	userButton_Init(); // Initialise User Button

	userButton_IntrEnable(); //initialise the User button as an interrupt source

  //Here we initialise the Joystick switches as interrupt sources
  joyStick_IntrEnable_PG15_13();
	joyStick_IntrEnable_PG7();
	joyStick_IntrEnable_PD3();
	
	AD_done = 0;
	ADC1->CR2 |= (1UL << 22);       		//Start the ADC conversion
	doTone = 0;
	
	WelcomeScreen();

	


// initialiseGetAnswer(answer, 10);
//	if(currentState == ON_DIFFICULTY_SCREEN)
//	{
//			GLCD_Clear(White);
//			if(currDifficulty == 0){
//				currDifficulty = 1;
//			}
//			updateNextDifficulty(nextDifficulty);
//			DisplayInstructions(NULL,currentScore,currDifficulty,1);
//			DrawBarGraph(BAR_X,BAR_Y,currDifficulty * 20,BAR_HEIGHT,BAR_VALUE);
//	}	
	while (TRUE) {
		
		
		// Program pauses whilst Countdown timer ticks - this is necessary because the program does not like interrupts and delay timers
		// i.e. SysTick does not work whilst interrupts being handled
		// Gives the user time to memorise the code
		// Program then advances to accept answer state
		if(currentState == QUESTION_SCREEN) { // Question Screen Delay countdown timer
			RunTimer(5000);
			
			currentState = ANSWER_SCREEN;
			answerScreen();
			
			Vectored_Interrupt(USER_BUTTON); // Simulate user pressing the button
		}
		
		
		
//								
//				//RunTimer(TIMER_LENGTH);
//			GLCD_SetBackColor(Red);
//			DrawBarGraph(100,6*24,barWidth,15,1);
//			delay10th(10000);
//			GLCD_SetBackColor(White);
//			barWidth -= 20;
//			if(barWidth <= 0){
//				barWidth = 100;
//			}
//			GLCD_DisplayString(6,0,__FI,"                   ");
				//Check to see if ADC sampling is completed
//				if (AD_done) {
//					//Yes, so get part of the sample value
//					c = (AD_last >> 8) + 4;
//					if (doTone) {
//						//If enabled, switch the tone on
//							sprintf(potOutput,"Pot = %d",c);
//							displayTestMessage(1,0,potOutput,0);
//				   		generate_Tone_On_Speaker(c * 50, 10);
//					}
//					AD_done = 0;  					//Reset the ADC complete flag waiting for next sample
//					ADC1->CR2 |= (1UL << 22);   	//Start the next ADC conversion
	}
}