| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  |  * Copyright (C) 2016 Furrtek | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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_lcr.hpp"
 | 
					
						
							| 
									
										
										
										
											2015-09-04 20:37:27 +02:00
										 |  |  | #include "ui_afsksetup.hpp"
 | 
					
						
							|  |  |  | #include "ui_debug.hpp"
 | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | #include "modems.hpp"
 | 
					
						
							| 
									
										
										
										
											2017-04-18 12:55:49 +01:00
										 |  |  | #include "lcr.hpp"
 | 
					
						
							| 
									
										
										
										
											2016-07-27 03:03:40 +02:00
										 |  |  | #include "baseband_api.hpp"
 | 
					
						
							| 
									
										
										
										
											2016-02-04 10:27:53 +01:00
										 |  |  | #include "string_format.hpp"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-03 06:34:00 +02:00
										 |  |  | #include "portapack_persistent_memory.hpp"
 | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <cstring>
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-04 10:27:53 +01:00
										 |  |  | using namespace portapack; | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | using namespace modems; | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace ui { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LCRView::focus() { | 
					
						
							| 
									
										
										
										
											2015-09-05 20:17:43 +02:00
										 |  |  | 	button_setrgsb.focus(); | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LCRView::~LCRView() { | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 	transmitter_model.disable(); | 
					
						
							|  |  |  | 	baseband::shutdown(); | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-04 20:37:27 +02:00
										 |  |  | void LCRView::paint(Painter& painter) { | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 	size_t i; | 
					
						
							| 
									
										
										
										
											2016-08-02 12:44:31 +02:00
										 |  |  | 	std::string final_str; | 
					
						
							| 
									
										
										
										
											2015-09-10 20:36:39 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2015-09-04 20:37:27 +02:00
										 |  |  | 	static constexpr Style style_orange { | 
					
						
							|  |  |  | 		.font = font::fixed_8x16, | 
					
						
							|  |  |  | 		.background = Color::black(), | 
					
						
							|  |  |  | 		.foreground = Color::orange(), | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	Point offset = { | 
					
						
							| 
									
										
										
										
											2015-09-05 20:17:43 +02:00
										 |  |  | 		static_cast<Coord>(104), | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 		static_cast<Coord>(68) | 
					
						
							| 
									
										
										
										
											2015-09-04 20:37:27 +02:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2015-09-03 06:34:00 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2015-09-10 20:36:39 +02:00
										 |  |  | 	for (i = 0; i < 5; i++) { | 
					
						
							|  |  |  | 		painter.draw_string( | 
					
						
							|  |  |  | 			screen_pos() + offset, | 
					
						
							|  |  |  | 			style_orange, | 
					
						
							|  |  |  | 			litteral[i] | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-01-16 03:45:44 +00:00
										 |  |  | 		offset += { 0, 32 }; | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-05-29 12:06:47 +02:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	button_setrgsb.set_text(rgsb); | 
					
						
							| 
									
										
										
										
											2016-07-25 16:21:27 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-08-02 12:44:31 +02:00
										 |  |  | 	// Recap: freq @ bps
 | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 	final_str = to_string_dec_int(persistent_memory::tuned_frequency() / 1000, 6); | 
					
						
							| 
									
										
										
										
											2016-08-02 12:44:31 +02:00
										 |  |  | 	final_str += '@'; | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 	final_str += to_string_dec_int(persistent_memory::modem_baudrate(), 4); | 
					
						
							| 
									
										
										
										
											2016-08-02 12:44:31 +02:00
										 |  |  | 	final_str += "bps "; | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 	//final_str += modem_defs[persistent_memory::modem_def_index()].name;
 | 
					
						
							| 
									
										
										
										
											2016-08-02 12:44:31 +02:00
										 |  |  | 	text_recap.set(final_str); | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 12:55:49 +01:00
										 |  |  | std::vector<std::string> LCRView::parse_litterals() { | 
					
						
							|  |  |  | 	std::vector<std::string> litterals; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	for (size_t i = 0; i < 5; i++) { | 
					
						
							|  |  |  | 		if (checkboxes[i].value()) | 
					
						
							|  |  |  | 			litterals.push_back(litteral[i]); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return litterals; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | void LCRView::update_progress() { | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 	std::string progress_str; | 
					
						
							| 
									
										
										
										
											2016-07-27 03:03:40 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 	text_status.set("            ");	// Clear
 | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	if (tx_mode == SINGLE) { | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 		progress_str = to_string_dec_uint(repeat_index) + "/" + to_string_dec_uint(persistent_memory::modem_repeat()); | 
					
						
							|  |  |  | 		text_status.set(progress_str); | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 		progress.set_value(repeat_index); | 
					
						
							|  |  |  | 	} else if (tx_mode == SCAN) { | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 		progress_str = to_string_dec_uint(repeat_index) + "/" + to_string_dec_uint(persistent_memory::modem_repeat()); | 
					
						
							|  |  |  | 		progress_str += " " + to_string_dec_uint(scan_index + 1) + "/" + to_string_dec_uint(scan_count); | 
					
						
							|  |  |  | 		text_status.set(progress_str); | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 		progress.set_value(scan_progress); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		text_status.set("Ready"); | 
					
						
							| 
									
										
										
										
											2016-07-27 03:03:40 +02:00
										 |  |  | 		progress.set_value(0); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LCRView::on_txdone(int n) { | 
					
						
							| 
									
										
										
										
											2016-07-27 03:03:40 +02:00
										 |  |  | 	if (n > 0) { | 
					
						
							| 
									
										
										
										
											2016-07-28 05:25:33 +02:00
										 |  |  | 		// Repeating...
 | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 		repeat_index = n + 1; | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 		if (tx_mode == SCAN) { | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 			scan_progress++; | 
					
						
							|  |  |  | 			update_progress(); | 
					
						
							| 
									
										
										
										
											2016-07-27 03:03:40 +02:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 			update_progress(); | 
					
						
							| 
									
										
										
										
											2016-07-27 03:03:40 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2016-07-28 05:25:33 +02:00
										 |  |  | 		// Done transmitting
 | 
					
						
							| 
									
										
										
										
											2016-08-02 12:44:31 +02:00
										 |  |  | 		if ((tx_mode == SCAN) && (scan_index < (scan_count - 1))) { | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 			transmitter_model.disable(); | 
					
						
							| 
									
										
										
										
											2017-04-18 12:55:49 +01:00
										 |  |  | 			// Next address
 | 
					
						
							|  |  |  | 			scan_index++; | 
					
						
							| 
									
										
										
										
											2017-04-18 18:12:32 +01:00
										 |  |  | 			rgsb = scan_list[options_scanlist.selected_index()].addresses[scan_index]; | 
					
						
							| 
									
										
										
										
											2017-04-18 12:55:49 +01:00
										 |  |  | 			scan_progress++; | 
					
						
							|  |  |  | 			repeat_index = 1; | 
					
						
							|  |  |  | 			update_progress(); | 
					
						
							|  |  |  | 			start_tx(true); | 
					
						
							| 
									
										
										
										
											2016-07-27 03:03:40 +02:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 			transmitter_model.disable(); | 
					
						
							|  |  |  | 			tx_mode = IDLE; | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 			update_progress(); | 
					
						
							| 
									
										
										
										
											2016-07-27 03:03:40 +02:00
										 |  |  | 			button_scan.set_style(&style_val); | 
					
						
							|  |  |  | 			button_scan.set_text("SCAN"); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}	 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | void LCRView::start_tx(const bool scan) { | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 	uint8_t repeats; | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 	repeats = persistent_memory::modem_repeat(); | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 	if (scan) { | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 		if (tx_mode != SCAN) { | 
					
						
							|  |  |  | 			scan_index = 0; | 
					
						
							| 
									
										
										
										
											2016-08-02 12:44:31 +02:00
										 |  |  | 			scan_count = scan_list[options_scanlist.selected_index()].count; | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 			scan_progress = 1; | 
					
						
							|  |  |  | 			repeat_index = 1; | 
					
						
							|  |  |  | 			tx_mode = SCAN; | 
					
						
							| 
									
										
										
										
											2017-04-18 18:12:32 +01:00
										 |  |  | 			rgsb = scan_list[options_scanlist.selected_index()].addresses[0]; | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 			progress.set_max(scan_count * repeats); | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 			update_progress(); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 	} else { | 
					
						
							|  |  |  | 		tx_mode = SINGLE; | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 		repeat_index = 1; | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 		progress.set_max(repeats); | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 		update_progress(); | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2017-04-18 12:55:49 +01:00
										 |  |  | 	button_setrgsb.set_text(rgsb); | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 	modems::generate_data(lcr::generate_message(rgsb, parse_litterals(), options_ec.selected_index()), lcr_message_data); | 
					
						
							| 
									
										
										
										
											2016-08-02 12:44:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 	transmitter_model.set_tuning_frequency(persistent_memory::tuned_frequency()); | 
					
						
							| 
									
										
										
										
											2017-01-16 03:45:44 +00:00
										 |  |  | 	transmitter_model.set_sampling_rate(1536000U); | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 	transmitter_model.set_rf_amp(true); | 
					
						
							|  |  |  | 	transmitter_model.set_baseband_bandwidth(1750000); | 
					
						
							|  |  |  | 	transmitter_model.enable(); | 
					
						
							| 
									
										
										
										
											2016-08-06 08:49:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-09 18:21:47 +01:00
										 |  |  | 	memcpy(shared_memory.bb_data.data, lcr_message_data, 300); | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	baseband::set_afsk_data( | 
					
						
							| 
									
										
										
										
											2017-04-21 06:22:31 +01:00
										 |  |  | 		1536000 / persistent_memory::modem_baudrate(), | 
					
						
							|  |  |  | 		persistent_memory::afsk_mark_freq(), | 
					
						
							|  |  |  | 		persistent_memory::afsk_space_freq(), | 
					
						
							|  |  |  | 		repeats, | 
					
						
							|  |  |  | 		persistent_memory::modem_bw(), | 
					
						
							|  |  |  | 		modems::symbol_count() | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 	); | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | void LCRView::on_button_setam(NavigationView& nav, Button& button) { | 
					
						
							| 
									
										
										
										
											2017-04-18 18:12:32 +01:00
										 |  |  | 	text_entry(nav, litteral[button.id], 7); | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-27 03:03:40 +02:00
										 |  |  | LCRView::LCRView(NavigationView& nav) { | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 	std::string label; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 	baseband::run_image(portapack::spi_flash::image_tag_afsk); | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2017-04-18 18:12:32 +01:00
										 |  |  | 	rgsb = scan_list[0].addresses[0]; | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2017-01-16 03:45:44 +00:00
										 |  |  | 	add_children({ | 
					
						
							| 
									
										
										
										
											2015-09-04 20:37:27 +02:00
										 |  |  | 		&text_recap, | 
					
						
							| 
									
										
										
										
											2016-07-25 16:21:27 +02:00
										 |  |  | 		&options_ec, | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 		&button_setrgsb, | 
					
						
							| 
									
										
										
										
											2015-09-03 06:34:00 +02:00
										 |  |  | 		&button_txsetup, | 
					
						
							| 
									
										
										
										
											2015-09-04 20:37:27 +02:00
										 |  |  | 		&text_status, | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 		&progress, | 
					
						
							| 
									
										
										
										
											2015-09-04 20:37:27 +02:00
										 |  |  | 		&button_lcrdebug, | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 		&button_transmit, | 
					
						
							| 
									
										
										
										
											2016-08-02 12:44:31 +02:00
										 |  |  | 		&text_scanlist, | 
					
						
							|  |  |  | 		&options_scanlist, | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 		&button_scan, | 
					
						
							|  |  |  | 		&button_clear | 
					
						
							| 
									
										
										
										
											2017-01-16 03:45:44 +00:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-08-17 02:55:34 +02:00
										 |  |  | 	options_scanlist.set_selected_index(0); | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 	const auto button_setam_fn = [this, &nav](Button& button) { | 
					
						
							|  |  |  | 		this->on_button_setam(nav, button); | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 	size_t n = 0; | 
					
						
							|  |  |  | 	for(auto& button : buttons) { | 
					
						
							|  |  |  | 		button.on_select = button_setam_fn; | 
					
						
							|  |  |  | 		button.id = n; | 
					
						
							| 
									
										
										
										
											2016-07-29 04:52:51 +02:00
										 |  |  | 		label = "AM " + to_string_dec_uint(n + 1, 1);; | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 		button.set_text(label); | 
					
						
							|  |  |  | 		button.set_parent_rect({ | 
					
						
							|  |  |  | 			static_cast<Coord>(48), | 
					
						
							|  |  |  | 			static_cast<Coord>(n * 32 + 64), | 
					
						
							|  |  |  | 			48, 24 | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 		add_child(&button); | 
					
						
							|  |  |  | 		n++; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-07-25 16:21:27 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 	n = 0; | 
					
						
							|  |  |  | 	for(auto& checkbox : checkboxes) { | 
					
						
							|  |  |  | 		checkbox.set_parent_rect({ | 
					
						
							|  |  |  | 			static_cast<Coord>(16), | 
					
						
							|  |  |  | 			static_cast<Coord>(n * 32 + 64), | 
					
						
							|  |  |  | 			48, 24 | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 		checkbox.set_value(false); | 
					
						
							|  |  |  | 		add_child(&checkbox); | 
					
						
							|  |  |  | 		n++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-07-29 04:52:51 +02:00
										 |  |  | 	n = 0; | 
					
						
							|  |  |  | 	for(auto& rectangle : rectangles) { | 
					
						
							|  |  |  | 		rectangle.set_parent_rect({ | 
					
						
							|  |  |  | 			static_cast<Coord>(104 - 2), | 
					
						
							|  |  |  | 			static_cast<Coord>(n * 32 + 68 - 2), | 
					
						
							|  |  |  | 			56 + 4, 16 + 4 | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 		rectangle.set_color(ui::Color::grey()); | 
					
						
							|  |  |  | 		rectangle.set_outline(true); | 
					
						
							|  |  |  | 		add_child(&rectangle); | 
					
						
							|  |  |  | 		n++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-07-28 00:08:05 +02:00
										 |  |  | 	button_setrgsb.set_text(rgsb); | 
					
						
							|  |  |  | 	options_ec.set_selected_index(0);	// Auto
 | 
					
						
							|  |  |  | 	checkboxes[0].set_value(true); | 
					
						
							| 
									
										
										
										
											2015-09-05 20:17:43 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2015-09-04 20:37:27 +02:00
										 |  |  | 	button_transmit.set_style(&style_val); | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 	button_scan.set_style(&style_val); | 
					
						
							| 
									
										
										
										
											2015-09-04 20:37:27 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 	button_setrgsb.on_select = [this,&nav](Button&) { | 
					
						
							| 
									
										
										
										
											2017-04-18 18:12:32 +01:00
										 |  |  | 		text_entry(nav, rgsb, 4); | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 	button_txsetup.on_select = [&nav](Button&) { | 
					
						
							|  |  |  | 		nav.push<AFSKSetupView>(); | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2016-07-29 04:52:51 +02:00
										 |  |  | 	button_lcrdebug.on_select = [this, &nav](Button&) { | 
					
						
							| 
									
										
										
										
											2017-04-18 12:55:49 +01:00
										 |  |  | 		nav.push<DebugLCRView>(lcr::generate_message(rgsb, parse_litterals(), options_ec.selected_index())); | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	button_transmit.on_select = [this](Button&) { | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 		if (tx_mode == IDLE) start_tx(false); | 
					
						
							| 
									
										
										
										
											2016-05-09 20:42:20 +02:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	button_scan.on_select = [this](Button&) { | 
					
						
							| 
									
										
										
										
											2017-04-18 18:12:32 +01:00
										 |  |  | 		std::string str_temp; | 
					
						
							| 
									
										
										
										
											2017-04-18 12:55:49 +01:00
										 |  |  | 		 | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 		if (tx_mode == IDLE)	{ | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 			button_scan.set_style(&style_cancel); | 
					
						
							|  |  |  | 			button_scan.set_text("ABORT"); | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 			start_tx(true); | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2017-04-18 12:55:49 +01:00
										 |  |  | 			// Kill scan process
 | 
					
						
							|  |  |  | 			baseband::kill_afsk(); | 
					
						
							| 
									
										
										
										
											2017-04-18 18:12:32 +01:00
										 |  |  | 			text_status.set("Abort @" + rgsb); | 
					
						
							| 
									
										
										
										
											2017-04-18 12:55:49 +01:00
										 |  |  | 			progress.set_value(0); | 
					
						
							|  |  |  | 			tx_mode = IDLE; | 
					
						
							|  |  |  | 			button_scan.set_style(&style_val); | 
					
						
							|  |  |  | 			button_scan.set_text("SCAN"); | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-09-04 20:37:27 +02:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-27 09:26:43 +02:00
										 |  |  | 	button_clear.on_select = [this, &nav](Button&) { | 
					
						
							| 
									
										
										
										
											2016-07-28 05:25:33 +02:00
										 |  |  | 		uint8_t n; | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 		if (tx_mode == IDLE) { | 
					
						
							| 
									
										
										
										
											2016-07-28 05:25:33 +02:00
										 |  |  | 			options_ec.set_selected_index(0);	// Auto
 | 
					
						
							| 
									
										
										
										
											2017-04-18 18:12:32 +01:00
										 |  |  | 			for (n = 0; n < 5; n++) { | 
					
						
							|  |  |  | 				litteral[n] = "       "; | 
					
						
							| 
									
										
										
										
											2016-07-28 05:25:33 +02:00
										 |  |  | 				checkboxes[n].set_value(true); | 
					
						
							| 
									
										
										
										
											2017-04-18 18:12:32 +01:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-07-25 16:21:27 +02:00
										 |  |  | 			set_dirty(); | 
					
						
							| 
									
										
										
										
											2016-07-27 21:26:03 +02:00
										 |  |  | 			start_tx(false); | 
					
						
							| 
									
										
										
										
											2016-07-25 16:21:27 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-08-28 20:50:42 +02:00
										 |  |  | 	}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } /* namespace ui */ |