From 676ccda3cbecac2bb89390952b8d5961738c8b66 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Fri, 1 Jun 2018 15:37:24 -0700 Subject: [PATCH] add smaller int type specilizatons --- Firmware/communication/protocol.hpp | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Firmware/communication/protocol.hpp b/Firmware/communication/protocol.hpp index baa2ddea..a1082575 100644 --- a/Firmware/communication/protocol.hpp +++ b/Firmware/communication/protocol.hpp @@ -635,6 +635,26 @@ public: snprintf(buffer, length, "%lu", *property_); return true; } + ENABLE_IF_SAME(std::decay_t, int16_t, bool) + get_string_ex(char * buffer, size_t length, int) { + snprintf(buffer, length, "%hd", *property_); + return true; + } + ENABLE_IF_SAME(std::decay_t, uint16_t, bool) + get_string_ex(char * buffer, size_t length, int) { + snprintf(buffer, length, "%hu", *property_); + return true; + } + ENABLE_IF_SAME(std::decay_t, int8_t, bool) + get_string_ex(char * buffer, size_t length, int) { + snprintf(buffer, length, "%hhd", *property_); + return true; + } + ENABLE_IF_SAME(std::decay_t, uint8_t, bool) + get_string_ex(char * buffer, size_t length, int) { + snprintf(buffer, length, "%hhu", *property_); + return true; + } ENABLE_IF_SAME(std::decay_t, bool, bool) get_string_ex(char * buffer, size_t length, int) { buffer[0] = (*property_) ? '1' : '0'; @@ -660,6 +680,22 @@ public: set_string_ex(char * buffer, size_t length, int) { return sscanf(buffer, "%lu", property_) == 1; } + ENABLE_IF_SAME(TProperty, int16_t, bool) + set_string_ex(char * buffer, size_t length, int) { + return sscanf(buffer, "%hd", property_) == 1; + } + ENABLE_IF_SAME(TProperty, uint16_t, bool) + set_string_ex(char * buffer, size_t length, int) { + return sscanf(buffer, "%hu", property_) == 1; + } + ENABLE_IF_SAME(TProperty, int8_t, bool) + set_string_ex(char * buffer, size_t length, int) { + return sscanf(buffer, "%hhd", property_) == 1; + } + ENABLE_IF_SAME(TProperty, uint8_t, bool) + set_string_ex(char * buffer, size_t length, int) { + return sscanf(buffer, "%hhu", property_) == 1; + } ENABLE_IF_SAME(TProperty, bool, bool) set_string_ex(char * buffer, size_t length, int) { int val;