Merge pull request #173 from bobbycar-graz/update_submodules

Update submodules
This commit is contained in:
2021-12-24 01:39:25 +01:00
committed by GitHub
10 changed files with 123 additions and 114 deletions

View File

@ -18,8 +18,6 @@ jobs:
- name: Checkout (without submodules)
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Checkout and install esp-idf
uses: 0xFEEDC0DE64/checkout_install_esp_idf@main

View File

@ -1,10 +1,15 @@
#include "debuginputhandler.h"
// Arduino includes
#include <HardwareSerial.h>
// system includes
#include <string_view>
// esp-idf includes
#include <driver/uart.h>
#include <esp_log.h>
// 3rdparty lib includes
#include <tftinstance.h>
#include <esp32-hal-gpio.h>
// local includes
#include "globals.h"
@ -12,117 +17,123 @@
#include "screens.h"
#include "buttons.h"
using namespace espgui;
namespace {
constexpr const char * const TAG = "DEBUG";
//wl_status_t last_status;
//IPAddress last_ip;
uint8_t consoleControlCharsReceived{};
bool uart0Initialized{};
} // namespace
void initDebugInput()
{
Serial.begin(115200);
//Serial.setDebugOutput(true);
if (const auto result = uart_set_pin(UART_NUM_0, UART_PIN_NO_CHANGE, 3, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); result != ESP_OK)
{
ESP_LOGE(TAG, "uart_set_pin() failed with %s", esp_err_to_name(result));
}
if (const auto result = uart_driver_install(UART_NUM_0, SOC_UART_FIFO_LEN + 1, 0, 10, nullptr, 0); result != ESP_OK)
ESP_LOGE(TAG, "uart_driver_install() failed with %s", esp_err_to_name(result));
else
uart0Initialized = true;
pinMode(3, INPUT_PULLUP);
}
void handleDebugInput()
{
//const auto status = WiFi.status();
//if (last_status != status)
//{
//Serial.print("Status changed to: ");
//Serial.println(to_string(status).c_str());
//last_status = status;
//}
if (!uart0Initialized)
return;
//const auto ip = WiFi.localIP();
//if (last_ip != ip)
//{
//Serial.print("IP changed to: ");
//Serial.println(to_string(ip).c_str());
//last_ip = ip;
//}
while(Serial.available())
size_t length{};
if (const auto result = uart_get_buffered_data_len(UART_NUM_0, &length); result != ESP_OK)
{
const auto c = Serial.read();
ESP_LOGW(TAG, "uart_get_buffered_data_len() failed with %s", esp_err_to_name(result));
}
else if (length)
{
char data[length];
length = uart_read_bytes(UART_NUM_0, data, length, 0);
switch (c)
for (char c : std::string_view{data, length})
{
case 'i':
case 'I':
tft.init();
break;
case 'p':
case 'P':
{
const auto firstPower = controllers.front.command.poweroff;
for (Controller &controller : controllers)
controller.command.poweroff = !firstPower;
break;
}
case 'l':
case 'L':
{
const auto firstLed = controllers.front.command.led;
for (Controller &controller : controllers)
controller.command.led = !firstLed;
break;
}
case 'r':
case 'R':
loadSettings();
break;
case 's':
case 'S':
saveSettings();
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
for (Controller &controller : controllers)
controller.command.buzzer.freq = c-'0';
break;
case 'A':
InputDispatcher::rotate(-1);
break;
case 'B':
InputDispatcher::rotate(1);
break;
case 'C':
InputDispatcher::confirmButton(true);
InputDispatcher::confirmButton(false);
break;
case 'D':
InputDispatcher::backButton(true);
InputDispatcher::backButton(false);
break;
case 'z':
case 'Z':
switch (c)
{
case 'i':
case 'I':
espgui::tft.init();
break;
case 'p':
case 'P':
{
const auto firstPower = controllers.front.command.poweroff;
for (Controller &controller : controllers)
controller.command.poweroff = !firstPower;
break;
}
case 'l':
case 'L':
{
const auto firstLed = controllers.front.command.led;
for (Controller &controller : controllers)
controller.command.led = !firstLed;
break;
}
case 'r':
case 'R':
loadSettings();
break;
case 's':
case 'S':
saveSettings();
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
for (Controller &controller : controllers)
controller.command.buzzer.freq = c-'0';
break;
case 'A':
InputDispatcher::rotate(-1);
break;
case 'B':
InputDispatcher::rotate(1);
break;
case 'C':
InputDispatcher::confirmButton(true);
InputDispatcher::confirmButton(false);
break;
case 'D':
InputDispatcher::backButton(true);
InputDispatcher::backButton(false);
break;
case 'z':
case 'Z':
#ifndef LEDSTRIP_WRONG_DIRECTION
InputDispatcher::blinkLeftButton(true);
InputDispatcher::blinkLeftButton(false);
InputDispatcher::blinkLeftButton(true);
InputDispatcher::blinkLeftButton(false);
#else
InputDispatcher::blinkRightButton(true);
InputDispatcher::blinkRightButton(false);
InputDispatcher::blinkRightButton(true);
InputDispatcher::blinkRightButton(false);
#endif
break;
case 'u':
case 'U':
break;
case 'u':
case 'U':
#ifndef LEDSTRIP_WRONG_DIRECTION
InputDispatcher::blinkRightButton(true);
InputDispatcher::blinkRightButton(false);
InputDispatcher::blinkRightButton(true);
InputDispatcher::blinkRightButton(false);
#else
InputDispatcher::blinkLeftButton(true);
InputDispatcher::blinkLeftButton(false);
InputDispatcher::blinkLeftButton(true);
InputDispatcher::blinkLeftButton(false);
#endif
break;
break;
}
}
}
}

