ggwave : remove <map> header dependency

This commit is contained in:
Georgi Gerganov
2022-05-30 22:52:12 +03:00
parent 4f94634611
commit 676163cc65
9 changed files with 116 additions and 93 deletions

View File

@@ -344,12 +344,12 @@ int main(int argc, char** argv) {
#endif
const GGWave::TxProtocols protocols = {
{ GGWAVE_TX_PROTOCOL_CUSTOM_0, { "[R2T2] Normal", 64, 9, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_1, { "[R2T2] Fast", 64, 6, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_2, { "[R2T2] Fastest", 64, 3, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_3, { "[R2T2] Low Normal", 16, 9, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_4, { "[R2T2] Low Fast", 16, 6, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_5, { "[R2T2] Low Fastest", 16, 3, 1, 2, } },
{ "[R2T2] Normal", 64, 9, 1, 2, true, },
{ "[R2T2] Fast", 64, 6, 1, 2, true, },
{ "[R2T2] Fastest", 64, 3, 1, 2, true, },
{ "[R2T2] Low Normal", 16, 9, 1, 2, true, },
{ "[R2T2] Low Fast", 16, 6, 1, 2, true, },
{ "[R2T2] Low Fastest", 16, 3, 1, 2, true, },
};
const auto argm = parseCmdArguments(argc, argv);

View File

@@ -37,8 +37,9 @@ int main(int argc, char** argv) {
printf("Available Tx protocols:\n");
const auto & protocols = GGWave::getTxProtocols();
for (const auto & protocol : protocols) {
printf(" -t%d : %s\n", protocol.first, protocol.second.name);
for (int i = 0; i < (int) protocols.size(); ++i) {
const auto & protocol = protocols[i];
printf(" %d - %s\n", i, protocol.name);
}
if (txProtocolId < 0) {

View File

@@ -19,8 +19,9 @@ int main(int argc, char** argv) {
fprintf(stderr, " Available protocols:\n");
const auto & protocols = GGWave::getTxProtocols();
for (const auto & protocol : protocols) {
fprintf(stderr, " %d - %s\n", protocol.first, protocol.second.name);
for (int i = 0; i < (int) protocols.size(); ++i) {
const auto & protocol = protocols[i];
fprintf(stderr, " %d - %s\n", i, protocol.name);
}
fprintf(stderr, "\n");

View File

@@ -53,12 +53,12 @@ int main(int argc, char** argv) {
printf("\n");
const GGWave::TxProtocols protocols = {
{ GGWAVE_TX_PROTOCOL_CUSTOM_0, { "[R2T2] Normal", 64, 9, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_1, { "[R2T2] Fast", 64, 6, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_2, { "[R2T2] Fastest", 64, 3, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_3, { "[R2T2] Low Normal", 16, 9, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_4, { "[R2T2] Low Fast", 16, 6, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_5, { "[R2T2] Low Fastest", 16, 3, 1, 2, } },
{ "[R2T2] Normal", 64, 9, 1, 2, true, },
{ "[R2T2] Fast", 64, 6, 1, 2, true, },
{ "[R2T2] Fastest", 64, 3, 1, 2, true, },
{ "[R2T2] Low Normal", 16, 9, 1, 2, true, },
{ "[R2T2] Low Fast", 16, 6, 1, 2, true, },
{ "[R2T2] Low Fastest", 16, 3, 1, 2, true, },
};
const auto argm = parseCmdArguments(argc, argv);
@@ -81,21 +81,13 @@ int main(int argc, char** argv) {
});
printf("Available Tx protocols:\n");
for (const auto & protocol : protocols) {
printf(" -t%-2d : %-16s", protocol.first, protocol.second.name);
if (protocol.first == GGWAVE_TX_PROTOCOL_CUSTOM_0) {
printf(" (8.5 sec)\n");
} else if (protocol.first == GGWAVE_TX_PROTOCOL_CUSTOM_1) {
printf(" (5.7 sec)\n");
} else if (protocol.first == GGWAVE_TX_PROTOCOL_CUSTOM_2) {
printf(" (2.9 sec)\n");
} else {
printf("\n");
}
for (int i = 0; i < (int) protocols.size(); ++i) {
const auto & protocol = protocols[i];
printf(" -t%-2d : %-16s\n", i, protocol.name);
}
printf("\n");
if (protocols.find(GGWave::TxProtocolId(txProtocolId)) == protocols.end()) {
if (txProtocolId < 0 || txProtocolId >= (int) protocols.size()) {
fprintf(stderr, "Unknown Tx protocol %d\n", txProtocolId);
return -3;
}

View File

@@ -322,12 +322,12 @@ int main(int argc, char** argv) {
#endif
const GGWave::TxProtocols protocols = {
{ GGWAVE_TX_PROTOCOL_CUSTOM_0, { "[R2T2] Normal", 64, 9, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_1, { "[R2T2] Fast", 64, 6, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_2, { "[R2T2] Fastest", 64, 3, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_3, { "[R2T2] Low Normal", 16, 9, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_4, { "[R2T2] Low Fast", 16, 6, 1, 2, } },
{ GGWAVE_TX_PROTOCOL_CUSTOM_5, { "[R2T2] Low Fastest", 16, 3, 1, 2, } },
{ "[R2T2] Normal", 64, 9, 1, 2, true, },
{ "[R2T2] Fast", 64, 6, 1, 2, true, },
{ "[R2T2] Fastest", 64, 3, 1, 2, true, },
{ "[R2T2] Low Normal", 16, 9, 1, 2, true, },
{ "[R2T2] Low Fast", 16, 6, 1, 2, true, },
{ "[R2T2] Low Fastest", 16, 3, 1, 2, true, },
};
const auto argm = parseCmdArguments(argc, argv);

View File

@@ -870,9 +870,7 @@ void renderMain() {
float volume = 0.10f;
GGWave::TxProtocols txProtocols;
GGWave::RxProtocols rxProtocols;
std::map<GGWave::RxProtocolId, bool> rxProtocolSelected;
};
static WindowId windowId = WindowId::Messages;
@@ -964,9 +962,6 @@ void renderMain() {
if (stateCurrent.flags.newTxProtocols) {
settings.txProtocols = std::move(stateCurrent.txProtocols);
settings.rxProtocols = settings.txProtocols;
for (auto & rxProtocol : settings.rxProtocols) {
settings.rxProtocolSelected[rxProtocol.first] = true;
}
}
stateCurrent.flags.clear();
stateCurrent.update = false;
@@ -1153,8 +1148,10 @@ void renderMain() {
}
if (ImGui::BeginCombo("##txProtocol", settings.txProtocols.at(GGWave::TxProtocolId(settings.protocolId)).name)) {
for (int i = 0; i < (int) settings.txProtocols.size(); ++i) {
const auto & txProtocol = settings.txProtocols.at(GGWave::TxProtocolId(i));
if (txProtocol.name == nullptr) continue;
const bool isSelected = (settings.protocolId == i);
if (ImGui::Selectable(settings.txProtocols.at(GGWave::TxProtocolId(i)).name, isSelected)) {
if (ImGui::Selectable(txProtocol.name, isSelected)) {
settings.protocolId = i;
}
@@ -1289,11 +1286,12 @@ void renderMain() {
}
{
ImGui::PushID("RxProtocols");
for (const auto & rxProtocol : settings.rxProtocols) {
for (auto & rxProtocol : settings.rxProtocols) {
if (rxProtocol.name == nullptr) continue;
auto posSave = ImGui::GetCursorScreenPos();
ImGui::Text("%s", "");
ImGui::SetCursorScreenPos({ posSave.x + kLabelWidth, posSave.y });
if (ImGui::Checkbox(rxProtocol.second.name, &settings.rxProtocolSelected.at(rxProtocol.first))) {
if (ImGui::Checkbox(rxProtocol.name, &rxProtocol.enabled)) {
updateRxProtocols = true;
}
}
@@ -1303,11 +1301,7 @@ void renderMain() {
if (updateRxProtocols) {
g_buffer.inputUI.update = true;
g_buffer.inputUI.flags.changeRxProtocols = true;
g_buffer.inputUI.rxProtocols.clear();
for (const auto & rxProtocol : settings.rxProtocols) {
if (settings.rxProtocolSelected.at(rxProtocol.first) == false) continue;
g_buffer.inputUI.rxProtocols[rxProtocol.first] = rxProtocol.second;
}
g_buffer.inputUI.rxProtocols = settings.rxProtocols;
}
ScrollWhenDraggingOnVoid(ImVec2(0.0f, -mouse_delta.y), ImGuiMouseButton_Left);