Skip to content

Commit

Permalink
Band plans alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryzerth committed Aug 5, 2020
1 parent 3aa8ce8 commit a9c82ec
Show file tree
Hide file tree
Showing 8 changed files with 404 additions and 3 deletions.
7 changes: 7 additions & 0 deletions band_colors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"broadcast": "#0000FFFF",
"amateur": "#FF0000FF",
"aviation": "#00FF00FF",
"marine": "#00FFFFFF",
"military": "#FFFF00FF"
}
267 changes: 267 additions & 0 deletions bandplans/general.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
{
"name": "General",
"country_name": "Worldwide",
"country_code": "--",
"author_name": "Ryzerth",
"author_url": "https://github.com/AlexandreRouma",
"bands": [
{
"name": "Long Wave",
"type": "broadcast",
"start": 148500,
"end": 283500
},
{
"name": "Medium Wave",
"type": "broadcast",
"start": 526500,
"end": 1606500
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 2300000,
"end": 2468000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 3200000,
"end": 3400000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 3950000,
"end": 4000000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 4750000,
"end": 4995000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 5005000,
"end": 5060000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 5900000,
"end": 6200000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 7200000,
"end": 7450000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 9400000,
"end": 9900000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 11600000,
"end": 12100000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 13570000,
"end": 13870000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 15100000,
"end": 15800000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 17480000,
"end": 17900000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 18900000,
"end": 19020000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 21450000,
"end": 21850000
},
{
"name": "Shortwave Broadcast",
"type": "broadcast",
"start": 25670000,
"end": 26100000
},
{
"name": "FM Broadcast",
"type": "broadcast",
"start": 87500000,
"end": 108000000
},
{
"name": "Air Band VOR/ILS",
"type": "aviation",
"start": 108000000,
"end": 118000000
},
{
"name": "Air Band Voice",
"type": "aviation",
"start": 118000000,
"end": 137000000
},
{
"name": "160m Ham Band",
"type": "amateur",
"start": 1800000,
"end": 2000000
},
{
"name": "80m Ham Band",
"type": "amateur",
"start": 3500000,
"end": 3950000
},
{
"name": "60m Ham Band",
"type": "amateur",
"start": 5351500,
"end": 5366500
},
{
"name": "40m Ham Band",
"type": "amateur",
"start": 7000000,
"end": 7200000
},
{
"name": "30m Ham Band",
"type": "amateur",
"start": 10100000,
"end": 10150000
},
{
"name": "20m Ham Band",
"type": "amateur",
"start": 14000000,
"end": 14350000
},
{
"name": "17m Ham Band",
"type": "amateur",
"start": 18068000,
"end": 18168000
},
{
"name": "15m Ham Band",
"type": "amateur",
"start": 21000000,
"end": 21450000
},
{
"name": "12m Ham Band",
"type": "amateur",
"start": 24890000,
"end": 24990000
},
{
"name": "CB",
"type": "amateur",
"start": 26960000,
"end": 27410000
},
{
"name": "10m Ham Band",
"type": "amateur",
"start": 28000000,
"end": 29750000
},
{
"name": "6m Ham Band",
"type": "amateur",
"start": 50000000,
"end": 54000000
},
{
"name": "2m Ham Band",
"type": "amateur",
"start": 144000000,
"end": 148000000
},
{
"name": "Marine",
"type": "marine",
"start": 156000000,
"end": 162025000
},
{
"name": "1.25m Ham Band",
"type": "amateur",
"start": 222000000,
"end": 225000000
},
{
"name": "Military Air",
"type": "military",
"start": 225000000,
"end": 380000000
},
{
"name": "Military Sat",
"type": "military",
"start": 240000000,
"end": 270000000
},
{
"name": "70cm Ham Band",
"type": "amateur",
"start": 420000000,
"end": 450000000
},
{
"name": "PMR446",
"type": "amateur",
"start": 446000000,
"end": 446200000
},
{
"name": "33cm Ham Band",
"type": "amateur",
"start": 902000000,
"end": 928000000
},
{
"name": "23cm Ham Band",
"type": "amateur",
"start": 1240000000,
"end": 1300000000
},
{
"name": "13cm Ham Band",
"type": "amateur",
"start": 2300000000,
"end": 2310000000
},
{
"name": "13cm Ham Band",
"type": "amateur",
"start": 2390000000,
"end": 2450000000
}
]
}
36 changes: 36 additions & 0 deletions src/bandplan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace bandplan {
std::map<std::string, BandPlan_t> bandplans;
std::vector<std::string> bandplanNames;
std::string bandplanNameTxt;
std::map<std::string, BandPlanColor_t> colorTable;

void generateTxt() {
bandplanNameTxt = "";
Expand Down Expand Up @@ -49,6 +50,24 @@ namespace bandplan {
j.at("bands").get_to(b.bands);
}

void to_json(json& j, const BandPlanColor_t& ct) {
spdlog::error("ImGui color to JSON not implemented!!!");
}

void from_json(const json& j, BandPlanColor_t& ct) {
std::string col = j.get<std::string>();
if (col[0] != '#' || !std::all_of(col.begin() + 1, col.end(), ::isxdigit)) {
return;
}
uint8_t r, g, b, a;
r = std::stoi(col.substr(1, 2), NULL, 16);
g = std::stoi(col.substr(3, 2), NULL, 16);
b = std::stoi(col.substr(5, 2), NULL, 16);
a = std::stoi(col.substr(7, 2), NULL, 16);
ct.colorValue = IM_COL32(r, g, b, a);
ct.transColorValue = IM_COL32(r, g, b, 100);
}

void loadBandPlan(std::string path) {
std::ifstream file(path.c_str());
json data;
Expand Down Expand Up @@ -83,4 +102,21 @@ namespace bandplan {
loadBandPlan(path);
}
}

void loadColorTable(std::string path) {
if (!std::filesystem::exists(path)) {
spdlog::error("Band Plan Color Table file does not exist");
return;
}
if (!std::filesystem::is_regular_file(path)) {
spdlog::error("Band Plan Color Table file isn't a file...");
return;
}
std::ifstream file(path.c_str());
json data;
data << file;
file.close();

colorTable = data.get<std::map<std::string, BandPlanColor_t>>();
}
};
13 changes: 13 additions & 0 deletions src/bandplan.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include <fstream>
#include <spdlog/spdlog.h>
#include <filesystem>
#include <sstream>
#include <iomanip>
#include <imgui/imgui.h>

using nlohmann::json;

Expand All @@ -28,11 +31,21 @@ namespace bandplan {

void to_json(json& j, const BandPlan_t& b);
void from_json(const json& j, BandPlan_t& b);

struct BandPlanColor_t {
uint32_t colorValue;
uint32_t transColorValue;
};

void to_json(json& j, const BandPlanColor_t& ct);
void from_json(const json& j, BandPlanColor_t& ct);

void loadBandPlan(std::string path);
void loadFromDir(std::string path);
void loadColorTable(std::string path);

extern std::map<std::string, BandPlan_t> bandplans;
extern std::vector<std::string> bandplanNames;
extern std::string bandplanNameTxt;
extern std::map<std::string, BandPlanColor_t> colorTable;
};
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ int main() {
spdlog::info("Loading band plans");
bandplan::loadFromDir("bandplans");

spdlog::info("Loading band plans color table");
bandplan::loadColorTable("band_colors.json");

spdlog::info("Ready.");

// Main loop
Expand Down
Loading

0 comments on commit a9c82ec

Please sign in to comment.