12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #include <string.h>
- #include <ctype.h>
- #include <stdint.h>
- #include <arpa/inet.h>
- #include "esp_log.h"
- #include "config.h"
- #include "embedded.h"
- #include "display.h"
- #define TAG "display"
- static bool (*slimp_handler_chain)(u8_t *data, int len);
- static struct display_handle_s *handle;
- static bool display_handler(u8_t *data, int len);
- void display_init(void) {
- char *item = config_alloc_get(NVS_TYPE_STR, "display_config");
- if (item && *item) {
- handle = &SSD1306_handle;
- if (handle->init(item)) {
- slimp_handler_chain = slimp_handler;
- slimp_handler = display_handler;
- ESP_LOGI(TAG, "Display initialization successful");
- } else {
- ESP_LOGI(TAG, "Display initialization failed");
- }
- } else {
- ESP_LOGI(TAG, "no display");
- }
- if (item) free(item);
- }
- static bool display_handler(u8_t *data, int len){
- bool res = true;
- if (!strncmp((char*) data, "vfdc", 4)) {
- handle->vfdc_handler(data, len);
- } else if (!strncmp((char*) data, "grfe", 4)) {
- handle->grfe_handler(data, len);
- } else {
- res = false;
- }
-
-
- if (*slimp_handler_chain) res |= (*slimp_handler_chain)(data, len);
- return res;
- }
|