Alternative to display INT_MIN correctly (#7557)

INT_MIN/INT_MAX
This commit is contained in:
Bertrand Songis
2020-05-15 15:54:51 +02:00
committed by GitHub
parent 40f9b05ce2
commit 0609cdb2d3
3 changed files with 39 additions and 0 deletions
+13
View File
@@ -18,6 +18,7 @@
* GNU General Public License for more details.
*/
#include <limits.h>
#include "opentx.h"
display_t displayBuf[DISPLAY_BUFFER_SIZE] __DMA;
@@ -465,7 +466,19 @@ void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags, uint8_t le
int idx = 0;
int mode = MODE(flags);
bool neg = false;
if (val == INT_MAX) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MAX", flags);
return;
}
if (val < 0) {
if (val == INT_MIN) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MIN", flags);
return;
}
val = -val;
neg = true;
}
+13
View File
@@ -18,6 +18,7 @@
* GNU General Public License for more details.
*/
#include <limits.h>
#include "opentx.h"
#include "timers.h"
@@ -402,7 +403,19 @@ void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags, uint8_t le
int idx = 0;
int mode = MODE(flags);
bool neg = false;
if (val == INT_MAX) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MAX", flags);
return;
}
if (val < 0) {
if (val == INT_MIN) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MIN", flags);
return;
}
val = -val;
neg = true;
}
+13
View File
@@ -20,6 +20,7 @@
#include <math.h>
#include <stdio.h>
#include <limits.h>
#include "opentx.h"
#include "strhelpers.h"
@@ -165,7 +166,19 @@ void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags, uint8_t le
int idx = 0;
int mode = MODE(flags);
bool neg = false;
if (val == INT_MAX) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MAX", flags);
return;
}
if (val < 0) {
if (val == INT_MIN) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MIN", flags);
return;
}
val = -val;
neg = true;
}