mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-25 05:47:44 +00:00
Added raw ASCII char field in keyboard view
This commit is contained in:
@@ -289,58 +289,45 @@ void ILI9341::render_box(const ui::Point p, const ui::Size s, const ui::Color* l
|
||||
io.lcd_write_pixels(line_buffer, s.w * s.h);
|
||||
}
|
||||
|
||||
// RLE_4 BMP loader (delta not implemented)
|
||||
void ILI9341::drawBMP(const ui::Point p, const uint8_t * bitmap, const bool transparency) {
|
||||
uint32_t pixel_data, pal_data;
|
||||
uint8_t pal, by, c, count, transp_idx = 0, color_r, color_g, color_b;
|
||||
ui::Color linebuffer[240];
|
||||
const bmp_t * bmp_header = (const bmp_t *)bitmap;
|
||||
uint32_t data_idx;
|
||||
uint8_t by, c, count, transp_idx = 0;
|
||||
ui::Color line_buffer[240];
|
||||
ui::Coord px = 0, py;
|
||||
ui::Color palette[16];
|
||||
uint32_t bmpwidth, bmpheight;
|
||||
|
||||
// RLE_4 BMP loader with no delta :(
|
||||
|
||||
if (bitmap[0x1E] != 2) return; // Bad compression type
|
||||
|
||||
bmpwidth = static_cast<int32_t>(
|
||||
(bitmap[0x12]) |
|
||||
(bitmap[0x13] << 8) |
|
||||
(bitmap[0x14] << 16)|
|
||||
(bitmap[0x15] << 24) );
|
||||
bmpheight = static_cast<int32_t>(
|
||||
(bitmap[0x16]) |
|
||||
(bitmap[0x17] << 8) |
|
||||
(bitmap[0x18] << 16)|
|
||||
(bitmap[0x19] << 24) );
|
||||
// Abort if bad depth or no RLE
|
||||
if ((bmp_header->bpp != 4) ||
|
||||
(bmp_header->compression != 2)) return;
|
||||
|
||||
pal_data = bitmap[0x0E] + 0x0E;
|
||||
|
||||
pixel_data = bitmap[0x0A];
|
||||
pal = 0;
|
||||
for (c = 0; c < (16*4); c+=4) {
|
||||
color_r = bitmap[c+2+pal_data];
|
||||
color_g = bitmap[c+1+pal_data];
|
||||
color_b = bitmap[c+pal_data];
|
||||
palette[pal] = ui::Color(color_r, color_g, color_b);
|
||||
if ((color_r == 0xFF) && (color_g == 0x00) && (color_b == 0xFF)) transp_idx = pal;
|
||||
pal++;
|
||||
data_idx = bmp_header->image_data;
|
||||
|
||||
// Convert palette and find pure magenta index (alpha color key)
|
||||
for (c = 0; c < 16; c++) {
|
||||
palette[c] = ui::Color(bmp_header->palette[c].R, bmp_header->palette[c].G, bmp_header->palette[c].B);
|
||||
if ((bmp_header->palette[c].R == 0xFF) &&
|
||||
(bmp_header->palette[c].G == 0x00) &&
|
||||
(bmp_header->palette[c].B == 0xFF)) transp_idx = c;
|
||||
}
|
||||
|
||||
if (!transparency) {
|
||||
py = bmpheight + 16; // +1 ?
|
||||
py = bmp_header->height + 16;
|
||||
do {
|
||||
by = bitmap[pixel_data++];
|
||||
by = bitmap[data_idx++];
|
||||
if (by) {
|
||||
count = by;
|
||||
by = bitmap[pixel_data++];
|
||||
for (c = 0; c < count; c+=2) {
|
||||
linebuffer[px++] = palette[by >> 4];
|
||||
if (px < bmpwidth) linebuffer[px++] = palette[by & 15];
|
||||
count = by >> 1;
|
||||
by = bitmap[data_idx++];
|
||||
for (c = 0; c < count; c++) {
|
||||
line_buffer[px++] = palette[by >> 4];
|
||||
if (px < bmp_header->width) line_buffer[px++] = palette[by & 15];
|
||||
}
|
||||
if (pixel_data & 1) pixel_data++;
|
||||
if (data_idx & 1) data_idx++;
|
||||
} else {
|
||||
by = bitmap[pixel_data++];
|
||||
by = bitmap[data_idx++];
|
||||
if (by == 0) {
|
||||
render_line({p.x, p.y + py}, bmpwidth, linebuffer);
|
||||
render_line({p.x, p.y + py}, bmp_header->width, line_buffer);
|
||||
py--;
|
||||
px = 0;
|
||||
} else if (by == 1) {
|
||||
@@ -348,34 +335,34 @@ void ILI9341::drawBMP(const ui::Point p, const uint8_t * bitmap, const bool tran
|
||||
} else if (by == 2) {
|
||||
// Delta
|
||||
} else {
|
||||
count = by;
|
||||
for (c = 0; c < count; c+=2) {
|
||||
by = bitmap[pixel_data++];
|
||||
linebuffer[px++] = palette[by >> 4];
|
||||
if (px < bmpwidth) linebuffer[px++] = palette[by & 15];
|
||||
count = by >> 1;
|
||||
for (c = 0; c < count; c++) {
|
||||
by = bitmap[data_idx++];
|
||||
line_buffer[px++] = palette[by >> 4];
|
||||
if (px < bmp_header->width) line_buffer[px++] = palette[by & 15];
|
||||
}
|
||||
if (pixel_data & 1) pixel_data++;
|
||||
if (data_idx & 1) data_idx++;
|
||||
}
|
||||
}
|
||||
} while (1);
|
||||
} else {
|
||||
py = bmpheight; // +1 ?
|
||||
py = bmp_header->height;
|
||||
do {
|
||||
by = bitmap[pixel_data++];
|
||||
by = bitmap[data_idx++];
|
||||
if (by) {
|
||||
count = by;
|
||||
by = bitmap[pixel_data++];
|
||||
for (c = 0; c < count; c+=2) {
|
||||
count = by >> 1;
|
||||
by = bitmap[data_idx++];
|
||||
for (c = 0; c < count; c++) {
|
||||
if ((by >> 4) != transp_idx) draw_pixel({static_cast<ui::Coord>(p.x + px), static_cast<ui::Coord>(p.y + py)}, palette[by >> 4]);
|
||||
px++;
|
||||
if (px < bmpwidth) {
|
||||
if (px < bmp_header->width) {
|
||||
if ((by & 15) != transp_idx) draw_pixel({static_cast<ui::Coord>(p.x + px), static_cast<ui::Coord>(p.y + py)}, palette[by & 15]);
|
||||
}
|
||||
px++;
|
||||
}
|
||||
if (pixel_data & 1) pixel_data++;
|
||||
if (data_idx & 1) data_idx++;
|
||||
} else {
|
||||
by = bitmap[pixel_data++];
|
||||
by = bitmap[data_idx++];
|
||||
if (by == 0) {
|
||||
py--;
|
||||
px = 0;
|
||||
@@ -384,17 +371,17 @@ void ILI9341::drawBMP(const ui::Point p, const uint8_t * bitmap, const bool tran
|
||||
} else if (by == 2) {
|
||||
// Delta
|
||||
} else {
|
||||
count = by;
|
||||
for (c = 0; c < count; c+=2) {
|
||||
by = bitmap[pixel_data++];
|
||||
count = by >> 1;
|
||||
for (c = 0; c < count; c++) {
|
||||
by = bitmap[data_idx++];
|
||||
if ((by >> 4) != transp_idx) draw_pixel({static_cast<ui::Coord>(p.x + px), static_cast<ui::Coord>(p.y + py)}, palette[by >> 4]);
|
||||
px++;
|
||||
if (px < bmpwidth) {
|
||||
if (px < bmp_header->width) {
|
||||
if ((by & 15) != transp_idx) draw_pixel({static_cast<ui::Coord>(p.x + px), static_cast<ui::Coord>(p.y + py)}, palette[by & 15]);
|
||||
}
|
||||
px++;
|
||||
}
|
||||
if (pixel_data & 1) pixel_data++;
|
||||
if (data_idx & 1) data_idx++;
|
||||
}
|
||||
}
|
||||
} while (1);
|
||||
|
@@ -109,6 +109,33 @@ private:
|
||||
uint16_t height;
|
||||
uint16_t current_position;
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct bmp_t {
|
||||
uint16_t signature;
|
||||
uint32_t size;
|
||||
uint16_t reserved_1;
|
||||
uint16_t reserved_2;
|
||||
uint32_t image_data;
|
||||
uint32_t BIH_size;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint16_t planes;
|
||||
uint16_t bpp;
|
||||
uint32_t compression;
|
||||
uint32_t data_size;
|
||||
uint32_t h_res;
|
||||
uint32_t v_res;
|
||||
uint32_t colors_count;
|
||||
uint32_t icolors_count;
|
||||
struct palette {
|
||||
uint8_t B;
|
||||
uint8_t G;
|
||||
uint8_t R;
|
||||
uint8_t A;
|
||||
} palette[16];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
scroll_t scroll_state;
|
||||
|
||||
|
@@ -820,7 +820,6 @@ bool ImageButton::on_touch(const TouchEvent event) {
|
||||
set_dirty();
|
||||
return true;
|
||||
|
||||
|
||||
case TouchEvent::Type::End:
|
||||
set_highlighted(false);
|
||||
set_dirty();
|
||||
@@ -1040,12 +1039,12 @@ void NumberField::paint(Painter& painter) {
|
||||
}
|
||||
|
||||
bool NumberField::on_key(const KeyEvent key) {
|
||||
/*if( key == KeyEvent::Select ) {
|
||||
if( key == KeyEvent::Select ) {
|
||||
if( on_select ) {
|
||||
on_select(*this);
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -403,6 +403,7 @@ private:
|
||||
|
||||
class NumberField : public Widget {
|
||||
public:
|
||||
std::function<void(NumberField&)> on_select;
|
||||
std::function<void(int32_t)> on_change;
|
||||
|
||||
using range_t = std::pair<int32_t, int32_t>;
|
||||
|
Reference in New Issue
Block a user