mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-08 06:32:35 -04:00
Added raw ASCII char field in keyboard view
This commit is contained in:
parent
94b27ec45c
commit
72f3c08e9b
11 changed files with 110 additions and 70 deletions
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Bitmaps generated with:
|
// Bitmaps generated with:
|
||||||
// Gimp :( > indexed colors, then "xxd -i *.bmp"
|
// Gimp image > indexed colors (16), then "xxd -i *.bmp"
|
||||||
|
|
||||||
//BUG: No audio in about when shown second time
|
//BUG: No audio in about when shown second time
|
||||||
//BUG: Description doesn't show up first time going to system>module info (UI drawn on top)
|
//BUG: Description doesn't show up first time going to system>module info (UI drawn on top)
|
||||||
|
|
|
@ -1,3 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||||
|
* Copyright (C) 2016 Furrtek
|
||||||
|
*
|
||||||
|
* This file is part of PortaPack.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
const unsigned char splash_bmp[] = {
|
const unsigned char splash_bmp[] = {
|
||||||
0x42, 0x4d, 0x28, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00,
|
0x42, 0x4d, 0x28, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00,
|
||||||
0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, 0x1b, 0x01,
|
0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, 0x1b, 0x01,
|
||||||
|
|
|
@ -106,12 +106,12 @@ AlphanumView::AlphanumView(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*add_child(&raw_char);
|
add_child(&raw_char);
|
||||||
raw_char.set_value(0x30);
|
raw_char.set_value(0x30);
|
||||||
raw_char.on_select = [this, &nav, txt, max_len](Button&) {
|
raw_char.on_select = [this, &nav, txt, max_len](NumberField&) {
|
||||||
char_add(raw_char.value());
|
char_add(raw_char.value());
|
||||||
update_text();
|
update_text();
|
||||||
};*/
|
};
|
||||||
|
|
||||||
add_child(&button_done);
|
add_child(&button_done);
|
||||||
button_done.on_select = [this, &nav, txt, max_len](Button&) {
|
button_done.on_select = [this, &nav, txt, max_len](Button&) {
|
||||||
|
|
|
@ -73,13 +73,13 @@ private:
|
||||||
"UC"
|
"UC"
|
||||||
};
|
};
|
||||||
|
|
||||||
/*NumberField raw_char {
|
NumberField raw_char {
|
||||||
{ 16, 270, 16, 16 },
|
{ 16, 270 },
|
||||||
3,
|
3,
|
||||||
{ 1, 255 },
|
{ 1, 255 },
|
||||||
1,
|
1,
|
||||||
'0'
|
'0'
|
||||||
};*/
|
};
|
||||||
|
|
||||||
Button button_done {
|
Button button_done {
|
||||||
{ 88, 270, 64, 24 },
|
{ 88, 270, 64, 24 },
|
||||||
|
|
|
@ -123,7 +123,11 @@ void LCRView::generate_message() {
|
||||||
// Alt format
|
// Alt format
|
||||||
for (dp = 0; dp < strlen(lcr_message); dp++) {
|
for (dp = 0; dp < strlen(lcr_message); dp++) {
|
||||||
pp = pm;
|
pp = pm;
|
||||||
cur_byte = alt_lookup[(uint8_t)lcr_message[dp] & 0x7F];
|
// Do not apply LUT on checksum (last byte) ?
|
||||||
|
if (dp != strlen(lcr_message) - 1)
|
||||||
|
cur_byte = alt_lookup[(uint8_t)lcr_message[dp] & 0x7F];
|
||||||
|
else
|
||||||
|
cur_byte = lcr_message[dp];
|
||||||
for (cp = 0; cp < 8; cp++) {
|
for (cp = 0; cp < 8; cp++) {
|
||||||
if ((cur_byte >> cp) & 1) pp++;
|
if ((cur_byte >> cp) & 1) pp++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ private:
|
||||||
// 9: 85 ?
|
// 9: 85 ?
|
||||||
|
|
||||||
const char alt_lookup[128] = {
|
const char alt_lookup[128] = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0F, // 0
|
0, 0, 0, 0x5F, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0F, // 0
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 10
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 10
|
||||||
0xF8, 0, 0x99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20 !"#$%&'()*+,-./
|
0xF8, 0, 0x99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20 !"#$%&'()*+,-./
|
||||||
0xF5, 0, 0x94, 0x55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1C, 0, 0, // 30 0123456789:;<=>?
|
0xF5, 0, 0x94, 0x55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1C, 0, 0, // 30 0123456789:;<=>?
|
||||||
|
|
|
@ -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);
|
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) {
|
void ILI9341::drawBMP(const ui::Point p, const uint8_t * bitmap, const bool transparency) {
|
||||||
uint32_t pixel_data, pal_data;
|
const bmp_t * bmp_header = (const bmp_t *)bitmap;
|
||||||
uint8_t pal, by, c, count, transp_idx = 0, color_r, color_g, color_b;
|
uint32_t data_idx;
|
||||||
ui::Color linebuffer[240];
|
uint8_t by, c, count, transp_idx = 0;
|
||||||
|
ui::Color line_buffer[240];
|
||||||
ui::Coord px = 0, py;
|
ui::Coord px = 0, py;
|
||||||
ui::Color palette[16];
|
ui::Color palette[16];
|
||||||
uint32_t bmpwidth, bmpheight;
|
|
||||||
|
|
||||||
// RLE_4 BMP loader with no delta :(
|
// Abort if bad depth or no RLE
|
||||||
|
if ((bmp_header->bpp != 4) ||
|
||||||
if (bitmap[0x1E] != 2) return; // Bad compression type
|
(bmp_header->compression != 2)) return;
|
||||||
|
|
||||||
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) );
|
|
||||||
|
|
||||||
pal_data = bitmap[0x0E] + 0x0E;
|
data_idx = bmp_header->image_data;
|
||||||
|
|
||||||
pixel_data = bitmap[0x0A];
|
// Convert palette and find pure magenta index (alpha color key)
|
||||||
pal = 0;
|
for (c = 0; c < 16; c++) {
|
||||||
for (c = 0; c < (16*4); c+=4) {
|
palette[c] = ui::Color(bmp_header->palette[c].R, bmp_header->palette[c].G, bmp_header->palette[c].B);
|
||||||
color_r = bitmap[c+2+pal_data];
|
if ((bmp_header->palette[c].R == 0xFF) &&
|
||||||
color_g = bitmap[c+1+pal_data];
|
(bmp_header->palette[c].G == 0x00) &&
|
||||||
color_b = bitmap[c+pal_data];
|
(bmp_header->palette[c].B == 0xFF)) transp_idx = c;
|
||||||
palette[pal] = ui::Color(color_r, color_g, color_b);
|
|
||||||
if ((color_r == 0xFF) && (color_g == 0x00) && (color_b == 0xFF)) transp_idx = pal;
|
|
||||||
pal++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!transparency) {
|
if (!transparency) {
|
||||||
py = bmpheight + 16; // +1 ?
|
py = bmp_header->height + 16;
|
||||||
do {
|
do {
|
||||||
by = bitmap[pixel_data++];
|
by = bitmap[data_idx++];
|
||||||
if (by) {
|
if (by) {
|
||||||
count = by;
|
count = by >> 1;
|
||||||
by = bitmap[pixel_data++];
|
by = bitmap[data_idx++];
|
||||||
for (c = 0; c < count; c+=2) {
|
for (c = 0; c < count; c++) {
|
||||||
linebuffer[px++] = palette[by >> 4];
|
line_buffer[px++] = palette[by >> 4];
|
||||||
if (px < bmpwidth) linebuffer[px++] = palette[by & 15];
|
if (px < bmp_header->width) line_buffer[px++] = palette[by & 15];
|
||||||
}
|
}
|
||||||
if (pixel_data & 1) pixel_data++;
|
if (data_idx & 1) data_idx++;
|
||||||
} else {
|
} else {
|
||||||
by = bitmap[pixel_data++];
|
by = bitmap[data_idx++];
|
||||||
if (by == 0) {
|
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--;
|
py--;
|
||||||
px = 0;
|
px = 0;
|
||||||
} else if (by == 1) {
|
} 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) {
|
} else if (by == 2) {
|
||||||
// Delta
|
// Delta
|
||||||
} else {
|
} else {
|
||||||
count = by;
|
count = by >> 1;
|
||||||
for (c = 0; c < count; c+=2) {
|
for (c = 0; c < count; c++) {
|
||||||
by = bitmap[pixel_data++];
|
by = bitmap[data_idx++];
|
||||||
linebuffer[px++] = palette[by >> 4];
|
line_buffer[px++] = palette[by >> 4];
|
||||||
if (px < bmpwidth) linebuffer[px++] = palette[by & 15];
|
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);
|
} while (1);
|
||||||
} else {
|
} else {
|
||||||
py = bmpheight; // +1 ?
|
py = bmp_header->height;
|
||||||
do {
|
do {
|
||||||
by = bitmap[pixel_data++];
|
by = bitmap[data_idx++];
|
||||||
if (by) {
|
if (by) {
|
||||||
count = by;
|
count = by >> 1;
|
||||||
by = bitmap[pixel_data++];
|
by = bitmap[data_idx++];
|
||||||
for (c = 0; c < count; c+=2) {
|
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]);
|
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++;
|
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]);
|
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++;
|
px++;
|
||||||
}
|
}
|
||||||
if (pixel_data & 1) pixel_data++;
|
if (data_idx & 1) data_idx++;
|
||||||
} else {
|
} else {
|
||||||
by = bitmap[pixel_data++];
|
by = bitmap[data_idx++];
|
||||||
if (by == 0) {
|
if (by == 0) {
|
||||||
py--;
|
py--;
|
||||||
px = 0;
|
px = 0;
|
||||||
|
@ -384,17 +371,17 @@ void ILI9341::drawBMP(const ui::Point p, const uint8_t * bitmap, const bool tran
|
||||||
} else if (by == 2) {
|
} else if (by == 2) {
|
||||||
// Delta
|
// Delta
|
||||||
} else {
|
} else {
|
||||||
count = by;
|
count = by >> 1;
|
||||||
for (c = 0; c < count; c+=2) {
|
for (c = 0; c < count; c++) {
|
||||||
by = bitmap[pixel_data++];
|
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]);
|
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++;
|
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]);
|
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++;
|
px++;
|
||||||
}
|
}
|
||||||
if (pixel_data & 1) pixel_data++;
|
if (data_idx & 1) data_idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
|
@ -109,6 +109,33 @@ private:
|
||||||
uint16_t height;
|
uint16_t height;
|
||||||
uint16_t current_position;
|
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;
|
scroll_t scroll_state;
|
||||||
|
|
||||||
|
|
|
@ -820,7 +820,6 @@ bool ImageButton::on_touch(const TouchEvent event) {
|
||||||
set_dirty();
|
set_dirty();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
case TouchEvent::Type::End:
|
case TouchEvent::Type::End:
|
||||||
set_highlighted(false);
|
set_highlighted(false);
|
||||||
set_dirty();
|
set_dirty();
|
||||||
|
@ -1040,12 +1039,12 @@ void NumberField::paint(Painter& painter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NumberField::on_key(const KeyEvent key) {
|
bool NumberField::on_key(const KeyEvent key) {
|
||||||
/*if( key == KeyEvent::Select ) {
|
if( key == KeyEvent::Select ) {
|
||||||
if( on_select ) {
|
if( on_select ) {
|
||||||
on_select(*this);
|
on_select(*this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,6 +403,7 @@ private:
|
||||||
|
|
||||||
class NumberField : public Widget {
|
class NumberField : public Widget {
|
||||||
public:
|
public:
|
||||||
|
std::function<void(NumberField&)> on_select;
|
||||||
std::function<void(int32_t)> on_change;
|
std::function<void(int32_t)> on_change;
|
||||||
|
|
||||||
using range_t = std::pair<int32_t, int32_t>;
|
using range_t = std::pair<int32_t, int32_t>;
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue