Ejemplo n.º 1
0
int affichage_apres_tournoi (combattant * cbt, int nb_combattants){
		
	temps current_time, refresh_diff_time, refresh_previous_time;
	bool quitter;
	
	/* On remplit la fenetre de la couleur de fond */
	buff_rect(0,0,W_FENETRE,H_FENETRE,CLR_BACKGROUND);
	
	/* On met le logo */
	buff_element (EL_LOGO, (W_FENETRE-400)/2 ,0);
	
	buff_ecrire_texte_xaligncenter ("Voici le classement final des combattants",120,2,CLR_TEXTE_DEFAUT);
	
	buff_classement_combattants (cbt, nb_combattants, 10, 150, W_FENETRE-20, H_FENETRE -200 );
	
	buff_ecrire_texte_xaligncenter ("Appuyez sur n'importe quelle touche pour quitter.",H_FENETRE-20,1,CLR_TEXTE_INFO);
	
	
	
	refresh_previous_time=get_temps();
	
	quitter=FAUX;
	while(!quitter)
	{
		current_time=get_temps();
		
		
		quitter = pressanykey();
	
		if(quitter==QUITTER_AFFICHAGE)
			return QUITTER_AFFICHAGE;
				
		refresh_diff_time=current_time-refresh_previous_time;
		
		if(refresh_diff_time > REFRESH_TIME)
		{
			flip(); 
			refresh_previous_time=current_time;
		}
		else
		if(!quitter)
		{
			delay(REFRESH_TIME - refresh_diff_time); // pause le temps qu'il reste
		}
		
		
	}
	return 0;
}
Ejemplo n.º 2
0
int init_local() {
 	// Connect to SQL database
	dbmsg_connect();

	// Populate the temperature array
	get_temps();

	// Get Product Temperature Setting
	desired_product_temp = get_desired_temp();

	// Initialize the hardware interface
	if (!bcm2835_init()) {
		return -1;
	}

	// Set all appropriate GPIO pins to outputs
	bcm2835_gpio_fsel(HEAT1, GPOUT);
	bcm2835_gpio_fsel(HEAT2, GPOUT);
	bcm2835_gpio_fsel(HEAT3, GPOUT);
	bcm2835_gpio_fsel(HEAT4, GPOUT);
	bcm2835_gpio_fsel(FAN, GPOUT);

	// Determine message source
	source = LOCAL;

	return 0;
}
Ejemplo n.º 3
0
int  main(void)
{
    while (TRUE)
    {
        printf("\nTemperature Plotting Program Menu\n");
        printf("\tE - Enter temperatures for scratchpad\n");
        printf("\tS - Store scratchpad to disk\n");
        printf("\tR - Read disk file to scratchpad\n");
        printf("\tT - Table view of current data\n");
        printf("\tG - Graph view of current data\n");
        printf("\tX - Exit the program\n");
        printf("\nPress one of the above keys: ");

        switch (toupper(getche()))
        {
        case 'E':
            get_temps();
            break;
        case 'S':
            save_temps();
            break;
        case 'R':
            read_temps();
            break;
        case 'T':
            table_view();
            break;
        case 'G':
            graph_view();
            break;
        case 'X':
            exit(0);
        }
    }
}
Ejemplo n.º 4
0
float retourner_fps (void)
{
	temps t = get_temps()-env.dernier_rafraichissement;
	if(t)
		return (1000000.0/(float)(t));
	else
		return 0.0;
}
Ejemplo n.º 5
0
int affichage_apres_execution_instruction (int num_programme)
{
	actions_sur_pression_touche_combat ();
	if(env.mode == MODE_MAXSPEED_NODISPLAY)
		return 0;
	
	temps debut;
	temps refresh_previous_time, current_time, refresh_diff_time, temps_fin;
	bool quitter;

	
	buff_zone_mem();
	buff_stepbar(env.current_step, LIMIT_CYCLE, CLR_STEPBAR);
	
	buff_stat_prog(num_programme);
	buff_instruction_prog(num_programme);
	
	buff_instruction_selection(!num_programme); // prochain prog
	flip();
	
	
	refresh_previous_time=debut=get_temps();
	temps_fin=env.waitingtime;
	if(env.mode == MODE_MAXSPEED_WITHDISPLAY)
		quitter=VRAI;
	else
		quitter=FAUX;
	while(!quitter)
	{
		
		
		if(actions_sur_pression_touche_combat ()==QUITTER_AFFICHAGE)
			return QUITTER_AFFICHAGE;
			
		current_time=get_temps();
		refresh_diff_time=current_time-refresh_previous_time;
		
		quitter = ((current_time-debut) > temps_fin);
		

		if(env.mode != MODE_NORMAL)
				quitter=VRAI;
				
		if(refresh_diff_time > REFRESH_TIME)
		{

			//printf("%f\n",retourner_fps());
			
			flip(); // update_dernier_rafraichissement();
			
			
			refresh_previous_time=current_time;
		}
		else 
		if(!quitter)
		{
			delay(REFRESH_TIME - refresh_diff_time); // pause le temps qu'il reste
		}
		
		
	}
	return 0;
}
Ejemplo n.º 6
0
int affichage_apres_round(int gagnant)
{
	if(actions_sur_pression_touche_combat ()==QUITTER_AFFICHAGE)
		return QUITTER_AFFICHAGE;
	if(env.mode == MODE_MAXSPEED_NODISPLAY)
		return 0;
	
	temps debut;
	temps refresh_previous_time, current_time, refresh_diff_time, temps_fin;
	bool quitter;
	
	// On travaille avec un cycle de taille limit_clign
	int limit_clign = TIME_END_MATCH / (REFRESH_TIME*NB_CLIGN);
	int iclign = 0;
	bool affiche_texte=FAUX;
	
	char * inf = info_fin_round2string( gagnant );
	
	int x,y,w,h; // zone prise par le texte
	
	
	
	x = (W_FENETRE - TailleChaineEcran(inf,2))/2;
	y = H_FENETRE/2 - 50 - TailleSupPolice(2);
	w = TailleChaineEcran(inf,2);
	h = TailleSupPolice(2) + TailleInfPolice(2);
	
	x=x-5;
	y=y-4;
	w=w+10;
	h=h+10;
	
	couleur_role clr_back, clr_texte;
	
		
	if(gagnant==-1)
	{
		clr_back=CLR_BACKGROUND;
		clr_texte=CLR_TEXTE_INFO;
	}
	else if(gagnant==0)
	{
		clr_back=CLR_CASE_P0;
		clr_texte=CLR_PROG0;
		env.mem_owner [ env.ip[1] ] = OWNER_P1_KILL;
		env.need_rebuff[ env.ip[1] ]  = VRAI;
		buff_zone_mem();
	}
	else if(gagnant==1)
	{
		clr_back=CLR_CASE_P1;
		clr_texte=CLR_PROG1;
		env.mem_owner [ env.ip[0] ] = OWNER_P0_KILL;
		env.need_rebuff[ env.ip[0] ]  = VRAI;
		buff_zone_mem();
	}
	
	
	/* On sauvegarde la zone 'sans texte' dans save (depuis buffer),
	 * On ecrit le texte dans buffer,
	 * On copie la zone 'avec texte' dans save
	 */
	
	save_buff_zone (x,y,w,h,0,0);
	
	
	buff_rect (x,y,w,h,clr_back);
	buff_combat_text_info (inf, clr_texte);
	
	free(inf);
	inf=NULL;
	
	save_buff_zone (x,y,w,h,0,100);
	
	
	
	refresh_previous_time=debut=get_temps();
	temps_fin=env.waitingtime;
	
	quitter=FAUX;
	while(!quitter)
	{
		
		current_time=get_temps();
		
		
		quitter = ((current_time-debut) > TIME_END_MATCH);


		if(actions_sur_pression_touche_combat ()==QUITTER_AFFICHAGE)
			return QUITTER_AFFICHAGE;
		
		
		if ( iclign==limit_clign )
		{
			iclign= 0;
			buff_save_zone (0,(affiche_texte)?100:0,w,h,x,y);
			affiche_texte = !affiche_texte;
		}
		else
			iclign ++;
		
		refresh_diff_time=current_time-refresh_previous_time;
		
		if(refresh_diff_time > REFRESH_TIME)
		{
			flip(); 
			refresh_previous_time=current_time;
		}
		else 
		if(!quitter)
		{
			delay(REFRESH_TIME - refresh_diff_time); // pause le temps qu'il reste
		}
		
		
	}
	return 0;
}
Ejemplo n.º 7
0
int affichage_avant_combat (liste_combat l, combattant * cbt, int nb_combattants)
{
	temps current_time, refresh_diff_time, refresh_previous_time;
	bool quitter;
	
	char * s = malloc(sizeof(char) * 128);
	int count;
	
	/* On remplit la fenetre de la couleur de fond */
	buff_rect(0,0,W_FENETRE,H_FENETRE,CLR_BACKGROUND);
	
	/* On met le logo */
	buff_element (EL_LOGO, (W_FENETRE-400)/2 ,0);
	
	buff_ecrire_texte_xaligncenter ("Tournoi en cours",120,2,CLR_TEXTE_DEFAUT);
	
	buff_ecrire_texte("combats :",100,200,2,CLR_TEXTE_DEFAUT);
	buff_liste_combat (l,10,220,350,300);
	
	
	count=count_combat_restant(l);
	if(count>=2)
		snprintf(s,127,"Il reste %d combats.",count);
	else if(count==1)
		snprintf(s,127,"Il reste un combat.");
	else
		snprintf(s,127,"Il ne reste plus de combats.");
	
	buff_ecrire_texte(s,50,550,2,CLR_TEXTE_DEFAUT);
	
	
	buff_ecrire_texte("TOP 5 des combattants :",440,200,2,CLR_TEXTE_DEFAUT);
	buff_top5_combattants(cbt, nb_combattants, 500, 250, 300, 350);
	
	buff_ecrire_texte_xaligncenter ("Appuyez sur n'importe quelle touche pour Lancer le combat.",H_FENETRE-20,1,CLR_TEXTE_INFO);
	
	free(s);
	
	refresh_previous_time=get_temps();

	quitter=FAUX;
	while(!quitter)
	{
		current_time=get_temps();
		
		quitter = pressanykey();
		
		if(quitter==QUITTER_AFFICHAGE)
			return QUITTER_AFFICHAGE;

		refresh_diff_time=current_time-refresh_previous_time;
		
		if(refresh_diff_time > REFRESH_TIME)
		{
			flip();
			refresh_previous_time=current_time;
		}
		else
		if(!quitter)
		{
			delay(REFRESH_TIME - refresh_diff_time); // pause le temps qu'il reste
		}
		
		
	}
	
	// Apres l'affichage de la liste
	buff_combat_new();
	buff_waitingtime();
	buff_changemode();
	
	return 0;
}
Ejemplo n.º 8
0
void DEBUG_temps_perdu (void)
{
	printf("temps perdu: %f\n",(get_temps()-env.dernier_rafraichissement)/1000000.0); update_dernier_rafraichissement();
}
Ejemplo n.º 9
0
temps retourner_temps_passe (void)
{
	return get_temps()-env.dernier_rafraichissement;
	
}
Ejemplo n.º 10
0
void update_dernier_rafraichissement (void)
{
	env.dernier_rafraichissement = get_temps();	
}