mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 03:57:07 +03:00
brightness
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user