summaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'command.c')
-rw-r--r--command.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/command.c b/command.c
index 7d8c515..09b91ec 100644
--- a/command.c
+++ b/command.c
@@ -14,7 +14,7 @@ static void handle_set(char *buffer, uint16_t len)
const char *success_msg = "OK Temperature set.\r\n";
const char *input;
char *endptr;
- long temperature;
+ double temperature;
if (len < 2) {
serial_send(error_msg, strlen(error_msg), 0);
@@ -22,7 +22,7 @@ static void handle_set(char *buffer, uint16_t len)
}
input = buffer + 1;
- temperature = strtol(input, &endptr, 10);
+ temperature = strtod(input, &endptr);
if (input[0] == '\r' || input[0] == '\n' ||
(endptr[0] != '\r' && endptr[0] != '\n')) {
serial_send(error_msg, strlen(error_msg), 0);
@@ -48,8 +48,10 @@ static void handle_off(char *buffer, uint16_t len)
static void handle_get(char *buffer, uint16_t len)
{
char response[128];
+ long temp = 10 * controller_get();
- snprintf(response, sizeof(response), "OK t=%ld\r\n", controller_get());
+ /* printf won't print doubles on avr */
+ snprintf(response, sizeof(response), "OK t=%ld.%ld\r\n", temp/10, temp%10);
serial_send(response, strlen(response), 0);
}