Skip to content

Commit

Permalink
fix(bw): Prevent points being drawn outside of LCD buffer (#4550)
Browse files Browse the repository at this point in the history
  • Loading branch information
3djc authored and pfeerick committed Jan 17, 2024
1 parent 7ce0107 commit ca18c65
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion radio/src/gui/128x64/lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ void lcdMaskPoint(uint8_t * p, uint8_t mask, LcdFlags att)
void lcdDrawPoint(coord_t x, coord_t y, LcdFlags att)
{
uint8_t * p = &displayBuf[ y / 8 * LCD_W + x ];
if (p < DISPLAY_END) {
if (IS_IN_DISPLAY(p)) {
lcdMaskPoint(p, bfBit<uint8_t>(y % 8), att);
}
}
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/128x64/lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ extern coord_t lcdLastLeftPos;
extern coord_t lcdNextPos;

#define DISPLAY_END (displayBuf + DISPLAY_BUFFER_SIZE)
#define IS_IN_DISPLAY(p) ((p) >= displayBuf && (p) < DISPLAY_END)
#define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END)


Expand Down
2 changes: 2 additions & 0 deletions radio/src/gui/common/stdlcd/model_curves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ void drawFunction(FnFuncP fn, uint8_t offset)

for (int xv = -CURVE_SIDE_WIDTH; xv <= CURVE_SIDE_WIDTH; xv++) {
coord_t yv = -(fn((xv * RESX) / CURVE_SIDE_WIDTH) * (CURVE_SIDE_WIDTH*2+1) / (RESX*2));
if (yv < -CURVE_SIDE_WIDTH) yv = -CURVE_SIDE_WIDTH;
if (yv > CURVE_SIDE_WIDTH) yv = CURVE_SIDE_WIDTH;
if ((xv > -CURVE_SIDE_WIDTH) && (abs((int8_t)yv-prev_yv) > 1)) {
int len = 0;
if (yv > prev_yv) {
Expand Down

0 comments on commit ca18c65

Please sign in to comment.