From b2cde0d8cee8135cbefb9ef64d706ab681006987 Mon Sep 17 00:00:00 2001 From: Tyler Perkins Date: Tue, 21 Dec 2021 19:43:20 -0500 Subject: [PATCH] Add wifi network name and password --- src/panel/wifi.cpp | 25 +++++++++++++++++++++++-- src/panel/wifi_config.hpp | 6 ++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/panel/wifi.cpp b/src/panel/wifi.cpp index eb2727c..772f4b1 100644 --- a/src/panel/wifi.cpp +++ b/src/panel/wifi.cpp @@ -86,13 +86,34 @@ void wifi::update_texture(){ //show the QRCode tgt.x = -25; - tgt.y = tgt.h; + tgt.y = tgt.h - 6; tgt.w = (SCREEN_WIDTH / 2) ; - std::cerr << "TGT.W : " << tgt.w << "\n"; tgt.h = tgt.w; SDL_RenderCopy(board::getRenderer(), board::getImage("wifi.png"), NULL, &tgt); + std::string network_string("Network: "); + network_string += WIFI_NETWORK_NAME; + + //show info about the network + tgt.x = (SCREEN_WIDTH / 2) + 25; + tgt.y = 50; + TTF_SizeText(board::getFont({ "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), + network_string.c_str(), &tgt.w, &tgt.h); + SDL_RenderCopy(board::getRenderer(), + board::getString(network_string.c_str(), + { "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), NULL, &tgt); + + tgt.y += tgt.h + 25; + std::string password_string("Password: "); + password_string += WIFI_NETWORK_PASS; + TTF_SizeText(board::getFont({ "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), + password_string.c_str(), &tgt.w, &tgt.h); + SDL_RenderCopy(board::getRenderer(), + board::getString(password_string.c_str(), + { "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), NULL, &tgt); + + SDL_SetRenderTarget(board::getRenderer(), NULL); } diff --git a/src/panel/wifi_config.hpp b/src/panel/wifi_config.hpp index 9be4d04..6735d22 100644 --- a/src/panel/wifi_config.hpp +++ b/src/panel/wifi_config.hpp @@ -14,4 +14,10 @@ namespace dashboard::panel { //How long should we wait between updates? in ms //Due to the nature of this panel, this value is ignored constexpr size_t WIFI_UPDATE_INTERVAL = 60000; + + //All of the following options WILL be shown on the screen. + //If this is a privacy concernt for you, set the value to be blank + //(ie "") and it will not be shown + constexpr char WIFI_NETWORK_NAME[] = "MyNetwork"; + constexpr char WIFI_NETWORK_PASS[] = "MyPassword"; }