Skip to content

Commit 38bcf4c

Browse files
committed
Show BT icon on countdown
1 parent f111090 commit 38bcf4c

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

src/AgOledDisplay.cpp

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ static unsigned char OFFLINE_BITS[] = {
1919
0xE6, 0x00, 0xFE, 0x1F, 0xFE, 0x1F, 0xE6, 0x00, 0x62, 0x00,
2020
0x30, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
2121
};
22-
// {
23-
// 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x60, 0x00, 0x62, 0x00, 0xE2, 0x00,
24-
// 0xFE, 0x1F, 0xFE, 0x1F, 0xE2, 0x00, 0x62, 0x00, 0x60, 0x00, 0x30, 0x00,
25-
// 0x00, 0x00, 0x00, 0x00, };
22+
23+
static unsigned char BLUETOOTH_BITS[] = {
24+
0x00, 0x02, 0x00, 0x00, 0x06, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x3a, 0x00, 0x60,
25+
0x72, 0x00, 0xe0, 0x72, 0x00, 0xc0, 0x3b, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x0f,
26+
0x00, 0x80, 0x1f, 0x00, 0xc0, 0x3b, 0x00, 0xe0, 0x72, 0x00, 0x60, 0x72, 0x00, 0x00, 0x3a, 0x00,
27+
0x00, 0x1e, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x06, 0x00, 0x00, 0x02, 0x00
28+
};
29+
2630
/**
2731
* @brief Show dashboard temperature and humdity
2832
*
@@ -270,6 +274,28 @@ void OledDisplay::setText(const char *line1, const char *line2,
270274
}
271275
}
272276

277+
void OledDisplay::showWiFiProvisioning(bool firstRun, int countdown) {
278+
if (firstRun) {
279+
DISP()->clearBuffer();
280+
DISP()->setFont(u8g2_font_t0_16_tf);
281+
DISP()->drawStr(1, 25, "to WiFi hotspot:");
282+
DISP()->drawStr(1, 40, "\"airgradient-");
283+
DISP()->drawStr(1, 55, (ag->deviceId() + "\"").c_str());
284+
DISP()->drawXBM(108, 44, 20, 20, BLUETOOTH_BITS);
285+
DISP()->sendBuffer();
286+
}
287+
288+
// Now just update countdown area
289+
char buf[16];
290+
snprintf(buf, sizeof(buf), "%ds to connect", countdown);
291+
DISP()->setDrawColor(0); // erase previous text
292+
DISP()->drawBox(0, 0, 128, 16); // clear top region
293+
DISP()->setDrawColor(1); // draw new text in white
294+
DISP()->setFont(u8g2_font_t0_16_tf);
295+
DISP()->drawStr(1, 10, buf);
296+
DISP()->sendBuffer();
297+
}
298+
273299
/**
274300
* @brief Update dashboard content
275301
*

src/AgOledDisplay.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class OledDisplay : public PrintLog {
4848
void setText(String &line1, String &line2, String &line3, String &line4);
4949
void setText(const char *line1, const char *line2, const char *line3,
5050
const char *line4);
51+
void showWiFiProvisioning(bool firstRun, int countdown);
5152
void showDashboard(void);
5253
void showDashboard(DashboardStatus status);
5354
void setBrightness(int percent);

src/AgStateMachine.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,10 @@ void StateMachine::displayHandle(AgStateMachineState state) {
494494
if (ag->isBasic()) {
495495
String ssid = "\"airgradient-" + ag->deviceId() + "\" " +
496496
String(wifiConnectCountDown) + String("s");
497-
disp.setText("Connect tohotspot:", ssid.c_str(), "");
497+
disp.setText("Connect to hotspot:", ssid.c_str(), "");
498498
} else {
499-
String line1 = String(wifiConnectCountDown) + "s to connect";
500-
String line2 = "to WiFi hotspot:";
501-
String line3 = "\"airgradient-";
502-
String line4 = ag->deviceId() + "\"";
503-
disp.setText(line1, line2, line3, line4);
499+
// NOTE: This bool is hardcoded!
500+
disp.showWiFiProvisioning((wifiConnectCountDown == 180), wifiConnectCountDown);
504501
}
505502
wifiConnectCountDown--;
506503
}

0 commit comments

Comments
 (0)