示例#1
0
文件: main.c 项目: Andy1978/Brautomat
static void uart_put_temp_maxres(int32_t tval)
{
    char s[10];

    uart_put_longint( tval );
    uart_puts_P(" °Ce-4, ");
    DS18X20_format_from_maxres( tval, s, 10 );
    uart_puts( s );
    uart_puts_P(" °C");
}
示例#2
0
文件: tempsensors.c 项目: C3MA/Aiolos
void uart_put_temp_maxres(int32_t tval) {
  char s[10];

  //uart_put_longint( tval );
  printf("%d", (int )tval );
  printf(" °Ce-4, ");
  DS18X20_format_from_maxres( tval, s, 10 );
  printf( s );
  printf(" °C");
}
void printStatus(void) {
  uint32_t currentTemp, currentTime;	
  uint16_t setpoint;
  char s[10];

  currentTime=TimerRead();
  currentTemp=getHighResTemperature();
  setpoint=getPIDSetpoint();
  uart_puts_P("#:");
  uart_put_longint(currentTime/1000);
  DS18X20_format_from_maxres(currentTemp, s, 10 );
  uart_puts_P(" T:");
  uart_puts( s );
  uart_puts_P(" S:");
  uart_put_float( setpoint );
  uart_puts_P(" D:");
  uart_put_longint( get_duty_cycle() );
  uart_puts_P( NEWLINESTR );
}
示例#4
0
void handle_input(char* input)
{

    if (state == START)
    {
        if (strcmp("set fan\r", input) == 0)
        {
            print_usb("enter fan speed, 0...40 \n\r");

            /* advance state machine */
            state = SET_FAN;

        }
        else if (strcmp("set pump\r", input) == 0)
        {
            print_usb("enter pump speed, 0...200  \n\r");

            /* advance state machine */
            state = SET_PUMP;
        }
        else if (strcmp("set led\r", input) == 0)
        {
            print_usb("enter led brightness, 0...255  \n\r");

            /* advance state machine */
            state = SET_LED;
        }
        else if (strcmp("read temp\r", input) == 0)
        {
            print_usb("reading temp...  \n\r");

            /* advance state machine */
            state = READ_TEMP;
        }
        else
        {
            /* didnt understand string */
            print_usb("did not understand command \n\r");

            /* dont change state */
            state = START;
        }
    }
    else if (state == SET_LED)
    {
        static uint16_t pwm;
        char *garbage = NULL;
        pwm = strtol(input, &garbage, 0);
        OCR4A = pwm;

        print_usb("led set. \n\r");

        /* go back to start */
        state = START;
    }
    else if (state == SET_FAN)
    {
        static uint16_t pwm;
        char *garbage = NULL;
        pwm = strtol(input, &garbage, 0);
        OCR3A = pwm;

        print_usb("fan set. \n\r");

        /* go back to start */
        state = START;
    }
    else if (state == SET_PUMP)
    {
        static uint16_t pwm;
        char *garbage = NULL;
        pwm = strtol(input, &garbage, 0);
        OCR4B = pwm;

        print_usb("pump set. \n\r");

        /* go back to start */
        state = START;
    }
    else if (state == READ_TEMP)
    {
        uint8_t nSensors;

        char maxres_buffer[10];

        ow_set_bus(&PIND, &PORTD, &DDRD, PD4);

        ow_reset();

        /* search for temperature sensors */
        nSensors = search_sensors();

        /* classify sensors */
        classify_sensors(nSensors);

        /* measure temperature */
        measure_temp(nSensors, temp_eminus4);

        DS18X20_format_from_maxres(temp_eminus4[0], maxres_buffer, 10);

        print_usb("\n\r ");
        print_usb("temp max res 1: ");
        print_usb(maxres_buffer);
        print_usb("\n\r ");

        DS18X20_format_from_maxres(temp_eminus4[1], maxres_buffer, 10);

        print_usb("temp max res 2: ");
        print_usb(maxres_buffer);
        print_usb("\n\r ");

        /* go back to start */
        state = START;

    }
    else
    {
        CDC_Device_SendString(&USB_Interface, "went into unknown state!? \n\r");

        state = START;

    }

}