mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Added map display view (GeoMapView)
SigGen duration bugfix
This commit is contained in:
parent
3005403b5e
commit
b57b41753f
@ -161,27 +161,26 @@ set(CPPSRC
|
||||
${COMMON}/ui_painter.cpp
|
||||
${COMMON}/ui_focus.cpp
|
||||
ui_about.cpp
|
||||
ui_adsb_tx.cpp
|
||||
ui_adsb_rx.cpp
|
||||
ui_aprstx.cpp
|
||||
ui_modemsetup.cpp
|
||||
ui_adsb_tx.cpp
|
||||
ui_alphanum.cpp
|
||||
ui_aprstx.cpp
|
||||
ui_audio.cpp
|
||||
ui_mictx.cpp
|
||||
ui_baseband_stats_view.cpp
|
||||
ui_bht_tx.cpp
|
||||
ui_channel.cpp
|
||||
ui_scanner.cpp
|
||||
ui_coasterp.cpp
|
||||
ui_siggen.cpp
|
||||
ui_debug.cpp
|
||||
ui_encoders.cpp
|
||||
ui_font_fixed_8x16.cpp
|
||||
ui_freqman.cpp
|
||||
ui_geomap.cpp
|
||||
ui_handwrite.cpp
|
||||
ui_jammer.cpp
|
||||
ui_lcr.cpp
|
||||
ui_menu.cpp
|
||||
ui_mictx.cpp
|
||||
ui_modemsetup.cpp
|
||||
ui_morse.cpp
|
||||
ui_navigation.cpp
|
||||
# ui_numbers.cpp
|
||||
@ -193,11 +192,13 @@ set(CPPSRC
|
||||
ui_record_view.cpp
|
||||
ui_replay_view.cpp
|
||||
ui_rssi.cpp
|
||||
ui_scanner.cpp
|
||||
# ui_script.cpp
|
||||
ui_sd_card_status_view.cpp
|
||||
ui_sd_wipe.cpp
|
||||
# ui_sd_card_debug.cpp
|
||||
ui_setup.cpp
|
||||
ui_siggen.cpp
|
||||
ui_soundboard.cpp
|
||||
ui_spectrum.cpp
|
||||
ui_sstvtx.cpp
|
||||
|
@ -22,50 +22,37 @@
|
||||
|
||||
#include "de_bruijn.hpp"
|
||||
|
||||
/*
|
||||
How this works:
|
||||
B(2,4): 2 states, 4 bits
|
||||
Primitive poly with n=4: 1001
|
||||
|
||||
0001
|
||||
xor 1001 = 0 ^ 1 = 1
|
||||
|
||||
00011
|
||||
xor 1001 = 0 ^ 1 = 1
|
||||
|
||||
000111
|
||||
xor 1001 = 0 ^ 1 = 1
|
||||
|
||||
0001111
|
||||
xor 1001 = 1 ^ 1 = 0
|
||||
|
||||
00011110
|
||||
xor 1001 = 1 ^ 0 = 1
|
||||
|
||||
000111101
|
||||
xor 1001 = 1 ^ 1 = 0
|
||||
|
||||
0001111010
|
||||
xor 1001 = 0 ^ 1 = 1
|
||||
|
||||
00011110101
|
||||
xor 1001 = 0 ^ 1 = 1
|
||||
|
||||
000111101011
|
||||
xor 1001 = 1 ^ 1 = 0
|
||||
|
||||
0001111010110
|
||||
xor 1001 = 0 ^ 0 = 0
|
||||
|
||||
00011110101100
|
||||
xor 1001 = 1 ^ 0 = 1
|
||||
|
||||
000111101011001
|
||||
xor 1001 = 1 ^ 1 = 0
|
||||
|
||||
0001111010110010
|
||||
xor 1001 = 0 ^ 0 = 0
|
||||
*/
|
||||
/* How this works:
|
||||
* B(2,4) means:
|
||||
* Alphabet size = 2 (binary)
|
||||
* Code length = 4
|
||||
* The length of the bitstream is (2 ^ 4) - 1 = 15
|
||||
* The primitive polynomials come from the de_bruijn_polys[] array (one for each code length)
|
||||
* The shift register is init with 1 and shifted left each step
|
||||
* The polynomial is kept on the right, and ANDed with the corresponding shift register bits
|
||||
* The resulting bits are XORed together to produce the new bit pushed in the shift register
|
||||
*
|
||||
* 0001 (init)
|
||||
* AND 1001 (polynomial)
|
||||
* 0001 XOR'd -> 1
|
||||
*
|
||||
* 00011 (shift left)
|
||||
* AND 1001
|
||||
* 0001 XOR'd -> 1
|
||||
*
|
||||
* 000111 (shift left)
|
||||
* AND 1001
|
||||
* 0001 XOR'd -> 1
|
||||
*
|
||||
* 0001111 (shift left)
|
||||
* AND 1001
|
||||
* 1001 XOR'd -> 0
|
||||
*
|
||||
* 00011110 (shift left)
|
||||
* AND 1001
|
||||
* 1000 XOR'd -> 1
|
||||
* ...
|
||||
*/
|
||||
|
||||
void de_bruijn::init(const uint32_t n) {
|
||||
if ((n < 3) || (n > 16))
|
||||
@ -73,16 +60,15 @@ void de_bruijn::init(const uint32_t n) {
|
||||
else
|
||||
length = n;
|
||||
|
||||
// k is 2 (binary sequence)
|
||||
poly = de_bruijn_polys[length - 3];
|
||||
shift_register = 1;
|
||||
}
|
||||
|
||||
uint32_t de_bruijn::compute(const uint32_t step) {
|
||||
uint32_t c, bits, masked;
|
||||
uint32_t de_bruijn::compute(const uint32_t steps) {
|
||||
uint32_t step, bits, masked;
|
||||
uint8_t new_bit;
|
||||
|
||||
for (c = 0; c < step; c++) {
|
||||
for (step = 0; step < steps; step++) {
|
||||
masked = shift_register & poly;
|
||||
new_bit = 0;
|
||||
for (bits = 0; bits < length; bits++) {
|
||||
|
@ -46,7 +46,7 @@ const uint32_t de_bruijn_polys[14] {
|
||||
struct de_bruijn {
|
||||
public:
|
||||
void init(const uint32_t n);
|
||||
uint32_t compute(const uint32_t step);
|
||||
uint32_t compute(const uint32_t steps);
|
||||
|
||||
private:
|
||||
uint32_t length { };
|
||||
|
@ -23,6 +23,8 @@
|
||||
// Color bitmaps generated with:
|
||||
// Gimp image > indexed colors (16), then "xxd -i *.bmp"
|
||||
|
||||
//TODO: De bruijn sequence scanner for encoders
|
||||
//TODO: Waveform viewer
|
||||
//TEST: Mic tx
|
||||
//TEST: Menuview refresh, seems to blink a lot
|
||||
//TEST: Check AFSK transmit end, skips last bits ?
|
||||
|
@ -86,7 +86,7 @@ private:
|
||||
flags flag;
|
||||
} credits_t;
|
||||
|
||||
const credits_t credits[15] = { {"Portapack|HAVOC", "Git hash " GIT_REVISION, SECTION},
|
||||
const credits_t credits[16] = { {"Portapack|HAVOC", "Git hash " GIT_REVISION, SECTION},
|
||||
{"Gurus", "J. Boone", TITLE},
|
||||
{"M. Ossmann", "", MEMBER_LF},
|
||||
{"HAVOC", "Furrtek", TITLE_LF},
|
||||
@ -94,12 +94,13 @@ private:
|
||||
{"E. Oenal", "", MEMBER_LF},
|
||||
{"RDS waveform", "C. Jacquet", TITLE_LF},
|
||||
{"Xy. infos", "cLx", TITLE_LF},
|
||||
{"ADS-B map", "ShadeRelief", TITLE_LF},
|
||||
{"ADS-B map", "D. Strebe", TITLE_LF},
|
||||
{"Thanks", "", SECTION},
|
||||
{"Rainer Matla", "Keld Norman", TITLE},
|
||||
{"Giorgio C.", "DC1RDB", TITLE},
|
||||
{"Sigmounte", "Waax", TITLE},
|
||||
{"Windyoona", "Channels", TITLE_LF},
|
||||
{"Windyoona", "Channels", TITLE},
|
||||
{"F4GEV", "", TITLE_LF},
|
||||
{"", "MMXVII", END}
|
||||
};
|
||||
|
||||
|
@ -22,9 +22,11 @@
|
||||
|
||||
#include "ui_adsb_rx.hpp"
|
||||
#include "ui_alphanum.hpp"
|
||||
#include "ui_geomap.hpp"
|
||||
|
||||
#include "adsb.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "sine_table_int8.hpp"
|
||||
#include "portapack.hpp"
|
||||
#include "baseband_api.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
@ -202,11 +204,6 @@ bool ADSBRxView::analyze(uint64_t offset) {
|
||||
|
||||
prev_mag = mag;
|
||||
|
||||
/*if (!lcd_y && !lcd_x) {
|
||||
for (c = 0; c < 16; c++)
|
||||
display.fill_rectangle({c * 4, 300, 4, 16}, shifter[c] ? Color::white() : Color::blue());
|
||||
}*/
|
||||
|
||||
if (preamble_count) {
|
||||
if (lcd_y < 188) {
|
||||
mag *= 16;
|
||||
@ -250,18 +247,18 @@ ADSBRxView::ADSBRxView(NavigationView& nav) {
|
||||
if (result.is_valid()) {
|
||||
text_debug_a.set("Can't open file");
|
||||
}
|
||||
|
||||
|
||||
offset_field.on_change = [this, &nav](int32_t value) {
|
||||
// TODO
|
||||
};
|
||||
|
||||
button_ffw.on_select = [this, &nav](Button&) {
|
||||
while (!analyze(f_offset)) {
|
||||
auto new_view = nav.push<GeoMapView>();
|
||||
/*while (!analyze(f_offset)) {
|
||||
f_offset++;
|
||||
}
|
||||
offset_field.set_value(f_offset);
|
||||
f_offset++;
|
||||
//offset_field.set_value(offset_field.value() + 1562);
|
||||
f_offset++;*/
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
|
@ -117,7 +117,7 @@ void FreqManBaseView::refresh_list() {
|
||||
for (size_t n = 0; n < database.entries.size(); n++) {
|
||||
menu_view.add_item({
|
||||
freqman_item_string(database.entries[n], 26),
|
||||
ui::Color::light_grey(),
|
||||
ui::Color::white(),
|
||||
nullptr,
|
||||
[this](){
|
||||
if (on_select_frequency)
|
||||
|
131
firmware/application/ui_geomap.cpp
Normal file
131
firmware/application/ui_geomap.cpp
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui_geomap.hpp"
|
||||
|
||||
#include "adsb.hpp"
|
||||
//#include "string_format.hpp"
|
||||
#include "sine_table_int8.hpp"
|
||||
#include "portapack.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
namespace ui {
|
||||
|
||||
void GeoMapView::focus() {
|
||||
if (!file_error) {
|
||||
field_xpos.focus();
|
||||
move_map();
|
||||
} else
|
||||
nav_.display_modal("No map", "No world_map.bin file in\n/ADSB/ directory", ABORT, nullptr);
|
||||
}
|
||||
|
||||
GeoMapView::~GeoMapView() {
|
||||
|
||||
}
|
||||
|
||||
Point GeoMapView::polar_to_point(const uint8_t angle, const uint32_t size) {
|
||||
return { (Coord)(sine_table_i8[(angle + 64) & 0xFF] * size) >> 7, (Coord)(sine_table_i8[angle] * size) >> 7 };
|
||||
}
|
||||
|
||||
void GeoMapView::draw_bearing(const Point origin, const uint8_t angle, uint32_t size, const Color color) {
|
||||
Point arrow_a, arrow_b, arrow_c;
|
||||
|
||||
arrow_a = polar_to_point(angle, size) + origin;
|
||||
arrow_b = polar_to_point(angle + 128 - 16, size) + origin;
|
||||
arrow_c = polar_to_point(angle + 128 + 16, size) + origin;
|
||||
display.draw_line(arrow_a, arrow_b, color);
|
||||
display.draw_line(arrow_b, arrow_c, color);
|
||||
display.draw_line(arrow_c, arrow_a, color);
|
||||
|
||||
size--;
|
||||
arrow_a = polar_to_point(angle, size) + origin;
|
||||
arrow_b = polar_to_point(angle + 128 - 16, size) + origin;
|
||||
arrow_c = polar_to_point(angle + 128 + 16, size) + origin;
|
||||
display.draw_line(arrow_a, arrow_b, color);
|
||||
display.draw_line(arrow_b, arrow_c, color);
|
||||
display.draw_line(arrow_c, arrow_a, color);
|
||||
}
|
||||
|
||||
void GeoMapView::move_map() {
|
||||
Coord line;
|
||||
int32_t x_pos, y_pos;
|
||||
std::array<ui::Color, 240> map_buffer;
|
||||
|
||||
// Map is in Equidistant "Plate Carrée" projection
|
||||
x_pos = map_center_x - 120 + ((((field_xpos.value() * map_center_x) << 8) / 180) >> 8);
|
||||
y_pos = map_center_y - 144 + ((((field_ypos.value() * map_center_y) << 8) / 90) >> 8);
|
||||
|
||||
if (x_pos > (map_width - 240))
|
||||
x_pos = map_width - 240;
|
||||
if (y_pos > (map_height + 288))
|
||||
y_pos = map_height - 288;
|
||||
|
||||
for (line = 0; line < 288; line++) {
|
||||
map_file.seek(4 + ((x_pos + (map_width * (y_pos + line))) << 1));
|
||||
map_file.read(map_buffer.data(), 240 * 2);
|
||||
display.draw_pixels({ 0, 32 + line, 240, 1 }, map_buffer);
|
||||
}
|
||||
|
||||
draw_bearing({ 120, 32 + 144 }, field_angle.value(), 16, Color::red());
|
||||
|
||||
//display.fill_rectangle({ 120-16, 176-1, 32, 2 }, Color::red());
|
||||
//display.fill_rectangle({ 120-1, 176-16, 2, 32 }, Color::red());
|
||||
}
|
||||
|
||||
GeoMapView::GeoMapView(
|
||||
NavigationView& nav
|
||||
) : nav_ (nav)
|
||||
{
|
||||
auto result = map_file.open("ADSB/world_map.bin");
|
||||
if (result.is_valid()) {
|
||||
file_error = true;
|
||||
return;
|
||||
}
|
||||
|
||||
map_file.read(&map_width, 2);
|
||||
map_file.read(&map_height, 2);
|
||||
|
||||
map_center_x = map_width >> 1;
|
||||
map_center_y = map_height >> 1;
|
||||
|
||||
add_children({
|
||||
&field_xpos,
|
||||
&field_ypos,
|
||||
&field_angle
|
||||
});
|
||||
|
||||
field_xpos.on_change = [this](int32_t) {
|
||||
move_map();
|
||||
};
|
||||
field_ypos.on_change = [this](int32_t) {
|
||||
move_map();
|
||||
};
|
||||
field_angle.on_change = [this](int32_t) {
|
||||
move_map();
|
||||
};
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
80
firmware/application/ui_geomap.hpp
Normal file
80
firmware/application/ui_geomap.hpp
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "file.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_font_fixed_8x16.hpp"
|
||||
|
||||
#include "portapack.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
class GeoMapView : public View {
|
||||
public:
|
||||
GeoMapView(NavigationView& nav);
|
||||
~GeoMapView();
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "Map view"; };
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
|
||||
File map_file { };
|
||||
bool file_error { false };
|
||||
uint16_t map_width { }, map_height { };
|
||||
int32_t map_center_x { }, map_center_y { };
|
||||
|
||||
void move_map();
|
||||
Point polar_to_point(const uint8_t angle, const uint32_t size);
|
||||
void draw_bearing(const Point origin, const uint8_t angle, uint32_t size, const Color color);
|
||||
|
||||
Labels labels {
|
||||
{ { 0 * 8, 0 * 8 }, "Test", Color::light_grey() }
|
||||
};
|
||||
|
||||
NumberField field_xpos {
|
||||
{ 0, 0 },
|
||||
4,
|
||||
{ -180, 180 },
|
||||
1,
|
||||
'0'
|
||||
};
|
||||
NumberField field_ypos {
|
||||
{ 6 * 8, 0 },
|
||||
4,
|
||||
{ -90, 90 },
|
||||
1,
|
||||
'0'
|
||||
};
|
||||
NumberField field_angle {
|
||||
{ 12 * 8, 0 },
|
||||
3,
|
||||
{ 0, 255 },
|
||||
1,
|
||||
'0'
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
@ -53,7 +53,7 @@ void SigGenView::start_tx() {
|
||||
auto duration = field_stop.value();
|
||||
if (!checkbox_auto.value())
|
||||
duration = 0;
|
||||
baseband::set_siggen_config(transmitter_model.bandwidth(), options_shape.selected_index_value(), field_stop.value());
|
||||
baseband::set_siggen_config(transmitter_model.bandwidth(), options_shape.selected_index_value(), duration);
|
||||
}
|
||||
|
||||
void SigGenView::update_tone() {
|
||||
|
17910
sdcard/ADSB/world_map.bin
Normal file
17910
sdcard/ADSB/world_map.bin
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user