void sk_main(){
unsigned char level,i;
	y_pos(1,0);
	lcd_printf(" P:");
	for(i=1;i<8;i++) lcd_printf("%X",presa_read_level(i));
heh
			
	y_pos(1,3);
	lcd_printf("Menu");			
	cursore_sceqgli_opz(3);
}
void sk_init(){
 	y_pos(7,0);
	lcd_printf("VISITA");	
		
 	y_pos(2,1);
	lcd_printf("www.pyacqua.net"); 
	y_pos(0,3);
	lcd_printf("--------------------");	
	msDelay(3000);
	sk_clear();
	
}
void sk_menu_1_3(){
unsigned char scelta;
	y_pos(1,0);
	lcd_printf("<<     INFO");			
	y_pos(1,1);
	lcd_printf("Progetto opensource");			
	y_pos(1,2);
	lcd_printf("  per la gestione   ");			
	y_pos(1,3);
	lcd_printf("     di acquari     ");		
	scelta=aggiorna_cursore_opz(0,0);//min,max quindi solo ritornare indietro
	
}
  void CompNovoIdentificationBase::getCIDSpectrumLight_(PeakSpectrum & spec, const String & sequence, DoubleReal prefix, DoubleReal suffix)
  {
    static DoubleReal h2o_mass = EmpiricalFormula("H2O").getMonoWeight();
    Peak1D p;
    DoubleReal b_pos(0.0 + prefix);
    DoubleReal y_pos(h2o_mass + suffix);
    for (Size i = 0; i != sequence.size() - 1; ++i)
    {
      char aa(sequence[i]);
      b_pos += aa_to_weight_[aa];

      char aa2(sequence[sequence.size() - i - 1]);
      y_pos += aa_to_weight_[aa2];

      if (b_pos > min_mz_ && b_pos < max_mz_)
      {
        p.setPosition(b_pos + Constants::PROTON_MASS_U);
        p.setIntensity(1.0f);
        spec.push_back(p);
      }

      if (y_pos > min_mz_ && y_pos < max_mz_)
      {
        p.setPosition(y_pos + Constants::PROTON_MASS_U);
        p.setIntensity(1.0f);
        spec.push_back(p);
      }
    }

    spec.sortByPosition();
    return;
  }
