Added hostname display

This commit is contained in:
2020-05-31 23:57:39 +02:00
parent af2b6d1f87
commit a7659ee567
3 changed files with 36 additions and 17 deletions

View File

@@ -95,12 +95,15 @@ private:
BoardStatus m_frontStatus{42}; BoardStatus m_frontStatus{42};
BoardStatus m_backStatus{142}; BoardStatus m_backStatus{142};
Label m_labelWifiStatus{35, 266}; // 120, 15 Label m_labelWifiStatus{35, bottomLines[0]}; // 120, 15
Label m_labelLimit0{205, 266}; // 35, 15 Label m_labelLimit0{205, bottomLines[0]}; // 35, 15
Label m_labelIpAddress{25, 281}; // 130, 15 Label m_labelIpAddress{25, bottomLines[1]}; // 130, 15
Label m_labelLimit1{205, 281}; // 35, 15 Label m_labelLimit1{205, bottomLines[1]}; // 35, 15
Label m_labelPerformance{85, 296}; // 40, 15 Label m_labelPerformance{85, bottomLines[2]}; // 40, 15
Label m_labelMode{165, 296}; // 75, 15 Label m_labelMode{165, bottomLines[2]}; // 75, 15
Label m_labelName{40, bottomLines[3]}; // 40, 15
static const constexpr int bottomLines[4] { 251, 266, 281, 296 };
}; };
void StatusDisplay::initScreen() void StatusDisplay::initScreen()
@@ -122,18 +125,20 @@ void StatusDisplay::initScreen()
m_backStatus.start(); m_backStatus.start();
tft.setTextFont(2); tft.setTextFont(2);
tft.drawString("WiFi:", 0, 266); tft.drawString("WiFi:", 0, bottomLines[0]);
m_labelWifiStatus.start(); m_labelWifiStatus.start();
tft.drawString("Limit0:", 160, 266); tft.drawString("Limit0:", 160, bottomLines[0]);
m_labelLimit0.start(); m_labelLimit0.start();
tft.drawString("IP:", 0, 281); tft.drawString("IP:", 0, bottomLines[1]);
m_labelIpAddress.start(); m_labelIpAddress.start();
tft.drawString("Limit1:", 160, 281); tft.drawString("Limit1:", 160, bottomLines[1]);
m_labelLimit1.start(); m_labelLimit1.start();
tft.drawString("Performance:", 0, 296); tft.drawString("Performance:", 0, bottomLines[2]);
m_labelPerformance.start(); m_labelPerformance.start();
tft.drawString("Mode:", 125, 296); tft.drawString("Mode:", 125, bottomLines[2]);
m_labelMode.start(); m_labelMode.start();
tft.drawString("Name:", 0, bottomLines[3]);
m_labelName.start();
tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
} }
@@ -158,6 +163,7 @@ void StatusDisplay::redraw()
m_labelLimit1.redraw(String{front.command.left.iDcMax} + "A"); m_labelLimit1.redraw(String{front.command.left.iDcMax} + "A");
m_labelPerformance.redraw(String{performance.last}); m_labelPerformance.redraw(String{performance.last});
m_labelMode.redraw(currentMode->displayName()); m_labelMode.redraw(currentMode->displayName());
m_labelName.redraw(&deviceName[0]);
} }
void StatusDisplay::rotate(int offset) void StatusDisplay::rotate(int offset)

View File

@@ -24,7 +24,7 @@ float gametrakX, gametrakY, gametrakDist;
#endif #endif
float avgSpeed, avgSpeedKmh, sumCurrent, sumAbsoluteCurrent; float avgSpeed, avgSpeedKmh, sumCurrent, sumAbsoluteCurrent;
char deviceName[16]; char deviceName[32];
Settings settings; Settings settings;
SettingsSaver settingsSaver; SettingsSaver settingsSaver;

View File

@@ -67,12 +67,25 @@ void setup()
{ {
uint8_t macAddress[6]; uint8_t macAddress[6];
WiFi.macAddress(&macAddress[0]); WiFi.macAddress(&macAddress[0]);
std::sprintf(deviceName, __STRINGIFY(DEVICE_PREFIX) "_%02hhx%02hhx%02hhx", macAddress[3], macAddress[4], macAddress[5]); #define STRING2(s) #s
#define STRING(s) STRING2(s)
std::sprintf(deviceName, STRING(DEVICE_PREFIX) "_%02hhx%02hhx%02hhx", macAddress[3], macAddress[4], macAddress[5]);
} }
WiFi.mode(WIFI_AP_STA); if (!WiFi.setHostname(deviceName))
WiFi.softAP(deviceName, "Passwort_123"); Serial.println("Could not setHostname");
WiFi.begin("realraum", "r3alraum");
if (!WiFi.softAPsetHostname(deviceName))
Serial.println("Could not softAPsetHostname");
if (!WiFi.mode(WIFI_AP_STA))
Serial.println("Could not set mode to WIFI_AP_STA");
if (!WiFi.softAP(deviceName, "Passwort_123"))
Serial.println("Could not softAP");
if (!WiFi.begin("realraum", "r3alraum"))
Serial.println("Could not begin WiFi");
if (settings.bluetoothMode == BluetoothMode::Master) if (settings.bluetoothMode == BluetoothMode::Master)
{ {