mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 20:17:04 +03:00
Merge branch 'master' of https://github.com/sle118/squeezelite-esp32.git
Conflicts: components/display/driver_SSD1306.c
This commit is contained in:
@@ -62,6 +62,7 @@ static esp_err_t i2c_master_driver_install(){
|
||||
if((err=i2c_driver_install(i2c_port, I2C_MODE_MASTER, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0))!=ESP_OK){
|
||||
ESP_LOGW(TAG,"i2c driver was already installed. Deleting it.");
|
||||
i2c_driver_delete(i2c_port);
|
||||
ESP_LOGW(TAG,"Installing i2c driver on port %u",i2c_port);
|
||||
if((err=i2c_driver_install(i2c_port, I2C_MODE_MASTER, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0))!=ESP_OK){
|
||||
ESP_LOGE(TAG,"Driver install failed. %s", esp_err_to_name(err));
|
||||
}
|
||||
|
||||
@@ -35,6 +35,27 @@ static void (*chained_notify)(in_addr_t ip, u16_t hport, u16_t cport);
|
||||
static void server_attach(in_addr_t ip, u16_t hport, u16_t cport);
|
||||
static bool display_handler(u8_t *data, int len);
|
||||
|
||||
/* scrolling undocumented information
|
||||
grfs
|
||||
B: screen number
|
||||
B:1 = left, 2 = right,
|
||||
Q: scroll pause once done (ms)
|
||||
Q: scroll speed (ms)
|
||||
W: # of pixels to scroll each time
|
||||
W: 0 = continue scrolling after pause, 1 = scroll to scrollend and then stop, 2 = scroll to scrollend and then end animation (causing new update)
|
||||
W: width of total scroll area in pixels
|
||||
|
||||
grfd
|
||||
W: screen number
|
||||
W: width of scrollable area in pixels
|
||||
|
||||
ANIC flags
|
||||
ANIM_TRANSITION 0x01 # A transition animation has finished
|
||||
ANIM_SCROLL_ONCE 0x02 # A scrollonce has finished
|
||||
ANIM_SCREEN_1 0x04 # For scrollonce only, screen 1 was scrolling
|
||||
ANIM_SCREEN_2 0x08 # For scrollonce only, screen 2 was scrolling
|
||||
*/
|
||||
|
||||
/****************************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -47,7 +47,7 @@ struct display_handle_s SSD1306_handle = {
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
static struct SSD1306_Device I2CDisplay;
|
||||
static struct SSD1306_Device Display;
|
||||
static SSD1306_AddressMode AddressMode = AddressMode_Invalid;
|
||||
|
||||
static const unsigned char BitReverseTable256[] =
|
||||
@@ -88,10 +88,10 @@ static bool display_init(char *config, char *welcome) {
|
||||
|
||||
if (width != -1 && height != -1) {
|
||||
SSD1306_I2CMasterInitDefault( i2c_system_port, -1, -1 ) ;
|
||||
SSD1306_I2CMasterAttachDisplayDefault( &I2CDisplay, width, height, address, -1 );
|
||||
SSD1306_SetHFlip( &I2CDisplay, strcasestr(config, "HFlip") ? true : false);
|
||||
SSD1306_SetVFlip( &I2CDisplay, strcasestr(config, "VFlip") ? true : false);
|
||||
SSD1306_SetFont( &I2CDisplay, &Font_droid_sans_fallback_15x17 );
|
||||
SSD1306_I2CMasterAttachDisplayDefault( &Display, width, height, address, -1 );
|
||||
SSD1306_SetHFlip( &Display, strcasestr(config, "HFlip") ? true : false);
|
||||
SSD1306_SetVFlip( &Display, strcasestr(config, "VFlip") ? true : false);
|
||||
SSD1306_SetFont( &Display, &Font_droid_sans_fallback_15x17 );
|
||||
print_message(welcome);
|
||||
ESP_LOGI(TAG, "Initialized I2C display %dx%d", width, height);
|
||||
res = true;
|
||||
@@ -111,11 +111,11 @@ static bool display_init(char *config, char *welcome) {
|
||||
static void print_message(char *msg) {
|
||||
if (!msg) return;
|
||||
SSD1306_AddressMode Mode = AddressMode;
|
||||
SSD1306_Clear( &I2CDisplay, SSD_COLOR_BLACK );
|
||||
SSD1306_SetDisplayAddressMode( &I2CDisplay, AddressMode_Horizontal );
|
||||
SSD1306_FontDrawAnchoredString( &I2CDisplay, TextAnchor_Center, msg, SSD_COLOR_WHITE );
|
||||
SSD1306_Update( &I2CDisplay );
|
||||
SSD1306_SetDisplayAddressMode( &I2CDisplay, Mode );
|
||||
SSD1306_Clear( &Display, SSD_COLOR_BLACK );
|
||||
SSD1306_SetDisplayAddressMode( &Display, AddressMode_Horizontal );
|
||||
SSD1306_FontDrawAnchoredString( &Display, TextAnchor_Center, msg, SSD_COLOR_WHITE );
|
||||
SSD1306_Update( &Display );
|
||||
SSD1306_SetDisplayAddressMode( &Display, Mode );
|
||||
}
|
||||
|
||||
/****************************************************************************************
|
||||
@@ -180,17 +180,17 @@ static void show_display_buffer(char *ddram) {
|
||||
|
||||
ESP_LOGI(TAG, "\n\t%.40s\n\t%.40s", line1, line2);
|
||||
|
||||
SSD1306_Clear( &I2CDisplay, SSD_COLOR_BLACK );
|
||||
SSD1306_FontDrawAnchoredString( &I2CDisplay, TextAnchor_NorthWest, line1, SSD_COLOR_WHITE );
|
||||
SSD1306_FontDrawAnchoredString( &I2CDisplay, TextAnchor_SouthWest, line2, SSD_COLOR_WHITE );
|
||||
SSD1306_Clear( &Display, SSD_COLOR_BLACK );
|
||||
SSD1306_FontDrawAnchoredString( &Display, TextAnchor_NorthWest, line1, SSD_COLOR_WHITE );
|
||||
SSD1306_FontDrawAnchoredString( &Display, TextAnchor_SouthWest, line2, SSD_COLOR_WHITE );
|
||||
|
||||
// check addressing mode by rows
|
||||
if (AddressMode != AddressMode_Horizontal) {
|
||||
AddressMode = AddressMode_Horizontal;
|
||||
SSD1306_SetDisplayAddressMode( &I2CDisplay, AddressMode );
|
||||
SSD1306_SetDisplayAddressMode( &Display, AddressMode );
|
||||
}
|
||||
|
||||
SSD1306_Update( &I2CDisplay );
|
||||
SSD1306_Update( &Display );
|
||||
}
|
||||
|
||||
/****************************************************************************************
|
||||
@@ -247,16 +247,47 @@ void grfe_handler( u8_t *data, int len) {
|
||||
data += 8;
|
||||
len -= 8;
|
||||
|
||||
#ifndef FULL_REFRESH
|
||||
// force addressing mode by lines
|
||||
if (AddressMode != AddressMode_Horizontal) {
|
||||
AddressMode = AddressMode_Horizontal;
|
||||
SSD1306_SetDisplayAddressMode( &Display, AddressMode );
|
||||
}
|
||||
|
||||
// try to minmize I2C traffic which is very slow
|
||||
int rows = Display.Height / 8;
|
||||
for (int r = 0; r < rows; r++) {
|
||||
uint8_t first = 0, last;
|
||||
uint8_t *optr = Display.Framebuffer + r*Display.Width, *iptr = data + r;
|
||||
|
||||
// row/col swap, frame buffr comparison and bit-reversing
|
||||
for (int c = 0; c < Display.Width; c++) {
|
||||
if (*iptr != *optr) {
|
||||
if (first) last = c;
|
||||
else first = c;
|
||||
}
|
||||
*optr++ = BitReverseTable256[*iptr];
|
||||
iptr += rows;
|
||||
}
|
||||
|
||||
// now update the display by "byte rows"
|
||||
if (first--) {
|
||||
SSD1306_SetColumnAddress( &Display, first, last );
|
||||
SSD1306_SetPageAddress( &Display, r, r);
|
||||
SSD1306_WriteRawData( &Display, Display.Framebuffer + r*Display.Width + first, last - first + 1);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// to be verified, but this is as fast as using a pointer on data
|
||||
for (int i = len - 1; i >= 0; i--) data[i] = BitReverseTable256[data[i]];
|
||||
|
||||
// check addressing mode by columns
|
||||
|
||||
// force addressing mode by columns
|
||||
if (AddressMode != AddressMode_Vertical) {
|
||||
AddressMode = AddressMode_Vertical;
|
||||
SSD1306_SetDisplayAddressMode( &I2CDisplay, AddressMode );
|
||||
SSD1306_SetDisplayAddressMode( &Display, AddressMode );
|
||||
}
|
||||
|
||||
SSD1306_WriteRawData( &I2CDisplay, data, len);
|
||||
SSD1306_WriteRawData( &Display, data, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
//#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@@ -68,18 +68,18 @@ static const char * TAG = "audio controls";
|
||||
static actrls_config_t *json_config;
|
||||
static actrls_t default_controls, current_controls;
|
||||
|
||||
static void control_handler(void *id, button_event_e event, button_press_e press, bool long_press) {
|
||||
actrls_config_t *key = (actrls_config_t*) id;
|
||||
static void control_handler(void *client, button_event_e event, button_press_e press, bool long_press) {
|
||||
actrls_config_t *key = (actrls_config_t*) client;
|
||||
actrls_action_e action;
|
||||
|
||||
switch(press) {
|
||||
case BUTTON_NORMAL:
|
||||
if (long_press) action = key->longpress[event == BUTTON_PRESSED ? 0 : 1];
|
||||
else action = key->normal[event == BUTTON_PRESSED ? 0 : 1];
|
||||
if (long_press) action = key->longpress[event == BUTTON_PRESSED ? 0 : 1].action;
|
||||
else action = key->normal[event == BUTTON_PRESSED ? 0 : 1].action;
|
||||
break;
|
||||
case BUTTON_SHIFTED:
|
||||
if (long_press) action = key->longshifted[event == BUTTON_PRESSED ? 0 : 1];
|
||||
else action = key->shifted[event == BUTTON_PRESSED ? 0 : 1];
|
||||
if (long_press) action = key->longshifted[event == BUTTON_PRESSED ? 0 : 1].action;
|
||||
else action = key->shifted[event == BUTTON_PRESSED ? 0 : 1].action;
|
||||
break;
|
||||
default:
|
||||
action = ACTRLS_NONE;
|
||||
@@ -88,8 +88,11 @@ static void control_handler(void *id, button_event_e event, button_press_e press
|
||||
|
||||
ESP_LOGD(TAG, "control gpio:%u press:%u long:%u event:%u action:%u", key->gpio, press, long_press, event, action);
|
||||
|
||||
if (action != ACTRLS_NONE) {
|
||||
ESP_LOGD(TAG, " calling action %u", action);
|
||||
if (action > ACTRLS_MAX) {
|
||||
// need to do the remap here
|
||||
ESP_LOGD(TAG, "remapping buttons");
|
||||
} else if (action != ACTRLS_NONE) {
|
||||
ESP_LOGD(TAG, "calling action %u", action);
|
||||
if (current_controls[action]) (*current_controls[action])();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,14 +31,17 @@ typedef void (*actrls_handler)(void);
|
||||
typedef actrls_handler actrls_t[ACTRLS_MAX - ACTRLS_NONE - 1];
|
||||
|
||||
// BEWARE any change to struct below must be mapped to actrls_config_map
|
||||
typedef struct {
|
||||
typedef struct actrl_config_s {
|
||||
int gpio;
|
||||
int type;
|
||||
bool pull;
|
||||
int debounce;
|
||||
int long_press;
|
||||
int shifter_gpio;
|
||||
actrls_action_e normal[2], longpress[2], shifted[2], longshifted[2]; // [0] keypressed, [1] keyreleased
|
||||
union {
|
||||
actrls_action_e action;
|
||||
struct actrl_config_s *config;
|
||||
} normal[2], longpress[2], shifted[2], longshifted[2]; // [0] keypressed, [1] keyreleased
|
||||
} actrls_config_t;
|
||||
|
||||
esp_err_t actrls_init(int n, const actrls_config_t *config);
|
||||
|
||||
@@ -28,7 +28,7 @@ static const char *TAG = "services";
|
||||
*
|
||||
*/
|
||||
void services_init(void) {
|
||||
int scl = -1, sda = -1, i2c_speed = 250000;
|
||||
int scl = -1, sda = -1, i2c_speed = 400000;
|
||||
char *nvs_item, *p;
|
||||
|
||||
gpio_install_isr_service(0);
|
||||
|
||||
@@ -362,6 +362,7 @@ td.value {
|
||||
|
||||
iframe#dummyframe {
|
||||
float: right;
|
||||
border: none;
|
||||
}
|
||||
|
||||
div#message {
|
||||
|
||||
Reference in New Issue
Block a user