
If I found the makefile, should I just replace it with the one I recently used or should I do something else???
/*
* display unsigned value plus unit (character)
* - scales value to max. 4 digits excluding "." and unit
*
* requires:
* - unsigned value
* - exponent of factor related to base unit (value * 10^x)
* e.g: p = 10^-12 -> -12
* - unit character (0 = none)
*/
void Display_Value(uint32_t Value, int8_t Exponent, unsigned char Unit)
{
unsigned char Prefix = 0; /* prefix character */
uint8_t Offset = 0; /* exponent offset to lower 10^3 step */
uint8_t Index; /* index ID */
uint8_t Length; /* string length */
/* scale value down to 4 digits */
while (Value >= 10000)
{
Value += 5; /* for automagic rounding */
Value = Value / 10; /* scale down by 10^1 */
Exponent++; /* increase exponent by 1 */
}
/*
* determine prefix and offset (= number of digits right of dot)
*/
if (Exponent >= -15) /* prevent index underflow */
{
Exponent += 15; /* shift exponent to be >= 0 */
Index = Exponent / 3; /* number of 10^3 steps */
Offset = Exponent % 3; /* offset to lower 10^3 step */
if (Offset > 0 || !UpScaleReadout) /* dot required */
{
Index++; /* upscale prefix */
Offset = 3 - Offset; /* reverse value (1 or 2) */
}
/* look up prefix in table */
if (Index < NUM_PREFIXES) /* prevent array overflow */
{
Prefix = DATA_read_byte(&Prefix_table[Index]);
}
}
/*
* display value
*/
#ifdef UI_COLORED_VALUES
Display_UseValueColor(); /* set value color */
#endif
/* convert value into string */
utoa((uint16_t)Value, OutBuffer, 10); /* radix 10: max. 5 chars + /0 */
Length = strlen(OutBuffer); /* get string length */
/* we misuse Exponent for the dot position */
Exponent = Length - Offset; /* calculate position */
if (Exponent <= 0) /* we have to prepend "0." */
{
/* 0: factor 10 / -1: factor 100 */
Display_Char('0'); /* display: 0 */
#ifdef UI_COMMA
Display_Char(','); /* display: , */
#else
Display_Char('.'); /* display: . */
#endif
if (Exponent < 0) /* factor 100 */
{
Display_Char('0'); /* additional 0 */
}
}
if (Offset == 0) /* no dot needed */
{
Exponent = -1; /* disable dot */
}
/* adjust position to match array or disable dot if set to 0 */
Exponent--;
/* display value and add dot if requested */
Index = 0;
while (Index < Length) /* loop through string */
{
Display_Char(OutBuffer[Index]); /* display char/digit */
if (Index == Exponent) /* starting point of decimal fraction */
{
#ifdef UI_COMMA
Display_Char(','); /* display: , */
#else
Display_Char('.'); /* display: . */
#endif
}
Index++; /* next one */
}
#ifdef UI_COLORED_VALUES
Display_UseOldColor(); /* reset pen color */
#endif
/* display prefix and unit */
if (Prefix) Display_Char(Prefix);
if (Unit) Display_Char(Unit);
UpScaleReadout = 1; /* disable scaling flag */
}
void Show_SingleResistor(uint8_t ID1, uint8_t ID2)
{
Resistor_Type *Resistor; /* pointer to resistor */
Resistor = &Resistors[0]; /* pointer to first resistor */
/* show pinout */
Display_Char(ID1);
Display_EEString(Resistor_str);
Display_Char(ID2);
/* show resistance value */
Display_Space();
UpScaleReadout = 0;
Display_Value(Resistor->Value, Resistor->Scale, LCD_CHAR_OMEGA);
}
The only value looking a bit strange should be T6 (Rh+) in the self test. It's near Vcc, e.g. 4990. 4990 would become 4.980k (because it's just a plain number).
@all: Please tell me if you encounter other strange values when testing the modification for 4-digit values!