Skip to content

Commit 3efe013

Browse files
TomSawsalkinium
authored andcommitted
[display] Swap x/y data buffer of monochrome display
1 parent db3cc85 commit 3efe013

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

src/modm/driver/display/max7219_matrix_horizontal.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Max7219MatrixHorizontal<SPI, CS, COLUMNS, ROWS>::update()
9595
// a group of eight pixels horizontal
9696
for (uint8_t col = 0; col < COLUMNS; ++col)
9797
{
98-
buf[--idx] = this->buffer[row * 8 + ledCol][col];
98+
buf[--idx] = this->buffer[col][row * 8 + ledCol];
9999
}
100100
}
101101

src/modm/ui/display/monochrome_graphic_display.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class MonochromeGraphicDisplay : public GraphicDisplay
7676
clear() final;
7777

7878
protected:
79-
uint8_t buffer[BufferWidth][BufferHeight];
79+
uint8_t buffer[BufferHeight][BufferWidth];
8080
};
8181
} // namespace modm
8282

src/modm/ui/display/monochrome_graphic_display_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ template<int16_t Width, int16_t Height, std::size_t BufferWidth, std::size_t Buf
2222
void
2323
modm::MonochromeGraphicDisplay<Width, Height, BufferWidth, BufferHeight>::clear()
2424
{
25-
std::fill(&buffer[0][0], &buffer[BufferWidth][BufferHeight], 0);
26-
this->cursor = glcd::Point(0, 0);
25+
std::fill(&buffer[0][0], &buffer[0][0] + sizeof(buffer), 0);
26+
this->cursor = {0, 0};
2727
}

src/modm/ui/display/monochrome_graphic_display_vertical_impl.hpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,11 @@ modm::MonochromeGraphicDisplayVertical<Width, Height>::drawHorizontalLine(glcd::
2525
{
2626
const int16_t y = start.y / 8;
2727

28-
// TODO Implement draw / clear pixels for monochrome displays
29-
// if (draw mode)
30-
// {
3128
const uint8_t byte = 1 << (start.y % 8);
3229
for (int_fast16_t x = start.x; x < static_cast<int16_t>(start.x + length); ++x)
3330
{
34-
if (x < Width) { this->buffer[x][y] |= byte; }
31+
if (x < Width) { this->buffer[y][x] |= byte; }
3532
}
36-
// } else
37-
// {
38-
// const uint8_t byte = ~(1 << (start.y % 8));
39-
// for (int_fast16_t x = start.x; x < static_cast<int16_t>(start.x + length);
40-
// ++x)
41-
// {
42-
// if (x < Width and y < Height) { this->buffer[x][y] &= byte; }
43-
// }
44-
// }
4533
}
4634
}
4735

@@ -62,7 +50,7 @@ modm::MonochromeGraphicDisplayVertical<Width, Height>::drawVerticalLine(glcd::Po
6250
{
6351
if (y < Height / 8)
6452
{
65-
this->buffer[start.x][y] |= byte;
53+
this->buffer[y][start.x] |= byte;
6654
byte = 0xFF;
6755
}
6856
y++;
@@ -71,7 +59,7 @@ modm::MonochromeGraphicDisplayVertical<Width, Height>::drawVerticalLine(glcd::Po
7159
if (y < Height / 8)
7260
{
7361
byte &= 0xFF >> (8 - end_y % 8);
74-
this->buffer[start.x][y] |= byte;
62+
this->buffer[y][start.x] |= byte;
7563
}
7664
}
7765
}
@@ -97,7 +85,7 @@ modm::MonochromeGraphicDisplayVertical<Width, Height>::drawImageRaw(
9785

9886
if (x < Width and y < Height)
9987
{
100-
this->buffer[x][y] = data[i + k * width];
88+
this->buffer[y][x] = data[i + k * width];
10189
}
10290
}
10391
}
@@ -112,14 +100,14 @@ template<int16_t Width, int16_t Height>
112100
void
113101
modm::MonochromeGraphicDisplayVertical<Width, Height>::setPixel(int16_t x, int16_t y)
114102
{
115-
if (x < Width and y < Height) { this->buffer[x][y / 8] |= (1 << y % 8); }
103+
if (x < Width and y < Height) { this->buffer[y / 8][x] |= (1 << y % 8); }
116104
}
117105

118106
template<int16_t Width, int16_t Height>
119107
void
120108
modm::MonochromeGraphicDisplayVertical<Width, Height>::clearPixel(int16_t x, int16_t y)
121109
{
122-
if (x < Width and y < Height) { this->buffer[x][y / 8] &= ~(1 << y % 8); }
110+
if (x < Width and y < Height) { this->buffer[y / 8][x] &= ~(1 << y % 8); }
123111
}
124112

125113
template<int16_t Width, int16_t Height>
@@ -128,7 +116,7 @@ modm::MonochromeGraphicDisplayVertical<Width, Height>::getPixel(int16_t x, int16
128116
{
129117
if (x < Width and y < Height)
130118
{
131-
return (this->buffer[x][y / 8] & (1 << y % 8));
119+
return (this->buffer[y / 8][x] & (1 << y % 8));
132120
} else
133121
{
134122
return false;

0 commit comments

Comments
 (0)