-
-
Notifications
You must be signed in to change notification settings - Fork 598
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'portapack-mayhem:next' into no_touchscreen_workaround
- Loading branch information
Showing
42 changed files
with
818 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* Copyright (C) 2024 Bernd Herzog | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include "ui_external_module_view.hpp" | ||
#include "portapack.hpp" | ||
#include "ui_standalone_view.hpp" | ||
|
||
#include "i2cdevmanager.hpp" | ||
#include "i2cdev_ppmod.hpp" | ||
|
||
#include <optional> | ||
|
||
namespace ui { | ||
|
||
void ExternalModuleView::focus() { | ||
dummy.focus(); | ||
} | ||
|
||
void ExternalModuleView::on_tick_second() { | ||
i2cdev::I2CDevManager::manual_scan(); | ||
|
||
auto dev = (i2cdev::I2cDev_PPmod*)i2cdev::I2CDevManager::get_dev_by_model(I2C_DEVMDL::I2CDECMDL_PPMOD); | ||
|
||
if (!dev) { | ||
text_header.set("No module connected"); | ||
text_name.set(""); | ||
text_version.set(""); | ||
text_number_apps.set(""); | ||
text_app1_name.set(""); | ||
text_app2_name.set(""); | ||
text_app3_name.set(""); | ||
text_app4_name.set(""); | ||
text_app5_name.set(""); | ||
return; | ||
} | ||
|
||
auto device_info = dev->readDeviceInfo(); | ||
|
||
if (device_info.has_value() == false) { | ||
text_header.set("No module connected"); | ||
text_name.set(""); | ||
text_version.set(""); | ||
text_number_apps.set(""); | ||
text_app1_name.set(""); | ||
text_app2_name.set(""); | ||
text_app3_name.set(""); | ||
text_app4_name.set(""); | ||
text_app5_name.set(""); | ||
return; | ||
} | ||
|
||
text_header.set("Module found"); | ||
|
||
std::string btnText = (std::string) "Module: " + device_info->module_name; | ||
text_name.set(btnText); | ||
text_version.set("Version: " + std::to_string(device_info->module_version)); | ||
text_number_apps.set("No# Apps: " + std::to_string(device_info->application_count)); | ||
|
||
for (uint32_t i = 0; i < device_info->application_count && i < 5; i++) { | ||
auto appInfo = dev->getStandaloneAppInfo(i); | ||
if (appInfo.has_value() == false) { | ||
continue; | ||
} | ||
|
||
std::string btnText = (std::string) "App " + std::to_string(device_info->application_count) + ": " + (const char*)appInfo->app_name; | ||
|
||
switch (appInfo->menu_location) { | ||
case app_location_t::UTILITIES: | ||
btnText += " (Utilities)"; | ||
break; | ||
case app_location_t::RX: | ||
btnText += " (RX)"; | ||
break; | ||
case app_location_t::TX: | ||
btnText += " (TX)"; | ||
break; | ||
case app_location_t::DEBUG: | ||
btnText += " (Debug)"; | ||
break; | ||
case app_location_t::HOME: | ||
btnText += " (Home)"; | ||
break; | ||
} | ||
|
||
switch (i) { | ||
case 0: | ||
text_app1_name.set(btnText); | ||
break; | ||
case 1: | ||
text_app2_name.set(btnText); | ||
break; | ||
case 2: | ||
text_app3_name.set(btnText); | ||
break; | ||
case 3: | ||
text_app4_name.set(btnText); | ||
break; | ||
case 4: | ||
text_app5_name.set(btnText); | ||
break; | ||
} | ||
} | ||
} | ||
} // namespace ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright (C) 2024 Bernd Herzog | ||
* | ||
* 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. | ||
*/ | ||
|
||
#ifndef __UI_EXTERNAL_MODULE_VIEW_H | ||
#define __UI_EXTERNAL_MODULE_VIEW_H | ||
|
||
#include "ui.hpp" | ||
#include "ui_widget.hpp" | ||
#include "ui_painter.hpp" | ||
#include "ui_menu.hpp" | ||
#include "ui_navigation.hpp" | ||
|
||
#include "rffc507x.hpp" | ||
#include "portapack.hpp" | ||
#include "memory_map.hpp" | ||
#include "irq_controls.hpp" | ||
|
||
#include <functional> | ||
#include <utility> | ||
|
||
#include "i2cdevmanager.hpp" | ||
#include "i2cdev_ppmod.hpp" | ||
|
||
namespace ui { | ||
|
||
class ExternalModuleView : public View { | ||
public: | ||
ExternalModuleView(NavigationView& nav) | ||
: nav_(nav) { | ||
add_children({&text_header, | ||
&text_name, | ||
&text_version, | ||
&text_number_apps, | ||
&text_app1_name, | ||
&text_app2_name, | ||
&text_app3_name, | ||
&text_app4_name, | ||
&text_app5_name, | ||
&dummy}); | ||
|
||
text_header.set("No module connected"); | ||
|
||
signal_token_tick_second = rtc_time::signal_tick_second += [this]() { | ||
on_tick_second(); | ||
}; | ||
} | ||
|
||
~ExternalModuleView() { | ||
rtc_time::signal_tick_second -= signal_token_tick_second; | ||
} | ||
|
||
std::string title() const override { return "Ext Module"; }; | ||
void focus() override; | ||
|
||
private: | ||
NavigationView& nav_; | ||
Text text_header{{16, 16, 208, 16}}; | ||
Text text_name{{24, 32, 200, 16}}; | ||
Text text_version{{24, 48, 200, 16}}; | ||
Text text_number_apps{{24, 64, 200, 16}}; | ||
|
||
Text text_app1_name{{24, 96, 200, 16}}; | ||
Text text_app2_name{{24, 112, 200, 16}}; | ||
Text text_app3_name{{24, 128, 200, 16}}; | ||
Text text_app4_name{{24, 144, 200, 16}}; | ||
Text text_app5_name{{24, 160, 200, 16}}; | ||
|
||
Button dummy{ | ||
{240, 0, 0, 0}, | ||
""}; | ||
|
||
SignalToken signal_token_tick_second{}; | ||
|
||
void on_tick_second(); | ||
}; | ||
|
||
} // namespace ui | ||
|
||
#endif |
Oops, something went wrong.