return false on input error
This commit is contained in:
parent
d0a713a98e
commit
8e65cff24d
|
@ -221,15 +221,16 @@ void led_max7219_intensity(uint8_t intensity)
|
||||||
led_max7219_write(0x0A00+intensity); // set brightness
|
led_max7219_write(0x0A00+intensity); // set brightness
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_max7219_text(char* text)
|
bool led_max7219_text(char* text)
|
||||||
{
|
{
|
||||||
for (uint8_t i=0; i<8; i++) { // input text should only contain printable character (8th bit is used for dots)
|
for (uint8_t i=0; i<8; i++) { // input text should only contain printable character (8th bit is used for dots)
|
||||||
if ((text[i]&0x7f)<' ' || (text[i]&0x7f)>=' '+LENGTH(ascii_7segments)) {
|
if ((text[i]&0x7f)<' ' || (text[i]&0x7f)>=' '+LENGTH(ascii_7segments)) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
led_max7219_write(0x0900); // disable BCD decoding on all 7 digits
|
led_max7219_write(0x0900); // disable BCD decoding on all 7 digits
|
||||||
for (uint8_t i=0; i<8; i++) { // display text
|
for (uint8_t i=0; i<8; i++) { // display text
|
||||||
led_max7219_write(((i+1)<<8)+(ascii_7segments[(text[7-i]&0x7f)-' '])+(text[7-i]&0x80)); // send digit (in reverse order)
|
led_max7219_write(((i+1)<<8)+(ascii_7segments[(text[7-i]&0x7f)-' '])+(text[7-i]&0x80)); // send digit (in reverse order)
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ void led_max7219_intensity(uint8_t intensity);
|
||||||
/** display text
|
/** display text
|
||||||
* @param[in] text text to display (8 characters)
|
* @param[in] text text to display (8 characters)
|
||||||
* @note use first bit of each character to enable dot
|
* @note use first bit of each character to enable dot
|
||||||
|
* @return false if string has unsupported characters
|
||||||
*/
|
*/
|
||||||
void led_max7219_text(char* text);
|
bool led_max7219_text(char* text);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue