make it more or less work with 'warning_level=everything'
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
int lcd_open(struct lcd_t *lcd, bool reopen);
|
||||
void lcd_write(struct lcd_t *lcd, const uint8_t *cmdbuf, uint16_t len);
|
||||
|
||||
int lcd_open(struct lcd_t *lcd, const bool reopen) {
|
||||
applog(LOG_INF, "Opening serial port at %s", lcd->port);
|
||||
if (lcd->fd <= 0 || reopen)
|
||||
@@ -55,7 +58,7 @@ void lcd_set_backlight(struct lcd_t *lcd, const bool enabled) {
|
||||
}
|
||||
|
||||
void lcd_set_cursor(struct lcd_t *lcd, const uint8_t row, const uint8_t col) {
|
||||
const uint8_t cmdbuf[] = {254, 71, (col + 1), (row + 1)};
|
||||
const uint8_t cmdbuf[] = {254, 71, col + 1, row + 1};
|
||||
lcd_write(lcd, cmdbuf, sizeof(cmdbuf));
|
||||
}
|
||||
|
||||
@@ -84,13 +87,13 @@ void lcd_writef(struct lcd_t *lcd, const uint8_t x, const uint8_t y, const char
|
||||
char tmp[LCD_COLS + 1];
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
uint8_t len = vsnprintf(tmp, sizeof(tmp), fmt, ap); // print fmt and ap to a temporary buffer
|
||||
int len = vsnprintf(tmp, sizeof(tmp), fmt, ap); // print fmt and ap to a temporary buffer
|
||||
va_end(ap);
|
||||
len = MIN(len, LCD_COLS - x);
|
||||
int pos = 4 + x + (LCD_COLS * (y % 2)); // skip 4 bytes to leave room for set cursor command
|
||||
if (y >= 2)
|
||||
pos += 2 * LCD_COLS + 4; // if we're writing to disp2, skip another 4 bytes for set cursor command and 2*40 bytes of disp 1
|
||||
memcpy(lcd->writebuf.text + pos, tmp, len); // copy to lcd writebuffer address + whatever pos is
|
||||
memcpy(lcd->writebuf.text + pos, tmp, (size_t)len); // copy to lcd writebuffer address + whatever pos is
|
||||
}
|
||||
|
||||
inline void lcd_clear_buf(struct lcd_t *lcd) {
|
||||
|
||||
Reference in New Issue
Block a user