Skip to content

Commit d40daf9

Browse files
committed
Fixing floatToString.
1 parent ac29f9b commit d40daf9

File tree

2 files changed

+3
-31
lines changed

2 files changed

+3
-31
lines changed

src/Commander-API.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ int Commander::floatToString( float number, char* buffer, int bufferSize ){
813813
bufferSize--;
814814
}
815815
else{
816-
status = snprintf( buffer, bufferSize, "%d.%0*d", decimalPart, 2, fractionPart );
816+
status = snprintf( buffer, bufferSize, "%d.%02d", decimalPart, fractionPart );
817817
}
818818

819819
// If we had to print a '-' character because a negative number,

src/Commander-API.hpp

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -139,42 +139,14 @@ SOFTWARE.
139139
/// With this macro you can fill the system variable table easily.
140140
/// @param name The name of the int variable.
141141
/// @note Do not use & operator before the name. Just use the name, the macro will handle the rest.
142-
#define systemVariableInt( name ) { 0, NULL, NULL, #name, { Commander::VARIABLE_INT, { (float*)&name } } }
142+
#define systemVariableInt( name ) { 0, NULL, NULL, #name, { Commander::VARIABLE_INT, { (float*)&name } } } // It is an union, this is why (float*) casting required.
143143

144144
/// This macro simplifies the char* or const char* type system variable creation.
145145
///
146146
/// With this macro you can fill the system variable table easily.
147147
/// @param name The name of the char* or const char* variable.
148148
/// @note Do not use & operator before the name. Just use the name, the macro will handle the rest. Also, no const casting is needed.
149-
#define systemVariableString( name ) { 0, NULL, NULL, #name, { Commander::VARIABLE_STRING, { (float*)name } } }
150-
151-
#ifdef __AVR__
152-
153-
/// This macro simplifies the float type system variable creation for PROGMEM implementation.
154-
///
155-
/// With this macro you can fill the system variable table easily.
156-
/// @param element One element in the system variables table.
157-
/// @param name The name of the float variable.
158-
/// @note Do not use & operator before the name. Just use the name, the macro will handle the rest.
159-
#define systemVariableFloat_P( element, name ) { element.name_P = __CONST_TXT__( name ); element.floatData = &name; element.intData = NULL; element.strData = NULL; element.name = NULL; }
160-
161-
/// This macro simplifies the int type system variable creation for PROGMEM implementation.
162-
///
163-
/// With this macro you can fill the system variable table easily.
164-
/// @param element One element in the system variables table.
165-
/// @param name The name of the char* or const char* variable.
166-
/// @note Do not use & operator before the name. Just use the name, the macro will handle the rest. Also, no const casting is needed.
167-
#define systemVariableInt_P( element, name ) { element.name_P = __CONST_TXT__( name ); element.floatData = NULL; element.intData = &name; element.strData = NULL; element.name = NULL; }
168-
169-
/// This macro simplifies the char* or const char* type system variable creation for PROGMEM implementation.
170-
///
171-
/// With this macro you can fill the system variable table easily.
172-
/// @param element One element in the system variables table.
173-
/// @param name The name of the int variable.
174-
/// @note Do not use & operator before the name. Just use the name, the macro will handle the rest.
175-
#define systemVariableString_P( element, name ) { element.name_P = __CONST_TXT__( name ); element.floatData = NULL; element.intData = NULL; element.strData = (char*)name; element.name = NULL; }
176-
177-
#endif
149+
#define systemVariableString( name ) { 0, NULL, NULL, #name, { Commander::VARIABLE_STRING, { (float*)name } } } // It is an union, this is why (float*) casting required.
178150

179151
/// This macro simplifies the attachment of the system variable table.
180152
///

0 commit comments

Comments
 (0)