mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
ILI9341 read_pixels().
Improves on / abstracts prior interface, which just handed back uint16_ts from the LCD's parallel interface.
This commit is contained in:
parent
bdaa13c103
commit
77eb0c5d24
@ -179,6 +179,11 @@ void lcd_ramwr_start() {
|
|||||||
io.lcd_data_write_command_and_data(0x2c, {});
|
io.lcd_data_write_command_and_data(0x2c, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcd_ramrd_start() {
|
||||||
|
io.lcd_data_write_command_and_data(0x2e, {});
|
||||||
|
io.lcd_read_word();
|
||||||
|
}
|
||||||
|
|
||||||
void lcd_caset(const uint_fast16_t start_column, uint_fast16_t end_column) {
|
void lcd_caset(const uint_fast16_t start_column, uint_fast16_t end_column) {
|
||||||
lcd_set(0x2a, start_column, end_column);
|
lcd_set(0x2a, start_column, end_column);
|
||||||
}
|
}
|
||||||
@ -196,12 +201,27 @@ void lcd_start_ram_write(
|
|||||||
lcd_ramwr_start();
|
lcd_ramwr_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcd_start_ram_read(
|
||||||
|
const ui::Point p,
|
||||||
|
const ui::Size s
|
||||||
|
) {
|
||||||
|
lcd_caset(p.x, p.x + s.w - 1);
|
||||||
|
lcd_paset(p.y, p.y + s.h - 1);
|
||||||
|
lcd_ramrd_start();
|
||||||
|
}
|
||||||
|
|
||||||
void lcd_start_ram_write(
|
void lcd_start_ram_write(
|
||||||
const ui::Rect& r
|
const ui::Rect& r
|
||||||
) {
|
) {
|
||||||
lcd_start_ram_write(r.pos, r.size);
|
lcd_start_ram_write(r.pos, r.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcd_start_ram_read(
|
||||||
|
const ui::Rect& r
|
||||||
|
) {
|
||||||
|
lcd_start_ram_read(r.pos, r.size);
|
||||||
|
}
|
||||||
|
|
||||||
void lcd_vertical_scrolling_definition(
|
void lcd_vertical_scrolling_definition(
|
||||||
const uint_fast16_t top_fixed_area,
|
const uint_fast16_t top_fixed_area,
|
||||||
const uint_fast16_t vertical_scrolling_area,
|
const uint_fast16_t vertical_scrolling_area,
|
||||||
@ -299,6 +319,19 @@ void ILI9341::draw_pixels(
|
|||||||
io.lcd_write_pixels(colors, count);
|
io.lcd_write_pixels(colors, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ILI9341::read_pixels(
|
||||||
|
const ui::Rect r,
|
||||||
|
ui::ColorRGB888* const colors,
|
||||||
|
const size_t count
|
||||||
|
) {
|
||||||
|
/* TODO: Assert that rectangle width x height < count */
|
||||||
|
lcd_start_ram_read(r);
|
||||||
|
io.lcd_read_bytes(
|
||||||
|
reinterpret_cast<uint8_t*>(colors),
|
||||||
|
count * sizeof(ui::ColorRGB888)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void ILI9341::draw_bitmap(
|
void ILI9341::draw_bitmap(
|
||||||
const ui::Point p,
|
const ui::Point p,
|
||||||
const ui::Size size,
|
const ui::Size size,
|
||||||
|
@ -65,6 +65,14 @@ public:
|
|||||||
draw_pixels(r, colors.data(), colors.size());
|
draw_pixels(r, colors.data(), colors.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<size_t N>
|
||||||
|
void read_pixels(
|
||||||
|
const ui::Rect r,
|
||||||
|
std::array<ui::ColorRGB888, N>& colors
|
||||||
|
) {
|
||||||
|
read_pixels(r, colors.data(), colors.size());
|
||||||
|
}
|
||||||
|
|
||||||
void draw_bitmap(
|
void draw_bitmap(
|
||||||
const ui::Point p,
|
const ui::Point p,
|
||||||
const ui::Size size,
|
const ui::Size size,
|
||||||
@ -101,6 +109,7 @@ private:
|
|||||||
scroll_t scroll_state;
|
scroll_t scroll_state;
|
||||||
|
|
||||||
void draw_pixels(const ui::Rect r, const ui::Color* const colors, const size_t count);
|
void draw_pixels(const ui::Rect r, const ui::Color* const colors, const size_t count);
|
||||||
|
void read_pixels(const ui::Rect r, ui::ColorRGB888* const colors, const size_t count);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace lcd */
|
} /* namespace lcd */
|
||||||
|
Loading…
Reference in New Issue
Block a user