Fixes in XGauge for fixed-point integer math functions
ElemXGaugeDrawRadial(), ElemXGaugeDrawRamp()
@@ -543,12 +543,13 @@ bool gslc_ElemXGaugeDrawRadial(gslc_tsGui* pGui,gslc_tsElemRef* pElemRef,gslc_te
}
// Support reversing of direction
+ // TODO: Clean up excess integer typecasting
if (pGauge->bFlip) {
- n64Ang = (nMax - nVal )* 360*64 /nRng;
- n64AngLast = (nMax - nValLast)* 360*64 /nRng;
+ n64Ang = (int32_t)(nMax - nVal )* 360*64 /nRng;
+ n64AngLast = (int32_t)(nMax - nValLast)* 360*64 /nRng;
} else {
- n64Ang = (nVal - nMin)* 360*64 /nRng;
- n64AngLast = (nValLast - nMin)* 360*64 /nRng;
+ n64Ang = (int32_t)(nVal - nMin)* 360*64 /nRng;
+ n64AngLast = (int32_t)(nValLast - nMin)* 360*64 /nRng;
}
// Clear old
@@ -598,7 +599,7 @@ bool gslc_ElemXGaugeDrawRamp(gslc_tsGui* pGui,gslc_tsElemRef* pElemRef,gslc_teRe
return false;
}
- uint16_t nSclFX;
+ uint32_t nSclFX;
uint16_t nHeight;
int32_t nHeightTmp;
uint16_t nHeightBot;
@@ -643,7 +644,7 @@ bool gslc_ElemXGaugeDrawRamp(gslc_tsGui* pGui,gslc_tsElemRef* pElemRef,gslc_teRe
nPosXStart = (nValStart - nMin)*nElemW/nRng;
nPosXEnd = (nValEnd - nMin)*nElemW/nRng;
- nSclFX = nElemH*32767/(nElemW*nElemW);
+ nSclFX = (uint32_t)nElemH*32767/(nElemW*nElemW);
for (nX=nPosXStart;nX<nPosXEnd;nX++) {
nInd = nElemW-nX;
@@ -671,7 +672,7 @@ bool gslc_ElemXGaugeDrawRamp(gslc_tsGui* pGui,gslc_tsElemRef* pElemRef,gslc_teRe
if (nSegOffset <= nBlockLen) {
// Inside block
- nColInd = nSegStart*1000/nElemW;
+ nColInd = (uint32_t)nSegStart*1000/nElemW;
nCol = gslc_ColorBlend3(GSLC_COL_GREEN,GSLC_COL_YELLOW,GSLC_COL_RED,500,nColInd);
} else {
