refactor name

This commit is contained in:
zxkmm 2024-09-29 16:29:53 +08:00
parent 423bb9ec6a
commit 35edb7f7ea
5 changed files with 40 additions and 40 deletions

View File

@ -98,8 +98,8 @@ set(EXTCPPSRC
external/sstvtx/ui_sstvtx.cpp
#random
external/random/main.cpp
external/random/ui_random.cpp
external/random_password/main.cpp
external/random_password/ui_random_password.cpp
)
set(EXTAPPLIST
@ -126,5 +126,5 @@ set(EXTAPPLIST
adsbtx
morse_tx
sstvtx
random
random_password
)

View File

@ -46,7 +46,7 @@ MEMORY
ram_external_app_adsbtx(rwx) : org = 0xADC50000, len = 32k
ram_external_app_morse_tx(rwx) : org = 0xADC60000, len = 32k
ram_external_app_sstvtx(rwx) : org = 0xADC70000, len = 32k
ram_external_app_random(rwx) : org = 0xADC80000, len = 32k
ram_external_app_random_password(rwx) : org = 0xADC80000, len = 32k
}
SECTIONS
@ -191,10 +191,10 @@ SECTIONS
*(*ui*external_app*sstvtx*);
} > ram_external_app_sstvtx
.external_app_random : ALIGN(4) SUBALIGN(4)
.external_app_random_password : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_random.application_information));
*(*ui*external_app*random*);
} > ram_external_app_random
KEEP(*(.external_app.app_random_password.application_information));
*(*ui*external_app*random_password*);
} > ram_external_app_random_password
}

View File

@ -20,25 +20,25 @@
*/
#include "ui.hpp"
#include "ui_random.hpp"
#include "ui_random_password.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::random {
namespace ui::external_app::random_password {
void initialize_app(ui::NavigationView& nav) {
nav.push<RandomView>();
nav.push<RandomPasswordView>();
}
} // namespace ui::external_app::random
} // namespace ui::external_app::random_password
extern "C" {
__attribute__((section(".external_app.app_random.application_information"), used)) application_information_t _application_information_random = {
__attribute__((section(".external_app.app_random_password.application_information"), used)) application_information_t _application_information_random_password = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::random::initialize_app,
/*.externalAppEntry = */ ui::external_app::random_password::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "random",
/*.app_name = */ "random_password",
/*.bitmap_data = */ {
0xC0,
0x03,

View File

@ -21,7 +21,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "ui_random.hpp"
#include "ui_random_password.hpp"
#include "ui_modemsetup.hpp"
#include "modems.hpp"
@ -35,17 +35,17 @@ using namespace portapack;
using namespace modems;
using namespace ui;
namespace ui::external_app::random {
namespace ui::external_app::random_password {
void RandomLogger::log_raw_data(const std::string& data) {
void RandomPasswordLogger::log_raw_data(const std::string& data) {
log_file.write_entry(data);
}
void RandomView::focus() {
void RandomPasswordView::focus() {
field_digits.focus();
}
RandomView::RandomView(NavigationView& nav)
RandomPasswordView::RandomPasswordView(NavigationView& nav)
: nav_{nav} {
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
@ -172,7 +172,7 @@ RandomView::RandomView(NavigationView& nav)
field_digits.set_value(8);
///^ check defauly val init
logger = std::make_unique<RandomLogger>();
logger = std::make_unique<RandomPasswordLogger>();
if (logger)
logger->append(logs_dir / u"random.TXT");
@ -185,7 +185,7 @@ RandomView::RandomView(NavigationView& nav)
new_password();
}
void RandomView::on_data(uint32_t value, bool is_data) {
void RandomPasswordView::on_data(uint32_t value, bool is_data) {
if (paused)
return;
if (is_data) {
@ -197,11 +197,11 @@ void RandomView::on_data(uint32_t value, bool is_data) {
}
}
void RandomView::on_freqchg(int64_t freq) {
void RandomPasswordView::on_freqchg(int64_t freq) {
field_frequency.set_value(freq);
}
void RandomView::set_random_freq() {
void RandomPasswordView::set_random_freq() {
std::srand(LPC_RTC->CTIME0);
// this is only for seed to visit random freq, the radio is still real random
@ -210,7 +210,7 @@ void RandomView::set_random_freq() {
field_frequency.set_value(random_freq);
}
void RandomView::new_password() {
void RandomPasswordView::new_password() {
password = "";
std::string charset;
std::string char_type_hints;
@ -287,7 +287,7 @@ void RandomView::new_password() {
// 4. override nav's paint func (i think it can tried to capture same obj) and paint in a seperate func, hoping set_dirty handle it correctly
// all these methods failed, and all of them only flash and disappeared. only when set_dirty in on_data (which seems incorrect), and it keep flashing never stop. but see painted content (flashing too)
// btw this is not caused by the seed text set thing, cuz commented it out not helping.
void RandomView::paint_password_hints() {
void RandomPasswordView::paint_password_hints() {
Painter painter;
const int char_width = 8;
const int char_height = 16;
@ -314,16 +314,16 @@ void RandomView::paint_password_hints() {
}
}
std::string RandomView::generate_log_line() {
std::string RandomPasswordView::generate_log_line() {
std::string line = "\npassword=" + password +
"\nseed=" + std::to_string(seed) +
"\n";
return line;
}
RandomView::~RandomView() {
RandomPasswordView::~RandomPasswordView() {
receiver_model.disable();
baseband::shutdown();
}
} // namespace ui::external_app::random
} // namespace ui::external_app::random_password

View File

@ -21,8 +21,8 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef __UI_RANDOM_H__
#define __UI_RANDOM_H__
#ifndef __UI_RANDOM_PASSWORD_H__
#define __UI_RANDOM_PASSWORD_H__
#include "ui.hpp"
#include "ui_language.hpp"
@ -39,9 +39,9 @@
using namespace ui;
namespace ui::external_app::random {
namespace ui::external_app::random_password {
class RandomLogger {
class RandomPasswordLogger {
public:
Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename);
@ -53,14 +53,14 @@ class RandomLogger {
LogFile log_file{};
};
class RandomView : public View {
class RandomPasswordView : public View {
public:
RandomView(NavigationView& nav);
~RandomView();
RandomPasswordView(NavigationView& nav);
~RandomPasswordView();
void focus() override;
std::string title() const override { return "random"; };
std::string title() const override { return "r.passwd"; };
private:
unsigned int seed = 0; // extern void srand (unsigned int __seed) __THROW;
@ -184,7 +184,7 @@ class RandomView : public View {
void on_data_afsk(const AFSKDataMessage& message);
std::unique_ptr<RandomLogger> logger{};
std::unique_ptr<RandomPasswordLogger> logger{};
MessageHandlerRegistration message_handler_packet{
Message::ID::AFSKData,
@ -204,6 +204,6 @@ class RandomView : public View {
void set_random_freq();
};
} // namespace ui::external_app::random
} // namespace ui::external_app::random_password
#endif /*__UI_RANDOM_H__*/
#endif /*__UI_RANDOM_PASSWORD_H__*/