diff --git a/firmware/Makefile b/firmware/Makefile index 0def504ce..5bce1a9fc 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -65,7 +65,7 @@ modules: $(TARGET_BASEBAND).bin $(TARGET_BASEBAND_TX).bin cp $(PATH_BASEBAND_TX).bin ../sdcard/$(PATH_BASEBAND_TX).bin $(TARGET).bin: modules $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND_TX)_inc.bin $(TARGET_APPLICATION).bin - $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND_TX)_inc.bin $(TARGET_APPLICATION).bin $(TARGET).bin + $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND)_inc.bin $(TARGET_APPLICATION).bin $(TARGET).bin $(TARGET_BOOTSTRAP).bin: $(TARGET_BOOTSTRAP).elf $(CP) -O binary $(TARGET_BOOTSTRAP).elf $(TARGET_BOOTSTRAP).bin diff --git a/firmware/application/Makefile b/firmware/application/Makefile index 0d2b97d48..553af8458 100755 --- a/firmware/application/Makefile +++ b/firmware/application/Makefile @@ -138,6 +138,7 @@ CPPSRC = main.cpp \ radio.cpp \ baseband_cpld.cpp \ tuning.cpp \ + msgpack.cpp \ rf_path.cpp \ rffc507x.cpp \ rffc507x_spi.cpp \ diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index 412c74bc9..622fccf25 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -21,8 +21,8 @@ //BUG: No audio in about when shown second time //BUG: Description doesn't show up first time going to system>module info (UI drawn on top) -//BUG: Module load and return to systemview -//TODO: EPAR transmit +//TODO: SD card wiper +//TODO: Draw on touchscreen and transmit as spectrum paint //TODO: Use progressbars //TODO: Setting: Prefered input method //TODO: LCR emergency clear all diff --git a/firmware/application/transmitter_model.cpp b/firmware/application/transmitter_model.cpp index 7ed7f2e0e..22a9a442b 100644 --- a/firmware/application/transmitter_model.cpp +++ b/firmware/application/transmitter_model.cpp @@ -103,10 +103,6 @@ uint32_t TransmitterModel::baseband_oversampling() const { return baseband_configuration.decimation_factor; } -int32_t TransmitterModel::tuning_offset() { - return -(sampling_rate() / 4); -} - void TransmitterModel::update_tuning_frequency() { radio::set_tuning_frequency(tuning_frequency()); } diff --git a/firmware/application/transmitter_model.hpp b/firmware/application/transmitter_model.hpp index a4eae0f08..3de71bfdb 100644 --- a/firmware/application/transmitter_model.hpp +++ b/firmware/application/transmitter_model.hpp @@ -70,7 +70,6 @@ private: .sampling_rate = 3072000, .decimation_factor = 1, }; - int32_t tuning_offset(); void update_tuning_frequency(); void update_rf_amp(); diff --git a/firmware/application/ui_closecall.cpp b/firmware/application/ui_closecall.cpp index 79e837e90..629f1f3d5 100644 --- a/firmware/application/ui_closecall.cpp +++ b/firmware/application/ui_closecall.cpp @@ -22,6 +22,7 @@ #include "ui_closecall.hpp" #include "ui_receiver.hpp" +#include "msgpack.hpp" #include "ch.h" #include "time.hpp" @@ -59,8 +60,6 @@ void CloseCallView::do_detection() { rf::Frequency resolved_frequency; size_t i; - portapack::display.fill_rectangle({last_pos, 92, 1, 9}, Color::black()); - mean /= (CC_BIN_NB * (slices_max + 1)); for (i = 0; i < (slices_max + 1); i++) { @@ -87,7 +86,7 @@ void CloseCallView::do_detection() { // Lock / release if ((imax >= last_channel - 2) && (imax <= last_channel + 2) && imax) { - if (detect_counter == 8) { + if (detect_counter >= (5 / (slices_max + 1))) { if (imax != locked_frequency) { //char finalstr[24] = {0}; @@ -100,6 +99,7 @@ void CloseCallView::do_detection() { //strcat(finalstr, fstr.c_str()); text_infos.set("Locked ! "); big_display.set(resolved_frequency); + big_display.set_style(&style_locked); locked = true; locked_frequency = imax; @@ -114,7 +114,7 @@ void CloseCallView::do_detection() { if (release_counter == 8) { locked = false; text_infos.set("Lost "); - //big_display.set(0); + big_display.set_style(&style_grey); } else { release_counter++; } @@ -124,8 +124,9 @@ void CloseCallView::do_detection() { last_channel = imax; scan_counter++; - last_pos = (ui::Coord)(imax + 2); - portapack::display.fill_rectangle({last_pos, 92, 1, 9}, Color::red()); + portapack::display.fill_rectangle({last_pos, 90, 1, 13}, Color::black()); + last_pos = (ui::Coord)(imax % 240); + portapack::display.fill_rectangle({last_pos, 90, 1, 13}, Color::red()); } void CloseCallView::on_channel_spectrum(const ChannelSpectrum& spectrum) { @@ -148,7 +149,7 @@ void CloseCallView::on_channel_spectrum(const ChannelSpectrum& spectrum) { } display.draw_pixels( - { { 0, 96 + slices_counter * 4 }, { pixel_row.size(), 1 } }, + { { 0, 96 + slices_counter * 6 }, { pixel_row.size(), 1 } }, pixel_row ); @@ -247,8 +248,18 @@ void CloseCallView::on_range_changed() { // ex: 100~115 (15): 102.5(97.5~107.5) -> 112.5(107.5~117.5) = 2.5 lost left and right slices_max = (scan_span + CC_SLICE_WIDTH - 1) / CC_SLICE_WIDTH; slices_span = slices_max * CC_SLICE_WIDTH; - offset = (slices_span - scan_span) / 2; + offset = ((scan_span - slices_span) / 2) + (CC_SLICE_WIDTH / 2); slice_start = std::min(f_min, f_max) + offset; + slice_trim = 0; + + /* + * ----||||---- 4M -> 2*3M = 6 + * AAABBB 4-6 = -2 -> -2/2 = -1 -> -1+1.5 = +0.5 + * + * ----1111222233334444---- + * AAAAaaaaAAAAbbbbBBBBbbbb + * + */ slices_max--; // For slices_counter slicing = true; @@ -267,12 +278,14 @@ void CloseCallView::on_range_changed() { portapack::display.fill_rectangle({0, 97, slice_trim, 4}, Color::orange()); portapack::display.fill_rectangle({240 - slice_trim, 97, slice_trim, 4}, Color::orange()); + set_dirty(); + slices_max = 0; slices_counter = 0; slicing = false; } - text_debug.set(to_string_dec_uint(slice_start)); + //text_debug.set(to_string_dec_uint(slice_start)); text_slices.set(to_string_dec_int(slices_max + 1)); slices_counter = 0; @@ -312,12 +325,22 @@ CloseCallView::CloseCallView( &button_exit } }); - static constexpr Style style_grey { - .font = font::fixed_8x16, - .background = Color::black(), - .foreground = Color::grey(), - }; - + uint8_t testbuffer[] = { 0xDE, 0x00, 0x02, + 0xCD, 0x00, 0x00, // Key 0000 = False + 0xC2, + 0xCD, 0x00, 0x01, // Key 0001 = True + 0xC3 + }; + + // DEBUG + bool debug_v; + MsgPack msgpack; + msgpack.msgpack_get(&testbuffer, sizeof(testbuffer), MsgPack::TestList, &debug_v); // MsgPack::FrequencyList + if (debug_v) + text_debug.set("OK!"); + else + text_debug.set("NOK"); + text_labels_a.set_style(&style_grey); text_labels_b.set_style(&style_grey); text_labels_c.set_style(&style_grey); diff --git a/firmware/application/ui_closecall.hpp b/firmware/application/ui_closecall.hpp index 49a557b8f..26746327f 100644 --- a/firmware/application/ui_closecall.hpp +++ b/firmware/application/ui_closecall.hpp @@ -20,17 +20,6 @@ * Boston, MA 02110-1301, USA. */ -/*#include "ui.hpp" -#include "ui_widget.hpp" -#include "ui_painter.hpp" -#include "ui_menu.hpp" -#include "ui_navigation.hpp" -#include "clock_manager.hpp" -#include "message.hpp" -#include "rf_path.hpp" -#include "volume.hpp" -#include "receiver_model.hpp"*/ - #include "receiver_model.hpp" #include "spectrum_color_lut.hpp" @@ -58,6 +47,17 @@ public: std::string title() const override { return "Close Call"; }; private: + const Style style_grey { // For labels and lost signal + .font = font::fixed_8x16, + .background = Color::black(), + .foreground = Color::grey(), + }; + + const Style style_locked { + .font = font::fixed_8x16, + .background = Color::black(), + .foreground = Color::green(), + }; Coord last_pos = 0; ChannelSpectrumFIFO* fifo { nullptr }; uint8_t detect_counter = 0, release_counter = 0; @@ -89,7 +89,7 @@ private: * | Min: Max: LNA VGA | * | 0000.0000 0000.0000 00 00 | * | Threshold: 000 | - * | Slices: 00 Rate: 000Hz | + * | Slices: 00 Rate: 00Hz | * | * */ @@ -103,7 +103,7 @@ private: }; Text text_labels_c { { 1 * 8, 3 * 16, 28 * 8, 16 }, - "Slices: Rate: Hz" + "Slices: Rate: Hz" }; NumberField field_threshold { @@ -133,8 +133,8 @@ private: "--" }; Text text_rate { - { 24 * 8, 3 * 16, 3 * 8, 16 }, - "---" + { 24 * 8, 3 * 16, 2 * 8, 16 }, + "--2" }; Text text_infos { diff --git a/firmware/application/ui_epar.cpp b/firmware/application/ui_epar.cpp index 70ea8f8e2..07d1982dc 100644 --- a/firmware/application/ui_epar.cpp +++ b/firmware/application/ui_epar.cpp @@ -96,6 +96,10 @@ void EPARView::journuit() { transmitter_model.enable(); } +void EPARView::on_tuning_frequency_changed(rf::Frequency f) { + receiver_model.set_tuning_frequency(f); +} + EPARView::EPARView( NavigationView& nav ) @@ -125,8 +129,10 @@ EPARView::EPARView( &options_group, &checkbox_ra, &checkbox_rb, + &excur, &text_freq, - &options_freq, + //&options_freq, + &field_frequency, &progressbar, &text_debug, &button_transmit, @@ -136,10 +142,31 @@ EPARView::EPARView( city_code.set_value(220); options_group.set_selected_index(3); // TP - options_freq.set_selected_index(6); // 5 ! DEBUG + //options_freq.set_selected_index(6); // 5 ! DEBUG checkbox_ra.set_value(true); checkbox_rb.set_value(true); + + excur.set_value(500); + shared_memory.excursion = 500; + excur.on_change = [this](int32_t v) { + (void)v; + shared_memory.excursion = excur.value(); + }; + + field_frequency.set_value(31387500); // 31.3805 receiver_model.tuning_frequency() + field_frequency.set_step(500); + field_frequency.on_change = [this](rf::Frequency f) { + this->on_tuning_frequency_changed(f); + }; + field_frequency.on_edit = [this, &nav]() { + // TODO: Provide separate modal method/scheme? + auto new_view = nav.push(receiver_model.tuning_frequency()); + new_view->on_changed = [this](rf::Frequency f) { + this->on_tuning_frequency_changed(f); + this->field_frequency.set_value(f); + }; + }; city_code.on_change = [this](int32_t v) { (void)v; @@ -189,7 +216,8 @@ EPARView::EPARView( shared_memory.transmit_done = false; memcpy(shared_memory.epardata, epar_bits, 13); - transmitter_model.set_tuning_frequency(epar_freqs[options_freq.selected_index()]); + transmitter_model.set_tuning_frequency(field_frequency.value()); + //transmitter_model.set_tuning_frequency(epar_freqs[options_freq.selected_index()]); txing = true; button_transmit.set_style(&style_cancel); diff --git a/firmware/application/ui_epar.hpp b/firmware/application/ui_epar.hpp index d9d5762fc..a3ce96e54 100644 --- a/firmware/application/ui_epar.hpp +++ b/firmware/application/ui_epar.hpp @@ -26,6 +26,7 @@ #include "ui_menu.hpp" #include "ui_navigation.hpp" #include "ui_font_fixed_8x16.hpp" +#include "ui_receiver.hpp" #include "clock_manager.hpp" #include "message.hpp" #include "rf_path.hpp" @@ -51,6 +52,7 @@ private: bool txing = false; const rf::Frequency epar_freqs[7] = { 31325000, 31387500, 31437500, 31475000, 31687500, 31975000, 88000000 }; char epar_bits[13]; + void on_tuning_frequency_changed(rf::Frequency f); /* |012345678901234567890123456789| * | Code ville: 000 | @@ -88,7 +90,10 @@ private: { 5 * 8, 4 * 16, 10 * 8, 16 }, "Frequence:" }; - OptionsField options_freq { + FrequencyField field_frequency { + { 16 * 8, 4 * 16 }, + }; + /*OptionsField options_freq { { 16 * 8, 4 * 16}, 7, { @@ -100,7 +105,7 @@ private: { "31.9750", 5 }, { "TEST 88", 6 } } - }; + };*/ Checkbox checkbox_ra { { 7 * 8, 6 * 16 }, @@ -113,6 +118,14 @@ private: "Relais 2" }; + NumberField excur { + { 12 * 8, 10 * 16 }, + 4, + { 0, 5000 }, + 20, + ' ' + }; + ProgressBar progressbar { { 2 * 8, 12 * 16, 26 * 8, 20 }, }; diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 5ea4446b5..4b9956205 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -35,6 +35,7 @@ #include "ui_handwrite.hpp" // DEBUG #include "ui_soundboard.hpp" // DEBUG +#include "ui_closecall.hpp" // DEBUG #include "analog_audio_app.hpp" #include "ais_app.hpp" @@ -263,6 +264,7 @@ SystemView::SystemView( navigation_view.push(); else //navigation_view.push(); + //navigation_view.push(); //navigation_view.push(debugtxt, 20); navigation_view.push(); } diff --git a/firmware/baseband-tx.bin b/firmware/baseband-tx.bin index b8c8e5b9b..de0e480ba 100644 Binary files a/firmware/baseband-tx.bin and b/firmware/baseband-tx.bin differ diff --git a/firmware/baseband-tx/proc_epar.cpp b/firmware/baseband-tx/proc_epar.cpp index d186228f1..124ef078b 100644 --- a/firmware/baseband-tx/proc_epar.cpp +++ b/firmware/baseband-tx/proc_epar.cpp @@ -78,7 +78,7 @@ void EPARProcessor::execute(const buffer_c8_t& buffer) { } else { current_tu++; } - sample = 0; + sample = -127; } sample_count = 0; @@ -91,7 +91,7 @@ void EPARProcessor::execute(const buffer_c8_t& buffer) { } //FM - frq = sample * 1000; // ~25kHz wide + frq = sample * shared_memory.excursion; // 500=~3kHz wide phase = (phase + frq); sphase = phase + (256<<16); diff --git a/firmware/baseband-tx/proc_epar.hpp b/firmware/baseband-tx/proc_epar.hpp index d1b060d03..257f6de40 100644 --- a/firmware/baseband-tx/proc_epar.hpp +++ b/firmware/baseband-tx/proc_epar.hpp @@ -49,9 +49,9 @@ public: void execute(const buffer_c8_t& buffer) override; private: - const uint8_t bitdef[2][3] = { - {0, 255, 255}, - {0, 0, 255} + const int8_t bitdef[2][3] = { + {-127, 127, 127}, + {-127, -127, 127} }; int8_t re, im; uint8_t s; diff --git a/firmware/common/modules.h b/firmware/common/modules.h index dfb335a0b..ebee39f4c 100644 --- a/firmware/common/modules.h +++ b/firmware/common/modules.h @@ -1,2 +1,2 @@ const char md5_baseband[16] = {0x07,0xff,0xf6,0x7f,0x06,0x02,0xd1,0xd7,0x67,0x8f,0x67,0xdc,0xe8,0x36,0xa9,0xc0,}; -const char md5_baseband_tx[16] = {0xac,0xaf,0x2a,0x20,0x45,0x35,0x18,0x9c,0xdf,0x02,0x5c,0x2c,0x8f,0x76,0xd3,0xdc,}; +const char md5_baseband_tx[16] = {0x72,0xf5,0x35,0x17,0x37,0x57,0xd7,0x28,0x5f,0xc5,0x8a,0xc0,0x0b,0x71,0xd4,0xd1,}; diff --git a/firmware/common/msgpack.cpp b/firmware/common/msgpack.cpp new file mode 100644 index 000000000..93b9e1e56 --- /dev/null +++ b/firmware/common/msgpack.cpp @@ -0,0 +1,211 @@ +/* + * Copyright (C) 2015 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. + */ + +#include "msgpack.hpp" + +#include + +bool MsgPack::get_bool(const void * buffer, const bool inc, bool * value) { + uint8_t v; + + if (seek_ptr >= buffer_size) return false; // End of buffer + + v = ((uint8_t*)buffer)[seek_ptr]; + if (v == MSGPACK_FALSE) + *value = false; + else if (v == MSGPACK_TRUE) + *value = true; + else + return false; // Not a bool + + if (inc) seek_ptr++; + return true; +} + +bool MsgPack::get_raw_byte(const void * buffer, const bool inc, uint8_t * byte) { + if (seek_ptr >= buffer_size) return false; // End of buffer + *byte = ((uint8_t*)buffer)[seek_ptr]; + if (inc) seek_ptr++; + return true; +} + +bool MsgPack::get_raw_word(const void * buffer, const bool inc, uint16_t * word) { + if ((seek_ptr + 1) >= buffer_size) return false; // End of buffer + *word = (((uint8_t*)buffer)[seek_ptr] << 8) | ((uint8_t*)buffer)[seek_ptr + 1]; + if (inc) seek_ptr += 2; + return true; +} + +bool MsgPack::get_u16(const void * buffer, const bool inc, uint16_t * value) { + uint8_t byte; + + if ((seek_ptr + 1) >= buffer_size) return false; // End of buffer + if ((get_raw_byte(buffer, true, &byte)) && (byte != MSGPACK_TYPE_U16)) return false; // Value isn't a u16 + *value = (((uint8_t*)buffer)[seek_ptr] << 8) | ((uint8_t*)buffer)[seek_ptr + 1]; + if (inc) seek_ptr += 2; + return true; +} + +bool MsgPack::get_s32(const void * buffer, const bool inc, int32_t * value) { + uint8_t byte; + + if ((seek_ptr + 3) >= buffer_size) return false; // End of buffer + if ((get_raw_byte(buffer, true, &byte)) && (byte != MSGPACK_TYPE_S32)) return false; // Value isn't a s32 + *value = (((uint8_t*)buffer)[seek_ptr] << 24) | (((uint8_t*)buffer)[seek_ptr + 1] << 16) | + (((uint8_t*)buffer)[seek_ptr + 2] << 8) | ((uint8_t*)buffer)[seek_ptr + 3]; + if (inc) seek_ptr += 4; + return true; +} + +bool MsgPack::get_s64(const void * buffer, const bool inc, int64_t * value) { + uint8_t byte; + + if ((seek_ptr + 3) >= buffer_size) return false; // End of buffer + if ((get_raw_byte(buffer, true, &byte)) && (byte != MSGPACK_TYPE_S64)) return false; // Value isn't a s64 + *value = ((int64_t)((uint8_t*)buffer)[seek_ptr] << 56) | ((int64_t)((uint8_t*)buffer)[seek_ptr + 1] << 48) | + ((int64_t)((uint8_t*)buffer)[seek_ptr + 2] << 40) | ((int64_t)((uint8_t*)buffer)[seek_ptr + 3] << 32) | + (((uint8_t*)buffer)[seek_ptr + 4] << 24) | (((uint8_t*)buffer)[seek_ptr + 5] << 16) | + (((uint8_t*)buffer)[seek_ptr + 6] << 8) | ((uint8_t*)buffer)[seek_ptr + 7]; + if (inc) seek_ptr += 8; + return true; +} + +bool MsgPack::get_chars(const void * buffer, const bool inc, char * value) { + size_t length; + uint8_t byte; + + // Todo: Set max length ! + if ((seek_ptr + 3) >= buffer_size) return false; // End of buffer + if ((get_raw_byte(buffer, true, &byte)) && (byte != MSGPACK_TYPE_STR8) + && (byte != MSGPACK_TYPE_STR16)) return false; // Value isn't a str8 or str16 + + if (byte == MSGPACK_TYPE_STR8) { + if (!get_raw_byte(buffer, true, (uint8_t*)&length)) return false; // Couldn't get str8 length + } else { + if (!get_raw_word(buffer, true, (uint16_t*)&length)) return false; // Couldn't get str16 length + } + + memcpy(value, ((uint8_t*)buffer), length); + + if (inc) seek_ptr += length; + return true; +} + +bool MsgPack::init_search(const void * buffer, const size_t size) { + uint8_t byte; + uint16_t map_size; // Unused for now + + if (!size) return false; + buffer_size = size; + seek_ptr = 0; + if ((get_raw_byte(buffer, true, &byte)) && (byte != MSGPACK_TYPE_MAP16)) return false; // First record isn't a map16 + if (!get_raw_word(buffer, true, &map_size)) return false; // Couldn't get map16 size + + return true; +} + +bool MsgPack::skip(const void * buffer) { + uint8_t byte; + size_t length; + + if (!get_raw_byte(buffer, true, &byte)) return false; // Couldn't get type + + switch (byte) { + case MSGPACK_FALSE: + case MSGPACK_TRUE: + return true; // Already skipped by get_raw_byte + break; + case MSGPACK_TYPE_U16: + seek_ptr += 2; + break; + case MSGPACK_TYPE_S32: + seek_ptr += 4; + break; + case MSGPACK_TYPE_S64: + seek_ptr += 8; + break; + + case MSGPACK_TYPE_STR8: + if (!get_raw_byte(buffer, true, (uint8_t*)&length)) return false; // Couldn't get str8 length + seek_ptr += length; + break; + case MSGPACK_TYPE_STR16: + if (!get_raw_word(buffer, true, (uint16_t*)&length)) return false; // Couldn't get str16 length + seek_ptr += length; + break; + + default: + return false; // Type unsupported + } + + return true; +} + +bool MsgPack::search_key(const void * buffer, const MsgPack::RecID record_id) { + uint8_t byte; + uint16_t key; + + while (get_raw_byte(buffer, true, &byte)) { + if (byte == MSGPACK_TYPE_U16) { + if (!get_u16(buffer, true, &key)) return false; // Couldn't get key + if (key == record_id) return true; // Found record + if (!skip(buffer)) return false; // Can't skip to next key + } else { + return false; // Key wasn't a U16 + } + }; + return false; +} + +bool MsgPack::msgpack_get(const void * buffer, const size_t size, const MsgPack::RecID record_id, bool * value) { + init_search(buffer, size); + if (!search_key(buffer, record_id)) return false; // Record not found + *value = true; + return true; + if (!get_bool(buffer, false, value)) return false; // Value isn't a bool + + return true; +} + +bool MsgPack::msgpack_get(const void * buffer, size_t size, RecID record_id, int32_t * value) { + init_search(buffer, size); + if (!search_key(buffer, record_id)) return false; // Record not found + if (!get_s32(buffer, false, value)) return false; // Value isn't a s32 + + return true; +} + +bool MsgPack::msgpack_get(const void * buffer, size_t size, RecID record_id, int64_t * value) { + init_search(buffer, size); + if (!search_key(buffer, record_id)) return false; // Record not found + if (!get_s64(buffer, false, value)) return false; // Value isn't a s64 + + return true; +} + +bool MsgPack::msgpack_get(const void * buffer, size_t size, RecID record_id, char * value) { + init_search(buffer, size); + if (!search_key(buffer, record_id)) return false; // Record not found + if (!get_chars(buffer, false, value)) return false; // Value isn't a char array + + return true; +} diff --git a/firmware/common/msgpack.hpp b/firmware/common/msgpack.hpp new file mode 100644 index 000000000..ae8a3ed11 --- /dev/null +++ b/firmware/common/msgpack.hpp @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2015 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. + */ + +#ifndef __MSGPACK_H__ +#define __MSGPACK_H__ + +#include "ui.hpp" +#include + +#define MSGPACK_TYPE_U16 0xcd +#define MSGPACK_TYPE_U32 0xce +#define MSGPACK_TYPE_S32 0xd2 +#define MSGPACK_TYPE_S64 0xd3 +#define MSGPACK_TYPE_STR8 0xd9 +#define MSGPACK_TYPE_STR16 0xda + +#define MSGPACK_TYPE_MAP16 0xde + +#define MSGPACK_FALSE 0xc2 +#define MSGPACK_TRUE 0xc3 + +class MsgPack { +public: + + enum RecID { + FrequencyList = 0, + TestList = 1 + }; + + bool msgpack_get(const void * buffer, const size_t size, const MsgPack::RecID record_id, bool * value); + bool msgpack_get(const void * buffer, const size_t size, const RecID record_id, int32_t * value); + bool msgpack_get(const void * buffer, const size_t size, const RecID record_id, int64_t * value); + bool msgpack_get(const void * buffer, const size_t size, const RecID record_id, char * value); + +private: + bool get_raw_byte(const void * buffer, const bool inc, uint8_t * byte); + bool get_raw_word(const void * buffer, const bool inc, uint16_t * word); + bool get_bool(const void * buffer, const bool inc, bool * value); + bool get_u16(const void * buffer, const bool inc, uint16_t * value); + bool get_s32(const void * buffer, const bool inc, int32_t * value); + bool get_s64(const void * buffer, const bool inc, int64_t * value); + bool get_chars(const void * buffer, const bool inc, char * value); + + bool init_search(const void * buffer, const size_t size); + bool search_key(const void * buffer, const RecID record_id); + bool skip(const void * buffer); + + size_t seek_ptr = 0; + size_t buffer_size; +}; + +#endif diff --git a/firmware/common/portapack_shared_memory.hpp b/firmware/common/portapack_shared_memory.hpp index 26492d7c7..acc2881ab 100644 --- a/firmware/common/portapack_shared_memory.hpp +++ b/firmware/common/portapack_shared_memory.hpp @@ -68,6 +68,7 @@ struct SharedMemory { char xylosdata[21]; char epardata[13]; + int32_t excursion; bool transmit_done; }; diff --git a/firmware/common/ui_widget.hpp b/firmware/common/ui_widget.hpp index 0ba7185d6..d9602f52c 100644 --- a/firmware/common/ui_widget.hpp +++ b/firmware/common/ui_widget.hpp @@ -215,7 +215,6 @@ public: ProgressBar(Rect parent_rect); void set_value(const uint16_t value); - uint16_t value() const; void paint(Painter& painter) override; @@ -230,7 +229,6 @@ public: Checkbox(Point parent_pos, size_t length, std::string text); void set_text(const std::string value); - void set_style(const Style* new_style); std::string text() const; void set_value(const bool value); bool value() const; diff --git a/firmware/portapack-h1-firmware.bin b/firmware/portapack-h1-firmware.bin index b3d7bdade..847e83ff6 100644 Binary files a/firmware/portapack-h1-firmware.bin and b/firmware/portapack-h1-firmware.bin differ diff --git a/sdcard/baseband-tx.bin b/sdcard/baseband-tx.bin index b8c8e5b9b..de0e480ba 100644 Binary files a/sdcard/baseband-tx.bin and b/sdcard/baseband-tx.bin differ