mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-21 06:59:02 +00:00
Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c46cc431c9 | |||
| a4d23768c1 | |||
| 344aa0c741 | |||
| fd7637187a | |||
| 674b865ec0 | |||
| 00c9c6b40e | |||
| 113cbc42c9 | |||
| 454b8776b6 | |||
| efdf043d62 | |||
| 0f9d9e589d | |||
| 3b57672dda | |||
| b739dd883c | |||
| bf18851b6b | |||
| 81afec9ea4 | |||
| 60a5222058 | |||
| 7041d507ca | |||
| d3373734e9 | |||
| 200831ad67 | |||
| dafe3b7641 | |||
| 63634407b6 | |||
| 9f06ccf9ae | |||
| 6782e12a15 | |||
| cbbd8103d3 | |||
| e88ab44f49 | |||
| 545dead1ca | |||
| e3b2a65b39 | |||
| 2f4d222403 | |||
| 54d99945f2 | |||
| 65a3c797c6 | |||
| 6a81a981aa | |||
| 193ac73b34 | |||
| 477d035dce | |||
| 1d8f53b49e | |||
| db324a5225 | |||
| b2331bf818 | |||
| 4b18ac42e9 | |||
| 41dd0c4674 | |||
| 371b6b5079 | |||
| 23cabb8b8a | |||
| b3edaf3cd0 | |||
| 9afd3a9dca | |||
| d80f41e9d7 | |||
| 46d87d95ae | |||
| 7626dff1ef | |||
| f101680521 | |||
| 325f295ee8 | |||
| b15bb59678 | |||
| 776c9bc7c9 | |||
| b9ebefc7c7 | |||
| 70ace4be8f | |||
| fe826d5d98 | |||
| 4dda7cfaa5 | |||
| e6d4081c06 | |||
| 4f738adc70 | |||
| d516191ccb | |||
| 29bdc539a3 | |||
| 29bba4d0ea | |||
| a6f886ad0a | |||
| 2d2d9223f2 | |||
| 6e33007cb6 | |||
| 3f7b59f27e | |||
| 375d1ad54e | |||
| 6b05878532 | |||
| 3983749f11 | |||
| 28e2f770e5 |
@@ -1 +1 @@
|
|||||||
v2.1.0
|
v2.2.0
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v2.2.0
|
v2.3.1
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ cmake-build-debug/
|
|||||||
.vscode
|
.vscode
|
||||||
.idea
|
.idea
|
||||||
*.swp
|
*.swp
|
||||||
|
.claude
|
||||||
|
|
||||||
# VSCodium extensions
|
# VSCodium extensions
|
||||||
.history
|
.history
|
||||||
|
|||||||
@@ -192,7 +192,6 @@ set(CPPSRC
|
|||||||
core_control.cpp
|
core_control.cpp
|
||||||
database.cpp
|
database.cpp
|
||||||
gradient.cpp
|
gradient.cpp
|
||||||
rfm69.cpp
|
|
||||||
event_m0.cpp
|
event_m0.cpp
|
||||||
file_reader.cpp
|
file_reader.cpp
|
||||||
file.cpp
|
file.cpp
|
||||||
@@ -261,7 +260,6 @@ set(CPPSRC
|
|||||||
ui/ui_receiver.cpp
|
ui/ui_receiver.cpp
|
||||||
ui/ui_rssi.cpp
|
ui/ui_rssi.cpp
|
||||||
ui/ui_freqlist.cpp
|
ui/ui_freqlist.cpp
|
||||||
ui/ui_tv.cpp
|
|
||||||
ui/ui_spectrum.cpp
|
ui/ui_spectrum.cpp
|
||||||
ui/ui_tabview.cpp
|
ui/ui_tabview.cpp
|
||||||
ui/ui_textentry.cpp
|
ui/ui_textentry.cpp
|
||||||
@@ -270,19 +268,15 @@ set(CPPSRC
|
|||||||
ui/ui_bmpview.cpp
|
ui/ui_bmpview.cpp
|
||||||
apps/ais_app.cpp
|
apps/ais_app.cpp
|
||||||
apps/analog_audio_app.cpp
|
apps/analog_audio_app.cpp
|
||||||
apps/ble_comm_app.cpp
|
|
||||||
apps/ble_rx_app.cpp
|
apps/ble_rx_app.cpp
|
||||||
apps/ble_tx_app.cpp
|
apps/ble_tx_app.cpp
|
||||||
apps/capture_app.cpp
|
apps/capture_app.cpp
|
||||||
apps/ert_app.cpp
|
|
||||||
apps/pocsag_app.cpp
|
apps/pocsag_app.cpp
|
||||||
apps/soundboard_app.cpp
|
|
||||||
apps/ui_about_simple.cpp
|
apps/ui_about_simple.cpp
|
||||||
apps/ui_adsb_rx.cpp
|
apps/ui_adsb_rx.cpp
|
||||||
apps/ui_aprs_rx.cpp
|
apps/ui_aprs_rx.cpp
|
||||||
apps/ui_aprs_tx.cpp
|
apps/ui_aprs_tx.cpp
|
||||||
apps/ui_battinfo.cpp
|
apps/ui_battinfo.cpp
|
||||||
apps/ui_bht_tx.cpp
|
|
||||||
apps/ui_bmp_file_viewer.cpp
|
apps/ui_bmp_file_viewer.cpp
|
||||||
apps/ui_btle_rx.cpp
|
apps/ui_btle_rx.cpp
|
||||||
apps/ui_debug.cpp
|
apps/ui_debug.cpp
|
||||||
@@ -317,7 +311,6 @@ set(CPPSRC
|
|||||||
apps/ui_weatherstation.cpp
|
apps/ui_weatherstation.cpp
|
||||||
protocols/aprs.cpp
|
protocols/aprs.cpp
|
||||||
protocols/ax25.cpp
|
protocols/ax25.cpp
|
||||||
protocols/bht.cpp
|
|
||||||
protocols/dcs.cpp
|
protocols/dcs.cpp
|
||||||
protocols/encoders.cpp
|
protocols/encoders.cpp
|
||||||
protocols/modems.cpp
|
protocols/modems.cpp
|
||||||
|
|||||||
@@ -223,9 +223,9 @@ void AISRecentEntry::update(const ais::Packet& packet) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
call_sign = packet.text(70, 7);
|
call_sign = trim(packet.text(70, 7));
|
||||||
name = packet.text(112, 20);
|
name = trim(packet.text(112, 20));
|
||||||
destination = packet.text(302, 20);
|
destination = trim(packet.text(302, 20));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 18:
|
case 18:
|
||||||
@@ -238,7 +238,7 @@ void AISRecentEntry::update(const ais::Packet& packet) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 21:
|
case 21:
|
||||||
name = packet.text(43, 20);
|
name = trim(packet.text(43, 20));
|
||||||
last_position.timestamp = packet.received_at();
|
last_position.timestamp = packet.received_at();
|
||||||
last_position.latitude = packet.latitude(192);
|
last_position.latitude = packet.latitude(192);
|
||||||
last_position.longitude = packet.longitude(164);
|
last_position.longitude = packet.longitude(164);
|
||||||
@@ -247,11 +247,11 @@ void AISRecentEntry::update(const ais::Packet& packet) {
|
|||||||
case 24:
|
case 24:
|
||||||
switch (packet.read(38, 2)) {
|
switch (packet.read(38, 2)) {
|
||||||
case 0:
|
case 0:
|
||||||
name = packet.text(40, 20);
|
name = trim(packet.text(40, 20));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
call_sign = packet.text(90, 7);
|
call_sign = trim(packet.text(90, 7));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -272,14 +272,14 @@ void RecentEntriesTable<AISRecentEntries>::draw(
|
|||||||
const Entry& entry,
|
const Entry& entry,
|
||||||
const Rect& target_rect,
|
const Rect& target_rect,
|
||||||
Painter& painter,
|
Painter& painter,
|
||||||
const Style& style) {
|
const Style& style,
|
||||||
|
RecentEntriesColumns&) {
|
||||||
std::string line = ais::format::mmsi(entry.mmsi) + " ";
|
std::string line = ais::format::mmsi(entry.mmsi) + " ";
|
||||||
if (!entry.name.empty()) {
|
if (!entry.name.empty()) {
|
||||||
line += ais::format::text(entry.name);
|
line += ais::format::text(entry.name);
|
||||||
} else {
|
} else {
|
||||||
line += ais::format::text(entry.call_sign);
|
line += ais::format::text(entry.call_sign);
|
||||||
}
|
}
|
||||||
|
|
||||||
line.resize(target_rect.width() / 8, ' ');
|
line.resize(target_rect.width() / 8, ' ');
|
||||||
painter.draw_string(target_rect.location(), style, line);
|
painter.draw_string(target_rect.location(), style, line);
|
||||||
}
|
}
|
||||||
@@ -324,7 +324,7 @@ AISRecentEntryDetailView& AISRecentEntryDetailView::operator=(const AISRecentEnt
|
|||||||
|
|
||||||
void AISRecentEntryDetailView::update_position() {
|
void AISRecentEntryDetailView::update_position() {
|
||||||
if (send_updates)
|
if (send_updates)
|
||||||
geomap_view->update_position(ais::format::latlon_float(entry_.last_position.latitude.normalized()), ais::format::latlon_float(entry_.last_position.longitude.normalized()), (float)entry_.last_position.true_heading, 0, entry_.last_position.speed_over_ground > 1022 ? 0 : entry_.last_position.speed_over_ground);
|
geomap_view->update_position(ais::format::latlon_float(entry_.last_position.latitude.normalized()), ais::format::latlon_float(entry_.last_position.longitude.normalized()), (float)entry_.last_position.true_heading, 0, entry_.last_position.speed_over_ground > 1022 ? 0 : entry_.last_position.speed_over_ground / 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AISRecentEntryDetailView::add_map_marker(const AISRecentEntry& entry) {
|
bool AISRecentEntryDetailView::add_map_marker(const AISRecentEntry& entry) {
|
||||||
@@ -456,7 +456,10 @@ void AISAppView::on_tick_second() {
|
|||||||
++timer_seconds;
|
++timer_seconds;
|
||||||
if (timer_seconds % 10 == 0) {
|
if (timer_seconds % 10 == 0) {
|
||||||
if (recent_entry_detail_view.hidden()) return;
|
if (recent_entry_detail_view.hidden()) return;
|
||||||
recent_entry_detail_view.update_map_markers(recent);
|
if (got_new_packet) {
|
||||||
|
got_new_packet = false;
|
||||||
|
recent_entry_detail_view.update_map_markers(recent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +478,7 @@ void AISAppView::on_packet(const ais::Packet& packet) {
|
|||||||
if (logger) {
|
if (logger) {
|
||||||
logger->on_packet(packet);
|
logger->on_packet(packet);
|
||||||
}
|
}
|
||||||
|
got_new_packet = true;
|
||||||
auto& entry = ::on_packet(recent, packet.source_id());
|
auto& entry = ::on_packet(recent, packet.source_id());
|
||||||
entry.update(packet);
|
entry.update(packet);
|
||||||
recent_entries_view.set_dirty();
|
recent_entries_view.set_dirty();
|
||||||
|
|||||||
@@ -137,10 +137,10 @@ class AISRecentEntryDetailView : public View {
|
|||||||
AISRecentEntry entry_{};
|
AISRecentEntry entry_{};
|
||||||
|
|
||||||
Button button_done{
|
Button button_done{
|
||||||
{125, 224, 96, 24},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(6), UI_POS_Y(14), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Done"};
|
"Done"};
|
||||||
Button button_see_map{
|
Button button_see_map{
|
||||||
{19, 224, 96, 24},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y(14), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"See on map"};
|
"See on map"};
|
||||||
GeoMapView* geomap_view{nullptr};
|
GeoMapView* geomap_view{nullptr};
|
||||||
bool send_updates{false};
|
bool send_updates{false};
|
||||||
@@ -179,9 +179,9 @@ class AISAppView : public View {
|
|||||||
AISRecentEntries recent{};
|
AISRecentEntries recent{};
|
||||||
std::unique_ptr<AISLogger> logger{};
|
std::unique_ptr<AISLogger> logger{};
|
||||||
|
|
||||||
const RecentEntriesColumns columns{{
|
RecentEntriesColumns columns{{
|
||||||
{"MMSI", 9},
|
{"MMSI", 9},
|
||||||
{"Name/Call", 20},
|
{"Name/Call", 0},
|
||||||
}};
|
}};
|
||||||
AISRecentEntriesView recent_entries_view{columns, recent};
|
AISRecentEntriesView recent_entries_view{columns, recent};
|
||||||
AISRecentEntryDetailView recent_entry_detail_view{nav_};
|
AISRecentEntryDetailView recent_entry_detail_view{nav_};
|
||||||
@@ -189,11 +189,11 @@ class AISAppView : public View {
|
|||||||
static constexpr auto header_height = 1 * 16;
|
static constexpr auto header_height = 1 * 16;
|
||||||
|
|
||||||
Text label_channel{
|
Text label_channel{
|
||||||
{0 * 8, 0 * 16, 2 * 8, 1 * 16},
|
{UI_POS_X(0), UI_POS_Y(0), 2 * 8, 1 * 16},
|
||||||
"Ch"};
|
"Ch"};
|
||||||
|
|
||||||
OptionsField options_channel{
|
OptionsField options_channel{
|
||||||
{3 * 8, 0 * 16},
|
{3 * 8, UI_POS_Y(0)},
|
||||||
3,
|
3,
|
||||||
{
|
{
|
||||||
{"87B", 161975000},
|
{"87B", 161975000},
|
||||||
@@ -201,26 +201,27 @@ class AISAppView : public View {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{13 * 8, 0 * 16}};
|
{13 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{15 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{18 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4},
|
{UI_POS_X(21), UI_POS_Y(0), UI_POS_WIDTH_REMAINING(23), 4},
|
||||||
};
|
};
|
||||||
|
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{screen_width - 2 * 8, 0 * 16}};
|
{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
|
||||||
|
|
||||||
Channel channel{
|
Channel channel{
|
||||||
{21 * 8, 5, 6 * 8, 4},
|
{UI_POS_X(21), 5, UI_POS_WIDTH_REMAINING(23), 4},
|
||||||
};
|
};
|
||||||
SignalToken signal_token_tick_second{};
|
SignalToken signal_token_tick_second{};
|
||||||
uint8_t timer_seconds = 0;
|
uint8_t timer_seconds = 0;
|
||||||
|
bool got_new_packet{false}; // got any new packet since latest screen update?
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_packet{
|
MessageHandlerRegistration message_handler_packet{
|
||||||
Message::ID::AISPacket,
|
Message::ID::AISPacket,
|
||||||
|
|||||||
@@ -43,19 +43,19 @@ class AMOptionsView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Text label_config{
|
Text label_config{
|
||||||
{0 * 8, 0 * 16, 2 * 8, 1 * 16},
|
{UI_POS_X(0), UI_POS_Y(0), UI_POS_WIDTH(2), UI_POS_HEIGHT(1)},
|
||||||
"BW",
|
"BW",
|
||||||
};
|
};
|
||||||
|
|
||||||
OptionsField options_config{
|
OptionsField options_config{
|
||||||
{3 * 8, 0 * 16},
|
{UI_POS_X(3), UI_POS_Y(0)},
|
||||||
6, // Max option length
|
6, // Max option length
|
||||||
{
|
{
|
||||||
// Using common messages from freqman_ui.cpp
|
// Using common messages from freqman_ui.cpp
|
||||||
}};
|
}};
|
||||||
|
|
||||||
OptionsField zoom_config{
|
OptionsField zoom_config{
|
||||||
{23 * 8, 0 * 16},
|
{UI_POS_X_RIGHT(7), UI_POS_Y(0)},
|
||||||
7,
|
7,
|
||||||
{{"ZOOM x1", 0},
|
{{"ZOOM x1", 0},
|
||||||
{"ZOOM x2", 6}} // offset index AM modes array FIR filters.
|
{"ZOOM x2", 6}} // offset index AM modes array FIR filters.
|
||||||
@@ -68,19 +68,19 @@ class AMFMAptOptionsView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Text label_config{
|
Text label_config{
|
||||||
{0 * 8, 0 * 16, 2 * 8, 1 * 16},
|
{UI_POS_X(0), UI_POS_Y(0), UI_POS_WIDTH(2), UI_POS_HEIGHT(1)},
|
||||||
"BW",
|
"BW",
|
||||||
};
|
};
|
||||||
|
|
||||||
OptionsField options_config{
|
OptionsField options_config{
|
||||||
{3 * 8, 0 * 16},
|
{UI_POS_X(3), UI_POS_Y(0)},
|
||||||
17, // Max option length chars "USB+FM(Wefax Apt)"
|
17, // Max option length chars "USB+FM(Wefax Apt)"
|
||||||
{
|
{
|
||||||
// Using common messages from freqman_ui.cpp In HF USB , Here we only need USB Audio demod, + post-FM demod fsubcarrier FM tone to get APT signal.
|
// Using common messages from freqman_ui.cpp In HF USB , Here we only need USB Audio demod, + post-FM demod fsubcarrier FM tone to get APT signal.
|
||||||
}};
|
}};
|
||||||
|
|
||||||
OptionsField zoom_config{
|
OptionsField zoom_config{
|
||||||
{23 * 8, 0 * 16},
|
{UI_POS_X_RIGHT(7), UI_POS_Y(0)},
|
||||||
7,
|
7,
|
||||||
{{"ZOOM x1", 0},
|
{{"ZOOM x1", 0},
|
||||||
{"ZOOM x2", 6}} // offset index array filters.
|
{"ZOOM x2", 6}} // offset index array filters.
|
||||||
@@ -93,21 +93,21 @@ class NBFMOptionsView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Text label_config{
|
Text label_config{
|
||||||
{0 * 8, 0 * 16, 2 * 8, 1 * 16},
|
{UI_POS_X(0), UI_POS_Y(0), UI_POS_WIDTH(2), UI_POS_HEIGHT(1)},
|
||||||
"BW",
|
"BW",
|
||||||
};
|
};
|
||||||
OptionsField options_config{
|
OptionsField options_config{
|
||||||
{3 * 8, 0 * 16},
|
{UI_POS_X(3), UI_POS_Y(0)},
|
||||||
3, // Max option length
|
3, // Max option length
|
||||||
{
|
{
|
||||||
// Using common messages from freqman_ui.cpp
|
// Using common messages from freqman_ui.cpp
|
||||||
}};
|
}};
|
||||||
|
|
||||||
Text text_squelch{
|
Text text_squelch{
|
||||||
{7 * 8, 0 * 16, 8 * 8, 1 * 16},
|
{UI_POS_X(7), UI_POS_Y(0), UI_POS_WIDTH(8), UI_POS_HEIGHT(1)},
|
||||||
"SQ /99"};
|
"SQ /99"};
|
||||||
NumberField field_squelch{
|
NumberField field_squelch{
|
||||||
{10 * 8, 0 * 16},
|
{UI_POS_X(10), UI_POS_Y(0)},
|
||||||
2,
|
2,
|
||||||
{0, 99},
|
{0, 99},
|
||||||
1,
|
1,
|
||||||
@@ -121,11 +121,11 @@ class WFMOptionsView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Text label_config{
|
Text label_config{
|
||||||
{0 * 8, 0 * 16, 2 * 8, 1 * 16},
|
{UI_POS_X(0), UI_POS_Y(0), UI_POS_WIDTH(2), UI_POS_HEIGHT(1)},
|
||||||
"BW",
|
"BW",
|
||||||
};
|
};
|
||||||
OptionsField options_config{
|
OptionsField options_config{
|
||||||
{3 * 8, 0 * 16},
|
{UI_POS_X(3), UI_POS_Y(0)},
|
||||||
4, // Max option length
|
4, // Max option length
|
||||||
{
|
{
|
||||||
// Using common messages from freqman_ui.cpp
|
// Using common messages from freqman_ui.cpp
|
||||||
@@ -138,11 +138,11 @@ class WFMAMAptOptionsView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Text label_config{
|
Text label_config{
|
||||||
{0 * 8, 0 * 16, 2 * 8, 1 * 16},
|
{UI_POS_X(0), UI_POS_Y(0), UI_POS_WIDTH(2), UI_POS_HEIGHT(1)},
|
||||||
"BW",
|
"BW",
|
||||||
};
|
};
|
||||||
OptionsField options_config{
|
OptionsField options_config{
|
||||||
{3 * 8, 0 * 16},
|
{UI_POS_X(3), UI_POS_Y(0)},
|
||||||
16, // Max option char length "80k-NOAA Apt LPF" , example.
|
16, // Max option char length "80k-NOAA Apt LPF" , example.
|
||||||
{
|
{
|
||||||
// Using common messages from freqman_ui.cpp
|
// Using common messages from freqman_ui.cpp
|
||||||
@@ -155,11 +155,11 @@ class SPECOptionsView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Text label_config{
|
Text label_config{
|
||||||
{0 * 8, 0 * 16, 2 * 8, 1 * 16},
|
{UI_POS_X(0), UI_POS_Y(0), UI_POS_WIDTH(2), UI_POS_HEIGHT(1)},
|
||||||
"BW",
|
"BW",
|
||||||
};
|
};
|
||||||
OptionsField options_config{
|
OptionsField options_config{
|
||||||
{3 * 8, 0 * 16},
|
{UI_POS_X(3), UI_POS_Y(0)},
|
||||||
4,
|
4,
|
||||||
{
|
{
|
||||||
{"20m ", 20000000},
|
{"20m ", 20000000},
|
||||||
@@ -172,20 +172,20 @@ class SPECOptionsView : public View {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
Text text_speed{
|
Text text_speed{
|
||||||
{9 * 8, 0 * 16, 8 * 8, 1 * 16},
|
{UI_POS_X(9), UI_POS_Y(0), UI_POS_WIDTH(8), UI_POS_HEIGHT(1)},
|
||||||
"SP /63"};
|
"SP /63"};
|
||||||
NumberField field_speed{
|
NumberField field_speed{
|
||||||
{12 * 8, 0 * 16},
|
{UI_POS_X(12), UI_POS_Y(0)},
|
||||||
2,
|
2,
|
||||||
{0, 63},
|
{0, 63},
|
||||||
1,
|
1,
|
||||||
' ',
|
' ',
|
||||||
};
|
};
|
||||||
Text text_rx_cal{
|
Text text_rx_cal{
|
||||||
{19 * 8, 0 * 16, 11 * 8, 1 * 16}, // 18 (x col.) x char_size, 12 (length) x 8 blanking space to delete previous chars.
|
{UI_POS_X(19), UI_POS_Y(0), UI_POS_WIDTH(11), UI_POS_HEIGHT(1)}, // 18 (x col.) x char_size, 12 (length) x 8 blanking space to delete previous chars.
|
||||||
"Rx_IQ_CAL "};
|
"Rx_IQ_CAL "};
|
||||||
NumberField field_rx_iq_phase_cal{
|
NumberField field_rx_iq_phase_cal{
|
||||||
{screen_width - 2 * 8, 0 * 16},
|
{screen_width - 2 * 8, UI_POS_Y(0)},
|
||||||
2,
|
2,
|
||||||
{0, 63}, // 5 or 6 bits IQ CAL phase adjustment (range updated later)
|
{0, 63}, // 5 or 6 bits IQ CAL phase adjustment (range updated later)
|
||||||
1,
|
1,
|
||||||
@@ -244,34 +244,34 @@ class AnalogAudioView : public View {
|
|||||||
{"previous_zoom"sv, &previous_zoom}, // we are saving and restoring AMFM ZOOM factor from Settings.
|
{"previous_zoom"sv, &previous_zoom}, // we are saving and restoring AMFM ZOOM factor from Settings.
|
||||||
}};
|
}};
|
||||||
|
|
||||||
const Rect options_view_rect{0 * 8, 1 * 16, screen_width, 1 * 16};
|
const Rect options_view_rect{UI_POS_X(0), UI_POS_Y(1), UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)};
|
||||||
const Rect nbfm_view_rect{0 * 8, 1 * 16, 18 * 8, 1 * 16};
|
const Rect nbfm_view_rect{UI_POS_X(0), UI_POS_Y(1), UI_POS_WIDTH(18), UI_POS_HEIGHT(1)};
|
||||||
|
|
||||||
size_t spec_bw_index = 0;
|
size_t spec_bw_index = 0;
|
||||||
uint32_t spec_bw = 20000000;
|
uint32_t spec_bw = 20000000;
|
||||||
uint16_t spec_trigger = 63;
|
uint16_t spec_trigger = 63;
|
||||||
|
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4}};
|
{UI_POS_X(21), 0, UI_POS_WIDTH_REMAINING(21) - UI_POS_WIDTH(2), 4}};
|
||||||
|
|
||||||
Channel channel{
|
Channel channel{
|
||||||
{21 * 8, 5, 6 * 8, 4}};
|
{UI_POS_X(21), 5, UI_POS_WIDTH_REMAINING(21) - UI_POS_WIDTH(2), 4}};
|
||||||
|
|
||||||
Audio audio{
|
Audio audio{
|
||||||
{21 * 8, 10, 6 * 8, 4}};
|
{UI_POS_X(21), 10, UI_POS_WIDTH_REMAINING(21) - UI_POS_WIDTH(2), 4}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{5 * 8, 0 * 16},
|
{UI_POS_X(5), UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{UI_POS_X(15), UI_POS_Y(0)}};
|
||||||
|
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{UI_POS_X(18), UI_POS_Y(0)}};
|
||||||
|
|
||||||
OptionsField options_modulation{
|
OptionsField options_modulation{
|
||||||
{0 * 8, 0 * 16},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
4,
|
4,
|
||||||
{
|
{
|
||||||
{" AM ", toUType(ReceiverModel::Mode::AMAudio)},
|
{" AM ", toUType(ReceiverModel::Mode::AMAudio)},
|
||||||
@@ -283,16 +283,16 @@ class AnalogAudioView : public View {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{screen_width - 2 * 8, 0 * 16}};
|
{screen_width - 2 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
Text text_ctcss{
|
Text text_ctcss{
|
||||||
{16 * 8, 1 * 16, 14 * 8, 1 * 16},
|
{UI_POS_X(16), UI_POS_Y(1), UI_POS_WIDTH(14), UI_POS_HEIGHT(1)},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
std::unique_ptr<Widget> options_widget{};
|
std::unique_ptr<Widget> options_widget{};
|
||||||
|
|
||||||
RecordView record_view{
|
RecordView record_view{
|
||||||
{0 * 8, 2 * 16, screen_width, 1 * 16},
|
{UI_POS_X(0), UI_POS_Y(2), UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)},
|
||||||
u"AUD",
|
u"AUD",
|
||||||
u"AUDIO",
|
u"AUDIO",
|
||||||
RecordView::FileType::WAV,
|
RecordView::FileType::WAV,
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ static std::uint64_t get_freq_by_channel_number(uint8_t channel_number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BLECommView::focus() {
|
void BLECommView::focus() {
|
||||||
options_channel.focus();
|
field_frequency.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
BLECommView::BLECommView(NavigationView& nav)
|
BLECommView::BLECommView(NavigationView& nav)
|
||||||
@@ -79,10 +79,7 @@ BLECommView::BLECommView(NavigationView& nav)
|
|||||||
&field_rf_amp,
|
&field_rf_amp,
|
||||||
&field_lna,
|
&field_lna,
|
||||||
&field_vga,
|
&field_vga,
|
||||||
&options_channel,
|
|
||||||
&field_frequency,
|
&field_frequency,
|
||||||
&label_send_adv,
|
|
||||||
&button_send_adv,
|
|
||||||
&check_log,
|
&check_log,
|
||||||
&label_packets_sent,
|
&label_packets_sent,
|
||||||
&text_packets_sent,
|
&text_packets_sent,
|
||||||
@@ -90,10 +87,6 @@ BLECommView::BLECommView(NavigationView& nav)
|
|||||||
|
|
||||||
field_frequency.set_step(0);
|
field_frequency.set_step(0);
|
||||||
|
|
||||||
button_send_adv.on_select = [this](ImageButton&) {
|
|
||||||
this->toggle();
|
|
||||||
};
|
|
||||||
|
|
||||||
check_log.set_value(logging);
|
check_log.set_value(logging);
|
||||||
|
|
||||||
check_log.on_select = [this](Checkbox&, bool v) {
|
check_log.on_select = [this](Checkbox&, bool v) {
|
||||||
@@ -104,27 +97,8 @@ BLECommView::BLECommView(NavigationView& nav)
|
|||||||
logger->append(logs_dir.string() + "/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT");
|
logger->append(logs_dir.string() + "/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT");
|
||||||
};
|
};
|
||||||
|
|
||||||
options_channel.on_change = [this](size_t, int32_t i) {
|
|
||||||
// If we selected Auto don't do anything and Auto will handle changing.
|
|
||||||
if (i == 40) {
|
|
||||||
auto_channel = true;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
auto_channel = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
field_frequency.set_value(get_freq_by_channel_number(i));
|
|
||||||
channel_number_rx = i;
|
|
||||||
channel_number_tx = i;
|
|
||||||
};
|
|
||||||
|
|
||||||
options_channel.set_selected_index(3, true);
|
|
||||||
|
|
||||||
logger = std::make_unique<BLECommLogger>();
|
logger = std::make_unique<BLECommLogger>();
|
||||||
|
|
||||||
// Generate new random Mac Address upon each new startup.
|
|
||||||
generateRandomMacAddress(randomMac);
|
|
||||||
|
|
||||||
// Setup Initial Advertise Packet.
|
// Setup Initial Advertise Packet.
|
||||||
advertisePacket = build_adv_packet();
|
advertisePacket = build_adv_packet();
|
||||||
}
|
}
|
||||||
@@ -145,86 +119,66 @@ bool BLECommView::in_tx_mode() const {
|
|||||||
return (bool)is_running_tx;
|
return (bool)is_running_tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLECommView::toggle() {
|
|
||||||
if (in_tx_mode()) {
|
|
||||||
sendAdvertisement(false);
|
|
||||||
} else {
|
|
||||||
sendAdvertisement(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BLETxPacket BLECommView::build_adv_packet() {
|
BLETxPacket BLECommView::build_adv_packet() {
|
||||||
BLETxPacket bleTxPacket;
|
BLETxPacket bleTxPacket;
|
||||||
memset(&bleTxPacket, 0, sizeof(BLETxPacket));
|
memset(&bleTxPacket, 0, sizeof(BLETxPacket));
|
||||||
|
|
||||||
std::string dataString = "11094861636b524620506f7274617061636b";
|
std::string dataString = "02010603030F1807084861636B5246";
|
||||||
|
|
||||||
strncpy(bleTxPacket.macAddress, randomMac, 12);
|
|
||||||
strncpy(bleTxPacket.advertisementData, dataString.c_str(), dataString.length());
|
strncpy(bleTxPacket.advertisementData, dataString.c_str(), dataString.length());
|
||||||
|
|
||||||
// Duty cycle of 40% per 100ms advertisment periods.
|
strncpy(bleTxPacket.packetCount, "1", 2);
|
||||||
strncpy(bleTxPacket.packetCount, "80", 3);
|
bleTxPacket.packet_count = 1;
|
||||||
bleTxPacket.packet_count = 80;
|
|
||||||
|
|
||||||
bleTxPacket.packetType = PKT_TYPE_DISCOVERY;
|
bleTxPacket.pduType = PKT_TYPE_ADV_IND;
|
||||||
|
|
||||||
return bleTxPacket;
|
return bleTxPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLECommView::sendAdvertisement(bool enable) {
|
void BLECommView::sendAdvertisement(void) {
|
||||||
if (enable) {
|
startTx(advertisePacket);
|
||||||
startTx(advertisePacket);
|
ble_state = Ble_State_Advertising;
|
||||||
is_adv = true;
|
|
||||||
} else {
|
|
||||||
is_adv = false;
|
|
||||||
stopTx();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLECommView::startTx(BLETxPacket packetToSend) {
|
void BLECommView::startTx(BLETxPacket packetToSend) {
|
||||||
int randomChannel = channel_number_tx;
|
switch_rx_tx(false);
|
||||||
|
|
||||||
if (auto_channel) {
|
currentPacket = packetToSend;
|
||||||
int min = 37;
|
packet_counter = currentPacket.packet_count;
|
||||||
int max = 39;
|
|
||||||
|
|
||||||
randomChannel = min + std::rand() % (max - min + 1);
|
switch (advCount) {
|
||||||
|
case 0:
|
||||||
field_frequency.set_value(get_freq_by_channel_number(randomChannel));
|
channel_number_tx = 37;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
channel_number_tx = 38;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
channel_number_tx = 39;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_tx_mode()) {
|
field_frequency.set_value(get_freq_by_channel_number(37));
|
||||||
switch_rx_tx(false);
|
|
||||||
|
|
||||||
currentPacket = packetToSend;
|
advCount++;
|
||||||
packet_counter = currentPacket.packet_count;
|
|
||||||
|
|
||||||
button_send_adv.set_bitmap(&bitmap_stop);
|
if (advCount == 3) {
|
||||||
baseband::set_btletx(randomChannel, currentPacket.macAddress, currentPacket.advertisementData, currentPacket.packetType);
|
advCount = 0;
|
||||||
transmitter_model.set_tx_gain(47);
|
|
||||||
transmitter_model.enable();
|
|
||||||
|
|
||||||
is_running_tx = true;
|
|
||||||
} else {
|
|
||||||
baseband::set_btletx(randomChannel, currentPacket.macAddress, currentPacket.advertisementData, currentPacket.packetType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((packet_counter % 10) == 0) {
|
baseband::set_btletx(37, deviceMAC, currentPacket.advertisementData, currentPacket.pduType);
|
||||||
text_packets_sent.set(to_string_dec_uint(packet_counter));
|
transmitter_model.set_tx_gain(47);
|
||||||
}
|
transmitter_model.enable();
|
||||||
|
|
||||||
is_sending = true;
|
is_running_tx = true;
|
||||||
|
|
||||||
packet_counter--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLECommView::stopTx() {
|
void BLECommView::stopTx() {
|
||||||
button_send_adv.set_bitmap(&bitmap_play);
|
|
||||||
text_packets_sent.set(to_string_dec_uint(packet_counter));
|
text_packets_sent.set(to_string_dec_uint(packet_counter));
|
||||||
|
|
||||||
switch_rx_tx(true);
|
switch_rx_tx(true);
|
||||||
|
|
||||||
baseband::set_btlerx(channel_number_rx);
|
baseband::set_btlerx(channel_number_rx);
|
||||||
|
field_frequency.set_value(get_freq_by_channel_number(channel_number_rx));
|
||||||
receiver_model.enable();
|
receiver_model.enable();
|
||||||
|
|
||||||
is_running_tx = false;
|
is_running_tx = false;
|
||||||
@@ -248,14 +202,12 @@ void BLECommView::on_data(BlePacketData* packet) {
|
|||||||
parse_received_packet(packet, (ADV_PDU_TYPE)packet->type);
|
parse_received_packet(packet, (ADV_PDU_TYPE)packet->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// called each 1/60th of second, so 6 = 100ms
|
|
||||||
void BLECommView::on_timer() {
|
void BLECommView::on_timer() {
|
||||||
// Send advertise burst only once every 100ms
|
|
||||||
if (++timer_counter == timer_period) {
|
if (++timer_counter == timer_period) {
|
||||||
timer_counter = 0;
|
timer_counter = 0;
|
||||||
|
|
||||||
if (!is_adv) {
|
if (ble_state == Ble_State_Receiving || ble_state == Ble_State_Idle) {
|
||||||
sendAdvertisement(true);
|
sendAdvertisement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -263,17 +215,18 @@ void BLECommView::on_timer() {
|
|||||||
void BLECommView::on_tx_progress(const bool done) {
|
void BLECommView::on_tx_progress(const bool done) {
|
||||||
if (done) {
|
if (done) {
|
||||||
if (in_tx_mode()) {
|
if (in_tx_mode()) {
|
||||||
is_sending = false;
|
ble_state = Ble_State_Receiving;
|
||||||
|
|
||||||
if (packet_counter == 0) {
|
timer_counter = 0;
|
||||||
if (is_adv) {
|
timer_period = 12;
|
||||||
sendAdvertisement(false);
|
|
||||||
} else {
|
stopTx();
|
||||||
stopTx();
|
|
||||||
}
|
// else
|
||||||
} else {
|
// {
|
||||||
startTx(currentPacket);
|
// startTx(advertisePacket);
|
||||||
}
|
// advCount++;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,23 +262,28 @@ void BLECommView::parse_received_packet(const BlePacketData* packet, ADV_PDU_TYP
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pdu_type == SCAN_REQ || pdu_type == CONNECT_REQ) {
|
if (pdu_type == SCAN_REQ || pdu_type == CONNECT_REQ) {
|
||||||
ADV_PDU_PAYLOAD_TYPE_1_3* directed_mac_data = (ADV_PDU_PAYLOAD_TYPE_1_3*)packet->data;
|
|
||||||
|
|
||||||
std::reverse(directed_mac_data->A1, directed_mac_data->A1 + 6);
|
|
||||||
console.clear(true);
|
|
||||||
std::string str_console = "";
|
|
||||||
std::string pduTypeStr = "";
|
|
||||||
|
|
||||||
if (pdu_type == SCAN_REQ) {
|
if (pdu_type == SCAN_REQ) {
|
||||||
pduTypeStr += "SCAN_REQ";
|
ADV_PDU_PAYLOAD_TYPE_1_3* directed_mac_data = (ADV_PDU_PAYLOAD_TYPE_1_3*)packet->data;
|
||||||
} else if (pdu_type == CONNECT_REQ) {
|
|
||||||
pduTypeStr += "CONNECT_REQ";
|
|
||||||
}
|
|
||||||
|
|
||||||
str_console += "PACKET TYPE:" + pduTypeStr + "\n";
|
std::reverse(directed_mac_data->A1, directed_mac_data->A1 + 6);
|
||||||
str_console += "MY MAC:" + to_string_formatted_mac_address(randomMac) + "\n";
|
std::string directedMAC = to_string_mac_address(directed_mac_data->A1, 6, false);
|
||||||
str_console += "SCAN MAC:" + to_string_mac_address(directed_mac_data->A1, 6, false) + "\n";
|
|
||||||
console.write(str_console);
|
// Compare directed MAC Hex with the device MAC.
|
||||||
|
if (1) {
|
||||||
|
// std::string str_console = "Received SCAN_REQ from directed MAC: " + directedMAC + "\n";
|
||||||
|
// console.clear(true);
|
||||||
|
// console.writeln(str_console);
|
||||||
|
}
|
||||||
|
} else if (pdu_type == CONNECT_REQ) {
|
||||||
|
ADV_PDU_PAYLOAD_TYPE_5* connectReq = (ADV_PDU_PAYLOAD_TYPE_5*)packet->data;
|
||||||
|
|
||||||
|
std::reverse(connectReq->AdvA, connectReq->AdvA + 6);
|
||||||
|
std::string directedMAC = to_string_mac_address(connectReq->AdvA, 6, false);
|
||||||
|
|
||||||
|
std::string str_console = "Received CONNECT_REQ from directed MAC: " + directedMAC + "\n";
|
||||||
|
console.clear(true);
|
||||||
|
console.writeln(str_console);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,16 @@ class BLECommView : public View {
|
|||||||
void on_data(BlePacketData* packetData);
|
void on_data(BlePacketData* packetData);
|
||||||
void on_tx_progress(const bool done);
|
void on_tx_progress(const bool done);
|
||||||
void parse_received_packet(const BlePacketData* packet, ADV_PDU_TYPE pdu_type);
|
void parse_received_packet(const BlePacketData* packet, ADV_PDU_TYPE pdu_type);
|
||||||
void sendAdvertisement(bool enable);
|
void sendAdvertisement(void);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
Ble_State_Idle = 0,
|
||||||
|
Ble_State_Advertising = 1,
|
||||||
|
Ble_State_Receiving = 2,
|
||||||
|
Ble_State_Sending = 3
|
||||||
|
} BleState;
|
||||||
|
|
||||||
|
BleState ble_state{Ble_State_Idle};
|
||||||
|
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
|
|
||||||
@@ -101,8 +110,9 @@ class BLECommView : public View {
|
|||||||
uint8_t channel_number_tx = 37;
|
uint8_t channel_number_tx = 37;
|
||||||
uint8_t channel_number_rx = 37;
|
uint8_t channel_number_rx = 37;
|
||||||
bool auto_channel = false;
|
bool auto_channel = false;
|
||||||
|
uint8_t advCount = 0;
|
||||||
|
|
||||||
char randomMac[13] = "010203040506";
|
char deviceMAC[13] = "C23456789ABC";
|
||||||
|
|
||||||
bool is_running_tx = false;
|
bool is_running_tx = false;
|
||||||
bool is_sending = false;
|
bool is_sending = false;
|
||||||
@@ -111,7 +121,7 @@ class BLECommView : public View {
|
|||||||
int16_t timer_period{6}; // Delay each packet by 16ms.
|
int16_t timer_period{6}; // Delay each packet by 16ms.
|
||||||
int16_t timer_counter = 0;
|
int16_t timer_counter = 0;
|
||||||
int16_t timer_rx_counter = 0;
|
int16_t timer_rx_counter = 0;
|
||||||
int16_t timer_rx_period{12}; // Poll Rx for at least 200ms. (TBD)
|
int16_t timer_rx_period{12}; // Poll Rx for at least 150ms. (TBD)
|
||||||
|
|
||||||
uint32_t packet_counter{0};
|
uint32_t packet_counter{0};
|
||||||
BLETxPacket advertisePacket{};
|
BLETxPacket advertisePacket{};
|
||||||
@@ -121,7 +131,7 @@ class BLECommView : public View {
|
|||||||
static constexpr auto header_height = 5 * 16;
|
static constexpr auto header_height = 5 * 16;
|
||||||
|
|
||||||
OptionsField options_channel{
|
OptionsField options_channel{
|
||||||
{0 * 8, 0 * 8},
|
{UI_POS_X(0), 0 * 8},
|
||||||
5,
|
5,
|
||||||
{{"Ch.37 ", 37},
|
{{"Ch.37 ", 37},
|
||||||
{"Ch.38", 38},
|
{"Ch.38", 38},
|
||||||
@@ -129,17 +139,17 @@ class BLECommView : public View {
|
|||||||
{"Auto", 40}}};
|
{"Auto", 40}}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{6 * 8, 0 * 16},
|
{6 * 8, UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{16 * 8, 0 * 16}};
|
{16 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{18 * 8, 0 * 16}};
|
{18 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{21 * 8, 0 * 16}};
|
{21 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{24 * 8, 0, 6 * 8, 4}};
|
{24 * 8, 0, 6 * 8, 4}};
|
||||||
@@ -147,15 +157,6 @@ class BLECommView : public View {
|
|||||||
Channel channel{
|
Channel channel{
|
||||||
{24 * 8, 5, 6 * 8, 4}};
|
{24 * 8, 5, 6 * 8, 4}};
|
||||||
|
|
||||||
Labels label_send_adv{
|
|
||||||
{{0 * 8, 2 * 8}, "Send Advertisement:", Theme::getInstance()->fg_light->foreground}};
|
|
||||||
|
|
||||||
ImageButton button_send_adv{
|
|
||||||
{21 * 8, 1 * 16, 10 * 8, 2 * 16},
|
|
||||||
&bitmap_play,
|
|
||||||
Theme::getInstance()->fg_green->foreground,
|
|
||||||
Theme::getInstance()->fg_green->background};
|
|
||||||
|
|
||||||
Checkbox check_log{
|
Checkbox check_log{
|
||||||
{24 * 8, 2 * 8},
|
{24 * 8, 2 * 8},
|
||||||
3,
|
3,
|
||||||
@@ -163,7 +164,7 @@ class BLECommView : public View {
|
|||||||
true};
|
true};
|
||||||
|
|
||||||
Labels label_packets_sent{
|
Labels label_packets_sent{
|
||||||
{{0 * 8, 4 * 8}, "Packets Left:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 4 * 8}, "Packets Left:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Text text_packets_sent{
|
Text text_packets_sent{
|
||||||
{13 * 8, 2 * 16, 12 * 8, 16},
|
{13 * 8, 2 * 16, 12 * 8, 16},
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
#include "ui_textentry.hpp"
|
#include "ui_textentry.hpp"
|
||||||
#include "usb_serial_asyncmsg.hpp"
|
#include "usb_serial_asyncmsg.hpp"
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
using namespace modems;
|
using namespace modems;
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
@@ -179,21 +181,16 @@ void RecentEntriesTable<BleRecentEntries>::draw(
|
|||||||
const Entry& entry,
|
const Entry& entry,
|
||||||
const Rect& target_rect,
|
const Rect& target_rect,
|
||||||
Painter& painter,
|
Painter& painter,
|
||||||
const Style& style) {
|
const Style& style,
|
||||||
|
RecentEntriesColumns& columns) {
|
||||||
std::string line{};
|
std::string line{};
|
||||||
line.reserve(30);
|
line.reserve(40);
|
||||||
|
|
||||||
if (!entry.nameString.empty() && entry.include_name) {
|
if (!entry.nameString.empty() && entry.include_name) {
|
||||||
line = entry.nameString;
|
line = entry.nameString;
|
||||||
|
|
||||||
if (line.length() < 17) {
|
|
||||||
line += pad_string_with_spaces(17 - line.length());
|
|
||||||
} else {
|
|
||||||
line = truncate(line, 17);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
line = to_string_mac_address(entry.packetData.macAddress, 6, false);
|
line = to_string_mac_address(entry.packetData.macAddress, 6, false);
|
||||||
}
|
}
|
||||||
|
line.resize(columns.at(0).second, ' ');
|
||||||
|
|
||||||
std::string hitsStr;
|
std::string hitsStr;
|
||||||
|
|
||||||
@@ -239,15 +236,14 @@ BleRecentEntryDetailView::BleRecentEntryDetailView(NavigationView& nav, const Bl
|
|||||||
|
|
||||||
text_mac_address.set(to_string_mac_address(entry.packetData.macAddress, 6, false));
|
text_mac_address.set(to_string_mac_address(entry.packetData.macAddress, 6, false));
|
||||||
text_pdu_type.set(pdu_type_to_string(entry.pduType));
|
text_pdu_type.set(pdu_type_to_string(entry.pduType));
|
||||||
std::string vendor_name = lookup_mac_vendor(entry.packetData.macAddress);
|
text_vendor.set(entry.vendor_name.empty() ? lookup_mac_vendor(entry.packetData.macAddress) : entry.vendor_name);
|
||||||
text_vendor.set(vendor_name);
|
|
||||||
|
|
||||||
button_done.on_select = [&nav](const ui::Button&) {
|
button_done.on_select = [&nav](const ui::Button&) {
|
||||||
nav.pop();
|
nav.pop();
|
||||||
};
|
};
|
||||||
|
|
||||||
button_send.on_select = [this, &nav](const ui::Button&) {
|
button_send.on_select = [this, &nav](const ui::Button&) {
|
||||||
auto packetToSend = build_packet();
|
auto packetToSend = build_packet(entry_);
|
||||||
nav.set_on_pop([packetToSend, &nav]() {
|
nav.set_on_pop([packetToSend, &nav]() {
|
||||||
nav.replace<BLETxView>(packetToSend);
|
nav.replace<BLETxView>(packetToSend);
|
||||||
});
|
});
|
||||||
@@ -255,7 +251,7 @@ BleRecentEntryDetailView::BleRecentEntryDetailView(NavigationView& nav, const Bl
|
|||||||
};
|
};
|
||||||
|
|
||||||
button_save.on_select = [this, &nav](const ui::Button&) {
|
button_save.on_select = [this, &nav](const ui::Button&) {
|
||||||
auto packetToSave = build_packet();
|
auto packetToSave = build_packet(entry_);
|
||||||
|
|
||||||
packetFileBuffer = "";
|
packetFileBuffer = "";
|
||||||
text_prompt(
|
text_prompt(
|
||||||
@@ -431,12 +427,11 @@ void BleRecentEntryDetailView::set_entry(const BleRecentEntry& entry) {
|
|||||||
entry_ = entry;
|
entry_ = entry;
|
||||||
text_mac_address.set(to_string_mac_address(entry.packetData.macAddress, 6, false));
|
text_mac_address.set(to_string_mac_address(entry.packetData.macAddress, 6, false));
|
||||||
text_pdu_type.set(pdu_type_to_string(entry.pduType));
|
text_pdu_type.set(pdu_type_to_string(entry.pduType));
|
||||||
std::string vendor_name = lookup_mac_vendor(entry.packetData.macAddress);
|
text_vendor.set(entry.vendor_name.empty() ? lookup_mac_vendor(entry.packetData.macAddress) : entry.vendor_name);
|
||||||
text_vendor.set(vendor_name);
|
|
||||||
set_dirty();
|
set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
BLETxPacket BleRecentEntryDetailView::build_packet() {
|
BLETxPacket BleRecentEntryDetailView::build_packet(BleRecentEntry entry_) {
|
||||||
BLETxPacket bleTxPacket;
|
BLETxPacket bleTxPacket;
|
||||||
memset(&bleTxPacket, 0, sizeof(BLETxPacket));
|
memset(&bleTxPacket, 0, sizeof(BLETxPacket));
|
||||||
|
|
||||||
@@ -444,8 +439,8 @@ BLETxPacket BleRecentEntryDetailView::build_packet() {
|
|||||||
|
|
||||||
strncpy(bleTxPacket.macAddress, macAddressStr.c_str(), 12);
|
strncpy(bleTxPacket.macAddress, macAddressStr.c_str(), 12);
|
||||||
strncpy(bleTxPacket.advertisementData, entry_.dataString.c_str(), entry_.packetData.dataLen * 2);
|
strncpy(bleTxPacket.advertisementData, entry_.dataString.c_str(), entry_.packetData.dataLen * 2);
|
||||||
strncpy(bleTxPacket.packetCount, "50", 3);
|
strncpy(bleTxPacket.packetCount, "10", 3);
|
||||||
bleTxPacket.packet_count = 50;
|
bleTxPacket.packet_count = 10;
|
||||||
|
|
||||||
return bleTxPacket;
|
return bleTxPacket;
|
||||||
}
|
}
|
||||||
@@ -495,16 +490,18 @@ BLERxView::BLERxView(NavigationView& nav)
|
|||||||
&field_vga,
|
&field_vga,
|
||||||
&options_channel,
|
&options_channel,
|
||||||
&field_frequency,
|
&field_frequency,
|
||||||
&check_log,
|
|
||||||
&button_find,
|
|
||||||
&check_name,
|
|
||||||
&label_sort,
|
&label_sort,
|
||||||
&options_sort,
|
&options_sort,
|
||||||
&label_found,
|
|
||||||
&text_found_count,
|
|
||||||
&check_serial_log,
|
|
||||||
&button_filter,
|
&button_filter,
|
||||||
&options_filter,
|
&options_filter,
|
||||||
|
&check_name,
|
||||||
|
&check_log,
|
||||||
|
&check_serial_log,
|
||||||
|
&check_unique,
|
||||||
|
&check_duplicate_packets,
|
||||||
|
&button_find,
|
||||||
|
&label_found,
|
||||||
|
&text_found_count,
|
||||||
&button_save_list,
|
&button_save_list,
|
||||||
&button_clear_list,
|
&button_clear_list,
|
||||||
&button_switch,
|
&button_switch,
|
||||||
@@ -516,6 +513,29 @@ BLERxView::BLERxView(NavigationView& nav)
|
|||||||
nav_.push<BleRecentEntryDetailView>(entry);
|
nav_.push<BleRecentEntryDetailView>(entry);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ensure_directory(find_packet_path);
|
||||||
|
ensure_directory(log_packets_path);
|
||||||
|
ensure_directory(packet_save_path);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// Handle Check Boxes
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
logger = std::make_unique<BLELogger>();
|
||||||
|
|
||||||
|
check_name.on_select = [this](Checkbox&, bool v) {
|
||||||
|
name_enable = v;
|
||||||
|
// update the include_name instance variable value of each entry in recent entries
|
||||||
|
setAllMembersToValue(recent, &BleRecentEntry::include_name, v);
|
||||||
|
recent_entries_view.set_dirty();
|
||||||
|
};
|
||||||
|
|
||||||
|
check_log.on_select = [this](Checkbox&, bool v) {
|
||||||
|
logging = v;
|
||||||
|
|
||||||
|
if (logger && logging)
|
||||||
|
logger->append(bletx_dir.string() + "/Packets/BLETx_" + to_string_timestamp(rtc_time::now()) + ".TXT");
|
||||||
|
};
|
||||||
|
|
||||||
check_serial_log.on_select = [this](Checkbox&, bool v) {
|
check_serial_log.on_select = [this](Checkbox&, bool v) {
|
||||||
serial_logging = v;
|
serial_logging = v;
|
||||||
if (v) {
|
if (v) {
|
||||||
@@ -524,12 +544,28 @@ BLERxView::BLERxView(NavigationView& nav)
|
|||||||
portapack::async_tx_enabled = false;
|
portapack::async_tx_enabled = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
check_unique.on_select = [this](Checkbox&, bool v) {
|
||||||
|
uniqueParsing = v;
|
||||||
|
recent.clear();
|
||||||
|
recent_entries_view.set_dirty();
|
||||||
|
};
|
||||||
|
|
||||||
|
check_duplicate_packets.on_select = [this](Checkbox&, bool v) {
|
||||||
|
duplicatePackets = v;
|
||||||
|
recent.clear();
|
||||||
|
recent_entries_view.set_dirty();
|
||||||
|
};
|
||||||
|
|
||||||
|
check_name.set_value(name_enable);
|
||||||
|
check_log.set_value(logging);
|
||||||
check_serial_log.set_value(serial_logging);
|
check_serial_log.set_value(serial_logging);
|
||||||
|
check_unique.set_value(uniqueParsing);
|
||||||
|
check_duplicate_packets.set_value(duplicatePackets);
|
||||||
|
|
||||||
ensure_directory(find_packet_path);
|
// ------------------------------------------------------------------------------
|
||||||
ensure_directory(log_packets_path);
|
// Handle Buttons
|
||||||
ensure_directory(packet_save_path);
|
// ------------------------------------------------------------------------------
|
||||||
|
|
||||||
filterBuffer = filter;
|
filterBuffer = filter;
|
||||||
|
|
||||||
button_filter.on_select = [this](Button&) {
|
button_filter.on_select = [this](Button&) {
|
||||||
@@ -543,16 +579,6 @@ BLERxView::BLERxView(NavigationView& nav)
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
logger = std::make_unique<BLELogger>();
|
|
||||||
|
|
||||||
check_log.on_select = [this](Checkbox&, bool v) {
|
|
||||||
logging = v;
|
|
||||||
|
|
||||||
if (logger && logging)
|
|
||||||
logger->append(blerx_dir.string() + "/Logs/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT");
|
|
||||||
};
|
|
||||||
check_log.set_value(logging);
|
|
||||||
|
|
||||||
button_save_list.on_select = [this, &nav](const ui::Button&) {
|
button_save_list.on_select = [this, &nav](const ui::Button&) {
|
||||||
listFileBuffer = "";
|
listFileBuffer = "";
|
||||||
text_prompt(
|
text_prompt(
|
||||||
@@ -574,17 +600,18 @@ BLERxView::BLERxView(NavigationView& nav)
|
|||||||
nav.replace<BLETxView>();
|
nav.replace<BLETxView>();
|
||||||
};
|
};
|
||||||
|
|
||||||
field_frequency.set_step(0);
|
button_find.on_select = [this](Button&) {
|
||||||
|
auto open_view = nav_.push<FileLoadView>(".TXT");
|
||||||
check_name.set_value(name_enable);
|
open_view->on_changed = [this](std::filesystem::path new_file_path) {
|
||||||
|
on_file_changed(new_file_path);
|
||||||
check_name.on_select = [this](Checkbox&, bool v) {
|
};
|
||||||
name_enable = v;
|
|
||||||
// update the include_name instance variable value of each entry in recent entries
|
|
||||||
setAllMembersToValue(recent, &BleRecentEntry::include_name, v);
|
|
||||||
recent_entries_view.set_dirty();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// Handle Options
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
field_frequency.set_step(0);
|
||||||
|
|
||||||
options_channel.on_change = [this](size_t index, int32_t v) {
|
options_channel.on_change = [this](size_t index, int32_t v) {
|
||||||
channel_index = (uint8_t)index;
|
channel_index = (uint8_t)index;
|
||||||
|
|
||||||
@@ -608,10 +635,9 @@ BLERxView::BLERxView(NavigationView& nav)
|
|||||||
};
|
};
|
||||||
|
|
||||||
options_filter.on_change = [this](size_t index, int32_t v) {
|
options_filter.on_change = [this](size_t index, int32_t v) {
|
||||||
|
(void)v;
|
||||||
filter_index = (uint8_t)index;
|
filter_index = (uint8_t)index;
|
||||||
recent.clear();
|
recent.clear();
|
||||||
handle_filter_options(v);
|
|
||||||
uniqueParsing = filter_index == 2 ? true : false;
|
|
||||||
recent_entries_view.set_dirty();
|
recent_entries_view.set_dirty();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -619,15 +645,6 @@ BLERxView::BLERxView(NavigationView& nav)
|
|||||||
options_sort.set_selected_index(sort_index, true);
|
options_sort.set_selected_index(sort_index, true);
|
||||||
options_filter.set_selected_index(filter_index, true);
|
options_filter.set_selected_index(filter_index, true);
|
||||||
|
|
||||||
button_find.on_select = [this](Button&) {
|
|
||||||
auto open_view = nav_.push<FileLoadView>(".TXT");
|
|
||||||
open_view->on_changed = [this](std::filesystem::path new_file_path) {
|
|
||||||
on_file_changed(new_file_path);
|
|
||||||
|
|
||||||
// nav_.set_on_pop([this]() { button_play.focus(); });
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// Auto-configure modem for LCR RX (will be removed later)
|
// Auto-configure modem for LCR RX (will be removed later)
|
||||||
baseband::set_btlerx(channel_number);
|
baseband::set_btlerx(channel_number);
|
||||||
|
|
||||||
@@ -785,37 +802,28 @@ bool BLERxView::saveFile(const std::filesystem::path& path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BLERxView::on_data(BlePacketData* packet) {
|
void BLERxView::on_data(BlePacketData* packet) {
|
||||||
uint64_t macAddressEncoded = copy_mac_address_to_uint64(packet->macAddress);
|
uint64_t uniqueKeyEncoded = copy_mac_address_to_uint64(packet->macAddress);
|
||||||
|
|
||||||
// Start of Packet stuffing.
|
// Start of Packet stuffing.
|
||||||
// Masking off the top 2 bytes to avoid invalid keys.
|
// Masking off the top 2 bytes to avoid invalid keys.
|
||||||
|
|
||||||
uint64_t key = macAddressEncoded & 0xFFFFFFFFFFFF;
|
uint64_t key = (uniqueKeyEncoded & 0xFFFFFFFFFFFF);
|
||||||
bool packetExists = false;
|
|
||||||
|
if (duplicatePackets) {
|
||||||
|
key |= ((uint64_t)packet->type) << 48;
|
||||||
|
}
|
||||||
|
|
||||||
// If found store into tempEntry to modify.
|
// If found store into tempEntry to modify.
|
||||||
auto it = find(recent, key);
|
auto it = find(recent, key);
|
||||||
if (it != recent.end()) {
|
if (it != recent.end()) {
|
||||||
recent.push_front(*it);
|
recent.push_front(*it);
|
||||||
recent.erase(it);
|
recent.erase(it);
|
||||||
updateEntry(packet, recent.front(), (ADV_PDU_TYPE)packet->type);
|
|
||||||
packetExists = true;
|
|
||||||
} else {
|
} else {
|
||||||
recent.emplace_front(key);
|
recent.emplace_front(key);
|
||||||
truncate_entries(recent);
|
truncate_entries(recent);
|
||||||
|
|
||||||
packetExists = updateEntry(packet, recent.front(), (ADV_PDU_TYPE)packet->type);
|
|
||||||
|
|
||||||
// If parsing failed, remove entry.
|
|
||||||
if (!packetExists) {
|
|
||||||
recent.erase(recent.begin());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packetExists) {
|
if (updateEntry(packet, recent.front(), (ADV_PDU_TYPE)packet->type)) {
|
||||||
handle_filter_options(options_filter.selected_index());
|
|
||||||
handle_entries_sort(options_sort.selected_index());
|
|
||||||
|
|
||||||
if (!searchList.empty()) {
|
if (!searchList.empty()) {
|
||||||
auto it = searchList.begin();
|
auto it = searchList.begin();
|
||||||
|
|
||||||
@@ -833,24 +841,31 @@ void BLERxView::on_data(BlePacketData* packet) {
|
|||||||
|
|
||||||
text_found_count.set(to_string_dec_uint(found_count) + "/" + to_string_dec_uint(total_count));
|
text_found_count.set(to_string_dec_uint(found_count) + "/" + to_string_dec_uint(total_count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Packets were updated, resort the list.
|
||||||
|
handle_entries_sort(options_sort.selected_index());
|
||||||
|
} else {
|
||||||
|
recent.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
log_ble_packet(packet);
|
log_ble_packet(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLERxView::log_ble_packet(BlePacketData* packet) {
|
void BLERxView::log_ble_packet(BlePacketData* packet) {
|
||||||
str_console = "";
|
if ((logger && logging) || serial_logging) {
|
||||||
str_console += pdu_type_to_string((ADV_PDU_TYPE)packet->type);
|
str_console = "";
|
||||||
str_console += " Len:";
|
str_console += pdu_type_to_string((ADV_PDU_TYPE)packet->type);
|
||||||
str_console += to_string_dec_uint(packet->size);
|
str_console += " Len:";
|
||||||
str_console += " Mac:";
|
str_console += to_string_dec_uint(packet->size);
|
||||||
str_console += to_string_mac_address(packet->macAddress, 6, false);
|
str_console += " Mac:";
|
||||||
str_console += " Data:";
|
str_console += to_string_mac_address(packet->macAddress, 6, false);
|
||||||
|
str_console += " Data:";
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < packet->dataLen; i++) {
|
for (i = 0; i < packet->dataLen; i++) {
|
||||||
str_console += to_string_hex(packet->data[i], 2);
|
str_console += to_string_hex(packet->data[i], 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log at End of Packet.
|
// Log at End of Packet.
|
||||||
@@ -866,12 +881,8 @@ void BLERxView::log_ble_packet(BlePacketData* packet) {
|
|||||||
void BLERxView::on_filter_change(std::string value) {
|
void BLERxView::on_filter_change(std::string value) {
|
||||||
// New filter? Reset list from recent entries.
|
// New filter? Reset list from recent entries.
|
||||||
if (filter != value) {
|
if (filter != value) {
|
||||||
// resetFilteredEntries(recent, [&value](const BleRecentEntry& entry) {
|
|
||||||
// // return (entry.dataString.find(value) == std::string::npos) && (entry.nameString.find(value) == std::string::npos);
|
|
||||||
// return (entry.dataString.find(value) == std::string::npos) && (entry.nameString.find(value) == std::string::npos) && (to_string_mac_address(entry.packetData.macAddress, 6, false).find(value) == std::string::npos);
|
|
||||||
// });
|
|
||||||
filter = value;
|
filter = value;
|
||||||
handle_filter_options(options_filter.selected_index());
|
recent.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,7 +958,7 @@ void BLERxView::handle_entries_sort(uint8_t index) {
|
|||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
sortEntriesBy(
|
sortEntriesBy(
|
||||||
recent, [](const BleRecentEntry& entry) { return entry.macAddress; }, true);
|
recent, [](const BleRecentEntry& entry) { return entry.uniqueKey & 0xFFFFFFFFFFFF; }, true);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
sortEntriesBy(
|
sortEntriesBy(
|
||||||
@@ -965,6 +976,10 @@ void BLERxView::handle_entries_sort(uint8_t index) {
|
|||||||
sortEntriesBy(
|
sortEntriesBy(
|
||||||
recent, [](const BleRecentEntry& entry) { return entry.nameString; }, true);
|
recent, [](const BleRecentEntry& entry) { return entry.nameString; }, true);
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
sortEntriesBy(
|
||||||
|
recent, [](const BleRecentEntry& entry) { return entry.informationString; }, true);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -972,21 +987,31 @@ void BLERxView::handle_entries_sort(uint8_t index) {
|
|||||||
recent_entries_view.set_dirty();
|
recent_entries_view.set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLERxView::handle_filter_options(uint8_t index) {
|
bool BLERxView::handle_filter_options(uint8_t index, const BleRecentEntry& entry) {
|
||||||
auto value = filter;
|
const std::string& value = filter; // no copy
|
||||||
|
if (value.empty()) return true;
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0: // filter by Data
|
case 0: // Data OR Name
|
||||||
resetFilteredEntries(recent, [&value](const BleRecentEntry& entry) {
|
return std::string_view(entry.dataString).find(value) != std::string_view::npos || std::string_view(entry.nameString).find(value) != std::string_view::npos;
|
||||||
return (entry.dataString.find(value) == std::string::npos) && (entry.nameString.find(value) == std::string::npos);
|
|
||||||
});
|
case 1: // MAC
|
||||||
break;
|
return std::string_view(to_string_mac_address(entry.packetData.macAddress, 6, false)).find(value) != std::string_view::npos;
|
||||||
case 1: // filter by MAC address (All caps: e.g. AA:BB:CC:DD:EE:FF)
|
|
||||||
resetFilteredEntries(recent, [&value](const BleRecentEntry& entry) {
|
case 2: // Name
|
||||||
return (to_string_mac_address(entry.packetData.macAddress, 6, false).find(value) == std::string::npos);
|
return std::string_view(entry.nameString).find(value) != std::string_view::npos;
|
||||||
});
|
|
||||||
break;
|
case 3: // Info
|
||||||
|
return std::string_view(entry.informationString).find(value) != std::string_view::npos;
|
||||||
|
|
||||||
|
case 4: // Vendor
|
||||||
|
return std::string_view(entry.vendor_name).find(value) != std::string_view::npos;
|
||||||
|
|
||||||
|
case 5: // Channel (string once, not per call)
|
||||||
|
return std::string_view(to_string_dec_int(entry.channelNumber)).find(value) != std::string_view::npos;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1007,60 +1032,175 @@ bool BLERxView::updateEntry(const BlePacketData* packet, BleRecentEntry& entry,
|
|||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < packet->dataLen; i++) {
|
|
||||||
data_string += to_string_hex(packet->data[i], 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
entry.dbValue = packet->max_dB - (receiver_model.lna() + receiver_model.vga() + (receiver_model.rf_amp() ? 14 : 0));
|
|
||||||
entry.timestamp = to_string_timestamp(rtc_time::now());
|
|
||||||
entry.dataString = data_string;
|
|
||||||
|
|
||||||
entry.packetData.type = packet->type;
|
|
||||||
entry.packetData.size = packet->size;
|
|
||||||
entry.packetData.dataLen = packet->dataLen;
|
|
||||||
|
|
||||||
// Mac Address of sender.
|
|
||||||
entry.packetData.macAddress[0] = packet->macAddress[0];
|
|
||||||
entry.packetData.macAddress[1] = packet->macAddress[1];
|
|
||||||
entry.packetData.macAddress[2] = packet->macAddress[2];
|
|
||||||
entry.packetData.macAddress[3] = packet->macAddress[3];
|
|
||||||
entry.packetData.macAddress[4] = packet->macAddress[4];
|
|
||||||
entry.packetData.macAddress[5] = packet->macAddress[5];
|
|
||||||
|
|
||||||
entry.pduType = pdu_type;
|
|
||||||
entry.channelNumber = channel_number;
|
|
||||||
entry.numHits++;
|
|
||||||
|
|
||||||
if (entry.vendor_status == MAC_VENDOR_UNKNOWN) {
|
|
||||||
std::string vendor_name;
|
|
||||||
entry.vendor_status = lookup_mac_vendor_status(entry.packetData.macAddress, vendor_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse Data Section into buffer to be interpretted later.
|
|
||||||
for (int i = 0; i < packet->dataLen; i++) {
|
|
||||||
entry.packetData.data[i] = packet->data[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
entry.include_name = check_name.value();
|
|
||||||
|
|
||||||
// Only parse name for advertisment packets and empty name entries
|
// Only parse name for advertisment packets and empty name entries
|
||||||
if (pdu_type == ADV_IND || pdu_type == ADV_NONCONN_IND || pdu_type == SCAN_RSP || pdu_type == ADV_SCAN_IND) {
|
if (pdu_type == ADV_IND || pdu_type == ADV_NONCONN_IND || pdu_type == SCAN_RSP || pdu_type == ADV_SCAN_IND) {
|
||||||
if (uniqueParsing) {
|
if (uniqueParsing) {
|
||||||
// Add your unique beacon parsing function here.
|
success = parse_tracking_beacon_data(packet->data, packet->dataLen, entry.nameString, entry.informationString);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success && !uniqueParsing) {
|
if (!success && !uniqueParsing) {
|
||||||
success = parse_beacon_data(packet->data, packet->dataLen, entry.nameString, entry.informationString);
|
success = parse_beacon_data(packet->data, packet->dataLen, entry.nameString, entry.informationString);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (pdu_type == ADV_DIRECT_IND || pdu_type == SCAN_REQ) {
|
} else if (pdu_type == ADV_DIRECT_IND || pdu_type == SCAN_REQ) {
|
||||||
ADV_PDU_PAYLOAD_TYPE_1_3* directed_mac_data = (ADV_PDU_PAYLOAD_TYPE_1_3*)entry.packetData.data;
|
if (!uniqueParsing) {
|
||||||
reverse_byte_array(directed_mac_data->A1, 6);
|
ADV_PDU_PAYLOAD_TYPE_1_3* directed_mac_data = (ADV_PDU_PAYLOAD_TYPE_1_3*)packet->data;
|
||||||
|
reverse_byte_array(directed_mac_data->A1, 6);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
if (success) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < packet->dataLen; i++) {
|
||||||
|
data_string += to_string_hex(packet->data[i], 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.dbValue = packet->max_dB - (receiver_model.lna() + receiver_model.vga() + (receiver_model.rf_amp() ? 14 : 0));
|
||||||
|
entry.timestamp = to_string_timestamp(rtc_time::now());
|
||||||
|
entry.dataString = data_string;
|
||||||
|
|
||||||
|
entry.packetData.type = packet->type;
|
||||||
|
entry.packetData.size = packet->size;
|
||||||
|
entry.packetData.dataLen = packet->dataLen;
|
||||||
|
|
||||||
|
// Mac Address of sender.
|
||||||
|
entry.packetData.macAddress[0] = packet->macAddress[0];
|
||||||
|
entry.packetData.macAddress[1] = packet->macAddress[1];
|
||||||
|
entry.packetData.macAddress[2] = packet->macAddress[2];
|
||||||
|
entry.packetData.macAddress[3] = packet->macAddress[3];
|
||||||
|
entry.packetData.macAddress[4] = packet->macAddress[4];
|
||||||
|
entry.packetData.macAddress[5] = packet->macAddress[5];
|
||||||
|
|
||||||
|
entry.pduType = pdu_type;
|
||||||
|
entry.channelNumber = channel_number;
|
||||||
|
entry.numHits++;
|
||||||
|
|
||||||
|
if (entry.vendor_status == MAC_VENDOR_UNKNOWN) {
|
||||||
|
entry.vendor_status = lookup_mac_vendor_status(entry.packetData.macAddress, entry.vendor_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse Data Section into buffer to be interpretted later.
|
||||||
|
for (int i = 0; i < packet->dataLen; i++) {
|
||||||
|
entry.packetData.data[i] = packet->data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.include_name = check_name.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
return handle_filter_options(options_filter.selected_index(), entry) && success;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BLERxView::parse_tracking_beacon_data(const uint8_t* data, uint8_t length, std::string& nameString, std::string& informationString) {
|
||||||
|
uint8_t currentByte, currentLength, currentType = 0;
|
||||||
|
|
||||||
|
for (currentByte = 0; currentByte < length;) {
|
||||||
|
currentLength = data[currentByte++];
|
||||||
|
currentType = data[currentByte++];
|
||||||
|
|
||||||
|
// Manufacturer Specific Data (0xFF)
|
||||||
|
if (currentType == 0xFF && currentLength >= 4) {
|
||||||
|
uint16_t companyID = data[currentByte] | (data[currentByte + 1] << 8);
|
||||||
|
|
||||||
|
// Apple AirTag / Find My
|
||||||
|
if (companyID == 0x004C && currentLength >= 6) {
|
||||||
|
uint8_t appleType = data[currentByte + 2];
|
||||||
|
uint8_t appleLen = data[currentByte + 3];
|
||||||
|
if (appleType == 0x12 && appleLen == 0x19 && currentLength >= 4 + appleLen) {
|
||||||
|
nameString.assign("Apple AirTag");
|
||||||
|
informationString.assign("Find My");
|
||||||
|
return true;
|
||||||
|
} else if (appleType == 0x02 && appleLen == 0x15) {
|
||||||
|
uint16_t major = (data[currentByte + 20] << 8) | data[currentByte + 21];
|
||||||
|
uint16_t minor = (data[currentByte + 22] << 8) | data[currentByte + 23];
|
||||||
|
|
||||||
|
nameString.assign("iBeacon");
|
||||||
|
informationString.assign(to_string_hex(major) + to_string_hex(minor));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Services
|
||||||
|
else if ((currentType == 0x02 || currentType == 0x03) && currentLength >= 3) {
|
||||||
|
for (int u = 0; u < currentLength - 1; u += 2) {
|
||||||
|
uint16_t uuid16 = data[currentByte + u] | (data[currentByte + u + 1] << 8);
|
||||||
|
if (uuid16 == 0x1802) { // Immediate Alert Service = Find Me Profile
|
||||||
|
nameString.assign("FindMe");
|
||||||
|
informationString.assign("IAS");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Service Data
|
||||||
|
else if (currentType == 0x16 && currentLength >= 3) {
|
||||||
|
uint16_t uuid16 = data[currentByte] | (data[currentByte + 1] << 8);
|
||||||
|
|
||||||
|
switch (uuid16) {
|
||||||
|
case 0xFD59: { // Samsung SmartTag - Unregistered
|
||||||
|
nameString.assign("Samsung SmartTag");
|
||||||
|
informationString.assign("Unreg");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case 0xFD5A: { // Samsung SmartTag - Registered
|
||||||
|
nameString.assign("Samsung SmartTag");
|
||||||
|
informationString.assign("Reg");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case 0xFD84: {
|
||||||
|
if (currentByte + 2 < length) {
|
||||||
|
uint8_t model = data[currentByte + 2];
|
||||||
|
switch (model) {
|
||||||
|
case 0x01:
|
||||||
|
informationString.assign("Mate");
|
||||||
|
break;
|
||||||
|
case 0x02:
|
||||||
|
informationString.assign("Pro");
|
||||||
|
break;
|
||||||
|
case 0x03:
|
||||||
|
informationString.assign("Slim");
|
||||||
|
break;
|
||||||
|
case 0x04:
|
||||||
|
informationString.assign("Sticker");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
informationString.assign("Unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nameString.assign("Tile");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case 0xFEAA: {
|
||||||
|
if (currentByte + 2 < length) {
|
||||||
|
uint8_t frameType = data[currentByte + 2];
|
||||||
|
switch (frameType) {
|
||||||
|
case 0x00:
|
||||||
|
informationString.assign("UID");
|
||||||
|
break;
|
||||||
|
case 0x10:
|
||||||
|
informationString.assign("URL");
|
||||||
|
break;
|
||||||
|
case 0x20:
|
||||||
|
informationString.assign("TLM");
|
||||||
|
break;
|
||||||
|
case 0x30:
|
||||||
|
informationString.assign("EID");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
informationString.assign("Unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nameString.assign("Eddystone");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentByte += (currentLength - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BLERxView::parse_beacon_data(const uint8_t* data, uint8_t length, std::string& nameString, std::string& informationString) {
|
bool BLERxView::parse_beacon_data(const uint8_t* data, uint8_t length, std::string& nameString, std::string& informationString) {
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ typedef enum {
|
|||||||
RESERVED5 = 12,
|
RESERVED5 = 12,
|
||||||
RESERVED6 = 13,
|
RESERVED6 = 13,
|
||||||
RESERVED7 = 14,
|
RESERVED7 = 14,
|
||||||
RESERVED8 = 15
|
RESERVED8 = 15,
|
||||||
|
UNKNOWN = 16
|
||||||
} ADV_PDU_TYPE;
|
} ADV_PDU_TYPE;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -84,9 +85,9 @@ typedef enum {
|
|||||||
struct BleRecentEntry {
|
struct BleRecentEntry {
|
||||||
using Key = uint64_t;
|
using Key = uint64_t;
|
||||||
|
|
||||||
static constexpr Key invalid_key = 0xFFFFFFFFFFFF;
|
static constexpr Key invalid_key = 0xFFFFFFFFFFFFF;
|
||||||
|
|
||||||
uint64_t macAddress;
|
uint64_t uniqueKey;
|
||||||
int dbValue;
|
int dbValue;
|
||||||
BlePacketData packetData;
|
BlePacketData packetData;
|
||||||
std::string timestamp;
|
std::string timestamp;
|
||||||
@@ -98,6 +99,7 @@ struct BleRecentEntry {
|
|||||||
ADV_PDU_TYPE pduType;
|
ADV_PDU_TYPE pduType;
|
||||||
uint8_t channelNumber;
|
uint8_t channelNumber;
|
||||||
MAC_VENDOR_STATUS vendor_status;
|
MAC_VENDOR_STATUS vendor_status;
|
||||||
|
std::string vendor_name;
|
||||||
bool entryFound;
|
bool entryFound;
|
||||||
|
|
||||||
BleRecentEntry()
|
BleRecentEntry()
|
||||||
@@ -105,8 +107,8 @@ struct BleRecentEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BleRecentEntry(
|
BleRecentEntry(
|
||||||
const uint64_t macAddress)
|
const uint64_t uniqueKey)
|
||||||
: macAddress{macAddress},
|
: uniqueKey{uniqueKey},
|
||||||
dbValue{},
|
dbValue{},
|
||||||
packetData{},
|
packetData{},
|
||||||
timestamp{},
|
timestamp{},
|
||||||
@@ -118,11 +120,12 @@ struct BleRecentEntry {
|
|||||||
pduType{},
|
pduType{},
|
||||||
channelNumber{},
|
channelNumber{},
|
||||||
vendor_status{MAC_VENDOR_UNKNOWN},
|
vendor_status{MAC_VENDOR_UNKNOWN},
|
||||||
|
vendor_name{},
|
||||||
entryFound{} {
|
entryFound{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
Key key() const {
|
Key key() const {
|
||||||
return macAddress;
|
return uniqueKey;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -139,11 +142,11 @@ class BleRecentEntryDetailView : public View {
|
|||||||
void update_data();
|
void update_data();
|
||||||
void focus() override;
|
void focus() override;
|
||||||
void paint(Painter&) override;
|
void paint(Painter&) override;
|
||||||
|
static BLETxPacket build_packet(BleRecentEntry entry_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
BleRecentEntry entry_{};
|
BleRecentEntry entry_{};
|
||||||
BLETxPacket build_packet();
|
|
||||||
void on_save_file(const std::string value, BLETxPacket packetToSave);
|
void on_save_file(const std::string value, BLETxPacket packetToSave);
|
||||||
bool saveFile(const std::filesystem::path& path, BLETxPacket packetToSave);
|
bool saveFile(const std::filesystem::path& path, BLETxPacket packetToSave);
|
||||||
std::string packetFileBuffer{};
|
std::string packetFileBuffer{};
|
||||||
@@ -152,42 +155,42 @@ class BleRecentEntryDetailView : public View {
|
|||||||
static constexpr uint8_t total_data_lines{5};
|
static constexpr uint8_t total_data_lines{5};
|
||||||
|
|
||||||
Labels label_mac_address{
|
Labels label_mac_address{
|
||||||
{{0 * 8, 0 * 16}, "Mac Address:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), UI_POS_Y(0)}, "Mac Address:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Text text_mac_address{
|
Text text_mac_address{
|
||||||
{12 * 8, 0 * 16, 17 * 8, 16},
|
{UI_POS_X(12), UI_POS_Y(0), UI_POS_WIDTH(17), UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Labels label_pdu_type{
|
Labels label_pdu_type{
|
||||||
{{0 * 8, 1 * 16}, "PDU Type:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), UI_POS_Y(1)}, "PDU Type:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Text text_pdu_type{
|
Text text_pdu_type{
|
||||||
{9 * 8, 1 * 16, 17 * 8, 16},
|
{9 * 8, UI_POS_Y(1), 17 * 8, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Labels label_vendor{
|
Labels label_vendor{
|
||||||
{{0 * 8, 2 * 16}, "Vendor:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), UI_POS_Y(2)}, "Vendor:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Text text_vendor{
|
Text text_vendor{
|
||||||
{7 * 8, 2 * 16, 23 * 8, 16},
|
{7 * 8, UI_POS_Y(2), 23 * 8, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 3 * 16}, "Len", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), UI_POS_Y(3)}, "Len", Theme::getInstance()->fg_light->foreground},
|
||||||
{{5 * 8, 3 * 16}, "Type", Theme::getInstance()->fg_light->foreground},
|
{{5 * 8, UI_POS_Y(3)}, "Type", Theme::getInstance()->fg_light->foreground},
|
||||||
{{10 * 8, 3 * 16}, "Value", Theme::getInstance()->fg_light->foreground},
|
{{10 * 8, UI_POS_Y(3)}, "Value", Theme::getInstance()->fg_light->foreground},
|
||||||
};
|
};
|
||||||
|
|
||||||
Button button_send{
|
Button button_send{
|
||||||
{19, 224, 96, 24},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), 224, 96, 24},
|
||||||
"Send"};
|
"Send"};
|
||||||
|
|
||||||
Button button_done{
|
Button button_done{
|
||||||
{125, 224, 96, 24},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), 224, 96, 24},
|
||||||
"Done"};
|
"Done"};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{72, 264, 96, 24},
|
{UI_POS_X_CENTER(12), 264, 96, 24},
|
||||||
"Save"};
|
"Save"};
|
||||||
|
|
||||||
bool send_updates{false};
|
bool send_updates{false};
|
||||||
@@ -224,9 +227,10 @@ class BLERxView : public View {
|
|||||||
void file_error();
|
void file_error();
|
||||||
void on_timer();
|
void on_timer();
|
||||||
void handle_entries_sort(uint8_t index);
|
void handle_entries_sort(uint8_t index);
|
||||||
void handle_filter_options(uint8_t index);
|
bool handle_filter_options(uint8_t index, const BleRecentEntry& entry);
|
||||||
bool updateEntry(const BlePacketData* packet, BleRecentEntry& entry, ADV_PDU_TYPE pdu_type);
|
bool updateEntry(const BlePacketData* packet, BleRecentEntry& entry, ADV_PDU_TYPE pdu_type);
|
||||||
bool parse_beacon_data(const uint8_t* data, uint8_t length, std::string& nameString, std::string& informationString);
|
bool parse_beacon_data(const uint8_t* data, uint8_t length, std::string& nameString, std::string& informationString);
|
||||||
|
bool parse_tracking_beacon_data(const uint8_t* data, uint8_t length, std::string& nameString, std::string& informationString);
|
||||||
|
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
|
|
||||||
@@ -240,6 +244,7 @@ class BLERxView : public View {
|
|||||||
uint8_t sort_index{0};
|
uint8_t sort_index{0};
|
||||||
uint8_t filter_index{0};
|
uint8_t filter_index{0};
|
||||||
bool uniqueParsing = false;
|
bool uniqueParsing = false;
|
||||||
|
bool duplicatePackets = false;
|
||||||
std::string filter{};
|
std::string filter{};
|
||||||
bool logging{false};
|
bool logging{false};
|
||||||
bool serial_logging{false};
|
bool serial_logging{false};
|
||||||
@@ -258,6 +263,8 @@ class BLERxView : public View {
|
|||||||
// disabled to always start without USB serial activated until we can make it non blocking if not connected
|
// disabled to always start without USB serial activated until we can make it non blocking if not connected
|
||||||
// {"serial_log"sv, &serial_logging},
|
// {"serial_log"sv, &serial_logging},
|
||||||
{"name"sv, &name_enable},
|
{"name"sv, &name_enable},
|
||||||
|
{"unique_parsing"sv, &uniqueParsing},
|
||||||
|
{"duplicate_packets"sv, &duplicatePackets},
|
||||||
}};
|
}};
|
||||||
|
|
||||||
std::string str_console = "";
|
std::string str_console = "";
|
||||||
@@ -267,7 +274,7 @@ class BLERxView : public View {
|
|||||||
bool auto_channel = false;
|
bool auto_channel = false;
|
||||||
|
|
||||||
int16_t timer_count{0};
|
int16_t timer_count{0};
|
||||||
int16_t timer_period{2}; // 25ms
|
int16_t timer_period{1}; // 25ms
|
||||||
|
|
||||||
std::string filterBuffer{};
|
std::string filterBuffer{};
|
||||||
std::string listFileBuffer{};
|
std::string listFileBuffer{};
|
||||||
@@ -283,11 +290,11 @@ class BLERxView : public View {
|
|||||||
std::filesystem::path log_packets_path{blerx_dir / u"Logs/????.TXT"};
|
std::filesystem::path log_packets_path{blerx_dir / u"Logs/????.TXT"};
|
||||||
std::filesystem::path packet_save_path{blerx_dir / u"Lists/????.csv"};
|
std::filesystem::path packet_save_path{blerx_dir / u"Lists/????.csv"};
|
||||||
|
|
||||||
static constexpr auto header_height = 9 * 8;
|
static constexpr auto header_height = 12 * 8;
|
||||||
static constexpr auto switch_button_height = 3 * 16;
|
static constexpr auto switch_button_height = 3 * 16;
|
||||||
|
|
||||||
OptionsField options_channel{
|
OptionsField options_channel{
|
||||||
{0 * 8, 0 * 8},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
5,
|
5,
|
||||||
{{"Ch.37", 37},
|
{{"Ch.37", 37},
|
||||||
{"Ch.38", 38},
|
{"Ch.38", 38},
|
||||||
@@ -295,46 +302,50 @@ class BLERxView : public View {
|
|||||||
{"Auto", 40}}};
|
{"Auto", 40}}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{6 * 8, 0 * 16},
|
{UI_POS_X(6), UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{16 * 8, 0 * 16}};
|
{UI_POS_X(16), UI_POS_Y(0)}};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{18 * 8, 0 * 16}};
|
{UI_POS_X(18), UI_POS_Y(0)}};
|
||||||
|
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{21 * 8, 0 * 16}};
|
{UI_POS_X(21), UI_POS_Y(0)}};
|
||||||
|
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{24 * 8, 0, 6 * 8, 4}};
|
{UI_POS_X(24), 0, UI_POS_WIDTH_REMAINING(6), 4}};
|
||||||
|
|
||||||
Channel channel{
|
Channel channel{
|
||||||
{24 * 8, 5, 6 * 8, 4}};
|
{UI_POS_X(24), 5, UI_POS_WIDTH_REMAINING(6), 4}};
|
||||||
|
|
||||||
Labels label_sort{
|
Labels label_sort{
|
||||||
{{0 * 8, 2 * 8}, "Sort:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), UI_POS_Y(1)}, "Sort:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
OptionsField options_sort{
|
OptionsField options_sort{
|
||||||
{5 * 8, 2 * 8},
|
{5 * 8, UI_POS_Y(1)},
|
||||||
4,
|
4,
|
||||||
{{"MAC", 0},
|
{{"MAC", 0},
|
||||||
{"Hits", 1},
|
{"Hits", 1},
|
||||||
{"dB", 2},
|
{"dB", 2},
|
||||||
{"Time", 3},
|
{"Time", 3},
|
||||||
{"Name", 4}}};
|
{"Name", 4},
|
||||||
|
{"Info", 5}}};
|
||||||
|
|
||||||
Button button_filter{
|
Button button_filter{
|
||||||
{11 * 8, 2 * 8, 7 * 8, 16},
|
{11 * 8, UI_POS_Y(1), 7 * 8, 16},
|
||||||
"Filter:"};
|
"Filter:"};
|
||||||
|
|
||||||
OptionsField options_filter{
|
OptionsField options_filter{
|
||||||
{18 * 8 + 2, 2 * 8},
|
{18 * 8 + 2, UI_POS_Y(1)},
|
||||||
7,
|
7,
|
||||||
{{"Data", 0},
|
{{"Data", 0},
|
||||||
{"MAC", 1},
|
{"MAC", 1},
|
||||||
{"Unique", 2}}};
|
{"Name", 2},
|
||||||
|
{"Info", 3},
|
||||||
|
{"Vendor", 4},
|
||||||
|
{"Channel", 5}}};
|
||||||
|
|
||||||
Checkbox check_log{
|
Checkbox check_log{
|
||||||
{10 * 8, 4 * 8 + 2},
|
{10 * 8, 4 * 8 + 2},
|
||||||
@@ -343,41 +354,50 @@ class BLERxView : public View {
|
|||||||
true};
|
true};
|
||||||
|
|
||||||
Checkbox check_name{
|
Checkbox check_name{
|
||||||
{0 * 8, 4 * 8 + 2},
|
{UI_POS_X(0), 4 * 8 + 2},
|
||||||
3,
|
3,
|
||||||
"Name",
|
"Name",
|
||||||
true};
|
true};
|
||||||
|
|
||||||
Button button_find{
|
|
||||||
{0 * 8, 7 * 8 - 2, 4 * 8, 16},
|
|
||||||
"Find"};
|
|
||||||
|
|
||||||
Labels label_found{
|
|
||||||
{{5 * 8, 7 * 8 - 2}, "Found:", Theme::getInstance()->fg_light->foreground}};
|
|
||||||
|
|
||||||
Text text_found_count{
|
|
||||||
{11 * 8, 7 * 8 - 2, 20 * 8, 16},
|
|
||||||
"0/0"};
|
|
||||||
|
|
||||||
Checkbox check_serial_log{
|
Checkbox check_serial_log{
|
||||||
{18 * 8 + 2, 4 * 8 + 2},
|
{18 * 8 + 2, 4 * 8 + 2},
|
||||||
7,
|
7,
|
||||||
"USB Log",
|
"USB Log",
|
||||||
true};
|
true};
|
||||||
|
|
||||||
// Console console{
|
Checkbox check_unique{
|
||||||
// {0, 10 * 8, screen_height, screen_height-80}};
|
{0 * 8 + 2, 7 * 8 + 2},
|
||||||
|
7,
|
||||||
|
"Unique",
|
||||||
|
true};
|
||||||
|
|
||||||
|
Checkbox check_duplicate_packets{
|
||||||
|
{10 * 8 + 2, 7 * 8 + 2},
|
||||||
|
7,
|
||||||
|
"Duplicate",
|
||||||
|
true};
|
||||||
|
|
||||||
|
Button button_find{
|
||||||
|
{UI_POS_X(0), 10 * 8 - 2, 4 * 8, 16},
|
||||||
|
"Find"};
|
||||||
|
|
||||||
|
Labels label_found{
|
||||||
|
{{5 * 8, 10 * 8 - 2}, "Found:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
|
Text text_found_count{
|
||||||
|
{11 * 8, 10 * 8 - 2, 20 * 8, 16},
|
||||||
|
"0/0"};
|
||||||
|
|
||||||
Button button_clear_list{
|
Button button_clear_list{
|
||||||
{2 * 8, screen_height - (16 + 32), 7 * 8, 32},
|
{2 * 8, screen_height - (16 + 32), 7 * 8, 32},
|
||||||
"Clear"};
|
"Clear"};
|
||||||
|
|
||||||
Button button_save_list{
|
Button button_save_list{
|
||||||
{11 * 8, screen_height - (16 + 32), 11 * 8, 32},
|
{UI_POS_X_CENTER(11), screen_height - (16 + 32), 11 * 8, 32},
|
||||||
"Export CSV"};
|
"Export CSV"};
|
||||||
|
|
||||||
Button button_switch{
|
Button button_switch{
|
||||||
{screen_width - 6 * 8, screen_height - (16 + 32), 4 * 8, 32},
|
{UI_POS_X_RIGHT(6), screen_height - (16 + 32), 4 * 8, 32},
|
||||||
"Tx"};
|
"Tx"};
|
||||||
|
|
||||||
std::string str_log{""};
|
std::string str_log{""};
|
||||||
@@ -387,7 +407,7 @@ class BLERxView : public View {
|
|||||||
BleRecentEntries tempList{};
|
BleRecentEntries tempList{};
|
||||||
|
|
||||||
RecentEntriesColumns columns{{
|
RecentEntriesColumns columns{{
|
||||||
{"Name", 17},
|
{"Name", 0},
|
||||||
{"Hits", 7},
|
{"Hits", 7},
|
||||||
{"dBm", 4},
|
{"dBm", 4},
|
||||||
}};
|
}};
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "rtc_time.hpp"
|
#include "rtc_time.hpp"
|
||||||
#include "string_format.hpp"
|
#include "string_format.hpp"
|
||||||
#include "file_path.hpp"
|
#include "file_path.hpp"
|
||||||
|
#include "usb_serial_asyncmsg.hpp"
|
||||||
|
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
using namespace modems;
|
using namespace modems;
|
||||||
@@ -123,6 +124,31 @@ static std::uint64_t get_freq_by_channel_number(uint8_t channel_number) {
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
|
PKT_TYPE get_pkt_type_from_string(const std::string& type_str) {
|
||||||
|
if (type_str == "RAW") {
|
||||||
|
return PKT_TYPE_RAW;
|
||||||
|
} else if (type_str == "DISCOVERY") {
|
||||||
|
return PKT_TYPE_DISCOVERY;
|
||||||
|
} else if (type_str == "IBEACON") {
|
||||||
|
return PKT_TYPE_IBEACON;
|
||||||
|
} else if (type_str == "ADV_IND") {
|
||||||
|
return PKT_TYPE_ADV_IND;
|
||||||
|
} else if (type_str == "ADV_DIRECT_IND") {
|
||||||
|
return PKT_TYPE_ADV_DIRECT_IND;
|
||||||
|
} else if (type_str == "ADV_NONCONN_IND") {
|
||||||
|
return PKT_TYPE_ADV_NONCONN_IND;
|
||||||
|
} else if (type_str == "ADV_SCAN_IND") {
|
||||||
|
return PKT_TYPE_ADV_SCAN_IND;
|
||||||
|
} else if (type_str == "SCAN_REQ") {
|
||||||
|
return PKT_TYPE_SCAN_REQ;
|
||||||
|
} else if (type_str == "SCAN_RSP") {
|
||||||
|
return PKT_TYPE_SCAN_RSP;
|
||||||
|
} else if (type_str == "CONNECT_REQ") {
|
||||||
|
return PKT_TYPE_CONNECT_REQ;
|
||||||
|
}
|
||||||
|
return PKT_TYPE_INVALID_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
void BLETxView::focus() {
|
void BLETxView::focus() {
|
||||||
button_open.focus();
|
button_open.focus();
|
||||||
}
|
}
|
||||||
@@ -167,28 +193,11 @@ void BLETxView::toggle() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLETxView::start() {
|
void BLETxView::send_packet() {
|
||||||
baseband::run_image(portapack::spi_flash::image_tag_btle_tx);
|
|
||||||
transmitter_model.enable();
|
|
||||||
|
|
||||||
// Generate new random Mac Address.
|
// Generate new random Mac Address.
|
||||||
|
transmitter_model.enable();
|
||||||
generateRandomMacAddress(randomMac);
|
generateRandomMacAddress(randomMac);
|
||||||
|
|
||||||
// If this is our first run, check file.
|
|
||||||
if (!is_active()) {
|
|
||||||
File data_file;
|
|
||||||
|
|
||||||
auto error = data_file.open(file_path);
|
|
||||||
if (error && !file_override) {
|
|
||||||
file_error();
|
|
||||||
check_loop.set_value(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
button_play.set_bitmap(&bitmap_stop);
|
|
||||||
is_running = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
char advertisementData[63] = {0};
|
char advertisementData[63] = {0};
|
||||||
strcpy(advertisementData, packets[current_packet].advertisementData);
|
strcpy(advertisementData, packets[current_packet].advertisementData);
|
||||||
|
|
||||||
@@ -235,9 +244,28 @@ void BLETxView::start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup next packet configuration.
|
progressbar.set_value(packets[current_packet].packet_count - packet_counter);
|
||||||
progressbar.set_max(packets[current_packet].packet_count);
|
text_packets_sent.set(to_string_dec_uint(packet_counter));
|
||||||
baseband::set_btletx(channel_number, random_mac ? randomMac : packets[current_packet].macAddress, advertisementData, pduType);
|
|
||||||
|
baseband::set_btletx(channel_number, random_mac ? randomMac : packets[current_packet].macAddress, advertisementData, packets[current_packet].pduType);
|
||||||
|
|
||||||
|
packetDone = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BLETxView::start() {
|
||||||
|
if (file_path.empty()) {
|
||||||
|
file_error();
|
||||||
|
check_loop.set_value(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
baseband::run_image(portapack::spi_flash::image_tag_btle_tx);
|
||||||
|
transmitter_model.enable();
|
||||||
|
|
||||||
|
button_play.set_bitmap(&bitmap_stop);
|
||||||
|
is_running = true;
|
||||||
|
|
||||||
|
send_packet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLETxView::stop() {
|
void BLETxView::stop() {
|
||||||
@@ -253,66 +281,69 @@ void BLETxView::stop() {
|
|||||||
is_running = false;
|
is_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLETxView::reset() {
|
|
||||||
transmitter_model.disable();
|
|
||||||
baseband::shutdown();
|
|
||||||
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
|
|
||||||
// called each 1/60th of second, so 6 = 100ms
|
// called each 1/60th of second, so 6 = 100ms
|
||||||
void BLETxView::on_timer() {
|
void BLETxView::on_timer() {
|
||||||
if (++timer_count == timer_period) {
|
if (++timer_count == timer_period) {
|
||||||
timer_count = 0;
|
timer_count = 0;
|
||||||
|
|
||||||
if (is_active()) {
|
if (is_active() && packetDone) {
|
||||||
// Reached end of current packet repeats.
|
send_packet();
|
||||||
if (packet_counter == 0) {
|
|
||||||
// Done sending all packets.
|
|
||||||
if (current_packet == (num_packets - 1)) {
|
|
||||||
current_packet = 0;
|
|
||||||
|
|
||||||
// If looping, restart from beginning.
|
|
||||||
if (check_loop.value()) {
|
|
||||||
update_current_packet(packets[current_packet], current_packet);
|
|
||||||
reset();
|
|
||||||
} else {
|
|
||||||
stop();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
current_packet++;
|
|
||||||
update_current_packet(packets[current_packet], current_packet);
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (++auto_channel_counter == auto_channel_period) {
|
|
||||||
auto_channel_counter = 0;
|
|
||||||
|
|
||||||
if (auto_channel) {
|
|
||||||
int min = 37;
|
|
||||||
int max = 39;
|
|
||||||
|
|
||||||
channel_number = min + std::rand() % (max - min + 1);
|
|
||||||
|
|
||||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLETxView::on_tx_progress(const bool done) {
|
void BLETxView::on_tx_progress(const bool done, uint32_t progress) {
|
||||||
|
// TODO: make use of progress variable
|
||||||
|
(void)progress;
|
||||||
if (done) {
|
if (done) {
|
||||||
if (is_active()) {
|
if (is_active()) {
|
||||||
if ((packet_counter % 10) == 0) {
|
transmitter_model.disable();
|
||||||
text_packets_sent.set(to_string_dec_uint(packet_counter));
|
if (auto_channel) {
|
||||||
}
|
switch (advCount) {
|
||||||
|
case 0:
|
||||||
|
channel_number = 37;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
channel_number = 38;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
channel_number = 39;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
packet_counter--;
|
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||||
progressbar.set_value(packets[current_packet].packet_count - packet_counter);
|
|
||||||
|
if (advCount == 3) {
|
||||||
|
channel_number = 37;
|
||||||
|
packet_counter--;
|
||||||
|
packetDone = true;
|
||||||
|
advCount = 0;
|
||||||
|
} else {
|
||||||
|
send_packet();
|
||||||
|
advCount++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
packet_counter--;
|
||||||
|
packetDone = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reached end of current packet repeats.
|
||||||
|
if (packet_counter == 0) {
|
||||||
|
// Done sending all packets.
|
||||||
|
if (current_packet == (num_packets - 1)) {
|
||||||
|
current_packet = 0;
|
||||||
|
|
||||||
|
// If looping, restart from beginning.
|
||||||
|
if (check_loop.value()) {
|
||||||
|
update_current_packet(packets[current_packet], current_packet);
|
||||||
|
} else {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
current_packet++;
|
||||||
|
update_current_packet(packets[current_packet], current_packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -331,7 +362,6 @@ BLETxView::BLETxView(NavigationView& nav)
|
|||||||
&label_speed,
|
&label_speed,
|
||||||
&options_speed,
|
&options_speed,
|
||||||
&options_channel,
|
&options_channel,
|
||||||
&options_adv_type,
|
|
||||||
&label_marked_data,
|
&label_marked_data,
|
||||||
&marked_data_sequence,
|
&marked_data_sequence,
|
||||||
&label_packet_index,
|
&label_packet_index,
|
||||||
@@ -371,13 +401,8 @@ BLETxView::BLETxView(NavigationView& nav)
|
|||||||
timer_count = 0;
|
timer_count = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
options_adv_type.on_change = [this](size_t, int32_t i) {
|
|
||||||
pduType = (PKT_TYPE)i;
|
|
||||||
};
|
|
||||||
|
|
||||||
options_speed.set_selected_index(0);
|
options_speed.set_selected_index(0);
|
||||||
options_channel.set_selected_index(0);
|
options_channel.set_selected_index(3);
|
||||||
options_adv_type.set_selected_index(0);
|
|
||||||
|
|
||||||
check_rand_mac.set_value(false);
|
check_rand_mac.set_value(false);
|
||||||
check_rand_mac.on_select = [this](Checkbox&, bool v) {
|
check_rand_mac.on_select = [this](Checkbox&, bool v) {
|
||||||
@@ -482,17 +507,25 @@ void BLETxView::on_file_changed(const fs::path& new_file_path) {
|
|||||||
do {
|
do {
|
||||||
readUntil(data_file, packets[num_packets].macAddress, mac_address_size_str, ' ');
|
readUntil(data_file, packets[num_packets].macAddress, mac_address_size_str, ' ');
|
||||||
readUntil(data_file, packets[num_packets].advertisementData, max_packet_size_str, ' ');
|
readUntil(data_file, packets[num_packets].advertisementData, max_packet_size_str, ' ');
|
||||||
|
readUntil(data_file, packets[num_packets].packetType, max_packet_type_str, ' ');
|
||||||
readUntil(data_file, packets[num_packets].packetCount, max_packet_repeat_str, '\n');
|
readUntil(data_file, packets[num_packets].packetCount, max_packet_repeat_str, '\n');
|
||||||
|
|
||||||
uint64_t macAddressSize = strlen(packets[num_packets].macAddress);
|
uint64_t macAddressSize = strlen(packets[num_packets].macAddress);
|
||||||
uint64_t advertisementDataSize = strlen(packets[num_packets].advertisementData);
|
uint64_t advertisementDataSize = strlen(packets[num_packets].advertisementData);
|
||||||
uint64_t packetCountSize = strlen(packets[num_packets].packetCount);
|
uint64_t packetCountSize = strlen(packets[num_packets].packetCount);
|
||||||
|
uint64_t packetTypeSize = strlen(packets[num_packets].packetType);
|
||||||
|
|
||||||
packets[num_packets].packet_count = stringToUint32(packets[num_packets].packetCount);
|
packets[num_packets].packet_count = stringToUint32(packets[num_packets].packetCount);
|
||||||
|
packets[num_packets].pduType = (PKT_TYPE)get_pkt_type_from_string(packets[num_packets].packetType);
|
||||||
|
|
||||||
// Verify Data.
|
// Verify Data.
|
||||||
if ((macAddressSize == mac_address_size_str) && (advertisementDataSize < max_packet_size_str) && (packetCountSize < max_packet_repeat_str) &&
|
if ((macAddressSize == mac_address_size_str) &&
|
||||||
hasValidHexPairs(packets[num_packets].macAddress, macAddressSize / 2) && hasValidHexPairs(packets[num_packets].advertisementData, advertisementDataSize / 2) && (packets[num_packets].packet_count >= 1) && (packets[num_packets].packet_count < max_packet_repeat_count)) {
|
(advertisementDataSize < max_packet_size_str) &&
|
||||||
|
(packetCountSize < max_packet_repeat_str) &&
|
||||||
|
hasValidHexPairs(packets[num_packets].macAddress, macAddressSize / 2) &&
|
||||||
|
hasValidHexPairs(packets[num_packets].advertisementData, advertisementDataSize / 2) &&
|
||||||
|
(packets[num_packets].packet_count >= 1) && (packets[num_packets].packet_count < max_packet_repeat_count) &&
|
||||||
|
(packetTypeSize <= max_packet_type_str)) {
|
||||||
text_filename.set(truncate(file_path.filename().string(), 12));
|
text_filename.set(truncate(file_path.filename().string(), 12));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -510,6 +543,8 @@ void BLETxView::on_file_changed(const fs::path& new_file_path) {
|
|||||||
} while (num_packets < max_num_packets);
|
} while (num_packets < max_num_packets);
|
||||||
|
|
||||||
update_current_packet(packets[0], 0);
|
update_current_packet(packets[0], 0);
|
||||||
|
|
||||||
|
data_file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,6 +575,8 @@ void BLETxView::update_current_packet(BLETxPacket packet, uint32_t currentIndex)
|
|||||||
|
|
||||||
text_mac_address.set(formattedMacAddress);
|
text_mac_address.set(formattedMacAddress);
|
||||||
|
|
||||||
|
progressbar.set_max(packet.packet_count);
|
||||||
|
|
||||||
packet_counter = packet.packet_count;
|
packet_counter = packet.packet_count;
|
||||||
current_packet = currentIndex;
|
current_packet = currentIndex;
|
||||||
|
|
||||||
@@ -550,7 +587,7 @@ void BLETxView::update_current_packet(BLETxPacket packet, uint32_t currentIndex)
|
|||||||
dataFile.write("\n", 1);
|
dataFile.write("\n", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataFile.~File();
|
dataFile.close();
|
||||||
|
|
||||||
auto result = FileWrapper::open(dataTempFilePath);
|
auto result = FileWrapper::open(dataTempFilePath);
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,8 @@
|
|||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
#include "file_path.hpp"
|
#include "file_path.hpp"
|
||||||
|
|
||||||
|
#include "ble_tx_app.hpp"
|
||||||
|
|
||||||
#include "recent_entries.hpp"
|
#include "recent_entries.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -91,8 +93,9 @@ struct BLETxPacket {
|
|||||||
char macAddress[13];
|
char macAddress[13];
|
||||||
char advertisementData[63];
|
char advertisementData[63];
|
||||||
char packetCount[11];
|
char packetCount[11];
|
||||||
|
char packetType[17];
|
||||||
uint32_t packet_count;
|
uint32_t packet_count;
|
||||||
PKT_TYPE packetType;
|
PKT_TYPE pduType;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BLETxView : public View {
|
class BLETxView : public View {
|
||||||
@@ -109,8 +112,8 @@ class BLETxView : public View {
|
|||||||
bool is_active() const;
|
bool is_active() const;
|
||||||
void toggle();
|
void toggle();
|
||||||
void start();
|
void start();
|
||||||
|
void send_packet();
|
||||||
void stop();
|
void stop();
|
||||||
void reset();
|
|
||||||
void handle_replay_thread_done(const uint32_t return_code);
|
void handle_replay_thread_done(const uint32_t return_code);
|
||||||
void file_error();
|
void file_error();
|
||||||
bool saveFile(const std::filesystem::path& path);
|
bool saveFile(const std::filesystem::path& path);
|
||||||
@@ -122,7 +125,7 @@ class BLETxView : public View {
|
|||||||
void on_data(uint32_t value, bool is_data);
|
void on_data(uint32_t value, bool is_data);
|
||||||
void on_file_changed(const std::filesystem::path& new_file_path);
|
void on_file_changed(const std::filesystem::path& new_file_path);
|
||||||
void on_save_file(const std::string value);
|
void on_save_file(const std::string value);
|
||||||
void on_tx_progress(const bool done);
|
void on_tx_progress(const bool done, uint32_t progress);
|
||||||
void on_random_data_change(std::string value);
|
void on_random_data_change(std::string value);
|
||||||
void update_current_packet(BLETxPacket packet, uint32_t currentIndex);
|
void update_current_packet(BLETxPacket packet, uint32_t currentIndex);
|
||||||
|
|
||||||
@@ -156,6 +159,8 @@ class BLETxView : public View {
|
|||||||
uint32_t packet_counter{0};
|
uint32_t packet_counter{0};
|
||||||
uint32_t num_packets{0};
|
uint32_t num_packets{0};
|
||||||
uint32_t current_packet{0};
|
uint32_t current_packet{0};
|
||||||
|
uint8_t packetTxCount{0};
|
||||||
|
bool packetDone = false;
|
||||||
bool random_mac = false;
|
bool random_mac = false;
|
||||||
bool file_override = false;
|
bool file_override = false;
|
||||||
|
|
||||||
@@ -170,39 +175,39 @@ class BLETxView : public View {
|
|||||||
std::vector<uint16_t> markedBytes{};
|
std::vector<uint16_t> markedBytes{};
|
||||||
CursorPos cursor_pos{};
|
CursorPos cursor_pos{};
|
||||||
uint8_t marked_counter = 0;
|
uint8_t marked_counter = 0;
|
||||||
|
uint8_t advCount = 0;
|
||||||
|
|
||||||
static constexpr uint8_t mac_address_size_str{12};
|
static constexpr uint8_t mac_address_size_str{12};
|
||||||
static constexpr uint8_t max_packet_size_str{62};
|
static constexpr uint8_t max_packet_size_str{62};
|
||||||
static constexpr uint8_t max_packet_repeat_str{10};
|
static constexpr uint8_t max_packet_repeat_str{10};
|
||||||
|
static constexpr uint8_t max_packet_type_str{16};
|
||||||
static constexpr uint32_t max_packet_repeat_count{UINT32_MAX};
|
static constexpr uint32_t max_packet_repeat_count{UINT32_MAX};
|
||||||
static constexpr uint32_t max_num_packets{32};
|
static constexpr uint32_t max_num_packets{32};
|
||||||
|
|
||||||
BLETxPacket packets[max_num_packets];
|
BLETxPacket packets[max_num_packets];
|
||||||
|
|
||||||
PKT_TYPE pduType = {PKT_TYPE_DISCOVERY};
|
|
||||||
|
|
||||||
static constexpr auto header_height = 10 * 16;
|
static constexpr auto header_height = 10 * 16;
|
||||||
static constexpr auto switch_button_height = 6 * 16;
|
static constexpr auto switch_button_height = 6 * 16;
|
||||||
|
|
||||||
Button button_open{
|
Button button_open{
|
||||||
{0 * 8, 0 * 16, 10 * 8, 2 * 16},
|
{UI_POS_X(0), UI_POS_Y(0), 10 * 8, 2 * 16},
|
||||||
"Open file"};
|
"Open file"};
|
||||||
|
|
||||||
Text text_filename{
|
Text text_filename{
|
||||||
{11 * 8, 0 * 16, 12 * 8, 16},
|
{11 * 8, UI_POS_Y(0), UI_POS_WIDTH_REMAINING(11), 16},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
ProgressBar progressbar{
|
ProgressBar progressbar{
|
||||||
{11 * 8, 1 * 16, 9 * 8, 16}};
|
{11 * 8, 1 * 16, UI_POS_WIDTH_REMAINING(11 + 10), 16}};
|
||||||
|
|
||||||
Checkbox check_rand_mac{
|
Checkbox check_rand_mac{
|
||||||
{21 * 8, 1 * 16},
|
{UI_POS_X_RIGHT(9), 1 * 16},
|
||||||
6,
|
6,
|
||||||
"?? Mac",
|
"?? Mac",
|
||||||
true};
|
true};
|
||||||
|
|
||||||
TxFrequencyField field_frequency{
|
TxFrequencyField field_frequency{
|
||||||
{0 * 8, 2 * 16},
|
{UI_POS_X(0), 2 * 16},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
TransmitterView2 tx_view{
|
TransmitterView2 tx_view{
|
||||||
@@ -210,28 +215,28 @@ class BLETxView : public View {
|
|||||||
/*short_ui*/ true};
|
/*short_ui*/ true};
|
||||||
|
|
||||||
Checkbox check_loop{
|
Checkbox check_loop{
|
||||||
{21 * 8, 2 * 16},
|
{UI_POS_X_RIGHT(9), 2 * 16},
|
||||||
4,
|
4,
|
||||||
"Loop",
|
"Loop",
|
||||||
true};
|
true};
|
||||||
|
|
||||||
ImageButton button_play{
|
ImageButton button_play{
|
||||||
{screen_width - 2 * 8, 2 * 16, 2 * 8, 1 * 16},
|
{UI_POS_X_RIGHT(2), 2 * 16, 2 * 8, 1 * 16},
|
||||||
&bitmap_play,
|
&bitmap_play,
|
||||||
Theme::getInstance()->fg_green->foreground,
|
Theme::getInstance()->fg_green->foreground,
|
||||||
Theme::getInstance()->fg_green->background};
|
Theme::getInstance()->fg_green->background};
|
||||||
|
|
||||||
Labels label_speed{
|
Labels label_speed{
|
||||||
{{0 * 8, 6 * 8}, "Speed:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 6 * 8}, "Speed:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
OptionsField options_speed{
|
OptionsField options_speed{
|
||||||
{7 * 8, 6 * 8},
|
{7 * 8, 6 * 8},
|
||||||
3,
|
3,
|
||||||
{{"1 ", 1}, // 16ms
|
{{"1 ", 2}, // 25ms
|
||||||
{"2 ", 2}, // 32ms
|
{"2 ", 4}, // 50ms
|
||||||
{"3 ", 3}, // 48ms
|
{"3 ", 6}, // 75ms
|
||||||
{"4 ", 6}, // 100ms
|
{"4 ", 8}, // 100ms
|
||||||
{"5 ", 12}}}; // 200ms
|
{"5 ", 12}}}; // 150ms
|
||||||
|
|
||||||
OptionsField options_channel{
|
OptionsField options_channel{
|
||||||
{11 * 8, 6 * 8},
|
{11 * 8, 6 * 8},
|
||||||
@@ -254,7 +259,7 @@ class BLETxView : public View {
|
|||||||
{"CONNECT_REQ", PKT_TYPE_CONNECT_REQ}}};
|
{"CONNECT_REQ", PKT_TYPE_CONNECT_REQ}}};
|
||||||
|
|
||||||
Labels label_marked_data{
|
Labels label_marked_data{
|
||||||
{{0 * 8, 4 * 16}, "Marked Data:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 4 * 16}, "Marked Data:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
OptionsField marked_data_sequence{
|
OptionsField marked_data_sequence{
|
||||||
{12 * 8, 8 * 8},
|
{12 * 8, 8 * 8},
|
||||||
@@ -264,42 +269,42 @@ class BLETxView : public View {
|
|||||||
{"Random", 2}}};
|
{"Random", 2}}};
|
||||||
|
|
||||||
Labels label_packet_index{
|
Labels label_packet_index{
|
||||||
{{0 * 8, 12 * 8}, "Packet Index:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 12 * 8}, "Packet Index:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Text text_packet_index{
|
Text text_packet_index{
|
||||||
{13 * 8, 6 * 16, 12 * 8, 16},
|
{13 * 8, 6 * 16, 12 * 8, 16},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Labels label_packets_sent{
|
Labels label_packets_sent{
|
||||||
{{0 * 8, 14 * 8}, "Repeat Count:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 14 * 8}, "Repeat Count:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Text text_packets_sent{
|
Text text_packets_sent{
|
||||||
{13 * 8, 7 * 16, 12 * 8, 16},
|
{13 * 8, 7 * 16, 12 * 8, 16},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Labels label_mac_address{
|
Labels label_mac_address{
|
||||||
{{0 * 8, 16 * 8}, "Mac Address:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 16 * 8}, "Mac Address:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Text text_mac_address{
|
Text text_mac_address{
|
||||||
{12 * 8, 8 * 16, 20 * 8, 16},
|
{12 * 8, 8 * 16, 20 * 8, 16},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Labels label_data_packet{
|
Labels label_data_packet{
|
||||||
{{0 * 8, 9 * 16}, "Packet Data:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 9 * 16}, "Packet Data:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
TextViewer dataEditView{
|
TextViewer dataEditView{
|
||||||
{0, 9 * 18, screen_width, screen_height - 80}};
|
{0, 9 * 18, 240, 240}};
|
||||||
|
|
||||||
Button button_clear_marked{
|
Button button_clear_marked{
|
||||||
{1 * 8, 14 * 16, 13 * 8, 3 * 8},
|
{UI_POS_X(1), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(13), UI_POS_HEIGHT(1.5)},
|
||||||
"Clear Marked"};
|
"Clear Marked"};
|
||||||
|
|
||||||
Button button_save_packet{
|
Button button_save_packet{
|
||||||
{1 * 8, 16 * 16, 13 * 8, 2 * 16},
|
{UI_POS_X(1), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(13), UI_POS_HEIGHT(2)},
|
||||||
"Save Packet"};
|
"Save Packet"};
|
||||||
|
|
||||||
Button button_switch{
|
Button button_switch{
|
||||||
{16 * 8, 16 * 16, 13 * 8, 2 * 16},
|
{UI_POS_X_RIGHT(14), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(13), UI_POS_HEIGHT(2)},
|
||||||
"Switch to Rx"};
|
"Switch to Rx"};
|
||||||
|
|
||||||
std::string str_log{""};
|
std::string str_log{""};
|
||||||
@@ -320,7 +325,7 @@ class BLETxView : public View {
|
|||||||
Message::ID::TXProgress,
|
Message::ID::TXProgress,
|
||||||
[this](const Message* const p) {
|
[this](const Message* const p) {
|
||||||
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
|
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
|
||||||
this->on_tx_progress(message.done);
|
this->on_tx_progress(message.done, message.progress);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_frame_sync{
|
MessageHandlerRegistration message_handler_frame_sync{
|
||||||
|
|||||||
@@ -65,31 +65,31 @@ class CaptureAppView : public View {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 1 * 16}, "Rate:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 1 * 16}, "Rate:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{11 * 8, 1 * 16}, "Format:", Theme::getInstance()->fg_light->foreground},
|
{{11 * 8, 1 * 16}, "Format:", Theme::getInstance()->fg_light->foreground},
|
||||||
};
|
};
|
||||||
|
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{24 * 8, 0, 6 * 8, 4}};
|
{UI_POS_X(24), 0, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||||
|
|
||||||
Channel channel{
|
Channel channel{
|
||||||
{24 * 8, 5, 6 * 8, 4}};
|
{UI_POS_X(24), 5, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 16},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
FrequencyStepView field_frequency_step{
|
FrequencyStepView field_frequency_step{
|
||||||
{10 * 8, 0 * 16}};
|
{10 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{16 * 8, 0 * 16}};
|
{16 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{18 * 8, 0 * 16}};
|
{18 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{21 * 8, 0 * 16}};
|
{21 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
OptionsField option_bandwidth{
|
OptionsField option_bandwidth{
|
||||||
{5 * 8, 1 * 16},
|
{5 * 8, 1 * 16},
|
||||||
@@ -109,7 +109,7 @@ class CaptureAppView : public View {
|
|||||||
/*small*/ true};
|
/*small*/ true};
|
||||||
|
|
||||||
RecordView record_view{
|
RecordView record_view{
|
||||||
{0 * 8, 2 * 16, screen_width, 1 * 16},
|
{UI_POS_X(0), 2 * 16, screen_width, 1 * 16},
|
||||||
u"BBD_????.*",
|
u"BBD_????.*",
|
||||||
captures_dir,
|
captures_dir,
|
||||||
RecordView::FileType::RawS16,
|
RecordView::FileType::RawS16,
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ class POCSAGSettingsView : public View {
|
|||||||
true /*explicit_edit*/};
|
true /*explicit_edit*/};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{11 * 8, 16 * 16, 10 * 8, 2 * 16},
|
{UI_POS_X_CENTER(10), UI_POS_Y(16), 10 * 8, 2 * 16},
|
||||||
"Save"};
|
"Save"};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -236,30 +236,30 @@ class POCSAGAppView : public View {
|
|||||||
uint16_t packet_count = 0;
|
uint16_t packet_count = 0;
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 8},
|
{UI_POS_X(0), 0 * 8},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{11 * 8, 0 * 16}};
|
{11 * 8, UI_POS_Y(0)}};
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{13 * 8, 0 * 16}};
|
{13 * 8, UI_POS_Y(0)}};
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{16 * 8, 0 * 16}};
|
{16 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{19 * 8 - 4, 3, 6 * 8, 4}};
|
{19 * 8 - 4, 3, UI_POS_WIDTH_REMAINING(26), 4}};
|
||||||
Audio audio{
|
Audio audio{
|
||||||
{19 * 8 - 4, 8, 6 * 8, 4}};
|
{19 * 8 - 4, 8, UI_POS_WIDTH_REMAINING(26), 4}};
|
||||||
|
|
||||||
NumberField field_squelch{
|
NumberField field_squelch{
|
||||||
{25 * 8, 0 * 16},
|
{UI_POS_X_RIGHT(6), UI_POS_Y(0)},
|
||||||
2,
|
2,
|
||||||
{0, 99},
|
{0, 99},
|
||||||
1,
|
1,
|
||||||
' ',
|
' ',
|
||||||
true /*wrap*/};
|
true /*wrap*/};
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{screen_width - 2 * 8, 0 * 16}};
|
{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
|
||||||
|
|
||||||
Image image_status{
|
Image image_status{
|
||||||
{0 * 8 + 4, 1 * 16 + 2, 16, 16},
|
{0 * 8 + 4, 1 * 16 + 2, 16, 16},
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ void RecentEntriesTable<AircraftRecentEntries>::draw(
|
|||||||
const Entry& entry,
|
const Entry& entry,
|
||||||
const Rect& target_rect,
|
const Rect& target_rect,
|
||||||
Painter& painter,
|
Painter& painter,
|
||||||
const Style& style) {
|
const Style& style,
|
||||||
|
RecentEntriesColumns& columns) {
|
||||||
Color target_color;
|
Color target_color;
|
||||||
std::string entry_string;
|
std::string entry_string;
|
||||||
|
|
||||||
@@ -70,9 +71,11 @@ void RecentEntriesTable<AircraftRecentEntries>::draw(
|
|||||||
target_color = Theme::getInstance()->fg_medium->foreground;
|
target_color = Theme::getInstance()->fg_medium->foreground;
|
||||||
};
|
};
|
||||||
|
|
||||||
entry_string +=
|
std::string ipc = (entry.callsign.empty() ? entry.icao_str + " " : entry.callsign + " ");
|
||||||
(entry.callsign.empty() ? entry.icao_str + " " : entry.callsign + " ") +
|
uint8_t firstcolwidth = columns.at(0).second;
|
||||||
to_string_dec_uint((unsigned int)(entry.pos.altitude / 100), 4);
|
ipc.resize(firstcolwidth, ' '); // Make sure this is always match the first column's width that is dynamic.
|
||||||
|
|
||||||
|
entry_string += ipc + to_string_dec_uint((unsigned int)(entry.pos.altitude / 100), 4);
|
||||||
|
|
||||||
if (entry.velo.type == SPD_IAS && entry.pos.alt_valid) { // IAS can be converted to TAS
|
if (entry.velo.type == SPD_IAS && entry.pos.alt_valid) { // IAS can be converted to TAS
|
||||||
// It is generally accepted that for every thousand feet of altitude,
|
// It is generally accepted that for every thousand feet of altitude,
|
||||||
@@ -100,7 +103,7 @@ void RecentEntriesTable<AircraftRecentEntries>::draw(
|
|||||||
entry_string);
|
entry_string);
|
||||||
|
|
||||||
if (entry.pos.pos_valid)
|
if (entry.pos.pos_valid)
|
||||||
painter.draw_bitmap(target_rect.location() + Point(8 * 8, 0),
|
painter.draw_bitmap(target_rect.location() + Point(firstcolwidth * 8 - 8, 0),
|
||||||
bitmap_target, target_color, style.background);
|
bitmap_target, target_color, style.background);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,7 +412,7 @@ ADSBRxView::ADSBRxView(NavigationView& nav) {
|
|||||||
&status_good_frame,
|
&status_good_frame,
|
||||||
&field_volume});
|
&field_volume});
|
||||||
|
|
||||||
recent_entries_view.set_parent_rect({0, 16, screen_width, 272});
|
recent_entries_view.set_parent_rect({0, 16, screen_width, UI_POS_HEIGHT_REMAINING(2)});
|
||||||
recent_entries_view.on_select = [this, &nav](const AircraftRecentEntry& entry) {
|
recent_entries_view.on_select = [this, &nav](const AircraftRecentEntry& entry) {
|
||||||
detail_key = entry.key();
|
detail_key = entry.key();
|
||||||
details_view = nav.push<ADSBRxDetailsView>(entry);
|
details_view = nav.push<ADSBRxDetailsView>(entry);
|
||||||
@@ -635,14 +638,14 @@ void ADSBRxView::refresh_ui() {
|
|||||||
|
|
||||||
if (details_view->map_active()) {
|
if (details_view->map_active()) {
|
||||||
// Is it time to clear and refresh the map's markers?
|
// Is it time to clear and refresh the map's markers?
|
||||||
if (ticks_since_marker_refresh >= MARKER_UPDATE_SECONDS) {
|
if (ticks_since_marker_refresh >= (details_view->get_map_type() == MAP_TYPE_OSM ? MARKER_UPDATE_SECONDS_OSM : MARKER_UPDATE_SECONDS_BIN)) {
|
||||||
map_needs_update = true;
|
map_needs_update = true;
|
||||||
ticks_since_marker_refresh = 0;
|
ticks_since_marker_refresh = 0;
|
||||||
details_view->clear_map_markers();
|
details_view->clear_map_markers();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Refresh map immediately once active.
|
// Refresh map immediately once active.
|
||||||
ticks_since_marker_refresh = MARKER_UPDATE_SECONDS;
|
ticks_since_marker_refresh = MARKER_UPDATE_SECONDS_OSM; // this is the bigger, so set it to force
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the entries list.
|
// Process the entries list.
|
||||||
|
|||||||
@@ -64,8 +64,9 @@ namespace ui {
|
|||||||
#define VEL_AIR_SUBSONIC 3
|
#define VEL_AIR_SUBSONIC 3
|
||||||
#define VEL_AIR_SUPERSONIC 4
|
#define VEL_AIR_SUPERSONIC 4
|
||||||
|
|
||||||
#define O_E_FRAME_TIMEOUT 20 // timeout between odd and even frames
|
#define O_E_FRAME_TIMEOUT 20 // timeout between odd and even frames
|
||||||
#define MARKER_UPDATE_SECONDS 5 // "other" map marker redraw interval
|
#define MARKER_UPDATE_SECONDS_OSM 10 // "other" map marker redraw interval for osm
|
||||||
|
#define MARKER_UPDATE_SECONDS_BIN 5 // "other" map marker redraw interval for bin map
|
||||||
|
|
||||||
/* Thresholds (in seconds) that define the transition between ages. */
|
/* Thresholds (in seconds) that define the transition between ages. */
|
||||||
struct ADSBAgeLimit {
|
struct ADSBAgeLimit {
|
||||||
@@ -207,54 +208,54 @@ class ADSBRxAircraftDetailsView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 1 * 16}, "ICAO:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 1 * 16}, "ICAO:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 2 * 16}, "Registration:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 2 * 16}, "Registration:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 3 * 16}, "Manufacturer:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 3 * 16}, "Manufacturer:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 5 * 16}, "Model:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 5 * 16}, "Model:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 7 * 16}, "Type:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 7 * 16}, "Type:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 8 * 16}, "Number of engines:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 8 * 16}, "Number of engines:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 9 * 16}, "Engine type:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 9 * 16}, "Engine type:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 11 * 16}, "Owner:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 11 * 16}, "Owner:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 13 * 16}, "Operator:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 13 * 16}, "Operator:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Text text_icao_address{
|
Text text_icao_address{
|
||||||
{5 * 8, 1 * 16, 6 * 8, 16},
|
{5 * 8, 1 * 16, 6 * 8, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_registration{
|
Text text_registration{
|
||||||
{13 * 8, 2 * 16, 8 * 8, 16},
|
{13 * 8, 2 * 16, 8 * 8, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_manufacturer{
|
Text text_manufacturer{
|
||||||
{0 * 8, 4 * 16, 19 * 8, 16},
|
{UI_POS_X(0), 4 * 16, 19 * 8, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_model{
|
Text text_model{
|
||||||
{0 * 8, 6 * 16, screen_width, 16},
|
{UI_POS_X(0), 6 * 16, screen_width, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_type{
|
Text text_type{
|
||||||
{5 * 8, 7 * 16, 22 * 8, 16},
|
{5 * 8, 7 * 16, 22 * 8, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_number_of_engines{
|
Text text_number_of_engines{
|
||||||
{18 * 8, 8 * 16, screen_width, 16},
|
{18 * 8, 8 * 16, screen_width, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_engine_type{
|
Text text_engine_type{
|
||||||
{0 * 8, 10 * 16, screen_width, 16},
|
{UI_POS_X(0), 10 * 16, screen_width, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_owner{
|
Text text_owner{
|
||||||
{0 * 8, 12 * 16, screen_width, 16},
|
{UI_POS_X(0), 12 * 16, screen_width, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_operator{
|
Text text_operator{
|
||||||
{0 * 8, 14 * 16, screen_width, 16},
|
{UI_POS_X(0), 14 * 16, screen_width, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Button button_close{
|
Button button_close{
|
||||||
{9 * 8, 16 * 16, 12 * 8, 3 * 16},
|
{UI_POS_X_CENTER(12), UI_POS_Y(16), UI_POS_WIDTH(12), UI_POS_HEIGHT(3)},
|
||||||
"Back"};
|
"Back"};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -277,6 +278,13 @@ class ADSBRxDetailsView : public View {
|
|||||||
|
|
||||||
std::string title() const override { return "Details"; }
|
std::string title() const override { return "Details"; }
|
||||||
|
|
||||||
|
MapType get_map_type() {
|
||||||
|
if (geomap_view_)
|
||||||
|
return geomap_view_->get_map_type();
|
||||||
|
else
|
||||||
|
return MapType::MAP_TYPE_BIN; // default
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void refresh_ui();
|
void refresh_ui();
|
||||||
void on_gps(const GPSPosDataMessage* msg);
|
void on_gps(const GPSPosDataMessage* msg);
|
||||||
@@ -291,55 +299,55 @@ class ADSBRxDetailsView : public View {
|
|||||||
bool airline_checked{false};
|
bool airline_checked{false};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 1 * 16}, "ICAO:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 1 * 16}, "ICAO:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{13 * 8, 1 * 16}, "Callsign:", Theme::getInstance()->fg_light->foreground},
|
{{13 * 8, 1 * 16}, "Callsign:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 2 * 16}, "Last seen:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 2 * 16}, "Last seen:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 3 * 16}, "Airline:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 3 * 16}, "Airline:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 5 * 16}, "Country:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 5 * 16}, "Country:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 13 * 16}, "Even position frame:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 13 * 16}, "Even position frame:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 15 * 16}, "Odd position frame:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 15 * 16}, "Odd position frame:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Text text_icao_address{
|
Text text_icao_address{
|
||||||
{5 * 8, 1 * 16, 6 * 8, 16},
|
{5 * 8, 1 * 16, 6 * 8, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_callsign{
|
Text text_callsign{
|
||||||
{22 * 8, 1 * 16, 8 * 8, 16},
|
{22 * 8, 1 * 16, 8 * 8, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_last_seen{
|
Text text_last_seen{
|
||||||
{11 * 8, 2 * 16, 19 * 8, 16},
|
{11 * 8, 2 * 16, 19 * 8, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_airline{
|
Text text_airline{
|
||||||
{0 * 8, 4 * 16, screen_width, 16},
|
{UI_POS_X(0), 4 * 16, screen_width, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_country{
|
Text text_country{
|
||||||
{8 * 8, 5 * 16, 22 * 8, 16},
|
{8 * 8, 5 * 16, 22 * 8, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_infos{
|
Text text_infos{
|
||||||
{0 * 8, 6 * 16, screen_width, 16},
|
{UI_POS_X(0), 6 * 16, screen_width, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_info2{
|
Text text_info2{
|
||||||
{0 * 8, 7 * 16, screen_width, 16},
|
{UI_POS_X(0), 7 * 16, screen_width, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Text text_frame_pos_even{
|
Text text_frame_pos_even{
|
||||||
{0 * 8, 14 * 16, screen_width, 16},
|
{UI_POS_X(0), 14 * 16, screen_width, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
Text text_frame_pos_odd{
|
Text text_frame_pos_odd{
|
||||||
{0 * 8, 16 * 16, screen_width, 16},
|
{UI_POS_X(0), 16 * 16, screen_width, UI_POS_HEIGHT(1)},
|
||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Button button_aircraft_details{
|
Button button_aircraft_details{
|
||||||
{2 * 8, 9 * 16, 12 * 8, 3 * 16},
|
{UI_POS_X_CENTER(12) - UI_POS_X(8), UI_POS_Y(9), UI_POS_WIDTH(12), UI_POS_HEIGHT(3)},
|
||||||
"A/C details"};
|
"A/C details"};
|
||||||
|
|
||||||
Button button_see_map{
|
Button button_see_map{
|
||||||
{16 * 8, 9 * 16, 12 * 8, 3 * 16},
|
{UI_POS_X_CENTER(12) + UI_POS_X(8), UI_POS_Y(9), UI_POS_WIDTH(12), UI_POS_HEIGHT(3)},
|
||||||
"See on map"};
|
"See on map"};
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_gps{
|
MessageHandlerRegistration message_handler_gps{
|
||||||
@@ -388,15 +396,15 @@ class ADSBRxView : public View {
|
|||||||
|
|
||||||
SignalToken signal_token_tick_second{};
|
SignalToken signal_token_tick_second{};
|
||||||
uint8_t tick_count = 0;
|
uint8_t tick_count = 0;
|
||||||
uint16_t ticks_since_marker_refresh{MARKER_UPDATE_SECONDS};
|
uint16_t ticks_since_marker_refresh{MARKER_UPDATE_SECONDS_OSM};
|
||||||
|
|
||||||
/* Max number of entries that can be updated in a single pass.
|
/* Max number of entries that can be updated in a single pass.
|
||||||
* 16 is one screen of recent entries. */
|
* 16 is one screen of recent entries. */
|
||||||
static constexpr uint8_t max_update_entries = 16;
|
static constexpr uint8_t max_update_entries = 16;
|
||||||
|
|
||||||
/* Recent Entries */
|
/* Recent Entries */
|
||||||
const RecentEntriesColumns columns{
|
RecentEntriesColumns columns{
|
||||||
{{"ICAO/Call", 9},
|
{{"ICAO/Call", 0},
|
||||||
{"Lvl", 3},
|
{"Lvl", 3},
|
||||||
{"Spd", 3},
|
{"Spd", 3},
|
||||||
{"Amp", 3},
|
{"Amp", 3},
|
||||||
@@ -416,33 +424,33 @@ class ADSBRxView : public View {
|
|||||||
ADSBRxDetailsView* details_view{nullptr};
|
ADSBRxDetailsView* details_view{nullptr};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 0 * 8}, "LNA: VGA: AMP:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), UI_POS_Y(0)}, "LNA: VGA: AMP:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{4 * 8, 0 * 16}};
|
{UI_POS_X(4), UI_POS_Y(0)}};
|
||||||
|
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{11 * 8, 0 * 16}};
|
{UI_POS_X(11), UI_POS_Y(0)}};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{18 * 8, 0 * 16}};
|
{UI_POS_X(18), UI_POS_Y(0)}};
|
||||||
|
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{20 * 8, 4, 7 * 8, 8},
|
{UI_POS_X(20), 4, UI_POS_WIDTH_REMAINING(23), 8},
|
||||||
};
|
};
|
||||||
|
|
||||||
ActivityDot status_frame{
|
ActivityDot status_frame{
|
||||||
{27 * 8 + 2, 5, 2, 2},
|
{UI_POS_X_RIGHT(3) + 2, 5, 2, 2},
|
||||||
Theme::getInstance()->bg_darkest->foreground,
|
Theme::getInstance()->bg_darkest->foreground,
|
||||||
};
|
};
|
||||||
|
|
||||||
ActivityDot status_good_frame{
|
ActivityDot status_good_frame{
|
||||||
{27 * 8 + 2, 9, 2, 2},
|
{UI_POS_X_RIGHT(3) + 2, 9, 2, 2},
|
||||||
Theme::getInstance()->fg_green->foreground,
|
Theme::getInstance()->fg_green->foreground,
|
||||||
};
|
};
|
||||||
|
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{screen_width - 2 * 8, 0 * 16}};
|
{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_frame{
|
MessageHandlerRegistration message_handler_frame{
|
||||||
Message::ID::ADSBFrame,
|
Message::ID::ADSBFrame,
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ void RecentEntriesTable<APRSRecentEntries>::draw(
|
|||||||
const Entry& entry,
|
const Entry& entry,
|
||||||
const Rect& target_rect,
|
const Rect& target_rect,
|
||||||
Painter& painter,
|
Painter& painter,
|
||||||
const Style& style) {
|
const Style& style,
|
||||||
|
RecentEntriesColumns& columns) {
|
||||||
Color target_color;
|
Color target_color;
|
||||||
// auto entry_age = entry.age;
|
// auto entry_age = entry.age;
|
||||||
|
|
||||||
@@ -51,8 +52,8 @@ void RecentEntriesTable<APRSRecentEntries>::draw(
|
|||||||
std::string entry_string = "";
|
std::string entry_string = "";
|
||||||
|
|
||||||
entry_string += entry.source_formatted;
|
entry_string += entry.source_formatted;
|
||||||
entry_string.append(10 - entry.source_formatted.size(), ' ');
|
entry_string.resize(columns.at(0).second, ' ');
|
||||||
entry_string += " ";
|
entry_string += " ";
|
||||||
entry_string += (entry.hits <= 999 ? to_string_dec_uint(entry.hits, 4) : "999+");
|
entry_string += (entry.hits <= 999 ? to_string_dec_uint(entry.hits, 4) : "999+");
|
||||||
entry_string += " ";
|
entry_string += " ";
|
||||||
entry_string += entry.time_string;
|
entry_string += entry.time_string;
|
||||||
@@ -247,8 +248,8 @@ APRSTableView::APRSTableView(NavigationView& nav, Rect parent_rec)
|
|||||||
|
|
||||||
details_view.hidden(true);
|
details_view.hidden(true);
|
||||||
|
|
||||||
recent_entries_view.set_parent_rect({0, 0, screen_width, screen_width - 40});
|
recent_entries_view.set_parent_rect({0, 0, screen_width, screen_height - 40});
|
||||||
details_view.set_parent_rect({0, 0, screen_width, screen_width - 40});
|
details_view.set_parent_rect({0, 0, screen_width, screen_height - 40});
|
||||||
|
|
||||||
recent_entries_view.on_select = [this](const APRSRecentEntry& entry) {
|
recent_entries_view.on_select = [this](const APRSRecentEntry& entry) {
|
||||||
this->on_show_detail(entry);
|
this->on_show_detail(entry);
|
||||||
|
|||||||
@@ -134,14 +134,14 @@ class APRSDetailsView : public View {
|
|||||||
bool send_updates{false};
|
bool send_updates{false};
|
||||||
|
|
||||||
Console console{
|
Console console{
|
||||||
{0, 0 * 16, screen_width, 224}};
|
{UI_POS_X(0), UI_POS_Y(0), screen_width, screen_height - 80}};
|
||||||
|
|
||||||
Button button_done{
|
Button button_done{
|
||||||
{160, 14 * 16, 8 * 8, 3 * 16},
|
{UI_POS_X_CENTER(4) - UI_POS_WIDTH(8), UI_POS_Y(14), UI_POS_WIDTH(8), UI_POS_HEIGHT(3)},
|
||||||
"Close"};
|
"Close"};
|
||||||
|
|
||||||
Button button_see_map{
|
Button button_see_map{
|
||||||
{80, 14 * 16, 8 * 8, 3 * 16},
|
{UI_POS_X_CENTER(4) + UI_POS_WIDTH(8), UI_POS_Y(14), UI_POS_WIDTH(8), UI_POS_HEIGHT(3)},
|
||||||
"Map"};
|
"Map"};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -161,10 +161,10 @@ class APRSTableView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
const RecentEntriesColumns columns{{{"Source", 9},
|
RecentEntriesColumns columns{{{"Source", 0},
|
||||||
{"Loc", 6},
|
{"Loc", 6},
|
||||||
{"Hits", 4},
|
{"Hits", 4},
|
||||||
{"Time", 8}}};
|
{"Time", 8}}};
|
||||||
APRSRecentEntries recent{};
|
APRSRecentEntries recent{};
|
||||||
RecentEntriesView<RecentEntries<APRSRecentEntry>> recent_entries_view{columns, recent};
|
RecentEntriesView<RecentEntries<APRSRecentEntry>> recent_entries_view{columns, recent};
|
||||||
APRSDetailsView details_view{nav_};
|
APRSDetailsView details_view{nav_};
|
||||||
@@ -209,21 +209,21 @@ class APRSRxView : public View {
|
|||||||
std::string str_log{""};
|
std::string str_log{""};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{13 * 8, 0 * 16}};
|
{UI_POS_X(13), UI_POS_Y(0)}};
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{UI_POS_X(15), UI_POS_Y(0)}};
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{UI_POS_X(18), UI_POS_Y(0)}};
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4}};
|
{UI_POS_X(21), 0, UI_POS_WIDTH_REMAINING(21) - UI_POS_WIDTH(2), 4}};
|
||||||
Channel channel{
|
Channel channel{
|
||||||
{21 * 8, 5, 6 * 8, 4}};
|
{UI_POS_X(21), 5, UI_POS_WIDTH_REMAINING(21) - UI_POS_WIDTH(2), 4}};
|
||||||
|
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{screen_width - 2 * 8, 0 * 16}};
|
{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
|
||||||
|
|
||||||
OptionsField options_region{
|
OptionsField options_region{
|
||||||
{0 * 8, 0 * 8},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
3,
|
3,
|
||||||
{{"MAN", 0},
|
{{"MAN", 0},
|
||||||
{"NA ", 1},
|
{"NA ", 1},
|
||||||
@@ -237,11 +237,11 @@ class APRSRxView : public View {
|
|||||||
{"ISS", 9}}};
|
{"ISS", 9}}};
|
||||||
|
|
||||||
FrequencyField field_frequency{
|
FrequencyField field_frequency{
|
||||||
{3 * 8, 0 * 16}};
|
{UI_POS_X(3), UI_POS_Y(0)}};
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
RecordView record_view{
|
RecordView record_view{
|
||||||
{0 * 8, 1 * 16, screen_width, 1 * 16},
|
{UI_POS_X(0), UI_POS_Y(1), UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)},
|
||||||
u"AFS_????.WAV",
|
u"AFS_????.WAV",
|
||||||
aprs_dir,
|
aprs_dir,
|
||||||
RecordView::FileType::WAV,
|
RecordView::FileType::WAV,
|
||||||
@@ -249,7 +249,7 @@ class APRSRxView : public View {
|
|||||||
4};
|
4};
|
||||||
|
|
||||||
Console console{
|
Console console{
|
||||||
{0, 2 * 16, screen_width, screen_height - 80}};
|
{UI_POS_X(0), UI_POS_Y(2), UI_POS_MAXWIDTH, screen_height - 80}};
|
||||||
|
|
||||||
std::unique_ptr<APRSLogger> logger{};
|
std::unique_ptr<APRSLogger> logger{};
|
||||||
};
|
};
|
||||||
@@ -265,7 +265,7 @@ class APRSRXView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
Rect view_rect = {0, 3 * 8, screen_width, screen_height - 40};
|
Rect view_rect = {UI_POS_X(0), 3 * 8, UI_POS_MAXWIDTH, screen_height - 40};
|
||||||
|
|
||||||
APRSRxView view_stream{nav_, view_rect};
|
APRSRxView view_stream{nav_, view_rect};
|
||||||
APRSTableView view_table{nav_, view_rect};
|
APRSTableView view_table{nav_, view_rect};
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ class APRSTXView : public View {
|
|||||||
void on_tx_progress(const uint32_t progress, const bool done);
|
void on_tx_progress(const uint32_t progress, const bool done);
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 1 * 16}, "Source: SSID:", Theme::getInstance()->fg_light->foreground}, // 6 alphanum + SSID
|
{{UI_POS_X(0), 1 * 16}, "Source: SSID:", Theme::getInstance()->fg_light->foreground}, // 6 alphanum + SSID
|
||||||
{{0 * 8, 2 * 16}, " Dest.: SSID:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 2 * 16}, " Dest.: SSID:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 4 * 16}, "Info field:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 4 * 16}, "Info field:", Theme::getInstance()->fg_light->foreground},
|
||||||
};
|
};
|
||||||
|
|
||||||
SymField sym_source{
|
SymField sym_source{
|
||||||
@@ -91,14 +91,14 @@ class APRSTXView : public View {
|
|||||||
' '};
|
' '};
|
||||||
|
|
||||||
Text text_payload{
|
Text text_payload{
|
||||||
{0 * 8, 5 * 16, screen_width, 16},
|
{UI_POS_X(0), 5 * 16, screen_width, 16},
|
||||||
"-"};
|
"-"};
|
||||||
Button button_set{
|
Button button_set{
|
||||||
{0 * 8, 6 * 16, 80, 32},
|
{UI_POS_X(0), 6 * 16, 80, 32},
|
||||||
"Set"};
|
"Set"};
|
||||||
|
|
||||||
TransmitterView tx_view{
|
TransmitterView tx_view{
|
||||||
16 * 16,
|
(int16_t)UI_POS_Y_BOTTOM(4),
|
||||||
5000,
|
5000,
|
||||||
0 // disable setting bandwith, since APRS used fixed 10k bandwidth
|
0 // disable setting bandwith, since APRS used fixed 10k bandwidth
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ class BattinfoView : public View {
|
|||||||
"Volt"};
|
"Volt"};
|
||||||
|
|
||||||
Button button_exit{
|
Button button_exit{
|
||||||
{72, 17 * 16, 96, 32},
|
{UI_POS_X_CENTER(12), 17 * 16, UI_POS_WIDTH(12), UI_POS_HEIGHT(3)},
|
||||||
"Back"};
|
"Back"};
|
||||||
static msg_t static_fn(void* arg);
|
static msg_t static_fn(void* arg);
|
||||||
Thread* thread{nullptr};
|
Thread* thread{nullptr};
|
||||||
|
|||||||
@@ -63,22 +63,22 @@ class BTLERxView : public View {
|
|||||||
static constexpr uint8_t channel_number = 37;
|
static constexpr uint8_t channel_number = 37;
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{13 * 8, 0 * 16}};
|
{UI_POS_X(13), UI_POS_Y(0)}};
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{UI_POS_X(15), UI_POS_Y(0)}};
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{UI_POS_X(18), UI_POS_Y(0)}};
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4}};
|
{UI_POS_X(21), UI_POS_Y(0), UI_POS_WIDTH_REMAINING(21), 4}};
|
||||||
Channel channel{
|
Channel channel{
|
||||||
{21 * 8, 5, 6 * 8, 4}};
|
{UI_POS_X(21), 5, UI_POS_WIDTH_REMAINING(21), 4}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 16},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
Button button_modem_setup{
|
Button button_modem_setup{
|
||||||
{screen_width - 12 * 8, 1 * 16, 96, 24},
|
{screen_width - 12 * 8, UI_POS_Y(1), 96, 24},
|
||||||
"Modem setup"};
|
"Modem setup"};
|
||||||
|
|
||||||
Console console{
|
Console console{
|
||||||
|
|||||||
@@ -242,9 +242,9 @@ class DebugControlsView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{8 * 8, 1 * 16}, "Controls State", Theme::getInstance()->bg_darkest->foreground},
|
{{UI_POS_X_CENTER(14), 1 * 16}, "Controls State", Theme::getInstance()->bg_darkest->foreground},
|
||||||
{{0 * 8, 11 * 16}, "Dial:", Theme::getInstance()->fg_medium->foreground},
|
{{UI_POS_X(0), 11 * 16}, "Dial:", Theme::getInstance()->fg_medium->foreground},
|
||||||
{{0 * 8, 14 * 16}, "Long-Press Mode:", Theme::getInstance()->fg_medium->foreground}};
|
{{UI_POS_X(0), 14 * 16}, "Long-Press Mode:", Theme::getInstance()->fg_medium->foreground}};
|
||||||
|
|
||||||
ControlsSwitchesWidget switches_widget{
|
ControlsSwitchesWidget switches_widget{
|
||||||
{80, 80, 80, 112},
|
{80, 80, 80, 112},
|
||||||
@@ -259,7 +259,7 @@ class DebugControlsView : public View {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
Button button_done{
|
Button button_done{
|
||||||
{72, 264, 96, 24},
|
{UI_POS_X_CENTER(12), 264, 96, 24},
|
||||||
"Done"};
|
"Done"};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -271,28 +271,28 @@ class DebugMemoryDumpView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Button button_dump{
|
Button button_dump{
|
||||||
{72, 4 * 16, 96, 24},
|
{UI_POS_X_CENTER(12), 4 * 16, 96, 24},
|
||||||
"Dump"};
|
"Dump"};
|
||||||
|
|
||||||
Button button_read{
|
Button button_read{
|
||||||
{16, 11 * 16, 96, 24},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(10), 11 * 16, 96, 24},
|
||||||
"Read"};
|
"Read"};
|
||||||
|
|
||||||
Button button_write{
|
Button button_write{
|
||||||
{128, 11 * 16, 96, 24},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(10), 11 * 16, 96, 24},
|
||||||
"Write"};
|
"Write"};
|
||||||
|
|
||||||
Button button_done{
|
Button button_done{
|
||||||
{128, screen_height - 80, 96, 24},
|
{UI_POS_X_RIGHT(12), UI_POS_Y_BOTTOM(3), 96, 24},
|
||||||
"Done"};
|
"Done"};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{5 * 8, 1 * 16}, "Dump Range to File", Theme::getInstance()->fg_yellow->foreground},
|
{{5 * 8, 1 * 16}, "Dump Range to File", Theme::getInstance()->fg_yellow->foreground},
|
||||||
{{0 * 8, 2 * 16}, "Starting Address: 0x", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 2 * 16}, "Starting Address: 0x", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 3 * 16}, "Byte Count: 0x", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 3 * 16}, "Byte Count: 0x", Theme::getInstance()->fg_light->foreground},
|
||||||
{{3 * 8, 8 * 16}, "Read/Write Single Word", Theme::getInstance()->fg_yellow->foreground},
|
{{3 * 8, 8 * 16}, "Read/Write Single Word", Theme::getInstance()->fg_yellow->foreground},
|
||||||
{{0 * 8, 9 * 16}, "Memory Address: 0x", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 9 * 16}, "Memory Address: 0x", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 10 * 16}, "Data Value: 0x", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 10 * 16}, "Data Value: 0x", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
SymField field_starting_address{
|
SymField field_starting_address{
|
||||||
{20 * 8, 2 * 16},
|
{20 * 8, 2 * 16},
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ BatteryCapacityView::RegisterEntry BatteryCapacityView::get_entry(size_t index)
|
|||||||
|
|
||||||
BatteryCapacityView::BatteryCapacityView(NavigationView& nav) {
|
BatteryCapacityView::BatteryCapacityView(NavigationView& nav) {
|
||||||
for (size_t i = 0; i < ENTRIES_PER_PAGE; ++i) {
|
for (size_t i = 0; i < ENTRIES_PER_PAGE; ++i) {
|
||||||
name_texts[i].set_parent_rect({0 * 8, static_cast<int>((i + 1) * 16), 8 * 8, 16});
|
name_texts[i].set_parent_rect({UI_POS_X(0), static_cast<int>((i + 1) * 16), 8 * 8, 16});
|
||||||
addr_texts[i].set_parent_rect({9 * 8, static_cast<int>((i + 1) * 16), 4 * 8, 16});
|
addr_texts[i].set_parent_rect({9 * 8, static_cast<int>((i + 1) * 16), 4 * 8, 16});
|
||||||
hex_texts[i].set_parent_rect({14 * 8, static_cast<int>((i + 1) * 16), 6 * 8, 16});
|
hex_texts[i].set_parent_rect({14 * 8, static_cast<int>((i + 1) * 16), 6 * 8, 16});
|
||||||
value_texts[i].set_parent_rect({21 * 8, static_cast<int>((i + 1) * 16), 10 * 8, 16});
|
value_texts[i].set_parent_rect({21 * 8, static_cast<int>((i + 1) * 16), 10 * 8, 16});
|
||||||
|
|||||||
@@ -24,18 +24,18 @@ class BatteryCapacityView : public View {
|
|||||||
static RegisterEntry get_entry(size_t index);
|
static RegisterEntry get_entry(size_t index);
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 0 * 16}, "Reg", Theme::getInstance()->fg_yellow->foreground},
|
{{UI_POS_X(0), UI_POS_Y(0)}, "Reg", Theme::getInstance()->fg_yellow->foreground},
|
||||||
{{9 * 8, 0 * 16}, "Addr", Theme::getInstance()->fg_yellow->foreground},
|
{{9 * 8, UI_POS_Y(0)}, "Addr", Theme::getInstance()->fg_yellow->foreground},
|
||||||
{{14 * 8, 0 * 16}, "Hex", Theme::getInstance()->fg_yellow->foreground},
|
{{14 * 8, UI_POS_Y(0)}, "Hex", Theme::getInstance()->fg_yellow->foreground},
|
||||||
{{21 * 8, 0 * 16}, "Value", Theme::getInstance()->fg_yellow->foreground},
|
{{21 * 8, UI_POS_Y(0)}, "Value", Theme::getInstance()->fg_yellow->foreground},
|
||||||
};
|
};
|
||||||
std::array<Text, 16> name_texts = {};
|
std::array<Text, 16> name_texts = {};
|
||||||
std::array<Text, 16> addr_texts = {};
|
std::array<Text, 16> addr_texts = {};
|
||||||
std::array<Text, 16> hex_texts = {};
|
std::array<Text, 16> hex_texts = {};
|
||||||
std::array<Text, 16> value_texts = {};
|
std::array<Text, 16> value_texts = {};
|
||||||
|
|
||||||
Text page_text{{144, 284, 80, 16}, "Page 1/1"};
|
Text page_text{{144, UI_POS_Y_BOTTOM(3), 80, 16}, "Page 1/1"};
|
||||||
Button button_done{{16, 280, 96, 24}, "Done"};
|
Button button_done{{16, UI_POS_Y_BOTTOM(3), 96, 24}, "Done"};
|
||||||
|
|
||||||
void update_values();
|
void update_values();
|
||||||
void populate_page(int start_index);
|
void populate_page(int start_index);
|
||||||
|
|||||||
@@ -216,10 +216,10 @@ class EncodersView : public View {
|
|||||||
"Ready"};
|
"Ready"};
|
||||||
|
|
||||||
ProgressBar progressbar{
|
ProgressBar progressbar{
|
||||||
{2 * 8, 13 * 16 + 20, 208, 16}};
|
{2 * 8, 13 * 16 + 20, UI_POS_WIDTH_REMAINING(4), 16}};
|
||||||
|
|
||||||
TransmitterView tx_view{
|
TransmitterView tx_view{
|
||||||
16 * 16,
|
(int16_t)UI_POS_Y_BOTTOM(4),
|
||||||
50000,
|
50000,
|
||||||
9};
|
9};
|
||||||
|
|
||||||
|
|||||||
@@ -294,6 +294,7 @@ FileManBaseView::FileManBaseView(
|
|||||||
std::string filter)
|
std::string filter)
|
||||||
: nav_{nav},
|
: nav_{nav},
|
||||||
extension_filter{filter} {
|
extension_filter{filter} {
|
||||||
|
max_filename_length = screen_width / 8 - 10;
|
||||||
add_children({&labels,
|
add_children({&labels,
|
||||||
&text_current,
|
&text_current,
|
||||||
&button_exit});
|
&button_exit});
|
||||||
@@ -403,7 +404,7 @@ void FileManBaseView::refresh_list() {
|
|||||||
menu_view.clear();
|
menu_view.clear();
|
||||||
|
|
||||||
for (const auto& entry : entry_list) {
|
for (const auto& entry : entry_list) {
|
||||||
auto entry_name = std::string{entry.path.length() <= 20 ? entry.path : entry.path.substr(0, 20)};
|
auto entry_name = std::string{entry.path.length() <= max_filename_length ? entry.path : entry.path.substr(0, max_filename_length)};
|
||||||
|
|
||||||
if (entry.is_directory) {
|
if (entry.is_directory) {
|
||||||
std::string size_str{};
|
std::string size_str{};
|
||||||
@@ -414,7 +415,7 @@ void FileManBaseView::refresh_list() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
menu_view.add_item(
|
menu_view.add_item(
|
||||||
{entry_name.substr(0, max_filename_length) + std::string(21 - entry_name.length(), ' ') + size_str,
|
{entry_name.substr(0, max_filename_length) + std::string((max_filename_length + 1) - entry_name.length(), ' ') + size_str,
|
||||||
Theme::getInstance()->fg_yellow->foreground,
|
Theme::getInstance()->fg_yellow->foreground,
|
||||||
&bitmap_icon_dir,
|
&bitmap_icon_dir,
|
||||||
[this](KeyEvent key) {
|
[this](KeyEvent key) {
|
||||||
@@ -427,7 +428,7 @@ void FileManBaseView::refresh_list() {
|
|||||||
auto size_str = to_string_file_size(entry.size);
|
auto size_str = to_string_file_size(entry.size);
|
||||||
|
|
||||||
menu_view.add_item(
|
menu_view.add_item(
|
||||||
{entry_name.substr(0, max_filename_length) + std::string(21 - entry_name.length(), ' ') + size_str,
|
{entry_name.substr(0, max_filename_length) + std::string((max_filename_length + 1) - entry_name.length(), ' ') + size_str,
|
||||||
assoc.color,
|
assoc.color,
|
||||||
assoc.icon,
|
assoc.icon,
|
||||||
[this](KeyEvent key) {
|
[this](KeyEvent key) {
|
||||||
@@ -486,7 +487,7 @@ FileLoadView::FileLoadView(
|
|||||||
add_children({&menu_view});
|
add_children({&menu_view});
|
||||||
|
|
||||||
// Resize menu view to fill screen
|
// Resize menu view to fill screen
|
||||||
menu_view.set_parent_rect({0, 3 * 8, screen_width, 29 * 8});
|
menu_view.set_parent_rect({0, 3 * 8, screen_width, UI_POS_HEIGHT_REMAINING(4.5)});
|
||||||
|
|
||||||
refresh_list();
|
refresh_list();
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class FileManBaseView : public View {
|
|||||||
uint8_t pagination = 0;
|
uint8_t pagination = 0;
|
||||||
uint8_t nb_pages = 1;
|
uint8_t nb_pages = 1;
|
||||||
bool restoring_navigation = false;
|
bool restoring_navigation = false;
|
||||||
static constexpr size_t max_filename_length = 20;
|
size_t max_filename_length = 20;
|
||||||
static constexpr size_t max_items_loaded = 75; // too memory hungry, so won't sort it
|
static constexpr size_t max_items_loaded = 75; // too memory hungry, so won't sort it
|
||||||
static constexpr size_t items_per_page = 20;
|
static constexpr size_t items_per_page = 20;
|
||||||
|
|
||||||
@@ -122,16 +122,16 @@ class FileManBaseView : public View {
|
|||||||
{{0, 0}, "Path:", Theme::getInstance()->fg_light->foreground}};
|
{{0, 0}, "Path:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Text text_current{
|
Text text_current{
|
||||||
{6 * 8, 0 * 8, 24 * 8, 16},
|
{UI_POS_X(6), UI_POS_Y(0), UI_POS_WIDTH_REMAINING(6), UI_POS_HEIGHT(1)},
|
||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
MenuView menu_view{
|
MenuView menu_view{
|
||||||
{0, 2 * 8, screen_width, 26 * 8},
|
{0, UI_POS_Y(1), UI_POS_MAXWIDTH, UI_POS_HEIGHT_REMAINING(7)},
|
||||||
true};
|
true};
|
||||||
|
|
||||||
Button button_exit{
|
Button button_exit{
|
||||||
{22 * 8, 34 * 8, 8 * 8, 32},
|
{UI_POS_X_RIGHT(8), UI_POS_Y_BOTTOM(3), 8 * 8, UI_POS_HEIGHT(2)},
|
||||||
"Exit"};
|
"Exit"};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -230,66 +230,66 @@ class FileManagerView : public FileManBaseView {
|
|||||||
bool selected_is_valid() const;
|
bool selected_is_valid() const;
|
||||||
|
|
||||||
Text text_date{
|
Text text_date{
|
||||||
{0 * 8, 26 * 8, 28 * 8, 16},
|
{UI_POS_X(0), UI_POS_Y_BOTTOM(6), 28 * 8, UI_POS_HEIGHT(1)},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
NewButton button_rename{
|
NewButton button_rename{
|
||||||
{0 * 8, 29 * 8, 4 * 8, 32},
|
{UI_POS_X(0), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_rename,
|
&bitmap_icon_rename,
|
||||||
Theme::getInstance()->fg_blue->foreground};
|
Theme::getInstance()->fg_blue->foreground};
|
||||||
|
|
||||||
NewButton button_delete{
|
NewButton button_delete{
|
||||||
{9 * 8, 34 * 8, 4 * 8, 32},
|
{UI_POS_X(9), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_trash,
|
&bitmap_icon_trash,
|
||||||
Theme::getInstance()->fg_red->foreground};
|
Theme::getInstance()->fg_red->foreground};
|
||||||
|
|
||||||
NewButton button_clean{
|
NewButton button_clean{
|
||||||
{13 * 8, 34 * 8, 4 * 8, 32},
|
{UI_POS_X(13), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_clean,
|
&bitmap_icon_clean,
|
||||||
Theme::getInstance()->fg_red->foreground};
|
Theme::getInstance()->fg_red->foreground};
|
||||||
|
|
||||||
NewButton button_cut{
|
NewButton button_cut{
|
||||||
{9 * 8, 29 * 8, 4 * 8, 32},
|
{UI_POS_X(9), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_cut,
|
&bitmap_icon_cut,
|
||||||
Theme::getInstance()->fg_dark->foreground};
|
Theme::getInstance()->fg_dark->foreground};
|
||||||
|
|
||||||
NewButton button_copy{
|
NewButton button_copy{
|
||||||
{13 * 8, 29 * 8, 4 * 8, 32},
|
{UI_POS_X(13), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_copy,
|
&bitmap_icon_copy,
|
||||||
Theme::getInstance()->fg_dark->foreground};
|
Theme::getInstance()->fg_dark->foreground};
|
||||||
|
|
||||||
NewButton button_paste{
|
NewButton button_paste{
|
||||||
{17 * 8, 29 * 8, 4 * 8, 32},
|
{UI_POS_X(17), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_paste,
|
&bitmap_icon_paste,
|
||||||
Theme::getInstance()->fg_dark->foreground};
|
Theme::getInstance()->fg_dark->foreground};
|
||||||
|
|
||||||
NewButton button_new_dir{
|
NewButton button_new_dir{
|
||||||
{22 * 8, 29 * 8, 4 * 8, 32},
|
{UI_POS_X(22), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_new_dir,
|
&bitmap_icon_new_dir,
|
||||||
Theme::getInstance()->fg_green->foreground};
|
Theme::getInstance()->fg_green->foreground};
|
||||||
|
|
||||||
NewButton button_new_file{
|
NewButton button_new_file{
|
||||||
{26 * 8, 29 * 8, 4 * 8, 32},
|
{UI_POS_X(26), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_new_file,
|
&bitmap_icon_new_file,
|
||||||
Theme::getInstance()->fg_green->foreground};
|
Theme::getInstance()->fg_green->foreground};
|
||||||
|
|
||||||
NewButton button_open_notepad{
|
NewButton button_open_notepad{
|
||||||
{0 * 8, 34 * 8, 4 * 8, 32},
|
{UI_POS_X(0), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_notepad,
|
&bitmap_icon_notepad,
|
||||||
Theme::getInstance()->fg_orange->foreground};
|
Theme::getInstance()->fg_orange->foreground};
|
||||||
|
|
||||||
NewButton button_rename_timestamp{
|
NewButton button_rename_timestamp{
|
||||||
|
|
||||||
{4 * 8, 29 * 8, 4 * 8, 32},
|
{UI_POS_X(4), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_options_datetime,
|
&bitmap_icon_options_datetime,
|
||||||
Theme::getInstance()->fg_blue->foreground,
|
Theme::getInstance()->fg_blue->foreground,
|
||||||
@@ -297,13 +297,13 @@ class FileManagerView : public FileManBaseView {
|
|||||||
|
|
||||||
NewButton button_open_iq_trim{
|
NewButton button_open_iq_trim{
|
||||||
|
|
||||||
{4 * 8, 34 * 8, 4 * 8, 32},
|
{UI_POS_X(4), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_trim,
|
&bitmap_icon_trim,
|
||||||
Theme::getInstance()->fg_orange->foreground};
|
Theme::getInstance()->fg_orange->foreground};
|
||||||
|
|
||||||
NewButton button_show_hidden_files{
|
NewButton button_show_hidden_files{
|
||||||
{17 * 8, 34 * 8, 4 * 8, 32},
|
{UI_POS_X(17), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_hide,
|
&bitmap_icon_hide,
|
||||||
Theme::getInstance()->fg_dark->foreground};
|
Theme::getInstance()->fg_dark->foreground};
|
||||||
|
|||||||
@@ -130,6 +130,12 @@ bool FlashUtilityView::endsWith(const std::u16string& str, const std::u16string&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlashUtilityView::wait_till_loaded() {
|
||||||
|
while (!isLoaded) {
|
||||||
|
chThdSleepMilliseconds(50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::filesystem::path FlashUtilityView::extract_tar(std::filesystem::path::string_type path, ui::Painter& painter) {
|
std::filesystem::path FlashUtilityView::extract_tar(std::filesystem::path::string_type path, ui::Painter& painter) {
|
||||||
//
|
//
|
||||||
painter.fill_rectangle(
|
painter.fill_rectangle(
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class FlashUtilityView : public View {
|
|||||||
|
|
||||||
std::string title() const override { return "Flash Utility"; };
|
std::string title() const override { return "Flash Utility"; };
|
||||||
bool flash_firmware(std::filesystem::path::string_type path);
|
bool flash_firmware(std::filesystem::path::string_type path);
|
||||||
|
void wait_till_loaded();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
@@ -60,13 +61,21 @@ class FlashUtilityView : public View {
|
|||||||
{{4, 4}, "Select firmware to flash:", Theme::getInstance()->bg_darkest->foreground}};
|
{{4, 4}, "Select firmware to flash:", Theme::getInstance()->bg_darkest->foreground}};
|
||||||
|
|
||||||
MenuView menu_view{
|
MenuView menu_view{
|
||||||
{0, 2 * 8, screen_width, 26 * 8},
|
{0, UI_POS_Y(1), screen_width, UI_POS_HEIGHT_REMAINING(2)},
|
||||||
true};
|
true};
|
||||||
|
|
||||||
std::filesystem::path extract_tar(std::filesystem::path::string_type path, ui::Painter& painter); // extracts the tar file, and returns the firmware.bin path from it. empty string if no fw
|
std::filesystem::path extract_tar(std::filesystem::path::string_type path, ui::Painter& painter); // extracts the tar file, and returns the firmware.bin path from it. empty string if no fw
|
||||||
void firmware_selected(std::filesystem::path::string_type path);
|
void firmware_selected(std::filesystem::path::string_type path);
|
||||||
|
|
||||||
bool endsWith(const std::u16string& str, const std::u16string& suffix);
|
bool endsWith(const std::u16string& str, const std::u16string& suffix);
|
||||||
|
bool isLoaded = false;
|
||||||
|
uint8_t refreshcnt = 0;
|
||||||
|
MessageHandlerRegistration message_handler_frame_sync{
|
||||||
|
Message::ID::DisplayFrameSync,
|
||||||
|
[this](const Message* const) {
|
||||||
|
refreshcnt++;
|
||||||
|
if (refreshcnt > 5) isLoaded = true;
|
||||||
|
}};
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
|||||||
@@ -65,14 +65,14 @@ class FreqManBaseView : public View {
|
|||||||
|
|
||||||
OptionsField options_category{
|
OptionsField options_category{
|
||||||
{3 * 8, 2},
|
{3 * 8, 2},
|
||||||
20 /* length */,
|
19 /* length */,
|
||||||
{}};
|
{}};
|
||||||
|
|
||||||
FreqManUIList freqlist_view{
|
FreqManUIList freqlist_view{
|
||||||
{0, 3 * 8, screen_width, 12 * 16 + 2 /* 2 Keeps text out of border. */}};
|
{0, 3 * 8, screen_width, 12 * 16 + 2 /* 2 Keeps text out of border. */}};
|
||||||
|
|
||||||
Button button_exit{
|
Button button_exit{
|
||||||
{15 * 8, 17 * 16, 15 * 8, 2 * 16},
|
{UI_POS_X_RIGHT(14), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(14), UI_POS_HEIGHT(2)},
|
||||||
"Exit"};
|
"Exit"};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -97,14 +97,14 @@ class FrequencySaveView : public FreqManBaseView {
|
|||||||
0};
|
0};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 6 * 16}, "Description:", Theme::getInstance()->bg_darkest->foreground}};
|
{{UI_POS_X(0), 6 * 16}, "Description:", Theme::getInstance()->bg_darkest->foreground}};
|
||||||
|
|
||||||
TextField field_description{
|
TextField field_description{
|
||||||
{0 * 8, 7 * 16, screen_width, 1 * 16},
|
{UI_POS_X(0), 7 * 16, screen_width, 1 * 16},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{0 * 8, 17 * 16, 15 * 8, 2 * 16},
|
{UI_POS_X(0), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(14), UI_POS_HEIGHT(2)},
|
||||||
"Save"};
|
"Save"};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -134,44 +134,44 @@ class FrequencyManagerView : public FreqManBaseView {
|
|||||||
void on_del_entry();
|
void on_del_entry();
|
||||||
|
|
||||||
NewButton button_add_category{
|
NewButton button_add_category{
|
||||||
{23 * 8, 0 * 16, 7 * 4, 20},
|
{UI_POS_X_RIGHT(8), UI_POS_Y(0), 7 * 4, 20},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_new_file,
|
&bitmap_icon_new_file,
|
||||||
Theme::getInstance()->bg_darkest->foreground,
|
Theme::getInstance()->bg_darkest->foreground,
|
||||||
true};
|
true};
|
||||||
|
|
||||||
NewButton button_del_category{
|
NewButton button_del_category{
|
||||||
{26 * 8 + 4, 0 * 16, 7 * 4, 20},
|
{UI_POS_X_RIGHT(4), UI_POS_Y(0), 7 * 4, 20},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_trash,
|
&bitmap_icon_trash,
|
||||||
Theme::getInstance()->fg_red->foreground,
|
Theme::getInstance()->fg_red->foreground,
|
||||||
true};
|
true};
|
||||||
|
|
||||||
Button button_edit_entry{
|
Button button_edit_entry{
|
||||||
{0 * 8, 14 * 16 - 4, 15 * 8, 1 * 16 + 4},
|
{UI_POS_X(0), UI_POS_Y_BOTTOM(6.5) + 4, 15 * 8, 1 * 16 + 4},
|
||||||
"Edit"};
|
"Edit"};
|
||||||
|
|
||||||
Rectangle rect_padding{
|
Rectangle rect_padding{
|
||||||
{15 * 8, 14 * 16 - 4, 15 * 8, 1 * 16 + 4},
|
{15 * 8, UI_POS_Y_BOTTOM(6.5), 15 * 8, 1 * 16 + 4},
|
||||||
Theme::getInstance()->fg_medium->background};
|
Theme::getInstance()->fg_medium->background};
|
||||||
|
|
||||||
Button button_edit_freq{
|
Button button_edit_freq{
|
||||||
{0 * 8, 15 * 16, 15 * 8, 2 * 16},
|
{UI_POS_X(0), UI_POS_Y_BOTTOM(5), 15 * 8, 2 * 16},
|
||||||
"Frequency"};
|
"Frequency"};
|
||||||
|
|
||||||
Button button_edit_desc{
|
Button button_edit_desc{
|
||||||
{0 * 8, 17 * 16, 15 * 8, 2 * 16},
|
{UI_POS_X(0), UI_POS_Y_BOTTOM(3), 15 * 8, 2 * 16},
|
||||||
"Description"};
|
"Description"};
|
||||||
|
|
||||||
NewButton button_add_entry{
|
NewButton button_add_entry{
|
||||||
{15 * 8, 15 * 16, 7 * 8 + 4, 2 * 16},
|
{15 * 8, UI_POS_Y_BOTTOM(5), 7 * 8 + 4, 2 * 16},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_add,
|
&bitmap_icon_add,
|
||||||
Theme::getInstance()->bg_darkest->foreground,
|
Theme::getInstance()->bg_darkest->foreground,
|
||||||
true};
|
true};
|
||||||
|
|
||||||
NewButton button_del_entry{
|
NewButton button_del_entry{
|
||||||
{22 * 8 + 4, 15 * 16, 7 * 8 + 4, 2 * 16},
|
{22 * 8 + 4, UI_POS_Y_BOTTOM(5), 7 * 8 + 4, 2 * 16},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_delete,
|
&bitmap_icon_delete,
|
||||||
Theme::getInstance()->fg_red->foreground,
|
Theme::getInstance()->fg_red->foreground,
|
||||||
@@ -201,14 +201,14 @@ class FrequencyEditView : public View {
|
|||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{5 * 8, 1 * 16}, "Edit Frequency Entry", Theme::getInstance()->bg_darkest->foreground},
|
{{5 * 8, 1 * 16}, "Edit Frequency Entry", Theme::getInstance()->bg_darkest->foreground},
|
||||||
{{0 * 8, 3 * 16}, "Entry Type :", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 3 * 16}, "Entry Type :", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 4 * 16}, "Frequency A:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 4 * 16}, "Frequency A:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 5 * 16}, "Frequency B:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 5 * 16}, "Frequency B:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 6 * 16}, "Modulation :", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 6 * 16}, "Modulation :", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 7 * 16}, "Bandwidth :", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 7 * 16}, "Bandwidth :", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 8 * 16}, "Step :", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 8 * 16}, "Step :", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 9 * 16}, "Tone Freq :", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 9 * 16}, "Tone Freq :", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 10 * 16}, "Description:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 10 * 16}, "Description:", Theme::getInstance()->fg_light->foreground},
|
||||||
};
|
};
|
||||||
|
|
||||||
OptionsField field_type{
|
OptionsField field_type{
|
||||||
@@ -243,11 +243,11 @@ class FrequencyEditView : public View {
|
|||||||
{}};
|
{}};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{0 * 8, 17 * 16, 15 * 8, 2 * 16},
|
{UI_POS_X(0), UI_POS_Y_BOTTOM(3), 15 * 8, 2 * 16},
|
||||||
"Save"};
|
"Save"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{15 * 8, 17 * 16, 15 * 8, 2 * 16},
|
{UI_POS_X_RIGHT(15), UI_POS_Y_BOTTOM(3), 15 * 8, 2 * 16},
|
||||||
"Cancel"};
|
"Cancel"};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ void IQTrimView::update_range_controls(iq::TrimRange trim_range) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IQTrimView::profile_capture() {
|
void IQTrimView::profile_capture() {
|
||||||
power_buckets_ = {};
|
power_buckets_.clear();
|
||||||
iq::PowerBuckets buckets{
|
iq::PowerBuckets buckets{
|
||||||
.p = power_buckets_.data(),
|
.p = power_buckets_.data(),
|
||||||
.size = power_buckets_.size()};
|
.size = power_buckets_.size()};
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class TrimProgressUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
p.fill_rectangle({0 * 8, 4 * 16, screen_width, 3 * 16}, Theme::getInstance()->bg_darkest->background);
|
p.fill_rectangle({UI_POS_X(0), 4 * 16, screen_width, 3 * 16}, Theme::getInstance()->bg_darkest->background);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_callback() {
|
auto get_callback() {
|
||||||
@@ -100,22 +100,22 @@ class IQTrimView : public View {
|
|||||||
TrimProgressUI progress_ui{};
|
TrimProgressUI progress_ui{};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 0 * 16}, "Capture File:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), UI_POS_Y(0)}, "Capture File:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 6 * 16}, "Start :", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 6 * 16}, "Start :", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 7 * 16}, "End :", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 7 * 16}, "End :", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 8 * 16}, "Samples:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 8 * 16}, "Samples:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 9 * 16}, "Max Pwr:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 9 * 16}, "Max Pwr:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 10 * 16}, "Cutoff :", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 10 * 16}, "Cutoff :", Theme::getInstance()->fg_light->foreground},
|
||||||
{{12 * 8, 10 * 16}, "%", Theme::getInstance()->fg_light->foreground},
|
{{12 * 8, 10 * 16}, "%", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 12 * 16}, "Amplify:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 12 * 16}, "Amplify:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{10 * 8, 12 * 16}, "x", Theme::getInstance()->fg_light->foreground},
|
{{10 * 8, 12 * 16}, "x", Theme::getInstance()->fg_light->foreground},
|
||||||
};
|
};
|
||||||
|
|
||||||
TextField field_path{
|
TextField field_path{
|
||||||
{0 * 8, 1 * 16, screen_width, 1 * 16},
|
{UI_POS_X(0), 1 * 16, screen_width, 1 * 16},
|
||||||
"Open File..."};
|
"Open File..."};
|
||||||
|
|
||||||
Point pos_lines{0 * 8, 4 * 16};
|
Point pos_lines{UI_POS_X(0), 4 * 16};
|
||||||
Dim height_lines{2 * 16};
|
Dim height_lines{2 * 16};
|
||||||
|
|
||||||
NumberField field_start{
|
NumberField field_start{
|
||||||
@@ -155,7 +155,7 @@ class IQTrimView : public View {
|
|||||||
' '};
|
' '};
|
||||||
|
|
||||||
Button button_trim{
|
Button button_trim{
|
||||||
{20 * 8, 16 * 16, 8 * 8, 2 * 16},
|
{UI_POS_X_CENTER(8), UI_POS_Y_BOTTOM(3), 8 * 8, 2 * 16},
|
||||||
"Trim"};
|
"Trim"};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ class GlassView : public View {
|
|||||||
uint8_t ignore_dc = 0;
|
uint8_t ignore_dc = 0;
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0, 0 * 16}, "MIN: MAX: LNA VGA ", Theme::getInstance()->fg_light->foreground},
|
{{0, UI_POS_Y(0)}, "MIN: MAX: LNA VGA ", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0, 1 * 16}, "RANGE: FILTER: AMP:", Theme::getInstance()->fg_light->foreground},
|
{{0, 1 * 16}, "RANGE: FILTER: AMP:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0, 2 * 16}, "P:", Theme::getInstance()->fg_light->foreground},
|
{{0, 2 * 16}, "P:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0, 3 * 16}, "MARKER: MHz RXIQCAL", Theme::getInstance()->fg_light->foreground},
|
{{0, 3 * 16}, "MARKER: MHz RXIQCAL", Theme::getInstance()->fg_light->foreground},
|
||||||
@@ -178,24 +178,24 @@ class GlassView : public View {
|
|||||||
{{0, 4 * 16}, "RES: VOL:", Theme::getInstance()->fg_light->foreground}};
|
{{0, 4 * 16}, "RES: VOL:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
NumberField field_frequency_min{
|
NumberField field_frequency_min{
|
||||||
{4 * 8, 0 * 16},
|
{4 * 8, UI_POS_Y(0)},
|
||||||
4,
|
4,
|
||||||
{0, 7199},
|
{0, 7199},
|
||||||
1, // number of steps by encoder delta
|
1, // number of steps by encoder delta
|
||||||
' '};
|
' '};
|
||||||
|
|
||||||
NumberField field_frequency_max{
|
NumberField field_frequency_max{
|
||||||
{13 * 8, 0 * 16},
|
{13 * 8, UI_POS_Y(0)},
|
||||||
4,
|
4,
|
||||||
{1, 7200},
|
{1, 7200},
|
||||||
1, // number of steps by encoder delta
|
1, // number of steps by encoder delta
|
||||||
' '};
|
' '};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{21 * 8, 0 * 16}};
|
{21 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{27 * 8, 0 * 16}};
|
{27 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
TextField field_range{
|
TextField field_range{
|
||||||
{6 * 8, 1 * 16, 6 * 8, 16},
|
{6 * 8, 1 * 16, 6 * 8, 16},
|
||||||
@@ -298,7 +298,7 @@ class GlassView : public View {
|
|||||||
"RST"};
|
"RST"};
|
||||||
|
|
||||||
Text freq_stats{
|
Text freq_stats{
|
||||||
{0 * 8, 5 * 16, screen_width - 10 * 8, 8},
|
{UI_POS_X(0), 5 * 16, screen_width - 10 * 8, 8},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_spectrum_config{
|
MessageHandlerRegistration message_handler_spectrum_config{
|
||||||
|
|||||||
@@ -446,6 +446,8 @@ MicTXView::MicTXView(
|
|||||||
field_frequency.set_value(tx_frequency);
|
field_frequency.set_value(tx_frequency);
|
||||||
|
|
||||||
// TODO: would be nice if frequency step was configurable in this app
|
// TODO: would be nice if frequency step was configurable in this app
|
||||||
|
// but now, make it a bit lower
|
||||||
|
receiver_model.set_frequency_step(12'500); // set freq step to 12.5kHz
|
||||||
field_frequency.set_step(receiver_model.frequency_step());
|
field_frequency.set_step(receiver_model.frequency_step());
|
||||||
|
|
||||||
// WARNING: transmitter_model.set_target_frequency() and receiver_model.set_target_frequency() both update the same tuning freq, but one has an offset!
|
// WARNING: transmitter_model.set_target_frequency() and receiver_model.set_target_frequency() both update the same tuning freq, but one has an offset!
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ class MicTXView : public View {
|
|||||||
{{17 * 8, 1 * 8}, "ALC", Theme::getInstance()->fg_light->foreground}};
|
{{17 * 8, 1 * 8}, "ALC", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
VuMeter vumeter{
|
VuMeter vumeter{
|
||||||
{0 * 8, 1 * 8, 2 * 8, 33 * 8},
|
{UI_POS_X(0), 1 * 8, 2 * 8, 33 * 8},
|
||||||
12,
|
12,
|
||||||
true};
|
true};
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class ModemSetupView : public View {
|
|||||||
"SET"};
|
"SET"};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{9 * 8, 250, 96, 40},
|
{UI_POS_X_CENTER(12), 250, UI_POS_WIDTH(12), 40},
|
||||||
"Save"};
|
"Save"};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -387,7 +387,6 @@ PlaylistView::PlaylistView(
|
|||||||
&button_next,
|
&button_next,
|
||||||
&waterfall,
|
&waterfall,
|
||||||
});
|
});
|
||||||
|
|
||||||
ensure_directory(playlist_dir);
|
ensure_directory(playlist_dir);
|
||||||
waterfall.show_audio_spectrum_view(false);
|
waterfall.show_audio_spectrum_view(false);
|
||||||
|
|
||||||
|
|||||||
@@ -107,24 +107,24 @@ class PlaylistView : public View {
|
|||||||
void handle_replay_thread_done(uint32_t return_code);
|
void handle_replay_thread_done(uint32_t return_code);
|
||||||
|
|
||||||
Text text_filename{
|
Text text_filename{
|
||||||
{0 * 8, 0 * 16, screen_width, 16}};
|
{UI_POS_X(0), UI_POS_Y(0), screen_width, 16}};
|
||||||
|
|
||||||
FrequencyField field_frequency{
|
FrequencyField field_frequency{
|
||||||
{0 * 8, 1 * 16}};
|
{UI_POS_X(0), 1 * 16}};
|
||||||
|
|
||||||
Text text_sample_rate{
|
Text text_sample_rate{
|
||||||
{10 * 8, 1 * 16, 7 * 8, 16}};
|
{10 * 8, 1 * 16, 7 * 8, 16}};
|
||||||
|
|
||||||
ProgressBar progressbar_track{
|
ProgressBar progressbar_track{
|
||||||
{18 * 8, 1 * 16, 12 * 8, 8 + 1}};
|
{18 * 8, 1 * 16, UI_POS_WIDTH_REMAINING(19), 8 + 1}};
|
||||||
|
|
||||||
// (-1) to overlap with progressbar_track so there's
|
// (-1) to overlap with progressbar_track so there's
|
||||||
// only 1 pixel between them instead of 2.
|
// only 1 pixel between them instead of 2.
|
||||||
ProgressBar progressbar_transmit{
|
ProgressBar progressbar_transmit{
|
||||||
{18 * 8, 3 * 8 - 1, 12 * 8, 8}};
|
{18 * 8, 3 * 8 - 1, UI_POS_WIDTH_REMAINING(19), 8}};
|
||||||
|
|
||||||
Text text_duration{
|
Text text_duration{
|
||||||
{0 * 8, 2 * 16, 5 * 8, 16}};
|
{UI_POS_X(0), 2 * 16, 5 * 8, 16}};
|
||||||
|
|
||||||
// TODO: delay duration field.
|
// TODO: delay duration field.
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ class PlaylistView : public View {
|
|||||||
/*short_ui*/ true};
|
/*short_ui*/ true};
|
||||||
|
|
||||||
Checkbox check_loop{
|
Checkbox check_loop{
|
||||||
{21 * 8, 2 * 16},
|
{UI_POS_X_RIGHT(9), 2 * 16},
|
||||||
4,
|
4,
|
||||||
"Loop",
|
"Loop",
|
||||||
true};
|
true};
|
||||||
@@ -145,7 +145,7 @@ class PlaylistView : public View {
|
|||||||
Theme::getInstance()->fg_green->background};
|
Theme::getInstance()->fg_green->background};
|
||||||
|
|
||||||
Text text_track{
|
Text text_track{
|
||||||
{0 * 8, 3 * 16, screen_width, 16}};
|
{UI_POS_X(0), 3 * 16, screen_width, 16}};
|
||||||
|
|
||||||
NewButton button_prev{
|
NewButton button_prev{
|
||||||
{2 * 8, 4 * 16, 4 * 8, 2 * 16},
|
{2 * 8, 4 * 16, 4 * 8, 2 * 16},
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class POCSAGTXView : public View {
|
|||||||
{{6 * 8, 8 * 8}, "Type:", Theme::getInstance()->fg_light->foreground},
|
{{6 * 8, 8 * 8}, "Type:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{2 * 8, 10 * 8}, "Function:", Theme::getInstance()->fg_light->foreground},
|
{{2 * 8, 10 * 8}, "Function:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{5 * 8, 12 * 8}, "Phase:", Theme::getInstance()->fg_light->foreground},
|
{{5 * 8, 12 * 8}, "Phase:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 14 * 8}, "Message:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 14 * 8}, "Message:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
OptionsField options_bitrate{
|
OptionsField options_bitrate{
|
||||||
{11 * 8, 4 * 8},
|
{11 * 8, 4 * 8},
|
||||||
@@ -122,21 +122,21 @@ class POCSAGTXView : public View {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
Text text_message{
|
Text text_message{
|
||||||
{0 * 8, 16 * 8, screen_width, 16},
|
{UI_POS_X(0), 16 * 8, screen_width, 16},
|
||||||
""};
|
""};
|
||||||
Text text_message_l2{
|
Text text_message_l2{
|
||||||
{0 * 8, 18 * 8, screen_width, 16},
|
{UI_POS_X(0), 18 * 8, screen_width, 16},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
Button button_message{
|
Button button_message{
|
||||||
{0 * 8, 20 * 8, 14 * 8, 32},
|
{UI_POS_X(0), 20 * 8, 14 * 8, 32},
|
||||||
"Set message"};
|
"Set message"};
|
||||||
|
|
||||||
ProgressBar progressbar{
|
ProgressBar progressbar{
|
||||||
{16, 210, 208, 16}};
|
{16, 210, UI_POS_WIDTH_REMAINING(4), 16}};
|
||||||
|
|
||||||
TransmitterView tx_view{
|
TransmitterView tx_view{
|
||||||
16 * 16,
|
(int16_t)UI_POS_Y_BOTTOM(4),
|
||||||
10000,
|
10000,
|
||||||
9};
|
9};
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class RDSRadioTextView : public OptionTabView {
|
|||||||
{1 * 8, 4 * 16, 28 * 8, 16},
|
{1 * 8, 4 * 16, 28 * 8, 16},
|
||||||
"-"};
|
"-"};
|
||||||
Button button_set{
|
Button button_set{
|
||||||
{88, 6 * 16, 64, 32},
|
{UI_POS_X_CENTER(8), 6 * 16, UI_POS_WIDTH(8), 32},
|
||||||
"Set"};
|
"Set"};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ class RDSDateTimeView : public OptionTabView {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{44, 5 * 16}, "Not yet implemented", Theme::getInstance()->error_dark->foreground}};
|
{{UI_POS_X_CENTER(19), 5 * 16}, "Not yet implemented", Theme::getInstance()->error_dark->foreground}};
|
||||||
};
|
};
|
||||||
|
|
||||||
class RDSAudioView : public OptionTabView {
|
class RDSAudioView : public OptionTabView {
|
||||||
@@ -101,7 +101,7 @@ class RDSAudioView : public OptionTabView {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{44, 5 * 16}, "Not yet implemented", Theme::getInstance()->error_dark->foreground}};
|
{{UI_POS_X_CENTER(19), 5 * 16}, "Not yet implemented", Theme::getInstance()->error_dark->foreground}};
|
||||||
};
|
};
|
||||||
|
|
||||||
class RDSThread {
|
class RDSThread {
|
||||||
@@ -174,7 +174,7 @@ class RDSView : public View {
|
|||||||
{"Audio", Theme::getInstance()->fg_orange->foreground, &view_audio}};
|
{"Audio", Theme::getInstance()->fg_orange->foreground, &view_audio}};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 28}, "Program type:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 28}, "Program type:", Theme::getInstance()->fg_light->foreground},
|
||||||
//{ { 14 * 8, 16 + 8 }, "CC:", Theme::getInstance()->fg_light->foreground },
|
//{ { 14 * 8, 16 + 8 }, "CC:", Theme::getInstance()->fg_light->foreground },
|
||||||
{{2 * 8, 28 + 16}, "Program ID:", Theme::getInstance()->fg_light->foreground},
|
{{2 * 8, 28 + 16}, "Program ID:", Theme::getInstance()->fg_light->foreground},
|
||||||
//{ { 13 * 8, 32 + 8 }, "Cov:",Theme::getInstance()->fg_light->foreground },
|
//{ { 13 * 8, 32 + 8 }, "Cov:",Theme::getInstance()->fg_light->foreground },
|
||||||
@@ -319,7 +319,7 @@ class RDSView : public View {
|
|||||||
"TP"};
|
"TP"};
|
||||||
|
|
||||||
TransmitterView tx_view{
|
TransmitterView tx_view{
|
||||||
16 * 16,
|
(int16_t)UI_POS_Y_BOTTOM(4),
|
||||||
50000,
|
50000,
|
||||||
9};
|
9};
|
||||||
|
|
||||||
|
|||||||
@@ -217,23 +217,24 @@ class ReconView : public View {
|
|||||||
std::unique_ptr<RecordView> record_view{};
|
std::unique_ptr<RecordView> record_view{};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 0 * 16}, "LNA: VGA: AMP: VOL: ", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), UI_POS_Y(0)}, "LNA: VGA: AMP: ", Theme::getInstance()->fg_light->foreground},
|
||||||
|
{{UI_POS_X_RIGHT(6), UI_POS_Y(0)}, "VOL: ", Theme::getInstance()->fg_light->foreground},
|
||||||
{{3 * 8, 8 * 16}, "START END", Theme::getInstance()->fg_light->foreground},
|
{{3 * 8, 8 * 16}, "START END", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, (22 * 8)}, " S: ", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), (22 * 8)}, " S: ", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, (24 * 8) + 4}, "NBLCKS:x W,L: , ", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), (24 * 8) + 4}, "NBLCKS:x W,L: , ", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, (26 * 8) + 4}, "MODE: , SQUELCH: ", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), (26 * 8) + 4}, "MODE: , SQUELCH: ", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{4 * 8, 0 * 16}};
|
{4 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{11 * 8, 0 * 16}};
|
{11 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{18 * 8, 0 * 16}};
|
{18 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{24 * 8, 0 * 16}};
|
{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
|
||||||
|
|
||||||
Text file_name{
|
Text file_name{
|
||||||
// show file used
|
// show file used
|
||||||
@@ -297,7 +298,7 @@ class ReconView : public View {
|
|||||||
"CONFIG"};
|
"CONFIG"};
|
||||||
|
|
||||||
ButtonWithEncoder button_manual_start{
|
ButtonWithEncoder button_manual_start{
|
||||||
{0 * 8, 9 * 16, 11 * 8, 28},
|
{UI_POS_X(0), 9 * 16, 11 * 8, 28},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
ButtonWithEncoder button_manual_end{
|
ButtonWithEncoder button_manual_end{
|
||||||
@@ -305,7 +306,7 @@ class ReconView : public View {
|
|||||||
""};
|
""};
|
||||||
|
|
||||||
OptionsField field_recon_match_mode{
|
OptionsField field_recon_match_mode{
|
||||||
{0 * 8, 11 * 16},
|
{UI_POS_X(0), 11 * 16},
|
||||||
16, // CONTINUOUS MATCH MODE / SPARSE TIMED MATCH MODE
|
16, // CONTINUOUS MATCH MODE / SPARSE TIMED MATCH MODE
|
||||||
{
|
{
|
||||||
{"MATCH:CONTINOUS", 0},
|
{"MATCH:CONTINOUS", 0},
|
||||||
@@ -363,15 +364,15 @@ class ReconView : public View {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ButtonWithEncoder button_pause{
|
ButtonWithEncoder button_pause{
|
||||||
{0, (15 * 16) - 4, 72, 28},
|
{0, (15 * 16) - 4, UI_POS_WIDTH(9), 28},
|
||||||
"PAUSE"};
|
"PAUSE"};
|
||||||
|
|
||||||
Button button_audio_app{
|
Button button_audio_app{
|
||||||
{84, (15 * 16) - 4, 72, 28},
|
{UI_POS_X_CENTER(9), (15 * 16) - 4, UI_POS_WIDTH(9), 28},
|
||||||
"AUDIO"};
|
"AUDIO"};
|
||||||
|
|
||||||
ButtonWithEncoder button_add{
|
ButtonWithEncoder button_add{
|
||||||
{168, (15 * 16) - 4, 72, 28},
|
{UI_POS_X_RIGHT(9), (15 * 16) - 4, UI_POS_WIDTH(9), 28},
|
||||||
"<STORE>"};
|
"<STORE>"};
|
||||||
|
|
||||||
Button button_dir{
|
Button button_dir{
|
||||||
@@ -383,15 +384,15 @@ class ReconView : public View {
|
|||||||
"RST"};
|
"RST"};
|
||||||
|
|
||||||
Button button_mic_app{
|
Button button_mic_app{
|
||||||
{84, (35 * 8) - 4, 72, 28},
|
{UI_POS_X_CENTER(9), (35 * 8) - 4, UI_POS_WIDTH(9), 28},
|
||||||
"MIC TX"};
|
"MIC TX"};
|
||||||
|
|
||||||
ButtonWithEncoder button_remove{
|
ButtonWithEncoder button_remove{
|
||||||
{168, (35 * 8) - 4, 72, 28},
|
{UI_POS_X_RIGHT(9), (35 * 8) - 4, UI_POS_WIDTH(9), 28},
|
||||||
"<REMOVE>"};
|
"<REMOVE>"};
|
||||||
|
|
||||||
ProgressBar progressbar{
|
ProgressBar progressbar{
|
||||||
{0 * 8, screen_height / 2 - 16, screen_width, 32}};
|
{UI_POS_X(0), screen_height / 2 - 16, screen_width, 32}};
|
||||||
|
|
||||||
TransmitterView2 tx_view{
|
TransmitterView2 tx_view{
|
||||||
{11 * 8, 2 * 16},
|
{11 * 8, 2 * 16},
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ class ReconSetupView : public View {
|
|||||||
{"More", Theme::getInstance()->fg_green->foreground, &viewMore}};
|
{"More", Theme::getInstance()->fg_green->foreground, &viewMore}};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{9 * 8, 255, 14 * 8, 40},
|
{UI_POS_X_CENTER(18), 255, UI_POS_WIDTH(18), 40},
|
||||||
"SAVE"};
|
"SAVE"};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,15 +46,15 @@ class SdOverUsbView : public View {
|
|||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{3 * 8, 2 * 16}, "Click Run to start the", Theme::getInstance()->bg_darkest->foreground},
|
{{UI_POS_X_CENTER(22), 2 * 16}, "Click Run to start the", Theme::getInstance()->bg_darkest->foreground},
|
||||||
{{3 * 8, 3 * 16}, "USB Mass Storage Mode.", Theme::getInstance()->bg_darkest->foreground},
|
{{UI_POS_X_CENTER(22), 3 * 16}, "USB Mass Storage Mode.", Theme::getInstance()->bg_darkest->foreground},
|
||||||
{{3 * 8, 5 * 16}, "It can take up to 20s", Theme::getInstance()->bg_darkest->foreground},
|
{{UI_POS_X_CENTER(21), 5 * 16}, "It can take up to 20s", Theme::getInstance()->bg_darkest->foreground},
|
||||||
{{3 * 8, 6 * 16}, "for the drive to be", Theme::getInstance()->bg_darkest->foreground},
|
{{UI_POS_X_CENTER(19), 6 * 16}, "for the drive to be", Theme::getInstance()->bg_darkest->foreground},
|
||||||
{{3 * 8, 7 * 16}, "available.", Theme::getInstance()->bg_darkest->foreground},
|
{{UI_POS_X_CENTER(10), 7 * 16}, "available.", Theme::getInstance()->bg_darkest->foreground},
|
||||||
};
|
};
|
||||||
|
|
||||||
Button button_run{
|
Button button_run{
|
||||||
{9 * 8, 15 * 16, 12 * 8, 3 * 16},
|
{UI_POS_X_CENTER(12), 15 * 16, 12 * 8, 3 * 16},
|
||||||
"Run"};
|
"Run"};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -26,17 +26,24 @@
|
|||||||
#include "binder.hpp"
|
#include "binder.hpp"
|
||||||
#include "string_format.hpp"
|
#include "string_format.hpp"
|
||||||
#include "ui_freqman.hpp"
|
#include "ui_freqman.hpp"
|
||||||
|
#include "audio.hpp"
|
||||||
|
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
|
namespace pmem = portapack::persistent_memory;
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
|
void SearchLogger::log_data(SearchRecentEntry& data) {
|
||||||
|
log_file.write_entry(";" + to_string_short_freq(data.frequency) + ";" + std::to_string(data.duration));
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void RecentEntriesTable<SearchRecentEntries>::draw(
|
void RecentEntriesTable<SearchRecentEntries>::draw(
|
||||||
const Entry& entry,
|
const Entry& entry,
|
||||||
const Rect& target_rect,
|
const Rect& target_rect,
|
||||||
Painter& painter,
|
Painter& painter,
|
||||||
const Style& style) {
|
const Style& style,
|
||||||
|
RecentEntriesColumns& columns) {
|
||||||
std::string str_duration = "";
|
std::string str_duration = "";
|
||||||
|
|
||||||
if (entry.duration < 600)
|
if (entry.duration < 600)
|
||||||
@@ -44,9 +51,10 @@ void RecentEntriesTable<SearchRecentEntries>::draw(
|
|||||||
else
|
else
|
||||||
str_duration = to_string_dec_uint(entry.duration / 600) + "m" + to_string_dec_uint((entry.duration / 10) % 60) + "s";
|
str_duration = to_string_dec_uint(entry.duration / 600) + "m" + to_string_dec_uint((entry.duration / 10) % 60) + "s";
|
||||||
|
|
||||||
str_duration.resize(target_rect.width() / 8, ' ');
|
str_duration.resize(11, ' ');
|
||||||
|
std::string freq = to_string_short_freq(entry.frequency);
|
||||||
painter.draw_string(target_rect.location(), style, to_string_short_freq(entry.frequency) + " " + entry.time + " " + str_duration);
|
freq.resize(columns.at(0).second, ' ');
|
||||||
|
painter.draw_string(target_rect.location(), style, freq + " " + entry.time + " " + str_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SearchView ********************************************/
|
/* SearchView ********************************************/
|
||||||
@@ -54,6 +62,7 @@ void RecentEntriesTable<SearchRecentEntries>::draw(
|
|||||||
SearchView::SearchView(
|
SearchView::SearchView(
|
||||||
NavigationView& nav)
|
NavigationView& nav)
|
||||||
: nav_(nav) {
|
: nav_(nav) {
|
||||||
|
spectrum_row.resize(240);
|
||||||
baseband::run_image(portapack::spi_flash::image_tag_wideband_spectrum);
|
baseband::run_image(portapack::spi_flash::image_tag_wideband_spectrum);
|
||||||
|
|
||||||
if (!gradient.load_file(default_gradient_file)) {
|
if (!gradient.load_file(default_gradient_file)) {
|
||||||
@@ -75,11 +84,12 @@ SearchView::SearchView(
|
|||||||
&check_snap,
|
&check_snap,
|
||||||
&options_snap,
|
&options_snap,
|
||||||
&big_display,
|
&big_display,
|
||||||
|
&check_log,
|
||||||
&recent_entries_view});
|
&recent_entries_view});
|
||||||
|
|
||||||
baseband::set_spectrum(SEARCH_SLICE_WIDTH, 31);
|
baseband::set_spectrum(SEARCH_SLICE_WIDTH, 31);
|
||||||
|
|
||||||
recent_entries_view.set_parent_rect({0, 28 * 8, screen_width, 12 * 8});
|
recent_entries_view.set_parent_rect({0, 28 * 8, screen_width, screen_height - 28 * 8});
|
||||||
recent_entries_view.on_select = [this, &nav](const SearchRecentEntry& entry) {
|
recent_entries_view.on_select = [this, &nav](const SearchRecentEntry& entry) {
|
||||||
nav.push<FrequencySaveView>(entry.frequency);
|
nav.push<FrequencySaveView>(entry.frequency);
|
||||||
};
|
};
|
||||||
@@ -100,6 +110,14 @@ SearchView::SearchView(
|
|||||||
on_range_changed();
|
on_range_changed();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
check_log.on_select = [this](Checkbox&, bool v) {
|
||||||
|
logging = v;
|
||||||
|
if (logging) {
|
||||||
|
logger.append(logs_dir.string() + "/SEARCH_" + to_string_timestamp(rtc_time::now()) + ".CSV");
|
||||||
|
logger.write_header();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
bind(field_threshold, settings_.power_threshold);
|
bind(field_threshold, settings_.power_threshold);
|
||||||
bind(check_snap, settings_.snap_search);
|
bind(check_snap, settings_.snap_search);
|
||||||
bind(options_snap, settings_.snap_step);
|
bind(options_snap, settings_.snap_step);
|
||||||
@@ -108,9 +126,15 @@ SearchView::SearchView(
|
|||||||
|
|
||||||
on_range_changed();
|
on_range_changed();
|
||||||
receiver_model.enable();
|
receiver_model.enable();
|
||||||
|
|
||||||
|
if (pmem::beep_on_packets()) {
|
||||||
|
audio::set_rate(audio::Rate::Hz_24000);
|
||||||
|
audio::output::start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchView::~SearchView() {
|
SearchView::~SearchView() {
|
||||||
|
audio::output::stop();
|
||||||
receiver_model.disable();
|
receiver_model.disable();
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
@@ -139,9 +163,8 @@ void SearchView::do_detection() {
|
|||||||
// Display spectrum
|
// Display spectrum
|
||||||
bin_skip_acc = 0;
|
bin_skip_acc = 0;
|
||||||
pixel_index = 0;
|
pixel_index = 0;
|
||||||
display.draw_pixels(
|
uint16_t center_align_start = (screen_width - spectrum_row.size()) / 2;
|
||||||
{{0, 88}, {(Dim)spectrum_row.size(), 1}},
|
display.draw_pixels({{center_align_start, 88}, {(Dim)spectrum_row.size(), 1}}, spectrum_row);
|
||||||
spectrum_row);
|
|
||||||
|
|
||||||
mean_power = mean_acc / (SEARCH_BIN_NB_NO_DC * slices_nb);
|
mean_power = mean_acc / (SEARCH_BIN_NB_NO_DC * slices_nb);
|
||||||
mean_acc = 0;
|
mean_acc = 0;
|
||||||
@@ -192,7 +215,9 @@ void SearchView::do_detection() {
|
|||||||
|
|
||||||
locked = true;
|
locked = true;
|
||||||
locked_bin = bin_max;
|
locked_bin = bin_max;
|
||||||
|
if (pmem::beep_on_packets()) {
|
||||||
|
baseband::request_audio_beep(1000, 24000, 60);
|
||||||
|
}
|
||||||
// TODO: open Audio.
|
// TODO: open Audio.
|
||||||
} else
|
} else
|
||||||
text_infos.set("Out of range");
|
text_infos.set("Out of range");
|
||||||
@@ -210,6 +235,7 @@ void SearchView::do_detection() {
|
|||||||
|
|
||||||
auto& entry = ::on_packet(recent, resolved_frequency);
|
auto& entry = ::on_packet(recent, resolved_frequency);
|
||||||
entry.set_duration(duration);
|
entry.set_duration(duration);
|
||||||
|
if (logging) logger.log_data(entry);
|
||||||
recent_entries_view.set_dirty();
|
recent_entries_view.set_dirty();
|
||||||
|
|
||||||
text_infos.set("Listening");
|
text_infos.set("Listening");
|
||||||
@@ -225,7 +251,7 @@ void SearchView::do_detection() {
|
|||||||
// Refresh red tick
|
// Refresh red tick
|
||||||
portapack::display.fill_rectangle({last_tick_pos, 90, 1, 6}, Theme::getInstance()->fg_red->background);
|
portapack::display.fill_rectangle({last_tick_pos, 90, 1, 6}, Theme::getInstance()->fg_red->background);
|
||||||
if (bin_max > -1) {
|
if (bin_max > -1) {
|
||||||
last_tick_pos = (Coord)(bin_max / slices_nb);
|
last_tick_pos = (Coord)(bin_max / slices_nb) + center_align_start;
|
||||||
portapack::display.fill_rectangle({last_tick_pos, 90, 1, 6}, Theme::getInstance()->fg_red->foreground);
|
portapack::display.fill_rectangle({last_tick_pos, 90, 1, 6}, Theme::getInstance()->fg_red->foreground);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,7 +400,7 @@ void SearchView::add_spectrum_pixel(Color color) {
|
|||||||
|
|
||||||
bin_skip_acc -= 0x10000;
|
bin_skip_acc -= 0x10000;
|
||||||
|
|
||||||
if (pixel_index < screen_width)
|
if (pixel_index < spectrum_row.size())
|
||||||
spectrum_row[pixel_index++] = color;
|
spectrum_row[pixel_index++] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
#include "radio_state.hpp"
|
#include "radio_state.hpp"
|
||||||
#include "gradient.hpp"
|
#include "gradient.hpp"
|
||||||
#include "ui_receiver.hpp"
|
#include "ui_receiver.hpp"
|
||||||
|
#include "log_file.hpp"
|
||||||
|
#include "file_path.hpp"
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
@@ -70,6 +72,21 @@ struct SearchRecentEntry {
|
|||||||
|
|
||||||
using SearchRecentEntries = RecentEntries<SearchRecentEntry>;
|
using SearchRecentEntries = RecentEntries<SearchRecentEntry>;
|
||||||
|
|
||||||
|
class SearchLogger {
|
||||||
|
public:
|
||||||
|
Optional<File::Error> append(const std::filesystem::path& filename) {
|
||||||
|
return log_file.append(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void log_data(SearchRecentEntry& data);
|
||||||
|
void write_header() {
|
||||||
|
log_file.write_raw("Time;Freq;Duration;");
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
LogFile log_file{};
|
||||||
|
};
|
||||||
|
|
||||||
class SearchView : public View {
|
class SearchView : public View {
|
||||||
public:
|
public:
|
||||||
SearchView(NavigationView& nav);
|
SearchView(NavigationView& nav);
|
||||||
@@ -126,7 +143,7 @@ class SearchView : public View {
|
|||||||
uint32_t bin_skip_acc = 0;
|
uint32_t bin_skip_acc = 0;
|
||||||
uint32_t bin_skip_frac = 0;
|
uint32_t bin_skip_frac = 0;
|
||||||
uint32_t pixel_index = 0;
|
uint32_t pixel_index = 0;
|
||||||
std::array<Color, 240> spectrum_row{};
|
std::vector<Color> spectrum_row{};
|
||||||
ChannelSpectrumFIFO* fifo = nullptr;
|
ChannelSpectrumFIFO* fifo = nullptr;
|
||||||
|
|
||||||
uint8_t detect_timer = 0;
|
uint8_t detect_timer = 0;
|
||||||
@@ -148,6 +165,8 @@ class SearchView : public View {
|
|||||||
uint16_t locked_bin = 0;
|
uint16_t locked_bin = 0;
|
||||||
uint8_t search_counter = 0;
|
uint8_t search_counter = 0;
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
|
bool logging = false;
|
||||||
|
SearchLogger logger{};
|
||||||
|
|
||||||
void do_detection();
|
void do_detection();
|
||||||
void do_timers();
|
void do_timers();
|
||||||
@@ -155,75 +174,82 @@ class SearchView : public View {
|
|||||||
void on_range_changed();
|
void on_range_changed();
|
||||||
void add_spectrum_pixel(Color color);
|
void add_spectrum_pixel(Color color);
|
||||||
|
|
||||||
const RecentEntriesColumns columns{{{"Frequency", 9},
|
RecentEntriesColumns columns{{{"Frequency", 0},
|
||||||
{"Time", 8},
|
{"Time", 8},
|
||||||
{"Duration", 11}}};
|
{"Duration", 11}}};
|
||||||
SearchRecentEntries recent{};
|
SearchRecentEntries recent{};
|
||||||
RecentEntriesView<RecentEntries<SearchRecentEntry>> recent_entries_view{columns, recent};
|
RecentEntriesView<RecentEntries<SearchRecentEntry>> recent_entries_view{columns, recent};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{1 * 8, 0}, "Min: Max: LNA VGA", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(1), UI_POS_Y(0)}, "Min: Max: ", Theme::getInstance()->fg_light->foreground},
|
||||||
{{1 * 8, 4 * 8}, "Trig: /255 Mean: /255", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X_RIGHT(7), UI_POS_Y(0)}, "LNA VGA", Theme::getInstance()->fg_light->foreground},
|
||||||
{{1 * 8, 6 * 8}, "Slices: /32 Rate: Hz", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(1), UI_POS_Y(2)}, "Trig: /255", Theme::getInstance()->fg_light->foreground},
|
||||||
{{6 * 8, 10 * 8}, "Timer Status", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X_RIGHT(12), UI_POS_Y(2)}, "Mean: /255", Theme::getInstance()->fg_light->foreground},
|
||||||
{{1 * 8, 25 * 8}, "Accuracy +/-4.9kHz", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(1), UI_POS_Y(3)}, "Slices: /32", Theme::getInstance()->fg_light->foreground},
|
||||||
{{26 * 8, 25 * 8}, "MHz", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X_RIGHT(10), UI_POS_Y(3)}, "Rate: Hz", Theme::getInstance()->fg_light->foreground},
|
||||||
|
{{UI_POS_X(6), UI_POS_Y(5)}, "Timer Status", Theme::getInstance()->fg_light->foreground},
|
||||||
|
{{UI_POS_X(1), 25 * 8}, "Accuracy +/-4.9kHz", Theme::getInstance()->fg_light->foreground},
|
||||||
|
{{UI_POS_X_RIGHT(4), 25 * 8}, "MHz", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
|
Checkbox check_log{
|
||||||
|
{UI_POS_X_RIGHT(6), UI_POS_Y(5)},
|
||||||
|
3,
|
||||||
|
"LOG",
|
||||||
|
true};
|
||||||
|
|
||||||
FrequencyField field_frequency_min{
|
FrequencyField field_frequency_min{
|
||||||
{1 * 8, 1 * 16}};
|
{UI_POS_X(1), UI_POS_Y(1)}};
|
||||||
FrequencyField field_frequency_max{
|
FrequencyField field_frequency_max{
|
||||||
{11 * 8, 1 * 16}};
|
{UI_POS_X(11), UI_POS_Y(1)}};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{22 * 8, 1 * 16}};
|
{UI_POS_X_RIGHT(7), UI_POS_Y(1)}};
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{26 * 8, 1 * 16}};
|
{UI_POS_X_RIGHT(3), UI_POS_Y(1)}};
|
||||||
|
|
||||||
NumberField field_threshold{
|
NumberField field_threshold{
|
||||||
{6 * 8, 2 * 16},
|
{UI_POS_X(6), UI_POS_Y(2)},
|
||||||
3,
|
3,
|
||||||
{5, 255},
|
{5, 255},
|
||||||
5,
|
5,
|
||||||
' '};
|
' '};
|
||||||
Text text_mean{
|
Text text_mean{
|
||||||
{22 * 8, 2 * 16, 3 * 8, 16},
|
{UI_POS_X_RIGHT(7), UI_POS_Y(2), UI_POS_WIDTH(3), UI_POS_HEIGHT(1)},
|
||||||
"---"};
|
"---"};
|
||||||
Text text_slices{
|
Text text_slices{
|
||||||
{8 * 8, 3 * 16, 2 * 8, 16},
|
{UI_POS_X(8), UI_POS_Y(3), UI_POS_WIDTH(2), UI_POS_HEIGHT(1)},
|
||||||
"--"};
|
"--"};
|
||||||
Text text_rate{
|
Text text_rate{
|
||||||
{24 * 8, 3 * 16, 3 * 8, 16},
|
{UI_POS_X_RIGHT(5), UI_POS_Y(3), UI_POS_WIDTH(3), UI_POS_HEIGHT(1)},
|
||||||
"---"};
|
"---"};
|
||||||
|
|
||||||
VuMeter vu_max{
|
VuMeter vu_max{
|
||||||
{1 * 8, 11 * 8 - 4, 3 * 8, 48},
|
{UI_POS_X(1), 11 * 8 - 4, 3 * 8, 48},
|
||||||
18,
|
18,
|
||||||
false};
|
false};
|
||||||
|
|
||||||
ProgressBar progress_timers{
|
ProgressBar progress_timers{
|
||||||
{6 * 8, 12 * 8, 6 * 8, 16}};
|
{UI_POS_X(6), UI_POS_Y(6), UI_POS_WIDTH(6), UI_POS_HEIGHT(1)}};
|
||||||
Text text_infos{
|
Text text_infos{
|
||||||
{13 * 8, 12 * 8, 15 * 8, 16},
|
{UI_POS_X(13), UI_POS_Y(6), UI_POS_WIDTH(15), UI_POS_HEIGHT(1)},
|
||||||
"Listening"};
|
"Listening"};
|
||||||
|
|
||||||
Checkbox check_snap{
|
Checkbox check_snap{
|
||||||
{6 * 8, 15 * 8},
|
{UI_POS_X(6), 15 * 8},
|
||||||
7,
|
7,
|
||||||
"Snap to:",
|
"Snap to:",
|
||||||
true};
|
true};
|
||||||
OptionsField options_snap{
|
OptionsField options_snap{
|
||||||
{17 * 8, 15 * 8}, // Position
|
{UI_POS_X(17), 15 * 8}, // Position
|
||||||
7, // Length
|
7, // Length
|
||||||
{ // Options
|
{ // Options
|
||||||
{"25kHz ", 25'000},
|
{"25kHz ", 25'000},
|
||||||
{"12.5kHz", 12'500},
|
{"12.5kHz", 12'500},
|
||||||
{"8.33kHz", 8'333},
|
{"8.33kHz", 8'333},
|
||||||
{"2.5kHz", 2'500},
|
{"2.5kHz", 2'500},
|
||||||
{"500Hz", 500}}};
|
{"500Hz", 500}}};
|
||||||
|
|
||||||
BigFrequency big_display{
|
BigFrequency big_display{{UI_POS_X_CENTER(28), UI_POS_Y(9), UI_POS_WIDTH(28), 52}, 0};
|
||||||
{4, 9 * 16, 28 * 8, 52},
|
|
||||||
0};
|
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_spectrum_config{
|
MessageHandlerRegistration message_handler_spectrum_config{
|
||||||
Message::ID::ChannelSpectrumConfig,
|
Message::ID::ChannelSpectrumConfig,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* Copyright (C) 2024 Mark Thompson
|
* Copyright (C) 2024 Mark Thompson
|
||||||
* Copyright (C) 2024 u-foka
|
* Copyright (C) 2024 u-foka
|
||||||
* Copyright (C) 2024 HTotoo
|
* Copyright (C) 2024 HTotoo
|
||||||
* Copyleft (ɔ) 2024 zxkmm under GPL license
|
* copyleft 2024 zxkmm AKA zix aka sommermorgentraum
|
||||||
*
|
*
|
||||||
* This file is part of PortaPack.
|
* This file is part of PortaPack.
|
||||||
*
|
*
|
||||||
@@ -40,6 +40,7 @@ using namespace lpc43xx;
|
|||||||
|
|
||||||
#include "audio.hpp"
|
#include "audio.hpp"
|
||||||
#include "portapack.hpp"
|
#include "portapack.hpp"
|
||||||
|
#include "portapack_io.hpp"
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
|
|
||||||
#include "file.hpp"
|
#include "file.hpp"
|
||||||
@@ -759,7 +760,7 @@ AppSettingsView::AppSettingsView(
|
|||||||
add_children({&labels,
|
add_children({&labels,
|
||||||
&menu_view});
|
&menu_view});
|
||||||
|
|
||||||
menu_view.set_parent_rect({0, 3 * 8, screen_width, 33 * 8});
|
menu_view.set_parent_rect({0, 3 * 8, screen_width, UI_POS_HEIGHT_REMAINING(3)});
|
||||||
|
|
||||||
ensure_directory(settings_dir);
|
ensure_directory(settings_dir);
|
||||||
|
|
||||||
@@ -810,9 +811,12 @@ SetDisplayView::SetDisplayView(NavigationView& nav) {
|
|||||||
&field_fake_brightness,
|
&field_fake_brightness,
|
||||||
&button_save,
|
&button_save,
|
||||||
&button_cancel,
|
&button_cancel,
|
||||||
&checkbox_ips_screen_switch,
|
|
||||||
&checkbox_brightness_switch});
|
&checkbox_brightness_switch});
|
||||||
|
|
||||||
|
if (portapack::device_type == portapack::DeviceType::DEV_PORTAPACK) {
|
||||||
|
add_child(&checkbox_ips_screen_switch);
|
||||||
|
}
|
||||||
|
|
||||||
field_fake_brightness.set_by_value(pmem::fake_brightness_level());
|
field_fake_brightness.set_by_value(pmem::fake_brightness_level());
|
||||||
checkbox_brightness_switch.set_value(pmem::apply_fake_brightness());
|
checkbox_brightness_switch.set_value(pmem::apply_fake_brightness());
|
||||||
checkbox_ips_screen_switch.set_value(pmem::config_lcd_normally_black());
|
checkbox_ips_screen_switch.set_value(pmem::config_lcd_normally_black());
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Copyright (C) 2023 Kyle Reed
|
* Copyright (C) 2023 Kyle Reed
|
||||||
* Copyright (C) 2024 Mark Thompson
|
* Copyright (C) 2024 Mark Thompson
|
||||||
* Copyright (C) 2024 u-foka
|
* Copyright (C) 2024 u-foka
|
||||||
* Copyleft (ɔ) 2024 zxkmm under GPL license
|
* copyleft 2024 zxkmm AKA zix aka sommermorgentraum
|
||||||
*
|
*
|
||||||
* This file is part of PortaPack.
|
* This file is part of PortaPack.
|
||||||
*
|
*
|
||||||
@@ -72,8 +72,8 @@ class SetDateTimeView : public View {
|
|||||||
{{1 * 8, 5 * 16 - 2}, "YYYY-MM-DD HH:MM:SS DoW DoY", Theme::getInstance()->fg_medium->foreground},
|
{{1 * 8, 5 * 16 - 2}, "YYYY-MM-DD HH:MM:SS DoW DoY", Theme::getInstance()->fg_medium->foreground},
|
||||||
{{5 * 8, 6 * 16}, "- - : :", Theme::getInstance()->fg_light->foreground},
|
{{5 * 8, 6 * 16}, "- - : :", Theme::getInstance()->fg_light->foreground},
|
||||||
{{1 * 8, 11 * 16}, "DST adds 1 hour to RTC time.", Theme::getInstance()->fg_light->foreground},
|
{{1 * 8, 11 * 16}, "DST adds 1 hour to RTC time.", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 12 * 16}, "Start: 0:00 on Nth DDD in", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 12 * 16}, "Start: 0:00 on Nth DDD in", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 13 * 16}, "End: 1:00 on Nth DDD in", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 13 * 16}, "End: 1:00 on Nth DDD in", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
NumberField field_year{
|
NumberField field_year{
|
||||||
{1 * 8, 6 * 16},
|
{1 * 8, 6 * 16},
|
||||||
@@ -170,10 +170,10 @@ class SetDateTimeView : public View {
|
|||||||
{}};
|
{}};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Save"};
|
"Save"};
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Cancel"};
|
"Cancel"};
|
||||||
|
|
||||||
void form_init(const SetDateTimeModel& model);
|
void form_init(const SetDateTimeModel& model);
|
||||||
@@ -253,10 +253,10 @@ class SetRadioView : public View {
|
|||||||
"Disable external TCXO"};
|
"Disable external TCXO"};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Save"};
|
"Save"};
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Cancel",
|
"Cancel",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -372,11 +372,11 @@ class SetUIView : public View {
|
|||||||
&bitmap_sd_card_ok};
|
&bitmap_sd_card_ok};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Save"};
|
"Save"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(16) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Cancel"};
|
"Cancel"};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -391,28 +391,28 @@ class SetSDCardView : public View {
|
|||||||
private:
|
private:
|
||||||
Labels labels{
|
Labels labels{
|
||||||
// 01234567890123456789012345678
|
// 01234567890123456789012345678
|
||||||
{{1 * 8, 120 - 48}, " HIGH SPEED SDCARD IO ", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X_CENTER(26), 120 - 48}, " HIGH SPEED SDCARD IO ", Theme::getInstance()->fg_light->foreground},
|
||||||
{{1 * 8, 120 - 32}, " May or may not work !! ", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X_CENTER(26), 120 - 32}, " May or may not work !! ", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Checkbox checkbox_sdcard_speed{
|
Checkbox checkbox_sdcard_speed{
|
||||||
{2 * 8, 120},
|
{UI_POS_X_CENTER(26), 120},
|
||||||
20,
|
20,
|
||||||
"enable high speed IO"};
|
"enable high speed IO"};
|
||||||
|
|
||||||
Button button_test_sdcard_high_speed{
|
Button button_test_sdcard_high_speed{
|
||||||
{2 * 8, 152, 27 * 8, 32},
|
{UI_POS_X_CENTER(27), 152, UI_POS_WIDTH(27), UI_POS_HEIGHT(2)},
|
||||||
"TEST BUTTON (NO PMEM SAVE)"};
|
"TEST BUTTON (NO PMEM SAVE)"};
|
||||||
|
|
||||||
Text text_sdcard_test_status{
|
Text text_sdcard_test_status{
|
||||||
{2 * 8, 198, 28 * 8, 16},
|
{UI_POS_X_CENTER(28), 198, UI_POS_WIDTH(28), UI_POS_HEIGHT(1)},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Save"};
|
"Save"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(16) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Cancel"};
|
"Cancel"};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -455,7 +455,7 @@ class SetConverterSettingsView : public View {
|
|||||||
{8 * 8, 10 * 16}};
|
{8 * 8, 10 * 16}};
|
||||||
|
|
||||||
Button button_return{
|
Button button_return{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Return",
|
"Return",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -498,7 +498,7 @@ class SetFrequencyCorrectionView : public View {
|
|||||||
{8 * 8, 10 * 16}};
|
{8 * 8, 10 * 16}};
|
||||||
|
|
||||||
Button button_return{
|
Button button_return{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12), UI_POS_Y_BOTTOM(4), 12 * 8, UI_POS_HEIGHT(2)},
|
||||||
"Return",
|
"Return",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -536,11 +536,11 @@ class SetAudioView : public View {
|
|||||||
"Beep on RX packets"};
|
"Beep on RX packets"};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Save"};
|
"Save"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Cancel",
|
"Cancel",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -559,11 +559,11 @@ class SetEncoderDialView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 0 * 16}, "Sensitivity to dial rotation", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), UI_POS_Y(0)}, "Sensitivity to dial rotation", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 1 * 16}, "position (x steps per 360):", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 1 * 16}, "position (x steps per 360):", Theme::getInstance()->fg_light->foreground},
|
||||||
{{1 * 8, 3 * 16}, "Sensitivity:", Theme::getInstance()->fg_light->foreground},
|
{{1 * 8, 3 * 16}, "Sensitivity:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 7 * 16}, "Rotation rate (default 1", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 7 * 16}, "Rotation rate (default 1", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 8 * 16}, "means no rate dependency):", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 8 * 16}, "means no rate dependency):", Theme::getInstance()->fg_light->foreground},
|
||||||
{{2 * 8, 10 * 16}, "Rate multiplier:", Theme::getInstance()->fg_light->foreground},
|
{{2 * 8, 10 * 16}, "Rate multiplier:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{4 * 8, 14 * 16}, "Direction:", Theme::getInstance()->fg_light->foreground},
|
{{4 * 8, 14 * 16}, "Direction:", Theme::getInstance()->fg_light->foreground},
|
||||||
|
|
||||||
@@ -606,11 +606,11 @@ class SetEncoderDialView : public View {
|
|||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Save"};
|
"Save"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Cancel",
|
"Cancel",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -649,11 +649,11 @@ class SetButtonsView : public View {
|
|||||||
{"FAST", true}}};
|
{"FAST", true}}};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Save"};
|
"Save"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Cancel",
|
"Cancel",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -674,7 +674,7 @@ class SetPersistentMemoryView : public View {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Text text_pmem_status{
|
Text text_pmem_status{
|
||||||
{1 * 8, 4 * 16 + 8, 28 * 8, 16},
|
{UI_POS_X_CENTER(28), 4 * 16 + 8, 28 * 8, 16},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
Checkbox check_use_sdcard_for_pmem{
|
Checkbox check_use_sdcard_for_pmem{
|
||||||
@@ -683,19 +683,19 @@ class SetPersistentMemoryView : public View {
|
|||||||
"Use SD card for P.Mem"};
|
"Use SD card for P.Mem"};
|
||||||
|
|
||||||
Button button_save_mem_to_file{
|
Button button_save_mem_to_file{
|
||||||
{1 * 8, 8 * 16, 28 * 8, 2 * 16},
|
{UI_POS_X_CENTER(28), 8 * 16, 28 * 8, 2 * 16},
|
||||||
"Save P.Mem to SD card"};
|
"Save P.Mem to SD card"};
|
||||||
|
|
||||||
Button button_load_mem_from_file{
|
Button button_load_mem_from_file{
|
||||||
{1 * 8, 10 * 16 + 2, 28 * 8, 2 * 16},
|
{UI_POS_X_CENTER(28), 10 * 16 + 2, 28 * 8, 2 * 16},
|
||||||
"Load P.Mem from SD Card"};
|
"Load P.Mem from SD Card"};
|
||||||
|
|
||||||
Button button_load_mem_defaults{
|
Button button_load_mem_defaults{
|
||||||
{1 * 8, 12 * 16 + 4, 28 * 8, 2 * 16},
|
{UI_POS_X_CENTER(28), 12 * 16 + 4, 28 * 8, 2 * 16},
|
||||||
"Reset P.Mem to defaults"};
|
"Reset P.Mem to defaults"};
|
||||||
|
|
||||||
Button button_return{
|
Button button_return{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Return",
|
"Return",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -713,7 +713,7 @@ class AppSettingsView : public View {
|
|||||||
{{0, 4}, "Select file to edit:", Theme::getInstance()->bg_darkest->foreground}};
|
{{0, 4}, "Select file to edit:", Theme::getInstance()->bg_darkest->foreground}};
|
||||||
|
|
||||||
MenuView menu_view{
|
MenuView menu_view{
|
||||||
{0, 2 * 8, screen_width, 26 * 8},
|
{0, 2 * 8, screen_width, UI_POS_HEIGHT_REMAINING(3)},
|
||||||
true};
|
true};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -738,11 +738,11 @@ class SetConfigModeView : public View {
|
|||||||
"Config Mode enable"};
|
"Config Mode enable"};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Save"};
|
"Save"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 32},
|
||||||
"Cancel",
|
"Cancel",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -784,11 +784,11 @@ class SetDisplayView : public View {
|
|||||||
"IPS Screen"};
|
"IPS Screen"};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Save"};
|
"Save"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(16) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Cancel",
|
"Cancel",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -841,19 +841,19 @@ class SetTouchscreenThresholdView : public View {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Button button_autodetect{
|
Button button_autodetect{
|
||||||
{2 * 8, 13 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), 13 * 16, 12 * 8, 32},
|
||||||
"Auto Detect"};
|
"Auto Detect"};
|
||||||
Button button_reset{
|
Button button_reset{
|
||||||
{16 * 8, 13 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), 13 * 16, 12 * 8, 32},
|
||||||
"Reset",
|
"Reset",
|
||||||
};
|
};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), 16 * 16, 12 * 8, 32},
|
||||||
"Save"};
|
"Save"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), 16 * 16, 12 * 8, 32},
|
||||||
"Cancel",
|
"Cancel",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -876,14 +876,14 @@ class SetMenuColorView : public View {
|
|||||||
void paint_sample();
|
void paint_sample();
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{3 * 8, 1 * 16}, "Menu Button Color Scheme", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X_CENTER(25), 1 * 16}, "Menu Button Color Scheme", Theme::getInstance()->fg_light->foreground},
|
||||||
{{2 * 8, 8 * 16}, "Red Level:", Theme::getInstance()->fg_light->foreground},
|
{{2 * 8, 8 * 16}, "Red Level:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{2 * 8, 9 * 16}, "Green Level:", Theme::getInstance()->fg_light->foreground},
|
{{2 * 8, 9 * 16}, "Green Level:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{2 * 8, 10 * 16}, "Blue Level:", Theme::getInstance()->fg_light->foreground},
|
{{2 * 8, 10 * 16}, "Blue Level:", Theme::getInstance()->fg_light->foreground},
|
||||||
};
|
};
|
||||||
|
|
||||||
NewButton button_sample{
|
NewButton button_sample{
|
||||||
{8 * 8, 4 * 16, 14 * 8, 3 * 16},
|
{UI_POS_X_CENTER(14), 4 * 16, 14 * 8, 3 * 16},
|
||||||
"New Color",
|
"New Color",
|
||||||
&bitmap_icon_brightness,
|
&bitmap_icon_brightness,
|
||||||
};
|
};
|
||||||
@@ -913,16 +913,16 @@ class SetMenuColorView : public View {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Button button_reset{
|
Button button_reset{
|
||||||
{2 * 8, 13 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(7), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Reset",
|
"Reset",
|
||||||
};
|
};
|
||||||
|
|
||||||
Button button_save{
|
Button button_save{
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Save"};
|
"Save"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Cancel",
|
"Cancel",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -941,12 +941,8 @@ class SetThemeView : public View {
|
|||||||
{{1 * 8, 1 * 16}, "Select a theme.", Theme::getInstance()->fg_light->foreground},
|
{{1 * 8, 1 * 16}, "Select a theme.", Theme::getInstance()->fg_light->foreground},
|
||||||
{{1 * 8, 2 * 16}, "Restart PP to fully apply!", Theme::getInstance()->fg_light->foreground}};
|
{{1 * 8, 2 * 16}, "Restart PP to fully apply!", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Button button_save{
|
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
|
||||||
"Save"};
|
|
||||||
|
|
||||||
OptionsField options{
|
OptionsField options{
|
||||||
{0 * 8, 4 * 16},
|
{UI_POS_X(0), 4 * 16},
|
||||||
(size_t)(screen_width / 8),
|
(size_t)(screen_width / 8),
|
||||||
{
|
{
|
||||||
{"Default - Grey", 0},
|
{"Default - Grey", 0},
|
||||||
@@ -963,8 +959,12 @@ class SetThemeView : public View {
|
|||||||
23,
|
23,
|
||||||
"Set Menu color too"};
|
"Set Menu color too"};
|
||||||
|
|
||||||
|
Button button_save{
|
||||||
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
|
"Save"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Cancel",
|
"Cancel",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -988,10 +988,6 @@ class SetBatteryView : public View {
|
|||||||
|
|
||||||
Labels labels2{{{1 * 8, 11 * 16}, "Reset IC's learned params.", Theme::getInstance()->fg_light->foreground}};
|
Labels labels2{{{1 * 8, 11 * 16}, "Reset IC's learned params.", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
Button button_save{
|
|
||||||
{2 * 8, 16 * 16, 12 * 8, 32},
|
|
||||||
"Save"};
|
|
||||||
|
|
||||||
Checkbox checkbox_overridebatt{
|
Checkbox checkbox_overridebatt{
|
||||||
{2 * 8, 4 * 16},
|
{2 * 8, 4 * 16},
|
||||||
23,
|
23,
|
||||||
@@ -1003,12 +999,16 @@ class SetBatteryView : public View {
|
|||||||
"Charge hint"};
|
"Charge hint"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{16 * 8, 16 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Cancel",
|
"Cancel",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Button button_save{
|
||||||
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
|
"Save"};
|
||||||
|
|
||||||
Button button_reset{
|
Button button_reset{
|
||||||
{2 * 8, 13 * 16, 12 * 8, 32},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y(13), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
"Reset",
|
"Reset",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class SigGenView : public View {
|
|||||||
{"Pulse CW 25%", 7}}};
|
{"Pulse CW 25%", 7}}};
|
||||||
|
|
||||||
TransmitterView tx_view{
|
TransmitterView tx_view{
|
||||||
16 * 16,
|
(int16_t)UI_POS_Y_BOTTOM(4),
|
||||||
10000,
|
10000,
|
||||||
12};
|
12};
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ SondeView::SondeView(NavigationView& nav)
|
|||||||
&field_lna,
|
&field_lna,
|
||||||
&field_vga,
|
&field_vga,
|
||||||
&rssi,
|
&rssi,
|
||||||
|
&channel,
|
||||||
&field_volume,
|
&field_volume,
|
||||||
&check_log,
|
&check_log,
|
||||||
&check_crc,
|
&check_crc,
|
||||||
|
|||||||
@@ -96,39 +96,42 @@ class SondeView : public View {
|
|||||||
Labels labels{
|
Labels labels{
|
||||||
{{4 * 8, 2 * 16}, "Type:", Theme::getInstance()->fg_light->foreground},
|
{{4 * 8, 2 * 16}, "Type:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{6 * 8, 3 * 16}, "ID:", Theme::getInstance()->fg_light->foreground},
|
{{6 * 8, 3 * 16}, "ID:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 4 * 16}, "DateTime:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 4 * 16}, "DateTime:", Theme::getInstance()->fg_light->foreground},
|
||||||
|
|
||||||
{{3 * 8, 5 * 16}, "Vbatt:", Theme::getInstance()->fg_light->foreground},
|
{{3 * 8, 5 * 16}, "Vbatt:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{3 * 8, 6 * 16}, "Frame:", Theme::getInstance()->fg_light->foreground},
|
{{3 * 8, 6 * 16}, "Frame:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{4 * 8, 7 * 16}, "Temp:", Theme::getInstance()->fg_light->foreground},
|
{{4 * 8, 7 * 16}, "Temp:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 8 * 16}, "Humidity:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 8 * 16}, "Humidity:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 8},
|
{UI_POS_X(0), 0 * 8},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{13 * 8, 0 * 16}};
|
{13 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{15 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{18 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4}};
|
{21 * 8, 0, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||||
|
Channel channel{
|
||||||
|
{21 * 8, 5, UI_POS_WIDTH_REMAINING(24), 4},
|
||||||
|
};
|
||||||
|
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{screen_width - 2 * 8, 0 * 16}};
|
{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
|
||||||
|
|
||||||
Checkbox check_log{
|
Checkbox check_log{
|
||||||
{22 * 8, 8 * 16},
|
{UI_POS_X_RIGHT(8), UI_POS_Y(8)},
|
||||||
3,
|
3,
|
||||||
"Log"};
|
"Log"};
|
||||||
|
|
||||||
Checkbox check_crc{
|
Checkbox check_crc{
|
||||||
{22 * 8, 10 * 16},
|
{UI_POS_X_RIGHT(8), UI_POS_Y(10)},
|
||||||
3,
|
3,
|
||||||
"CRC"};
|
"CRC"};
|
||||||
|
|
||||||
@@ -166,11 +169,11 @@ class SondeView : public View {
|
|||||||
GeoPos::spd_unit::HIDDEN};
|
GeoPos::spd_unit::HIDDEN};
|
||||||
|
|
||||||
Button button_see_qr{
|
Button button_see_qr{
|
||||||
{2 * 8, 15 * 16, 12 * 8, 3 * 16},
|
{UI_POS_X_CENTER(12) - UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 3 * 16},
|
||||||
"See QR"};
|
"See QR"};
|
||||||
|
|
||||||
Button button_see_map{
|
Button button_see_map{
|
||||||
{16 * 8, 15 * 16, 12 * 8, 3 * 16},
|
{UI_POS_X_CENTER(12) + UI_POS_WIDTH(8), UI_POS_Y_BOTTOM(4), 12 * 8, 3 * 16},
|
||||||
"See on map"};
|
"See on map"};
|
||||||
|
|
||||||
GeoMapView* geomap_view_{nullptr};
|
GeoMapView* geomap_view_{nullptr};
|
||||||
|
|||||||
@@ -27,6 +27,9 @@
|
|||||||
|
|
||||||
#include "ui_font_fixed_5x8.hpp"
|
#include "ui_font_fixed_5x8.hpp"
|
||||||
#include "ui_font_fixed_8x16.hpp"
|
#include "ui_font_fixed_8x16.hpp"
|
||||||
|
#include "portapack.hpp"
|
||||||
|
|
||||||
|
#include "file.hpp"
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
@@ -93,8 +96,90 @@ bool i2c_read(uint8_t* cmd, size_t cmd_len, uint8_t* data, size_t data_len) {
|
|||||||
return dev->i2c_read(cmd, cmd_len, data, data_len);
|
return dev->i2c_read(cmd, cmd_len, data, data_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// v3
|
||||||
|
// Version 3
|
||||||
|
FRESULT ext_f_open(FIL* fp, const TCHAR* path, BYTE mode) {
|
||||||
|
return f_open(fp, path, mode);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_close(FIL* fp) {
|
||||||
|
return f_close(fp);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_read(FIL* fp, void* buff, UINT btr, UINT* br) {
|
||||||
|
return f_read(fp, buff, btr, br);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_write(FIL* fp, const void* buff, UINT btw, UINT* bw) {
|
||||||
|
return f_write(fp, buff, btw, bw);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_lseek(FIL* fp, FSIZE_t ofs) {
|
||||||
|
return f_lseek(fp, ofs);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_truncate(FIL* fp) {
|
||||||
|
return f_truncate(fp);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_sync(FIL* fp) {
|
||||||
|
return f_sync(fp);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_opendir(DIR* dp, const TCHAR* path) {
|
||||||
|
return f_opendir(dp, path);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_closedir(DIR* dp) {
|
||||||
|
return f_closedir(dp);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_readdir(DIR* dp, FILINFO* fno) {
|
||||||
|
return f_readdir(dp, fno);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_findfirst(DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern) {
|
||||||
|
return f_findfirst(dp, fno, path, pattern);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_findnext(DIR* dp, FILINFO* fno) {
|
||||||
|
return f_findnext(dp, fno);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_mkdir(const TCHAR* path) {
|
||||||
|
return f_mkdir(path);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_unlink(const TCHAR* path) {
|
||||||
|
return f_unlink(path);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_rename(const TCHAR* path_old, const TCHAR* path_new) {
|
||||||
|
return f_rename(path_old, path_new);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_stat(const TCHAR* path, FILINFO* fno) {
|
||||||
|
return f_stat(path, fno);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_utime(const TCHAR* path, const FILINFO* fno) {
|
||||||
|
return f_utime(path, fno);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_getfree(const TCHAR* path, DWORD* nclst, FATFS** fatfs) {
|
||||||
|
return f_getfree(path, nclst, fatfs);
|
||||||
|
}
|
||||||
|
FRESULT ext_f_mount(FATFS* fs, const TCHAR* path, BYTE opt) {
|
||||||
|
return f_mount(fs, path, opt);
|
||||||
|
}
|
||||||
|
int ext_f_putc(TCHAR c, FIL* fp) {
|
||||||
|
return f_putc(c, fp);
|
||||||
|
}
|
||||||
|
int ext_f_puts(const TCHAR* str, FIL* cp) {
|
||||||
|
return f_puts(str, cp);
|
||||||
|
}
|
||||||
|
int ext_f_printf(FIL* fp, const TCHAR* str, ...) {
|
||||||
|
return f_printf(fp, str);
|
||||||
|
}
|
||||||
|
TCHAR* ext_f_gets(TCHAR* buff, int len, FIL* fp) {
|
||||||
|
return f_gets(buff, len, fp);
|
||||||
|
}
|
||||||
|
void ext_draw_pixels(const ui::Rect r, const ui::Color* const colors, const size_t count) {
|
||||||
|
portapack::display.draw_pixels(r, colors, count);
|
||||||
|
}
|
||||||
|
void ext_draw_pixel(const ui::Point p, const ui::Color color) {
|
||||||
|
portapack::display.draw_pixel(p, color);
|
||||||
|
}
|
||||||
|
|
||||||
StandaloneView* standaloneView = nullptr;
|
StandaloneView* standaloneView = nullptr;
|
||||||
|
|
||||||
|
void exit_app() {
|
||||||
|
if (standaloneView) standaloneView->exit();
|
||||||
|
}
|
||||||
|
|
||||||
void set_dirty() {
|
void set_dirty() {
|
||||||
if (standaloneView != nullptr)
|
if (standaloneView != nullptr)
|
||||||
standaloneView->set_dirty();
|
standaloneView->set_dirty();
|
||||||
@@ -121,6 +206,36 @@ standalone_application_api_t api = {
|
|||||||
/* .i2c_read = */ &i2c_read,
|
/* .i2c_read = */ &i2c_read,
|
||||||
/* .panic = */ &chDbgPanic,
|
/* .panic = */ &chDbgPanic,
|
||||||
/* .set_dirty = */ &set_dirty,
|
/* .set_dirty = */ &set_dirty,
|
||||||
|
// Version 3
|
||||||
|
.f_open = &ext_f_open,
|
||||||
|
.f_close = &ext_f_close,
|
||||||
|
.f_read = &ext_f_read,
|
||||||
|
.f_write = &ext_f_write,
|
||||||
|
.f_lseek = &ext_f_lseek,
|
||||||
|
.f_truncate = &ext_f_truncate,
|
||||||
|
.f_sync = &ext_f_sync,
|
||||||
|
.f_opendir = &ext_f_opendir,
|
||||||
|
.f_closedir = &ext_f_closedir,
|
||||||
|
.f_readdir = &ext_f_readdir,
|
||||||
|
.f_findfirst = &ext_f_findfirst,
|
||||||
|
.f_findnext = &ext_f_findnext,
|
||||||
|
.f_mkdir = &ext_f_mkdir,
|
||||||
|
.f_unlink = &ext_f_unlink,
|
||||||
|
.f_rename = &ext_f_rename,
|
||||||
|
.f_stat = &ext_f_stat,
|
||||||
|
.f_utime = &ext_f_utime,
|
||||||
|
.f_getfree = &ext_f_getfree,
|
||||||
|
.f_mount = &ext_f_mount,
|
||||||
|
.f_putc = &ext_f_putc,
|
||||||
|
.f_puts = &ext_f_puts,
|
||||||
|
.f_printf = &ext_f_printf,
|
||||||
|
.f_gets = &ext_f_gets,
|
||||||
|
.draw_pixels = &ext_draw_pixels,
|
||||||
|
.draw_pixel = &ext_draw_pixel,
|
||||||
|
.exit_app = &exit_app,
|
||||||
|
// version 4
|
||||||
|
.screen_height = &screen_height,
|
||||||
|
.screen_width = &screen_width,
|
||||||
};
|
};
|
||||||
|
|
||||||
StandaloneView::StandaloneView(NavigationView& nav, uint8_t* app_image)
|
StandaloneView::StandaloneView(NavigationView& nav, uint8_t* app_image)
|
||||||
@@ -158,22 +273,21 @@ bool StandaloneView::on_key(const KeyEvent key) {
|
|||||||
if (get_application_information()->header_version > 1) {
|
if (get_application_information()->header_version > 1) {
|
||||||
return get_application_information()->OnKeyEvent((uint8_t)key);
|
return get_application_information()->OnKeyEvent((uint8_t)key);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StandaloneView::on_encoder(const EncoderEvent event) {
|
bool StandaloneView::on_encoder(const EncoderEvent event) {
|
||||||
if (get_application_information()->header_version > 1) {
|
if (get_application_information()->header_version > 1) {
|
||||||
return get_application_information()->OnEncoder((int32_t)event);
|
return get_application_information()->OnEncoder((int32_t)event);
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StandaloneView::on_touch(const TouchEvent event) {
|
bool StandaloneView::on_touch(const TouchEvent event) {
|
||||||
if (get_application_information()->header_version > 1) {
|
if (get_application_information()->header_version > 1) {
|
||||||
get_application_information()->OnTouchEvent(event.point.x(), event.point.y(), (uint32_t)event.type);
|
return get_application_information()->OnTouchEvent(event.point.x(), event.point.y(), (uint32_t)event.type);
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StandaloneView::on_keyboard(const KeyboardEvent event) {
|
bool StandaloneView::on_keyboard(const KeyboardEvent event) {
|
||||||
@@ -202,4 +316,8 @@ void StandaloneView::on_before_detach() {
|
|||||||
context().focus_manager().clearMirror();
|
context().focus_manager().clearMirror();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StandaloneView::exit() {
|
||||||
|
nav_.pop();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ class StandaloneView : public View {
|
|||||||
|
|
||||||
void frame_sync();
|
void frame_sync();
|
||||||
|
|
||||||
|
void exit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
|
|||||||
@@ -262,17 +262,14 @@ void RecentEntriesTable<ui::SubGhzDRecentEntries>::draw(
|
|||||||
const Entry& entry,
|
const Entry& entry,
|
||||||
const Rect& target_rect,
|
const Rect& target_rect,
|
||||||
Painter& painter,
|
Painter& painter,
|
||||||
const Style& style) {
|
const Style& style,
|
||||||
|
RecentEntriesColumns& columns) {
|
||||||
std::string line{};
|
std::string line{};
|
||||||
line.reserve(30);
|
line.reserve(30);
|
||||||
|
|
||||||
line = SubGhzDView::getSensorTypeName((FPROTO_SUBGHZD_SENSOR)entry.sensorType);
|
line = SubGhzDView::getSensorTypeName((FPROTO_SUBGHZD_SENSOR)entry.sensorType);
|
||||||
line = line + " " + to_string_hex(entry.data << 32);
|
line = line + " " + to_string_hex(entry.data << 32);
|
||||||
if (line.length() < 19) {
|
line.resize(columns.at(0).second, ' ');
|
||||||
line += SubGhzDView::pad_string_with_spaces(19 - line.length());
|
|
||||||
} else {
|
|
||||||
line = truncate(line, 19);
|
|
||||||
}
|
|
||||||
std::string ageStr = to_string_dec_uint(entry.age);
|
std::string ageStr = to_string_dec_uint(entry.age);
|
||||||
std::string bitsStr = to_string_dec_uint(entry.bits);
|
std::string bitsStr = to_string_dec_uint(entry.bits);
|
||||||
line += SubGhzDView::pad_string_with_spaces(5 - bitsStr.length()) + bitsStr;
|
line += SubGhzDView::pad_string_with_spaces(5 - bitsStr.length()) + bitsStr;
|
||||||
@@ -342,7 +339,7 @@ void SubGhzDRecentEntryDetailView::parseProtocol() {
|
|||||||
if (entry_.sensorType == FPS_CAMEATOMO) {
|
if (entry_.sensorType == FPS_CAMEATOMO) {
|
||||||
entry_.data ^= 0xFFFFFFFFFFFFFFFF;
|
entry_.data ^= 0xFFFFFFFFFFFFFFFF;
|
||||||
entry_.data <<= 4;
|
entry_.data <<= 4;
|
||||||
uint8_t pack[8] = {};
|
uint8_t pack[8];
|
||||||
pack[0] = (entry_.data >> 56);
|
pack[0] = (entry_.data >> 56);
|
||||||
pack[1] = ((entry_.data >> 48) & 0xFF);
|
pack[1] = ((entry_.data >> 48) & 0xFF);
|
||||||
pack[2] = ((entry_.data >> 40) & 0xFF);
|
pack[2] = ((entry_.data >> 40) & 0xFF);
|
||||||
|
|||||||
@@ -122,18 +122,18 @@ class SubGhzDView : public View {
|
|||||||
SubGhzDRecentEntries recent{};
|
SubGhzDRecentEntries recent{};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{13 * 8, 0 * 16}};
|
{13 * 8, UI_POS_Y(0)}};
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{15 * 8, UI_POS_Y(0)}};
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{18 * 8, UI_POS_Y(0)}};
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4}};
|
{21 * 8, 0, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||||
Channel channel{
|
Channel channel{
|
||||||
{21 * 8, 5, 6 * 8, 4},
|
{21 * 8, 5, UI_POS_WIDTH_REMAINING(24), 4},
|
||||||
};
|
};
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 16},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
SignalToken signal_token_tick_second{};
|
SignalToken signal_token_tick_second{};
|
||||||
@@ -152,8 +152,8 @@ class SubGhzDView : public View {
|
|||||||
|
|
||||||
std::unique_ptr<SubGhzDLogger> logger{};
|
std::unique_ptr<SubGhzDLogger> logger{};
|
||||||
|
|
||||||
const RecentEntriesColumns columns{{
|
RecentEntriesColumns columns{{
|
||||||
{"Type", 19},
|
{"Type", 0},
|
||||||
{"Bits", 4},
|
{"Bits", 4},
|
||||||
{"Age", 3},
|
{"Age", 3},
|
||||||
}};
|
}};
|
||||||
@@ -191,16 +191,16 @@ class SubGhzDRecentEntryDetailView : public View {
|
|||||||
uint32_t cnt = SD_NO_CNT;
|
uint32_t cnt = SD_NO_CNT;
|
||||||
uint32_t seed = 0;
|
uint32_t seed = 0;
|
||||||
|
|
||||||
Text text_type{{0 * 8, 1 * 16, 15 * 8, 16}, "?"};
|
Text text_type{{UI_POS_X(0), 1 * 16, 15 * 8, 16}, "?"};
|
||||||
Text text_id{{6 * 8, 2 * 16, 10 * 8, 16}, "?"};
|
Text text_id{{6 * 8, 2 * 16, 10 * 8, 16}, "?"};
|
||||||
|
|
||||||
Console console{
|
Console console{
|
||||||
{0, 4 * 16, screen_width, screen_height - (4 * 16) - 36}};
|
{0, 4 * 16, screen_width, screen_height - (4 * 16) - 36}};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 0 * 16}, "Type:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), UI_POS_Y(0)}, "Type:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 2 * 16}, "Serial: ", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 2 * 16}, "Serial: ", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 3 * 16}, "Data:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 3 * 16}, "Data:", Theme::getInstance()->fg_light->foreground},
|
||||||
};
|
};
|
||||||
|
|
||||||
Button button_done{
|
Button button_done{
|
||||||
|
|||||||
@@ -76,29 +76,29 @@ class TestView : public View {
|
|||||||
bool logging{false};
|
bool logging{false};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 1 * 16}, "Data:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 1 * 16}, "Data:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 8},
|
{UI_POS_X(0), 0 * 8},
|
||||||
nav_};
|
nav_};
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{13 * 8, 0 * 16}};
|
{13 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{15 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{18 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4},
|
{21 * 8, 0, 6 * 8, 4},
|
||||||
};
|
};
|
||||||
|
|
||||||
Text text_debug_a{
|
Text text_debug_a{
|
||||||
{0 * 8, 4 * 16, screen_width, 16},
|
{UI_POS_X(0), 4 * 16, screen_width, 16},
|
||||||
"..."};
|
"..."};
|
||||||
Text text_debug_b{
|
Text text_debug_b{
|
||||||
{0 * 8, 5 * 16, screen_width, 16},
|
{UI_POS_X(0), 5 * 16, screen_width, 16},
|
||||||
"..."};
|
"..."};
|
||||||
|
|
||||||
Button button_cal{
|
Button button_cal{
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ void TextViewer::set_font_zoom(bool zoom) {
|
|||||||
/* TextEditorMenu ***************************************************/
|
/* TextEditorMenu ***************************************************/
|
||||||
|
|
||||||
TextEditorMenu::TextEditorMenu()
|
TextEditorMenu::TextEditorMenu()
|
||||||
: View{{7 * 4, 9 * 4, 25 * 8, 25 * 8}} {
|
: View{{UI_POS_X_CENTER(25), 9 * 4, 25 * 8, 25 * 8}} {
|
||||||
add_children(
|
add_children(
|
||||||
{
|
{
|
||||||
&rect_frame,
|
&rect_frame,
|
||||||
@@ -612,7 +612,7 @@ void TextEditorView::open_file(const fs::path& path) {
|
|||||||
viewer.clear_file();
|
viewer.clear_file();
|
||||||
delete_temp_file(path_);
|
delete_temp_file(path_);
|
||||||
|
|
||||||
path_ = {};
|
path_ = "";
|
||||||
file_dirty_ = false;
|
file_dirty_ = false;
|
||||||
has_temp_file_ = false;
|
has_temp_file_ = false;
|
||||||
auto result = FileWrapper::open(
|
auto result = FileWrapper::open(
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ class TextEditorMenu : public View {
|
|||||||
void hide_children(bool hidden);
|
void hide_children(bool hidden);
|
||||||
|
|
||||||
Rectangle rect_frame{
|
Rectangle rect_frame{
|
||||||
{0 * 8, 0 * 8, 23 * 8, 23 * 8},
|
{UI_POS_X(0), 0 * 8, 23 * 8, 23 * 8},
|
||||||
Theme::getInstance()->fg_dark->foreground};
|
Theme::getInstance()->fg_dark->foreground};
|
||||||
|
|
||||||
NewButton button_home{
|
NewButton button_home{
|
||||||
@@ -267,23 +267,23 @@ class TextEditorView : public View {
|
|||||||
|
|
||||||
TextViewer viewer{
|
TextViewer viewer{
|
||||||
/* 272 = screen_height - 16 (top bar) - 32 (bottom controls) */
|
/* 272 = screen_height - 16 (top bar) - 32 (bottom controls) */
|
||||||
{0, 0, screen_width, 272}};
|
{0, 0, screen_width, UI_POS_HEIGHT_REMAINING(4)}};
|
||||||
|
|
||||||
TextEditorMenu menu{};
|
TextEditorMenu menu{};
|
||||||
|
|
||||||
NewButton button_menu{
|
NewButton button_menu{
|
||||||
{26 * 8, 34 * 8, 4 * 8, 4 * 8},
|
{UI_POS_X_RIGHT(4), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
{},
|
{},
|
||||||
&bitmap_icon_controls,
|
&bitmap_icon_controls,
|
||||||
Theme::getInstance()->bg_dark->background,
|
Theme::getInstance()->bg_dark->background,
|
||||||
/*vcenter*/ true};
|
/*vcenter*/ true};
|
||||||
|
|
||||||
Text text_position{
|
Text text_position{
|
||||||
{0 * 8, 34 * 8, 26 * 8, 2 * 8},
|
{UI_POS_X(0), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH_REMAINING(5), UI_POS_HEIGHT(1)},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
Text text_size{
|
Text text_size{
|
||||||
{0 * 8, 36 * 8, 26 * 8, 2 * 8},
|
{UI_POS_X(0), UI_POS_Y_BOTTOM(2), UI_POS_WIDTH_REMAINING(5), UI_POS_HEIGHT(1)},
|
||||||
""};
|
""};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -81,13 +81,13 @@ class TouchCalibrationView : public View {
|
|||||||
Color::black()};
|
Color::black()};
|
||||||
|
|
||||||
Image image_calibrate_1{
|
Image image_calibrate_1{
|
||||||
{240 - 32 - 16, (320 - 16) / 2 - 16, 32, 32},
|
{screen_width - 32 - 16, (screen_height - 16) / 2 - 16, 32, 32},
|
||||||
&bitmap_target_calibrate,
|
&bitmap_target_calibrate,
|
||||||
Color::white(),
|
Color::white(),
|
||||||
Color::black()};
|
Color::black()};
|
||||||
|
|
||||||
Image image_calibrate_2{
|
Image image_calibrate_2{
|
||||||
{240 / 2 - 16, (320 - 16) - 32 - 16, 32, 32},
|
{screen_width / 2 - 16, (screen_height - 16) - 32 - 16, 32, 32},
|
||||||
&bitmap_target_calibrate,
|
&bitmap_target_calibrate,
|
||||||
Color::white(),
|
Color::white(),
|
||||||
Color::black()};
|
Color::black()};
|
||||||
@@ -99,13 +99,13 @@ class TouchCalibrationView : public View {
|
|||||||
Color::black()};
|
Color::black()};
|
||||||
|
|
||||||
Image image_verify_1{
|
Image image_verify_1{
|
||||||
{240 - 32 - 16, (320 - 16) / 2 - 16, 32, 32},
|
{screen_width - 32 - 16, (screen_height - 16) / 2 - 16, 32, 32},
|
||||||
&bitmap_target_verify,
|
&bitmap_target_verify,
|
||||||
Color::white(),
|
Color::white(),
|
||||||
Color::black()};
|
Color::black()};
|
||||||
|
|
||||||
Image image_verify_2{
|
Image image_verify_2{
|
||||||
{240 / 2 - 16, (320 - 16) - 32 - 16, 32, 32},
|
{screen_width / 2 - 16, (screen_height - 16) - 32 - 16, 32, 32},
|
||||||
&bitmap_target_verify,
|
&bitmap_target_verify,
|
||||||
Color::white(),
|
Color::white(),
|
||||||
Color::black()};
|
Color::black()};
|
||||||
@@ -131,11 +131,11 @@ class TouchCalibrationView : public View {
|
|||||||
"Calibration failed. Retry?"};
|
"Calibration failed. Retry?"};
|
||||||
|
|
||||||
Button button_cancel{
|
Button button_cancel{
|
||||||
{40, 200, 64, 24},
|
{40, 200, UI_POS_WIDTH(8), 24},
|
||||||
"Cancel"};
|
"Cancel"};
|
||||||
|
|
||||||
Button button_ok{
|
Button button_ok{
|
||||||
{136, 200, 64, 24},
|
{136, 200, UI_POS_WIDTH(8), 24},
|
||||||
"OK"};
|
"OK"};
|
||||||
|
|
||||||
void on_frame_sync();
|
void on_frame_sync();
|
||||||
|
|||||||
@@ -162,16 +162,16 @@ class TouchTunesView : public View {
|
|||||||
{{18 * 8 + 4, 18 * 8}, "V"},
|
{{18 * 8 + 4, 18 * 8}, "V"},
|
||||||
{{22 * 8, 18 * 8}, "F4"},
|
{{22 * 8, 18 * 8}, "F4"},
|
||||||
|
|
||||||
{{0 * 8, 5 * 8}, "1"},
|
{{UI_POS_X(0), 5 * 8}, "1"},
|
||||||
{{4 * 8, 5 * 8}, "2"},
|
{{4 * 8, 5 * 8}, "2"},
|
||||||
{{8 * 8, 5 * 8}, "3"},
|
{{8 * 8, 5 * 8}, "3"},
|
||||||
{{0 * 8, 10 * 8}, "4"},
|
{{UI_POS_X(0), 10 * 8}, "4"},
|
||||||
{{4 * 8, 10 * 8}, "5"},
|
{{4 * 8, 10 * 8}, "5"},
|
||||||
{{8 * 8, 10 * 8}, "6"},
|
{{8 * 8, 10 * 8}, "6"},
|
||||||
{{0 * 8, 15 * 8}, "7"},
|
{{UI_POS_X(0), 15 * 8}, "7"},
|
||||||
{{4 * 8, 15 * 8}, "8"},
|
{{4 * 8, 15 * 8}, "8"},
|
||||||
{{8 * 8, 15 * 8}, "9"},
|
{{8 * 8, 15 * 8}, "9"},
|
||||||
{{0 * 8, 20 * 8}, "*"},
|
{{UI_POS_X(0), 20 * 8}, "*"},
|
||||||
{{4 * 8, 20 * 8}, "0"},
|
{{4 * 8, 20 * 8}, "0"},
|
||||||
{{8 * 8, 20 * 8}, "#"},
|
{{8 * 8, 20 * 8}, "#"},
|
||||||
|
|
||||||
|
|||||||
@@ -197,6 +197,10 @@ WeatherView::~WeatherView() {
|
|||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t WeatherView::bcd_decode_short(uint32_t data) {
|
||||||
|
return (data & 0xF) * 10 + ((data >> 4) & 0xF);
|
||||||
|
}
|
||||||
|
|
||||||
const char* WeatherView::getWeatherSensorTypeName(FPROTO_WEATHER_SENSOR type) {
|
const char* WeatherView::getWeatherSensorTypeName(FPROTO_WEATHER_SENSOR type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case FPW_NexusTH:
|
case FPW_NexusTH:
|
||||||
@@ -225,6 +229,8 @@ const char* WeatherView::getWeatherSensorTypeName(FPROTO_WEATHER_SENSOR type) {
|
|||||||
return "LaCrosse TX141THBv2";
|
return "LaCrosse TX141THBv2";
|
||||||
case FPW_OREGON2:
|
case FPW_OREGON2:
|
||||||
return "Oregon2";
|
return "Oregon2";
|
||||||
|
case FPW_OREGON2B:
|
||||||
|
return "Oregon2B";
|
||||||
case FPW_OREGON3:
|
case FPW_OREGON3:
|
||||||
return "Oregon3";
|
return "Oregon3";
|
||||||
case FPW_OREGONv1:
|
case FPW_OREGONv1:
|
||||||
@@ -270,16 +276,13 @@ void RecentEntriesTable<ui::WeatherRecentEntries>::draw(
|
|||||||
const Entry& entry,
|
const Entry& entry,
|
||||||
const Rect& target_rect,
|
const Rect& target_rect,
|
||||||
Painter& painter,
|
Painter& painter,
|
||||||
const Style& style) {
|
const Style& style,
|
||||||
|
RecentEntriesColumns& columns) {
|
||||||
std::string line{};
|
std::string line{};
|
||||||
line.reserve(30);
|
line.reserve(30);
|
||||||
|
|
||||||
line = WeatherView::getWeatherSensorTypeName((FPROTO_WEATHER_SENSOR)entry.sensorType);
|
line = WeatherView::getWeatherSensorTypeName((FPROTO_WEATHER_SENSOR)entry.sensorType);
|
||||||
if (line.length() < 10) {
|
line.resize(columns.at(0).second, ' ');
|
||||||
line += WeatherView::pad_string_with_spaces(10 - line.length());
|
|
||||||
} else {
|
|
||||||
line = truncate(line, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string temp = (weather_units_fahr ? to_string_decimal((entry.temp * 9 / 5) + 32, 1) : to_string_decimal(entry.temp, 1));
|
std::string temp = (weather_units_fahr ? to_string_decimal((entry.temp * 9 / 5) + 32, 1) : to_string_decimal(entry.temp, 1));
|
||||||
std::string humStr = (entry.humidity != WS_NO_HUMIDITY) ? to_string_dec_uint(entry.humidity) + "%" : "-";
|
std::string humStr = (entry.humidity != WS_NO_HUMIDITY) ? to_string_dec_uint(entry.humidity) + "%" : "-";
|
||||||
@@ -302,7 +305,9 @@ WeatherRecentEntry WeatherView::process_data(const WeatherDataMessage* data) {
|
|||||||
WeatherRecentEntry ret = {};
|
WeatherRecentEntry ret = {};
|
||||||
ret.sensorType = data->sensorType;
|
ret.sensorType = data->sensorType;
|
||||||
int16_t i16 = 0;
|
int16_t i16 = 0;
|
||||||
|
int32_t i32 = 0;
|
||||||
uint16_t u16 = 0;
|
uint16_t u16 = 0;
|
||||||
|
|
||||||
uint64_t u64 = 0;
|
uint64_t u64 = 0;
|
||||||
uint8_t u8 = 0;
|
uint8_t u8 = 0;
|
||||||
uint8_t channel_3021[] = {3, 0, 2, 1};
|
uint8_t channel_3021[] = {3, 0, 2, 1};
|
||||||
@@ -445,12 +450,34 @@ WeatherRecentEntry WeatherView::process_data(const WeatherDataMessage* data) {
|
|||||||
ret.humidity = (data->decode_data >> 8) & 0xFF;
|
ret.humidity = (data->decode_data >> 8) & 0xFF;
|
||||||
break;
|
break;
|
||||||
case FPW_OREGON2:
|
case FPW_OREGON2:
|
||||||
i16 = ((data->decode_data >> 4) & 0xF) * 10 + (((data->decode_data >> 4) >> 4) & 0xF);
|
i32 = bcd_decode_short(data->decode_data >> 4);
|
||||||
i16 *= 10;
|
i32 *= 10;
|
||||||
i16 += (data->decode_data >> 12) & 0xF;
|
i32 += (data->decode_data >> 12) & 0xf;
|
||||||
if (data->decode_data & 0xF) i16 = -i16;
|
if (data->decode_data & 0xF) i32 = -i32;
|
||||||
ret.temp = (float)i16 / 10.0;
|
ret.temp = (float)i32 / 10.0;
|
||||||
// todo fix missing parts.
|
ret.battery_low = ((data->decode_data >> 32) & 0x4) ? 1 : 0;
|
||||||
|
u8 = (data->decode_data >> 44) & 0xF;
|
||||||
|
ret.channel = 1;
|
||||||
|
while (u8 > 1) {
|
||||||
|
ret.channel++;
|
||||||
|
u8 >>= 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FPW_OREGON2B:
|
||||||
|
ret.humidity = bcd_decode_short(data->decode_data);
|
||||||
|
u64 = data->decode_data >> 8;
|
||||||
|
i32 = bcd_decode_short(u64 >> 4);
|
||||||
|
i32 *= 10;
|
||||||
|
i32 += (u64 >> 12) & 0xf;
|
||||||
|
if (u64 & 0xF) i32 = -i32;
|
||||||
|
ret.temp = (float)i32 / 10.0;
|
||||||
|
ret.battery_low = ((data->decode_data >> 32) & 0x4) ? 1 : 0;
|
||||||
|
u8 = (data->decode_data >> 44) & 0xF;
|
||||||
|
ret.channel = 1;
|
||||||
|
while (u8 > 1) {
|
||||||
|
ret.channel++;
|
||||||
|
u8 >>= 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FPW_OREGON3:
|
case FPW_OREGON3:
|
||||||
// todo check
|
// todo check
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ class WeatherView : public View {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void on_tick_second();
|
void on_tick_second();
|
||||||
|
uint16_t bcd_decode_short(uint32_t data);
|
||||||
void on_data(const WeatherDataMessage* data);
|
void on_data(const WeatherDataMessage* data);
|
||||||
WeatherRecentEntry process_data(const WeatherDataMessage* data);
|
WeatherRecentEntry process_data(const WeatherDataMessage* data);
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
@@ -134,28 +135,28 @@ class WeatherView : public View {
|
|||||||
WeatherRecentEntries recent{};
|
WeatherRecentEntries recent{};
|
||||||
|
|
||||||
OptionsField options_temperature{
|
OptionsField options_temperature{
|
||||||
{10 * 8, 0 * 16},
|
{10 * 8, UI_POS_Y(0)},
|
||||||
2,
|
2,
|
||||||
{{STR_DEGREES_C, 0},
|
{{STR_DEGREES_C, 0},
|
||||||
{STR_DEGREES_F, 1}}};
|
{STR_DEGREES_F, 1}}};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{13 * 8, 0 * 16}};
|
{13 * 8, UI_POS_Y(0)}};
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{15 * 8, UI_POS_Y(0)}};
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{18 * 8, UI_POS_Y(0)}};
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4}};
|
{21 * 8, 0, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||||
Channel channel{
|
Channel channel{
|
||||||
{21 * 8, 5, 6 * 8, 4},
|
{21 * 8, 5, UI_POS_WIDTH_REMAINING(24), 4},
|
||||||
};
|
};
|
||||||
|
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{screen_width - 2 * 8, 0 * 16}};
|
{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 16},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
SignalToken signal_token_tick_second{};
|
SignalToken signal_token_tick_second{};
|
||||||
@@ -174,8 +175,8 @@ class WeatherView : public View {
|
|||||||
|
|
||||||
std::unique_ptr<WeatherLogger> logger{};
|
std::unique_ptr<WeatherLogger> logger{};
|
||||||
|
|
||||||
const RecentEntriesColumns columns{{
|
RecentEntriesColumns columns{{
|
||||||
{"Type", 10},
|
{"Type", 0},
|
||||||
{"Temp", 5},
|
{"Temp", 5},
|
||||||
{"Hum", 4},
|
{"Hum", 4},
|
||||||
{"Ch", 3},
|
{"Ch", 3},
|
||||||
@@ -218,14 +219,14 @@ class WeatherRecentEntryDetailView : public View {
|
|||||||
Text text_age{{10 * 8, 7 * 16, 10 * 8, 16}, "?"};
|
Text text_age{{10 * 8, 7 * 16, 10 * 8, 16}, "?"};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 0 * 16}, "Weather Station", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), UI_POS_Y(0)}, "Weather Station", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 1 * 16}, "Type:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 1 * 16}, "Type:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 2 * 16}, "Id: ", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 2 * 16}, "Id: ", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 3 * 16}, "Temp:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 3 * 16}, "Temp:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 4 * 16}, "Humidity:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 4 * 16}, "Humidity:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 5 * 16}, "Channel:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 5 * 16}, "Channel:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 6 * 16}, "Battery:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 6 * 16}, "Battery:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 7 * 16}, "Age:", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 7 * 16}, "Age:", Theme::getInstance()->fg_light->foreground},
|
||||||
};
|
};
|
||||||
|
|
||||||
Button button_done{
|
Button button_done{
|
||||||
|
|||||||
@@ -415,6 +415,44 @@ static constexpr Bitmap bitmap_icon_adsb{
|
|||||||
{16, 16},
|
{16, 16},
|
||||||
bitmap_icon_adsb_data};
|
bitmap_icon_adsb_data};
|
||||||
|
|
||||||
|
static constexpr uint8_t bitmap_icon_adulttoys_data[] = {
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x30,
|
||||||
|
0x0C,
|
||||||
|
0x78,
|
||||||
|
0x1E,
|
||||||
|
0x7C,
|
||||||
|
0x3E,
|
||||||
|
0xFE,
|
||||||
|
0x7F,
|
||||||
|
0xFE,
|
||||||
|
0x7F,
|
||||||
|
0xFE,
|
||||||
|
0x7F,
|
||||||
|
0xFE,
|
||||||
|
0x7F,
|
||||||
|
0xFC,
|
||||||
|
0x3F,
|
||||||
|
0xFC,
|
||||||
|
0x3F,
|
||||||
|
0xF8,
|
||||||
|
0x1F,
|
||||||
|
0xF0,
|
||||||
|
0x0F,
|
||||||
|
0xE0,
|
||||||
|
0x07,
|
||||||
|
0xC0,
|
||||||
|
0x03,
|
||||||
|
0x80,
|
||||||
|
0x01,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
|
static constexpr Bitmap bitmap_icon_adulttoys{
|
||||||
|
{16, 16},
|
||||||
|
bitmap_icon_adulttoys_data};
|
||||||
|
|
||||||
static constexpr uint8_t bitmap_icon_ais_data[] = {
|
static constexpr uint8_t bitmap_icon_ais_data[] = {
|
||||||
0x00,
|
0x00,
|
||||||
0x01,
|
0x01,
|
||||||
|
|||||||
@@ -124,12 +124,12 @@ void EventDispatcher::request_stop() {
|
|||||||
|
|
||||||
void EventDispatcher::set_display_sleep(const bool sleep) {
|
void EventDispatcher::set_display_sleep(const bool sleep) {
|
||||||
// TODO: Distribute display sleep message more broadly, shut down data generation
|
// TODO: Distribute display sleep message more broadly, shut down data generation
|
||||||
// on baseband side, since all that data is being discarded during sleep.
|
// on baseband side, since all that data is being discarded during sleep. -- DON'T TODO it, sincethe stealth mode want to send with screen off!
|
||||||
if (sleep) {
|
if (sleep) {
|
||||||
portapack::backlight()->off();
|
portapack::backlight()->off();
|
||||||
portapack::display.sleep();
|
portapack::display.sleep(false); // when called the hw_sleep = true, the irq wont fire, so the EVT_MASK_LCD_FRAME_SYNC won't set.
|
||||||
} else {
|
} else {
|
||||||
portapack::display.wake();
|
portapack::display.wake(true); // not important, command not affect if already hw waken up
|
||||||
// Don't turn on backlight here.
|
// Don't turn on backlight here.
|
||||||
// Let frame sync handler turn on backlight after repaint.
|
// Let frame sync handler turn on backlight after repaint.
|
||||||
}
|
}
|
||||||
@@ -180,12 +180,10 @@ void EventDispatcher::dispatch(const eventmask_t events) {
|
|||||||
/*if( events & EVT_MASK_LCD_FRAME_SYNC ) {
|
/*if( events & EVT_MASK_LCD_FRAME_SYNC ) {
|
||||||
blink_timer();
|
blink_timer();
|
||||||
}*/
|
}*/
|
||||||
|
if (events & EVT_MASK_LCD_FRAME_SYNC) {
|
||||||
|
handle_lcd_frame_sync(!EventDispatcher::display_sleep);
|
||||||
|
}
|
||||||
if (!EventDispatcher::display_sleep) {
|
if (!EventDispatcher::display_sleep) {
|
||||||
if (events & EVT_MASK_LCD_FRAME_SYNC) {
|
|
||||||
handle_lcd_frame_sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (events & EVT_MASK_ENCODER) {
|
if (events & EVT_MASK_ENCODER) {
|
||||||
handle_encoder();
|
handle_encoder();
|
||||||
}
|
}
|
||||||
@@ -328,17 +326,16 @@ ui::Widget* EventDispatcher::getFocusedWidget() {
|
|||||||
return context.focus_manager().focus_widget();
|
return context.focus_manager().focus_widget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::handle_lcd_frame_sync() {
|
void EventDispatcher::handle_lcd_frame_sync(bool screen_on) {
|
||||||
bool waiting_for_frame = this->waiting_for_frame;
|
bool waiting_for_frame = this->waiting_for_frame;
|
||||||
|
|
||||||
DisplayFrameSyncMessage message;
|
DisplayFrameSyncMessage message; // send framesync msg all the time, bc some apps relay on it
|
||||||
message_map.send(&message);
|
message_map.send(&message);
|
||||||
|
if (screen_on) { // only draw when screen is on
|
||||||
static_cast<ui::SystemView*>(top_widget)->paint_overlay();
|
static_cast<ui::SystemView*>(top_widget)->paint_overlay();
|
||||||
painter.paint_widget_tree(top_widget);
|
painter.paint_widget_tree(top_widget);
|
||||||
|
portapack::backlight()->on();
|
||||||
portapack::backlight()->on();
|
}
|
||||||
|
|
||||||
if (waiting_for_frame)
|
if (waiting_for_frame)
|
||||||
this->waiting_for_frame = false;
|
this->waiting_for_frame = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class EventDispatcher {
|
|||||||
void on_keyboard_event(ui::KeyboardEvent event);
|
void on_keyboard_event(ui::KeyboardEvent event);
|
||||||
|
|
||||||
// void blink_timer();
|
// void blink_timer();
|
||||||
void handle_lcd_frame_sync();
|
void handle_lcd_frame_sync(bool screen_on);
|
||||||
void handle_switches();
|
void handle_switches();
|
||||||
void handle_encoder();
|
void handle_encoder();
|
||||||
void handle_touch();
|
void handle_touch();
|
||||||
|
|||||||
+6
-6
@@ -67,18 +67,18 @@ class ACARSAppView : public View {
|
|||||||
uint32_t packet_counter{0};
|
uint32_t packet_counter{0};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{13 * 8, 0 * 16}};
|
{13 * 8, UI_POS_Y(0)}};
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{15 * 8, UI_POS_Y(0)}};
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{18 * 8, UI_POS_Y(0)}};
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4}};
|
{UI_POS_X(21), 0, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||||
Channel channel{
|
Channel channel{
|
||||||
{21 * 8, 5, 6 * 8, 4}};
|
{UI_POS_X(21), 5, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 8},
|
{UI_POS_X(0), 0 * 8},
|
||||||
nav_};
|
nav_};
|
||||||
Checkbox check_log{
|
Checkbox check_log{
|
||||||
{16 * 8, 1 * 16},
|
{16 * 8, 1 * 16},
|
||||||
|
|||||||
+2
-2
@@ -62,7 +62,7 @@ class ADSBPositionView : public OptionTabView {
|
|||||||
GeoPos::HIDDEN};
|
GeoPos::HIDDEN};
|
||||||
|
|
||||||
Button button_set_map{
|
Button button_set_map{
|
||||||
{8 * 8, 6 * 16, 14 * 8, 2 * 16},
|
{UI_POS_X_CENTER(14), 6 * 16, 14 * 8, 2 * 16},
|
||||||
"Set from map"};
|
"Set from map"};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ class ADSBTxView : public View {
|
|||||||
"-"};
|
"-"};
|
||||||
|
|
||||||
TransmitterView tx_view{
|
TransmitterView tx_view{
|
||||||
16 * 16,
|
(int16_t)UI_POS_Y_BOTTOM(4),
|
||||||
1000000,
|
1000000,
|
||||||
0};
|
0};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Pezsma
|
||||||
|
*
|
||||||
|
* 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.hpp"
|
||||||
|
#include "ui_adult_toys_controller.hpp"
|
||||||
|
#include "ui_navigation.hpp"
|
||||||
|
#include "external_app.hpp"
|
||||||
|
|
||||||
|
namespace ui::external_app::adult_toys_controller {
|
||||||
|
|
||||||
|
void initialize_app(::ui::NavigationView& nav) {
|
||||||
|
nav.push<AdultToysView>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ui::external_app::adult_toys_controller
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
__attribute__((section(".external_app.app_adult_toys_controller.application_information"), used)) application_information_t _application_information_adult_toys_controller = {
|
||||||
|
/*.memory_location = */ (uint8_t*)0x00000000,
|
||||||
|
/*.externalAppEntry = */ ui::external_app::adult_toys_controller::initialize_app,
|
||||||
|
/*.header_version = */ CURRENT_HEADER_VERSION,
|
||||||
|
/*.app_version = */ VERSION_MD5,
|
||||||
|
|
||||||
|
/*.app_name = */ "Adult Toys",
|
||||||
|
/*.bitmap_data = */ {
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x30,
|
||||||
|
0x0C,
|
||||||
|
0x78,
|
||||||
|
0x1E,
|
||||||
|
0x7C,
|
||||||
|
0x3E,
|
||||||
|
0xFE,
|
||||||
|
0x7F,
|
||||||
|
0xFE,
|
||||||
|
0x7F,
|
||||||
|
0xFE,
|
||||||
|
0x7F,
|
||||||
|
0xFE,
|
||||||
|
0x7F,
|
||||||
|
0xFC,
|
||||||
|
0x3F,
|
||||||
|
0xFC,
|
||||||
|
0x3F,
|
||||||
|
0xF8,
|
||||||
|
0x1F,
|
||||||
|
0xF0,
|
||||||
|
0x0F,
|
||||||
|
0xE0,
|
||||||
|
0x07,
|
||||||
|
0xC0,
|
||||||
|
0x03,
|
||||||
|
0x80,
|
||||||
|
0x01,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
},
|
||||||
|
/*.icon_color = */ ui::Color::yellow().v,
|
||||||
|
/*.menu_location = */ app_location_t::TX,
|
||||||
|
/*.desired_menu_position = */ -1,
|
||||||
|
|
||||||
|
/*.m4_app_tag = portapack::spi_flash::image_tag_btle_tx */ {'P', 'B', 'T', 'T'},
|
||||||
|
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
|
||||||
|
};
|
||||||
|
}
|
||||||
+373
@@ -0,0 +1,373 @@
|
|||||||
|
|
||||||
|
#include "ui_adult_toys_controller.hpp"
|
||||||
|
|
||||||
|
#include "ui_modemsetup.hpp"
|
||||||
|
#include "modems.hpp"
|
||||||
|
#include "audio.hpp"
|
||||||
|
#include "baseband_api.hpp"
|
||||||
|
#include "string_format.hpp"
|
||||||
|
#include "portapack_persistent_memory.hpp"
|
||||||
|
#include "ui_navigation.hpp"
|
||||||
|
|
||||||
|
using namespace portapack;
|
||||||
|
using namespace modems;
|
||||||
|
using namespace ui;
|
||||||
|
|
||||||
|
namespace ui::external_app::adult_toys_controller {
|
||||||
|
|
||||||
|
void AdultToysView::focus() {
|
||||||
|
button_on.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
AdultToysView::AdultToysView(NavigationView& nav)
|
||||||
|
: nav_{nav} {
|
||||||
|
add_children({
|
||||||
|
&button_on,
|
||||||
|
&btn_adult,
|
||||||
|
&btn_child,
|
||||||
|
&btn_mode_decrease,
|
||||||
|
&btn_mode_increase,
|
||||||
|
&btn_pcknum_inc,
|
||||||
|
&btn_pcknum_dec,
|
||||||
|
&chk_mode_rnd,
|
||||||
|
&chk_mode_play,
|
||||||
|
&chk_mode_stop,
|
||||||
|
&chk_mode_ncnt,
|
||||||
|
&chk_mode_infinite,
|
||||||
|
&field_frequency,
|
||||||
|
&txt_selected_mode,
|
||||||
|
&options_target,
|
||||||
|
&labels,
|
||||||
|
&message_num,
|
||||||
|
&tx_view,
|
||||||
|
&screen_message_1,
|
||||||
|
&screen_message_2,
|
||||||
|
&screen_message_3,
|
||||||
|
&screen_message_4,
|
||||||
|
&screen_message_5,
|
||||||
|
&screen_message_6,
|
||||||
|
&screen_message_7,
|
||||||
|
&screen_message_8,
|
||||||
|
&screen_message_9,
|
||||||
|
&screen_message_10,
|
||||||
|
});
|
||||||
|
|
||||||
|
btn_adult.on_select = [this](Button&) {
|
||||||
|
start_screen = true;
|
||||||
|
hidden_program(!start_screen);
|
||||||
|
};
|
||||||
|
|
||||||
|
btn_child.on_select = [this](Button&) {
|
||||||
|
nav_.pop();
|
||||||
|
};
|
||||||
|
|
||||||
|
button_on.on_select = [this](Button&) {
|
||||||
|
if (play_running || stop_running) {
|
||||||
|
if (button_onstate) {
|
||||||
|
button_onstate = false;
|
||||||
|
stop();
|
||||||
|
button_on.set_text(LanguageHelper::currentMessages[LANG_START]);
|
||||||
|
} else {
|
||||||
|
button_onstate = true;
|
||||||
|
printCurrentModes();
|
||||||
|
start();
|
||||||
|
button_on.set_text(LanguageHelper::currentMessages[LANG_STOP]);
|
||||||
|
}
|
||||||
|
} // if play_running || stop_running
|
||||||
|
};
|
||||||
|
|
||||||
|
btn_mode_decrease.on_select = [this](Button&) {
|
||||||
|
if (toy_packet > 0) {
|
||||||
|
toy_packet--;
|
||||||
|
printCurrentModes();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
btn_mode_increase.on_select = [this](Button&) {
|
||||||
|
if (stop_running || play_running) {
|
||||||
|
if (play_running && (toy_packet < max_plays - 1)) {
|
||||||
|
toy_packet++;
|
||||||
|
} else {
|
||||||
|
if (stop_running && toy_packet < max_stops - 1) {
|
||||||
|
toy_packet++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printCurrentModes();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
btn_pcknum_inc.on_select = [this](Button&) {
|
||||||
|
if (!button_onstate) {
|
||||||
|
chk_mode_ncnt.set_value(true);
|
||||||
|
if (n_message_set < n_message_max) {
|
||||||
|
n_message_set++;
|
||||||
|
} else {
|
||||||
|
n_message_set = 0;
|
||||||
|
}
|
||||||
|
message_num.set_value(n_message_set);
|
||||||
|
n_message_current = n_message_set;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
btn_pcknum_dec.on_select = [this](Button&) {
|
||||||
|
if (!button_onstate) {
|
||||||
|
chk_mode_ncnt.set_value(true);
|
||||||
|
if (n_message_set > 0) {
|
||||||
|
n_message_set--;
|
||||||
|
} else {
|
||||||
|
n_message_set = n_message_max;
|
||||||
|
}
|
||||||
|
message_num.set_value(n_message_set);
|
||||||
|
n_message_current = n_message_set;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
message_num.on_change = [this](int32_t v) {
|
||||||
|
if (!button_onstate) {
|
||||||
|
chk_mode_ncnt.set_value(true);
|
||||||
|
n_message_set = static_cast<uint16_t>(v);
|
||||||
|
n_message_current = n_message_set;
|
||||||
|
} else {
|
||||||
|
if (!button_onstate) message_num.set_value(n_message_current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
chk_mode_rnd.on_select = [this](Checkbox&, bool v) {
|
||||||
|
random_running = v;
|
||||||
|
};
|
||||||
|
|
||||||
|
chk_mode_play.on_select = [this](Checkbox&, bool v) {
|
||||||
|
play_running = v;
|
||||||
|
if (play_running && stop_running) {
|
||||||
|
toy_packet = 0;
|
||||||
|
stop_running = false;
|
||||||
|
chk_mode_stop.set_value(stop_running);
|
||||||
|
}
|
||||||
|
if (play_running) printCurrentModes();
|
||||||
|
};
|
||||||
|
|
||||||
|
chk_mode_stop.on_select = [this](Checkbox&, bool v) {
|
||||||
|
stop_running = v;
|
||||||
|
if (play_running && stop_running) {
|
||||||
|
toy_packet = 0;
|
||||||
|
play_running = false;
|
||||||
|
chk_mode_play.set_value(play_running);
|
||||||
|
}
|
||||||
|
if (stop_running) printCurrentModes();
|
||||||
|
};
|
||||||
|
|
||||||
|
chk_mode_ncnt.on_select = [this](Checkbox&, bool v) {
|
||||||
|
n_message_running = v;
|
||||||
|
if (n_message_running && inf_message_running) {
|
||||||
|
inf_message_running = false;
|
||||||
|
chk_mode_infinite.set_value(inf_message_running);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
chk_mode_infinite.on_select = [this](Checkbox&, bool v) {
|
||||||
|
inf_message_running = v;
|
||||||
|
if (n_message_running && inf_message_running) {
|
||||||
|
n_message_running = false;
|
||||||
|
chk_mode_ncnt.set_value(n_message_running);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
options_target.on_change = [this](size_t, int32_t i) {
|
||||||
|
target = (uint8_t)i;
|
||||||
|
};
|
||||||
|
|
||||||
|
chk_mode_infinite.set_value(true);
|
||||||
|
chk_mode_play.set_value(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdultToysView::hidden_program(bool hide) {
|
||||||
|
options_target.hidden(hide);
|
||||||
|
labels.hidden(hide);
|
||||||
|
button_on.hidden(hide);
|
||||||
|
btn_mode_decrease.hidden(hide);
|
||||||
|
btn_mode_increase.hidden(hide);
|
||||||
|
btn_pcknum_inc.hidden(hide);
|
||||||
|
btn_pcknum_dec.hidden(hide);
|
||||||
|
chk_mode_rnd.hidden(hide);
|
||||||
|
chk_mode_play.hidden(hide);
|
||||||
|
chk_mode_stop.hidden(hide);
|
||||||
|
chk_mode_ncnt.hidden(hide);
|
||||||
|
chk_mode_infinite.hidden(hide);
|
||||||
|
field_frequency.hidden(hide);
|
||||||
|
txt_selected_mode.hidden(hide);
|
||||||
|
message_num.hidden(hide);
|
||||||
|
tx_view.hidden(hide);
|
||||||
|
btn_adult.hidden(!hide);
|
||||||
|
btn_child.hidden(!hide);
|
||||||
|
screen_message_1.hidden(!hide);
|
||||||
|
screen_message_2.hidden(!hide);
|
||||||
|
screen_message_3.hidden(!hide);
|
||||||
|
screen_message_4.hidden(!hide);
|
||||||
|
screen_message_5.hidden(!hide);
|
||||||
|
screen_message_6.hidden(!hide);
|
||||||
|
screen_message_7.hidden(!hide);
|
||||||
|
screen_message_8.hidden(!hide);
|
||||||
|
screen_message_9.hidden(!hide);
|
||||||
|
screen_message_10.hidden(!hide);
|
||||||
|
set_dirty();
|
||||||
|
if (hide)
|
||||||
|
btn_child.focus();
|
||||||
|
else
|
||||||
|
button_on.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdultToysView::on_show() {
|
||||||
|
hidden_program(!start_screen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdultToysView::createPacket(bool regenerate) {
|
||||||
|
if (regenerate) randomizeMac();
|
||||||
|
randomChn();
|
||||||
|
if (target == 1 || 1) { // now only lovespouse supported, in the future, need to separee them
|
||||||
|
uint32_t mode = play_running ? plays[toy_packet].value : stops[toy_packet].value;
|
||||||
|
|
||||||
|
const uint8_t size = 22;
|
||||||
|
uint8_t packet[size];
|
||||||
|
uint8_t i = 0;
|
||||||
|
|
||||||
|
// 1. AD Flags
|
||||||
|
packet[i++] = 2;
|
||||||
|
packet[i++] = 0x01;
|
||||||
|
packet[i++] = 0x1A;
|
||||||
|
|
||||||
|
// 2. Manufacturer Specific
|
||||||
|
packet[i++] = 14;
|
||||||
|
packet[i++] = 0xFF;
|
||||||
|
packet[i++] = 0xFF;
|
||||||
|
packet[i++] = 0x00;
|
||||||
|
packet[i++] = 0x6D;
|
||||||
|
packet[i++] = 0xB6;
|
||||||
|
packet[i++] = 0x43;
|
||||||
|
packet[i++] = 0xCE;
|
||||||
|
packet[i++] = 0x97;
|
||||||
|
packet[i++] = 0xFE;
|
||||||
|
packet[i++] = 0x42;
|
||||||
|
packet[i++] = 0x7C;
|
||||||
|
packet[i++] = (mode >> 0x10) & 0xFF;
|
||||||
|
packet[i++] = (mode >> 0x8) & 0xFF;
|
||||||
|
packet[i++] = (mode >> 0x0) & 0xFF;
|
||||||
|
|
||||||
|
// 3. Service UUID List
|
||||||
|
packet[i++] = 3;
|
||||||
|
packet[i++] = 0x03;
|
||||||
|
packet[i++] = 0x8F;
|
||||||
|
packet[i++] = 0xAE;
|
||||||
|
|
||||||
|
std::string res = to_string_hex_array(packet, i);
|
||||||
|
|
||||||
|
memset(advertisementData, 0, sizeof(advertisementData));
|
||||||
|
std::copy(res.begin(), res.end(), advertisementData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AdultToysView::~AdultToysView() {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdultToysView::stop() {
|
||||||
|
transmitter_model.disable();
|
||||||
|
baseband::shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdultToysView::start() {
|
||||||
|
baseband::run_image(portapack::spi_flash::image_tag_btle_tx);
|
||||||
|
transmitter_model.enable();
|
||||||
|
on_tx_progress(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdultToysView::reset() {
|
||||||
|
stop();
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t AdultToysView::randomize(uint8_t max) {
|
||||||
|
return static_cast<uint8_t>(rand() % max);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdultToysView::printCurrentModes() {
|
||||||
|
uint8_t max_val = play_running ? max_plays : max_stops;
|
||||||
|
auto name = play_running ? plays[toy_packet].name : stops[toy_packet].name;
|
||||||
|
std::string current = to_string_dec_uint(toy_packet + 1);
|
||||||
|
std::string max_val_str = to_string_dec_uint(max_val);
|
||||||
|
|
||||||
|
std::string result_str = current;
|
||||||
|
result_str += "/";
|
||||||
|
result_str += max_val_str;
|
||||||
|
result_str += " ";
|
||||||
|
result_str += name;
|
||||||
|
txt_selected_mode.set(result_str.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t AdultToysView::get_freq_by_channel_number(uint8_t channel_number) {
|
||||||
|
uint64_t freq_hz;
|
||||||
|
|
||||||
|
switch (channel_number) {
|
||||||
|
case 37:
|
||||||
|
freq_hz = 2'402'000'000ull;
|
||||||
|
break;
|
||||||
|
case 38:
|
||||||
|
freq_hz = 2'426'000'000ull;
|
||||||
|
break;
|
||||||
|
case 39:
|
||||||
|
freq_hz = 2'480'000'000ull;
|
||||||
|
break;
|
||||||
|
case 0 ... 10:
|
||||||
|
freq_hz = 2'404'000'000ull + channel_number * 2'000'000ull;
|
||||||
|
break;
|
||||||
|
case 11 ... 36:
|
||||||
|
freq_hz = 2'428'000'000ull + (channel_number - 11) * 2'000'000ull;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
freq_hz = UINT64_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
return freq_hz;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdultToysView::randomizeMac() {
|
||||||
|
const char hexDigits[] = "0123456789ABCDEF";
|
||||||
|
// Generate 12 random hexadecimal characters
|
||||||
|
for (int i = 0; i < 12; ++i) {
|
||||||
|
int randomIndex = rand() % 16;
|
||||||
|
mac[i] = hexDigits[randomIndex];
|
||||||
|
}
|
||||||
|
mac[12] = '\0'; // Null-terminate the string
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdultToysView::randomChn() {
|
||||||
|
channel_number = 37 + std::rand() % (39 - 37 + 1);
|
||||||
|
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdultToysView::on_tx_progress(const bool done) {
|
||||||
|
if (!done) return;
|
||||||
|
if (!button_onstate) return;
|
||||||
|
bool regenerate = (counter++ % 600) == 0;
|
||||||
|
if (random_running && regenerate) {
|
||||||
|
toy_packet = randomize(play_running ? max_plays : max_stops);
|
||||||
|
}
|
||||||
|
createPacket(regenerate);
|
||||||
|
printCurrentModes();
|
||||||
|
|
||||||
|
if (n_message_running) {
|
||||||
|
if (n_message_current > 0) {
|
||||||
|
n_message_current--;
|
||||||
|
message_num.set_value(n_message_current);
|
||||||
|
} else {
|
||||||
|
stop();
|
||||||
|
message_num.set_value(n_message_set);
|
||||||
|
button_on.set_text(LanguageHelper::currentMessages[LANG_START]);
|
||||||
|
button_onstate = false;
|
||||||
|
n_message_current = n_message_set;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} // if n_message
|
||||||
|
|
||||||
|
baseband::set_btletx(channel_number, mac, advertisementData, pduType);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ui::external_app::adult_toys_controller
|
||||||
+245
@@ -0,0 +1,245 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Pezsma
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code from https://github.com/Next-Flip/Momentum-Apps/blob/89d493daa1ea0cb86906fa0042c41dd4edc22a6a/ble_spam/protocols/lovespouse.c#L93
|
||||||
|
// Thanks for the work of the original creators!
|
||||||
|
|
||||||
|
#ifndef __UI_ADULT_TOYS_H__
|
||||||
|
#define __UI_ADULT_TOYS_H__
|
||||||
|
|
||||||
|
#include "ui.hpp"
|
||||||
|
#include "ui_language.hpp"
|
||||||
|
#include "ui_navigation.hpp"
|
||||||
|
#include "ui_transmitter.hpp"
|
||||||
|
#include "ui_freq_field.hpp"
|
||||||
|
#include "ui_record_view.hpp"
|
||||||
|
#include "app_settings.hpp"
|
||||||
|
#include "radio_state.hpp"
|
||||||
|
#include "log_file.hpp"
|
||||||
|
#include "utility.hpp"
|
||||||
|
|
||||||
|
using namespace ui;
|
||||||
|
|
||||||
|
namespace ui::external_app::adult_toys_controller {
|
||||||
|
|
||||||
|
enum PKT_TYPE {
|
||||||
|
PKT_TYPE_INVALID_TYPE,
|
||||||
|
PKT_TYPE_RAW,
|
||||||
|
PKT_TYPE_DISCOVERY,
|
||||||
|
PKT_TYPE_IBEACON,
|
||||||
|
PKT_TYPE_ADV_IND,
|
||||||
|
PKT_TYPE_ADV_DIRECT_IND,
|
||||||
|
PKT_TYPE_ADV_NONCONN_IND,
|
||||||
|
PKT_TYPE_ADV_SCAN_IND,
|
||||||
|
PKT_TYPE_SCAN_REQ,
|
||||||
|
PKT_TYPE_SCAN_RSP,
|
||||||
|
PKT_TYPE_CONNECT_REQ,
|
||||||
|
PKT_TYPE_LL_DATA,
|
||||||
|
PKT_TYPE_LL_CONNECTION_UPDATE_REQ,
|
||||||
|
PKT_TYPE_LL_CHANNEL_MAP_REQ,
|
||||||
|
PKT_TYPE_LL_TERMINATE_IND,
|
||||||
|
PKT_TYPE_LL_ENC_REQ,
|
||||||
|
PKT_TYPE_LL_ENC_RSP,
|
||||||
|
PKT_TYPE_LL_START_ENC_REQ,
|
||||||
|
PKT_TYPE_LL_START_ENC_RSP,
|
||||||
|
PKT_TYPE_LL_UNKNOWN_RSP,
|
||||||
|
PKT_TYPE_LL_FEATURE_REQ,
|
||||||
|
PKT_TYPE_LL_FEATURE_RSP,
|
||||||
|
PKT_TYPE_LL_PAUSE_ENC_REQ,
|
||||||
|
PKT_TYPE_LL_PAUSE_ENC_RSP,
|
||||||
|
PKT_TYPE_LL_VERSION_IND,
|
||||||
|
PKT_TYPE_LL_REJECT_IND,
|
||||||
|
PKT_TYPE_NUM_PKT_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
class AdultToysView : public ui::View {
|
||||||
|
public:
|
||||||
|
AdultToysView(NavigationView& nav);
|
||||||
|
~AdultToysView();
|
||||||
|
|
||||||
|
void focus() override;
|
||||||
|
void on_show() override;
|
||||||
|
|
||||||
|
std::string title() const override {
|
||||||
|
return "Adult Toys";
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LovespouseMode {
|
||||||
|
uint32_t value;
|
||||||
|
std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
NavigationView& nav_;
|
||||||
|
TxRadioState radio_state_{
|
||||||
|
2'402'000'000 /* frequency */,
|
||||||
|
4'000'000 /* bandwidth */,
|
||||||
|
4'000'000 /* sampling rate */
|
||||||
|
};
|
||||||
|
|
||||||
|
TxFrequencyField field_frequency{
|
||||||
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
|
nav_};
|
||||||
|
|
||||||
|
TransmitterView2 tx_view{
|
||||||
|
{UI_POS_X(11), UI_POS_Y(0)},
|
||||||
|
/*short_ui*/ true};
|
||||||
|
|
||||||
|
app_settings::SettingsManager settings_{
|
||||||
|
"Adult Toys", app_settings::Mode::TX};
|
||||||
|
|
||||||
|
OptionsField options_target{
|
||||||
|
{UI_POS_X(6), UI_POS_Y(1)},
|
||||||
|
11,
|
||||||
|
{{"LoveSpouse", 1}}};
|
||||||
|
|
||||||
|
Button btn_adult{{UI_POS_X(0), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(10), UI_POS_HEIGHT(3)}, "adult"};
|
||||||
|
|
||||||
|
Button btn_child{{UI_POS_X_RIGHT(10), UI_POS_Y_BOTTOM(4), UI_POS_WIDTH(10), UI_POS_HEIGHT(3)}, "child"};
|
||||||
|
|
||||||
|
Button button_on{
|
||||||
|
{UI_POS_X(0), UI_POS_Y(3), UI_POS_WIDTH(12), UI_POS_HEIGHT(2)},
|
||||||
|
LanguageHelper::currentMessages[LANG_START]};
|
||||||
|
|
||||||
|
Button btn_mode_decrease{
|
||||||
|
{UI_POS_X(0), UI_POS_Y(13), UI_POS_WIDTH(3), UI_POS_HEIGHT(2)},
|
||||||
|
"<-"};
|
||||||
|
|
||||||
|
Button btn_mode_increase{
|
||||||
|
{UI_POS_X_RIGHT(3), UI_POS_Y(13), UI_POS_WIDTH(3), UI_POS_HEIGHT(2)},
|
||||||
|
"->"};
|
||||||
|
|
||||||
|
Text txt_selected_mode{{UI_POS_X_CENTER(22), UI_POS_Y(13.5), UI_POS_WIDTH(22), UI_POS_HEIGHT(1)}, ""};
|
||||||
|
|
||||||
|
Button btn_pcknum_inc{
|
||||||
|
{UI_POS_X(7), UI_POS_Y(9), UI_POS_WIDTH(2), UI_POS_HEIGHT(1.5)},
|
||||||
|
"+"};
|
||||||
|
|
||||||
|
Button btn_pcknum_dec{
|
||||||
|
{UI_POS_X(0), UI_POS_Y(9), UI_POS_WIDTH(2), UI_POS_HEIGHT(1.5)},
|
||||||
|
"-"};
|
||||||
|
|
||||||
|
NumberField message_num{{UI_POS_X(3), UI_POS_Y(9.2)}, 3, {0, 999}, 1, ' ', true};
|
||||||
|
|
||||||
|
Checkbox chk_mode_rnd{{UI_POS_X_RIGHT(15), UI_POS_Y(3)}, 12, "Random Msg.", false};
|
||||||
|
Checkbox chk_mode_play{{UI_POS_X_RIGHT(15), UI_POS_Y(5)}, 10, "Play Mode", false};
|
||||||
|
Checkbox chk_mode_stop{{UI_POS_X_RIGHT(15), UI_POS_Y(7)}, 10, "Stop Mode", false};
|
||||||
|
Checkbox chk_mode_ncnt{{UI_POS_X_RIGHT(15), UI_POS_Y(9)}, 7, "N Msg.", false};
|
||||||
|
Checkbox chk_mode_infinite{{UI_POS_X_RIGHT(15), UI_POS_Y(11)}, 10, "Inf. Msg.", false};
|
||||||
|
|
||||||
|
Text screen_message_1{{0, 0, UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)}, "The application is intended"};
|
||||||
|
Text screen_message_2{{0, 25, UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)}, "for controlling Love Spouse"};
|
||||||
|
Text screen_message_3{{0, 50, UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)}, "auxiliary tools/devices."};
|
||||||
|
Text screen_message_4{{0, 75, UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)}, "It is only for use by adults."};
|
||||||
|
Text screen_message_5{{0, 100, UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)}, "Are you an adult?"};
|
||||||
|
|
||||||
|
Text screen_message_6{{0, 140, UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)}, "To use the application, "};
|
||||||
|
Text screen_message_7{{0, 165, UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)}, "I assume full responsibility"};
|
||||||
|
Text screen_message_8{{0, 190, UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)}, "for the \"I do not assume"};
|
||||||
|
Text screen_message_9{{0, 215, UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)}, "responsibility\"."};
|
||||||
|
Text screen_message_10{{UI_POS_X_RIGHT(16), 230, UI_POS_WIDTH(16), UI_POS_HEIGHT(1)}, "(The developer)"};
|
||||||
|
|
||||||
|
Labels labels{
|
||||||
|
{{UI_POS_X(0), UI_POS_Y(1)}, "Type:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
|
bool button_onstate{false};
|
||||||
|
bool play_running{false};
|
||||||
|
bool stop_running{false};
|
||||||
|
bool random_running{false};
|
||||||
|
bool n_message_running{false};
|
||||||
|
bool inf_message_running{false};
|
||||||
|
bool start_screen{false};
|
||||||
|
|
||||||
|
uint8_t target = 1; // lovespouse
|
||||||
|
|
||||||
|
char mac[13] = "010203040506";
|
||||||
|
uint8_t channel_number = 37;
|
||||||
|
char advertisementData[63] = {"03032CFE06162CFED5A59E020AB4\0"};
|
||||||
|
|
||||||
|
PKT_TYPE pduType = {PKT_TYPE_DISCOVERY};
|
||||||
|
|
||||||
|
uint8_t toy_packet = 0;
|
||||||
|
uint16_t n_message_max = 999;
|
||||||
|
uint16_t n_message_set = 0;
|
||||||
|
uint16_t n_message_current = 0;
|
||||||
|
static const size_t max_plays = 27;
|
||||||
|
static const size_t max_stops = 3;
|
||||||
|
|
||||||
|
uint16_t counter = 599;
|
||||||
|
|
||||||
|
void createPacket(bool regenerate);
|
||||||
|
void start();
|
||||||
|
void stop();
|
||||||
|
void reset();
|
||||||
|
void printCurrentModes();
|
||||||
|
void on_tx_progress(const bool done);
|
||||||
|
void hidden_program(bool hide);
|
||||||
|
void randomizeMac();
|
||||||
|
void randomChn();
|
||||||
|
uint8_t randomize(uint8_t max);
|
||||||
|
uint64_t get_freq_by_channel_number(uint8_t channel_number);
|
||||||
|
|
||||||
|
MessageHandlerRegistration message_handler_tx_progress{
|
||||||
|
Message::ID::TXProgress,
|
||||||
|
[this](const Message* const p) {
|
||||||
|
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
|
||||||
|
this->on_tx_progress(message.done);
|
||||||
|
}};
|
||||||
|
|
||||||
|
LovespouseMode plays[max_plays] = {
|
||||||
|
{0xE49C6C, "Classic 1"},
|
||||||
|
{0xE7075E, "Classic 2"},
|
||||||
|
{0xE68E4F, "Classic 3"},
|
||||||
|
{0xE1313B, "Classic 4"},
|
||||||
|
{0xE0B82A, "Classic 5"},
|
||||||
|
{0xE32318, "Classic 6"},
|
||||||
|
{0xE2AA09, "Classic 7"},
|
||||||
|
{0xED5DF1, "Classic 8"},
|
||||||
|
{0xECD4E0, "Classic 9"},
|
||||||
|
{0xD41F5D, "Independent 1-1"},
|
||||||
|
{0xD7846F, "Independent 1-2"},
|
||||||
|
{0xD60D7E, "Independent 1-3"},
|
||||||
|
{0xD1B20A, "Independent 1-4"},
|
||||||
|
{0xD0B31B, "Independent 1-5"},
|
||||||
|
{0xD3A029, "Independent 1-6"},
|
||||||
|
{0xD22938, "Independent 1-7"},
|
||||||
|
{0xDDDEC0, "Independent 1-8"},
|
||||||
|
{0xDC57D1, "Independent 1-9"},
|
||||||
|
{0xA4982E, "Independent 2-1"},
|
||||||
|
{0xA7031C, "Independent 2-2"},
|
||||||
|
{0xA68A0D, "Independent 2-3"},
|
||||||
|
{0xA13579, "Independent 2-4"},
|
||||||
|
{0xA0BC68, "Independent 2-5"},
|
||||||
|
{0xA3275A, "Independent 2-6"},
|
||||||
|
{0xA2AE4B, "Independent 2-7"},
|
||||||
|
{0xAD59B3, "Independent 2-8"},
|
||||||
|
{0xACD0A2, "Independent 2-9"},
|
||||||
|
};
|
||||||
|
|
||||||
|
LovespouseMode stops[max_stops] = {
|
||||||
|
{0xE5157D, "Classic Stop"},
|
||||||
|
{0xD5964C, "Independent 1 Stop"},
|
||||||
|
{0xA5113F, "Independent 2 Stop"},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}; // namespace ui::external_app::adult_toys_controller
|
||||||
|
|
||||||
|
#endif // ui_adult_toys_controller_hpp
|
||||||
+9
-9
@@ -73,31 +73,31 @@ class AFSKRxView : public View {
|
|||||||
bool logging{false};
|
bool logging{false};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{13 * 8, 0 * 16}};
|
{13 * 8, UI_POS_Y(0)}};
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{15 * 8, UI_POS_Y(0)}};
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{18 * 8, UI_POS_Y(0)}};
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4}};
|
{UI_POS_X(21), 0, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||||
Channel channel{
|
Channel channel{
|
||||||
{21 * 8, 5, 6 * 8, 4}};
|
{UI_POS_X(21), 5, UI_POS_WIDTH_REMAINING(24), 4}};
|
||||||
|
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{screen_width - 2 * 8, 0 * 16}};
|
{screen_width - 2 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 16},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
Checkbox check_log{
|
Checkbox check_log{
|
||||||
{0 * 8, 1 * 16},
|
{UI_POS_X(0), 1 * 16},
|
||||||
3,
|
3,
|
||||||
LanguageHelper::currentMessages[LANG_LOG],
|
LanguageHelper::currentMessages[LANG_LOG],
|
||||||
false};
|
false};
|
||||||
|
|
||||||
Text text_debug{
|
Text text_debug{
|
||||||
{0 * 8, 12 + 2 * 16, screen_width, 16},
|
{UI_POS_X(0), 12 + 2 * 16, screen_width, 16},
|
||||||
LanguageHelper::currentMessages[LANG_DEBUG]};
|
LanguageHelper::currentMessages[LANG_DEBUG]};
|
||||||
|
|
||||||
Button button_modem_setup{
|
Button button_modem_setup{
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ class AnalogTvView : public View {
|
|||||||
app_settings::SettingsManager settings_{
|
app_settings::SettingsManager settings_{
|
||||||
"rx_tv", app_settings::Mode::RX};
|
"rx_tv", app_settings::Mode::RX};
|
||||||
|
|
||||||
const Rect options_view_rect{0 * 8, 1 * 16, screen_width, 1 * 16};
|
const Rect options_view_rect{UI_POS_X(0), 1 * 16, screen_width, 1 * 16};
|
||||||
const Rect nbfm_view_rect{0 * 8, 1 * 16, 18 * 8, 1 * 16};
|
const Rect nbfm_view_rect{UI_POS_X(0), 1 * 16, 18 * 8, 1 * 16};
|
||||||
|
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4}};
|
{21 * 8, 0, 6 * 8, 4}};
|
||||||
@@ -71,17 +71,17 @@ class AnalogTvView : public View {
|
|||||||
{21 * 8, 10, 6 * 8, 4}};
|
{21 * 8, 10, 6 * 8, 4}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{5 * 8, 0 * 16},
|
{5 * 8, UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{15 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{18 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
OptionsField options_modulation{
|
OptionsField options_modulation{
|
||||||
{0 * 8, 0 * 16},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
4,
|
4,
|
||||||
{
|
{
|
||||||
{"TV ", toUType(ReceiverModel::Mode::WidebandFMAudio)},
|
{"TV ", toUType(ReceiverModel::Mode::WidebandFMAudio)},
|
||||||
@@ -90,7 +90,7 @@ class AnalogTvView : public View {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{27 * 8, 0 * 16}};
|
{27 * 8, UI_POS_Y(0)}};
|
||||||
|
|
||||||
std::unique_ptr<Widget> options_widget{};
|
std::unique_ptr<Widget> options_widget{};
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -34,7 +34,7 @@ using namespace portapack;
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace ui {
|
namespace ui::external_app::analogtv {
|
||||||
namespace tv {
|
namespace tv {
|
||||||
|
|
||||||
/* TimeScopeView******************************************************/
|
/* TimeScopeView******************************************************/
|
||||||
@@ -235,4 +235,4 @@ void TVWidget::on_audio_spectrum() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace tv */
|
} /* namespace tv */
|
||||||
} /* namespace ui */
|
} // namespace ui::external_app::analogtv
|
||||||
+6
-6
@@ -33,7 +33,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
namespace ui {
|
namespace ui::external_app::analogtv {
|
||||||
namespace tv {
|
namespace tv {
|
||||||
|
|
||||||
class TimeScopeView : public View {
|
class TimeScopeView : public View {
|
||||||
@@ -50,11 +50,11 @@ class TimeScopeView : public View {
|
|||||||
int16_t audio_spectrum[128]{0};
|
int16_t audio_spectrum[128]{0};
|
||||||
|
|
||||||
/*Labels labels {
|
/*Labels labels {
|
||||||
{ { 6 * 8, 0 * 16 }, "Hz", Theme::getInstance()->fg_light->foreground }
|
{ { 6 * 8,UI_POS_Y(0) }, "Hz", Theme::getInstance()->fg_light->foreground }
|
||||||
};*/
|
};*/
|
||||||
/*
|
/*
|
||||||
NumberField field_frequency {
|
NumberField field_frequency {
|
||||||
{ 0 * 8, 0 * 16 },
|
{ 0 * 8,UI_POS_Y(0) },
|
||||||
5,
|
5,
|
||||||
{ 0, 48000 },
|
{ 0, 48000 },
|
||||||
48000 / 240,
|
48000 / 240,
|
||||||
@@ -108,7 +108,7 @@ class TVWidget : public View {
|
|||||||
|
|
||||||
void paint(Painter& painter) override;
|
void paint(Painter& painter) override;
|
||||||
NumberField field_xcorr{
|
NumberField field_xcorr{
|
||||||
{0 * 8, 0 * 16},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
5,
|
5,
|
||||||
{0, 128},
|
{0, 128},
|
||||||
1,
|
1,
|
||||||
@@ -117,7 +117,7 @@ class TVWidget : public View {
|
|||||||
private:
|
private:
|
||||||
void update_widgets_rect();
|
void update_widgets_rect();
|
||||||
|
|
||||||
const Rect audio_spectrum_view_rect{0 * 8, 0 * 16, screen_width, 2 * 16 + 20};
|
const Rect audio_spectrum_view_rect{UI_POS_X(0), UI_POS_Y(0), screen_width, 2 * 16 + 20};
|
||||||
static constexpr Dim audio_spectrum_height = 16 * 2 + 20;
|
static constexpr Dim audio_spectrum_height = 16 * 2 + 20;
|
||||||
static constexpr Dim scale_height = 20;
|
static constexpr Dim scale_height = 20;
|
||||||
|
|
||||||
@@ -167,6 +167,6 @@ class TVWidget : public View {
|
|||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace tv */
|
} /* namespace tv */
|
||||||
} /* namespace ui */
|
} // namespace ui::external_app::analogtv
|
||||||
|
|
||||||
#endif /*__UI_TV_H__*/
|
#endif /*__UI_TV_H__*/
|
||||||
@@ -89,7 +89,7 @@ class WhipCalcView : public View {
|
|||||||
{0, 6 * 16, screen_width, 160}};
|
{0, 6 * 16, screen_width, 160}};
|
||||||
|
|
||||||
Button button_exit{
|
Button button_exit{
|
||||||
{72, 17 * 16, 96, 32},
|
{UI_POS_X_RIGHT(12), UI_POS_Y_BOTTOM(3), 96, 32},
|
||||||
"Back"};
|
"Back"};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* copyleft spammingdramaqueen
|
* copyleft 2024 zxkmm AKA zix aka sommermorgentraum
|
||||||
*
|
*
|
||||||
* This file is part of PortaPack.
|
* This file is part of PortaPack.
|
||||||
*
|
*
|
||||||
@@ -50,7 +50,7 @@ AppManagerView::AppManagerView(NavigationView& nav)
|
|||||||
&button_set_cancel_autostart,
|
&button_set_cancel_autostart,
|
||||||
&button_clean_autostart});
|
&button_clean_autostart});
|
||||||
|
|
||||||
menu_view.set_parent_rect({0, 2 * 8, screen_width, 24 * 8});
|
menu_view.set_parent_rect({0, 2 * 8, screen_width, UI_POS_HEIGHT_REMAINING(7)});
|
||||||
|
|
||||||
menu_view.on_highlight = [this]() {
|
menu_view.on_highlight = [this]() {
|
||||||
if (menu_view.highlighted_index() >= app_list_index) {
|
if (menu_view.highlighted_index() >= app_list_index) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* copyleft spammingdramaqueen
|
* copyleft 2024 zxkmm AKA zix aka sommermorgentraum
|
||||||
*
|
*
|
||||||
* This file is part of PortaPack.
|
* This file is part of PortaPack.
|
||||||
*
|
*
|
||||||
@@ -43,28 +43,28 @@ class AppManagerView : public View {
|
|||||||
uint16_t app_list_index{0};
|
uint16_t app_list_index{0};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 0 * 16}, "App list:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), UI_POS_Y(0)}, "App list:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
MenuView menu_view{};
|
MenuView menu_view{};
|
||||||
|
|
||||||
Text text_app_info{
|
Text text_app_info{
|
||||||
{0, 27 * 8, screen_width, 16},
|
{0, UI_POS_Y_BOTTOM(6), screen_width, UI_POS_HEIGHT(1)},
|
||||||
"Highlight an app"};
|
"Highlight an app"};
|
||||||
|
|
||||||
Button button_hide_unhide{
|
Button button_hide_unhide{
|
||||||
{0, 29 * 8, screen_width / 2 - 1, 32},
|
{0, UI_POS_Y_BOTTOM(5), screen_width / 2 - 1, UI_POS_HEIGHT(2)},
|
||||||
"Hide/Show"};
|
"Hide/Show"};
|
||||||
|
|
||||||
Button button_clean_hide{
|
Button button_clean_hide{
|
||||||
{screen_width / 2 + 2, 29 * 8, screen_width / 2 - 2, 32},
|
{screen_width / 2 + 2, UI_POS_Y_BOTTOM(5), screen_width / 2 - 2, UI_POS_HEIGHT(2)},
|
||||||
"Clean Hidden"};
|
"Clean Hidden"};
|
||||||
|
|
||||||
Button button_set_cancel_autostart{
|
Button button_set_cancel_autostart{
|
||||||
{0, screen_height - 32 - 16, screen_width / 2 - 1, 32},
|
{0, screen_height - 32 - 16, screen_width / 2 - 1, UI_POS_HEIGHT(2)},
|
||||||
"Set Autostart"};
|
"Set Autostart"};
|
||||||
|
|
||||||
Button button_clean_autostart{
|
Button button_clean_autostart{
|
||||||
{screen_width / 2 + 2, screen_height - 32 - 16, screen_width / 2 - 2, 32},
|
{screen_width / 2 + 2, screen_height - 32 - 16, screen_width / 2 - 2, UI_POS_HEIGHT(2)},
|
||||||
"Del Autostart"};
|
"Del Autostart"};
|
||||||
|
|
||||||
std::string get_app_info(uint16_t index, bool is_display_name);
|
std::string get_app_info(uint16_t index, bool is_display_name);
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ class AudioTestView : public View {
|
|||||||
bool beep{false};
|
bool beep{false};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{7 * 8, 3 * 16}, "Audio Beep Test", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X_CENTER(16), 3 * 16}, "Audio Beep Test", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 6 * 16}, "Sample Rate (Hz):", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 6 * 16}, "Sample Rate (Hz):", Theme::getInstance()->fg_light->foreground},
|
||||||
{{25 * 8, 7 * 16}, "Step:", Theme::getInstance()->fg_light->foreground},
|
{{25 * 8, 7 * 16}, "Step:", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 8 * 16}, "Frequency (Hz):", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 8 * 16}, "Frequency (Hz):", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 10 * 16}, "Duration (ms):", Theme::getInstance()->fg_light->foreground},
|
{{UI_POS_X(0), 10 * 16}, "Duration (ms):", Theme::getInstance()->fg_light->foreground},
|
||||||
{{25 * 8, 10 * 16}, "0=con", Theme::getInstance()->fg_light->foreground},
|
{{25 * 8, 10 * 16}, "0=con", Theme::getInstance()->fg_light->foreground},
|
||||||
{{0 * 8, 12 * 16}, "Volume:", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), 12 * 16}, "Volume:", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
OptionsField options_sample_rate{
|
OptionsField options_sample_rate{
|
||||||
{18 * 8, 6 * 16},
|
{18 * 8, 6 * 16},
|
||||||
|
|||||||
+75
-127
@@ -24,25 +24,25 @@ constexpr uint32_t BLUE_TEAM_ADDRESS = BATTLESHIP_BASE_ADDRESS + 2;
|
|||||||
|
|
||||||
BattleshipView::BattleshipView(NavigationView& nav)
|
BattleshipView::BattleshipView(NavigationView& nav)
|
||||||
: nav_{nav} {
|
: nav_{nav} {
|
||||||
|
CELL_SIZE = screen_width / GRID_SIZE;
|
||||||
baseband::run_image(portapack::spi_flash::image_tag_pocsag2);
|
baseband::run_image(portapack::spi_flash::image_tag_pocsag2);
|
||||||
|
|
||||||
add_children({&text_title, &text_subtitle,
|
add_children({&text_title, &text_subtitle,
|
||||||
&rect_radio_settings, &label_radio, &button_frequency,
|
//&rect_radio_settings, &rect_audio_settings, &rect_team_selection,
|
||||||
|
&label_radio, &button_frequency,
|
||||||
&label_rf_amp, &checkbox_rf_amp,
|
&label_rf_amp, &checkbox_rf_amp,
|
||||||
&label_lna, &field_lna,
|
&label_lna, &field_lna,
|
||||||
&label_vga, &field_vga,
|
&label_vga, &field_vga,
|
||||||
&label_tx_gain, &field_tx_gain,
|
&label_tx_gain, &field_tx_gain,
|
||||||
&rect_audio_settings, &label_audio,
|
&label_audio,
|
||||||
&checkbox_sound, &label_volume, &field_volume,
|
&checkbox_sound, &label_volume, &field_volume,
|
||||||
&rect_team_selection, &label_team,
|
&label_team,
|
||||||
&button_red_team, &button_blue_team,
|
&button_red_team, &button_blue_team,
|
||||||
&rssi, &text_status, &text_score,
|
&rssi,
|
||||||
&button_rotate, &button_place, &button_fire, &button_menu});
|
&button_rotate, &button_place, &button_fire, &button_menu});
|
||||||
|
|
||||||
// Hide in-game elements
|
// Hide in-game elements
|
||||||
rssi.hidden(true);
|
rssi.hidden(true);
|
||||||
text_status.hidden(true);
|
|
||||||
text_score.hidden(true);
|
|
||||||
button_rotate.hidden(true);
|
button_rotate.hidden(true);
|
||||||
button_place.hidden(true);
|
button_place.hidden(true);
|
||||||
button_fire.hidden(true);
|
button_fire.hidden(true);
|
||||||
@@ -151,8 +151,8 @@ BattleshipView::BattleshipView(NavigationView& nav)
|
|||||||
field_tx_gain.set_parent_rect({185, 118, 32, 16});
|
field_tx_gain.set_parent_rect({185, 118, 32, 16});
|
||||||
checkbox_sound.set_parent_rect({17, 187, 80, 24});
|
checkbox_sound.set_parent_rect({17, 187, 80, 24});
|
||||||
field_volume.set_parent_rect({165, 187, 32, 16});
|
field_volume.set_parent_rect({165, 187, 32, 16});
|
||||||
button_red_team.set_parent_rect({25, 242, 85, 45});
|
// button_red_team.set_parent_rect({25, 242, 85, 45});
|
||||||
button_blue_team.set_parent_rect({130, 242, 85, 45});
|
// button_blue_team.set_parent_rect({130, 242, 85, 45});
|
||||||
|
|
||||||
// Make menu elements focusable
|
// Make menu elements focusable
|
||||||
button_frequency.set_focusable(true);
|
button_frequency.set_focusable(true);
|
||||||
@@ -191,11 +191,42 @@ void BattleshipView::init_game() {
|
|||||||
enemy_grid[y][x] = CellState::EMPTY;
|
enemy_grid[y][x] = CellState::EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_ships();
|
setup_ships();
|
||||||
update_score();
|
update_score();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BattleshipView::show_hide_menu(bool menu_vis) {
|
||||||
|
text_title.hidden(!menu_vis);
|
||||||
|
text_subtitle.hidden(!menu_vis);
|
||||||
|
// rect_radio_settings.hidden(!menu_vis); rect_audio_settings.hidden(!menu_vis); rect_team_selection.hidden(!menu_vis);
|
||||||
|
label_radio.hidden(!menu_vis);
|
||||||
|
button_frequency.hidden(!menu_vis);
|
||||||
|
label_rf_amp.hidden(!menu_vis);
|
||||||
|
checkbox_rf_amp.hidden(!menu_vis);
|
||||||
|
label_lna.hidden(!menu_vis);
|
||||||
|
field_lna.hidden(!menu_vis);
|
||||||
|
label_vga.hidden(!menu_vis);
|
||||||
|
field_vga.hidden(!menu_vis);
|
||||||
|
label_tx_gain.hidden(!menu_vis);
|
||||||
|
field_tx_gain.hidden(!menu_vis);
|
||||||
|
label_audio.hidden(!menu_vis);
|
||||||
|
checkbox_sound.hidden(!menu_vis);
|
||||||
|
label_volume.hidden(!menu_vis);
|
||||||
|
field_volume.hidden(!menu_vis);
|
||||||
|
label_team.hidden(!menu_vis);
|
||||||
|
button_red_team.hidden(!menu_vis);
|
||||||
|
button_blue_team.hidden(!menu_vis);
|
||||||
|
rssi.hidden(menu_vis);
|
||||||
|
button_rotate.hidden(menu_vis);
|
||||||
|
button_place.hidden(menu_vis);
|
||||||
|
button_menu.hidden(menu_vis);
|
||||||
|
|
||||||
|
// button_rotate.set_focusable(false); //no need, since can't focus on hidden
|
||||||
|
// button_place.set_focusable(false);
|
||||||
|
// button_menu.set_focusable(false);
|
||||||
|
set_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
void BattleshipView::reset_game() {
|
void BattleshipView::reset_game() {
|
||||||
transmitter_model.disable();
|
transmitter_model.disable();
|
||||||
receiver_model.disable();
|
receiver_model.disable();
|
||||||
@@ -221,50 +252,7 @@ void BattleshipView::reset_game() {
|
|||||||
update_score();
|
update_score();
|
||||||
|
|
||||||
// Toggle visibility
|
// Toggle visibility
|
||||||
bool menu_vis = true;
|
show_hide_menu(true);
|
||||||
bool game_vis = false;
|
|
||||||
|
|
||||||
text_title.hidden(!menu_vis);
|
|
||||||
text_subtitle.hidden(!menu_vis);
|
|
||||||
rect_radio_settings.hidden(!menu_vis);
|
|
||||||
label_radio.hidden(!menu_vis);
|
|
||||||
button_frequency.hidden(!menu_vis);
|
|
||||||
label_rf_amp.hidden(!menu_vis);
|
|
||||||
checkbox_rf_amp.hidden(!menu_vis);
|
|
||||||
label_lna.hidden(!menu_vis);
|
|
||||||
field_lna.hidden(!menu_vis);
|
|
||||||
label_vga.hidden(!menu_vis);
|
|
||||||
field_vga.hidden(!menu_vis);
|
|
||||||
label_tx_gain.hidden(!menu_vis);
|
|
||||||
field_tx_gain.hidden(!menu_vis);
|
|
||||||
rect_audio_settings.hidden(!menu_vis);
|
|
||||||
label_audio.hidden(!menu_vis);
|
|
||||||
checkbox_sound.hidden(!menu_vis);
|
|
||||||
label_volume.hidden(!menu_vis);
|
|
||||||
field_volume.hidden(!menu_vis);
|
|
||||||
rect_team_selection.hidden(!menu_vis);
|
|
||||||
label_team.hidden(!menu_vis);
|
|
||||||
button_red_team.hidden(!menu_vis);
|
|
||||||
button_blue_team.hidden(!menu_vis);
|
|
||||||
|
|
||||||
rssi.hidden(!game_vis);
|
|
||||||
text_status.hidden(!game_vis);
|
|
||||||
text_score.hidden(!game_vis);
|
|
||||||
button_rotate.hidden(!game_vis);
|
|
||||||
button_place.hidden(!game_vis);
|
|
||||||
button_fire.hidden(!game_vis);
|
|
||||||
button_menu.hidden(!game_vis);
|
|
||||||
|
|
||||||
// Restore focusability
|
|
||||||
button_frequency.set_focusable(menu_vis);
|
|
||||||
checkbox_rf_amp.set_focusable(menu_vis);
|
|
||||||
field_lna.set_focusable(menu_vis);
|
|
||||||
field_vga.set_focusable(menu_vis);
|
|
||||||
field_tx_gain.set_focusable(menu_vis);
|
|
||||||
checkbox_sound.set_focusable(menu_vis);
|
|
||||||
field_volume.set_focusable(menu_vis);
|
|
||||||
button_red_team.set_focusable(menu_vis);
|
|
||||||
button_blue_team.set_focusable(menu_vis);
|
|
||||||
|
|
||||||
button_frequency.focus();
|
button_frequency.focus();
|
||||||
set_dirty();
|
set_dirty();
|
||||||
@@ -283,45 +271,10 @@ void BattleshipView::start_team(bool red) {
|
|||||||
game_state = GameState::PLACING_SHIPS;
|
game_state = GameState::PLACING_SHIPS;
|
||||||
|
|
||||||
// Toggle visibility
|
// Toggle visibility
|
||||||
bool menu_vis = false;
|
show_hide_menu(false);
|
||||||
bool game_vis = true;
|
|
||||||
|
|
||||||
text_title.hidden(!menu_vis);
|
|
||||||
text_subtitle.hidden(!menu_vis);
|
|
||||||
rect_radio_settings.hidden(!menu_vis);
|
|
||||||
label_radio.hidden(!menu_vis);
|
|
||||||
button_frequency.hidden(!menu_vis);
|
|
||||||
label_rf_amp.hidden(!menu_vis);
|
|
||||||
checkbox_rf_amp.hidden(!menu_vis);
|
|
||||||
label_lna.hidden(!menu_vis);
|
|
||||||
field_lna.hidden(!menu_vis);
|
|
||||||
label_vga.hidden(!menu_vis);
|
|
||||||
field_vga.hidden(!menu_vis);
|
|
||||||
label_tx_gain.hidden(!menu_vis);
|
|
||||||
field_tx_gain.hidden(!menu_vis);
|
|
||||||
rect_audio_settings.hidden(!menu_vis);
|
|
||||||
label_audio.hidden(!menu_vis);
|
|
||||||
checkbox_sound.hidden(!menu_vis);
|
|
||||||
label_volume.hidden(!menu_vis);
|
|
||||||
field_volume.hidden(!menu_vis);
|
|
||||||
rect_team_selection.hidden(!menu_vis);
|
|
||||||
label_team.hidden(!menu_vis);
|
|
||||||
button_red_team.hidden(!menu_vis);
|
|
||||||
button_blue_team.hidden(!menu_vis);
|
|
||||||
|
|
||||||
rssi.hidden(!game_vis);
|
|
||||||
text_status.hidden(true);
|
|
||||||
text_score.hidden(true);
|
|
||||||
button_rotate.hidden(false);
|
|
||||||
button_place.hidden(false);
|
|
||||||
button_menu.hidden(false);
|
|
||||||
|
|
||||||
current_status = "Place carrier (5)";
|
current_status = "Place carrier (5)";
|
||||||
|
|
||||||
button_rotate.set_focusable(false);
|
|
||||||
button_place.set_focusable(false);
|
|
||||||
button_menu.set_focusable(false);
|
|
||||||
|
|
||||||
focus();
|
focus();
|
||||||
is_transmitting = true;
|
is_transmitting = true;
|
||||||
configure_radio_rx();
|
configure_radio_rx();
|
||||||
@@ -382,7 +335,7 @@ void BattleshipView::configure_radio_rx() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BattleshipView::paint(Painter& painter) {
|
void BattleshipView::paint(Painter& painter) {
|
||||||
painter.fill_rectangle({0, 0, 240, 320}, Color::black());
|
painter.fill_rectangle({0, 0, UI_POS_MAXWIDTH, UI_POS_MAXHEIGHT}, Color::black());
|
||||||
|
|
||||||
if (game_state == GameState::MENU) {
|
if (game_state == GameState::MENU) {
|
||||||
draw_menu_screen(painter);
|
draw_menu_screen(painter);
|
||||||
@@ -426,24 +379,21 @@ void BattleshipView::paint(Painter& painter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Color team_color = is_red_team ? Color::red() : Color::blue();
|
Color team_color = is_red_team ? Color::red() : Color::blue();
|
||||||
painter.fill_rectangle({0, 5, 240, 16}, team_color);
|
painter.fill_rectangle({0, 5, screen_width, 16}, team_color);
|
||||||
|
|
||||||
auto style_white = Style{
|
auto style_white = Style{
|
||||||
.font = ui::font::fixed_8x16,
|
.font = ui::font::fixed_8x16,
|
||||||
.background = team_color,
|
.background = team_color,
|
||||||
.foreground = Color::white()};
|
.foreground = Color::white()};
|
||||||
painter.draw_string({85, 5}, style_white, is_red_team ? "RED TEAM" : "BLUE TEAM");
|
painter.draw_string({UI_POS_X_CENTER(9), 5}, style_white, is_red_team ? "RED TEAM" : "BLUE TEAM");
|
||||||
|
|
||||||
auto style_status = Style{
|
auto style_status = Style{
|
||||||
.font = ui::font::fixed_8x16,
|
.font = ui::font::fixed_8x16,
|
||||||
.background = Color::black(),
|
.background = Color::black(),
|
||||||
.foreground = Color::white()};
|
.foreground = Color::white()};
|
||||||
painter.fill_rectangle({0, 21, 240, 16}, Color::black());
|
painter.fill_rectangle({0, 21, screen_width, 16}, Color::black());
|
||||||
painter.draw_string({10, 21}, style_status, current_status);
|
painter.draw_string({5, 21}, style_status, current_status);
|
||||||
|
painter.draw_string({170, 21}, style_status, current_score);
|
||||||
if (game_state != GameState::MENU) {
|
|
||||||
painter.draw_string({170, 21}, style_status, current_score);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (game_state == GameState::PLACING_SHIPS) {
|
if (game_state == GameState::PLACING_SHIPS) {
|
||||||
draw_grid(painter, GRID_OFFSET_X, GRID_OFFSET_Y + 5, my_grid, true);
|
draw_grid(painter, GRID_OFFSET_X, GRID_OFFSET_Y + 5, my_grid, true);
|
||||||
@@ -452,35 +402,35 @@ void BattleshipView::paint(Painter& painter) {
|
|||||||
}
|
}
|
||||||
} else if (game_state == GameState::MY_TURN) {
|
} else if (game_state == GameState::MY_TURN) {
|
||||||
draw_grid(painter, GRID_OFFSET_X, GRID_OFFSET_Y + 5, enemy_grid, false, true);
|
draw_grid(painter, GRID_OFFSET_X, GRID_OFFSET_Y + 5, enemy_grid, false, true);
|
||||||
painter.draw_string({10, GRID_OFFSET_Y + GRID_SIZE * CELL_SIZE + 10}, style_status,
|
painter.draw_string({0, GRID_OFFSET_Y + GRID_SIZE * CELL_SIZE + 10}, style_status,
|
||||||
"Enemy ships: " + to_string_dec_uint(enemy_ships_remaining));
|
"Enemy: " + to_string_dec_uint(enemy_ships_remaining));
|
||||||
} else if (game_state == GameState::OPPONENT_TURN || game_state == GameState::WAITING_FOR_OPPONENT) {
|
} else if (game_state == GameState::OPPONENT_TURN || game_state == GameState::WAITING_FOR_OPPONENT) {
|
||||||
draw_grid(painter, GRID_OFFSET_X, GRID_OFFSET_Y + 5, my_grid, true);
|
draw_grid(painter, GRID_OFFSET_X, GRID_OFFSET_Y + 5, my_grid, true);
|
||||||
painter.draw_string({10, GRID_OFFSET_Y + GRID_SIZE * CELL_SIZE + 10}, style_status,
|
painter.draw_string({0, GRID_OFFSET_Y + GRID_SIZE * CELL_SIZE + 10}, style_status,
|
||||||
"Your ships: " + to_string_dec_uint(ships_remaining));
|
"You: " + to_string_dec_uint(ships_remaining));
|
||||||
} else if (game_state == GameState::GAME_OVER) {
|
} else if (game_state == GameState::GAME_OVER) {
|
||||||
painter.draw_string({50, 150}, style_status, "Game Over!");
|
painter.draw_string({UI_POS_X_CENTER(11), 150}, style_status, "Game Over!");
|
||||||
painter.draw_string({30, 170}, style_status, current_status);
|
painter.draw_string({30, 170}, style_status, current_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleshipView::draw_menu_screen(Painter& painter) {
|
void BattleshipView::draw_menu_screen(Painter& painter) {
|
||||||
painter.draw_hline({12, 38}, 216, Color::dark_cyan());
|
painter.draw_hline({12, 20 + 16}, screen_width - 24, Color::dark_cyan());
|
||||||
|
|
||||||
painter.fill_rectangle({13, 41, 214, 116}, Color::dark_grey());
|
painter.fill_rectangle({13, 59, screen_width - 26, 116}, Color::dark_grey());
|
||||||
painter.draw_hline({12, 40}, 216, Color::cyan());
|
painter.draw_hline({12, 58}, screen_width - 24, Color::cyan());
|
||||||
painter.draw_hline({12, 157}, 216, Color::cyan());
|
painter.draw_hline({12, 157}, screen_width - 24, Color::cyan());
|
||||||
|
|
||||||
painter.fill_rectangle({13, 165, 214, 43}, Color::dark_grey());
|
painter.fill_rectangle({13, 165, screen_width - 24, 57}, Color::dark_grey());
|
||||||
painter.draw_hline({12, 164}, 216, Color::cyan());
|
painter.draw_hline({12, 164}, screen_width - 24, Color::cyan());
|
||||||
painter.draw_hline({12, 208}, 216, Color::cyan());
|
painter.draw_hline({12, 223}, screen_width - 24, Color::cyan());
|
||||||
|
|
||||||
painter.fill_rectangle({13, 218, 214, 73}, Color::dark_grey());
|
painter.fill_rectangle({13, 232, screen_width - 26, 67}, Color::dark_grey());
|
||||||
painter.draw_hline({12, 217}, 216, Color::cyan());
|
painter.draw_hline({12, 232}, screen_width - 24, Color::cyan());
|
||||||
painter.draw_hline({12, 291}, 216, Color::cyan());
|
painter.draw_hline({12, 300}, screen_width - 24, Color::cyan());
|
||||||
|
|
||||||
// Radio status indicator
|
// Radio status indicator
|
||||||
Point indicator_pos{220, 53};
|
Point indicator_pos{UI_POS_MAXWIDTH - 20, 59};
|
||||||
if (is_transmitting) {
|
if (is_transmitting) {
|
||||||
painter.fill_rectangle({indicator_pos, {6, 6}}, Color::red());
|
painter.fill_rectangle({indicator_pos, {6, 6}}, Color::red());
|
||||||
painter.draw_rectangle({indicator_pos.x() - 1, indicator_pos.y() - 1, 8, 8}, Color::light_grey());
|
painter.draw_rectangle({indicator_pos.x() - 1, indicator_pos.y() - 1, 8, 8}, Color::light_grey());
|
||||||
@@ -490,7 +440,7 @@ void BattleshipView::draw_menu_screen(Painter& painter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleshipView::draw_grid(Painter& painter, uint8_t grid_x, uint8_t grid_y, const std::array<std::array<CellState, GRID_SIZE>, GRID_SIZE>& grid, bool show_ships, bool is_offense_grid) {
|
void BattleshipView::draw_grid(Painter& painter, uint16_t grid_x, uint16_t grid_y, const std::array<std::array<CellState, GRID_SIZE>, GRID_SIZE>& grid, bool show_ships, bool is_offense_grid) {
|
||||||
painter.fill_rectangle({grid_x, grid_y, GRID_SIZE * CELL_SIZE, GRID_SIZE * CELL_SIZE},
|
painter.fill_rectangle({grid_x, grid_y, GRID_SIZE * CELL_SIZE, GRID_SIZE * CELL_SIZE},
|
||||||
Color::dark_blue());
|
Color::dark_blue());
|
||||||
|
|
||||||
@@ -501,26 +451,24 @@ void BattleshipView::draw_grid(Painter& painter, uint8_t grid_x, uint8_t grid_y,
|
|||||||
GRID_SIZE * CELL_SIZE, Color::grey());
|
GRID_SIZE * CELL_SIZE, Color::grey());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t y = 0; y < GRID_SIZE; y++) {
|
for (uint16_t y = 0; y < GRID_SIZE; y++) {
|
||||||
for (uint8_t x = 0; x < GRID_SIZE; x++) {
|
for (uint16_t x = 0; x < GRID_SIZE; x++) {
|
||||||
draw_cell(painter, grid_x + x * CELL_SIZE + 1, grid_y + y * CELL_SIZE + 1,
|
draw_cell(painter, grid_x + x * CELL_SIZE + 1, grid_y + y * CELL_SIZE + 1, grid[y][x], show_ships, is_offense_grid, is_cursor_at(x, y, is_offense_grid));
|
||||||
grid[y][x], show_ships, is_offense_grid,
|
|
||||||
is_cursor_at(x, y, is_offense_grid));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleshipView::draw_cell(Painter& painter, uint8_t cell_x, uint8_t cell_y, CellState state, bool show_ships, bool is_offense_grid, bool is_cursor) {
|
void BattleshipView::draw_cell(Painter& painter, uint16_t cell_x, uint16_t cell_y, CellState state, bool show_ships, bool is_offense_grid, bool is_cursor) {
|
||||||
Color cell_color = Color::dark_blue();
|
Color cell_color = Color::dark_blue();
|
||||||
bool should_fill = false;
|
bool should_fill = false;
|
||||||
|
|
||||||
if (game_state == GameState::PLACING_SHIPS && !is_offense_grid && current_ship_index < 5) {
|
if (game_state == GameState::PLACING_SHIPS && !is_offense_grid && current_ship_index < 5) {
|
||||||
uint8_t ship_size = my_ships[current_ship_index].size();
|
uint8_t ship_size = my_ships[current_ship_index].size();
|
||||||
for (uint8_t i = 0; i < ship_size; i++) {
|
for (uint8_t i = 0; i < ship_size; i++) {
|
||||||
uint8_t preview_x = placing_horizontal ? cursor_x + i : cursor_x;
|
uint16_t preview_x = placing_horizontal ? cursor_x + i : cursor_x;
|
||||||
uint8_t preview_y = placing_horizontal ? cursor_y : cursor_y + i;
|
uint16_t preview_y = placing_horizontal ? cursor_y : cursor_y + i;
|
||||||
uint8_t grid_x = (cell_x - 1) / CELL_SIZE;
|
uint16_t grid_x = (cell_x - 1) / CELL_SIZE;
|
||||||
uint8_t grid_y = (cell_y - GRID_OFFSET_Y - 6) / CELL_SIZE;
|
uint16_t grid_y = (cell_y - GRID_OFFSET_Y - 6) / CELL_SIZE;
|
||||||
if (grid_x == preview_x && grid_y == preview_y && preview_x < GRID_SIZE && preview_y < GRID_SIZE) {
|
if (grid_x == preview_x && grid_y == preview_y && preview_x < GRID_SIZE && preview_y < GRID_SIZE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -597,8 +545,8 @@ void BattleshipView::draw_ship_preview(Painter& painter) {
|
|||||||
uint8_t y = placing_horizontal ? cursor_y : cursor_y + i;
|
uint8_t y = placing_horizontal ? cursor_y : cursor_y + i;
|
||||||
|
|
||||||
if (x < GRID_SIZE && y < GRID_SIZE) {
|
if (x < GRID_SIZE && y < GRID_SIZE) {
|
||||||
uint8_t cell_x = GRID_OFFSET_X + x * CELL_SIZE + 1;
|
uint16_t cell_x = GRID_OFFSET_X + x * CELL_SIZE + 1;
|
||||||
uint8_t cell_y = GRID_OFFSET_Y + 5 + y * CELL_SIZE + 1;
|
uint16_t cell_y = GRID_OFFSET_Y + 5 + y * CELL_SIZE + 1;
|
||||||
|
|
||||||
Color preview_color = can_place ? Color::green() : Color::red();
|
Color preview_color = can_place ? Color::green() : Color::red();
|
||||||
|
|
||||||
|
|||||||
+26
-25
@@ -23,12 +23,9 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace ui::external_app::battleship {
|
#define GRID_SIZE 10
|
||||||
|
|
||||||
constexpr uint8_t GRID_SIZE = 10;
|
namespace ui::external_app::battleship {
|
||||||
constexpr uint8_t CELL_SIZE = 24;
|
|
||||||
constexpr uint8_t GRID_OFFSET_X = 0;
|
|
||||||
constexpr uint8_t GRID_OFFSET_Y = 32;
|
|
||||||
|
|
||||||
enum class ShipType : uint8_t {
|
enum class ShipType : uint8_t {
|
||||||
CARRIER = 5,
|
CARRIER = 5,
|
||||||
@@ -103,6 +100,10 @@ class BattleshipView : public View {
|
|||||||
private:
|
private:
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
|
|
||||||
|
uint16_t CELL_SIZE = 24;
|
||||||
|
uint16_t GRID_OFFSET_X = 0;
|
||||||
|
uint16_t GRID_OFFSET_Y = 32;
|
||||||
|
|
||||||
RxRadioState rx_radio_state_{
|
RxRadioState rx_radio_state_{
|
||||||
433920000 /* frequency */,
|
433920000 /* frequency */,
|
||||||
1750000 /* bandwidth */,
|
1750000 /* bandwidth */,
|
||||||
@@ -163,11 +164,11 @@ class BattleshipView : public View {
|
|||||||
uint32_t last_address{0};
|
uint32_t last_address{0};
|
||||||
|
|
||||||
// UI Elements - Menu/Settings Screen
|
// UI Elements - Menu/Settings Screen
|
||||||
Text text_title{{60, 2, 120, 24}, "BATTLESHIP"};
|
Text text_title{{UI_POS_X_CENTER(11), 2, UI_POS_WIDTH(11), 16}, "BATTLESHIP"};
|
||||||
Text text_subtitle{{40, 20, 160, 16}, "Naval Combat Game"};
|
Text text_subtitle{{UI_POS_X_CENTER(18), 24, UI_POS_WIDTH(18), 16}, "Naval Combat Game"};
|
||||||
|
|
||||||
Rectangle rect_radio_settings{{12, 40, 216, 118}, Color::dark_grey()};
|
// Rectangle rect_radio_settings{{12, 40, 216, 118}, Color::dark_grey()};
|
||||||
Text label_radio{{17, 45, 100, 16}, "RADIO SETUP"};
|
Text label_radio{{UI_POS_X_CENTER(12), 45, UI_POS_WIDTH(12), 16}, "RADIO SETUP"};
|
||||||
ButtonWithEncoder button_frequency{{17, 65, 11 * 8, 20}, ""};
|
ButtonWithEncoder button_frequency{{17, 65, 11 * 8, 20}, ""};
|
||||||
|
|
||||||
// Radio controls
|
// Radio controls
|
||||||
@@ -183,25 +184,24 @@ class BattleshipView : public View {
|
|||||||
Text label_tx_gain{{155, 118, 25, 16}, "TX:"};
|
Text label_tx_gain{{155, 118, 25, 16}, "TX:"};
|
||||||
NumberField field_tx_gain{{185, 118}, 2, {0, 47}, 8, ' '};
|
NumberField field_tx_gain{{185, 118}, 2, {0, 47}, 8, ' '};
|
||||||
|
|
||||||
Rectangle rect_audio_settings{{12, 164, 216, 45}, Color::dark_grey()};
|
// Rectangle rect_audio_settings{{12, 164, 216, 45}, Color::dark_grey()};
|
||||||
Text label_audio{{17, 169, 80, 16}, "AUDIO"};
|
Text label_audio{{UI_POS_X_CENTER(6), 155, UI_POS_WIDTH(6), 16}, "AUDIO"};
|
||||||
Checkbox checkbox_sound{{17, 187}, 8, "Sound On", true};
|
Checkbox checkbox_sound{{17, 177}, 8, "Sound On", true};
|
||||||
Text label_volume{{110, 187, 50, 16}, "Volume:"};
|
Text label_volume{{110, 187, 50, 16}, "Volume:"};
|
||||||
AudioVolumeField field_volume{{165, 187}};
|
AudioVolumeField field_volume{{165, 177}};
|
||||||
|
|
||||||
Rectangle rect_team_selection{{12, 217, 216, 75}, Color::dark_grey()};
|
// Rectangle rect_team_selection{{12, 217, 216, 75}, Color::dark_grey()};
|
||||||
Text label_team{{17, 222, 110, 16}, "SELECT TEAM"};
|
Text label_team{{17, 220, 8 * 12, 16}, "SELECT TEAM"};
|
||||||
Button button_red_team{{25, 242, 85, 45}, "RED\nTEAM"};
|
Button button_red_team{{UI_POS_X_CENTER(10) - UI_POS_WIDTH(7), 237, UI_POS_WIDTH(10), 45}, "RED\nTEAM"};
|
||||||
Button button_blue_team{{130, 242, 85, 45}, "BLUE\nTEAM"};
|
Button button_blue_team{{UI_POS_X_CENTER(10) + UI_POS_WIDTH(7), 237, UI_POS_WIDTH(10), 45}, "BLUE\nTEAM"};
|
||||||
|
|
||||||
// In-game UI elements
|
// In-game UI elements
|
||||||
RSSI rssi{{21 * 8, 0, 6 * 8, 4}};
|
RSSI rssi{{UI_POS_X_RIGHT(6), 0, 6 * 8, 4}};
|
||||||
Text text_status{{10, 16, 220, 16}, ""};
|
|
||||||
Text text_score{{170, 16, 60, 16}, ""};
|
Text text_score{{170, 16, 60, 16}, ""};
|
||||||
Button button_rotate{{10, 265, 65, 32}, "Rotate"};
|
Button button_rotate{{5, UI_POS_Y_BOTTOM(3), 65, 32}, "Rotate"};
|
||||||
Button button_place{{82, 265, 65, 32}, "Place"};
|
Button button_place{{UI_POS_X_CENTER(6), UI_POS_Y_BOTTOM(3), 65, 32}, "Place"};
|
||||||
Button button_fire{{82, 265, 65, 32}, "Fire!"};
|
Button button_fire{{UI_POS_X_RIGHT(17), UI_POS_Y_BOTTOM(3), 65, 32}, "Fire!"};
|
||||||
Button button_menu{{155, 265, 65, 32}, "Menu"};
|
Button button_menu{{UI_POS_X_RIGHT(8), UI_POS_Y_BOTTOM(3), 65, 32}, "Menu"};
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void init_game();
|
void init_game();
|
||||||
@@ -209,8 +209,8 @@ class BattleshipView : public View {
|
|||||||
void start_team(bool red);
|
void start_team(bool red);
|
||||||
void setup_ships();
|
void setup_ships();
|
||||||
void draw_menu_screen(Painter& painter);
|
void draw_menu_screen(Painter& painter);
|
||||||
void draw_grid(Painter& painter, uint8_t grid_x, uint8_t grid_y, const std::array<std::array<CellState, GRID_SIZE>, GRID_SIZE>& grid, bool show_ships, bool is_offense_grid = false);
|
void draw_grid(Painter& painter, uint16_t grid_x, uint16_t grid_y, const std::array<std::array<CellState, GRID_SIZE>, GRID_SIZE>& grid, bool show_ships, bool is_offense_grid = false);
|
||||||
void draw_cell(Painter& painter, uint8_t cell_x, uint8_t cell_y, CellState state, bool show_ships, bool is_offense_grid, bool is_cursor);
|
void draw_cell(Painter& painter, uint16_t cell_x, uint16_t cell_y, CellState state, bool show_ships, bool is_offense_grid, bool is_cursor);
|
||||||
void draw_ship_preview(Painter& painter);
|
void draw_ship_preview(Painter& painter);
|
||||||
void place_ship();
|
void place_ship();
|
||||||
bool can_place_ship(uint8_t x, uint8_t y, uint8_t size, bool horizontal);
|
bool can_place_ship(uint8_t x, uint8_t y, uint8_t size, bool horizontal);
|
||||||
@@ -218,6 +218,7 @@ class BattleshipView : public View {
|
|||||||
void process_shot(uint8_t x, uint8_t y);
|
void process_shot(uint8_t x, uint8_t y);
|
||||||
void update_score();
|
void update_score();
|
||||||
bool is_cursor_at(uint8_t x, uint8_t y, bool is_offense_grid);
|
bool is_cursor_at(uint8_t x, uint8_t y, bool is_offense_grid);
|
||||||
|
void show_hide_menu(bool menu_vis);
|
||||||
|
|
||||||
void send_message(const GameMessage& msg);
|
void send_message(const GameMessage& msg);
|
||||||
void process_message(const std::string& message);
|
void process_message(const std::string& message);
|
||||||
|
|||||||
+4
-1
@@ -21,7 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bht.hpp"
|
#include "bht.hpp"
|
||||||
#include "portapack_persistent_memory.hpp"
|
|
||||||
|
namespace ui::external_app::bht_tx {
|
||||||
|
|
||||||
size_t gen_message_ep(uint8_t city_code, size_t family_code_ep, uint32_t relay_number, uint32_t relay_state) {
|
size_t gen_message_ep(uint8_t city_code, size_t family_code_ep, uint32_t relay_number, uint32_t relay_state) {
|
||||||
size_t c;
|
size_t c;
|
||||||
@@ -152,3 +153,5 @@ std::string ccir_to_ascii(uint8_t* ccir) {
|
|||||||
|
|
||||||
return ascii;
|
return ascii;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace ui::external_app::bht_tx
|
||||||
+4
@@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
using namespace encoders;
|
using namespace encoders;
|
||||||
|
|
||||||
|
namespace ui::external_app::bht_tx {
|
||||||
|
|
||||||
#define XY_TONE_DURATION ((TONES_SAMPLERATE * 0.1) - 1) // 100ms
|
#define XY_TONE_DURATION ((TONES_SAMPLERATE * 0.1) - 1) // 100ms
|
||||||
#define XY_SILENCE (TONES_SAMPLERATE * 0.4) // 400ms
|
#define XY_SILENCE (TONES_SAMPLERATE * 0.4) // 400ms
|
||||||
#define XY_TONE_COUNT 20
|
#define XY_TONE_COUNT 20
|
||||||
@@ -47,3 +49,5 @@ size_t gen_message_ep(uint8_t city_code, size_t family_code_ep, uint32_t relay_s
|
|||||||
std::string gen_message_xy(const std::string& code);
|
std::string gen_message_xy(const std::string& code);
|
||||||
std::string gen_message_xy(size_t header_code_a, size_t header_code_b, size_t city_code, size_t family_code, bool subfamily_wc, size_t subfamily_code, bool id_wc, size_t receiver_code, size_t relay_state_A, size_t relay_state_B, size_t relay_state_C, size_t relay_state_D);
|
std::string gen_message_xy(size_t header_code_a, size_t header_code_b, size_t city_code, size_t family_code, bool subfamily_wc, size_t subfamily_code, bool id_wc, size_t receiver_code, size_t relay_state_A, size_t relay_state_B, size_t relay_state_C, size_t relay_state_D);
|
||||||
std::string ccir_to_ascii(uint8_t* ccir);
|
std::string ccir_to_ascii(uint8_t* ccir);
|
||||||
|
|
||||||
|
} // namespace ui::external_app::bht_tx
|
||||||
+83
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 EPIRB Decoder Implementation
|
||||||
|
*
|
||||||
|
* 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.hpp"
|
||||||
|
#include "ui_bht_tx.hpp"
|
||||||
|
#include "ui_navigation.hpp"
|
||||||
|
#include "external_app.hpp"
|
||||||
|
|
||||||
|
namespace ui::external_app::bht_tx {
|
||||||
|
void initialize_app(ui::NavigationView& nav) {
|
||||||
|
nav.push<BHTView>();
|
||||||
|
}
|
||||||
|
} // namespace ui::external_app::bht_tx
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
__attribute__((section(".external_app.app_bht_tx.application_information"), used)) application_information_t _application_information_bht_tx = {
|
||||||
|
/*.memory_location = */ (uint8_t*)0x00000000,
|
||||||
|
/*.externalAppEntry = */ ui::external_app::bht_tx::initialize_app,
|
||||||
|
/*.header_version = */ CURRENT_HEADER_VERSION,
|
||||||
|
/*.app_version = */ VERSION_MD5,
|
||||||
|
|
||||||
|
/*.app_name = */ "BHT TX",
|
||||||
|
/*.bitmap_data = */ {
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0xE0,
|
||||||
|
0x07,
|
||||||
|
0xF8,
|
||||||
|
0x08,
|
||||||
|
0x9C,
|
||||||
|
0x07,
|
||||||
|
0x0C,
|
||||||
|
0x00,
|
||||||
|
0x8E,
|
||||||
|
0x0A,
|
||||||
|
0x46,
|
||||||
|
0x12,
|
||||||
|
0x26,
|
||||||
|
0x22,
|
||||||
|
0x06,
|
||||||
|
0x02,
|
||||||
|
0x06,
|
||||||
|
0x00,
|
||||||
|
0x06,
|
||||||
|
0x00,
|
||||||
|
0x06,
|
||||||
|
0x00,
|
||||||
|
0x06,
|
||||||
|
0x00,
|
||||||
|
0x06,
|
||||||
|
0x00,
|
||||||
|
0x06,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
},
|
||||||
|
/*.icon_color = */ ui::Color::green().v,
|
||||||
|
/*.menu_location = */ app_location_t::TX,
|
||||||
|
/*.desired_menu_position = */ -1,
|
||||||
|
|
||||||
|
/*.m4_app_tag = portapack::spi_flash::image_tag_tones */ {'P', 'T', 'O', 'N'},
|
||||||
|
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
|
||||||
|
};
|
||||||
|
}
|
||||||
Vendored
+3
-4
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
|
|
||||||
namespace ui {
|
namespace ui::external_app::bht_tx {
|
||||||
|
|
||||||
void BHTView::focus() {
|
void BHTView::focus() {
|
||||||
tx_view.focus();
|
tx_view.focus();
|
||||||
@@ -40,8 +40,7 @@ void BHTView::start_tx() {
|
|||||||
transmitter_model.set_baseband_bandwidth(1750000);
|
transmitter_model.set_baseband_bandwidth(1750000);
|
||||||
|
|
||||||
if (target_system == XYLOS) {
|
if (target_system == XYLOS) {
|
||||||
baseband::run_image(portapack::spi_flash::image_tag_tones);
|
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
|
||||||
|
|
||||||
view_xylos.generate_message();
|
view_xylos.generate_message();
|
||||||
|
|
||||||
// if (tx_mode == SINGLE) {
|
// if (tx_mode == SINGLE) {
|
||||||
@@ -339,4 +338,4 @@ void XylosView::focus() {
|
|||||||
field_city.focus();
|
field_city.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace ui */
|
} // namespace ui::external_app::bht_tx
|
||||||
Vendored
+5
-5
@@ -35,7 +35,7 @@
|
|||||||
#include "radio_state.hpp"
|
#include "radio_state.hpp"
|
||||||
#include "portapack.hpp"
|
#include "portapack.hpp"
|
||||||
|
|
||||||
namespace ui {
|
namespace ui::external_app::bht_tx {
|
||||||
|
|
||||||
class XylosView : public View {
|
class XylosView : public View {
|
||||||
public:
|
public:
|
||||||
@@ -207,7 +207,7 @@ class BHTView : public View {
|
|||||||
"Scan"};
|
"Scan"};
|
||||||
|
|
||||||
Checkbox checkbox_flashing{
|
Checkbox checkbox_flashing{
|
||||||
{16 * 8, 25 * 8},
|
{UI_POS_X(16), 25 * 8},
|
||||||
8,
|
8,
|
||||||
"Flashing"};
|
"Flashing"};
|
||||||
NumberField field_speed{
|
NumberField field_speed{
|
||||||
@@ -218,11 +218,11 @@ class BHTView : public View {
|
|||||||
' '};
|
' '};
|
||||||
|
|
||||||
ProgressBar progressbar{
|
ProgressBar progressbar{
|
||||||
{0 * 8, 29 * 8, screen_width, 16},
|
{UI_POS_X(0), UI_POS_Y_BOTTOM(5), screen_width, 16},
|
||||||
};
|
};
|
||||||
|
|
||||||
TransmitterView tx_view{
|
TransmitterView tx_view{
|
||||||
16 * 16,
|
(int16_t)UI_POS_Y_BOTTOM(4),
|
||||||
10000,
|
10000,
|
||||||
12};
|
12};
|
||||||
|
|
||||||
@@ -234,4 +234,4 @@ class BHTView : public View {
|
|||||||
}};
|
}};
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ui */
|
} // namespace ui::external_app::bht_tx
|
||||||
+153
-139
@@ -41,6 +41,19 @@ void game_timer_check() {
|
|||||||
|
|
||||||
BlackjackView::BlackjackView(NavigationView& nav)
|
BlackjackView::BlackjackView(NavigationView& nav)
|
||||||
: nav_{nav}, game_timer{} {
|
: nav_{nav}, game_timer{} {
|
||||||
|
// Initialize screen dimensions dynamically
|
||||||
|
screen_w = ui::screen_width;
|
||||||
|
screen_h = ui::screen_height;
|
||||||
|
|
||||||
|
// Scale card size based on screen
|
||||||
|
if (screen_w <= 240) {
|
||||||
|
card_width = 50;
|
||||||
|
card_height = 65;
|
||||||
|
} else if (screen_w >= 400) {
|
||||||
|
card_width = 70;
|
||||||
|
card_height = 90;
|
||||||
|
}
|
||||||
|
|
||||||
add_children({&dummy});
|
add_children({&dummy});
|
||||||
current_instance = this;
|
current_instance = this;
|
||||||
game_timer.attach(&game_timer_check, 1.0 / 60.0);
|
game_timer.attach(&game_timer_check, 1.0 / 60.0);
|
||||||
@@ -70,7 +83,7 @@ void BlackjackView::frame_sync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BlackjackView::clear_screen() {
|
void BlackjackView::clear_screen() {
|
||||||
painter.fill_rectangle({0, 0, 240, 320}, Color::black());
|
painter.fill_rectangle({0, 0, screen_w, screen_h}, Color::black());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlackjackView::init_deck() {
|
void BlackjackView::init_deck() {
|
||||||
@@ -265,24 +278,26 @@ void BlackjackView::draw_menu_static() {
|
|||||||
auto style_text = *ui::Theme::getInstance()->fg_light;
|
auto style_text = *ui::Theme::getInstance()->fg_light;
|
||||||
auto style_rules = *ui::Theme::getInstance()->fg_cyan;
|
auto style_rules = *ui::Theme::getInstance()->fg_cyan;
|
||||||
|
|
||||||
painter.draw_string({84, 20}, style_title, "BLACKJACK");
|
painter.draw_string({UI_POS_X_CENTER(10), 20}, style_title, "BLACKJACK");
|
||||||
|
|
||||||
// Draw rules
|
// Draw rules - adjust Y positions for smaller screens
|
||||||
painter.draw_string({70, 55}, style_rules, "-- RULES --");
|
int rules_y = (screen_h > 300) ? 55 : 45;
|
||||||
painter.draw_string({61, 75}, style_text, "Get close to 21");
|
painter.draw_string({UI_POS_X_CENTER(12), rules_y}, style_rules, "-- RULES --");
|
||||||
painter.draw_string({61, 90}, style_text, "without going over");
|
painter.draw_string({UI_POS_X_CENTER(16), rules_y + 20}, style_text, "Get close to 21");
|
||||||
painter.draw_string({61, 110}, style_text, "Dealer hits on 16");
|
painter.draw_string({UI_POS_X_CENTER(19), rules_y + 35}, style_text, "without going over");
|
||||||
painter.draw_string({61, 125}, style_text, "Dealer stays on 17");
|
painter.draw_string({UI_POS_X_CENTER(18), rules_y + 55}, style_text, "Dealer hits on 16");
|
||||||
painter.draw_string({61, 145}, style_text, "Blackjack pays 1:1");
|
painter.draw_string({UI_POS_X_CENTER(19), rules_y + 70}, style_text, "Dealer stays on 17");
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(19), rules_y + 90}, style_text, "Blackjack pays 1:1");
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
painter.draw_string({65, 175}, style_rules, "-- CONTROLS --");
|
int controls_y = (screen_h > 300) ? 175 : 155;
|
||||||
painter.draw_string({61, 195}, style_text, "SELECT: Start/Hit");
|
painter.draw_string({UI_POS_X_CENTER(15), controls_y}, style_rules, "-- CONTROLS --");
|
||||||
painter.draw_string({61, 210}, style_text, "LEFT: Stats");
|
painter.draw_string({UI_POS_X_CENTER(18), controls_y + 20}, style_text, "SELECT: Start/Hit");
|
||||||
painter.draw_string({61, 225}, style_text, "RIGHT: Exit/Stay");
|
painter.draw_string({UI_POS_X_CENTER(12), controls_y + 35}, style_text, "LEFT: Stats");
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(17), controls_y + 50}, style_text, "RIGHT: Exit/Stay");
|
||||||
|
|
||||||
// Draw high score
|
// Draw high score at bottom
|
||||||
painter.draw_string({61, 250}, style_text, "High Score: $" + std::to_string(high_score));
|
painter.draw_string({UI_POS_X_CENTER(17), screen_h - 70}, style_text, "High Score: $" + std::to_string(high_score));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlackjackView::draw_menu() {
|
void BlackjackView::draw_menu() {
|
||||||
@@ -293,10 +308,10 @@ void BlackjackView::draw_menu() {
|
|||||||
|
|
||||||
if (blink_state) {
|
if (blink_state) {
|
||||||
auto style = *ui::Theme::getInstance()->fg_yellow;
|
auto style = *ui::Theme::getInstance()->fg_yellow;
|
||||||
painter.draw_string({55, 280}, style, "* PRESS SELECT *");
|
painter.draw_string({UI_POS_X_CENTER(17), screen_h - 40}, style, "* PRESS SELECT *");
|
||||||
} else {
|
} else {
|
||||||
// Clear just the text area
|
// Clear just the text area
|
||||||
painter.fill_rectangle({55, 278, 130, 20}, Color::black());
|
painter.fill_rectangle({UI_POS_X_CENTER(17), screen_h - 42, 130, 20}, Color::black());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -308,29 +323,31 @@ void BlackjackView::draw_stats() {
|
|||||||
auto style_text = *ui::Theme::getInstance()->fg_light;
|
auto style_text = *ui::Theme::getInstance()->fg_light;
|
||||||
auto style_value = *ui::Theme::getInstance()->fg_yellow;
|
auto style_value = *ui::Theme::getInstance()->fg_yellow;
|
||||||
|
|
||||||
painter.draw_string({75, 30}, style_title, "STATISTICS");
|
painter.draw_string({UI_POS_X_CENTER(11), 30}, style_title, "STATISTICS");
|
||||||
|
|
||||||
painter.draw_string({30, 80}, style_text, "Wins:");
|
int stats_x = (screen_w > 300) ? 50 : 30;
|
||||||
painter.draw_string({150, 80}, style_value, std::to_string(wins));
|
|
||||||
|
|
||||||
painter.draw_string({30, 100}, style_text, "Losses:");
|
painter.draw_string({stats_x, 80}, style_text, "Wins:");
|
||||||
painter.draw_string({150, 100}, style_value, std::to_string(losses));
|
painter.draw_string({UI_POS_X_CENTER(5), 80}, style_value, std::to_string(wins));
|
||||||
|
|
||||||
|
painter.draw_string({stats_x, 100}, style_text, "Losses:");
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(5), 100}, style_value, std::to_string(losses));
|
||||||
|
|
||||||
// Win percentage
|
// Win percentage
|
||||||
uint32_t total = wins + losses;
|
uint32_t total = wins + losses;
|
||||||
if (total > 0) {
|
if (total > 0) {
|
||||||
uint32_t win_pct = (wins * 100) / total;
|
uint32_t win_pct = (wins * 100) / total;
|
||||||
painter.draw_string({30, 120}, style_text, "Win %:");
|
painter.draw_string({stats_x, 120}, style_text, "Win %:");
|
||||||
painter.draw_string({150, 120}, style_value, std::to_string(win_pct) + "%");
|
painter.draw_string({UI_POS_X_CENTER(5), 120}, style_value, std::to_string(win_pct) + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
painter.draw_string({30, 160}, style_text, "High Score:");
|
painter.draw_string({stats_x, 160}, style_text, "High Score:");
|
||||||
painter.draw_string({150, 160}, style_value, "$" + std::to_string(high_score));
|
painter.draw_string({UI_POS_X_CENTER(5), 160}, style_value, "$" + std::to_string(high_score));
|
||||||
|
|
||||||
painter.draw_string({30, 180}, style_text, "Cash:");
|
painter.draw_string({stats_x, 180}, style_text, "Cash:");
|
||||||
painter.draw_string({150, 180}, style_value, "$" + std::to_string(cash));
|
painter.draw_string({UI_POS_X_CENTER(5), 180}, style_value, "$" + std::to_string(cash));
|
||||||
|
|
||||||
painter.draw_string({40, 250}, style_text, "SELECT: Back");
|
painter.draw_string({UI_POS_X_CENTER(12), screen_h - 70}, style_text, "SELECT: Back");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlackjackView::draw_betting() {
|
void BlackjackView::draw_betting() {
|
||||||
@@ -343,7 +360,7 @@ void BlackjackView::draw_betting() {
|
|||||||
auto style_title = *ui::Theme::getInstance()->fg_green;
|
auto style_title = *ui::Theme::getInstance()->fg_green;
|
||||||
auto style_text = *ui::Theme::getInstance()->fg_light;
|
auto style_text = *ui::Theme::getInstance()->fg_light;
|
||||||
|
|
||||||
painter.draw_string({70, 40}, style_title, "PLACE BET");
|
painter.draw_string({UI_POS_X_CENTER(10), 40}, style_title, "PLACE BET");
|
||||||
painter.draw_string({30, 80}, style_text, "Cash: $" + std::to_string(cash));
|
painter.draw_string({30, 80}, style_text, "Cash: $" + std::to_string(cash));
|
||||||
|
|
||||||
painter.draw_string({30, 140}, style_text, "ENCODER: +/- $10");
|
painter.draw_string({30, 140}, style_text, "ENCODER: +/- $10");
|
||||||
@@ -373,7 +390,7 @@ void BlackjackView::draw_game() {
|
|||||||
|
|
||||||
auto style = *ui::Theme::getInstance()->fg_green;
|
auto style = *ui::Theme::getInstance()->fg_green;
|
||||||
painter.draw_string({10, 10}, style, "Cash: $" + std::to_string(cash));
|
painter.draw_string({10, 10}, style, "Cash: $" + std::to_string(cash));
|
||||||
painter.draw_string({140, 10}, style, "Bet: $" + std::to_string(bet));
|
painter.draw_string({screen_w - 80, 10}, style, "Bet: $" + std::to_string(bet));
|
||||||
|
|
||||||
// Draw dealer hand with value next to label
|
// Draw dealer hand with value next to label
|
||||||
auto style_value = *ui::Theme::getInstance()->fg_yellow;
|
auto style_value = *ui::Theme::getInstance()->fg_yellow;
|
||||||
@@ -385,16 +402,18 @@ void BlackjackView::draw_game() {
|
|||||||
draw_hand(10, 65, dealer_cards, dealer_card_count, true);
|
draw_hand(10, 65, dealer_cards, dealer_card_count, true);
|
||||||
|
|
||||||
// Draw player hand with value next to label
|
// Draw player hand with value next to label
|
||||||
painter.draw_string({10, 165}, *ui::Theme::getInstance()->fg_light, "You:");
|
int player_y = (screen_h > 300) ? 165 : 145;
|
||||||
|
painter.draw_string({10, player_y}, *ui::Theme::getInstance()->fg_light, "You:");
|
||||||
int player_value = calculate_hand_value(player_cards, player_card_count);
|
int player_value = calculate_hand_value(player_cards, player_card_count);
|
||||||
painter.draw_string({50, 165}, style_value, "(" + std::to_string(player_value) + ")");
|
painter.draw_string({50, player_y}, style_value, "(" + std::to_string(player_value) + ")");
|
||||||
draw_hand(10, 185, player_cards, player_card_count, false);
|
draw_hand(10, player_y + 20, player_cards, player_card_count, false);
|
||||||
|
|
||||||
// Draw controls or result
|
// Draw controls or result
|
||||||
|
int controls_y = screen_h - 50;
|
||||||
if (game_state == GameState::PLAYING) {
|
if (game_state == GameState::PLAYING) {
|
||||||
auto style_text = *ui::Theme::getInstance()->fg_light;
|
auto style_text = *ui::Theme::getInstance()->fg_light;
|
||||||
painter.draw_string({30, 290}, style_text, "SELECT: Hit");
|
painter.draw_string({30, controls_y}, style_text, "SELECT: Hit");
|
||||||
painter.draw_string({130, 290}, style_text, "RIGHT: Stay");
|
painter.draw_string({screen_w - 100, controls_y}, style_text, "RIGHT: Stay");
|
||||||
} else if (game_state == GameState::GAME_OVER) {
|
} else if (game_state == GameState::GAME_OVER) {
|
||||||
const Style* style_result = ui::Theme::getInstance()->fg_yellow;
|
const Style* style_result = ui::Theme::getInstance()->fg_yellow;
|
||||||
std::string result;
|
std::string result;
|
||||||
@@ -416,14 +435,14 @@ void BlackjackView::draw_game() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw result
|
// Draw result
|
||||||
painter.draw_string({60, 270}, *style_result, result);
|
painter.draw_string({UI_POS_X_CENTER(result.length()), controls_y - 20}, *style_result, result);
|
||||||
|
|
||||||
// Draw compact bet selector in top right area
|
// Draw compact bet selector
|
||||||
auto style_bet = *ui::Theme::getInstance()->fg_cyan;
|
auto style_bet = *ui::Theme::getInstance()->fg_cyan;
|
||||||
painter.draw_string({140, 25}, style_bet, "Next: $" + std::to_string(bet));
|
painter.draw_string({screen_w - 100, 25}, style_bet, "Next: $" + std::to_string(bet));
|
||||||
|
|
||||||
// Show controls
|
// Show controls
|
||||||
painter.draw_string({10, 290}, *ui::Theme::getInstance()->fg_light, "SELECT: Deal ENC: +/-");
|
painter.draw_string({10, controls_y}, *ui::Theme::getInstance()->fg_light, "SELECT: Deal ENC: +/-");
|
||||||
}
|
}
|
||||||
|
|
||||||
last_player_count = player_card_count;
|
last_player_count = player_card_count;
|
||||||
@@ -432,109 +451,106 @@ void BlackjackView::draw_game() {
|
|||||||
last_bet = bet;
|
last_bet = bet;
|
||||||
} else if (game_state == GameState::GAME_OVER && bet != last_bet) {
|
} else if (game_state == GameState::GAME_OVER && bet != last_bet) {
|
||||||
// Only update the bet display when it changes
|
// Only update the bet display when it changes
|
||||||
painter.fill_rectangle({140, 25, 90, 16}, Color::black());
|
painter.fill_rectangle({screen_w - 100, 25, 90, 16}, Color::black());
|
||||||
painter.draw_string({140, 25}, *ui::Theme::getInstance()->fg_cyan, "Next: $" + std::to_string(bet));
|
painter.draw_string({screen_w - 100, 25}, *ui::Theme::getInstance()->fg_cyan, "Next: $" + std::to_string(bet));
|
||||||
last_bet = bet;
|
last_bet = bet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlackjackView::draw_suit_symbol(int x, int y, uint8_t suit, Color color, bool large) {
|
void BlackjackView::draw_suit_symbol(int x, int y, uint8_t suit, Color color, bool large) {
|
||||||
if (large) {
|
if (large) {
|
||||||
// Large suit symbols for center of card
|
// Scale large symbols based on card size
|
||||||
|
int scale = card_width / 60;
|
||||||
|
|
||||||
switch (suit) {
|
switch (suit) {
|
||||||
case 0: // Spades
|
case 0: // Spades
|
||||||
// Top curve
|
// Draw using scaled rectangles
|
||||||
painter.fill_rectangle({x + 9, y + 4, 2, 2}, color);
|
painter.fill_rectangle({x + 9 * scale, y + 4 * scale, 2 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 8, y + 5, 4, 2}, color);
|
painter.fill_rectangle({x + 8 * scale, y + 5 * scale, 4 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 7, y + 6, 6, 2}, color);
|
painter.fill_rectangle({x + 7 * scale, y + 6 * scale, 6 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 6, y + 7, 8, 2}, color);
|
painter.fill_rectangle({x + 6 * scale, y + 7 * scale, 8 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 5, y + 8, 10, 2}, color);
|
painter.fill_rectangle({x + 5 * scale, y + 8 * scale, 10 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 4, y + 9, 12, 2}, color);
|
painter.fill_rectangle({x + 4 * scale, y + 9 * scale, 12 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 3, y + 10, 14, 2}, color);
|
painter.fill_rectangle({x + 3 * scale, y + 10 * scale, 14 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 2, y + 11, 16, 2}, color);
|
painter.fill_rectangle({x + 2 * scale, y + 11 * scale, 16 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 1, y + 12, 18, 2}, color);
|
painter.fill_rectangle({x + 1 * scale, y + 12 * scale, 18 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 0, y + 13, 20, 3}, color);
|
painter.fill_rectangle({x + 0 * scale, y + 13 * scale, 20 * scale, 3 * scale}, color);
|
||||||
painter.fill_rectangle({x + 1, y + 16, 18, 2}, color);
|
painter.fill_rectangle({x + 1 * scale, y + 16 * scale, 18 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 2, y + 17, 16, 1}, color);
|
painter.fill_rectangle({x + 2 * scale, y + 17 * scale, 16 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 3, y + 18, 14, 1}, color);
|
painter.fill_rectangle({x + 3 * scale, y + 18 * scale, 14 * scale, 1 * scale}, color);
|
||||||
// Stem
|
// Stem
|
||||||
painter.fill_rectangle({x + 9, y + 19, 2, 4}, color);
|
painter.fill_rectangle({x + 9 * scale, y + 19 * scale, 2 * scale, 4 * scale}, color);
|
||||||
painter.fill_rectangle({x + 8, y + 22, 4, 1}, color);
|
painter.fill_rectangle({x + 8 * scale, y + 22 * scale, 4 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 7, y + 23, 6, 1}, color);
|
painter.fill_rectangle({x + 7 * scale, y + 23 * scale, 6 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 6, y + 24, 8, 1}, color);
|
painter.fill_rectangle({x + 6 * scale, y + 24 * scale, 8 * scale, 1 * scale}, color);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // Hearts
|
case 1: // Hearts
|
||||||
// Left bump
|
// Draw using scaled rectangles
|
||||||
painter.fill_rectangle({x + 3, y + 5, 4, 2}, color);
|
painter.fill_rectangle({x + 3 * scale, y + 5 * scale, 4 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 2, y + 6, 6, 2}, color);
|
painter.fill_rectangle({x + 2 * scale, y + 6 * scale, 6 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 1, y + 7, 8, 3}, color);
|
painter.fill_rectangle({x + 1 * scale, y + 7 * scale, 8 * scale, 3 * scale}, color);
|
||||||
painter.fill_rectangle({x + 0, y + 9, 9, 3}, color);
|
painter.fill_rectangle({x + 0 * scale, y + 9 * scale, 9 * scale, 3 * scale}, color);
|
||||||
// Right bump
|
painter.fill_rectangle({x + 13 * scale, y + 5 * scale, 4 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 13, y + 5, 4, 2}, color);
|
painter.fill_rectangle({x + 12 * scale, y + 6 * scale, 6 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 12, y + 6, 6, 2}, color);
|
painter.fill_rectangle({x + 11 * scale, y + 7 * scale, 8 * scale, 3 * scale}, color);
|
||||||
painter.fill_rectangle({x + 11, y + 7, 8, 3}, color);
|
painter.fill_rectangle({x + 11 * scale, y + 9 * scale, 9 * scale, 3 * scale}, color);
|
||||||
painter.fill_rectangle({x + 11, y + 9, 9, 3}, color);
|
painter.fill_rectangle({x + 1 * scale, y + 11 * scale, 18 * scale, 3 * scale}, color);
|
||||||
// Body
|
painter.fill_rectangle({x + 2 * scale, y + 14 * scale, 16 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 1, y + 11, 18, 3}, color);
|
painter.fill_rectangle({x + 3 * scale, y + 16 * scale, 14 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 2, y + 14, 16, 2}, color);
|
painter.fill_rectangle({x + 4 * scale, y + 18 * scale, 12 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 3, y + 16, 14, 2}, color);
|
painter.fill_rectangle({x + 5 * scale, y + 19 * scale, 10 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 4, y + 18, 12, 1}, color);
|
painter.fill_rectangle({x + 6 * scale, y + 20 * scale, 8 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 5, y + 19, 10, 1}, color);
|
painter.fill_rectangle({x + 7 * scale, y + 21 * scale, 6 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 6, y + 20, 8, 1}, color);
|
painter.fill_rectangle({x + 8 * scale, y + 22 * scale, 4 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 7, y + 21, 6, 1}, color);
|
painter.fill_rectangle({x + 9 * scale, y + 23 * scale, 2 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 8, y + 22, 4, 1}, color);
|
|
||||||
painter.fill_rectangle({x + 9, y + 23, 2, 1}, color);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // Diamonds
|
case 2: // Diamonds
|
||||||
painter.fill_rectangle({x + 10, y + 3, 1, 1}, color);
|
// Draw using scaled rectangles
|
||||||
painter.fill_rectangle({x + 9, y + 4, 3, 1}, color);
|
painter.fill_rectangle({x + 10 * scale, y + 3 * scale, 1 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 8, y + 5, 5, 1}, color);
|
painter.fill_rectangle({x + 9 * scale, y + 4 * scale, 3 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 7, y + 6, 7, 1}, color);
|
painter.fill_rectangle({x + 8 * scale, y + 5 * scale, 5 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 6, y + 7, 9, 1}, color);
|
painter.fill_rectangle({x + 7 * scale, y + 6 * scale, 7 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 5, y + 8, 11, 1}, color);
|
painter.fill_rectangle({x + 6 * scale, y + 7 * scale, 9 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 4, y + 9, 13, 1}, color);
|
painter.fill_rectangle({x + 5 * scale, y + 8 * scale, 11 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 3, y + 10, 15, 1}, color);
|
painter.fill_rectangle({x + 4 * scale, y + 9 * scale, 13 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 2, y + 11, 17, 1}, color);
|
painter.fill_rectangle({x + 3 * scale, y + 10 * scale, 15 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 1, y + 12, 19, 1}, color);
|
painter.fill_rectangle({x + 2 * scale, y + 11 * scale, 17 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 0, y + 13, 21, 1}, color);
|
painter.fill_rectangle({x + 1 * scale, y + 12 * scale, 19 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 1, y + 14, 19, 1}, color);
|
painter.fill_rectangle({x + 0 * scale, y + 13 * scale, 21 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 2, y + 15, 17, 1}, color);
|
painter.fill_rectangle({x + 1 * scale, y + 14 * scale, 19 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 3, y + 16, 15, 1}, color);
|
painter.fill_rectangle({x + 2 * scale, y + 15 * scale, 17 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 4, y + 17, 13, 1}, color);
|
painter.fill_rectangle({x + 3 * scale, y + 16 * scale, 15 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 5, y + 18, 11, 1}, color);
|
painter.fill_rectangle({x + 4 * scale, y + 17 * scale, 13 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 6, y + 19, 9, 1}, color);
|
painter.fill_rectangle({x + 5 * scale, y + 18 * scale, 11 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 7, y + 20, 7, 1}, color);
|
painter.fill_rectangle({x + 6 * scale, y + 19 * scale, 9 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 8, y + 21, 5, 1}, color);
|
painter.fill_rectangle({x + 7 * scale, y + 20 * scale, 7 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 9, y + 22, 3, 1}, color);
|
painter.fill_rectangle({x + 8 * scale, y + 21 * scale, 5 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 10, y + 23, 1, 1}, color);
|
painter.fill_rectangle({x + 9 * scale, y + 22 * scale, 3 * scale, 1 * scale}, color);
|
||||||
|
painter.fill_rectangle({x + 10 * scale, y + 23 * scale, 1 * scale, 1 * scale}, color);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: // Clubs
|
case 3: // Clubs
|
||||||
// Center circle
|
// Draw using scaled rectangles
|
||||||
painter.fill_rectangle({x + 8, y + 8, 5, 1}, color);
|
painter.fill_rectangle({x + 8 * scale, y + 8 * scale, 5 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 7, y + 9, 7, 3}, color);
|
painter.fill_rectangle({x + 7 * scale, y + 9 * scale, 7 * scale, 3 * scale}, color);
|
||||||
painter.fill_rectangle({x + 8, y + 12, 5, 1}, color);
|
painter.fill_rectangle({x + 8 * scale, y + 12 * scale, 5 * scale, 1 * scale}, color);
|
||||||
// Left circle
|
painter.fill_rectangle({x + 3 * scale, y + 11 * scale, 4 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 3, y + 11, 4, 1}, color);
|
painter.fill_rectangle({x + 2 * scale, y + 12 * scale, 6 * scale, 3 * scale}, color);
|
||||||
painter.fill_rectangle({x + 2, y + 12, 6, 3}, color);
|
painter.fill_rectangle({x + 3 * scale, y + 15 * scale, 4 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 3, y + 15, 4, 1}, color);
|
painter.fill_rectangle({x + 14 * scale, y + 11 * scale, 4 * scale, 1 * scale}, color);
|
||||||
// Right circle
|
painter.fill_rectangle({x + 13 * scale, y + 12 * scale, 6 * scale, 3 * scale}, color);
|
||||||
painter.fill_rectangle({x + 14, y + 11, 4, 1}, color);
|
painter.fill_rectangle({x + 14 * scale, y + 15 * scale, 4 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 13, y + 12, 6, 3}, color);
|
painter.fill_rectangle({x + 6 * scale, y + 13 * scale, 9 * scale, 2 * scale}, color);
|
||||||
painter.fill_rectangle({x + 14, y + 15, 4, 1}, color);
|
painter.fill_rectangle({x + 9 * scale, y + 16 * scale, 3 * scale, 4 * scale}, color);
|
||||||
// Connect circles
|
painter.fill_rectangle({x + 8 * scale, y + 19 * scale, 5 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 6, y + 13, 9, 2}, color);
|
painter.fill_rectangle({x + 7 * scale, y + 20 * scale, 7 * scale, 1 * scale}, color);
|
||||||
// Stem
|
painter.fill_rectangle({x + 6 * scale, y + 21 * scale, 9 * scale, 1 * scale}, color);
|
||||||
painter.fill_rectangle({x + 9, y + 16, 3, 4}, color);
|
|
||||||
painter.fill_rectangle({x + 8, y + 19, 5, 1}, color);
|
|
||||||
painter.fill_rectangle({x + 7, y + 20, 7, 1}, color);
|
|
||||||
painter.fill_rectangle({x + 6, y + 21, 9, 1}, color);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Small suit symbols
|
// Small suit symbols remain the same
|
||||||
switch (suit) {
|
switch (suit) {
|
||||||
case 0: // Spades - small
|
case 0: // Spades - small
|
||||||
painter.fill_rectangle({x + 2, y + 1, 3, 3}, color);
|
painter.fill_rectangle({x + 2, y + 1, 3, 3}, color);
|
||||||
@@ -569,18 +585,15 @@ void BlackjackView::draw_suit_symbol(int x, int y, uint8_t suit, Color color, bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BlackjackView::draw_card(int x, int y, uint8_t card, bool hidden) {
|
void BlackjackView::draw_card(int x, int y, uint8_t card, bool hidden) {
|
||||||
const int width = 60;
|
|
||||||
const int height = 80;
|
|
||||||
|
|
||||||
// Draw card background
|
// Draw card background
|
||||||
painter.fill_rectangle({x, y, width, height}, Color::white());
|
painter.fill_rectangle({x, y, card_width, card_height}, Color::white());
|
||||||
painter.draw_rectangle({x, y, width, height}, Color::black());
|
painter.draw_rectangle({x, y, card_width, card_height}, Color::black());
|
||||||
painter.draw_rectangle({x + 1, y + 1, width - 2, height - 2}, Color::grey()); // Inner border
|
painter.draw_rectangle({x + 1, y + 1, card_width - 2, card_height - 2}, Color::grey());
|
||||||
|
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
// Draw card back pattern - diagonal lines
|
// Draw card back pattern - diagonal lines
|
||||||
for (int i = 4; i < width - 4; i += 6) {
|
for (int i = 4; i < card_width - 4; i += 6) {
|
||||||
for (int j = 4; j < height - 4; j += 6) {
|
for (int j = 4; j < card_height - 4; j += 6) {
|
||||||
painter.fill_rectangle({x + i, y + j, 3, 3}, Color::blue());
|
painter.fill_rectangle({x + i, y + j, 3, 3}, Color::blue());
|
||||||
painter.fill_rectangle({x + i + 3, y + j + 3, 3, 3}, Color::red());
|
painter.fill_rectangle({x + i + 3, y + j + 3, 3, 3}, Color::red());
|
||||||
}
|
}
|
||||||
@@ -606,22 +619,23 @@ void BlackjackView::draw_card(int x, int y, uint8_t card, bool hidden) {
|
|||||||
draw_suit_symbol(suit_x, y + 4, suit, suit_color, false);
|
draw_suit_symbol(suit_x, y + 4, suit, suit_color, false);
|
||||||
|
|
||||||
// Draw value in bottom-right corner
|
// Draw value in bottom-right corner
|
||||||
int bottom_x = (value_str == "10") ? x + width - 24 : x + width - 16;
|
int bottom_x = (value_str == "10") ? x + card_width - 24 : x + card_width - 16;
|
||||||
painter.draw_string({bottom_x, y + height - 18}, card_style, value_str);
|
painter.draw_string({bottom_x, y + card_height - 18}, card_style, value_str);
|
||||||
|
|
||||||
// Draw small suit symbol in bottom-right
|
// Draw small suit symbol in bottom-right
|
||||||
draw_suit_symbol(x + width - 10, y + height - 16, suit, suit_color, false);
|
draw_suit_symbol(x + card_width - 10, y + card_height - 16, suit, suit_color, false);
|
||||||
|
|
||||||
// Draw large suit symbol in center
|
// Draw large suit symbol in center
|
||||||
draw_suit_symbol(x + 20, y + 28, suit, suit_color, true);
|
int center_x = x + (card_width - 20) / 2;
|
||||||
|
int center_y = y + (card_height - 25) / 2;
|
||||||
|
draw_suit_symbol(center_x, center_y, suit, suit_color, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlackjackView::draw_hand(int x, int y, uint8_t* cards, uint8_t count, bool is_dealer) {
|
void BlackjackView::draw_hand(int x, int y, uint8_t* cards, uint8_t count, bool is_dealer) {
|
||||||
// Calculate total width needed
|
// Calculate total width needed
|
||||||
const int card_width = 60;
|
const int overlap = card_width * 2 / 3; // Amount of overlap when cards need to fit
|
||||||
const int overlap = 40; // Amount of overlap when cards need to fit
|
const int max_width = screen_w - 10 - x; // Available width on screen
|
||||||
const int max_width = 230 - x; // Available width on screen
|
|
||||||
|
|
||||||
int spacing;
|
int spacing;
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
@@ -651,7 +665,7 @@ bool BlackjackView::on_key(const KeyEvent key) {
|
|||||||
switch (game_state) {
|
switch (game_state) {
|
||||||
case GameState::MENU:
|
case GameState::MENU:
|
||||||
if (cash < 10) {
|
if (cash < 10) {
|
||||||
cash = 100; // Reset if broke - maybe should provide https://gamblersanonymous.org/ link if they also lost their wife and house
|
cash = 100; // Reset if broke
|
||||||
wins = 0;
|
wins = 0;
|
||||||
losses = 0;
|
losses = 0;
|
||||||
}
|
}
|
||||||
@@ -724,4 +738,4 @@ bool BlackjackView::on_encoder(const EncoderEvent delta) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ui::external_app::blackjack
|
} // namespace ui::external_app::blackjack
|
||||||
@@ -77,6 +77,12 @@ class BlackjackView : public View {
|
|||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
||||||
|
// Screen dimensions (set dynamically)
|
||||||
|
int screen_w = 0;
|
||||||
|
int screen_h = 0;
|
||||||
|
int card_width = 60;
|
||||||
|
int card_height = 80;
|
||||||
|
|
||||||
// Game variables
|
// Game variables
|
||||||
static constexpr uint8_t MAX_CARDS_IN_HAND = 11; // Maximum possible cards before bust
|
static constexpr uint8_t MAX_CARDS_IN_HAND = 11; // Maximum possible cards before bust
|
||||||
uint8_t deck[52];
|
uint8_t deck[52];
|
||||||
@@ -141,7 +147,7 @@ class BlackjackView : public View {
|
|||||||
{"highscore"sv, &high_score}}};
|
{"highscore"sv, &high_score}}};
|
||||||
|
|
||||||
Button dummy{
|
Button dummy{
|
||||||
{240, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_frame_sync{
|
MessageHandlerRegistration message_handler_frame_sync{
|
||||||
@@ -153,4 +159,4 @@ class BlackjackView : public View {
|
|||||||
|
|
||||||
} // namespace ui::external_app::blackjack
|
} // namespace ui::external_app::blackjack
|
||||||
|
|
||||||
#endif /* __UI_BLACKJACK_H__ */
|
#endif /* __UI_BLACKJACK_H__ */
|
||||||
+3
-3
@@ -104,10 +104,10 @@ class BLESpamView : public View {
|
|||||||
4'000'000 /* sampling rate */
|
4'000'000 /* sampling rate */
|
||||||
};
|
};
|
||||||
TxFrequencyField field_frequency{
|
TxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 16},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
TransmitterView2 tx_view{
|
TransmitterView2 tx_view{
|
||||||
{11 * 8, 0 * 16},
|
{11 * 8, UI_POS_Y(0)},
|
||||||
/*short_ui*/ true};
|
/*short_ui*/ true};
|
||||||
app_settings::SettingsManager settings_{
|
app_settings::SettingsManager settings_{
|
||||||
"tx_blespam", app_settings::Mode::TX};
|
"tx_blespam", app_settings::Mode::TX};
|
||||||
@@ -122,7 +122,7 @@ class BLESpamView : public View {
|
|||||||
{0, 70, screen_width, 220}};
|
{0, 70, screen_width, 220}};
|
||||||
#endif
|
#endif
|
||||||
OptionsField options_atkmode{
|
OptionsField options_atkmode{
|
||||||
{0 * 8, 2 * 8},
|
{UI_POS_X(0), 2 * 8},
|
||||||
10,
|
10,
|
||||||
{{"Android", 0},
|
{{"Android", 0},
|
||||||
{"iOs", 1},
|
{"iOs", 1},
|
||||||
|
|||||||
+12
-12
@@ -20,13 +20,13 @@ void initialize_app(ui::NavigationView& nav) {
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
__attribute__((section(".external_app.app_breakout.application_information"), used)) application_information_t _application_information_breakout = {
|
__attribute__((section(".external_app.app_breakout.application_information"), used)) application_information_t _application_information_breakout = {
|
||||||
(uint8_t*)0x00000000,
|
/*.memory_location = */ (uint8_t*)0x00000000,
|
||||||
ui::external_app::breakout::initialize_app,
|
/*.externalAppEntry = */ ui::external_app::breakout::initialize_app,
|
||||||
CURRENT_HEADER_VERSION,
|
/*.header_version = */ CURRENT_HEADER_VERSION,
|
||||||
VERSION_MD5,
|
/*.app_version = */ VERSION_MD5,
|
||||||
|
|
||||||
"Breakout",
|
/*.app_name = */ "Breakout",
|
||||||
{
|
/*.bitmap_data = */ {
|
||||||
0x00,
|
0x00,
|
||||||
0x00,
|
0x00,
|
||||||
0x7F,
|
0x7F,
|
||||||
@@ -60,11 +60,11 @@ __attribute__((section(".external_app.app_breakout.application_information"), us
|
|||||||
0xF7,
|
0xF7,
|
||||||
0xF7,
|
0xF7,
|
||||||
},
|
},
|
||||||
ui::Color::green().v,
|
/*.icon_color = */ ui::Color::green().v,
|
||||||
app_location_t::GAMES,
|
/*.menu_location = */ app_location_t::GAMES,
|
||||||
-1,
|
/*.desired_menu_position = */ -1,
|
||||||
|
|
||||||
{0, 0, 0, 0},
|
/*.m4_app_tag = */ {'P', 'A', 'B', 'P'}, // This is the audio beep baseband tag!
|
||||||
0x00000000,
|
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
|
||||||
};
|
};
|
||||||
} // namespace ui::external_app::breakout
|
}
|
||||||
+416
-251
@@ -7,94 +7,50 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ui_breakout.hpp"
|
#include "ui_breakout.hpp"
|
||||||
|
#include "baseband_api.hpp"
|
||||||
|
#include "audio.hpp"
|
||||||
|
#include "portapack.hpp"
|
||||||
|
#include "portapack_persistent_memory.hpp"
|
||||||
|
|
||||||
|
using namespace portapack;
|
||||||
|
|
||||||
namespace ui::external_app::breakout {
|
namespace ui::external_app::breakout {
|
||||||
|
|
||||||
Ticker game_timer;
|
void BreakoutView::cls() {
|
||||||
|
|
||||||
int paddle_x = 0;
|
|
||||||
float ball_x = 0;
|
|
||||||
float ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
|
|
||||||
float ball_dx = 1.5f;
|
|
||||||
float ball_dy = -2.0f;
|
|
||||||
int score = 0;
|
|
||||||
int lives = 3;
|
|
||||||
int level = 1;
|
|
||||||
int game_state = STATE_MENU;
|
|
||||||
bool initialized = false;
|
|
||||||
bool ball_attached = true;
|
|
||||||
unsigned int brick_count = 0;
|
|
||||||
|
|
||||||
bool menu_initialized = false;
|
|
||||||
bool blink_state = true;
|
|
||||||
uint32_t blink_counter = 0;
|
|
||||||
int16_t prompt_x = 0;
|
|
||||||
|
|
||||||
bool gameover_initialized = false;
|
|
||||||
bool gameover_blink_state = true;
|
|
||||||
uint32_t gameover_blink_counter = 0;
|
|
||||||
int16_t restart_x = 0;
|
|
||||||
|
|
||||||
bool bricks[BRICK_ROWS][BRICK_COLS];
|
|
||||||
int brick_colors[BRICK_ROWS];
|
|
||||||
|
|
||||||
const Color pp_colors[] = {
|
|
||||||
Color::white(),
|
|
||||||
Color::blue(),
|
|
||||||
Color::yellow(),
|
|
||||||
Color::purple(),
|
|
||||||
Color::green(),
|
|
||||||
Color::red(),
|
|
||||||
Color::magenta(),
|
|
||||||
Color::orange(),
|
|
||||||
Color::black(),
|
|
||||||
};
|
|
||||||
|
|
||||||
Painter painter;
|
|
||||||
|
|
||||||
bool but_RIGHT = false;
|
|
||||||
bool but_LEFT = false;
|
|
||||||
bool but_SELECT = false;
|
|
||||||
|
|
||||||
static Callback game_update_callback = nullptr;
|
|
||||||
static uint32_t game_update_timeout = 0;
|
|
||||||
static uint32_t game_update_counter = 0;
|
|
||||||
|
|
||||||
void cls() {
|
|
||||||
painter.fill_rectangle({0, 0, portapack::display.width(), portapack::display.height()}, Color::black());
|
painter.fill_rectangle({0, 0, portapack::display.width(), portapack::display.height()}, Color::black());
|
||||||
}
|
}
|
||||||
|
|
||||||
void background(int color) {
|
void BreakoutView::background(int color) {
|
||||||
(void)color;
|
(void)color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillrect(int x1, int y1, int x2, int y2, int color) {
|
void BreakoutView::fillrect(int x1, int y1, int x2, int y2, int color) {
|
||||||
painter.fill_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
|
painter.fill_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rect(int x1, int y1, int x2, int y2, int color) {
|
void BreakoutView::rect(int x1, int y1, int x2, int y2, int color) {
|
||||||
painter.draw_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
|
painter.draw_rectangle({x1, y1, x2 - x1, y2 - y1}, pp_colors[color]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_game_timer() {
|
void BreakoutView::check_game_timer() {
|
||||||
if (game_update_callback) {
|
if (game_update_callback) {
|
||||||
if (++game_update_counter >= game_update_timeout) {
|
if (++game_update_counter >= game_update_timeout) {
|
||||||
game_update_counter = 0;
|
game_update_counter = 0;
|
||||||
game_update_callback();
|
game_timer_check();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ticker::attach(Callback func, double delay_sec) {
|
void BreakoutView::attach(double delay_sec) {
|
||||||
game_update_callback = func;
|
game_update_callback = true;
|
||||||
game_update_timeout = delay_sec * 60;
|
game_update_timeout = delay_sec * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ticker::detach() {
|
void BreakoutView::detach() {
|
||||||
game_update_callback = nullptr;
|
game_update_callback = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_timer_check() {
|
void BreakoutView::game_timer_check() {
|
||||||
if (game_state == STATE_PLAYING) {
|
if (game_state == STATE_PLAYING) {
|
||||||
update_game();
|
update_game();
|
||||||
} else if (game_state == STATE_MENU) {
|
} else if (game_state == STATE_MENU) {
|
||||||
@@ -104,36 +60,88 @@ void game_timer_check() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_game() {
|
void BreakoutView::init_game() {
|
||||||
paddle_x = (screen_width - PADDLE_WIDTH) / 2;
|
SCREEN_WIDTH = screen_width;
|
||||||
|
SCREEN_HEIGHT = screen_height;
|
||||||
|
GAME_AREA_BOTTOM = SCREEN_HEIGHT - 10;
|
||||||
|
PADDLE_Y = GAME_AREA_BOTTOM - PADDLE_HEIGHT;
|
||||||
|
PADDLE_SPEED = 10;
|
||||||
|
|
||||||
|
// Calculate brick layout
|
||||||
|
int available_width = SCREEN_WIDTH - 4;
|
||||||
|
BRICK_COLS = available_width / 22;
|
||||||
|
if (BRICK_COLS > 12) BRICK_COLS = 12;
|
||||||
|
if (BRICK_COLS < 5) BRICK_COLS = 5;
|
||||||
|
BRICK_WIDTH = (available_width - (BRICK_COLS - 1) * BRICK_GAP) / BRICK_COLS;
|
||||||
|
|
||||||
|
// Initialize paddle position
|
||||||
|
paddle_x = (SCREEN_WIDTH - PADDLE_WIDTH) / 2;
|
||||||
score = 0;
|
score = 0;
|
||||||
lives = 3;
|
lives = 3;
|
||||||
level = 1;
|
level = 1;
|
||||||
|
|
||||||
|
// Set brick colors
|
||||||
brick_colors[0] = Red;
|
brick_colors[0] = Red;
|
||||||
brick_colors[1] = Orange;
|
brick_colors[1] = Orange;
|
||||||
brick_colors[2] = Yellow;
|
brick_colors[2] = Yellow;
|
||||||
brick_colors[3] = Green;
|
brick_colors[3] = Green;
|
||||||
brick_colors[4] = Purple;
|
brick_colors[4] = Purple;
|
||||||
|
|
||||||
|
// Initialize bricks array
|
||||||
|
bricks.resize(BRICK_ROWS);
|
||||||
|
for (int i = 0; i < BRICK_ROWS; i++) {
|
||||||
|
bricks[i].resize(BRICK_COLS);
|
||||||
|
}
|
||||||
|
|
||||||
init_level();
|
init_level();
|
||||||
|
|
||||||
game_state = STATE_MENU;
|
game_state = STATE_MENU;
|
||||||
menu_initialized = false;
|
menu_blink_state = true;
|
||||||
blink_state = true;
|
menu_blink_counter = 0;
|
||||||
blink_counter = 0;
|
|
||||||
|
// Play startup sound
|
||||||
|
if (sound_enabled) {
|
||||||
|
baseband::request_audio_beep(262, 24000, 150); // C4 -
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(262, 24000, 150); // C4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(392, 24000, 150); // G4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(392, 24000, 150); // G4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(440, 24000, 150); // A4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(440, 24000, 150); // A4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(392, 24000, 300); // G4
|
||||||
|
chThdSleepMilliseconds(350);
|
||||||
|
baseband::request_audio_beep(349, 24000, 150); // F4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(349, 24000, 150); // F4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(330, 24000, 150); // E4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(330, 24000, 150); // E4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(294, 24000, 150); // D4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(294, 24000, 150); // D4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(262, 24000, 400); // C4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_level() {
|
void BreakoutView::init_level() {
|
||||||
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
|
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
|
||||||
ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
|
ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
|
||||||
|
|
||||||
float speed_multiplier = (level == 1) ? 1.0f : 1.0f + ((level - 1) * BALL_SPEED_INCREASE);
|
float speed_multiplier = 1.0f + ((level - 1) * BALL_SPEED_INCREASE);
|
||||||
ball_dx = (ball_dx > 0 ? 1.5f : -1.5f) * speed_multiplier;
|
ball_dx = 1.5f * speed_multiplier;
|
||||||
ball_dy = -2.0f * speed_multiplier;
|
ball_dy = -2.0f * speed_multiplier;
|
||||||
|
|
||||||
ball_attached = true;
|
ball_attached = true;
|
||||||
|
|
||||||
|
// Fill all bricks
|
||||||
brick_count = 0;
|
brick_count = 0;
|
||||||
for (int row = 0; row < BRICK_ROWS; row++) {
|
for (int row = 0; row < BRICK_ROWS; row++) {
|
||||||
for (int col = 0; col < BRICK_COLS; col++) {
|
for (int col = 0; col < BRICK_COLS; col++) {
|
||||||
@@ -143,10 +151,9 @@ void init_level() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_screen() {
|
void BreakoutView::draw_screen() {
|
||||||
cls();
|
cls();
|
||||||
background(COLOR_BACKGROUND);
|
background(COLOR_BACKGROUND);
|
||||||
|
|
||||||
draw_borders();
|
draw_borders();
|
||||||
draw_bricks();
|
draw_bricks();
|
||||||
draw_paddle();
|
draw_paddle();
|
||||||
@@ -156,11 +163,39 @@ void draw_screen() {
|
|||||||
draw_level();
|
draw_level();
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_borders() {
|
void BreakoutView::draw_menu_volume_bar() {
|
||||||
rect(0, GAME_AREA_TOP - 1, screen_width, GAME_AREA_TOP, COLOR_BORDER);
|
// Clear the entire volume area first to handle bar shrinking
|
||||||
|
painter.fill_rectangle({40, 259, 220, 40}, Color::black());
|
||||||
|
|
||||||
|
// Draw volume label
|
||||||
|
auto style = *ui::Theme::getInstance()->fg_light;
|
||||||
|
painter.draw_string({40, 260}, style, "Volume:");
|
||||||
|
|
||||||
|
// Draw volume bar background
|
||||||
|
painter.draw_rectangle({100, 259, 102, 10}, Color::grey());
|
||||||
|
|
||||||
|
// Draw volume level
|
||||||
|
int bar_width = (volume_level * 100) / 99;
|
||||||
|
if (bar_width > 0) {
|
||||||
|
painter.fill_rectangle({101, 260, bar_width, 8}, Color::green());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw percentage
|
||||||
|
painter.draw_string({210, 260}, style, std::to_string(volume_level) + "%");
|
||||||
|
|
||||||
|
// Draw sound status
|
||||||
|
if (sound_enabled) {
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(11), 280}, *ui::Theme::getInstance()->fg_green, "Sound: ON");
|
||||||
|
} else {
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(11), 280}, *ui::Theme::getInstance()->fg_red, "Sound: OFF");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_bricks() {
|
void BreakoutView::draw_borders() {
|
||||||
|
rect(0, GAME_AREA_TOP - 1, SCREEN_WIDTH, GAME_AREA_TOP, COLOR_BORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakoutView::draw_bricks() {
|
||||||
for (int row = 0; row < BRICK_ROWS; row++) {
|
for (int row = 0; row < BRICK_ROWS; row++) {
|
||||||
for (int col = 0; col < BRICK_COLS; col++) {
|
for (int col = 0; col < BRICK_COLS; col++) {
|
||||||
if (bricks[row][col]) {
|
if (bricks[row][col]) {
|
||||||
@@ -173,37 +208,53 @@ void draw_bricks() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_paddle() {
|
void BreakoutView::draw_paddle() {
|
||||||
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_PADDLE);
|
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_PADDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_ball() {
|
void BreakoutView::draw_ball() {
|
||||||
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BALL);
|
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_score() {
|
void BreakoutView::draw_score() {
|
||||||
auto style = *ui::Theme::getInstance()->fg_green;
|
auto style = *ui::Theme::getInstance()->fg_green;
|
||||||
painter.draw_string({5, 10}, style, "Score: " + std::to_string(score));
|
painter.draw_string({5, 10}, style, "Score: " + std::to_string(score));
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_lives() {
|
void BreakoutView::draw_lives() {
|
||||||
auto style = *ui::Theme::getInstance()->fg_red;
|
auto style = *ui::Theme::getInstance()->fg_red;
|
||||||
painter.draw_string({5, 30}, style, "Lives: " + std::to_string(lives));
|
painter.draw_string({5, 30}, style, "Lives: " + std::to_string(lives));
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_level() {
|
void BreakoutView::draw_level() {
|
||||||
auto style = *ui::Theme::getInstance()->fg_yellow;
|
auto style = *ui::Theme::getInstance()->fg_yellow;
|
||||||
painter.draw_string({80, 30}, style, "Level: " + std::to_string(level));
|
painter.draw_string({80, 30}, style, "Level: " + std::to_string(level));
|
||||||
}
|
}
|
||||||
|
|
||||||
void move_paddle_left() {
|
void BreakoutView::adjust_volume(int delta) {
|
||||||
|
volume_level += delta;
|
||||||
|
if (volume_level < 0) volume_level = 0;
|
||||||
|
if (volume_level > 99) volume_level = 99;
|
||||||
|
|
||||||
|
// Update the actual audio volume using decibel conversion
|
||||||
|
// Map 0-99 to roughly -60dB to 0dB range
|
||||||
|
int db = (volume_level - 99) * 60 / 99; // Maps 0->-60dB, 99->0dB
|
||||||
|
audio::headphone::set_volume(volume_t::decibel(db));
|
||||||
|
|
||||||
|
// If we're in the menu, redraw the volume bar
|
||||||
|
if (game_state == STATE_MENU) {
|
||||||
|
draw_menu_volume_bar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakoutView::move_paddle_left() {
|
||||||
if (paddle_x > 0) {
|
if (paddle_x > 0) {
|
||||||
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_BACKGROUND);
|
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_BACKGROUND);
|
||||||
if (ball_attached) {
|
if (ball_attached) {
|
||||||
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
|
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
paddle_x -= 10;
|
paddle_x -= PADDLE_SPEED;
|
||||||
if (paddle_x < 0) paddle_x = 0;
|
if (paddle_x < 0) paddle_x = 0;
|
||||||
|
|
||||||
if (ball_attached) {
|
if (ball_attached) {
|
||||||
@@ -217,15 +268,15 @@ void move_paddle_left() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void move_paddle_right() {
|
void BreakoutView::move_paddle_right() {
|
||||||
if (paddle_x < screen_width - PADDLE_WIDTH) {
|
if (paddle_x < SCREEN_WIDTH - PADDLE_WIDTH) {
|
||||||
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_BACKGROUND);
|
fillrect(paddle_x, PADDLE_Y, paddle_x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT, COLOR_BACKGROUND);
|
||||||
if (ball_attached) {
|
if (ball_attached) {
|
||||||
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
|
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
paddle_x += 10;
|
paddle_x += PADDLE_SPEED;
|
||||||
if (paddle_x > screen_width - PADDLE_WIDTH) paddle_x = screen_width - PADDLE_WIDTH;
|
if (paddle_x > SCREEN_WIDTH - PADDLE_WIDTH) paddle_x = SCREEN_WIDTH - PADDLE_WIDTH;
|
||||||
|
|
||||||
if (ball_attached) {
|
if (ball_attached) {
|
||||||
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
|
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
|
||||||
@@ -238,27 +289,46 @@ void move_paddle_right() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void launch_ball() {
|
void BreakoutView::launch_ball() {
|
||||||
if (ball_attached) {
|
if (ball_attached) {
|
||||||
ball_attached = false;
|
ball_attached = false;
|
||||||
ball_x = paddle_x + (PADDLE_WIDTH / 2) - (BALL_SIZE / 2);
|
float speed_multiplier = 1.0f + ((level - 1) * BALL_SPEED_INCREASE);
|
||||||
ball_y = GAME_AREA_BOTTOM - PADDLE_HEIGHT - BALL_SIZE - 1;
|
|
||||||
float speed_multiplier = (level == 1) ? 1.0f : 1.0f + ((level - 1) * BALL_SPEED_INCREASE);
|
|
||||||
ball_dx = 1.5f * speed_multiplier;
|
ball_dx = 1.5f * speed_multiplier;
|
||||||
ball_dy = -2.0f * speed_multiplier;
|
ball_dy = -2.0f * speed_multiplier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_game() {
|
void BreakoutView::update_game() {
|
||||||
if (ball_attached) {
|
if (ball_attached) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
|
fillrect(ball_x, ball_y, ball_x + BALL_SIZE, ball_y + BALL_SIZE, COLOR_BACKGROUND);
|
||||||
|
|
||||||
float next_ball_y = ball_y + ball_dy;
|
ball_x += ball_dx;
|
||||||
if (next_ball_y > GAME_AREA_BOTTOM) {
|
ball_y += ball_dy;
|
||||||
|
|
||||||
|
// Wall collisions
|
||||||
|
if (ball_x < 0) {
|
||||||
|
ball_x = 0;
|
||||||
|
ball_dx = -ball_dx;
|
||||||
|
play_wall_hit();
|
||||||
|
} else if (ball_x > SCREEN_WIDTH - BALL_SIZE) {
|
||||||
|
ball_x = SCREEN_WIDTH - BALL_SIZE;
|
||||||
|
ball_dx = -ball_dx;
|
||||||
|
play_wall_hit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ball_y < GAME_AREA_TOP) {
|
||||||
|
ball_y = GAME_AREA_TOP;
|
||||||
|
ball_dy = -ball_dy;
|
||||||
|
play_wall_hit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bottom edge - lose life
|
||||||
|
if (ball_y > GAME_AREA_BOTTOM) {
|
||||||
lives--;
|
lives--;
|
||||||
|
play_death_sound(); // Play death sound
|
||||||
draw_lives();
|
draw_lives();
|
||||||
if (lives <= 0) {
|
if (lives <= 0) {
|
||||||
handle_game_over();
|
handle_game_over();
|
||||||
@@ -271,37 +341,22 @@ void update_game() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ball_x += ball_dx;
|
// Paddle collision
|
||||||
ball_y = next_ball_y;
|
|
||||||
|
|
||||||
if (ball_x < 0) {
|
|
||||||
ball_x = 0;
|
|
||||||
ball_dx = -ball_dx;
|
|
||||||
} else if (ball_x > screen_width - BALL_SIZE) {
|
|
||||||
ball_x = screen_width - BALL_SIZE;
|
|
||||||
ball_dx = -ball_dx;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ball_y < GAME_AREA_TOP) {
|
|
||||||
ball_y = GAME_AREA_TOP;
|
|
||||||
ball_dy = -ball_dy;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ball_y + BALL_SIZE >= PADDLE_Y && ball_y <= PADDLE_Y + PADDLE_HEIGHT) {
|
if (ball_y + BALL_SIZE >= PADDLE_Y && ball_y <= PADDLE_Y + PADDLE_HEIGHT) {
|
||||||
if (ball_x + BALL_SIZE >= paddle_x && ball_x <= paddle_x + PADDLE_WIDTH) {
|
if (ball_x + BALL_SIZE >= paddle_x && ball_x <= paddle_x + PADDLE_WIDTH) {
|
||||||
ball_y = PADDLE_Y - BALL_SIZE;
|
ball_y = PADDLE_Y - BALL_SIZE;
|
||||||
|
ball_dy = -ball_dy;
|
||||||
|
|
||||||
|
play_paddle_hit();
|
||||||
|
|
||||||
|
// Add some angle based on hit position
|
||||||
float hit_position = (ball_x + (BALL_SIZE / 2)) - paddle_x;
|
float hit_position = (ball_x + (BALL_SIZE / 2)) - paddle_x;
|
||||||
float angle = (hit_position / PADDLE_WIDTH) - 0.5f;
|
float angle = (hit_position / PADDLE_WIDTH) - 0.5f;
|
||||||
ball_dx = angle * 4.0f;
|
ball_dx = angle * 4.0f;
|
||||||
if (ball_dx > -0.5f && ball_dx < 0.5f) {
|
|
||||||
ball_dx = (ball_dx > 0) ? 0.5f : -0.5f;
|
|
||||||
}
|
|
||||||
ball_dy = -ball_dy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
check_collisions();
|
check_collisions();
|
||||||
|
|
||||||
draw_ball();
|
draw_ball();
|
||||||
|
|
||||||
if (check_level_complete()) {
|
if (check_level_complete()) {
|
||||||
@@ -309,188 +364,290 @@ void update_game() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_collisions() {
|
void BreakoutView::check_collisions() {
|
||||||
int grid_x = ball_x / (BRICK_WIDTH + BRICK_GAP);
|
int grid_x = ball_x / (BRICK_WIDTH + BRICK_GAP);
|
||||||
int grid_y = (ball_y - GAME_AREA_TOP - 5) / (BRICK_HEIGHT + BRICK_GAP);
|
int grid_y = (ball_y - GAME_AREA_TOP - 5) / (BRICK_HEIGHT + BRICK_GAP);
|
||||||
|
|
||||||
for (int row = grid_y - 1; row <= grid_y + 1; row++) {
|
if (grid_x >= 0 && grid_x < BRICK_COLS && grid_y >= 0 && grid_y < BRICK_ROWS) {
|
||||||
for (int col = grid_x - 1; col <= grid_x + 1; col++) {
|
check_brick_collision(grid_y, grid_x);
|
||||||
if (row >= 0 && row < BRICK_ROWS && col >= 0 && col < BRICK_COLS) {
|
|
||||||
if (bricks[row][col] && check_brick_collision(row, col)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_brick_collision(int row, int col) {
|
bool BreakoutView::check_brick_collision(int row, int col) {
|
||||||
|
if (!bricks[row][col]) return false;
|
||||||
|
|
||||||
int brick_x = col * (BRICK_WIDTH + BRICK_GAP);
|
int brick_x = col * (BRICK_WIDTH + BRICK_GAP);
|
||||||
int brick_y = GAME_AREA_TOP + row * (BRICK_HEIGHT + BRICK_GAP) + 5;
|
int brick_y = GAME_AREA_TOP + row * (BRICK_HEIGHT + BRICK_GAP) + 5;
|
||||||
|
|
||||||
if (ball_x + BALL_SIZE >= brick_x && ball_x <= brick_x + BRICK_WIDTH &&
|
if (ball_x + BALL_SIZE >= brick_x && ball_x <= brick_x + BRICK_WIDTH &&
|
||||||
ball_y + BALL_SIZE >= brick_y && ball_y <= brick_y + BRICK_HEIGHT) {
|
ball_y + BALL_SIZE >= brick_y && ball_y <= brick_y + BRICK_HEIGHT) {
|
||||||
fillrect(brick_x, brick_y, brick_x + BRICK_WIDTH, brick_y + BRICK_HEIGHT, COLOR_BACKGROUND);
|
fillrect(brick_x, brick_y, brick_x + BRICK_WIDTH, brick_y + BRICK_HEIGHT, COLOR_BACKGROUND);
|
||||||
|
|
||||||
bricks[row][col] = false;
|
bricks[row][col] = false;
|
||||||
brick_count--;
|
brick_count--;
|
||||||
|
|
||||||
score += (5 - row) * 10;
|
score += (5 - row) * 10;
|
||||||
draw_score();
|
draw_score();
|
||||||
|
|
||||||
float center_x = brick_x + BRICK_WIDTH / 2;
|
play_brick_hit();
|
||||||
float center_y = brick_y + BRICK_HEIGHT / 2;
|
|
||||||
float ball_center_x = ball_x + BALL_SIZE / 2;
|
|
||||||
float ball_center_y = ball_y + BALL_SIZE / 2;
|
|
||||||
float dx = std::abs(ball_center_x - center_x);
|
|
||||||
float dy = std::abs(ball_center_y - center_y);
|
|
||||||
|
|
||||||
if (dx * BRICK_HEIGHT > dy * BRICK_WIDTH) {
|
|
||||||
ball_dx = -ball_dx;
|
|
||||||
} else {
|
|
||||||
ball_dy = -ball_dy;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ball_dy = -ball_dy;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_level_complete() {
|
bool BreakoutView::check_level_complete() {
|
||||||
return brick_count == 0;
|
return brick_count == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void next_level() {
|
void BreakoutView::next_level() {
|
||||||
level++;
|
level++;
|
||||||
|
play_level_complete();
|
||||||
|
chThdSleepMilliseconds(500); // Give time for sound to play
|
||||||
init_level();
|
init_level();
|
||||||
draw_screen();
|
draw_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_game_over() {
|
void BreakoutView::handle_game_over() {
|
||||||
game_state = STATE_GAME_OVER;
|
game_state = STATE_GAME_OVER;
|
||||||
gameover_initialized = false;
|
|
||||||
show_game_over();
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_menu() {
|
|
||||||
cls();
|
|
||||||
background(COLOR_BACKGROUND);
|
|
||||||
|
|
||||||
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
|
|
||||||
auto style_blue = *ui::Theme::getInstance()->fg_blue;
|
|
||||||
auto style_cyan = *ui::Theme::getInstance()->fg_cyan;
|
|
||||||
|
|
||||||
int16_t screen_width = ui::screen_width;
|
|
||||||
int16_t title_x = (screen_width - 17 * 8) / 2;
|
|
||||||
int16_t divider_width = 24 * 8;
|
|
||||||
int16_t divider_x = (screen_width - divider_width) / 2;
|
|
||||||
int16_t instruction_width = 22 * 8;
|
|
||||||
int16_t instruction_x = (screen_width - instruction_width) / 2;
|
|
||||||
int16_t prompt_width = 16 * 8;
|
|
||||||
prompt_x = (screen_width - prompt_width) / 2;
|
|
||||||
|
|
||||||
painter.fill_rectangle({0, 30, screen_width, 30}, Color::black());
|
|
||||||
painter.draw_string({title_x + 2, 42}, style_yellow, "*** BREAKOUT ***");
|
|
||||||
painter.draw_string({divider_x, 70}, style_blue, "========================");
|
|
||||||
painter.fill_rectangle({instruction_x - 5, 110, instruction_width + 10, 70}, Color::black());
|
|
||||||
painter.draw_rectangle({instruction_x - 5, 110, instruction_width + 10, 70}, Color::white());
|
|
||||||
painter.draw_string({instruction_x, 120}, style_cyan, " ROTARY: MOVE PADDLE");
|
|
||||||
painter.draw_string({instruction_x, 150}, style_cyan, " SELECT: START/LAUNCH");
|
|
||||||
painter.draw_string({divider_x, 190}, style_blue, "========================");
|
|
||||||
|
|
||||||
menu_initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void show_menu() {
|
|
||||||
if (!menu_initialized) {
|
|
||||||
init_menu();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto style_red = *ui::Theme::getInstance()->fg_red;
|
|
||||||
|
|
||||||
if (++blink_counter >= 30) {
|
|
||||||
blink_counter = 0;
|
|
||||||
blink_state = !blink_state;
|
|
||||||
|
|
||||||
painter.fill_rectangle({prompt_x - 2, 228, 16 * 8 + 4, 20}, Color::black());
|
|
||||||
|
|
||||||
if (blink_state) {
|
|
||||||
painter.draw_string({prompt_x, 230}, style_red, "* PRESS SELECT *");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_game_over() {
|
|
||||||
cls();
|
|
||||||
background(COLOR_BACKGROUND);
|
|
||||||
|
|
||||||
auto style_red = *ui::Theme::getInstance()->fg_red;
|
|
||||||
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
|
|
||||||
|
|
||||||
// int16_t screen_width = screen_width;
|
|
||||||
int16_t title_width = 9 * 8;
|
|
||||||
int16_t title_x = (screen_width - title_width) / 2;
|
|
||||||
int16_t score_text_width = (16 + std::to_string(score).length()) * 8;
|
|
||||||
int16_t score_x = (screen_width - score_text_width) / 2;
|
|
||||||
|
|
||||||
painter.draw_rectangle({20, 80, screen_width - 40, 160}, Color::red());
|
|
||||||
painter.draw_rectangle({22, 82, screen_width - 44, 156}, Color::white());
|
|
||||||
|
|
||||||
painter.draw_string({title_x, 100}, style_red, "GAME OVER");
|
|
||||||
|
|
||||||
painter.fill_rectangle({40, 140, screen_width - 80, 30}, Color::black());
|
|
||||||
painter.draw_rectangle({40, 140, screen_width - 80, 30}, Color::yellow());
|
|
||||||
painter.draw_string({score_x, 150}, style_yellow, " FINAL SCORE: " + std::to_string(score));
|
|
||||||
|
|
||||||
int16_t restart_width = 12 * 8;
|
|
||||||
restart_x = (screen_width - restart_width) / 2;
|
|
||||||
|
|
||||||
gameover_initialized = true;
|
|
||||||
gameover_blink_state = true;
|
gameover_blink_state = true;
|
||||||
gameover_blink_counter = 0;
|
gameover_blink_counter = 0;
|
||||||
|
play_game_over();
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_game_over() {
|
void BreakoutView::show_menu() {
|
||||||
if (!gameover_initialized) {
|
// Only draw the static parts once
|
||||||
init_game_over();
|
if (menu_blink_counter == 0) {
|
||||||
|
cls();
|
||||||
|
background(COLOR_BACKGROUND);
|
||||||
|
|
||||||
|
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
|
||||||
|
auto style_blue = *ui::Theme::getInstance()->fg_blue;
|
||||||
|
auto style_cyan = *ui::Theme::getInstance()->fg_cyan;
|
||||||
|
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(17), 40}, style_yellow, "*** BREAKOUT ***");
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(25), 100}, style_blue, "========================");
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(20), 130}, style_cyan, "ROTARY: MOVE PADDLE");
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(21), 160}, style_cyan, "SELECT: START/LAUNCH");
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(25), 190}, style_blue, "========================");
|
||||||
|
|
||||||
|
// Volume adjustment instructions
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(24), 220}, style_cyan, "Press UP/DOWN for Volume");
|
||||||
|
|
||||||
|
// Draw volume control at bottom
|
||||||
|
draw_menu_volume_bar();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto style_green = *ui::Theme::getInstance()->fg_green;
|
// Only flash the "PRESS SELECT" text
|
||||||
|
if (++menu_blink_counter >= 30) {
|
||||||
|
menu_blink_counter = 1; // Keep it at 1 so we don't redraw everything
|
||||||
|
menu_blink_state = !menu_blink_state;
|
||||||
|
|
||||||
if (++gameover_blink_counter >= 30) {
|
auto style_red = *ui::Theme::getInstance()->fg_red;
|
||||||
gameover_blink_counter = 0;
|
painter.fill_rectangle({UI_POS_X_CENTER(17), 238, 128, 20}, Color::black());
|
||||||
gameover_blink_state = !gameover_blink_state;
|
|
||||||
|
|
||||||
painter.fill_rectangle({restart_x - 2, 198, 12 * 8 + 4, 20}, Color::black());
|
if (menu_blink_state) {
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(17), 240}, style_red, "* PRESS SELECT *");
|
||||||
if (gameover_blink_state) {
|
|
||||||
painter.draw_string({restart_x, 200}, style_green, "PRESS SELECT");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_game() {
|
void BreakoutView::show_game_over() {
|
||||||
|
// Only draw the static parts once
|
||||||
|
if (gameover_blink_counter == 0) {
|
||||||
|
cls();
|
||||||
|
background(COLOR_BACKGROUND);
|
||||||
|
|
||||||
|
auto style_red = *ui::Theme::getInstance()->fg_red;
|
||||||
|
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
|
||||||
|
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(10), 100}, style_red, "GAME OVER");
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(11), 150}, style_yellow, "SCORE: " + std::to_string(score));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only flash the "PRESS SELECT" text
|
||||||
|
if (++gameover_blink_counter >= 30) {
|
||||||
|
gameover_blink_counter = 1; // Keep it at 1 so we don't redraw everything
|
||||||
|
gameover_blink_state = !gameover_blink_state;
|
||||||
|
|
||||||
|
auto style_green = *ui::Theme::getInstance()->fg_green;
|
||||||
|
painter.fill_rectangle({UI_POS_X_CENTER(13), 198, 96, 20}, Color::black());
|
||||||
|
|
||||||
|
if (gameover_blink_state) {
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(13), 200}, style_green, "PRESS SELECT");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakoutView::reset_game() {
|
||||||
level = 1;
|
level = 1;
|
||||||
score = 0;
|
score = 0;
|
||||||
lives = 3;
|
lives = 3;
|
||||||
game_state = STATE_PLAYING;
|
game_state = STATE_PLAYING;
|
||||||
|
|
||||||
|
dummy.focus();
|
||||||
|
|
||||||
init_level();
|
init_level();
|
||||||
draw_screen();
|
draw_screen();
|
||||||
gameover_initialized = false;
|
}
|
||||||
gameover_blink_state = true;
|
|
||||||
gameover_blink_counter = 0;
|
// Sound effect implementations with timing control
|
||||||
|
void BreakoutView::play_paddle_hit() {
|
||||||
|
if (sound_enabled) {
|
||||||
|
uint32_t current_time = chTimeNow();
|
||||||
|
if (current_time - last_sound_time >= min_sound_interval) {
|
||||||
|
baseband::request_beep_stop(); // Stop any previous sound
|
||||||
|
chThdSleepMilliseconds(5); // Small delay
|
||||||
|
baseband::request_audio_beep(440, 24000, 40); // 440Hz A4, 40ms
|
||||||
|
last_sound_time = current_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakoutView::play_brick_hit() {
|
||||||
|
if (sound_enabled) {
|
||||||
|
uint32_t current_time = chTimeNow();
|
||||||
|
if (current_time - last_sound_time >= min_sound_interval) {
|
||||||
|
baseband::request_beep_stop(); // Stop any previous sound
|
||||||
|
chThdSleepMilliseconds(5); // Small delay
|
||||||
|
// Higher pitch that varies with remaining bricks
|
||||||
|
uint32_t freq = 880 + ((25 - brick_count) * 20); // Gets higher as bricks are destroyed
|
||||||
|
baseband::request_audio_beep(freq, 24000, 30);
|
||||||
|
last_sound_time = current_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakoutView::play_wall_hit() {
|
||||||
|
if (sound_enabled) {
|
||||||
|
uint32_t current_time = chTimeNow();
|
||||||
|
if (current_time - last_sound_time >= min_sound_interval) {
|
||||||
|
baseband::request_beep_stop(); // Stop any previous sound
|
||||||
|
chThdSleepMilliseconds(5); // Small delay
|
||||||
|
baseband::request_audio_beep(220, 24000, 120); // 220Hz A3, 120ms
|
||||||
|
last_sound_time = current_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakoutView::play_death_sound() {
|
||||||
|
if (sound_enabled) {
|
||||||
|
baseband::request_audio_beep(493, 24000, 150); // B4
|
||||||
|
chThdSleepMilliseconds(180);
|
||||||
|
baseband::request_audio_beep(466, 24000, 150); // Bb4
|
||||||
|
chThdSleepMilliseconds(180);
|
||||||
|
baseband::request_audio_beep(440, 24000, 150); // A4
|
||||||
|
chThdSleepMilliseconds(180);
|
||||||
|
baseband::request_audio_beep(415, 24000, 150); // Ab4
|
||||||
|
chThdSleepMilliseconds(180);
|
||||||
|
baseband::request_audio_beep(392, 24000, 150); // G4
|
||||||
|
chThdSleepMilliseconds(180);
|
||||||
|
baseband::request_audio_beep(369, 24000, 150); // Gb4
|
||||||
|
chThdSleepMilliseconds(180);
|
||||||
|
baseband::request_audio_beep(349, 24000, 150); // F4
|
||||||
|
chThdSleepMilliseconds(180);
|
||||||
|
baseband::request_audio_beep(329, 24000, 150); // E4
|
||||||
|
chThdSleepMilliseconds(180);
|
||||||
|
baseband::request_audio_beep(293, 24000, 150); // D4
|
||||||
|
chThdSleepMilliseconds(180);
|
||||||
|
baseband::request_audio_beep(261, 24000, 150); // C4
|
||||||
|
chThdSleepMilliseconds(180);
|
||||||
|
baseband::request_audio_beep(196, 24000, 200); // G3
|
||||||
|
chThdSleepMilliseconds(230);
|
||||||
|
baseband::request_audio_beep(130, 24000, 300); // C3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakoutView::play_game_over() {
|
||||||
|
if (sound_enabled) {
|
||||||
|
// First phrase
|
||||||
|
baseband::request_audio_beep(392, 24000, 300); // G4
|
||||||
|
chThdSleepMilliseconds(350);
|
||||||
|
baseband::request_audio_beep(392, 24000, 150); // G4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(392, 24000, 150); // G4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(311, 24000, 500); // Eb4 - long
|
||||||
|
chThdSleepMilliseconds(600);
|
||||||
|
|
||||||
|
// Second phrase
|
||||||
|
baseband::request_audio_beep(349, 24000, 300); // F4
|
||||||
|
chThdSleepMilliseconds(350);
|
||||||
|
baseband::request_audio_beep(349, 24000, 150); // F4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(349, 24000, 150); // F4
|
||||||
|
chThdSleepMilliseconds(200);
|
||||||
|
baseband::request_audio_beep(294, 24000, 500); // D4 - long
|
||||||
|
chThdSleepMilliseconds(600);
|
||||||
|
|
||||||
|
// Final phrase - slower and more dramatic
|
||||||
|
baseband::request_audio_beep(262, 24000, 200); // C4
|
||||||
|
chThdSleepMilliseconds(250);
|
||||||
|
baseband::request_audio_beep(247, 24000, 200); // B3
|
||||||
|
chThdSleepMilliseconds(250);
|
||||||
|
baseband::request_audio_beep(233, 24000, 200); // Bb3
|
||||||
|
chThdSleepMilliseconds(250);
|
||||||
|
baseband::request_audio_beep(220, 24000, 200); // A3
|
||||||
|
chThdSleepMilliseconds(250);
|
||||||
|
baseband::request_audio_beep(196, 24000, 200); // G3
|
||||||
|
chThdSleepMilliseconds(250);
|
||||||
|
baseband::request_audio_beep(175, 24000, 200); // F3
|
||||||
|
chThdSleepMilliseconds(250);
|
||||||
|
baseband::request_audio_beep(131, 24000, 600); // C3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakoutView::play_level_complete() {
|
||||||
|
if (sound_enabled) {
|
||||||
|
baseband::request_beep_stop(); // Stop any previous sound
|
||||||
|
chThdSleepMilliseconds(10);
|
||||||
|
baseband::request_audio_beep(1047, 24000, 300); // 1047Hz C6, 300ms
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BreakoutView::BreakoutView(NavigationView& nav)
|
BreakoutView::BreakoutView(NavigationView& nav)
|
||||||
: nav_{nav} {
|
: nav_{nav}, bricks{} {
|
||||||
paddle_x = (screen_width - PADDLE_WIDTH) / 2;
|
// Initialize audio system for beeps FIRST
|
||||||
ball_x = screen_width / 2;
|
baseband::run_prepared_image(portapack::memory::map::m4_code.base()); // Load the audio beep baseband
|
||||||
|
|
||||||
add_children({&dummy});
|
add_children({&dummy});
|
||||||
game_timer.attach(&game_timer_check, 1.0 / 60.0);
|
|
||||||
|
// Initialize audio
|
||||||
|
audio::set_rate(audio::Rate::Hz_24000);
|
||||||
|
audio::output::start();
|
||||||
|
|
||||||
|
// Set initial volume to 80% and ensure sound is ON
|
||||||
|
volume_level = 80;
|
||||||
|
sound_enabled = true; // Make sure this is explicitly set to ON
|
||||||
|
|
||||||
|
// Set the actual volume
|
||||||
|
int db = (volume_level - 99) * 60 / 99; // Maps to roughly -12dB for 80%
|
||||||
|
audio::headphone::set_volume(volume_t::decibel(db));
|
||||||
|
|
||||||
|
attach(1.0 / 60.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
BreakoutView::~BreakoutView() {
|
||||||
|
// Clean shutdown
|
||||||
|
baseband::request_beep_stop();
|
||||||
|
receiver_model.disable();
|
||||||
|
baseband::shutdown();
|
||||||
|
audio::output::stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakoutView::on_show() {
|
void BreakoutView::on_show() {
|
||||||
|
// Nothing needed here, initialization done in constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakoutView::on_hide() {
|
||||||
|
// Additional cleanup
|
||||||
|
baseband::request_beep_stop();
|
||||||
|
audio::output::stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakoutView::focus() {
|
||||||
|
dummy.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakoutView::paint(Painter& painter) {
|
void BreakoutView::paint(Painter& painter) {
|
||||||
@@ -512,20 +669,15 @@ bool BreakoutView::on_encoder(const EncoderEvent delta) {
|
|||||||
if (game_state == STATE_PLAYING) {
|
if (game_state == STATE_PLAYING) {
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
move_paddle_right();
|
move_paddle_right();
|
||||||
set_dirty();
|
|
||||||
} else if (delta < 0) {
|
} else if (delta < 0) {
|
||||||
move_paddle_left();
|
move_paddle_left();
|
||||||
set_dirty();
|
|
||||||
}
|
}
|
||||||
|
set_dirty();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BreakoutView::on_key(const KeyEvent key) {
|
bool BreakoutView::on_key(const KeyEvent key) {
|
||||||
but_SELECT = (key == KeyEvent::Select);
|
|
||||||
but_LEFT = (key == KeyEvent::Left);
|
|
||||||
but_RIGHT = (key == KeyEvent::Right);
|
|
||||||
|
|
||||||
if (key == KeyEvent::Select) {
|
if (key == KeyEvent::Select) {
|
||||||
if (game_state == STATE_MENU) {
|
if (game_state == STATE_MENU) {
|
||||||
game_state = STATE_PLAYING;
|
game_state = STATE_PLAYING;
|
||||||
@@ -533,20 +685,33 @@ bool BreakoutView::on_key(const KeyEvent key) {
|
|||||||
} else if (game_state == STATE_PLAYING && ball_attached) {
|
} else if (game_state == STATE_PLAYING && ball_attached) {
|
||||||
launch_ball();
|
launch_ball();
|
||||||
} else if (game_state == STATE_GAME_OVER) {
|
} else if (game_state == STATE_GAME_OVER) {
|
||||||
reset_game();
|
// Return to menu after game over
|
||||||
}
|
game_state = STATE_MENU;
|
||||||
} else if (key == KeyEvent::Left) {
|
menu_blink_counter = 0;
|
||||||
if (game_state == STATE_PLAYING) {
|
init_game();
|
||||||
move_paddle_left();
|
|
||||||
}
|
|
||||||
} else if (key == KeyEvent::Right) {
|
|
||||||
if (game_state == STATE_PLAYING) {
|
|
||||||
move_paddle_right();
|
|
||||||
}
|
}
|
||||||
|
} else if (key == KeyEvent::Left && game_state == STATE_PLAYING) {
|
||||||
|
move_paddle_left();
|
||||||
|
} else if (key == KeyEvent::Right && game_state == STATE_PLAYING) {
|
||||||
|
move_paddle_right();
|
||||||
|
} else if (key == KeyEvent::Up && game_state == STATE_MENU) {
|
||||||
|
// Only adjust volume in menu
|
||||||
|
adjust_volume(5);
|
||||||
|
if (!sound_enabled) sound_enabled = true;
|
||||||
|
set_dirty();
|
||||||
|
} else if (key == KeyEvent::Down && game_state == STATE_MENU) {
|
||||||
|
// Only adjust volume in menu
|
||||||
|
adjust_volume(-5);
|
||||||
|
set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
set_dirty();
|
set_dirty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BreakoutView::on_touch(const TouchEvent event) {
|
||||||
|
(void)event; // Intentionally unused - touch disabled to avoid nav bar issues
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ui::external_app::breakout
|
} // namespace ui::external_app::breakout
|
||||||
+100
-71
@@ -11,12 +11,14 @@
|
|||||||
|
|
||||||
#include "ui.hpp"
|
#include "ui.hpp"
|
||||||
#include "ui_navigation.hpp"
|
#include "ui_navigation.hpp"
|
||||||
|
#include "ui_receiver.hpp"
|
||||||
#include "event_m0.hpp"
|
#include "event_m0.hpp"
|
||||||
#include "message.hpp"
|
#include "message.hpp"
|
||||||
#include "irq_controls.hpp"
|
#include "irq_controls.hpp"
|
||||||
#include "random.hpp"
|
#include "random.hpp"
|
||||||
#include "lpc43xx_cpp.hpp"
|
#include "lpc43xx_cpp.hpp"
|
||||||
#include "ui_widget.hpp"
|
#include "ui_widget.hpp"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace ui::external_app::breakout {
|
namespace ui::external_app::breakout {
|
||||||
|
|
||||||
@@ -32,41 +34,15 @@ enum {
|
|||||||
Black,
|
Black,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const Color pp_colors[];
|
|
||||||
extern Painter painter;
|
|
||||||
extern bool but_RIGHT;
|
|
||||||
extern bool but_LEFT;
|
|
||||||
extern bool but_SELECT;
|
|
||||||
|
|
||||||
void cls();
|
|
||||||
void background(int color);
|
|
||||||
void fillrect(int x1, int y1, int x2, int y2, int color);
|
|
||||||
void rect(int x1, int y1, int x2, int y2, int color);
|
|
||||||
|
|
||||||
#define wait(x) chThdSleepMilliseconds(x * 1000)
|
#define wait(x) chThdSleepMilliseconds(x * 1000)
|
||||||
|
|
||||||
using Callback = void (*)(void);
|
|
||||||
|
|
||||||
void check_game_timer();
|
|
||||||
|
|
||||||
class Ticker {
|
|
||||||
public:
|
|
||||||
Ticker() = default;
|
|
||||||
void attach(Callback func, double delay_sec);
|
|
||||||
void detach();
|
|
||||||
};
|
|
||||||
|
|
||||||
#define PADDLE_WIDTH 40
|
#define PADDLE_WIDTH 40
|
||||||
#define PADDLE_HEIGHT 10
|
#define PADDLE_HEIGHT 10
|
||||||
#define BALL_SIZE 8
|
#define BALL_SIZE 8
|
||||||
#define BRICK_WIDTH 20
|
|
||||||
#define BRICK_HEIGHT 10
|
#define BRICK_HEIGHT 10
|
||||||
#define BRICK_ROWS 5
|
#define BRICK_ROWS 5
|
||||||
#define BRICK_COLS 10
|
|
||||||
#define BRICK_GAP 2
|
#define BRICK_GAP 2
|
||||||
#define GAME_AREA_TOP 50
|
#define GAME_AREA_TOP 50
|
||||||
#define GAME_AREA_BOTTOM 310
|
|
||||||
#define PADDLE_Y (GAME_AREA_BOTTOM - PADDLE_HEIGHT)
|
|
||||||
#define BALL_SPEED_INCREASE 0.1f
|
#define BALL_SPEED_INCREASE 0.1f
|
||||||
|
|
||||||
#define STATE_MENU 0
|
#define STATE_MENU 0
|
||||||
@@ -77,66 +53,119 @@ class Ticker {
|
|||||||
#define COLOR_PADDLE Blue
|
#define COLOR_PADDLE Blue
|
||||||
#define COLOR_BALL White
|
#define COLOR_BALL White
|
||||||
#define COLOR_BORDER White
|
#define COLOR_BORDER White
|
||||||
#define COLOR_BRICK_COLORS \
|
|
||||||
{ Red, Orange, Yellow, Green, Purple }
|
|
||||||
|
|
||||||
extern Ticker game_timer;
|
|
||||||
|
|
||||||
extern int paddle_x;
|
|
||||||
extern float ball_x;
|
|
||||||
extern float ball_y;
|
|
||||||
extern float ball_dx;
|
|
||||||
extern float ball_dy;
|
|
||||||
extern int score;
|
|
||||||
extern int lives;
|
|
||||||
extern int level;
|
|
||||||
extern int game_state;
|
|
||||||
extern bool initialized;
|
|
||||||
extern bool ball_attached;
|
|
||||||
extern unsigned int brick_count;
|
|
||||||
extern bool bricks[BRICK_ROWS][BRICK_COLS];
|
|
||||||
extern int brick_colors[BRICK_ROWS];
|
|
||||||
|
|
||||||
void game_timer_check();
|
|
||||||
void init_game();
|
|
||||||
void init_level();
|
|
||||||
void draw_screen();
|
|
||||||
void draw_bricks();
|
|
||||||
void draw_paddle();
|
|
||||||
void draw_ball();
|
|
||||||
void draw_score();
|
|
||||||
void draw_lives();
|
|
||||||
void draw_level();
|
|
||||||
void draw_borders();
|
|
||||||
void move_paddle_left();
|
|
||||||
void move_paddle_right();
|
|
||||||
void launch_ball();
|
|
||||||
void update_game();
|
|
||||||
void check_collisions();
|
|
||||||
bool check_brick_collision(int row, int col);
|
|
||||||
void handle_game_over();
|
|
||||||
void show_menu();
|
|
||||||
void show_game_over();
|
|
||||||
bool check_level_complete();
|
|
||||||
void next_level();
|
|
||||||
void reset_game();
|
|
||||||
|
|
||||||
class BreakoutView : public View {
|
class BreakoutView : public View {
|
||||||
public:
|
public:
|
||||||
BreakoutView(NavigationView& nav);
|
BreakoutView(NavigationView& nav);
|
||||||
|
~BreakoutView();
|
||||||
void on_show() override;
|
void on_show() override;
|
||||||
|
void on_hide() override;
|
||||||
|
|
||||||
std::string title() const override { return "Breakout"; }
|
std::string title() const override { return "Breakout"; }
|
||||||
|
|
||||||
void focus() override { dummy.focus(); }
|
void focus() override;
|
||||||
void paint(Painter& painter) override;
|
void paint(Painter& painter) override;
|
||||||
void frame_sync();
|
void frame_sync();
|
||||||
bool on_encoder(const EncoderEvent event) override;
|
bool on_encoder(const EncoderEvent event) override;
|
||||||
bool on_key(KeyEvent key) override;
|
bool on_key(KeyEvent key) override;
|
||||||
|
bool on_touch(const TouchEvent event) override;
|
||||||
|
|
||||||
|
void cls();
|
||||||
|
void background(int color);
|
||||||
|
void fillrect(int x1, int y1, int x2, int y2, int color);
|
||||||
|
void rect(int x1, int y1, int x2, int y2, int color);
|
||||||
|
void game_timer_check();
|
||||||
|
void init_game();
|
||||||
|
void init_level();
|
||||||
|
void draw_screen();
|
||||||
|
void draw_bricks();
|
||||||
|
void draw_paddle();
|
||||||
|
void draw_ball();
|
||||||
|
void draw_score();
|
||||||
|
void draw_lives();
|
||||||
|
void draw_level();
|
||||||
|
void draw_borders();
|
||||||
|
void draw_menu_volume_bar();
|
||||||
|
void move_paddle_left();
|
||||||
|
void move_paddle_right();
|
||||||
|
void launch_ball();
|
||||||
|
void update_game();
|
||||||
|
void check_collisions();
|
||||||
|
bool check_brick_collision(int row, int col);
|
||||||
|
void handle_game_over();
|
||||||
|
void show_menu();
|
||||||
|
void show_game_over();
|
||||||
|
bool check_level_complete();
|
||||||
|
void next_level();
|
||||||
|
void reset_game();
|
||||||
|
void check_game_timer();
|
||||||
|
void attach(double delay_sec);
|
||||||
|
void detach();
|
||||||
|
void adjust_volume(int delta);
|
||||||
|
|
||||||
|
// Sound effect methods
|
||||||
|
void play_paddle_hit();
|
||||||
|
void play_brick_hit();
|
||||||
|
void play_wall_hit();
|
||||||
|
void play_death_sound();
|
||||||
|
void play_game_over();
|
||||||
|
void play_level_complete();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool initialized = false;
|
const Color pp_colors[9] = {
|
||||||
|
Color::white(),
|
||||||
|
Color::blue(),
|
||||||
|
Color::yellow(),
|
||||||
|
Color::purple(),
|
||||||
|
Color::green(),
|
||||||
|
Color::red(),
|
||||||
|
Color::magenta(),
|
||||||
|
Color::orange(),
|
||||||
|
Color::black(),
|
||||||
|
};
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
|
Painter painter{};
|
||||||
|
|
||||||
|
// Dynamic screen-dependent values
|
||||||
|
int SCREEN_WIDTH = 0;
|
||||||
|
int SCREEN_HEIGHT = 0;
|
||||||
|
int GAME_AREA_BOTTOM = 0;
|
||||||
|
int PADDLE_Y = 0;
|
||||||
|
int BRICK_WIDTH = 0;
|
||||||
|
int BRICK_COLS = 0;
|
||||||
|
int PADDLE_SPEED = 0;
|
||||||
|
|
||||||
|
int paddle_x = 0;
|
||||||
|
float ball_x = 0;
|
||||||
|
float ball_y = 0;
|
||||||
|
float ball_dx = 1.5f;
|
||||||
|
float ball_dy = -2.0f;
|
||||||
|
int score = 0;
|
||||||
|
int lives = 3;
|
||||||
|
int level = 1;
|
||||||
|
int game_state = STATE_MENU;
|
||||||
|
bool initialized = false;
|
||||||
|
bool ball_attached = true;
|
||||||
|
unsigned int brick_count = 0;
|
||||||
|
|
||||||
|
bool menu_blink_state = true;
|
||||||
|
uint32_t menu_blink_counter = 0;
|
||||||
|
|
||||||
|
bool gameover_blink_state = true;
|
||||||
|
uint32_t gameover_blink_counter = 0;
|
||||||
|
|
||||||
|
std::vector<std::vector<bool>> bricks;
|
||||||
|
int brick_colors[BRICK_ROWS];
|
||||||
|
|
||||||
|
bool game_update_callback = false;
|
||||||
|
double game_update_timeout = 0;
|
||||||
|
uint32_t game_update_counter = 0;
|
||||||
|
|
||||||
|
// Audio control
|
||||||
|
bool sound_enabled = true;
|
||||||
|
int volume_level = 80; // 0-99
|
||||||
|
uint32_t last_sound_time = 0;
|
||||||
|
uint32_t min_sound_interval = 20; // Minimum ms between sounds
|
||||||
|
|
||||||
Button dummy{
|
Button dummy{
|
||||||
{screen_width, 0, 0, 0},
|
{screen_width, 0, 0, 0},
|
||||||
|
|||||||
+1
-1
@@ -440,7 +440,7 @@ static void _sumlr(void);
|
|||||||
#undef __O
|
#undef __O
|
||||||
#undef __P
|
#undef __P
|
||||||
|
|
||||||
#define PI 3.141592653589793
|
#include "mathdef.hpp"
|
||||||
|
|
||||||
static void _numinput(byte k);
|
static void _numinput(byte k);
|
||||||
static double dpush(double d);
|
static double dpush(double d);
|
||||||
|
|||||||
+17
-17
@@ -48,25 +48,25 @@ class CalculatorView : public View {
|
|||||||
private:
|
private:
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
|
|
||||||
Button button_F{{0 * 8, 11 * 16, 6 * 8, 16 + 8}, "F"};
|
Button button_F{{UI_POS_X_TABLE(4, 0), UI_POS_Y_BOTTOM(9), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "F"};
|
||||||
Button button_7{{8 * 8, 11 * 16, 6 * 8, 16 + 8}, "7"};
|
Button button_7{{UI_POS_X_TABLE(4, 1), UI_POS_Y_BOTTOM(9), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "7"};
|
||||||
Button button_8{{16 * 8, 11 * 16, 6 * 8, 16 + 8}, "8"};
|
Button button_8{{UI_POS_X_TABLE(4, 2), UI_POS_Y_BOTTOM(9), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "8"};
|
||||||
Button button_9{{24 * 8, 11 * 16, 6 * 8, 16 + 8}, "9"};
|
Button button_9{{UI_POS_X_TABLE(4, 3), UI_POS_Y_BOTTOM(9), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "9"};
|
||||||
Button button_E{{0 * 8, 13 * 16, 6 * 8, 16 + 8}, "E"};
|
Button button_E{{UI_POS_X_TABLE(4, 0), UI_POS_Y_BOTTOM(7), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "E"};
|
||||||
Button button_4{{8 * 8, 13 * 16, 6 * 8, 16 + 8}, "4"};
|
Button button_4{{UI_POS_X_TABLE(4, 1), UI_POS_Y_BOTTOM(7), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "4"};
|
||||||
Button button_5{{16 * 8, 13 * 16, 6 * 8, 16 + 8}, "5"};
|
Button button_5{{UI_POS_X_TABLE(4, 2), UI_POS_Y_BOTTOM(7), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "5"};
|
||||||
Button button_6{{24 * 8, 13 * 16, 6 * 8, 16 + 8}, "6"};
|
Button button_6{{UI_POS_X_TABLE(4, 3), UI_POS_Y_BOTTOM(7), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "6"};
|
||||||
Button button_N{{0 * 8, 15 * 16, 6 * 8, 16 + 8}, "N"};
|
Button button_N{{UI_POS_X_TABLE(4, 0), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "N"};
|
||||||
Button button_1{{8 * 8, 15 * 16, 6 * 8, 16 + 8}, "1"};
|
Button button_1{{UI_POS_X_TABLE(4, 1), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "1"};
|
||||||
Button button_2{{16 * 8, 15 * 16, 6 * 8, 16 + 8}, "2"};
|
Button button_2{{UI_POS_X_TABLE(4, 2), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "2"};
|
||||||
Button button_3{{24 * 8, 15 * 16, 6 * 8, 16 + 8}, "3"};
|
Button button_3{{UI_POS_X_TABLE(4, 3), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "3"};
|
||||||
Button button_C{{0 * 8, 17 * 16, 6 * 8, 16 + 8}, "C"};
|
Button button_C{{UI_POS_X_TABLE(4, 0), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "C"};
|
||||||
Button button_0{{8 * 8, 17 * 16, 6 * 8, 16 + 8}, "0"};
|
Button button_0{{UI_POS_X_TABLE(4, 1), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "0"};
|
||||||
Button button_P{{16 * 8, 17 * 16, 6 * 8, 16 + 8}, "."};
|
Button button_P{{UI_POS_X_TABLE(4, 2), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "."};
|
||||||
Button button_D{{24 * 8, 17 * 16, 6 * 8, 16 + 8}, "D"};
|
Button button_D{{UI_POS_X_TABLE(4, 3), UI_POS_Y_BOTTOM(3), UI_POS_WIDTH(6), UI_POS_HEIGHT(1.5)}, "D"};
|
||||||
|
|
||||||
Console console{
|
Console console{
|
||||||
{0 * 8, 0 * 16, screen_width, 10 * 16}};
|
{UI_POS_X(0), UI_POS_Y(0), screen_width, UI_POS_HEIGHT_REMAINING(10)}};
|
||||||
|
|
||||||
void on_button_press(uint8_t button);
|
void on_button_press(uint8_t button);
|
||||||
void update_button_labels();
|
void update_button_labels();
|
||||||
|
|||||||
+1
-1
@@ -88,7 +88,7 @@ class CoasterPagerView : public View {
|
|||||||
""};
|
""};
|
||||||
|
|
||||||
TransmitterView tx_view{
|
TransmitterView tx_view{
|
||||||
16 * 16,
|
(int16_t)UI_POS_Y_BOTTOM(4),
|
||||||
10000,
|
10000,
|
||||||
12};
|
12};
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -53,38 +53,38 @@ class CVSSpamView : public View {
|
|||||||
std::vector<std::filesystem::path> file_list{};
|
std::vector<std::filesystem::path> file_list{};
|
||||||
|
|
||||||
MenuView menu_view{
|
MenuView menu_view{
|
||||||
{0, 0, screen_width, 180},
|
{0, 0, screen_width, UI_POS_HEIGHT_REMAINING(12)},
|
||||||
true};
|
true};
|
||||||
|
|
||||||
Text text_empty{
|
Text text_empty{
|
||||||
{7 * 8, 12 * 8, 16 * 8, 16},
|
{UI_POS_X_CENTER(16), 12 * 8, UI_POS_WIDTH(16), UI_POS_HEIGHT(1)},
|
||||||
"Empty directory!"};
|
"Empty directory!"};
|
||||||
|
|
||||||
Button button_prev_page{
|
Button button_prev_page{
|
||||||
{0, 180, 50, 32},
|
{0, UI_POS_Y_BOTTOM(10), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
"<"};
|
"<"};
|
||||||
|
|
||||||
Button button_next_page{
|
Button button_next_page{
|
||||||
{190, 180, 50, 32},
|
{UI_POS_X_RIGHT(3), UI_POS_Y_BOTTOM(10), UI_POS_WIDTH(4), UI_POS_HEIGHT(2)},
|
||||||
">"};
|
">"};
|
||||||
|
|
||||||
Text page_info{
|
Text page_info{
|
||||||
{95, 188, 50, 16}};
|
{UI_POS_X_CENTER(7), UI_POS_Y_BOTTOM(9.5), UI_POS_WIDTH(7), UI_POS_HEIGHT(1)}};
|
||||||
|
|
||||||
Button button_send{
|
Button button_send{
|
||||||
{0, 212, 75, 36},
|
{0, UI_POS_Y_BOTTOM(8), UI_POS_WIDTH(9), UI_POS_HEIGHT(2)},
|
||||||
"CALL"};
|
"CALL"};
|
||||||
|
|
||||||
Button button_chaos{
|
Button button_chaos{
|
||||||
{82, 212, 75, 36},
|
{UI_POS_X_CENTER(9), UI_POS_Y_BOTTOM(8), UI_POS_WIDTH(9), UI_POS_HEIGHT(2)},
|
||||||
"CHAOS"};
|
"CHAOS"};
|
||||||
|
|
||||||
Button button_stop{
|
Button button_stop{
|
||||||
{165, 212, 75, 36},
|
{UI_POS_X_RIGHT(9), UI_POS_Y_BOTTOM(8), UI_POS_WIDTH(9), UI_POS_HEIGHT(2)},
|
||||||
LanguageHelper::currentMessages[LANG_STOP]};
|
LanguageHelper::currentMessages[LANG_STOP]};
|
||||||
|
|
||||||
ProgressBar progressbar{
|
ProgressBar progressbar{
|
||||||
{0, 256, screen_width, 44}};
|
{0, UI_POS_Y_BOTTOM(6), screen_width, UI_POS_HEIGHT(5)}};
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_fifo_signal{
|
MessageHandlerRegistration message_handler_fifo_signal{
|
||||||
Message::ID::RequestSignal,
|
Message::ID::RequestSignal,
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ class DebugDumpView : public View {
|
|||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
|
|
||||||
Text dump_output{
|
Text dump_output{
|
||||||
{0 * 8, 19 * 8, screen_width, 16},
|
{UI_POS_X(0), 19 * 8, screen_width, 16},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
Button button_exit{
|
Button button_exit{
|
||||||
{22 * 8, 34 * 8, 8 * 8, 32},
|
{UI_POS_X_CENTER(8), UI_POS_Y_BOTTOM(4), 8 * 8, 32},
|
||||||
"Exit"};
|
"Exit"};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ class DetectorRxView : public View {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{UI_POS_X(0), UI_POS_Y(0)}, "LNA: VGA: AMP: VOL: ", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), UI_POS_Y(0)}, "LNA: VGA: AMP: ", Theme::getInstance()->fg_light->foreground},
|
||||||
|
{{UI_POS_X_RIGHT(6), UI_POS_Y(0)}, "VOL: ", Theme::getInstance()->fg_light->foreground},
|
||||||
|
};
|
||||||
|
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{UI_POS_X(4), UI_POS_Y(0)}};
|
{UI_POS_X(4), UI_POS_Y(0)}};
|
||||||
@@ -89,7 +91,7 @@ class DetectorRxView : public View {
|
|||||||
{UI_POS_X(18), UI_POS_Y(0)}};
|
{UI_POS_X(18), UI_POS_Y(0)}};
|
||||||
|
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{UI_POS_X(24), UI_POS_Y(0)}};
|
{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
|
||||||
|
|
||||||
OptionsField field_mode{
|
OptionsField field_mode{
|
||||||
{UI_POS_X(0), UI_POS_Y(1)},
|
{UI_POS_X(0), UI_POS_Y(1)},
|
||||||
|
|||||||
+124
-78
@@ -43,7 +43,7 @@ const Color pp_colors[] = {
|
|||||||
|
|
||||||
// Drawing functions
|
// Drawing functions
|
||||||
void cls() {
|
void cls() {
|
||||||
painter.fill_rectangle({0, 0, portapack::display.width(), portapack::display.height()}, Color::black());
|
painter.fill_rectangle({0, 0, ui::screen_width, ui::screen_height}, Color::black());
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillrect(int x1, int y1, int x2, int y2, int color) {
|
void fillrect(int x1, int y1, int x2, int y2, int color) {
|
||||||
@@ -100,6 +100,15 @@ DinoGameView::DinoGameView(NavigationView& nav)
|
|||||||
: nav_{nav}, bird_info{}, game_timer{} {
|
: nav_{nav}, bird_info{}, game_timer{} {
|
||||||
add_children({&dummy, &button_difficulty});
|
add_children({&dummy, &button_difficulty});
|
||||||
current_instance = this;
|
current_instance = this;
|
||||||
|
|
||||||
|
// Initialize dimensions first
|
||||||
|
init_dimensions();
|
||||||
|
|
||||||
|
// Now reposition button with proper centering
|
||||||
|
int button_y = SCREEN_HEIGHT - 100;
|
||||||
|
int button_x = (SCREEN_WIDTH - 100) / 2;
|
||||||
|
button_difficulty.set_parent_rect({button_x, button_y, 100, 20});
|
||||||
|
|
||||||
game_timer.attach(&game_timer_check, 1.0 / 60.0);
|
game_timer.attach(&game_timer_check, 1.0 / 60.0);
|
||||||
|
|
||||||
button_difficulty.on_select = [this](Button&) {
|
button_difficulty.on_select = [this](Button&) {
|
||||||
@@ -126,6 +135,33 @@ void DinoGameView::frame_sync() {
|
|||||||
set_dirty();
|
set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DinoGameView::init_dimensions() {
|
||||||
|
SCREEN_WIDTH = ui::screen_width;
|
||||||
|
SCREEN_HEIGHT = ui::screen_height;
|
||||||
|
|
||||||
|
// Scale game area based on screen size
|
||||||
|
GAME_AREA_HEIGHT = (SCREEN_HEIGHT * 160) / 320; // Scale proportionally
|
||||||
|
GAME_AREA_TOP = SCREEN_HEIGHT / 4;
|
||||||
|
|
||||||
|
// Calculate positions
|
||||||
|
DINO_Y = GAME_AREA_TOP + GAME_AREA_HEIGHT - GROUND_HEIGHT - DINO_HEIGHT;
|
||||||
|
DINO_DUCK_Y = GAME_AREA_TOP + GAME_AREA_HEIGHT - GROUND_HEIGHT - DINO_DUCK_HEIGHT;
|
||||||
|
BIRD_Y_UP = GAME_AREA_TOP + 20;
|
||||||
|
BIRD_Y_DOWN = GAME_AREA_TOP + (GAME_AREA_HEIGHT * 60) / 160;
|
||||||
|
|
||||||
|
// Scale jump height
|
||||||
|
JUMP_MAX_HEIGHT = (GAME_AREA_HEIGHT * 70) / 160;
|
||||||
|
|
||||||
|
// Scale distances based on screen width
|
||||||
|
MIN_OBSTACLE_DISTANCE = (SCREEN_WIDTH * 300) / 240;
|
||||||
|
MAX_OBSTACLE_DISTANCE = (SCREEN_WIDTH * 600) / 240;
|
||||||
|
|
||||||
|
// Scale horizontal position
|
||||||
|
DINO_X = SCREEN_WIDTH / 8;
|
||||||
|
|
||||||
|
last_dino_y = DINO_Y;
|
||||||
|
}
|
||||||
|
|
||||||
void DinoGameView::init_game() {
|
void DinoGameView::init_game() {
|
||||||
game_state = GameState::MENU;
|
game_state = GameState::MENU;
|
||||||
menu_initialized = false;
|
menu_initialized = false;
|
||||||
@@ -142,7 +178,7 @@ void DinoGameView::new_game() {
|
|||||||
duck_timer = 0;
|
duck_timer = 0;
|
||||||
displayedGameOver = false;
|
displayedGameOver = false;
|
||||||
bird_info.inGame = false;
|
bird_info.inGame = false;
|
||||||
bird_info.x_offset = 320;
|
bird_info.x_offset = SCREEN_WIDTH;
|
||||||
bird_info.y_offset = 0;
|
bird_info.y_offset = 0;
|
||||||
bird_info.y_velocity = 0;
|
bird_info.y_velocity = 0;
|
||||||
jumping = false;
|
jumping = false;
|
||||||
@@ -178,12 +214,12 @@ void DinoGameView::show_menu() {
|
|||||||
auto style_title = *ui::Theme::getInstance()->fg_light;
|
auto style_title = *ui::Theme::getInstance()->fg_light;
|
||||||
|
|
||||||
// Draw title
|
// Draw title
|
||||||
painter.draw_string({80, 60}, style_title, "DINO GAME");
|
painter.draw_string({UI_POS_X_CENTER(10), 60}, style_title, "DINO GAME");
|
||||||
|
|
||||||
// Draw instructions
|
// Draw instructions
|
||||||
painter.draw_string({45, 130}, style, "SELECT: Jump/Start");
|
painter.draw_string({UI_POS_X_CENTER(19), 120}, style, "SELECT: Jump/Start");
|
||||||
painter.draw_string({65, 150}, style, "DOWN: Duck");
|
painter.draw_string({UI_POS_X_CENTER(11), 140}, style, "DOWN: Duck");
|
||||||
painter.draw_string({50, 170}, style, "Avoid obstacles!");
|
painter.draw_string({UI_POS_X_CENTER(17), 160}, style, "Avoid obstacles!");
|
||||||
|
|
||||||
// Draw high score
|
// Draw high score
|
||||||
draw_high_score();
|
draw_high_score();
|
||||||
@@ -194,14 +230,21 @@ void DinoGameView::show_menu() {
|
|||||||
// Show difficulty button
|
// Show difficulty button
|
||||||
button_difficulty.hidden(false);
|
button_difficulty.hidden(false);
|
||||||
|
|
||||||
// Animate the menu dino
|
// Animate the menu dino - use frame counter for smooth animation
|
||||||
bool menu_run_frame = (blink_counter / 15) % 2;
|
bool menu_run_frame = (blink_counter / 10) % 2;
|
||||||
|
|
||||||
// Clear previous dino position
|
int menu_dino_x = UI_POS_X_CENTER(DINO_WIDTH);
|
||||||
fillrect(103, 90, 103 + DINO_WIDTH, 90 + DINO_HEIGHT, Black);
|
int menu_dino_y = 90;
|
||||||
|
|
||||||
|
// Clear previous dino position - clear a bit extra to handle any artifacts
|
||||||
|
static bool last_menu_frame = false;
|
||||||
|
if (last_menu_frame != menu_run_frame || blink_counter == 0) {
|
||||||
|
fillrect(menu_dino_x - 5, menu_dino_y - 5, menu_dino_x + DINO_WIDTH + 5, menu_dino_y + DINO_HEIGHT + 5, Black);
|
||||||
|
last_menu_frame = menu_run_frame;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw animated dino
|
// Draw animated dino
|
||||||
draw_dino_at(103, 90, false, menu_run_frame);
|
draw_dino_at(menu_dino_x, menu_dino_y, false, menu_run_frame);
|
||||||
|
|
||||||
// Blinking start prompt
|
// Blinking start prompt
|
||||||
auto style_prompt = *ui::Theme::getInstance()->fg_light;
|
auto style_prompt = *ui::Theme::getInstance()->fg_light;
|
||||||
@@ -209,9 +252,10 @@ void DinoGameView::show_menu() {
|
|||||||
blink_counter = 0;
|
blink_counter = 0;
|
||||||
blink_state = !blink_state;
|
blink_state = !blink_state;
|
||||||
|
|
||||||
painter.fill_rectangle({55, 258, 130, 20}, Color::black());
|
int prompt_y = SCREEN_HEIGHT - 60;
|
||||||
|
painter.fill_rectangle({UI_POS_X_CENTER(17), prompt_y - 2, 130, 20}, Color::black());
|
||||||
if (blink_state) {
|
if (blink_state) {
|
||||||
painter.draw_string({55, 260}, style_prompt, "* PRESS SELECT *");
|
painter.draw_string({UI_POS_X_CENTER(17), prompt_y}, style_prompt, "* PRESS SELECT *");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,33 +264,30 @@ void DinoGameView::show_game_over() {
|
|||||||
if (!displayedGameOver) {
|
if (!displayedGameOver) {
|
||||||
displayedGameOver = true;
|
displayedGameOver = true;
|
||||||
|
|
||||||
// Clear the last normal dino position
|
// Clear the entire play area to ensure clean display
|
||||||
if (last_ducking) {
|
fillrect(0, GAME_AREA_TOP, SCREEN_WIDTH, GAME_AREA_HEIGHT + 20, Black);
|
||||||
fillrect(DINO_X, last_dino_y, DINO_X + DINO_DUCK_WIDTH, last_dino_y + DINO_DUCK_HEIGHT, Black);
|
|
||||||
} else {
|
|
||||||
fillrect(DINO_X, last_dino_y, DINO_X + DINO_WIDTH, last_dino_y + DINO_HEIGHT, Black);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the game over dino sprite
|
// Draw the game over dino sprite in the center
|
||||||
draw_dino_sprite(DINO_X, DINO_Y, dino_gameover);
|
int gameover_dino_x = UI_POS_X_CENTER(DINO_WIDTH);
|
||||||
|
int gameover_dino_y = GAME_AREA_TOP + 40;
|
||||||
|
draw_dino_sprite(gameover_dino_x, gameover_dino_y, dino_gameover);
|
||||||
|
|
||||||
auto style = *ui::Theme::getInstance()->fg_light;
|
auto style = *ui::Theme::getInstance()->fg_light;
|
||||||
auto style_score = *ui::Theme::getInstance()->fg_medium;
|
auto style_score = *ui::Theme::getInstance()->fg_medium;
|
||||||
|
|
||||||
// Game over text
|
// Game over text
|
||||||
painter.draw_string({85, 70}, style, "GAME OVER");
|
painter.draw_string({UI_POS_X_CENTER(10), GAME_AREA_TOP + 90}, style, "GAME OVER");
|
||||||
|
|
||||||
// Show final score
|
// Show final score
|
||||||
std::string score_text = "SCORE: " + score_to_string(score);
|
std::string score_text = "SCORE: " + score_to_string(score);
|
||||||
int score_x = (240 - score_text.length() * 8) / 2;
|
painter.draw_string({UI_POS_X_CENTER(score_text.length()), GAME_AREA_TOP + 110}, style_score, score_text);
|
||||||
painter.draw_string({score_x, 90}, style_score, score_text);
|
|
||||||
|
|
||||||
painter.draw_string({65, 110}, style, "SELECT TO RETRY");
|
painter.draw_string({UI_POS_X_CENTER(16), GAME_AREA_TOP + 130}, style, "SELECT TO RETRY");
|
||||||
|
|
||||||
// Update high score
|
// Update high score
|
||||||
if (score > highScore) {
|
if (score > highScore) {
|
||||||
highScore = score;
|
highScore = score;
|
||||||
painter.draw_string({55, 130}, style, "NEW HIGH SCORE!");
|
painter.draw_string({UI_POS_X_CENTER(16), GAME_AREA_TOP + 150}, style, "NEW HIGH SCORE!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -263,7 +304,7 @@ void DinoGameView::game_loop() {
|
|||||||
// Update ground animation
|
// Update ground animation
|
||||||
ground_offset = (ground_offset + GAME_SPEED_BASE + speed_modifier) % 20;
|
ground_offset = (ground_offset + GAME_SPEED_BASE + speed_modifier) % 20;
|
||||||
|
|
||||||
// Clear only the game area (not the whole screen to reduce flicker)
|
// Draw ground
|
||||||
draw_ground();
|
draw_ground();
|
||||||
|
|
||||||
// Update and draw obstacles
|
// Update and draw obstacles
|
||||||
@@ -295,38 +336,38 @@ void DinoGameView::game_loop() {
|
|||||||
// Update run animation
|
// Update run animation
|
||||||
if (get_steps() % (10 - speed_modifier) == 0) runstate = !runstate;
|
if (get_steps() % (10 - speed_modifier) == 0) runstate = !runstate;
|
||||||
|
|
||||||
// Draw dino with minimal redraw
|
// Draw dino with proper clearing
|
||||||
int current_dino_y = jumping ? (DINO_Y - jumpHeight) : (ducking ? DINO_DUCK_Y : DINO_Y);
|
int current_dino_y = jumping ? (DINO_Y - jumpHeight) : (ducking ? DINO_DUCK_Y : DINO_Y);
|
||||||
|
|
||||||
// Clear old dino position more precisely
|
// Only clear and redraw if something changed
|
||||||
if (current_dino_y != last_dino_y || runstate != last_runstate || ducking != last_ducking) {
|
if (current_dino_y != last_dino_y || runstate != last_runstate || ducking != last_ducking) {
|
||||||
// Clear based on last state
|
// Clear old position with extra margin to prevent artifacts
|
||||||
if (last_ducking) {
|
if (last_ducking) {
|
||||||
fillrect(DINO_X, last_dino_y, DINO_X + DINO_DUCK_WIDTH, last_dino_y + DINO_DUCK_HEIGHT, Black);
|
fillrect(DINO_X - 2, last_dino_y - 2, DINO_X + DINO_DUCK_WIDTH + 2, last_dino_y + DINO_DUCK_HEIGHT + 2, Black);
|
||||||
} else {
|
} else {
|
||||||
fillrect(DINO_X, last_dino_y, DINO_X + DINO_WIDTH, last_dino_y + DINO_HEIGHT, Black);
|
fillrect(DINO_X - 2, last_dino_y - 2, DINO_X + DINO_WIDTH + 2, last_dino_y + DINO_HEIGHT + 2, Black);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Draw dino at new position
|
// Draw dino at new position
|
||||||
if (jumping) {
|
if (jumping) {
|
||||||
draw_dino_sprite(DINO_X, current_dino_y, dino_default);
|
draw_dino_sprite(DINO_X, current_dino_y, dino_default);
|
||||||
} else if (ducking) {
|
} else if (ducking) {
|
||||||
if (runstate)
|
if (runstate)
|
||||||
draw_dino_sprite(DINO_X, current_dino_y, dino_ducking_leftstep);
|
draw_dino_sprite(DINO_X, current_dino_y, dino_ducking_leftstep);
|
||||||
else
|
else
|
||||||
draw_dino_sprite(DINO_X, current_dino_y, dino_ducking_rightstep);
|
draw_dino_sprite(DINO_X, current_dino_y, dino_ducking_rightstep);
|
||||||
} else {
|
} else {
|
||||||
if (runstate)
|
if (runstate)
|
||||||
draw_dino_sprite(DINO_X, current_dino_y, dino_leftstep);
|
draw_dino_sprite(DINO_X, current_dino_y, dino_leftstep);
|
||||||
else
|
else
|
||||||
draw_dino_sprite(DINO_X, current_dino_y, dino_rightstep);
|
draw_dino_sprite(DINO_X, current_dino_y, dino_rightstep);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update last state
|
// Update last state
|
||||||
last_dino_y = current_dino_y;
|
last_dino_y = current_dino_y;
|
||||||
last_ducking = ducking;
|
last_ducking = ducking;
|
||||||
last_runstate = runstate;
|
last_runstate = runstate;
|
||||||
|
}
|
||||||
|
|
||||||
// Check collisions
|
// Check collisions
|
||||||
check_collision();
|
check_collision();
|
||||||
@@ -346,14 +387,14 @@ void DinoGameView::draw_ground() {
|
|||||||
int ground_y = GAME_AREA_TOP + GAME_AREA_HEIGHT - GROUND_HEIGHT;
|
int ground_y = GAME_AREA_TOP + GAME_AREA_HEIGHT - GROUND_HEIGHT;
|
||||||
|
|
||||||
// Clear ground area
|
// Clear ground area
|
||||||
fillrect(0, ground_y, 320, ground_y + GROUND_HEIGHT, Black);
|
fillrect(0, ground_y, SCREEN_WIDTH, ground_y + GROUND_HEIGHT, Black);
|
||||||
|
|
||||||
// Draw ground line
|
// Draw ground line
|
||||||
painter.draw_hline({0, ground_y}, 320, Color::white());
|
painter.draw_hline({0, ground_y}, SCREEN_WIDTH, Color::white());
|
||||||
painter.draw_hline({0, ground_y + 1}, 320, Color::dark_grey());
|
painter.draw_hline({0, ground_y + 1}, SCREEN_WIDTH, Color::dark_grey());
|
||||||
|
|
||||||
// Draw ground texture
|
// Draw ground texture
|
||||||
for (int x = -ground_offset; x < 320; x += 20) {
|
for (int x = -ground_offset; x < SCREEN_WIDTH; x += 20) {
|
||||||
painter.draw_hline({x, ground_y + 3}, 10, Color::dark_grey());
|
painter.draw_hline({x, ground_y + 3}, 10, Color::dark_grey());
|
||||||
painter.draw_hline({x + 5, ground_y + 5}, 5, Color::dark_grey());
|
painter.draw_hline({x + 5, ground_y + 5}, 5, Color::dark_grey());
|
||||||
}
|
}
|
||||||
@@ -364,7 +405,7 @@ void DinoGameView::update_obstacles() {
|
|||||||
for (int i = 0; i < MAX_OBSTACLES; i++) {
|
for (int i = 0; i < MAX_OBSTACLES; i++) {
|
||||||
if (obstacles[i].active) {
|
if (obstacles[i].active) {
|
||||||
// Clear old position
|
// Clear old position
|
||||||
if (obstacles[i].last_x != obstacles[i].x && obstacles[i].last_x < 320) {
|
if (obstacles[i].last_x != obstacles[i].x && obstacles[i].last_x < SCREEN_WIDTH) {
|
||||||
clear_obstacle_area(obstacles[i].last_x, obstacles[i].width + 10, obstacles[i].height + 10);
|
clear_obstacle_area(obstacles[i].last_x, obstacles[i].width + 10, obstacles[i].height + 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,8 +435,8 @@ void DinoGameView::update_obstacles() {
|
|||||||
for (int i = 0; i < MAX_OBSTACLES; i++) {
|
for (int i = 0; i < MAX_OBSTACLES; i++) {
|
||||||
if (!obstacles[i].active) {
|
if (!obstacles[i].active) {
|
||||||
obstacles[i].active = true;
|
obstacles[i].active = true;
|
||||||
obstacles[i].x = 320;
|
obstacles[i].x = SCREEN_WIDTH;
|
||||||
obstacles[i].last_x = 320;
|
obstacles[i].last_x = SCREEN_WIDTH;
|
||||||
obstacles[i].type = rand() % 4;
|
obstacles[i].type = rand() % 4;
|
||||||
|
|
||||||
// Set obstacle dimensions based on type
|
// Set obstacle dimensions based on type
|
||||||
@@ -495,7 +536,7 @@ void DinoGameView::manage_bird() {
|
|||||||
// Only spawn bird if no obstacles are too close
|
// Only spawn bird if no obstacles are too close
|
||||||
bool obstacle_nearby = false;
|
bool obstacle_nearby = false;
|
||||||
for (int i = 0; i < MAX_OBSTACLES; i++) {
|
for (int i = 0; i < MAX_OBSTACLES; i++) {
|
||||||
if (obstacles[i].active && obstacles[i].x > 200) {
|
if (obstacles[i].active && obstacles[i].x > SCREEN_WIDTH * 0.8) {
|
||||||
obstacle_nearby = true;
|
obstacle_nearby = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -504,7 +545,7 @@ void DinoGameView::manage_bird() {
|
|||||||
// Randomly spawn bird if no nearby obstacles
|
// Randomly spawn bird if no nearby obstacles
|
||||||
if (!obstacle_nearby && rand() % 400 == 0 && get_steps() > 100) {
|
if (!obstacle_nearby && rand() % 400 == 0 && get_steps() > 100) {
|
||||||
bird_info.inGame = true;
|
bird_info.inGame = true;
|
||||||
bird_info.x_offset = 320;
|
bird_info.x_offset = SCREEN_WIDTH;
|
||||||
bird_info.y_offset = 0;
|
bird_info.y_offset = 0;
|
||||||
bird_info.y_velocity = easy_mode ? 0 : (rand() % 3) - 1; // No vertical movement in easy mode
|
bird_info.y_velocity = easy_mode ? 0 : (rand() % 3) - 1; // No vertical movement in easy mode
|
||||||
bird_info.y_position = BirdPosition::DOWN; // Always spawn at standing height in easy mode
|
bird_info.y_position = BirdPosition::DOWN; // Always spawn at standing height in easy mode
|
||||||
@@ -514,16 +555,16 @@ void DinoGameView::manage_bird() {
|
|||||||
int base_y = (bird_info.y_position == BirdPosition::UP) ? BIRD_Y_UP : BIRD_Y_DOWN;
|
int base_y = (bird_info.y_position == BirdPosition::UP) ? BIRD_Y_UP : BIRD_Y_DOWN;
|
||||||
int current_y = base_y + bird_info.y_offset;
|
int current_y = base_y + bird_info.y_offset;
|
||||||
|
|
||||||
// Clear previous bird position
|
// Clear previous bird position with extra margin
|
||||||
if (last_bird_x < 320 && last_bird_x >= -BIRD_WIDTH) {
|
if (last_bird_x < SCREEN_WIDTH && last_bird_x >= -BIRD_WIDTH) {
|
||||||
int clear_start_x = last_bird_x;
|
int clear_start_x = last_bird_x - 2;
|
||||||
int clear_end_x = last_bird_x + BIRD_WIDTH;
|
int clear_end_x = last_bird_x + BIRD_WIDTH + 2;
|
||||||
|
|
||||||
if (clear_start_x < 0) clear_start_x = 0;
|
if (clear_start_x < 0) clear_start_x = 0;
|
||||||
if (clear_end_x > 320) clear_end_x = 320;
|
if (clear_end_x > SCREEN_WIDTH) clear_end_x = SCREEN_WIDTH;
|
||||||
|
|
||||||
if (clear_end_x > clear_start_x) {
|
if (clear_end_x > clear_start_x) {
|
||||||
fillrect(clear_start_x, last_bird_y, clear_end_x, last_bird_y + BIRD_HEIGHT, Black);
|
fillrect(clear_start_x, last_bird_y - 2, clear_end_x, last_bird_y + BIRD_HEIGHT + 2, Black);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,7 +590,6 @@ void DinoGameView::manage_bird() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// In easy mode, keep bird at perfect ducking height
|
// In easy mode, keep bird at perfect ducking height
|
||||||
// Bird should hit standing dino but miss ducking dino
|
|
||||||
current_y = DINO_Y - 10; // Position bird just above ducking height
|
current_y = DINO_Y - 10; // Position bird just above ducking height
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,7 +597,7 @@ void DinoGameView::manage_bird() {
|
|||||||
if (get_steps() % 15 == 0) bird_info.flop = !bird_info.flop;
|
if (get_steps() % 15 == 0) bird_info.flop = !bird_info.flop;
|
||||||
|
|
||||||
// Draw bird only if any part is visible
|
// Draw bird only if any part is visible
|
||||||
if (bird_info.x_offset > -BIRD_WIDTH && bird_info.x_offset < 320) {
|
if (bird_info.x_offset > -BIRD_WIDTH && bird_info.x_offset < SCREEN_WIDTH) {
|
||||||
if (bird_info.flop) {
|
if (bird_info.flop) {
|
||||||
draw_bird_sprite(bird_info.x_offset, current_y, pterodactyl_upflop);
|
draw_bird_sprite(bird_info.x_offset, current_y, pterodactyl_upflop);
|
||||||
} else {
|
} else {
|
||||||
@@ -590,6 +630,7 @@ void DinoGameView::draw_dino_sprite(int x, int y, const uint16_t* sprite) {
|
|||||||
width = DINO_WIDTH;
|
width = DINO_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw sprite efficiently with run-length optimization
|
||||||
for (int dy = 0; dy < height; dy++) {
|
for (int dy = 0; dy < height; dy++) {
|
||||||
int run_start = -1;
|
int run_start = -1;
|
||||||
uint16_t run_color = 0;
|
uint16_t run_color = 0;
|
||||||
@@ -623,16 +664,21 @@ void DinoGameView::draw_dino_sprite(int x, int y, const uint16_t* sprite) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DinoGameView::draw_bird_sprite(int x, int y, const uint16_t* sprite) {
|
void DinoGameView::draw_bird_sprite(int x, int y, const uint16_t* sprite) {
|
||||||
|
// Draw sprite efficiently with clipping
|
||||||
for (int dy = 0; dy < BIRD_HEIGHT; dy++) {
|
for (int dy = 0; dy < BIRD_HEIGHT; dy++) {
|
||||||
int run_start = -1;
|
int run_start = -1;
|
||||||
uint16_t run_color = 0;
|
uint16_t run_color = 0;
|
||||||
|
|
||||||
for (int dx = 0; dx < BIRD_WIDTH; dx++) {
|
for (int dx = 0; dx < BIRD_WIDTH; dx++) {
|
||||||
// Skip pixels that would be off-screen
|
// Skip pixels that would be off-screen
|
||||||
if (x + dx < 0 || x + dx >= 320) {
|
if (x + dx < 0 || x + dx >= SCREEN_WIDTH) {
|
||||||
// End any current run
|
// End any current run
|
||||||
if (run_start != -1) {
|
if (run_start != -1 && x + run_start < SCREEN_WIDTH) {
|
||||||
painter.fill_rectangle({x + run_start, y + dy, dx - run_start, 1}, Color(run_color));
|
int run_width = dx - run_start;
|
||||||
|
if (x + run_start + run_width > SCREEN_WIDTH) {
|
||||||
|
run_width = SCREEN_WIDTH - (x + run_start);
|
||||||
|
}
|
||||||
|
painter.fill_rectangle({x + run_start, y + dy, run_width, 1}, Color(run_color));
|
||||||
run_start = -1;
|
run_start = -1;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@@ -660,10 +706,10 @@ void DinoGameView::draw_bird_sprite(int x, int y, const uint16_t* sprite) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (run_start != -1 && x + run_start < 320) {
|
if (run_start != -1 && x + run_start < SCREEN_WIDTH) {
|
||||||
int width = BIRD_WIDTH - run_start;
|
int width = BIRD_WIDTH - run_start;
|
||||||
if (x + run_start + width > 320) {
|
if (x + run_start + width > SCREEN_WIDTH) {
|
||||||
width = 320 - (x + run_start);
|
width = SCREEN_WIDTH - (x + run_start);
|
||||||
}
|
}
|
||||||
if (width > 0) {
|
if (width > 0) {
|
||||||
painter.fill_rectangle({x + run_start, y + dy, width, 1}, Color(run_color));
|
painter.fill_rectangle({x + run_start, y + dy, width, 1}, Color(run_color));
|
||||||
@@ -683,7 +729,7 @@ void DinoGameView::draw_dino_at(int x, int y, bool is_ducking, bool run_frame) {
|
|||||||
if (run_frame) {
|
if (run_frame) {
|
||||||
draw_dino_sprite(x, y, dino_leftstep);
|
draw_dino_sprite(x, y, dino_leftstep);
|
||||||
} else {
|
} else {
|
||||||
draw_dino_sprite(x, y, dino_default);
|
draw_dino_sprite(x, y, dino_rightstep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -743,8 +789,8 @@ void DinoGameView::draw_current_score() {
|
|||||||
|
|
||||||
void DinoGameView::draw_high_score() {
|
void DinoGameView::draw_high_score() {
|
||||||
auto style = *ui::Theme::getInstance()->fg_light;
|
auto style = *ui::Theme::getInstance()->fg_light;
|
||||||
painter.fill_rectangle({152, 28, 100, 14}, Color::black());
|
painter.fill_rectangle({UI_POS_X_RIGHT(90), 28, 90, 18}, Color::black());
|
||||||
painter.draw_string({152, 30}, style, "HI " + score_to_string(highScore));
|
painter.draw_string({UI_POS_X_RIGHT(90), 30}, style, "HI " + score_to_string(highScore));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DinoGameView::jump() {
|
void DinoGameView::jump() {
|
||||||
@@ -805,4 +851,4 @@ bool DinoGameView::on_encoder(const EncoderEvent delta) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ui::external_app::dinogame
|
} // namespace ui::external_app::dinogame
|
||||||
+31
-26
@@ -41,29 +41,6 @@ enum {
|
|||||||
Black,
|
Black,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Game constants
|
|
||||||
#define DINO_WIDTH 34
|
|
||||||
#define DINO_HEIGHT 36
|
|
||||||
#define DINO_DUCK_WIDTH 45
|
|
||||||
#define DINO_DUCK_HEIGHT 22
|
|
||||||
#define BIRD_WIDTH 34
|
|
||||||
#define BIRD_HEIGHT 27
|
|
||||||
#define GROUND_HEIGHT 10
|
|
||||||
#define GAME_AREA_TOP 78
|
|
||||||
#define GAME_AREA_HEIGHT 160
|
|
||||||
#define DINO_X 30
|
|
||||||
#define DINO_Y (GAME_AREA_TOP + GAME_AREA_HEIGHT - GROUND_HEIGHT - DINO_HEIGHT)
|
|
||||||
#define DINO_DUCK_Y (GAME_AREA_TOP + GAME_AREA_HEIGHT - GROUND_HEIGHT - DINO_DUCK_HEIGHT)
|
|
||||||
#define BIRD_Y_UP (GAME_AREA_TOP + 20)
|
|
||||||
#define BIRD_Y_DOWN (GAME_AREA_TOP + 60)
|
|
||||||
#define JUMP_MAX_HEIGHT 70
|
|
||||||
#define JUMP_SPEED 3
|
|
||||||
#define GAME_SPEED_BASE 3
|
|
||||||
#define SPRITE_COLOR 0x528A
|
|
||||||
#define TRANSPARENT_COLOR 0xFFFF
|
|
||||||
#define MIN_OBSTACLE_DISTANCE 300
|
|
||||||
#define MAX_OBSTACLE_DISTANCE 600
|
|
||||||
|
|
||||||
// Game states
|
// Game states
|
||||||
enum class GameState {
|
enum class GameState {
|
||||||
MENU,
|
MENU,
|
||||||
@@ -159,6 +136,33 @@ class DinoGameView : public View {
|
|||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
|
|
||||||
|
// Dynamic screen dimensions
|
||||||
|
int SCREEN_WIDTH = 240;
|
||||||
|
int SCREEN_HEIGHT = 320;
|
||||||
|
int DINO_WIDTH = 34;
|
||||||
|
int DINO_HEIGHT = 36;
|
||||||
|
int DINO_DUCK_WIDTH = 45;
|
||||||
|
int DINO_DUCK_HEIGHT = 22;
|
||||||
|
int BIRD_WIDTH = 34;
|
||||||
|
int BIRD_HEIGHT = 27;
|
||||||
|
int GROUND_HEIGHT = 10;
|
||||||
|
int GAME_AREA_TOP = 78;
|
||||||
|
int GAME_AREA_HEIGHT = 160;
|
||||||
|
int DINO_X = 30;
|
||||||
|
int DINO_Y = 0; // Will be calculated
|
||||||
|
int DINO_DUCK_Y = 0; // Will be calculated
|
||||||
|
int BIRD_Y_UP = 0; // Will be calculated
|
||||||
|
int BIRD_Y_DOWN = 0; // Will be calculated
|
||||||
|
int JUMP_MAX_HEIGHT = 70;
|
||||||
|
int JUMP_SPEED = 3;
|
||||||
|
int GAME_SPEED_BASE = 3;
|
||||||
|
int MIN_OBSTACLE_DISTANCE = 300;
|
||||||
|
int MAX_OBSTACLE_DISTANCE = 600;
|
||||||
|
|
||||||
|
// Sprite constants
|
||||||
|
static constexpr uint16_t SPRITE_COLOR = 0x528A;
|
||||||
|
static constexpr uint16_t TRANSPARENT_COLOR = 0xFFFF;
|
||||||
|
|
||||||
// Game variables
|
// Game variables
|
||||||
static constexpr uint8_t MAX_OBSTACLES = 1;
|
static constexpr uint8_t MAX_OBSTACLES = 1;
|
||||||
SimpleObstacle obstacles[MAX_OBSTACLES];
|
SimpleObstacle obstacles[MAX_OBSTACLES];
|
||||||
@@ -185,7 +189,7 @@ class DinoGameView : public View {
|
|||||||
int32_t obstacle_spawn_timer = 0;
|
int32_t obstacle_spawn_timer = 0;
|
||||||
|
|
||||||
// Position tracking for minimal redraw
|
// Position tracking for minimal redraw
|
||||||
int16_t last_dino_y = DINO_Y;
|
int16_t last_dino_y = 0;
|
||||||
int16_t last_bird_x = -1;
|
int16_t last_bird_x = -1;
|
||||||
int16_t last_bird_y = -1;
|
int16_t last_bird_y = -1;
|
||||||
uint8_t duck_timer = 0;
|
uint8_t duck_timer = 0;
|
||||||
@@ -202,6 +206,7 @@ class DinoGameView : public View {
|
|||||||
Ticker game_timer;
|
Ticker game_timer;
|
||||||
|
|
||||||
// Private methods
|
// Private methods
|
||||||
|
void init_dimensions();
|
||||||
void init_game();
|
void init_game();
|
||||||
void new_game();
|
void new_game();
|
||||||
void update_obstacles();
|
void update_obstacles();
|
||||||
@@ -239,7 +244,7 @@ class DinoGameView : public View {
|
|||||||
{"easy_mode"sv, &easy_mode}}};
|
{"easy_mode"sv, &easy_mode}}};
|
||||||
|
|
||||||
Button dummy{
|
Button dummy{
|
||||||
{screen_width, 0, 0, 0},
|
{240, 0, 0, 0},
|
||||||
""};
|
""};
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_frame_sync{
|
MessageHandlerRegistration message_handler_frame_sync{
|
||||||
@@ -251,4 +256,4 @@ class DinoGameView : public View {
|
|||||||
|
|
||||||
} // namespace ui::external_app::dinogame
|
} // namespace ui::external_app::dinogame
|
||||||
|
|
||||||
#endif /* __UI_DINOGAME_H__ */
|
#endif /* __UI_DINOGAME_H__ */
|
||||||
+63
-24
@@ -17,6 +17,7 @@ int SCREEN_HEIGHT = 0;
|
|||||||
int RENDER_HEIGHT = 0;
|
int RENDER_HEIGHT = 0;
|
||||||
int HALF_WIDTH = 0;
|
int HALF_WIDTH = 0;
|
||||||
int HALF_HEIGHT = 0;
|
int HALF_HEIGHT = 0;
|
||||||
|
int HUD_HEIGHT = 40;
|
||||||
#define LEVEL_WIDTH_BASE 6
|
#define LEVEL_WIDTH_BASE 6
|
||||||
#define LEVEL_WIDTH (1 << LEVEL_WIDTH_BASE)
|
#define LEVEL_WIDTH (1 << LEVEL_WIDTH_BASE)
|
||||||
#define LEVEL_HEIGHT 57
|
#define LEVEL_HEIGHT 57
|
||||||
@@ -24,18 +25,18 @@ int HALF_HEIGHT = 0;
|
|||||||
#define MAX_RENDER_DEPTH 12
|
#define MAX_RENDER_DEPTH 12
|
||||||
#define MIN_ENTITIES 15
|
#define MIN_ENTITIES 15
|
||||||
#define MAX_ENTITIES 25
|
#define MAX_ENTITIES 25
|
||||||
#define RES_DIVIDER 2
|
int RES_DIVIDER = 2;
|
||||||
#define DISTANCE_MULTIPLIER 20
|
#define DISTANCE_MULTIPLIER 20
|
||||||
#define ROT_SPEED 0.25
|
#define ROT_SPEED 0.25
|
||||||
#define MOV_SPEED 1.0
|
#define MOV_SPEED 1.0
|
||||||
#define JOGGING_SPEED 1.2
|
#define JOGGING_SPEED 1.2
|
||||||
#define MAX_ENTITY_DISTANCE 200
|
#define MAX_ENTITY_DISTANCE 200
|
||||||
#define ITEM_COLLIDER_DIST 6
|
#define ITEM_COLLIDER_DIST 6
|
||||||
#define PI 3.14159265358979323846
|
#include "mathdef.hpp"
|
||||||
#define GUN_WIDTH 30
|
int GUN_WIDTH = 30;
|
||||||
#define GUN_HEIGHT 40
|
int GUN_HEIGHT = 40;
|
||||||
#define GUN_TARGET_POS 24
|
int GUN_TARGET_POS = 24;
|
||||||
#define GUN_SHOT_POS (GUN_TARGET_POS + 6)
|
int GUN_SHOT_POS = 30;
|
||||||
#define ENEMY_SIZE 16
|
#define ENEMY_SIZE 16
|
||||||
#define ENEMY_SPEED 0.03
|
#define ENEMY_SPEED 0.03
|
||||||
#define ENEMY_MELEE_DIST 20
|
#define ENEMY_MELEE_DIST 20
|
||||||
@@ -145,7 +146,7 @@ static bool up, down, left, right, fired;
|
|||||||
static double jogging, view_height;
|
static double jogging, view_height;
|
||||||
static bool needs_redraw = false;
|
static bool needs_redraw = false;
|
||||||
static bool needs_gun_redraw = false;
|
static bool needs_gun_redraw = false;
|
||||||
static uint8_t gun_pos = GUN_TARGET_POS;
|
static uint8_t gun_pos = 24;
|
||||||
static bool gun_fired = false;
|
static bool gun_fired = false;
|
||||||
static int prev_gun_x = 0;
|
static int prev_gun_x = 0;
|
||||||
static int prev_gun_y = 0;
|
static int prev_gun_y = 0;
|
||||||
@@ -850,13 +851,23 @@ void render_entities(Painter& painter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_map(Painter& painter, bool full_clear, int16_t x_start = 0, int16_t x_end = SCREEN_WIDTH) {
|
void render_map(Painter& painter, bool full_clear, int16_t x_start = 0, int16_t x_end = -1) {
|
||||||
|
if (x_end == -1) x_end = SCREEN_WIDTH;
|
||||||
|
|
||||||
|
// Add safety bounds
|
||||||
|
x_start = fmax(0, x_start);
|
||||||
|
x_end = fmin(SCREEN_WIDTH, x_end);
|
||||||
|
|
||||||
|
// Dynamically adjust RES_DIVIDER based on screen size
|
||||||
|
int dynamic_res = (SCREEN_WIDTH > 400) ? 4 : (SCREEN_WIDTH > 300) ? 3
|
||||||
|
: RES_DIVIDER;
|
||||||
|
|
||||||
if (full_clear) {
|
if (full_clear) {
|
||||||
painter.fill_rectangle({0, 0, SCREEN_WIDTH, RENDER_HEIGHT / 2}, Color(64, 64, 128));
|
painter.fill_rectangle({0, 0, SCREEN_WIDTH, RENDER_HEIGHT / 2}, Color(64, 64, 128));
|
||||||
painter.fill_rectangle({0, RENDER_HEIGHT / 2, SCREEN_WIDTH, RENDER_HEIGHT / 2}, Color(32, 32, 32));
|
painter.fill_rectangle({0, RENDER_HEIGHT / 2, SCREEN_WIDTH, RENDER_HEIGHT / 2}, Color(32, 32, 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t x = x_start; x < x_end; x += RES_DIVIDER) {
|
for (uint16_t x = x_start; x < x_end; x += dynamic_res) {
|
||||||
double camera_x = 2 * (double)x / SCREEN_WIDTH - 1;
|
double camera_x = 2 * (double)x / SCREEN_WIDTH - 1;
|
||||||
double ray_x = player.dir.x + player.plane.x * camera_x;
|
double ray_x = player.dir.x + player.plane.x * camera_x;
|
||||||
double ray_y = player.dir.y + player.plane.y * camera_x;
|
double ray_y = player.dir.y + player.plane.y * camera_x;
|
||||||
@@ -985,15 +996,15 @@ void render_map(Painter& painter, bool full_clear, int16_t x_start = 0, int16_t
|
|||||||
wall_color = Color(brightness / 5, (brightness - noise) * 0.8, brightness / 5);
|
wall_color = Color(brightness / 5, (brightness - noise) * 0.8, brightness / 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
painter.fill_rectangle({x, start_y, RES_DIVIDER, end_y - start_y}, wall_color);
|
painter.fill_rectangle({x, start_y, dynamic_res, end_y - start_y}, wall_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!full_clear && hit) {
|
if (!full_clear && hit) {
|
||||||
if (start_y > 0) {
|
if (start_y > 0) {
|
||||||
painter.fill_rectangle({x, 0, RES_DIVIDER, start_y}, Color(64, 64, 128));
|
painter.fill_rectangle({x, 0, dynamic_res, start_y}, Color(64, 64, 128));
|
||||||
}
|
}
|
||||||
if (end_y < RENDER_HEIGHT) {
|
if (end_y < RENDER_HEIGHT) {
|
||||||
painter.fill_rectangle({x, end_y, RES_DIVIDER, RENDER_HEIGHT - end_y}, Color(32, 32, 32));
|
painter.fill_rectangle({x, end_y, dynamic_res, RENDER_HEIGHT - end_y}, Color(32, 32, 32));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1001,11 +1012,28 @@ void render_map(Painter& painter, bool full_clear, int16_t x_start = 0, int16_t
|
|||||||
|
|
||||||
DoomView::DoomView(NavigationView& nav)
|
DoomView::DoomView(NavigationView& nav)
|
||||||
: nav_{nav} {
|
: nav_{nav} {
|
||||||
SCREEN_WIDTH = screen_width;
|
SCREEN_WIDTH = ui::screen_width;
|
||||||
SCREEN_HEIGHT = screen_height;
|
SCREEN_HEIGHT = ui::screen_height;
|
||||||
RENDER_HEIGHT = screen_height - 40;
|
HUD_HEIGHT = 40;
|
||||||
HALF_WIDTH = screen_width / 2;
|
RENDER_HEIGHT = SCREEN_HEIGHT - HUD_HEIGHT;
|
||||||
|
HALF_WIDTH = SCREEN_WIDTH / 2;
|
||||||
HALF_HEIGHT = RENDER_HEIGHT / 2;
|
HALF_HEIGHT = RENDER_HEIGHT / 2;
|
||||||
|
|
||||||
|
// More aggressive resolution reduction for larger screens
|
||||||
|
if (SCREEN_WIDTH > 400) {
|
||||||
|
RES_DIVIDER = 4;
|
||||||
|
} else if (SCREEN_WIDTH > 300) {
|
||||||
|
RES_DIVIDER = 3;
|
||||||
|
} else {
|
||||||
|
RES_DIVIDER = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cap gun size to prevent overflow
|
||||||
|
GUN_WIDTH = fmin(60, SCREEN_WIDTH / 8);
|
||||||
|
GUN_HEIGHT = fmin(50, SCREEN_HEIGHT / 8);
|
||||||
|
GUN_TARGET_POS = fmin(40, RENDER_HEIGHT / 13);
|
||||||
|
GUN_SHOT_POS = GUN_TARGET_POS + 6;
|
||||||
|
|
||||||
add_children({&dummy});
|
add_children({&dummy});
|
||||||
game_timer.attach(&game_timer_check, 1.0 / 60.0);
|
game_timer.attach(&game_timer_check, 1.0 / 60.0);
|
||||||
}
|
}
|
||||||
@@ -1034,26 +1062,32 @@ void DoomView::paint(Painter& painter) {
|
|||||||
|
|
||||||
if (scene == 0) {
|
if (scene == 0) {
|
||||||
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
|
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
|
||||||
painter.draw_string({50, 40}, style_yellow, "* * * DOOM * * *");
|
painter.draw_string({UI_POS_X_CENTER(15), 40}, style_yellow, "* * * DOOM * * *");
|
||||||
auto style_green = *ui::Theme::getInstance()->fg_green;
|
auto style_green = *ui::Theme::getInstance()->fg_green;
|
||||||
painter.draw_string({15, 240}, style_green, "** PRESS SELECT TO START **");
|
painter.draw_string({UI_POS_X_CENTER(26), SCREEN_HEIGHT - 80}, style_green, "** PRESS SELECT TO START **");
|
||||||
} else if (scene == 1) {
|
} else if (scene == 1) {
|
||||||
if (needs_redraw || (needs_gun_redraw && jogging > 0)) {
|
if (needs_redraw || (needs_gun_redraw && jogging > 0)) {
|
||||||
bool full_clear = (player.velocity == 0 || !prev_velocity_moving);
|
bool full_clear = (player.velocity == 0 || !prev_velocity_moving);
|
||||||
render_map(painter, full_clear);
|
render_map(painter, full_clear);
|
||||||
render_entities(painter);
|
render_entities(painter);
|
||||||
render_gun(painter, gun_pos, jogging);
|
render_gun(painter, gun_pos, jogging);
|
||||||
|
|
||||||
|
// Draw HUD
|
||||||
painter.fill_rectangle({0, RENDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - RENDER_HEIGHT}, pp_colors[COLOR_BACKGROUND]);
|
painter.fill_rectangle({0, RENDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - RENDER_HEIGHT}, pp_colors[COLOR_BACKGROUND]);
|
||||||
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
|
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
|
||||||
auto style_red = *ui::Theme::getInstance()->fg_red;
|
auto style_red = *ui::Theme::getInstance()->fg_red;
|
||||||
auto style_blue = *ui::Theme::getInstance()->fg_blue;
|
auto style_blue = *ui::Theme::getInstance()->fg_blue;
|
||||||
painter.draw_string({5, RENDER_HEIGHT + 5}, style_yellow, "Health: " + std::to_string(player.health));
|
|
||||||
painter.draw_string({100, RENDER_HEIGHT + 5}, style_red, "Kills: " + std::to_string(kills));
|
int hud_y = RENDER_HEIGHT + 5;
|
||||||
painter.draw_string({170, RENDER_HEIGHT + 5}, style_blue, "Ammo: " + std::to_string(player.ammo));
|
painter.draw_string({5, hud_y}, style_yellow, "Health: " + std::to_string(player.health));
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(15), hud_y}, style_red, "Kills: " + std::to_string(kills));
|
||||||
|
painter.draw_string({UI_POS_X_RIGHT(80), hud_y}, style_blue, "Ammo: " + std::to_string(player.ammo));
|
||||||
|
|
||||||
prev_velocity_moving = (player.velocity != 0);
|
prev_velocity_moving = (player.velocity != 0);
|
||||||
needs_redraw = false;
|
needs_redraw = false;
|
||||||
needs_gun_redraw = false;
|
needs_gun_redraw = false;
|
||||||
} else if (needs_gun_redraw) {
|
} else if (needs_gun_redraw) {
|
||||||
|
// Partial redraw for gun only
|
||||||
int current_x = HALF_WIDTH - GUN_WIDTH / 2 + sin(LPC_RTC->CTIME0 * JOGGING_SPEED) * 10 * jogging;
|
int current_x = HALF_WIDTH - GUN_WIDTH / 2 + sin(LPC_RTC->CTIME0 * JOGGING_SPEED) * 10 * jogging;
|
||||||
int current_y = RENDER_HEIGHT - gun_pos - 29 + fabs(cos(LPC_RTC->CTIME0 * JOGGING_SPEED)) * 8 * jogging;
|
int current_y = RENDER_HEIGHT - gun_pos - 29 + fabs(cos(LPC_RTC->CTIME0 * JOGGING_SPEED)) * 8 * jogging;
|
||||||
int flash_height = (gun_pos > GUN_TARGET_POS) ? (gun_pos - GUN_TARGET_POS) * 2 + 10 : 0;
|
int flash_height = (gun_pos > GUN_TARGET_POS) ? (gun_pos - GUN_TARGET_POS) * 2 + 10 : 0;
|
||||||
@@ -1069,13 +1103,18 @@ void DoomView::paint(Painter& painter) {
|
|||||||
render_map(painter, false, min_x, max_x);
|
render_map(painter, false, min_x, max_x);
|
||||||
render_entities(painter);
|
render_entities(painter);
|
||||||
render_gun(painter, gun_pos, jogging);
|
render_gun(painter, gun_pos, jogging);
|
||||||
|
|
||||||
|
// Redraw HUD
|
||||||
painter.fill_rectangle({0, RENDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - RENDER_HEIGHT}, pp_colors[COLOR_BACKGROUND]);
|
painter.fill_rectangle({0, RENDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - RENDER_HEIGHT}, pp_colors[COLOR_BACKGROUND]);
|
||||||
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
|
auto style_yellow = *ui::Theme::getInstance()->fg_yellow;
|
||||||
auto style_red = *ui::Theme::getInstance()->fg_red;
|
auto style_red = *ui::Theme::getInstance()->fg_red;
|
||||||
auto style_blue = *ui::Theme::getInstance()->fg_blue;
|
auto style_blue = *ui::Theme::getInstance()->fg_blue;
|
||||||
painter.draw_string({5, RENDER_HEIGHT + 5}, style_yellow, "Health: " + std::to_string(player.health));
|
|
||||||
painter.draw_string({100, RENDER_HEIGHT + 5}, style_red, "Kills: " + std::to_string(kills));
|
int hud_y = RENDER_HEIGHT + 5;
|
||||||
painter.draw_string({170, RENDER_HEIGHT + 5}, style_blue, "Ammo: " + std::to_string(player.ammo));
|
painter.draw_string({5, hud_y}, style_yellow, "Health: " + std::to_string(player.health));
|
||||||
|
painter.draw_string({UI_POS_X_CENTER(15), hud_y}, style_red, "Kills: " + std::to_string(kills));
|
||||||
|
painter.draw_string({UI_POS_X_RIGHT(80), hud_y}, style_blue, "Ammo: " + std::to_string(player.ammo));
|
||||||
|
|
||||||
needs_gun_redraw = false;
|
needs_gun_redraw = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user