예제 #1
0
static void save_temperatures(FILE *f, struct dive *dive)
{
	if (!dive->airtemp.mkelvin && !dive->watertemp.mkelvin)
		return;
	fputs("  <temperature", f);
	show_temperature(f, dive->airtemp, " air='", "'");
	show_temperature(f, dive->watertemp, " water='", "'");
	fputs(" />\n", f);
}
예제 #2
0
파일: main.c 프로젝트: williamlagos/serial
int
main(int argc, char *argv[])
{
	int		 i, c, done;
	int		 offset;
	char	 buf[128], str[64];
	short	 temp;

	i = 0;
	offset = 0;
	init_board();

read_input:
	if (IS_PRESSED(BUTTON1)) {
		UART0_puts("_BALANCE:1_", 64);
		UART0_gets(str, sizeof(str));
		LCD_command(1);
		LCD_puts(str, sizeof(str));
		LCD_putchar('\n');
		temp = read_temp();
		show_temperature(temp);
	} else if (IS_PRESSED(BUTTON2)) {
		UART0_puts("_RECHARGE:1:", 64);
		escrevenum(leds_state);
		UART0_puts("_", 64);
		UART0_gets(str, sizeof(str));
		LCD_command(1);
		LCD_puts(str, sizeof(str));
		LCD_putchar('\n');
		temp = read_temp();
		show_temperature(temp);
	} else if (IS_PRESSED(BUTTON3)) {
		UART0_puts("_DISCHARGE:1:", 64);
		escrevenum(leds_state);
		UART0_puts("_", 64);
		UART0_gets(str, sizeof(str));
		LCD_command(1);
		LCD_puts(str, sizeof(str));
		LCD_putchar('\n');
		temp = read_temp();
		show_temperature(temp);
	} else if (IS_PRESSED(BUTTON4)) {
		leds_state++;
		UPDATE_LED();
		uwait(1000);
	} else if (IS_PRESSED(BUTTON5)) {
		leds_state--;
		UPDATE_LED();
		uwait(1000);
	}
	goto read_input;

	/* NOTREACHED */
	return (0);
}
예제 #3
0
파일: save-xml.c 프로젝트: kotnik/diveclog
static void save_overview(FILE *f, struct dive *dive)
{
	show_depth(f, dive->maxdepth, "  <maxdepth>", "</maxdepth>\n");
	show_depth(f, dive->meandepth, "  <meandepth>", "</meandepth>\n");
	show_temperature(f, dive->airtemp, "  <airtemp>", "</airtemp>\n");
	show_temperature(f, dive->watertemp, "  <watertemp>", "</watertemp>\n");
	show_duration(f, dive->duration, "  <duration>", "</duration>\n");
	show_duration(f, dive->surfacetime, "  <surfacetime>", "</surfacetime>\n");
	show_pressure(f, dive->beginning_pressure, "  <cylinderstartpressure>", "</cylinderstartpressure>\n");
	show_pressure(f, dive->end_pressure, "  <cylinderendpressure>", "</cylinderendpressure>\n");
	show_utf8(f, dive->location, "  <location>","</location>\n");
	show_utf8(f, dive->notes, "  <notes>","</notes>\n");
}
예제 #4
0
static void save_sample(FILE *f, struct sample *sample)
{
	fprintf(f, "  <sample time='%u:%02u min'", FRACTION(sample->time.seconds,60));
	show_milli(f, " depth='", sample->depth.mm, " m", "'");
	show_temperature(f, sample->temperature, " temp='", "'");
	show_pressure(f, sample->cylinderpressure, " pressure='", "'");
	if (sample->cylinderindex)
		fprintf(f, " cylinderindex='%d'", sample->cylinderindex);
	fprintf(f, " />\n");
}
예제 #5
0
파일: ui.c 프로젝트: russells/hc2
static QState uiRun(struct UI *me)
{
	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		lcd_buttons(LCD_BUTTONS_ENTER_UP_DOWN);
		show_temperature(me->ti);
		show_time(gettimep());
		return Q_HANDLED();
	case BUTTON_ENTER_PRESS_SIGNAL:
		return Q_TRAN(uiMenuMaybeSettime);
	case BUTTON_UP_PRESS_SIGNAL:
		return Q_TRAN(uiShowMax);
	case BUTTON_DOWN_PRESS_SIGNAL:
		return Q_TRAN(uiShowMin);
	case CURRENT_TEMPERATURE_SIGNAL:
		me->ti = (int16_t) Q_PAR(me);
		show_temperature(me->ti);
	}
	return Q_SUPER(uiTop);
}
예제 #6
0
int main(void)
{
    int fd;

    fd = open("/dev/ttyS1",O_RDWR |O_NONBLOCK);
    if(fd < 0){
        exit(1);
    }
    set_opt_str(fd,9600,8,'N',1);

    while(1){
        show_ip(fd,1);
        show_rate(fd,1);
        show_temperature(fd,1);
    }
    close(fd);
    
    return 0;
}
예제 #7
0
/*!
	Contains the code execution loop
 */
