Merge pull request #13693 from gemu2015/renderer_update

Renderer update
This commit is contained in:
Theo Arends 2021-11-16 16:34:31 +01:00 committed by GitHub
commit 9771ac12cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 9 deletions

View File

@ -633,6 +633,12 @@ LVGL_PARAMS *Renderer::lvgl_pars(void) {
return &lvgl_param;
}
void Renderer::ep_update_mode(uint8_t mode) {
}
void Renderer::ep_update_area(uint16_t xp, uint16_t yp, uint16_t width, uint16_t height, uint8_t mode) {
}
// #ifndef USE_DISPLAY_LVGL_ONLY
@ -642,6 +648,18 @@ void VButton::xdrawButton(bool inverted) {
wr_redir=0;
}
void VButton::xinitButtonUL(Renderer *renderer, int16_t gxp, int16_t gyp, uint16_t gxs, uint16_t gys, uint16_t outline,\
uint16_t fill, uint16_t textcolor , char *label, uint8_t textsize) {
initButtonUL(renderer, gxp, gyp, gxs, gys, outline, fill, textcolor, label, textsize);
spars.xp = gxp;
spars.yp = gyp;
spars.xs = gxs;
spars.ys = gys;
}
boolean VButton::didhit(int16_t x, int16_t y) {
return ((x >= spars.xp) && (x < (int16_t) (spars.xp + spars.xs)) &&
(y >= spars.yp) && (y < (int16_t) (spars.yp + spars.ys)));

View File

@ -88,6 +88,8 @@ public:
virtual void Splash(void);
virtual char *devname(void);
virtual LVGL_PARAMS *lvgl_pars(void);
virtual void ep_update_mode(uint8_t mode);
virtual void ep_update_area(uint16_t xp, uint16_t yp, uint16_t width, uint16_t height, uint8_t mode);
void setDrawMode(uint8_t mode);
uint8_t drawmode;
@ -144,6 +146,8 @@ class VButton : public Adafruit_GFX_Button {
boolean didhit(int16_t x, int16_t y);
uint16_t UpdateSlider(int16_t x, int16_t y);
void SliderInit(Renderer *rend, uint16_t xp, uint16_t yp, uint16_t xs, uint16_t ys, uint16_t nelem, uint16_t bgcol, uint16_t frcol, uint16_t barcol);
void xinitButtonUL(Renderer *renderer, int16_t gxp, int16_t gyp, uint16_t gxs, uint16_t gys, uint16_t outline,\
uint16_t fill, uint16_t textcolor , char *label, uint8_t textsize);
};
// #endif // USE_DISPLAY_LVGL_ONLY

View File

@ -343,6 +343,7 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) {
Serial.printf("SPED: %d\n", spi_speed*1000000);
Serial.printf("Pixels: %d\n", col_mode);
Serial.printf("SaMode: %d\n", sa_mode);
Serial.printf("DMA-Mode: %d\n", lvgl_param.use_dma);
Serial.printf("opts: %02x,%02x,%02x\n", saw_3, dim_op, startline);

View File

@ -68,10 +68,12 @@ enum uColorType { uCOLOR_BW, uCOLOR_COLOR };
#define SPI_BEGIN_TRANSACTION if (spi_nr <= 2) beginTransaction(spiSettings);
#define SPI_END_TRANSACTION if (spi_nr <= 2) endTransaction();
#define SPI_CS_LOW if (spi_cs >= 0) GPIO_CLR(spi_cs);
#define SPI_CS_HIGH if (spi_cs >= 0) GPIO_SET(spi_cs);
#define SPI_DC_LOW if (spi_dc >= 0) GPIO_CLR(spi_dc);
#define SPI_DC_HIGH if (spi_dc >= 0) GPIO_SET(spi_dc);
#define SPI_CS_LOW if (spi_cs >= 0) GPIO_CLR_SLOW(spi_cs);
#define SPI_CS_HIGH if (spi_cs >= 0) GPIO_SET_SLOW(spi_cs);
#define SPI_DC_LOW if (spi_dc >= 0) GPIO_CLR_SLOW(spi_dc);
#define SPI_DC_HIGH if (spi_dc >= 0) GPIO_SET_SLOW(spi_dc);
#define ESP32_PWM_CHANNEL 1

View File

@ -701,6 +701,12 @@ void DisplayText(void)
if (renderer) renderer->fillCircle(disp_xpos, disp_ypos, temp, fg_color);
//else DisplayDrawFilledCircle(disp_xpos, disp_ypos, temp, fg_color);
break;
case 'm':
// epaper draw mode currently only for 4,7 inch displays
var = atoiv(cp, &temp);
cp += var;
if (renderer) renderer->ep_update_mode(temp);
break;
case 'r':
// rectangle
var = atoiv(cp, &temp);
@ -723,7 +729,27 @@ void DisplayText(void)
break;
case 'u':
// rounded rectangle
{ int16_t rad;
{ int16_t rad, xp, yp, width, height;
if (*cp == 'p') {
// update epaper display
cp++;
var = atoiv(cp, &xp);
cp += var;
cp++;
var = atoiv(cp, &yp);
cp += var;
cp++;
var = atoiv(cp, &width);
cp += var;
cp++;
var = atoiv(cp, &height);
cp += var;
cp++;
var = atoiv(cp, &temp);
cp += var;
if (renderer) renderer->ep_update_area(xp, yp, width, height, temp);
break;
}
var = atoiv(cp, &temp);
cp += var;
cp++;
@ -1100,7 +1126,7 @@ extern FS *ffsp;
if (buttons[num]) {
if (!sbt) {
buttons[num]->vpower.slider = 0;
buttons[num]->initButtonUL(renderer, gxp, gyp, gxs, gys, GetColorFromIndex(outline),\
buttons[num]->xinitButtonUL(renderer, gxp, gyp, gxs, gys, GetColorFromIndex(outline),\
GetColorFromIndex(fill), GetColorFromIndex(textcolor), bbuff, textsize);
if (!bflags) {
// power button
@ -1969,6 +1995,7 @@ void ApplyDisplayDimmer(void) {
// still call Berry virtual display in case it is not managed entirely by renderer
Xdsp18(FUNC_DISPLAY_DIM);
#endif // USE_BERRY
} else {
XdspCall(FUNC_DISPLAY_DIM);
}
@ -2631,7 +2658,11 @@ void Restore_graph(uint8_t num, char *path) {
if (count<=4) {
if (count==0) gp->xcnt=atoi(vbuff);
} else {
gp->values[count-5]=atoi(vbuff);
uint8_t yval = atoi(vbuff);
if (yval >= gp->ys) {
yval = gp->ys - 1;
}
gp->values[count-5] = yval;
}
}
fp.close();
@ -2735,9 +2766,9 @@ void AddValue(uint8_t num,float fval) {
// decimation option
if (gp->decimation<0) {
if (gp->dcnt>=-gp->decimation) {
gp->dcnt=0;
// calc average
val=gp->summ/-gp->decimation;
val=gp->summ/gp->dcnt;
gp->dcnt=0;
gp->summ=0;
// add to graph
AddGraph(num,val);