Merge with master

This commit is contained in:
Sebastien
2020-01-15 12:23:55 -05:00
16 changed files with 119 additions and 18 deletions

View File

@@ -26,17 +26,19 @@
#include "embedded.h"
#include "display.h"
#define TAG "display"
static const char *TAG = "display";
static bool (*slimp_handler_chain)(u8_t *data, int len);
static struct display_handle_s *handle;
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);
/****************************************************************************************
*
*/
void display_init(void) {
void display_init(char *welcome) {
char *item = config_alloc_get(NVS_TYPE_STR, "display_config");
if (item && *item) {
@@ -52,15 +54,27 @@ void display_init(void) {
}
}else {
ESP_LOGE(TAG,"Unknown display driver name in display config: %s",item);
}
} else {
ESP_LOGW(TAG, "no display");
}
chained_notify = server_notify;
server_notify = server_attach;
if (item) free(item);
}
/****************************************************************************************
*
*/
static void server_attach(in_addr_t ip, u16_t hport, u16_t cport) {
char msg[32];
sprintf(msg, "%s:%hu", inet_ntoa(ip), hport);
handle->print_message(msg);
if (chained_notify) (*chained_notify)(ip, hport, cport);
}
/****************************************************************************************
* Process graphic display data
*/

View File

@@ -19,7 +19,8 @@
#pragma once
struct display_handle_s {
bool (*init)(char *config);
bool (*init)(char *config, char* welcome);
void (*print_message)(char *msg);
void (*vfdc_handler)(u8_t *data, int len);
void (*grfe_handler)(u8_t *data, int len);
void (*grfb_handler)(u8_t *data, int len);

View File

@@ -32,14 +32,16 @@
#define I2C_PORT 1
#define I2C_ADDRESS 0x3C
#define LINELEN 40
#define TAG "display"
static const char *TAG = "display";
static void vfdc_handler( u8_t *_data, int bytes_read);
void grfe_handler( u8_t *data, int len);
static bool display_init(char *config);
static void grfe_handler( u8_t *data, int len);
static bool display_init(char *config, char *welcome);
static void print_message(char *msg);
struct display_handle_s SSD1306_handle = {
display_init,
print_message,
vfdc_handler,
grfe_handler,
NULL, NULL,
@@ -71,7 +73,7 @@ static const unsigned char BitReverseTable256[] =
/****************************************************************************************
*
*/
static bool display_init(char *config) {
static bool display_init(char *config, char *welcome) {
bool res = false;
if (strstr(config, "I2C")) {
@@ -105,6 +107,7 @@ static bool display_init(char *config) {
}
}
if(res){
print_message(welcome);
ESP_LOGI(TAG, "Initialized I2C display %dx%d (sda:%d, scl:%d, address:%02x)", width, height, sda, scl, address);
} else {
ESP_LOGE(TAG, "Cannot initialized I2C display %s [%dx%d sda:%d, scl:%d, address:%02x]", config, width, height, sda, scl, address);
@@ -116,6 +119,19 @@ static bool display_init(char *config) {
return res;
}
/****************************************************************************************
*
*/
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 );
}
/****************************************************************************************
* Change special LCD chars to something more printable on screen
*/

View File

@@ -200,7 +200,8 @@ static bool SSD1306_Init( struct SSD1306_Device* DeviceHandle, int Width, int He
DeviceHandle->Height = Height;
DeviceHandle->FramebufferSize = ( DeviceHandle->Width * Height ) / 8;
DeviceHandle->Framebuffer = heap_caps_calloc( 1, DeviceHandle->FramebufferSize, MALLOC_CAP_DMA | MALLOC_CAP_8BIT );
// DeviceHandle->Framebuffer = heap_caps_calloc( 1, DeviceHandle->FramebufferSize, MALLOC_CAP_INTERNAL );
DeviceHandle->Framebuffer = calloc( 1, DeviceHandle->FramebufferSize );
NullCheck( DeviceHandle->Framebuffer, return false );

View File

@@ -19,7 +19,7 @@
#define BATTERY_TIMER (10*1000)
static const char TAG[] = "battery";
static const char *TAG = "battery";
static struct {
float sum, avg;

View File

@@ -21,7 +21,7 @@
#define MAX_LED 8
#define BLOCKTIME 10 // up to portMAX_DELAY
static const char TAG[] = "led";
static const char *TAG = "led";
static struct led_s {
gpio_num_t gpio;

View File

@@ -26,7 +26,7 @@
#define MONITOR_TIMER (10*1000)
static const char TAG[] = "monitor";
static const char *TAG = "monitor";
static TimerHandle_t monitor_timer;

View File

@@ -134,6 +134,8 @@ static void sendHELO(bool reconnect, const char *fixed_cap, const char *var_cap,
base_cap = BASE_CAP;
#endif
if (!reconnect) player_id = PLAYER_ID;
memset(&pkt, 0, sizeof(pkt));
memcpy(&pkt.opcode, "HELO", 4);
pkt.length = htonl(sizeof(struct HELO_packet) - 8 + strlen(base_cap) + strlen(fixed_cap) + strlen(var_cap));