Compare commits
2 Commits
ab4674f6f4
...
106de77287
| Author | SHA1 | Date | |
|---|---|---|---|
| 106de77287 | |||
| 84b8207531 |
@@ -22,6 +22,7 @@ void lcd_close(struct lcd_t *lcd);
|
||||
void lcd_clear(struct lcd_t *lcd);
|
||||
void lcd_set_contrast(struct lcd_t *lcd, uint8_t contrast);
|
||||
void lcd_set_backlight(struct lcd_t *lcd, bool enabled);
|
||||
void lcd_set_brightness(struct lcd_t *lcd, uint8_t brightness);
|
||||
void lcd_set_cursor(struct lcd_t *lcd, uint8_t row, uint8_t col);
|
||||
void lcd_set_custom_char(struct lcd_t *lcd, uint8_t index, const lcd_glyph_t *glyph);
|
||||
void lcd_write_buf(struct lcd_t *lcd, uint8_t row, uint8_t col, const char *str);
|
||||
@@ -31,4 +32,4 @@ void lcd_flush_buf(struct lcd_t *lcd);
|
||||
char lcd_bar(struct lcd_t *lcd, uint8_t char_id, double value);
|
||||
int lcd_init(struct lcd_t *lcd);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "log.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
@@ -58,6 +59,12 @@ void lcd_set_backlight(struct lcd_t *lcd, const bool enabled) {
|
||||
lcd_write(lcd, cmdbuf, enabled ? 3 : 2);
|
||||
}
|
||||
|
||||
void lcd_set_brightness(struct lcd_t *lcd, const uint8_t brightness) {
|
||||
applog(LOG_INF, "Set backlight brightness to %d", brightness);
|
||||
const uint8_t cmdbuf[] = {0xFE, 152, brightness};
|
||||
lcd_write(lcd, cmdbuf, 3);
|
||||
}
|
||||
|
||||
void lcd_set_cursor(struct lcd_t *lcd, const uint8_t row, const uint8_t col) {
|
||||
const uint8_t cmdbuf[] = {0xFE, 71, col + 1, row + 1};
|
||||
lcd_write(lcd, cmdbuf, sizeof(cmdbuf));
|
||||
@@ -138,4 +145,4 @@ int lcd_init(struct lcd_t *lcd) {
|
||||
|
||||
lcd_clear(lcd);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ static void *display_thread(void *arg) {
|
||||
.baud = 0010002, // from termios-baud.h, B115200
|
||||
};
|
||||
lcd_init(&lcd);
|
||||
lcd_set_brightness(&lcd, 255);
|
||||
lcd_set_backlight(&lcd, true);
|
||||
lcd_set_contrast(&lcd, lcd_contrast);
|
||||
|
||||
@@ -175,7 +176,6 @@ static void *display_thread(void *arg) {
|
||||
}
|
||||
|
||||
lcd_write_buf(&lcd, 2, 16, "Goodbye"); // center
|
||||
lcd_set_backlight(&lcd, false);
|
||||
lcd_flush_buf(&lcd);
|
||||
lcd_close(&lcd);
|
||||
applog(LOG_WRN, "display thread stopped");
|
||||
|
||||
Reference in New Issue
Block a user