Skip to content

Commit

Permalink
CVS Spam v0.2 (#2357)
Browse files Browse the repository at this point in the history
* Make the CVS Spam app

CHAOS.C16 is over 100mb and send to JLynx to be included in the sdcard ZIP file.

* indentation

* C16 files are perfect. Disregard any previous files for sdcard/CVSFILES. CHAOS now randomizes files to save space.

---------

Co-authored-by: sommermorgentraum <24917424+zxkmm@users.noreply.github.com>
  • Loading branch information
RocketGod-git and zxkmm authored Nov 14, 2024
1 parent 4641dcb commit c8f236a
Show file tree
Hide file tree
Showing 112 changed files with 50 additions and 32 deletions.
55 changes: 26 additions & 29 deletions firmware/application/external/cvs_spam/cvs_spam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "metadata_file.hpp"
#include "oversample.hpp"
#include "io_convert.hpp"
#include "lfsr_random.hpp"

using namespace portapack;

Expand Down Expand Up @@ -80,7 +81,7 @@ void CVSSpamView::start_tx(const uint32_t id) {
return;
}

const uint32_t sample_rate = 500000;
const uint32_t sample_rate = 250000;

current_file = cvsfiles_dir / file_list[id].filename();

Expand Down Expand Up @@ -149,36 +150,36 @@ void CVSSpamView::start_tx(const uint32_t id) {
});
}