int main()
{
	float temp;
	
	// setup
	temperature_setup();
	display_setup();
	SysTick_Config(SystemCoreClock / 50);
	
	// super loop
	while(1)
	{
		while (!ticks);
		ticks = 0;
		temp = get_temperature();
		printf("%f\n", temp);
		show_temperature(temp);
		blink_leds();
	}
}
예제 #8
0
파일: ui.c 프로젝트: russells/hc2
static QState uiShowMin(struct UI *me)
{
	QTimeEvtCtr timeout = showmaxmintimeout;
	int16_t ti;

	switch (Q_SIG(me)) {
	case Q_ENTRY_SIG:
		me->showmaxmincounter ++;
		switch (me->showmaxmincounter) {
		case 1:
			lcd_showstring("MIN T  ");
			timeout = showmaxmintimeout;
			break;
		case 2:
			lcd_showstring("SINCE  ");
			timeout = showmaxmintimeout;
			break;
		case 3:
			lcd_showstring("9 AM   ");
			timeout = showmaxmintimeout;
			break;
		case 4:
			ti = get_min_today()->ti;
			if (INVALIDTI == ti)
				me->showmaxmincounter ++;
			show_temperature(ti);
			timeout = 3 * showmaxmintimeout;
			break;
		case 5:
			show_at(&(get_min_today()->time));
			timeout = 3 * showmaxmintimeout;
			break;
		case 6:
			lcd_showstring("MIN T  ");
			timeout = showmaxmintimeout;
			break;
		case 7:
			lcd_showstring("TO LAST");
			timeout = showmaxmintimeout;
			break;
		case 8:
			lcd_showstring("9 AM   ");
			timeout = showmaxmintimeout;
			break;
		case 9:
			ti = get_min_yesterday()->ti;
			if (INVALIDTI == ti)
				me->showmaxmincounter ++;
			show_temperature(ti);
			timeout = 3 * showmaxmintimeout;
			break;
		case 10:
			show_at(&(get_min_yesterday()->time));
			timeout = 3 * showmaxmintimeout;
			break;
		default:
			Q_ASSERT( 0 );
			break;
		}
		QActive_armX(&me->super, 1, timeout);
		return Q_HANDLED();
	case Q_TIMEOUT1_SIG:
	case BUTTON_DOWN_PRESS_SIGNAL:
		if (10 == me->showmaxmincounter)
			return Q_TRAN(uiRun);
		else
			return Q_TRAN(uiShowMin);
	}
	return Q_SUPER(uiShowMinTop);
}
예제 #9
0
main()
{ 
ds1307_init(); 

// Set date for -> 15 June 2005 Tuesday 
// Set time for -> 15:20:55 
//ds1307_set_date_time(18,11,12,2,22,05,55); 


  setup_adc(ADC_CLOCK_INTERNAL);
//enables the a/d module 
  set_adc_channel(0);
//the next read_adc call will read channel 0
  delay_us(10);
//a small delay is required after setting the channel

//aguarda 100ms
  delay_ms(100);

//inicializa o display LCD
  inic_display();

  while (true)
  {

    switch(tela){
      case 0:
        display(0,0x01);
        update_clock();
        read_temperature();
        check_temperature();
        show_temperature();
        show_clock();

        if(tecla_set_status && !tecla_menos_status && tecla_mais_status)
          tela = 2;

        if(tecla_set_status && tecla_menos_status && !tecla_mais_status)
          tela = 1;
        

        break;
      case 1:
        read_temperature();
        configure_temperature();
        break;
      case 2:
        //update_clock();
        configure_time();
        break;
    }

//alterna o estado do pino D4
    //output_toggle(PIN_D1);

    verifica_teclas();

//aguarda 500ms
    delay_ms (100);
  }
}