View File

@ -45,11 +45,11 @@ void AlertDisplay::initOverlay()
//espgui::tft.fillRect(leftMargin + 1, topMargin + 1, espgui::tft.width() - leftMargin - rightMargin - 2, espgui::tft.height() - topMargin - bottomMargin - 2, TFT_BLACK);
espgui::tft.drawSunkenRect(leftMargin, topMargin, width, height,
espgui::tft.color565(240, 240, 240),
espgui::tft.color565(100, 100, 100),
espgui::tft.color565(30, 30, 30));
color565(240, 240, 240),
color565(100, 100, 100),
color565(30, 30, 30));
espgui::tft.setTextColor(TFT_WHITE, espgui::tft.color565(30, 30, 30));
espgui::tft.setTextColor(TFT_WHITE, color565(30, 30, 30));
int x = leftMargin + 5;
int y = topMargin + 5;
@ -71,23 +71,23 @@ void AlertDisplay::initOverlay()
break;
}
espgui::tft.setTextColor(TFT_BLACK, espgui::tft.color565(170, 170, 170));
espgui::tft.setTextColor(TFT_BLACK, color565(170, 170, 170));
espgui::tft.drawSunkenRect(leftMargin + 15, bottom - 40,
(width - 15 - 10 - 15) / 2,
30,
espgui::tft.color565(240, 240, 240),
espgui::tft.color565(100, 100, 100),
espgui::tft.color565(170, 170, 170));
color565(240, 240, 240),
color565(100, 100, 100),
color565(170, 170, 170));
espgui::tft.drawString("Yes", leftMargin + 18, bottom - 37);
espgui::tft.drawSunkenRect(leftMargin + 15 + ((width - 15 - 30 - 15) / 2) + 15, bottom - 40,
(width - 15 - 10 - 15) / 2,
30,
espgui::tft.color565(240, 240, 240),
espgui::tft.color565(100, 100, 100),
espgui::tft.color565(170, 170, 170));
color565(240, 240, 240),
color565(100, 100, 100),
color565(170, 170, 170));
espgui::tft.drawString("No", leftMargin + 18 + ((width - 15 - 30 - 15) / 2) + 15 + 1, bottom - 37);
}

View File

@ -69,7 +69,7 @@ void StarfieldDisplay::redraw()
{
uint8_t r, g, b;
r = g = b = 255 - sz[i];
espgui::tft.drawPixel(screen_x, screen_y, espgui::tft.color565(r,g,b));
espgui::tft.drawPixel(screen_x, screen_y, color565(r,g,b));
}
else
sz[i] = 0; // Out of screen, die.