void sk_menu_1_2_1(){
unsigned char scelta,presa;
	y_pos(1,0);
	lcd_printf("<<  Assegna nomi");
	presa=scegli_presa();
	assegna_nome(3,2,presa); //x,y
}
void sk_menu_1_2_3(){
unsigned char scelta;
	y_pos(1,0);
	lcd_printf("<< IMPOSTA TIMER");	
	scelta=scegli_presa();
//cursore su linea x

}
void sk_menu_1_2_2(){
unsigned char scelta,stato;
	y_pos(1,0);
	lcd_printf("<<  CAMBIA STATO ");	
	scelta=scegli_presa();
	stato=imposta_stato(scelta);
	presa_set_level(scelta,stato);
}
void BasicEnemy::draw(I_GraphicsHandler& graphics) {
    if (texture_ == NULL) {
        printf("BasicEnemy graphics were null! Setting BasicEnemy graphic...\n");
        set_texture(graphics.load_image("assets/ships/BasicEnemy.png"));
    }

    graphics.draw(texture_, (int)x_pos(), (int)y_pos(), GraphicPriority::MIDDLE);
}
void sk_menu_1_2(){
unsigned char scelta;
	y_pos(1,0);
	lcd_printf("<< GESTIONE PRESE");
	y_pos(1,1);
	lcd_printf("Assegna nomi");		
	y_pos(1,2);
	lcd_printf("Cambia stato");		
	y_pos(1,3);
	lcd_printf("Imposta timer");
	barra_menu_vert(0);
	scelta=aggiorna_cursore_opz(0,3);//12=menu = 1_2
	sk_clear();
	if (scelta==0) udelay(1);//ritorna
	else if (scelta==1) sk_menu_1_2_1(); 
	else if (scelta==2) sk_menu_1_2_2();
	else if (scelta==3) sk_menu_1_2_3();
	
}
void sk_menu_1_1(){
	
	char valore[5];
//	int intervalli[6];
	// leggi rtc
	y_pos(0,0);
	lcd_printf("<<  CAMBIA  DATA");			
	y_pos(2,2);
	//lcd_printf("15:00   25/04/07");
//ora 
  valore[0]=read_hour();
  lcd_printf("%02d:",valore[0]);
  valore[1]=read_min();
  lcd_printf("%02d  ",valore[1]);

//data 
  valore[2]=read_day();
  lcd_printf("%02d",valore[2]);
  valore[3]=read_month();
  lcd_printf("/%02d",valore[3]);
  valore[4]=read_year();
  lcd_printf("/%02d",valore[4]);

	// x,y,partenza,min,max
	valore[0]=inc_cifra(2,2,valore[0],0,24);// hh 
	valore[1]=inc_cifra(5,2,valore[1],0,59);// mm
	set_ora(valore[0],valore[1]);
	
	valore[2]=inc_cifra(9,2,valore[2],0,31);// gg
	valore[3]=inc_cifra(12,2,valore[3],0,12);// m
	valore[4]=inc_cifra(15,2,valore[4],7,20);// aa
	// verifica data x gg bisestili e gg de mesi
	set_data(valore[2],valore[3],valore[4]);
	
	//se ok salva il valore
	y_pos(4,3);
		
	if (true) lcd_printf("DATA SALVATA");
	else lcd_printf("DATA ERRATA");
	msDelay(2000);		

}
void sk_menu_1(){

	// problema... cm fare x scorrere le voci in verticale????
	unsigned char scelta;
	y_pos(1,0);
	lcd_printf("<<     MENU ");			
	y_pos(1,1);
	lcd_printf("Cambia data");			
	y_pos(1,2);
	lcd_printf("Gestione prese");			
	y_pos(1,3);
	lcd_printf("Info");
	barra_menu_vert(0);
	scelta=aggiorna_cursore_opz(0,3);
	sk_clear();
	if (scelta==0) udelay(1);//ritorna
	else if (scelta==1) sk_menu_1_1(); 
	else if (scelta==2) sk_menu_1_2();
	else if (scelta==3) sk_menu_1_3();
}
//da spostare in qualke altro file, viene comoda anke x assegnare i nomi alle sonde.... oppure il nome esce in automatiko...
// kidere al gruppo.... boh..
void assegna_nome(unsigned x, unsigned y, unsigned char presa) {
//presa 1..7
    char alfabeto[37][2]= {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"," ","0","1","2","3","4","5","6","7","8","9"};
    char nome[15][2];
    unsigned char lettera,carattere,press,i;
    y_pos(x,y);
    lettera=0;
    carattere=0;
    while(p_status() != P_OK) {
        msDelay(10);
        press=p_status();
        if (press!=0) {
            if (press==P_DOWN)	{
                if(lettera<26) lettera++;
                else lettera=0;
            }
            else if (press==P_UP)	{
                if(lettera<26) lettera++;
                else lettera=0;
            }
            else if (press==P_RIGHT)	{
                if(carattere<15) {
                    nome[carattere][0]=alfabeto[lettera][0];
                    carattere++;
                    x++; // avanza di un carattere
                    lettera=0;// il prox carattere partirà dalla lettere a.
                }
            }
            y_pos(x,y);
            lcd_printf(alfabeto[lettera]);
            while (p_status()!=0) msDelay(10);
        }
    }
    presa--;
    for(i=0; i<carattere; i++) prese_nomi[presa][i][0]=nome[i][0];
//for(i=carattere;i<15;i++) prese_nomi[presa][i][0]=" ";//azera gli altri caratteri


}
unsigned char  scegli_sonda(){

// ritorna 1..7
	unsigned char scelta,press,i,sonda;
	y_pos(1,1);
	lcd_printf("Scegli la sonda");
	y_pos(4,2);
	lcd_printf(">1 2 3 4 5 6 7");
	y_pos(3,3);	
	for (i=0;i<15;i++) lcd_printf(sonde_nomi[0][i]);
	scelta=4;
	y_pos(scelta,2);
	sonda=1;
	while(p_status() != P_OK){
		press=p_status();
		if (press!=0)	{
			y_pos(scelta,2);
			lcd_printf(" ");	
			if (press==P_RIGHT)	{
				scelta+=2;
				sonda++; 			
				if (scelta>17){
					scelta=4;
					sonda=1;
				}
			}
			else if (press==P_LEFT)	{
				scelta-=2;
				sonda--; 			
				if (scelta<4){
					scelta=16;
					sonda=7;
				}
			}
			y_pos(scelta,2);
			lcd_printf(">");
			y_pos(3,3);
			for (i=0;i<15;i++) lcd_printf(sonde_nomi[sonda-1][i]);
			while (p_status()!=0) msDelay(1);		
		}
	}
	clean_row(2);
	return sonda; // da1..7



}
unsigned char imposta_stato(unsigned char presa) {
    unsigned char level,press;
    y_pos(1,1);
    lcd_printf("Scegli lo stato");
    y_pos(6,2);
    lcd_printf(" 0     1");
    level=presa_read_level(presa);
    //porta il cursore sullivello del pin
    if (!level) 	y_pos(6,2);
    else		y_pos(12,2);
    lcd_printf(">");
    press=0;
    while(p_status() != P_OK) {
        press=p_status();
        if (press!=0)	{
            if (press==P_LEFT)	{
                y_pos(12,2);
                lcd_printf(" ");
                y_pos(6,2);
                lcd_printf(">");
                level=0;
                while (p_status()==P_LEFT) msDelay(1);
            }
            if (press==P_RIGHT)	{
                y_pos(6,2);
                lcd_printf(" ");
                y_pos(12,2);
                lcd_printf(">");
                level=1;
                while (p_status()==P_RIGHT) msDelay(1);
            }
        }
    }
    printf("restituisco %d",level);
    return level;
}
Example #15
0
//*****************
//	MAIN
//*****************
int  main (int argc, char *argv[]) {

//orologio
	time_t now;
	struct tm *tm_now;
	char conv[3];
	char buff[20];

//match 
	unsigned char hr;
	unsigned char min;
	
	int presa,timer;//x cicli for
	//aspetta alim stabile
		
	
	delay_ms(50);
	sk_clear();
	delay_ms(50);

	system ("clear");

    	if (i2c_open()<0) { 	printf("Apertura del bus I2C fallita\n"); return 1; }
	board_init();		printf("--Init board					[PASS]\n"); 
	lcd_init();		printf("--Init lcd					[PASS]\n"); 
	ciabatta_init();	printf("--Init ciabatta					[PASS]\n"); 
//	socket_init();		printf("--Init socket on 15000				[PASS]\n"); 
	board_init();
	ciabatta_init();
	sk_init();
	printf("\nfox-acqua in esecuzione.\n"); 



	if(fork() != 0){ //eseguito dal processo padre
		for(;;){
			y_pos(1,3);
			lcd_printf("MENU");
			cursore_scegli_opz(3);
		
			while(p_status()!= P_OK){
				//disegna lo stato delle prese
				y_pos(1,0);
				lcd_printf(" P:");
				for(presa=1;presa<8;presa++) lcd_printf("%d",presa_read_level(presa));
			
		
				//mostra ora e data
  			

				y_pos(12,1);
				now = time ( NULL );
  				tm_now = localtime ( &now );
//%a  /* Abbreviated weekday */
//%A  /* Full weekday */
//%b  /* Abbreviated month */
//%b  /* Full month */
//%c  /* Full date and time */
//%d  /* Day of the month (1-31) */
//%H  /* Hour (24 hour clock) */
//%I  /* Hour (12 hour clock) */
//%j  /* Day of the year (1-366)*/
//%m  /* Month (1-12) */
//%M  /* Minute (0-59) */
//%p  /* AM/PM for 12 hour clock */
//%S  /* Second (0-60) */
//%U  /* Week number from Sunday */
//%w  /* Weekday (0-6) from Sunday */
//%W  /* Week number from Monday */
//%x  /* Full date */
//%X  /* Full time of day */
//%y  /* Year without century */
//%Y  /* Year with century */
//%Z  /* Time zone */
//%%  /* Print a % character */
  				strftime ( buff, sizeof buff, "%H:%M:%S", tm_now );
  				strftime ( conv, sizeof conv, "%H", tm_now );	hr=atoi(conv);
  				strftime ( conv, sizeof conv, "%M", tm_now );	min=atoi(conv);

  				lcd_printf( "%s", buff );
				y_pos(12,2);
				strftime ( buff, sizeof buff, "%d/%m/%y", tm_now );
  				lcd_printf( "%s", buff );
				//----match tra rtc e timer vari----
		
				//controlla se un delle 10 prese ha un timer attivo
				
				s_timer timer[70];
				for (a=0; a<70; a++)
        			read_timer(&timer[a], a);
				//for (presa=0;presa<8;presa++){            //sfoglia le prese
					//for(timer=0;timer<10;timer++){         //sfoglia i 10 timer di questa presa
						if (presa_timer_stato[presa][timer]<99){
						//allora c'� un timer impostato x questa presa
						//controlla se deve scattare in questo momento
						// !!!!!!!!!!!!!!
						// risolvere il problema nel caso in cui: l'utente sia nel menu,
						// e quando si ritorna qui l'orologio � andato
						// dopo l'evento di un timer.
							if (presa_timer[presa][timer][0]==hr){
								if (presa_timer[presa][timer][1]==min){//ok, allora imposta la presa.
									presa_set_level(presa+1,presa_timer_stato[presa][timer]);
								}
							}
						}
					}
				}
			} //luppa fink� non � premuto
			sk_clear();
			//socket_printf(cs,"Menu_1_0");
			//write(cs,zero,1); //fa scrivee effettivamente la frase sopra svuotando il buffer ke ha interno(penso).
		
			sk_menu_1();
			sk_clear();
		}//for
  void CompNovoIdentificationBase::getCIDSpectrum_(PeakSpectrum & spec, const String & sequence, Size charge, DoubleReal prefix, DoubleReal suffix)
  {
    static DoubleReal h2o_mass = EmpiricalFormula("H2O").getMonoWeight();
    static DoubleReal nh3_mass = EmpiricalFormula("NH3").getMonoWeight();
    static DoubleReal co_mass = EmpiricalFormula("CO").getMonoWeight();
    Peak1D p;
    DoubleReal b_pos(0 + prefix);
    DoubleReal y_pos(h2o_mass + suffix);
    bool b_H2O_loss(false), b_NH3_loss(false), y_NH3_loss(false);

    for (Size i = 0; i != sequence.size() - 1; ++i)
    {
      char aa(sequence[i]);
      b_pos += aa_to_weight_[aa];

      char aa2(sequence[sequence.size() - i - 1]);
      y_pos += aa_to_weight_[aa2];
      for (Size z = 1; z <= charge && z < 3; ++z)
      {
        // b-ions
        if (b_pos >= min_mz_ && b_pos <= max_mz_)
        {
          for (Size j = 0; j != max_isotope_; ++j)
          {
            if (z == 1 /*|| b_pos > MIN_DOUBLE_MZ*/)
            {
              p.setPosition((b_pos + (DoubleReal)z * Constants::PROTON_MASS_U + (DoubleReal)j + Constants::NEUTRON_MASS_U) / (DoubleReal)z);
              p.setIntensity(isotope_distributions_[(Size)b_pos][j] * 0.8 / (z * z));
              spec.push_back(p);
            }
          }
        }

        // b-ion losses
        if (b_pos - h2o_mass > min_mz_ && b_pos - h2o_mass < max_mz_)
        {
          if (b_H2O_loss || aa == 'S' || aa == 'T' || aa == 'E' || aa == 'D')
          {
            b_H2O_loss = true;
            p.setPosition((b_pos + z * Constants::PROTON_MASS_U - h2o_mass) / z);
            p.setIntensity(0.02 / (DoubleReal)(z * z));
            if (z == 1 /* || b_pos > MIN_DOUBLE_MZ*/)
            {
              spec.push_back(p);
            }
          }
          if (b_NH3_loss || aa == 'Q' || aa == 'N' || aa == 'R' || aa == 'K')
          {
            b_NH3_loss = true;
            p.setPosition((b_pos + z * Constants::PROTON_MASS_U - nh3_mass) / z);
            p.setIntensity(0.02 / (DoubleReal)(z * z));

            if (z == 1 /* || b_pos > MIN_DOUBLE_MZ*/)
            {
              spec.push_back(p);
            }
          }
        }

        // a-ions only for charge 1
        if (z == 1)
        {
          if (b_pos - co_mass > min_mz_ && b_pos - co_mass < max_mz_)
          {
            // a-ions
            p.setPosition((b_pos + z * Constants::PROTON_MASS_U - co_mass) / (DoubleReal)z);
            p.setIntensity(0.1f);
            spec.push_back(p);
          }
        }



        if (y_pos > min_mz_ && y_pos < max_mz_)
        {
          // y-ions
          for (Size j = 0; j != max_isotope_; ++j)
          {
            if (z == 1 /* || y_pos > MIN_DOUBLE_MZ*/)
            {
              p.setPosition((y_pos + (DoubleReal)z * Constants::PROTON_MASS_U + (DoubleReal)j * Constants::NEUTRON_MASS_U) / (DoubleReal)z);
              p.setIntensity(isotope_distributions_[(Size)y_pos][j] / (DoubleReal) (z * z));
              spec.push_back(p);
            }
          }

          // H2O loss
          p.setPosition((y_pos + z * Constants::PROTON_MASS_U - h2o_mass) / (DoubleReal)z);
          p.setIntensity(0.1 / (DoubleReal)(z * z));
          if (aa2 == 'Q')           // pyroglutamic acid formation
          {
            p.setIntensity(0.5f);
          }
          if (z == 1 /* || y_pos > MIN_DOUBLE_MZ*/)
          {
            spec.push_back(p);
          }

          // NH3 loss
          if (y_NH3_loss || aa2 == 'Q' || aa2 == 'N' || aa2 == 'R' || aa2 == 'K')
          {
            y_NH3_loss = true;
            p.setPosition((y_pos + z * Constants::PROTON_MASS_U - nh3_mass) / (DoubleReal)z);
            p.setIntensity(0.1 / (DoubleReal)(z * z));

            if (z == 1 /*|| y_pos > MIN_DOUBLE_MZ*/)
            {
              spec.push_back(p);
            }
          }
        }
      }
    }

    // if Q1 abundant loss of water -> pyroglutamic acid formation

    if (sequence[0] == 'Q' && prefix == 0 && suffix == 0)
    {
      /*
      for (PeakSpectrum::Iterator it = spec.begin(); it != spec.end(); ++it)
      {
          it->setIntensity(it->getIntensity() * 0.5);
      }*/

      /*
      for (Size j = 0; j != max_isotope; ++j)
      {
  p.setPosition((precursor_weight + charge - 1 + j)/(DoubleReal)charge);
  p.setIntensity(isotope_distributions_[(Int)p.getPosition()[0]][j] * 0.1);
  spec.push_back(p);
      }
      */
    }


    spec.sortByPosition();

    return;
  }