mirror of https://github.com/arendst/Tasmota.git
commit
68464c5ebd
|
@ -251,7 +251,7 @@ void Renderer::setTextFont(uint8_t f) {
|
|||
#else
|
||||
#ifdef USE_EPD_FONTS
|
||||
switch (font) {
|
||||
case 1:
|
||||
case 1:
|
||||
selected_font = &Font12;
|
||||
break;
|
||||
case 2:
|
||||
|
@ -540,8 +540,14 @@ void Renderer::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
|
||||
}
|
||||
|
||||
extern uint16_t index_colors[MAX_INDEXCOLORS];
|
||||
|
||||
// this is called for every driver
|
||||
void Renderer::setDrawMode(uint8_t mode) {
|
||||
drawmode=mode;
|
||||
for (uint32_t count = 0; count < MAX_INDEXCOLORS; count++) {
|
||||
index_colors[count] = GetColorFromIndex(count);
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::invertDisplay(boolean i) {
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#define WHITE 1
|
||||
#define INVERSE 2
|
||||
|
||||
#define MAX_INDEXCOLORS 32
|
||||
|
||||
// depends on GFX driver
|
||||
// GFX patched
|
||||
// a. in class GFX setCursor,setTextSize => virtual
|
||||
|
|
|
@ -64,6 +64,7 @@ const uint8_t DISPLAY_LOG_ROWS = 32; // Number of lines in display log
|
|||
#define D_CMND_DISP_WIDTH "Width"
|
||||
#define D_CMND_DISP_HEIGHT "Height"
|
||||
#define D_CMND_DISP_BLINKRATE "Blinkrate"
|
||||
#define D_CMND_DISP_BATCH "Batch"
|
||||
|
||||
enum XdspFunctions { FUNC_DISPLAY_INIT_DRIVER, FUNC_DISPLAY_INIT, FUNC_DISPLAY_EVERY_50_MSECOND, FUNC_DISPLAY_EVERY_SECOND,
|
||||
FUNC_DISPLAY_MODEL, FUNC_DISPLAY_MODE, FUNC_DISPLAY_POWER,
|
||||
|
@ -72,19 +73,31 @@ enum XdspFunctions { FUNC_DISPLAY_INIT_DRIVER, FUNC_DISPLAY_INIT, FUNC_DISPLAY_E
|
|||
FUNC_DISPLAY_DRAW_CIRCLE, FUNC_DISPLAY_FILL_CIRCLE,
|
||||
FUNC_DISPLAY_DRAW_RECTANGLE, FUNC_DISPLAY_FILL_RECTANGLE,
|
||||
FUNC_DISPLAY_TEXT_SIZE, FUNC_DISPLAY_FONT_SIZE, FUNC_DISPLAY_ROTATION, FUNC_DISPLAY_DRAW_STRING,
|
||||
FUNC_DISPLAY_DIM, FUNC_DISPLAY_BLINKRATE };
|
||||
FUNC_DISPLAY_DIM, FUNC_DISPLAY_BLINKRATE
|
||||
#ifdef USE_UFILESYS
|
||||
,FUNC_DISPLAY_BATCH
|
||||
#endif
|
||||
};
|
||||
|
||||
enum DisplayInitModes { DISPLAY_INIT_MODE, DISPLAY_INIT_PARTIAL, DISPLAY_INIT_FULL };
|
||||
|
||||
const char kDisplayCommands[] PROGMEM = D_PRFX_DISPLAY "|" // Prefix
|
||||
"|" D_CMND_DISP_MODEL "|" D_CMND_DISP_WIDTH "|" D_CMND_DISP_HEIGHT "|" D_CMND_DISP_MODE "|" D_CMND_DISP_REFRESH "|"
|
||||
D_CMND_DISP_DIMMER "|" D_CMND_DISP_COLS "|" D_CMND_DISP_ROWS "|" D_CMND_DISP_SIZE "|" D_CMND_DISP_FONT "|"
|
||||
D_CMND_DISP_ROTATE "|" D_CMND_DISP_TEXT "|" D_CMND_DISP_ADDRESS "|" D_CMND_DISP_BLINKRATE ;
|
||||
D_CMND_DISP_ROTATE "|" D_CMND_DISP_TEXT "|" D_CMND_DISP_ADDRESS "|" D_CMND_DISP_BLINKRATE
|
||||
#ifdef USE_UFILESYS
|
||||
"|" D_CMND_DISP_BATCH
|
||||
#endif
|
||||
;
|
||||
|
||||
void (* const DisplayCommand[])(void) PROGMEM = {
|
||||
&CmndDisplay, &CmndDisplayModel, &CmndDisplayWidth, &CmndDisplayHeight, &CmndDisplayMode, &CmndDisplayRefresh,
|
||||
&CmndDisplayDimmer, &CmndDisplayColumns, &CmndDisplayRows, &CmndDisplaySize, &CmndDisplayFont,
|
||||
&CmndDisplayRotate, &CmndDisplayText, &CmndDisplayAddress, &CmndDisplayBlinkrate };
|
||||
&CmndDisplayRotate, &CmndDisplayText, &CmndDisplayAddress, &CmndDisplayBlinkrate
|
||||
#ifdef USE_UFILESYS
|
||||
,&CmndDisplayBatch
|
||||
#endif
|
||||
};
|
||||
|
||||
char *dsp_str;
|
||||
|
||||
|
@ -107,6 +120,8 @@ uint8_t dsp_font;
|
|||
uint8_t dsp_flag;
|
||||
uint8_t dsp_on;
|
||||
|
||||
uint16_t index_colors[MAX_INDEXCOLORS];
|
||||
|
||||
#ifdef USE_DISPLAY_MODES1TO5
|
||||
|
||||
char **disp_log_buffer;
|
||||
|
@ -363,6 +378,11 @@ uint32_t decode_te(char *line) {
|
|||
|
||||
#define DISPLAY_BUFFER_COLS 128 // Max number of characters in linebuf
|
||||
|
||||
uint16_t GetColorFromIndex(uint32_t index) {
|
||||
if (index >= MAX_INDEXCOLORS) index = 0;
|
||||
return index_colors[index];
|
||||
}
|
||||
|
||||
void DisplayText(void)
|
||||
{
|
||||
uint8_t lpos;
|
||||
|
@ -468,7 +488,7 @@ void DisplayText(void)
|
|||
// color index 0-18
|
||||
cp++;
|
||||
var = atoiv(cp, &temp);
|
||||
if (renderer) ftemp=renderer->GetColorFromIndex(temp);
|
||||
if (renderer) ftemp = GetColorFromIndex(temp);
|
||||
} else {
|
||||
// float because it must handle unsigned 16 bit
|
||||
var = fatoiv(cp,&ftemp);
|
||||
|
@ -483,7 +503,7 @@ void DisplayText(void)
|
|||
// color index 0-18
|
||||
cp++;
|
||||
var = atoiv(cp, &temp);
|
||||
if (renderer) ftemp=renderer->GetColorFromIndex(temp);
|
||||
if (renderer) ftemp = GetColorFromIndex(temp);
|
||||
} else {
|
||||
var = fatoiv(cp,&ftemp);
|
||||
}
|
||||
|
@ -640,6 +660,18 @@ void DisplayText(void)
|
|||
}
|
||||
break; }
|
||||
case 'd':
|
||||
if (*cp == 'c') {
|
||||
cp++;
|
||||
// define index colo
|
||||
var = atoiv(cp, &temp);
|
||||
cp += var;
|
||||
cp++;
|
||||
var = fatoiv(cp, &ftemp);
|
||||
cp += var;
|
||||
if (temp >= MAX_INDEXCOLORS) temp = 0;
|
||||
index_colors[temp] = ftemp;
|
||||
break;
|
||||
}
|
||||
// force draw grafics buffer
|
||||
if (renderer) renderer->Updateframe();
|
||||
else DisplayDrawFrame();
|
||||
|
@ -855,8 +887,8 @@ void DisplayText(void)
|
|||
if (buttons[num]) {
|
||||
if (!sbt) {
|
||||
buttons[num]->vpower.slider = 0;
|
||||
buttons[num]->initButtonUL(renderer, gxp, gyp, gxs, gys, renderer->GetColorFromIndex(outline),\
|
||||
renderer->GetColorFromIndex(fill), renderer->GetColorFromIndex(textcolor), bbuff, textsize);
|
||||
buttons[num]->initButtonUL(renderer, gxp, gyp, gxs, gys, GetColorFromIndex(outline),\
|
||||
GetColorFromIndex(fill), GetColorFromIndex(textcolor), bbuff, textsize);
|
||||
if (!bflags) {
|
||||
// power button
|
||||
if (dflg) buttons[num]->xdrawButton(bitRead(TasmotaGlobal.power, num));
|
||||
|
@ -877,8 +909,8 @@ void DisplayText(void)
|
|||
} else {
|
||||
// slider
|
||||
buttons[num]->vpower.slider = 1;
|
||||
buttons[num]->SliderInit(renderer, gxp, gyp, gxs, gys, outline, renderer->GetColorFromIndex(fill),\
|
||||
renderer->GetColorFromIndex(textcolor), renderer->GetColorFromIndex(textsize));
|
||||
buttons[num]->SliderInit(renderer, gxp, gyp, gxs, gys, outline, GetColorFromIndex(fill),\
|
||||
GetColorFromIndex(textcolor), GetColorFromIndex(textsize));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -924,6 +956,45 @@ void DisplayText(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_UFILESYS
|
||||
extern FS *ufsp;
|
||||
void Display_Text_From_File(const char *file) {
|
||||
File fp;
|
||||
fp = ufsp->open(file, FS_FILE_READ);
|
||||
if (fp >= 0) {
|
||||
char *savptr = XdrvMailbox.data;
|
||||
char linebuff[128];
|
||||
while (fp.available()) {
|
||||
uint16_t index = 0;
|
||||
while (fp.available()) {
|
||||
uint8_t buf[1];
|
||||
fp.read(buf,1);
|
||||
if (buf[0]=='\n' || buf[0]=='\r') {
|
||||
break;
|
||||
} else {
|
||||
linebuff[index] = buf[0];
|
||||
index++;
|
||||
if (index >= sizeof(linebuff) - 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
linebuff[index] = 0;
|
||||
char *cp = linebuff;
|
||||
while (*cp==' ') cp++;
|
||||
if (*cp == ';') continue;
|
||||
//AddLog(LOG_LEVEL_INFO, PSTR("displaytext %s"), cp);
|
||||
// execute display text here
|
||||
XdrvMailbox.data = cp;
|
||||
XdrvMailbox.data_len = 0;
|
||||
DisplayText();
|
||||
}
|
||||
XdrvMailbox.data = savptr;
|
||||
fp.close();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
||||
#ifdef USE_DISPLAY_MODES1TO5
|
||||
|
@ -1308,6 +1379,7 @@ void DisplayLocalSensor(void)
|
|||
|
||||
#endif // USE_DISPLAY_MODES1TO5
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Public
|
||||
\*********************************************************************************************/
|
||||
|
@ -1323,6 +1395,9 @@ void DisplayInitDriver(void)
|
|||
renderer->setDrawMode(0);
|
||||
}
|
||||
|
||||
#ifdef USE_UFILESYS
|
||||
Display_Text_From_File("/display.ini");
|
||||
#endif
|
||||
|
||||
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model);
|
||||
|
||||
|
@ -1467,6 +1542,17 @@ void CmndDisplayBlinkrate(void)
|
|||
ResponseCmndNumber(XdrvMailbox.payload);
|
||||
}
|
||||
|
||||
#ifdef USE_UFILESYS
|
||||
void CmndDisplayBatch(void) {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
if (!Settings.display_mode) {
|
||||
Display_Text_From_File(XdrvMailbox.data);
|
||||
}
|
||||
ResponseCmndChar(XdrvMailbox.data);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CmndDisplaySize(void)
|
||||
{
|
||||
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= 4)) {
|
||||
|
@ -2038,7 +2124,7 @@ void RedrawGraph(uint8_t num, uint8_t flags) {
|
|||
uint16_t linecol=fg_color;
|
||||
|
||||
if (color_type==COLOR_COLOR) {
|
||||
linecol=renderer->GetColorFromIndex(gp->color_index);
|
||||
linecol = GetColorFromIndex(gp->color_index);
|
||||
}
|
||||
|
||||
if (!gp->flags.overlay) {
|
||||
|
@ -2060,7 +2146,7 @@ void AddGraph(uint8_t num,uint8_t val) {
|
|||
|
||||
uint16_t linecol=fg_color;
|
||||
if (color_type==COLOR_COLOR) {
|
||||
linecol=renderer->GetColorFromIndex(gp->color_index);
|
||||
linecol = GetColorFromIndex(gp->color_index);
|
||||
}
|
||||
gp->xcnt++;
|
||||
if (gp->xcnt>gp->xs) {
|
||||
|
|
Loading…
Reference in New Issue