tabs
This commit is contained in:
parent
163c788a45
commit
e5561f2555
@ -60,60 +60,60 @@ void dispSetDigit(uint8_t digit, uint8_t value) {
|
|||||||
|
|
||||||
|
|
||||||
void dispSetFloat(uint8_t unit, float value) {
|
void dispSetFloat(uint8_t unit, float value) {
|
||||||
if ((value < -99) || (value > 999)) {
|
if ((value < -99) || (value > 999)) {
|
||||||
dispSetError();
|
dispSetError();
|
||||||
} else {
|
} else {
|
||||||
bool neg = value < 0;
|
bool neg = value < 0;
|
||||||
value = (value < 0) ? -1 * value : value;
|
value = (value < 0) ? -1 * value : value;
|
||||||
uint16_t preComma = (uint16_t)value;
|
uint16_t preComma = (uint16_t)value;
|
||||||
uint16_t postComma = round16((value - (float)preComma) * 10);
|
uint16_t postComma = round16((value - (float)preComma) * 10);
|
||||||
if (postComma == 10) {
|
if (postComma == 10) {
|
||||||
postComma = 0;
|
postComma = 0;
|
||||||
preComma += 1;
|
preComma += 1;
|
||||||
}
|
}
|
||||||
if ((preComma == 0) && (postComma == 0)) {
|
if ((preComma == 0) && (postComma == 0)) {
|
||||||
neg = false;
|
neg = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t digit1 = postComma;
|
uint8_t digit1 = postComma;
|
||||||
|
|
||||||
uint8_t digit4 = preComma / 100;
|
uint8_t digit4 = preComma / 100;
|
||||||
uint8_t remVal = preComma - (digit4 * 100);
|
uint8_t remVal = preComma - (digit4 * 100);
|
||||||
uint8_t digit3 = remVal / 10;
|
uint8_t digit3 = remVal / 10;
|
||||||
remVal = remVal - (digit3 * 10);
|
remVal = remVal - (digit3 * 10);
|
||||||
uint8_t digit2 = remVal;
|
uint8_t digit2 = remVal;
|
||||||
|
|
||||||
if (digit4 == 0) {
|
if (digit4 == 0) {
|
||||||
if (neg) {
|
if (neg) {
|
||||||
digit4 = 0x0a;
|
digit4 = 0x0a;
|
||||||
} else {
|
|
||||||
digit4 = 0x0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (digit4 > 0x09 && digit3 == 0) {
|
|
||||||
if (neg) {
|
|
||||||
digit3 = 0x0a;
|
|
||||||
digit4 = 0x0f;
|
|
||||||
} else {
|
|
||||||
digit3 = 0x0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
digit2 |= 0x80;
|
|
||||||
|
|
||||||
if (unit == 0) {
|
|
||||||
spiXfer16(0x0100 | digit1);
|
|
||||||
spiXfer16(0x0200 | digit2);
|
|
||||||
spiXfer16(0x0300 | digit3);
|
|
||||||
spiXfer16(0x0400 | digit4);
|
|
||||||
} else {
|
} else {
|
||||||
spiXfer16(0x0500 | digit1);
|
digit4 = 0x0f;
|
||||||
spiXfer16(0x0600 | digit2);
|
|
||||||
spiXfer16(0x0700 | digit3);
|
|
||||||
spiXfer16(0x0800 | digit4);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (digit4 > 0x09 && digit3 == 0) {
|
||||||
|
if (neg) {
|
||||||
|
digit3 = 0x0a;
|
||||||
|
digit4 = 0x0f;
|
||||||
|
} else {
|
||||||
|
digit3 = 0x0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
digit2 |= 0x80;
|
||||||
|
|
||||||
|
if (unit == 0) {
|
||||||
|
spiXfer16(0x0100 | digit1);
|
||||||
|
spiXfer16(0x0200 | digit2);
|
||||||
|
spiXfer16(0x0300 | digit3);
|
||||||
|
spiXfer16(0x0400 | digit4);
|
||||||
|
} else {
|
||||||
|
spiXfer16(0x0500 | digit1);
|
||||||
|
spiXfer16(0x0600 | digit2);
|
||||||
|
spiXfer16(0x0700 | digit3);
|
||||||
|
spiXfer16(0x0800 | digit4);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispSet(uint8_t unit, int16_t value) {
|
void dispSet(uint8_t unit, int16_t value) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user