Conflicts:
	components/display/driver_SSD1306.c
This commit is contained in:
Sebastien
2020-01-15 20:58:02 -05:00
7 changed files with 92 additions and 32 deletions

View File

@@ -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])();
}
}

View File

@@ -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);

View File

@@ -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);