mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-13 18:12:13 +00:00
move default splash into sdcard (#2595)
* move bmps to sdcard * remove unrelated files * gitignore * credit * format
This commit is contained in:

committed by
GitHub

parent
8a7aa9c0f8
commit
37cc35d3c6
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
* copyleft 2025 Whiterose of the Dark Army
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@@ -646,31 +647,58 @@ void ILI9341::draw_bitmap(
|
||||
const ui::Size size,
|
||||
const uint8_t* const pixels,
|
||||
const ui::Color foreground,
|
||||
const ui::Color background) {
|
||||
// Not a transparent background
|
||||
if (ui::Color::magenta().v != background.v) {
|
||||
lcd_start_ram_write(p, size);
|
||||
const ui::Color background,
|
||||
uint8_t zoom_level) {
|
||||
if (zoom_level <= 1) {
|
||||
// Not a transparent background
|
||||
if (ui::Color::magenta().v != background.v) {
|
||||
lcd_start_ram_write(p, size);
|
||||
|
||||
const size_t count = size.width() * size.height();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
|
||||
io.lcd_write_pixel(pixel ? foreground : background);
|
||||
}
|
||||
} else {
|
||||
int x = p.x();
|
||||
int y = p.y();
|
||||
int maxX = x + size.width();
|
||||
const size_t count = size.width() * size.height();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
|
||||
if (pixel) {
|
||||
draw_pixel(ui::Point(x, y), foreground);
|
||||
const size_t count = size.width() * size.height();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
|
||||
io.lcd_write_pixel(pixel ? foreground : background);
|
||||
}
|
||||
// Move to the next pixel
|
||||
x++;
|
||||
if (x >= maxX) {
|
||||
x = p.x();
|
||||
y++;
|
||||
} else {
|
||||
// transparent bg
|
||||
int x = p.x();
|
||||
int y = p.y();
|
||||
int maxX = x + size.width();
|
||||
const size_t count = size.width() * size.height();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
|
||||
if (pixel) {
|
||||
draw_pixel(ui::Point(x, y), foreground);
|
||||
}
|
||||
// move to next px
|
||||
x++;
|
||||
if (x >= maxX) {
|
||||
x = p.x();
|
||||
y++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // zoom
|
||||
|
||||
// dot to square
|
||||
for (int y = 0; y < size.height(); y++) {
|
||||
for (int x = 0; x < size.width(); x++) {
|
||||
// pos
|
||||
size_t bit_index = y * size.width() + x;
|
||||
int byte_index = bit_index >> 3;
|
||||
int bit_pos = bit_index & 0x7;
|
||||
|
||||
// val
|
||||
const auto pixel = pixels[byte_index] & (1U << bit_pos);
|
||||
/* ^ the byte_index-th bit AKA current bit
|
||||
^ current px in current byte*/
|
||||
|
||||
if (pixel || background.v != ui::Color::magenta().v) {
|
||||
fill_rectangle(
|
||||
{p.x() + x * zoom_level, p.y() + y * zoom_level,
|
||||
zoom_level, zoom_level},
|
||||
pixel ? foreground : background);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -680,8 +708,9 @@ void ILI9341::draw_glyph(
|
||||
const ui::Point p,
|
||||
const ui::Glyph& glyph,
|
||||
const ui::Color foreground,
|
||||
const ui::Color background) {
|
||||
draw_bitmap(p, glyph.size(), glyph.pixels(), foreground, background);
|
||||
const ui::Color background,
|
||||
uint8_t zoom_level) {
|
||||
draw_bitmap(p, glyph.size(), glyph.pixels(), foreground, background, zoom_level);
|
||||
}
|
||||
|
||||
void ILI9341::scroll_set_area(
|
||||
|
@@ -86,13 +86,15 @@ class ILI9341 {
|
||||
const ui::Size size,
|
||||
const uint8_t* const data,
|
||||
const ui::Color foreground,
|
||||
const ui::Color background);
|
||||
const ui::Color background,
|
||||
uint8_t zoom_level = 1);
|
||||
|
||||
void draw_glyph(
|
||||
const ui::Point p,
|
||||
const ui::Glyph& glyph,
|
||||
const ui::Color foreground,
|
||||
const ui::Color background);
|
||||
const ui::Color background,
|
||||
uint8_t zoom_level = 1);
|
||||
|
||||
/*** Scrolling ***
|
||||
* Scrolling support is implemented in the ILI9341 driver. Basically a region
|
||||
|
@@ -36,34 +36,12 @@ Style Style::invert() const {
|
||||
.foreground = background};
|
||||
}
|
||||
|
||||
int Painter::draw_char(Point p, const Style& style, char c, uint8_t zoom_factor) {
|
||||
int Painter::draw_char(Point p, const Style& style, char c, uint8_t zoom_level) {
|
||||
const auto glyph = style.font.glyph(c);
|
||||
|
||||
if (zoom_factor <= 1) {
|
||||
display.draw_glyph(p, glyph, style.foreground, style.background);
|
||||
} else {
|
||||
// dot to square
|
||||
const uint8_t* pixels = glyph.pixels();
|
||||
for (int y = 0; y < glyph.h(); y++) { // each line
|
||||
for (int x = 0; x < glyph.w(); x++) { // each clum
|
||||
// pos
|
||||
int byte_index = (y * glyph.w() + x) / 8;
|
||||
int bit_pos = (y * glyph.w() + x) % 8;
|
||||
display.draw_glyph(p, glyph, style.foreground, style.background, zoom_level);
|
||||
|
||||
// fill
|
||||
Color pixel_color = ((pixels[byte_index] & (1 << bit_pos)) != 0) ? style.foreground : style.background;
|
||||
/* ^ true: fg, false: bg
|
||||
^ the byte_index-th bit AKA current bit
|
||||
^ current px in current byte */
|
||||
display.fill_rectangle(
|
||||
{p.x() + x * zoom_factor, p.y() + y * zoom_factor,
|
||||
zoom_factor, zoom_factor},
|
||||
pixel_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return glyph.advance().x() * zoom_factor;
|
||||
return glyph.advance().x() * zoom_level;
|
||||
}
|
||||
|
||||
int Painter::draw_string(Point p, const Style& style, std::string_view text) {
|
||||
|
Reference in New Issue
Block a user