Merge pull request #12077 from gemu2015/udisp_update

Udisp update
This commit is contained in:
Theo Arends 2021-05-11 12:00:26 +02:00 committed by GitHub
commit d3874e9834
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 19 deletions

View File

@ -32,14 +32,14 @@ typedef struct LVGL_PARAMS {
union {
uint8_t data;
struct {
uint8_t use_dma : 1;
uint8_t swap_color : 1;
uint8_t resvd_0 : 1;
uint8_t resvd_1 : 1;
uint8_t resvd_2 : 1;
uint8_t resvd_3 : 1;
uint8_t resvd_4 : 1;
uint8_t resvd_5 : 1;
uint8_t resvd_6 : 1;
uint8_t use_dma : 1;
};
};
}LVGL_PARAMS;

View File

@ -289,7 +289,7 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) {
break;
case 'B':
lvgl_param.fluslines = next_val(&lp1);
lvgl_param.use_dma = next_val(&lp1);
lvgl_param.data = next_val(&lp1);
break;
case 'M':
rotmap_xmin = next_val(&lp1);
@ -1083,7 +1083,11 @@ static inline void lvgl_color_swap(uint16_t *data, uint16_t len) { for (uint32_t
void uDisplay::pushColors(uint16_t *data, uint16_t len, boolean not_swapped) {
uint16_t color;
//Serial.printf("push %x - %d\n", (uint32_t)data, len);
if (lvgl_param.swap_color) {
not_swapped = !not_swapped;
}
//Serial.printf("push %x - %d - %d - %d\n", (uint32_t)data, len, not_swapped,lvgl_param.data);
if (not_swapped == false) {
// called from LVGL bytes are swapped
if (bpp != 16) {
@ -1386,7 +1390,7 @@ void uDisplay::TS_RotConvert(int16_t *x, int16_t *y) {
if (rotmap_xmin >= 0) {
*y = map(*y, rotmap_ymin, rotmap_ymax, 0, gys);
*x = map(*x, rotmap_xmin, rotmap_xmax, 0, gxs);
*x = map(*x, rotmap_xmin, rotmap_xmax, 0, gxs);
}
*x = constrain(*x, 0, gxs);
*y = constrain(*y, 0, gys);
@ -1409,7 +1413,6 @@ void uDisplay::TS_RotConvert(int16_t *x, int16_t *y) {
*x = width() - temp;
break;
}
}
uint8_t uDisplay::strlen_ln(char *str) {

View File

@ -2616,13 +2616,21 @@ chknext:
len = 0;
goto exit;
}
if (!strncmp(vname, "iw(", 3)) {
lp = GetNumericArgument(lp + 3, OPER_EQU, &fvar, gv);
if (!strncmp(vname, "iw", 2)) {
uint8_t bytes = 1;
lp += 2;
if (*lp != '(') {
bytes = *lp & 0xf;
if (bytes < 1) bytes = 1;
if (bytes > 4) bytes = 4;
lp++;
}
lp = GetNumericArgument(lp + 1, OPER_EQU, &fvar, gv);
SCRIPT_SKIP_SPACES
// arg2
float fvar2;
lp = GetNumericArgument(lp, OPER_EQU, &fvar2, gv);
fvar = script_i2c(1, fvar, fvar2);
fvar = script_i2c(9 + bytes, fvar, fvar2);
lp++;
len = 0;
goto exit;
@ -7830,7 +7838,10 @@ void cpy2lf(char *dst, uint32_t dstlen, char *src) {
#ifdef USE_SCRIPT_I2C
uint8_t script_i2c_addr;
TwoWire *script_i2c_wire;
uint32_t script_i2c(uint8_t sel, uint8_t val, uint8_t val1) {
uint32_t script_i2c(uint8_t sel, uint32_t val, uint32_t val1) {
uint32_t rval = 0;
uint8_t bytes = 1;
switch (sel) {
case 0:
script_i2c_addr = val;
@ -7843,26 +7854,36 @@ uint32_t script_i2c(uint8_t sel, uint8_t val, uint8_t val1) {
script_i2c_wire->beginTransmission(script_i2c_addr);
return (0 == script_i2c_wire->endTransmission());
break;
case 1:
script_i2c_wire->beginTransmission(script_i2c_addr);
script_i2c_wire->write(val);
script_i2c_wire->write(val1);
script_i2c_wire->endTransmission();
break;
case 2:
// read 1..4 bytes
script_i2c_wire->beginTransmission(script_i2c_addr);
script_i2c_wire->write(val);
script_i2c_wire->endTransmission();
script_i2c_wire->requestFrom((int)script_i2c_addr, (int)val1);
uint32_t rval = 0;
for (uint8_t cnt = 0; cnt < val1; cnt++) {
rval <<= 8;
rval |= script_i2c_wire->read();
}
return rval;
break;
case 10:
case 11:
case 12:
case 13:
// write 1 .. 4 bytes
bytes = sel - 9;
script_i2c_wire->beginTransmission(script_i2c_addr);
script_i2c_wire->write(val);
for (uint8_t cnt = 0; cnt < bytes; cnt++) {
script_i2c_wire->write(val1);
val1 >>= 8;
}
script_i2c_wire->endTransmission();
break;
}
return 0;
return rval;
}
#endif // USE_SCRIPT_I2C
@ -8365,6 +8386,11 @@ bool Xdrv10(uint8_t function)
case FUNC_EVERY_100_MSECOND:
ScripterEvery100ms();
break;
#ifdef USE_LVGL
case FUNC_EVERY_50_MSECOND:
lv_task_handler();
break;
#endif // USE_LVGL
case FUNC_EVERY_SECOND:
ScriptEverySecond();