ts dont run bri

This commit is contained in:
2026-05-02 20:32:47 +02:00
parent 96e14ed6ea
commit a90a65ba96
3 changed files with 67 additions and 5 deletions

View File

@@ -5,6 +5,8 @@
#include "log.h"
#include "lcd.h"
#include <stdio.h>
#define MIN(a,b) ((a) < (b) ? (a) : (b))
int lcd_open(struct lcd_t* lcd, const bool reopen) {
@@ -84,6 +86,22 @@ void lcd_write_buf(struct lcd_t* lcd, const uint8_t row, const uint8_t col, cons
memcpy(&lcd->writebuf[pos], str, len);
}
int lcd_writef(struct lcd_t *lcd, uint8_t offset, const char *fmt, ...)
__attribute__((format(printf, 3, 4)));
int lcd_writef(struct lcd_t *lcd, uint8_t offset, const char *fmt, ...) {
char tmp[LCD_COLS + 1];
va_list ap;
va_start(ap, fmt);
int len = vsnprintf(tmp, sizeof(tmp), fmt, ap);
va_end(ap);
if (len <= 0) return -1;
if (offset + len > LCD_COLS) len = LCD_COLS - offset; /* clamp to buffer */
memcpy(lcd->writebuf + offset, tmp, len);
return len;
}
void lcd_clear_buf(struct lcd_t* lcd) {
memset(lcd->writebuf, ' ', sizeof(lcd->writebuf));