Files
bobbycar-boardcomputer-firm…/main/displays/qrcodedebug.cpp
T

50 lines
1.1 KiB
C++
Raw Normal View History

2021-12-12 01:23:19 +01:00
#include "qrcodedebug.h"
2022-03-05 22:26:57 +01:00
// 3rdparty lib includes
2021-12-12 01:23:40 +01:00
#include <fmt/core.h>
2021-12-18 02:17:30 +01:00
#include <tftinstance.h>
2021-12-12 01:23:19 +01:00
2022-03-05 22:26:57 +01:00
// local includes
2021-12-12 01:23:40 +01:00
#include "globals.h"
#include "screenmanager.h"
2021-12-29 00:40:05 +01:00
#include "newsettings.h"
2021-12-12 01:23:19 +01:00
using namespace espgui;
QrCodeDebugDisplay::QrCodeDebugDisplay()
{
}
void QrCodeDebugDisplay::initScreen()
{
Base::initScreen();
}
2021-12-28 02:19:27 +01:00
void QrCodeDebugDisplay::buttonPressed(espgui::Button button)
2021-12-12 01:23:19 +01:00
{
2021-12-28 02:19:27 +01:00
Base::buttonPressed(button);
2021-12-12 01:23:19 +01:00
2021-12-28 02:19:27 +01:00
switch (button)
{
using espgui::Button;
2022-03-05 22:26:57 +01:00
case Button::Left: popScreen(); break;
2021-12-28 02:19:27 +01:00
case Button::Right:
{
uint8_t qrcodeBytes[qrcode_getBufferSize(7)];
2022-04-29 22:40:49 +02:00
qrcode_initText(&m_qrcode, qrcodeBytes, 7, ECC_MEDIUM, fmt::format("WIFI:T:WPA;S:{};P:{};", configs.wifiApName.value(), configs.wifiApKey.value()).c_str());
2021-12-28 02:19:27 +01:00
for (uint8_t y = 0; y < m_qrcode.size; y++) {
for (uint8_t x = 0; x < m_qrcode.size; x++) {
if (qrcode_getModule(&m_qrcode, x, y))
{
tft.drawPixel(x+2,y+2, TFT_BLACK);
} else {
tft.drawPixel(x+2,y+2, TFT_WHITE);
}
2021-12-18 02:17:30 +01:00
}
}
2021-12-28 02:19:27 +01:00
break;
}
default:;
2021-12-18 02:17:30 +01:00
}
2021-12-12 01:23:19 +01:00
}