Skip to content

Commit

Permalink
add restart and channel setting in gs
Browse files Browse the repository at this point in the history
Signed-off-by: ncer <[email protected]>
  • Loading branch information
Ncerzzk committed Nov 4, 2023
1 parent 707172f commit be549e2
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions gs/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct{
bool record;
FILE * record_file=nullptr;
std::mutex record_mutex;
int wifi_channel;
}s_groundstation_config;
float video_fps = 0;
static void comms_thread_proc()
Expand Down Expand Up @@ -303,7 +304,7 @@ void ImageRotated(ImTextureID tex_id, ImVec2 center, ImVec2 size, float angle, f
draw_list->AddImageQuad(tex_id, pos[0], pos[1], pos[2], pos[3], uvs[0], uvs[1], uvs[2], uvs[3], IM_COL32_WHITE);
}

int run()
int run(char* argv[])
{
HUD hud(*s_hal);

Expand Down Expand Up @@ -333,7 +334,7 @@ int run()
Clock::time_point last_stats_tp = Clock::now();
Clock::time_point last_tp = Clock::now();

auto f = [&config]{
auto f = [&config,&argv]{

ImGui::Begin("HAL");
{
Expand Down Expand Up @@ -377,6 +378,9 @@ int run()
ImGui::SliderInt("Denoise", &value, 0, 0xFF);
config.camera.denoise = (int8_t)value;
}
{
ImGui::SliderInt("WIFI Channel", &s_groundstation_config.wifi_channel, 1, 12);
}
{
//ImGui::Checkbox("LC", &config.camera.lenc);
//ImGui::SameLine();
Expand Down Expand Up @@ -415,6 +419,12 @@ int run()
}
abort();
}
if (ImGui::Button("Restart")){
char tempstr[30];
sprintf(tempstr,"ESPVTX_WIFI_CHN=%d",s_groundstation_config.wifi_channel);
putenv(tempstr);
execv(argv[0],argv);
}

ImGui::Text("%.3f ms/frame (%.1f FPS) %.1f VFPS", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate, video_fps);
}
Expand Down Expand Up @@ -468,12 +478,12 @@ int main(int argc, const char* argv[])
rx_descriptor.coding_k = s_ground2air_config_packet.fec_codec_k;
rx_descriptor.coding_n = s_ground2air_config_packet.fec_codec_n;
rx_descriptor.mtu = s_ground2air_config_packet.fec_codec_mtu;
rx_descriptor.interfaces = {"wlx00127b22ac39"};
rx_descriptor.interfaces = {"wlxc01c30222455"};
Comms::TX_Descriptor tx_descriptor;
tx_descriptor.coding_k = 2;
tx_descriptor.coding_n = 6;
tx_descriptor.mtu = GROUND2AIR_DATA_MAX_SIZE;
tx_descriptor.interface = "wlx00127b22ac39";
tx_descriptor.interface = "wlxc01c30222455";

for(int i=1;i<argc;++i){
auto temp = std::string(argv[i]);
Expand Down Expand Up @@ -508,6 +518,16 @@ int main(int argc, const char* argv[])
}
}

{
char *temp = getenv("ESPVTX_WIFI_CHN");
if(temp){
s_groundstation_config.wifi_channel = atoi(temp);
}else{
s_groundstation_config.wifi_channel = 11;
}
}


if (!s_comms.init(rx_descriptor, tx_descriptor))
return -1;

Expand All @@ -516,7 +536,7 @@ int main(int argc, const char* argv[])
system(fmt::format("iwconfig {} channel 11", itf).c_str());
}

int result = run();
int result = run((char **)argv);

s_hal->shutdown();

Expand Down

0 comments on commit be549e2

Please sign in to comment.