void CVSSpamView::start_chaos_tx() {
void CVSSpamView::start_random_tx() {
if (is_active()) {
stop_tx();
return;
}

const std::filesystem::path chaos_file_path = cvsfiles_dir / "chaos.c16";
const uint32_t sample_rate = 500000;
if (file_list.empty()) {
nav_.display_modal("Error", "No files found!");
return;
}

lfsr_v = lfsr_iterate(lfsr_v);
size_t random_index = lfsr_v % file_list.size();

const uint32_t sample_rate = 250000;
current_file = cvsfiles_dir / file_list[random_index].filename();

File capture_file;
auto open_error = capture_file.open(chaos_file_path);
auto open_error = capture_file.open(current_file);
if (open_error) {
file_error(chaos_file_path,
"Cannot open CHAOS.C16.\n"
"Initial file check failed.\n"
"Path: " +
cvsfiles_dir.string() +
"\n"
"Error: " +
std::to_string(static_cast<uint32_t>(open_error)));
file_error(current_file, "Cannot open file.\nInitial check failed.");
return;
}

auto metadata_path = get_metadata_path(chaos_file_path);
auto metadata_path = get_metadata_path(current_file);
auto metadata = read_metadata_file(metadata_path);
if (!metadata) {
metadata = capture_metadata{transmitter_model.target_frequency(), sample_rate};
}

auto file_size = capture_file.size();
capture_file.close();

replay_thread.reset();
Expand All @@ -188,18 +189,8 @@ void CVSSpamView::start_chaos_tx() {
baseband::set_sample_rate(metadata->sample_rate, get_oversample_rate(metadata->sample_rate));

auto reader = std::make_unique<FileConvertReader>();
if (auto error = reader->open(chaos_file_path)) {
file_error(chaos_file_path,
"Cannot read CHAOS.C16.\n"
"Check file format/perms.\n"
"Rate: " +
to_string_dec_uint(metadata->sample_rate) +
"\n"
"Size: " +
to_string_dec_uint(file_size) +
"\n"
"Error: " +
std::to_string(static_cast<uint32_t>(error)));
if (auto error = reader->open(current_file)) {
file_error(current_file, "Cannot read file data.");
return;
}

Expand Down Expand Up @@ -241,9 +232,9 @@ bool CVSSpamView::is_active() const {
void CVSSpamView::stop_tx() {
replay_thread.reset();
transmitter_model.disable();
audio::output::stop();
ready_signal = false;
thread_sync_complete = false;
chaos_mode = false;
progressbar.set_value(0);
chThdSleepMilliseconds(50);
}
Expand Down Expand Up @@ -295,7 +286,13 @@ CVSSpamView::CVSSpamView(NavigationView& nav)
};

button_chaos.on_select = [this](Button&) {
start_chaos_tx();
if (is_active()) {
chaos_mode = false;
stop_tx();
} else {
chaos_mode = true;
start_random_tx();
}
};

button_stop.on_select = [this](Button&) {
Expand Down
27 changes: 24 additions & 3 deletions firmware/application/external/cvs_spam/cvs_spam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "baseband_api.hpp"
#include "ui_language.hpp"
#include "file_path.hpp"
#include "audio.hpp"

using namespace portapack;

Expand All @@ -29,6 +28,9 @@ class CVSSpamView : public View {
static constexpr size_t read_size = 0x4000;
static constexpr size_t buffer_count = 3;

lfsr_word_t lfsr_v = 1;
bool chaos_mode{false};

NavigationView& nav_;
std::unique_ptr<ReplayThread> replay_thread{};
bool ready_signal{false};
Expand All @@ -40,7 +42,7 @@ class CVSSpamView : public View {
void file_error(const std::filesystem::path& path, const std::string& error_details);
void refresh_list();
void start_tx(const uint32_t id);
void start_chaos_tx();
void start_random_tx();
void on_tx_progress(const uint32_t progress);

uint32_t page = 1;
Expand Down Expand Up @@ -102,12 +104,31 @@ class CVSSpamView : public View {
[this](const Message* const p) {
const auto message = *reinterpret_cast<const ReplayThreadDoneMessage*>(p);
if (message.return_code == ReplayThread::END_OF_FILE) {
if (is_active()) {
if (chaos_mode) {
replay_thread.reset();
transmitter_model.disable();
ready_signal = false;
lfsr_v = lfsr_iterate(lfsr_v);
size_t random_index = lfsr_v % file_list.size();
menu_view.set_highlighted(random_index);
chThdSleepMilliseconds(100);
start_tx(random_index);
} else {
thread_sync_complete = true;
stop_tx();
}
} else if (message.return_code == ReplayThread::READ_ERROR) {
file_error(file_list[menu_view.highlighted_index()], "Read error during playback");
if (chaos_mode) {
replay_thread.reset();
transmitter_model.disable();
ready_signal = false;
lfsr_v = lfsr_iterate(lfsr_v);
size_t random_index = lfsr_v % file_list.size();
menu_view.set_highlighted(random_index);
chThdSleepMilliseconds(100);
start_tx(random_index);
}
}
}};
};
Expand Down
Binary file added sdcard/CVSFILES/Aisle_Eight_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Eight_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Eighteen_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Eleven_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Eleven_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Fifteen_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Five_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Five_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Four_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Fourteen_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Nine_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Nineteen_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_One_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_One_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Seven_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Seven_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Seventeen_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Six_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Six_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Sixteen_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Ten_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Ten_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Thirteen_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Three_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Three_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Twelve_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Twelve_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Twenty_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Two_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Aisle_Two_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Allergy_Department_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Baby_Formula_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Baby_Formula_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Batteries_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Batteries_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Body_Wash_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Body_Wash_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Cosmetics_Department_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Cough_Cold_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Cough_Cold_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Dental_Care_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Dental_Care_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Deodorants_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Deodorants_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Ding_1_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Electric_Razors_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Electronics_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Electronics_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Eye_Care_Department_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Family_Planning_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Film_Department_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/First_Aid_Department_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Foot_Care_Department_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Hair-Care_Department_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Liquor_Department_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Skin_Care_Department_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Small_Appliances_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Special_Ding_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Stationery_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Stationery_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/Stomach_Remedies_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/Vitamin_Department_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/the_Fragrance_Case_ENGLISH.C16
Binary file not shown.
Binary file not shown.
Binary file added sdcard/CVSFILES/the_Pharmacy_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/the_Pharmacy_ENGLISH_SPANISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/the_Photo_Lab_ENGLISH.C16
Binary file not shown.
Binary file added sdcard/CVSFILES/the_Photo_Lab_ENGLISH_SPANISH.C16
Binary file not shown.

0 comments on commit c8f236a

Please sign in to comment.