updated interface, added M5Stick (PLUS) support

This commit is contained in:
Lurkars
2020-12-12 14:26:08 +01:00
parent 559ed3762a
commit 0d3fd854f8
43 changed files with 2832 additions and 313 deletions
+127
View File
@@ -16,6 +16,8 @@
#include "display.h"
#include "display-gfx.h"
static uint16_t current_color = WHITE;
uint8_t display_utf8_to_ascii_char(uint8_t ascii)
{
static uint8_t c1;
@@ -87,4 +89,129 @@ void display_chars(char *text, size_t length, uint8_t line, uint8_t offset, bool
display_data(textdata, res_length, line, offset * font_width, invert);
free(textdata);
}
}
void display_text_line_column(char *text, uint8_t line, uint8_t offset, bool invert)
{
display_chars(text, strlen(text), line, offset, invert);
}
void display_text_line(char *text, uint8_t line, bool invert)
{
display_text_line_column(text, line, 0, invert);
}
void display_text_input(char *text, uint8_t position)
{
size_t start = 0;
if (position > 13)
{
position = 13;
start = position - 13;
}
uint8_t cur_char = (uint8_t)text[start + position] - 32;
// arrow
display_data(display_gfx_arrow_left, 8, 2, 0, false);
// bounday
display_text_line_column("______________", 2, 1, false);
// arrow
display_data(display_gfx_arrow_right, 8, 2, 15 * 8, false);
// text
size_t text_length = strlen(text);
if (strlen(text) > 14)
{
text_length = 14;
}
size_t length = 0;
uint8_t *textdata = display_text_to_data(text, text_length, &length);
display_data(textdata, length, 2, 8, true);
free(textdata);
// arrow
display_data(display_gfx_arrow_up, 8, 0, (position + 1) * 8, false);
// upper char
display_data(display_gfx_font[cur_char - 1], 8, 1, (position + 1) * 8, false);
// sel char
display_data(display_gfx_font[cur_char], 8, 2, (position + 1) * 8, false);
// lower char
display_data(display_gfx_font[cur_char + 1], 8, 3, (position + 1) * 8, false);
// arrow
display_data(display_gfx_arrow_down, 8, 4, (position + 1) * 8, false);
}
void display_set_button(char *text, bool selected, bool primary)
{
uint8_t start = 0;
if (primary)
{
start = 64;
}
if (selected)
{
display_data(display_gfx_button_sel[0], 64, 5, start, false);
display_data(display_gfx_button_sel[1], 64, 6, start, false);
display_data(display_gfx_button_sel[2], 64, 7, start, false);
}
else
{
display_data(display_gfx_button[0], 64, 5, start, false);
display_data(display_gfx_button[1], 64, 6, start, false);
display_data(display_gfx_button[2], 64, 7, start, false);
}
// text
size_t text_length = strlen(text);
if (strlen(text) > 6)
{
text_length = 6;
}
size_t length = 0;
uint8_t *textdata = display_text_to_data(text, text_length, &length);
uint8_t offset = 0;
if (text_length < 6)
{
offset = (6 - text_length) / 2 * 8;
}
display_data(textdata, length, 6, start + 8 + offset, selected);
free(textdata);
}
void display_menu_headline(char *text, bool arrows, uint8_t line)
{
if (arrows)
{
display_data(display_gfx_arrow_left, 8, line, 0, false);
display_data(display_gfx_arrow_right, 8, line, 15 * 8, false);
}
// bounday
display_data(display_gfx_menu_head, 112, line, 8, false);
// text
size_t text_length = strlen(text);
if (strlen(text) > 10)
{
text_length = 10;
}
size_t length = 0;
uint8_t *textdata = display_text_to_data(text, text_length, &length);
uint8_t offset = 0;
if (text_length < 10)
{
offset = (10 - text_length) / 2 * 8;
}
display_data(textdata, length, line, 24 + offset, true);
free(textdata);
}
void display_set_color(uint16_t color)
{
current_color = color;
}
uint16_t display_get_color(void)
{
return current_color;
}
+35 -2
View File
@@ -22,6 +22,18 @@
#include "esp_system.h"
#define DISPLAY_COLUMNS 8
#define BLACK 0x0000
#define WHITE 0xffff
#define RED 0xf800
#define GREEN 0x07e0
#define BLUE 0x001f
#define GRAY 0x8c51
#define YELLOW 0xFFE0
#define CYAN 0x07FF
#define PURPLE 0xF81F
/**
*
*/
@@ -43,7 +55,7 @@ void display_start(void);
* @param[in] line the line to clear
* @param[in] invert if true, image is inverted
*/
void display_clear_line( uint8_t line, bool invert);
void display_clear_line(uint8_t line, bool invert);
/**
* @brief clear the display
@@ -52,12 +64,19 @@ void display_clear_line( uint8_t line, bool invert);
void display_clear(void);
/**
* @brief set display on or offf
* @brief set display on or off
*
* @param[in] on true if display on, false if display off
*/
void display_on(bool on);
/**
* @brief set display flipped or not
*
* @param[in] on true display is flipped
*/
void display_flipped(bool flipped);
/**
*
*/
@@ -122,4 +141,18 @@ void display_set_button(char *text, bool selected, bool primary);
*/
void display_menu_headline(char *text, bool arrows, uint8_t line);
/**
* @brief set current color for colored displays
*
* @param[in] color the color to set
*/
void display_set_color(uint16_t color);
/**
* @brief set current color for colored displays
*
* @return the current color
*/
uint16_t display_get_color(void);
#endif