display stuff
This commit is contained in:
@ -14,16 +14,36 @@ SSD1306Wire confDisplay(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_
|
|||||||
const char *ssid = "ModbusLoraConf";
|
const char *ssid = "ModbusLoraConf";
|
||||||
char password[12];
|
char password[12];
|
||||||
|
|
||||||
|
static void displayStatus(uint8_t numOfStations) {
|
||||||
|
confDisplay.clear();
|
||||||
|
confDisplay.display();
|
||||||
|
confDisplay.drawString(1, 0, "Config Mode running");
|
||||||
|
char buf[64];
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
sprintf(buf, "SSID: %s", ssid);
|
||||||
|
confDisplay.drawString(1, 12, buf);
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
sprintf(buf, "Key: %s", password);
|
||||||
|
confDisplay.drawString(1, 24, buf);
|
||||||
|
confDisplay.display();
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
sprintf(buf, "Num of stations: %d ", numOfStations);
|
||||||
|
confDisplay.drawString(1, 36, buf);
|
||||||
|
confDisplay.display();
|
||||||
|
}
|
||||||
|
|
||||||
void configurationSetup() {
|
static void displayInit() {
|
||||||
digitalWrite(Vext,LOW);
|
digitalWrite(Vext,LOW);
|
||||||
confDisplay.init();
|
confDisplay.init();
|
||||||
confDisplay.setFont(ArialMT_Plain_10);
|
confDisplay.setFont(ArialMT_Plain_10);
|
||||||
confDisplay.setTextAlignment(TEXT_ALIGN_LEFT);
|
confDisplay.setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
confDisplay.screenRotate(ANGLE_180_DEGREE);
|
||||||
confDisplay.clear();
|
confDisplay.clear();
|
||||||
confDisplay.drawString(1, 1, "Configuration Mode starting");
|
confDisplay.drawString(1, 0, "Config Mode starting");
|
||||||
confDisplay.display();
|
confDisplay.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
void configurationSetup() {
|
||||||
memset(password, 0, sizeof(password));
|
memset(password, 0, sizeof(password));
|
||||||
for (int i = 0; i < sizeof(password) - 1; i++) {
|
for (int i = 0; i < sizeof(password) - 1; i++) {
|
||||||
password[i] = random(65, 90);
|
password[i] = random(65, 90);
|
||||||
@ -31,23 +51,18 @@ void configurationSetup() {
|
|||||||
|
|
||||||
WiFi.softAP(ssid, password);
|
WiFi.softAP(ssid, password);
|
||||||
IPAddress myIP = WiFi.softAPIP();
|
IPAddress myIP = WiFi.softAPIP();
|
||||||
Serial.print("AP IP address: ");
|
|
||||||
Serial.println(myIP);
|
|
||||||
char buf[64];
|
|
||||||
memset(buf, 0, sizeof(buf));
|
|
||||||
sprintf(buf, "SSID: %s", ssid);
|
|
||||||
confDisplay.drawString(1, 15, buf);
|
|
||||||
memset(buf, 0, sizeof(buf));
|
|
||||||
sprintf(buf, "Key: %s", password);
|
|
||||||
confDisplay.drawString(1, 30, buf);
|
|
||||||
confDisplay.display();
|
|
||||||
|
|
||||||
|
|
||||||
delay(2000);
|
|
||||||
|
|
||||||
|
displayInit();
|
||||||
|
displayStatus(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void configurationLoop() {
|
void configurationLoop() {
|
||||||
|
static uint8_t numOfStations = 255;
|
||||||
|
uint8_t currentNumOfStations = WiFi.softAPgetStationNum();
|
||||||
|
if (numOfStations != currentNumOfStations) {
|
||||||
|
displayStatus(currentNumOfStations);
|
||||||
|
numOfStations = currentNumOfStations;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user