Skip to content

Commit 4437761

Browse files
committed
ugfx: update ssd1331 driver
1 parent ea7b508 commit 4437761

File tree

1 file changed

+50
-6
lines changed

1 file changed

+50
-6
lines changed

components/ugfx/drivers/gdisp/SSD1331/gdisp_lld_SSD1331.c

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,27 +146,71 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
146146
#endif
147147

148148
#if GDISP_HARDWARE_STREAM_WRITE
149+
static int16_t stream_write_x = 0;
150+
static int16_t stream_write_cx = 0;
151+
static int16_t stream_write_y = 0;
152+
static int16_t stream_write_cy = 0;
149153
LLDSPEC void gdisp_lld_write_start(GDisplay *g) {
154+
stream_write_x = g->p.x;
155+
stream_write_cx = g->p.cx;
156+
stream_write_y = g->p.y;
157+
stream_write_cy = g->p.cy;
150158
}
151159
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
152-
LLDCOLOR_TYPE c;
153-
c = gdispColor2Native(g->p.color);
154-
*((uint8_t *)g->priv + (g->p.y * g->g.Width + g->p.x) * 2 + 0) = c >> 8;
155-
*((uint8_t *)g->priv + (g->p.y * g->g.Width + g->p.x) * 2 + 1) = c;
160+
LLDCOLOR_TYPE c = gdispColor2Native(g->p.color);
161+
*((uint8_t *)g->priv + (stream_write_x + stream_write_y * g->g.Width) * 2 + 0) = c >> 8;
162+
*((uint8_t *)g->priv + (stream_write_x + stream_write_y * g->g.Width) * 2 + 1) = c;
163+
stream_write_x++;
164+
if (--stream_write_cx <= 0) {
165+
stream_write_x = g->p.x;
166+
stream_write_cx = g->p.cx;
167+
stream_write_y++;
168+
if (--stream_write_cy <= 0) {
169+
stream_write_y = g->p.y;
170+
stream_write_cy = g->p.cy;
171+
}
172+
}
156173
}
157174
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
175+
stream_write_x = 0;
176+
stream_write_cx = 0;
177+
stream_write_y = 0;
178+
stream_write_cy = 0;
158179
g->flags |= GDISP_FLG_NEEDFLUSH;
159180
}
160181
#endif
161182

162183
#if GDISP_HARDWARE_STREAM_READ
184+
static int16_t stream_read_x = 0;
185+
static int16_t stream_read_cx = 0;
186+
static int16_t stream_read_y = 0;
187+
static int16_t stream_read_cy = 0;
163188
LLDSPEC void gdisp_lld_read_start(GDisplay *g) {
189+
stream_read_x = g->p.x;
190+
stream_read_cx = g->p.cx;
191+
stream_read_y = g->p.y;
192+
stream_read_cy = g->p.cy;
164193
}
165194
LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) {
166-
return (*((uint8_t *)g->priv + (g->p.y * g->g.Width + g->p.x) * 2 + 0) << 8) |
167-
(*((uint8_t *)g->priv + (g->p.y * g->g.Width + g->p.x) * 2 + 1));
195+
LLDCOLOR_TYPE c = (*((uint8_t *)g->priv + (stream_read_x + stream_read_y * g->g.Width) * 2 + 0) << 8)
196+
| (*((uint8_t *)g->priv + (stream_read_x + stream_read_y * g->g.Width) * 2 + 1));
197+
stream_read_x++;
198+
if (--stream_read_cx <= 0) {
199+
stream_read_x = g->p.x;
200+
stream_read_cx = g->p.cx;
201+
stream_read_y++;
202+
if (--stream_read_cy <= 0) {
203+
stream_read_y = g->p.y;
204+
stream_read_cy = g->p.cy;
205+
}
206+
}
207+
return c;
168208
}
169209
LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
210+
stream_read_x = 0;
211+
stream_read_cx = 0;
212+
stream_read_y = 0;
213+
stream_read_cy = 0;
170214
}
171215
#endif
172216

0 commit comments

Comments
 (0)