1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-21 15:25:17 +03:00

Re #1458 - the cast is back, but cast to different type depending on platform. Gtest modernized.

This commit is contained in:
Damjan Adamic 2014-07-06 09:11:29 +02:00
parent ed094f89e8
commit 7130e48089
3 changed files with 10 additions and 20 deletions

View file

@ -57,8 +57,10 @@
#if defined(CPUARM)
#define lcdint_t int32_t
#define lcduint_t uint32_t
#else
#define lcdint_t int16_t
#define lcduint_t uint16_t
#endif
#define FW 6

View file

@ -276,11 +276,7 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t
if (mode != MODE(LEADING0)) {
len = 1;
#if defined(CPUARM)
uint32_t tmp = ((uint32_t)val) / 10;
#else
uint16_t tmp = ((uint16_t)val) / 10;
#endif
lcduint_t tmp = ((lcduint_t)val) / 10;
while (tmp) {
len++;
tmp /= 10;
@ -324,13 +320,13 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t
if (dblsize) x++;
for (uint8_t i=1; i<=len; i++) {
div_t qr = div(val, 10);
div_t qr = div((lcduint_t)val, 10);
char c = qr.rem + '0';
LcdFlags f = flags;
#if !defined(PCBTARANIS)
if (dblsize) {
if (c=='1' && i==len && xn>x+10) { x+=1; }
if (val >= 1000) { x+=FWNUM; f&=~DBLSIZE; }
if ((lcduint_t)val >= 1000) { x+=FWNUM; f&=~DBLSIZE; }
}
#endif
lcd_putcAtt(x, y, c, f);
@ -379,7 +375,7 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t
}
}
#if !defined(PCBTARANIS)
if (dblsize && val >= 1000 && val < 10000) x-=2;
if (dblsize && (lcduint_t)val >= 1000 && (lcduint_t)val < 10000) x-=2;
#endif
val = qr.quot;
x -= fw;

View file

@ -47,6 +47,8 @@
#define CHANNEL_MAX (1024*256)
void doMixerCalculations();
bool checkScreenshot(QString test);
#define MODEL_RESET() \
memset(&g_model, 0, sizeof(g_model)); \
@ -136,19 +138,9 @@ TEST(Trims, CopySticksToOffset)
TEST(outdezNAtt, test_unsigned)
{
uint8_t refBuf[sizeof(displayBuf)];
memset(displayBuf, 0, sizeof(displayBuf));
lcd_putc(0*FWNUM, 0, '6');
lcd_putc(1*FWNUM, 0, '5');
lcd_putc(2*FWNUM, 0, '5');
lcd_putc(3*FWNUM, 0, '3');
lcd_putc(4*FWNUM, 0, '0');
memcpy(refBuf, displayBuf, sizeof(displayBuf));
memset(displayBuf, 0, sizeof(displayBuf));
lcd_clear();
lcd_outdezNAtt(0, 0, 65530, LEFT|UNSIGN);
EXPECT_EQ(memcmp(refBuf, displayBuf, sizeof(displayBuf)), 0) << "Unsigned numbers will be bad displayed";
EXPECT_TRUE(checkScreenshot("unsigned")) << "Unsigned numbers will be bad displayed";
}
#if !defined(PCBSKY9X)