brightness

This commit is contained in:
philippe44
2020-01-18 01:05:59 -08:00
parent 452e38a04b
commit 10ea98f061
6 changed files with 28 additions and 4 deletions

View File

@@ -106,6 +106,8 @@ static bool display_handler(u8_t *data, int len){
handle->vfdc_handler(data, len);
} else if (!strncmp((char*) data, "grfe", 4)) {
handle->grfe_handler(data, len);
} else if (!strncmp((char*) data, "grfb", 4)) {
handle->grfb_handler(data, len);
} else {
res = false;
}

View File

@@ -36,6 +36,7 @@ static const char *TAG = "display";
static void vfdc_handler( u8_t *_data, int bytes_read);
static void grfe_handler( u8_t *data, int len);
static void grfb_handler( u8_t *data, int len);
static bool display_init(char *config, char *welcome);
static void print_message(char *msg);
@@ -44,6 +45,7 @@ struct display_handle_s SSD1306_handle = {
print_message,
vfdc_handler,
grfe_handler,
grfb_handler,
NULL, NULL,
};
@@ -243,7 +245,7 @@ static void vfdc_handler( u8_t *_data, int bytes_read) {
/****************************************************************************************
* Process graphic display data
*/
void grfe_handler( u8_t *data, int len) {
static void grfe_handler( u8_t *data, int len) {
data += 8;
len -= 8;
@@ -293,4 +295,20 @@ void grfe_handler( u8_t *data, int len) {
#endif
}
/****************************************************************************************
* Process graphic display data
*/
static void grfb_handler(u8_t *data, int len) {
s16_t brightness = htons(*(uint16_t*) (data + 4));
ESP_LOGI(TAG, "brightness %hx", brightness);
if (brightness < 0) {
SSD1306_DisplayOff( &Display );
} else {
SSD1306_DisplayOn( &Display );
SSD1306_SetContrast( &Display, brightness * 256 / 4 - 1);
}
}