I have a requirement where an event has char *newvalue
.
void event(char *newValue) {
//Code here
}
newValue
is 2 digits. If it's 1-9 it is " 1" " 2" and 10+ is "10" "11" etc. It also can contain alpha characters as well not just numbers.
I am passing this to a function void function(uint8_t ascii)
to display on a single digit display. If I pass newValue
it doesn't register less than 10 as it picks up the space.
So what I am trying to achieve is if it's a single character, strip the space somehow into a uint8_t
and if it's 2 digits strip just the right digit as a uint_8
and have a bool where I will turn on the decimal point.
I've googled like crazy and can't seem to get something workable. If somebody can help it would be appreciated. If the above is not clear please let me know what more info you need.
The code below, 'value here' is where I want to put the rightmost value from *newvalue
.
void onUfcComm2DisplayChange(char *newValue) {
comdisp.setBrightness(9);
comdisp.writeDigitAscii(0, 'valuehere');
comdisp.writeDisplay();
}
void Adafruit_AlphaNum4::writeDigitAscii(uint8_t n, uint8_t a, boolean d, boolean w) {
uint16_t font;
if (w == false) {
font = pgm_read_word(alphafonttable + a);
} else {
font = pgm_read_word(alphafonttableWD + a);
}
displaybuffer[n] = font;
if (d) displaybuffer[n] |= (1 << 14);
}