Fix iss#1492

Introduced lcd_strlen() and lcd_strlen_P().
Replaced the old functions where necessary.
Reworked language_ru.h.

Speeded up test for zero length string in cardreader.cpp
This commit is contained in:
AnHardt
2015-02-16 13:53:58 +01:00
parent 63a5ff7ab9
commit 6cdcd6c6d1
7 changed files with 61 additions and 36 deletions

View File

@ -1260,6 +1260,26 @@ void lcd_init()
#endif
}
int lcd_strlen(char *s) {
int i = 0, j = 0;
while (s[i]) {
if ((s[i] & 0xc0) != 0x80) j++;
i++;
}
return j;
}
int lcd_strlen_P(const char *s) {
int j = 0;
while (pgm_read_byte(s)) {
if ((pgm_read_byte(s) & 0xc0) != 0x80) j++;
s++;
}
return j;
}
void lcd_update()
{
static unsigned long timeoutToStatus = 0;
@ -1372,7 +1392,7 @@ void lcd_ignore_click(bool b)
}
void lcd_finishstatus() {
int len = strlen(lcd_status_message);
int len = lcd_strlen(lcd_status_message);
if (len > 0) {
while (len < LCD_WIDTH) {
lcd_status_message[len++] = ' ';