2016-01-07 08:17:39 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2016-01-29 18:28:05 -05:00
|
|
|
* Copyright (C) 2016 Furrtek
|
2016-01-07 08:17:39 -05:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-07-26 21:03:40 -04:00
|
|
|
#include "cpld_update.hpp"
|
2016-01-29 18:28:05 -05:00
|
|
|
#include "portapack.hpp"
|
2016-02-04 04:27:53 -05:00
|
|
|
#include "event_m0.hpp"
|
2016-01-29 18:28:05 -05:00
|
|
|
|
2016-01-07 08:17:39 -05:00
|
|
|
#include "ui_about.hpp"
|
|
|
|
|
2016-01-29 18:28:05 -05:00
|
|
|
#include "portapack_shared_memory.hpp"
|
2016-01-07 08:17:39 -05:00
|
|
|
#include "portapack_persistent_memory.hpp"
|
|
|
|
#include "lpc43xx_cpp.hpp"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
using namespace lpc43xx;
|
|
|
|
using namespace portapack;
|
|
|
|
|
|
|
|
namespace ui {
|
2016-01-29 18:28:05 -05:00
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
void AboutView::update() {
|
|
|
|
size_t c;
|
|
|
|
int32_t n;
|
|
|
|
std::string text;
|
|
|
|
Coord y_val, x_pos = 0;
|
|
|
|
uint32_t flag;
|
|
|
|
|
|
|
|
if (scroll & 1) {
|
|
|
|
if (!((scroll >> 1) & 15)) {
|
|
|
|
if (line_feed) {
|
|
|
|
line_feed = false;
|
2016-01-29 18:28:05 -05:00
|
|
|
} else {
|
2016-12-09 12:21:47 -05:00
|
|
|
// Find a free text widget
|
|
|
|
for (c = 0; c < 10; c++)
|
2017-01-15 22:45:44 -05:00
|
|
|
if (text_line[c].screen_pos().y() >= 200) break;
|
2016-12-09 12:21:47 -05:00
|
|
|
|
|
|
|
if (c < 10) {
|
|
|
|
flag = credits[credits_index].flag & 0x3F;
|
|
|
|
line_feed = (credits[credits_index].flag & 0x40) ? true : false;
|
|
|
|
|
|
|
|
if (flag == SECTION) {
|
|
|
|
if (!second) {
|
|
|
|
text = credits[credits_index].role;
|
|
|
|
if (credits[credits_index].name != "")
|
|
|
|
second = true;
|
|
|
|
else {
|
|
|
|
credits_index++;
|
|
|
|
line_feed = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
text = credits[credits_index].name;
|
|
|
|
second = false;
|
|
|
|
line_feed = true;
|
|
|
|
credits_index++;
|
|
|
|
}
|
|
|
|
x_pos = (240 - (text.size() * 8)) / 2;
|
|
|
|
} else if (flag == TITLE) {
|
|
|
|
text = credits[credits_index].role;
|
|
|
|
x_pos = 120 - (text.size() * 8);
|
|
|
|
if (credits[credits_index].name != "")
|
|
|
|
text += " " + credits[credits_index].name;
|
|
|
|
credits_index++;
|
|
|
|
} else if (flag == MEMBER) {
|
|
|
|
if (!second) {
|
|
|
|
text = credits[credits_index].role;
|
|
|
|
if (credits[credits_index].name != "")
|
|
|
|
second = true;
|
|
|
|
else
|
|
|
|
credits_index++;
|
2016-01-29 18:28:05 -05:00
|
|
|
} else {
|
2016-12-09 12:21:47 -05:00
|
|
|
text = credits[credits_index].name;
|
|
|
|
second = false;
|
|
|
|
credits_index++;
|
2016-01-29 18:28:05 -05:00
|
|
|
}
|
2016-12-09 12:21:47 -05:00
|
|
|
x_pos = 136;
|
2016-01-29 18:28:05 -05:00
|
|
|
}
|
2016-12-09 12:21:47 -05:00
|
|
|
|
|
|
|
if (!(flag & 0x80)) {
|
|
|
|
text_line[c].set_parent_rect({{ x_pos, 200 - 16 }, { (Dim)text.size() * 8, 17 }});
|
|
|
|
text_line[c].set(text);
|
|
|
|
text_line[c].hidden(false);
|
2016-01-29 18:28:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
// Scroll text lines
|
|
|
|
for (c = 0; c < 10; c++) {
|
2017-01-15 22:45:44 -05:00
|
|
|
y_val = text_line[c].screen_pos().y() - 16;
|
2016-12-09 12:21:47 -05:00
|
|
|
if (y_val < 32) {
|
2017-01-15 22:45:44 -05:00
|
|
|
text_line[c].set_parent_rect({{ text_line[c].screen_pos().x(), 200 }, { text_line[c].size() }});
|
2016-12-09 12:21:47 -05:00
|
|
|
text_line[c].hidden(true);
|
2016-01-29 18:28:05 -05:00
|
|
|
} else {
|
2016-12-09 12:21:47 -05:00
|
|
|
if (y_val < 200) {
|
2017-01-15 22:45:44 -05:00
|
|
|
text_line[c].set_parent_rect({{ text_line[c].screen_pos().x(), y_val - 1 }, { text_line[c].size() }});
|
2016-12-09 12:21:47 -05:00
|
|
|
n = (y_val - 32) >> 2;
|
|
|
|
if (n > 19)
|
|
|
|
n = (38 - n);
|
|
|
|
else
|
|
|
|
n -= 3;
|
|
|
|
if (n > 3) n = 3;
|
|
|
|
if (n < 0) n = 0;
|
|
|
|
text_line[c].set_style(&styles[n]);
|
|
|
|
}
|
2016-01-29 18:28:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-09 12:21:47 -05:00
|
|
|
scroll++;
|
2016-01-29 18:28:05 -05:00
|
|
|
}
|
2016-01-07 08:17:39 -05:00
|
|
|
|
2016-01-29 18:28:05 -05:00
|
|
|
AboutView::AboutView(
|
2016-02-04 04:27:53 -05:00
|
|
|
NavigationView& nav
|
|
|
|
)
|
2016-01-29 18:28:05 -05:00
|
|
|
{
|
2016-12-09 12:21:47 -05:00
|
|
|
//uint8_t p, c;
|
2016-08-16 20:55:34 -04:00
|
|
|
|
2017-01-15 22:45:44 -05:00
|
|
|
add_children({
|
2016-01-07 08:17:39 -05:00
|
|
|
&text_cpld_hackrf,
|
2016-07-26 21:03:40 -04:00
|
|
|
&text_cpld_hackrf_status,
|
2016-01-07 08:17:39 -05:00
|
|
|
&button_ok,
|
2017-01-15 22:45:44 -05:00
|
|
|
});
|
2016-01-29 18:28:05 -05:00
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
for (auto& text : text_line) {
|
|
|
|
text.set("");
|
|
|
|
text.set_parent_rect({
|
|
|
|
static_cast<Coord>(0),
|
|
|
|
static_cast<Coord>(200),
|
|
|
|
0, 0
|
|
|
|
});
|
|
|
|
add_child(&text);
|
|
|
|
}
|
|
|
|
|
2016-07-26 21:03:40 -04:00
|
|
|
if( cpld_hackrf_verify_eeprom() ) {
|
|
|
|
text_cpld_hackrf_status.set(" OK");
|
|
|
|
} else {
|
|
|
|
text_cpld_hackrf_status.set("BAD");
|
|
|
|
}
|
2016-01-29 18:28:05 -05:00
|
|
|
|
|
|
|
button_ok.on_select = [this,&nav](Button&){
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
2016-01-07 08:17:39 -05:00
|
|
|
|
|
|
|
void AboutView::focus() {
|
|
|
|
button_ok.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace ui */
|