-
-
Notifications
You must be signed in to change notification settings - Fork 914
Expand file tree
/
Copy pathmain.cpp
More file actions
229 lines (190 loc) · 7.94 KB
/
Copy pathmain.cpp
File metadata and controls
229 lines (190 loc) · 7.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 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.
*/
// Color bitmaps generated with:
// Gimp image > indexed colors (16), then "xxd -i *.bmp"
// Note about available RAM:
// Check what ends up in the BSS section by looking at the map files !
// Use constexpr where possible or make sure const are in .cpp files, not headers !
// Note about messages:
// There can only be one message handler for one kind of message at once
// If an attempt is made to register a second handler, there's a chDbgPanic "MsgDblReg"
// Note about matched filters: see proc_sonde.hpp
// TEST: Goertzel tone detect
// TEST: Menuview refresh, seems to blink a lot
// TEST: Check AFSK transmit end, skips last bits ?
// TEST: Imperial in whipcalc
// BUG: Console lock-up if first string to be printed starts with escape character ?
// BUG: (Workaround ok) CPLD-related rx ok, tx bad, see portapack.cpp lines 214+ to disable CPLD overlay
// BUG: SCANNER Lock on frequency, if frequency jump, still locked on first one
// BUG: SCANNER Multiple slices
// GLITCH: The about view scroller sometimes misses lines because of a race condition between the display scrolling and drawing the line
// GLITCH: Start of tx using ReplayThread plays a small bit of previous transmission (content of 1 buffer ?)
// See fifo.reset_in() ?
// FIXED: Update button in signal gen doesn't work for shape change
// BUG: Signal gen noise shape doesn't work
// TODO: Continue acars receiver. See matched filter, probably doesn't shift the spectrum correctly
// TODO: Add larger description text field in frequency load, under menuview
// TODO: Allow apps to select a preferred FREQMAN file
// TODO: Make play button larger in Replay
// TODO: Add default headphones volume setting in Audio settings
// TODO: Put LNA and VGA controls in Soundboard
// TODO: Make CTCSS display only when squelch is opened
// TODO: DCS decoder
// TODO: Increase resolution of audio FFT view ? Currently 48k/(256/2) (375Hz) because of the use of real values (half of FFT output)
// TODO: Move Touchtunes remote to Custom remote
// TODO: Use escapes \x1B to set colors in text, it works !
// TODO: Open files in File Manager
// TODO: Ask for filename after record
// TODO: Super simple text file viewer
// TODO: Clean up ReplayThread
// TODO: Cap Wav viewer position
// TODO: Adapt wav viewer position step
// TODO: Use unit_auto_scale
// TODO: Remove make_bistream from encoders.cpp, too complex, stinks. bitstream_append should be enough.
// TODO: Continue work on proc_afskrx_corr, see python script (it works !)
// TODO: De bruijn sequence scanner for encoders
// TODO: FILEMAN Move files
// TODO: Use separate thread for scanning in EPAR TX
// TODO: Make freqman refresh simpler (use previous black rectangle method)
// TODO: Merge AFSK and TONES procs ?
// TODO: NFM RX mode: nav.pop on squelch
// TODO: MORSE use prosigns
// TODO: MORSE live keying mode
// TODO: Use to_string_short_freq wherever possible
// TODO: SCANNER Waveform widget as FFT view ?
// TODO: Optimize (and group ?) CTCSS tone gen code
/*
Continuous (Fox-oring)
12s transmit, 48s space (Sprint 1/5th)
60s transmit, 240s space (Classic 1/5 min)
60s transmit, 360s space (Classic 1/7 min)
*/
// TODO: FreqMan: Remove and rename categories
// TODO: Mousejack ?
// TODO: Move frequencykeypad from ui_receiver to ui_widget (used everywhere)
// TODO: ADS-B draw trajectory + GPS coordinates + scale, and playback
// TODO: RDS multiple groups (sequence)
// TODO: Use ModalMessageView confirmation for TX ?
// TODO: Use msgpack for settings, lists... on sd card. and make it safe, since now it has a lot of oob potentials
// Multimon-style stuff:
// TODO: DMR detector
// TODO: GSM channel detector
// TODO: Setup: Play dead by default ? Enable/disable ?
// Old or low-priority stuff:
// TODO: Bodet :)
// TODO: Analog TV tx with camcorder font character generator
// TODO: Scan for OOK TX
// TODO: Check more OOK encoders
// BUG (fixed ?): No audio in about when shown second time
// TODO: Show MD5 mismatches for modules not found, etc...
// BUG: Description doesn't show up first time going to system>module info (UI drawn on top)
// TODO: Two players tic-tac-toe
// TODO: Analog TV pong game
#include "ch.h"
#include "portapack.hpp"
#include "portapack_shared_memory.hpp"
#include "config_mode.hpp"
#include "message_queue.hpp"
#include "ui.hpp"
#include "ui_widget.hpp"
#include "ui_painter.hpp"
#include "ui_navigation.hpp"
#include "irq_lcd_frame.hpp"
#include "irq_controls.hpp"
#include "irq_rtc.hpp"
#include "event_m0.hpp"
#include "core_control.hpp"
#include "spi_image.hpp"
#include "debug.hpp"
#include "led.hpp"
#include "gcc.hpp"
#include "sd_card.hpp"
#include "file_path.hpp"
#include <string.h>
#include "i2cdevmanager.hpp"
#include "rffc507x.hpp" /* c/m, avoiding initial short ON Ant_DC_Bias pulse, from cold reset */
rffc507x::RFFC507x first_if;
ui::SystemView* system_view_ptr;
static uint32_t random_seed_state = 123456789;
extern "C" int rand(void) {
random_seed_state ^= random_seed_state << 13;
random_seed_state ^= random_seed_state >> 17;
random_seed_state ^= random_seed_state << 5;
return (int)(random_seed_state & 0x7FFFFFFF);
}
extern "C" void srand(unsigned int seed) {
if (seed == 0) {
random_seed_state = 123456789;
} else {
random_seed_state = seed;
}
}
static void event_loop() {
static ui::Context context;
static ui::SystemView system_view{
context,
portapack::display.screen_rect()};
system_view_ptr = &system_view;
EventDispatcher event_dispatcher{&system_view, context};
static MessageHandlerRegistration message_handler_display_sleep{
Message::ID::DisplaySleep,
[&event_dispatcher](const Message* const) {
event_dispatcher.set_display_sleep(true);
}};
portapack::setEventDispatcherToUSBSerial(&event_dispatcher);
i2cdev::I2CDevManager::setEventDispatcher(&event_dispatcher);
system_view.get_navigation_view()->handle_autostart();
event_dispatcher.run();
}
int main(void) {
#ifndef PRALINE // Do not perform quick set up of GP01_RFF507X = 1 for PRALINE
first_if.init(); /* To avoid initial short Ant_DC_Bias pulse ,we need quick set up GP01_RFF507X =1 */
#endif
if (config_mode_should_enter()) {
config_mode_clear();
config_mode_run();
}
config_mode_set();
switch (portapack::init()) {
case portapack::init_status_t::INIT_HACKRF_CPLD_FAILED:
portapack::init_error = "HACKRF CPLD FAILED";
[[fallthrough]];
case portapack::init_status_t::INIT_SUCCESS:
init_apps_dir();
config_mode_clear();
lcd_frame_sync_configure();
rtc_interrupt_enable();
Theme::SetTheme((Theme::ThemeId)portapack::persistent_memory::ui_theme_id());
event_loop();
sdcDisconnect(&SDCD1);
sdcStop(&SDCD1);
portapack::shutdown();
break;
case portapack::init_status_t::INIT_NO_PORTAPACK:
case portapack::init_status_t::INIT_PORTAPACK_CPLD_FAILED:
config_mode_clear();
break;
}
m4_init(portapack::spi_flash::image_tag_hackrf, portapack::memory::map::m4_code_hackrf, true);
m0_halt();
return 0;
}