Merge pull request #277 from bobbycar-graz/qr
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
// local includes
|
// local includes
|
||||||
#include "displays/qrdisplay.h"
|
#include "displays/qrdisplay.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
#include "utils.h"
|
||||||
#include "settingsmenu.h"
|
#include "settingsmenu.h"
|
||||||
#include "texthelpers/networktexthelpers.h"
|
#include "texthelpers/networktexthelpers.h"
|
||||||
#include "wifiapsettingsmenu.h"
|
#include "wifiapsettingsmenu.h"
|
||||||
@@ -52,6 +53,6 @@ void NetworkSettingsMenu::back()
|
|||||||
|
|
||||||
void NetworkAccessPointQRAction::triggered()
|
void NetworkAccessPointQRAction::triggered()
|
||||||
{
|
{
|
||||||
std::string qr = fmt::format("WIFI:T:WPA;S:{};P:{};H:;", configs.wifiApName.value, configs.wifiApKey.value);
|
std::string qr = fmt::format("WIFI:T:{};S:{};P:{};H:;", get_wifi_security_string(configs.wifiApAuthmode.value), configs.wifiApName.value, configs.wifiApKey.value);
|
||||||
espgui::switchScreen<QrDisplay<NetworkSettingsMenu>>(qr);
|
espgui::switchScreen<QrDisplay<NetworkSettingsMenu>>(qr);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "qrdisplay.h"
|
#include "qrdisplay.h"
|
||||||
|
|
||||||
|
// this only works for ECC_MEDIUM
|
||||||
uint16_t get_qrver_from_strlen(std::string_view str)
|
uint16_t get_qrver_from_strlen(std::string_view str)
|
||||||
{
|
{
|
||||||
// alpha numeric, ECC Level M
|
// alpha numeric, ECC Level M
|
||||||
|
@@ -26,7 +26,7 @@ public:
|
|||||||
uint8_t qrcodeBytes[qrcode_getBufferSize(ver)];
|
uint8_t qrcodeBytes[qrcode_getBufferSize(ver)];
|
||||||
qrcode_initText(&qrcode, qrcodeBytes, ver, ECC_MEDIUM, m_msg.data());
|
qrcode_initText(&qrcode, qrcodeBytes, ver, ECC_MEDIUM, m_msg.data());
|
||||||
|
|
||||||
const uint8_t multiplier = (tft.width() - 9) / qrcode.size;
|
const uint8_t multiplier = (tft.width() - 18) / qrcode.size;
|
||||||
const uint8_t x_offset = (tft.width() - qrcode.size * multiplier) / 2;
|
const uint8_t x_offset = (tft.width() - qrcode.size * multiplier) / 2;
|
||||||
const uint8_t y_offset = (tft.height() - qrcode.size * multiplier) / 2;
|
const uint8_t y_offset = (tft.height() - qrcode.size * multiplier) / 2;
|
||||||
|
|
||||||
|
@@ -313,3 +313,20 @@ int16_t map_analog_stick(uint16_t middle, uint16_t start, uint16_t end, uint16_t
|
|||||||
return return_val;
|
return return_val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string get_wifi_security_string(wifi_auth_mode_t authMode)
|
||||||
|
{ // use for qr code
|
||||||
|
switch (authMode)
|
||||||
|
{
|
||||||
|
case WIFI_AUTH_OPEN:
|
||||||
|
return "nopass";
|
||||||
|
case WIFI_AUTH_WEP:
|
||||||
|
return "WEP";
|
||||||
|
case WIFI_AUTH_WPA_PSK:
|
||||||
|
case WIFI_AUTH_WPA2_PSK:
|
||||||
|
case WIFI_AUTH_WPA_WPA2_PSK:
|
||||||
|
return "WPA";
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -77,3 +77,5 @@ inline CRGB UINT32_TO_CRGB(uint32_t color)
|
|||||||
|
|
||||||
return crgb;
|
return crgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string get_wifi_security_string(wifi_auth_mode_t authMode);
|
||||||
|
Reference in New Issue
Block a user