diff options
Diffstat (limited to 'src/server/main.c')
-rw-r--r-- | src/server/main.c | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/src/server/main.c b/src/server/main.c index 737d694..11581ae 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -36,8 +36,7 @@ static void init(const unsigned int port, int *sock); static int getpacket(char *data, size_t buffsize, int *sock, struct sockaddr_in *sender); static void draw_idle(void); static void draw_busy(const char * const data); -static float digest_mpu_temp(const short int rawdata); -static float digest_thermistor_temp(const short int rawdata); +static float digest_temp(const short int rawdata); int main(void) { @@ -136,59 +135,40 @@ static void draw_idle(void) printw("sequence: [waiting for ESP8266...]"); move(1, 0); clrtoeol(); - mvprintw(1, 0, "mpu temp: [waiting for ESP8266...]"); + mvprintw(1, 0, "thermistor temp: [waiting for ESP8266...]"); move(2, 0); clrtoeol(); - mvprintw(2, 0, "thermistor temp: [waiting for ESP8266...]"); - move(3, 0); - clrtoeol(); - mvprintw(3, 0, "press 'q' to exit"); + mvprintw(2, 0, "press 'q' to exit"); refresh(); } static void draw_busy(const char * const data) { unsigned int sequence; - short int mpu_data; short int thermistor_data; - float mpu_temp; - float thermistor_temp; + float temp; memcpy(&sequence, data + 2, sizeof(sequence)); - memcpy(&mpu_data, data + 6, sizeof(mpu_data)); - memcpy(&thermistor_data, data + 8, sizeof(thermistor_data)); - mpu_temp = digest_mpu_temp(mpu_data); - thermistor_temp = digest_thermistor_temp(thermistor_data); + memcpy(&thermistor_data, data + 6, sizeof(thermistor_data)); + temp = digest_temp(thermistor_data); move(0, 0); clrtoeol(); printw("sequence: %u", sequence); move(1, 0); clrtoeol(); - mvprintw(1, 0, "mpu temp: %.3fC", mpu_temp); + mvprintw(1, 0, "thermistor temp: %.1fC", temp); move(2, 0); clrtoeol(); - mvprintw(2, 0, "thermistor temp: %.1fC", thermistor_temp); - move(3, 0); - clrtoeol(); - mvprintw(3, 0, "press 'q' to exit"); + mvprintw(2, 0, "press 'q' to exit"); refresh(); } -static float digest_mpu_temp(const short int rawdata) -{ - float ret; - - ret = rawdata / 340.0f + 36.53f; - - return ret; -} - /* * raw data is in 0.1°K per 1. Subtract 2730 to get Celsius. * Multiply by 0.1f (divide by 10) to get the correct scale. */ -static float digest_thermistor_temp(const short int rawdata) +static float digest_temp(const short int rawdata) { float ret; |