Skip to content

Commit 9eb8c78

Browse files
committed
Apply clang-format 13
1 parent db69cdb commit 9eb8c78

3 files changed

Lines changed: 53 additions & 49 deletions

File tree

src/common_header.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,10 +1294,10 @@ struct draw_param_t : public config_param_t {
12941294
uint8_t update_count = 0;
12951295
uint8_t modify_count = 0;
12961296
uint32_t draw_count = 0;
1297-
int8_t battery_state = m5::Power_Class::charge_unknown;
1298-
int8_t battery_level = -1;
1299-
uint8_t font_height = 8;
1300-
bool oncloud_conf_valid = false;
1297+
int8_t battery_state = m5::Power_Class::charge_unknown;
1298+
int8_t battery_level = -1;
1299+
uint8_t font_height = 8;
1300+
bool oncloud_conf_valid = false;
13011301
uint8_t macaddr[8];
13021302

13031303
enum cloud_status_t {
@@ -1316,10 +1316,10 @@ struct draw_param_t : public config_param_t {
13161316
std::string
13171317
net_tmp_pwd; // APモードで設定のために一時的に利用するパスワード
13181318
std::string net_ap_wifi_qr; // Wi-Fi credentials for joining the setup AP
1319-
std::string net_ap_url; // APモードアクセス用URL
1320-
std::string net_url_mdns; // mDNS名アクセス用URL
1321-
std::string net_url_ip; // mDNS名アクセス用URL
1322-
std::string net_hostname; // DNS host label, without .local
1319+
std::string net_ap_url; // APモードアクセス用URL
1320+
std::string net_url_mdns; // mDNS名アクセス用URL
1321+
std::string net_url_ip; // mDNS名アクセス用URL
1322+
std::string net_hostname; // DNS host label, without .local
13231323
std::string cloud_url;
13241324
IPAddress cloud_ip;
13251325

src/main.cpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,8 +1949,8 @@ class header_ui_t : public ui_base_t {
19491949
param->battery_state == m5::Power_Class::is_charging;
19501950
const bool unknown =
19511951
param->battery_state == m5::Power_Class::charge_unknown;
1952-
const uint32_t color = charging ? 0x00FF00u
1953-
: (unknown ? 0x808080u : 0xFFFFFFu);
1952+
const uint32_t color =
1953+
charging ? 0x00FF00u : (unknown ? 0x808080u : 0xFFFFFFu);
19541954
canvas->drawRect(xpos, y, 14, 10, color);
19551955
canvas->fillRect(xpos + 14, y + 3, 2, 4, color);
19561956
if (param->battery_level >= 0) {
@@ -2015,14 +2015,15 @@ class header_ui_t : public ui_base_t {
20152015
snprintf(countdown, sizeof(countdown), "%u",
20162016
unsigned(param->cloud_countdown_sec));
20172017
const lgfx::IFont* font = &fonts::Font2;
2018-
if (canvas->textWidth(countdown, font) > xpos - _client_rect.x) {
2018+
if (canvas->textWidth(countdown, font) >
2019+
xpos - _client_rect.x) {
20192020
font = &fonts::Font0;
20202021
}
20212022
// Narrow layouts prioritize the three status icons.
2022-
if (canvas->textWidth(countdown, font) <= xpos - _client_rect.x) {
2023-
xpos -= canvas->drawString(countdown, xpos,
2024-
_client_rect.y - canvas_y,
2025-
font);
2023+
if (canvas->textWidth(countdown, font) <=
2024+
xpos - _client_rect.x) {
2025+
xpos -= canvas->drawString(
2026+
countdown, xpos, _client_rect.y - canvas_y, font);
20262027
}
20272028
}
20282029
}
@@ -2244,7 +2245,7 @@ class image_ui_t : public ui_base_t {
22442245
param->range_temp_lower)
22452246
<< 8) /
22462247
param->temp_diff;
2247-
v3 = (v3 < 0) ? 0 : (v3 > 255) ? 255 : v3;
2248+
v3 = (v3 < 0) ? 0 : (v3 > 255) ? 255 : v3;
22482249
int32_t x1 = 0;
22492250
for (int32_t fx = 1; fx < frame_width; ++fx) {
22502251
int32_t x0 = x1;
@@ -2280,7 +2281,7 @@ class image_ui_t : public ui_base_t {
22802281
canvas->getBuffer())[_client_rect.x + x0 +
22812282
ypos * canvas->width()];
22822283
for (int32_t bx = 0; bx < boxWidth; ++bx) {
2283-
uint32_t v = (v02 * (boxWidth - bx) + v13 * bx) >> 16;
2284+
uint32_t v = (v02 * (boxWidth - bx) + v13 * bx) >> 16;
22842285
img_buf[bx] = m5gfx::getSwap16(param->color_map[v]);
22852286
}
22862287
}
@@ -2896,9 +2897,8 @@ uint8_t changeLayout(uint8_t layout_idx) {
28962897
}
28972898

28982899
void drawTask(void*) {
2899-
ui_base_t* ui_list[] = {&text_ui, &hist_ui,
2900-
&image_ui, &graph_ui, &config_ui,
2901-
&header_ui, &qrcode_ui, &overlay_ui};
2900+
ui_base_t* ui_list[] = {&text_ui, &hist_ui, &image_ui, &graph_ui,
2901+
&config_ui, &header_ui, &qrcode_ui, &overlay_ui};
29022902
static constexpr const uint32_t disp_buf_height = 16;
29032903
static constexpr const size_t disp_buf_count =
29042904
3; // 描画バッファの数。jpegエンコーダのqueueにセットする分があるため3とする
@@ -3090,8 +3090,8 @@ static void wifiTask(void*) {
30903090
bool rtc_sync = false;
30913091
config_param_t::net_setup_mode_t prev_net_setup_mode =
30923092
config_param_t::net_setup_mode_off;
3093-
bool prev_ap_connected = false;
3094-
bool prev_sta_connected = false;
3093+
bool prev_ap_connected = false;
3094+
bool prev_sta_connected = false;
30953095
uint32_t connect_retry_at = millis() + 15000;
30963096

30973097
for (;;) {
@@ -3208,13 +3208,12 @@ static void wifiTask(void*) {
32083208

32093209
const bool wifi_requested = (bool)draw_param.request_wifi_state;
32103210
const bool ap_setup_active =
3211-
draw_param.net_setup_mode ==
3212-
draw_param.net_setup_mode_accesspoint;
3211+
draw_param.net_setup_mode == draw_param.net_setup_mode_accesspoint;
32133212
const bool sta_enabled = WiFi.getMode() & WIFI_MODE_STA;
32143213
if (!need_wifi_reconnect &&
3215-
(wifi_requested ? WiFi.isConnected()
3216-
: (ap_setup_active ? !WiFi.isConnected()
3217-
: !sta_enabled))) {
3214+
(wifi_requested
3215+
? WiFi.isConnected()
3216+
: (ap_setup_active ? !WiFi.isConnected() : !sta_enabled))) {
32183217
continue;
32193218
}
32203219

@@ -3231,7 +3230,7 @@ static void wifiTask(void*) {
32313230
draw_param.net_setup_mode_off);
32323231
}
32333232
need_wifi_reconnect = false;
3234-
connect_retry_at = millis();
3233+
connect_retry_at = millis();
32353234
} else {
32363235
if (int32_t(millis() - connect_retry_at) >= 0) {
32373236
if (!draw_param.net_tmp_ssid.empty()) {
@@ -3584,7 +3583,8 @@ void setup(void) {
35843583

35853584
// DNS host labels cannot contain underscores. Keep the AP SSID unchanged.
35863585
char hostname[32];
3587-
snprintf(hostname, sizeof(hostname), "t-lite-%02x%02x", macaddr[4], macaddr[5]);
3586+
snprintf(hostname, sizeof(hostname), "t-lite-%02x%02x", macaddr[4],
3587+
macaddr[5]);
35883588
draw_param.net_hostname = hostname;
35893589

35903590
char cbuf[32];
@@ -3608,7 +3608,8 @@ void setup(void) {
36083608
// snprintf(cbuf, sizeof(cbuf), "http://%s/",
36093609
// draw_param.net_apmode_ipaddr.toString().c_str()); draw_param.net_ap_url =
36103610
// cbuf;
3611-
draw_param.net_ap_url = "http://" +
3611+
draw_param.net_ap_url =
3612+
"http://" +
36123613
std::string(draw_param.net_apmode_ipaddr.toString().c_str()) + "/wifi";
36133614

36143615
snprintf(cbuf, sizeof(cbuf), "%02x%02x%02x%02x%02x%02x", macaddr[0],

src/webserverTask.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,8 @@ static bool response_wifi(draw_param_t* draw_param, connection_t* conn) {
723723
client->print(HTTP_200_html);
724724
client->print(
725725
"<!DOCTYPE html><html><head><meta charset='UTF-8'>"
726-
"<meta name='viewport' content='width=device-width,initial-scale=1'>"
726+
"<meta name='viewport' "
727+
"content='width=device-width,initial-scale=1'>"
727728
"<title>T-Lite WiFi setup</title></head><body>"
728729
"<h1>WiFi settings saved</h1>"
729730
"<p>T-Lite is connecting to the selected network.</p>"
@@ -822,7 +823,7 @@ static bool response_wifi(draw_param_t* draw_param, connection_t* conn) {
822823
WiFi.scanDelete();
823824
WiFi.scanNetworks(true);
824825
}
825-
int count = WiFi.scanComplete();
826+
int count = WiFi.scanComplete();
826827
bool scan_running = count == WIFI_SCAN_RUNNING;
827828
if (count == WIFI_SCAN_FAILED) {
828829
WiFi.scanNetworks(true);
@@ -868,7 +869,8 @@ static bool response_wifi(draw_param_t* draw_param, connection_t* conn) {
868869
escaped.c_str());
869870
}
870871
}
871-
client->print("<a href='javascript:void(0);' onclick='r()'>Refresh networks</a>");
872+
client->print(
873+
"<a href='javascript:void(0);' onclick='r()'>Refresh networks</a>");
872874
client->print("<datalist id='ssid-list'>");
873875
for (int i = 0; i < count; ++i) {
874876
const String ssid = WiFi.SSID(i);
@@ -904,17 +906,17 @@ static bool response_health(draw_param_t* draw_param, connection_t* conn) {
904906
const size_t heap_largest_dma =
905907
heap_caps_get_largest_free_block(MALLOC_CAP_DMA);
906908

907-
const TaskHandle_t wifi_task = xTaskGetHandle("wifiTask");
909+
const TaskHandle_t wifi_task = xTaskGetHandle("wifiTask");
908910
const TaskHandle_t stream_task = xTaskGetHandle("stream");
909-
const UBaseType_t web_stack = uxTaskGetStackHighWaterMark(nullptr);
911+
const UBaseType_t web_stack = uxTaskGetStackHighWaterMark(nullptr);
910912
const UBaseType_t wifi_stack =
911913
wifi_task ? uxTaskGetStackHighWaterMark(wifi_task) : 0;
912914
const UBaseType_t stream_stack =
913915
stream_task ? uxTaskGetStackHighWaterMark(stream_task) : 0;
914916

915-
const wifi_mode_t wifi_mode = WiFi.getMode();
917+
const wifi_mode_t wifi_mode = WiFi.getMode();
916918
const wl_status_t wifi_status = WiFi.status();
917-
const bool sta_connected = wifi_status == WL_CONNECTED;
919+
const bool sta_connected = wifi_status == WL_CONNECTED;
918920
const IPAddress sta_ip = sta_connected ? WiFi.localIP() : IPAddress();
919921
const IPAddress ap_ip =
920922
(wifi_mode & WIFI_AP) ? WiFi.softAPIP() : IPAddress();
@@ -1103,9 +1105,9 @@ void webserverTask(void* arg) {
11031105
uint32_t conn_idx = 0;
11041106
bool prev_connected = false;
11051107
bool mdns_started = false;
1106-
uint32_t mdns_retry_at = 0;
1107-
uint32_t prev_sta_ip = 0;
1108-
uint32_t prev_ap_ip = 0;
1108+
uint32_t mdns_retry_at = 0;
1109+
uint32_t prev_sta_ip = 0;
1110+
uint32_t prev_ap_ip = 0;
11091111
uint8_t restart_countdown = 0;
11101112
uint8_t prev_active_count = 0;
11111113
uint8_t active_count = 0;
@@ -1146,25 +1148,26 @@ void webserverTask(void* arg) {
11461148
}
11471149
}
11481150
// AP and STA may change without the HTTP server becoming disconnected.
1149-
const uint32_t sta_ip = WiFi.isConnected() ? uint32_t(WiFi.localIP()) : 0;
1150-
const uint32_t ap_ip = (WiFi.getMode() & WIFI_MODE_AP)
1151-
? uint32_t(WiFi.softAPIP()) : 0;
1151+
const uint32_t sta_ip =
1152+
WiFi.isConnected() ? uint32_t(WiFi.localIP()) : 0;
1153+
const uint32_t ap_ip =
1154+
(WiFi.getMode() & WIFI_MODE_AP) ? uint32_t(WiFi.softAPIP()) : 0;
11521155
if (!sta_ip || sta_ip != prev_sta_ip || ap_ip != prev_ap_ip) {
11531156
if (mdns_started) MDNS.end();
1154-
mdns_started = false;
1157+
mdns_started = false;
11551158
mdns_retry_at = millis();
1156-
prev_sta_ip = sta_ip;
1157-
prev_ap_ip = ap_ip;
1159+
prev_sta_ip = sta_ip;
1160+
prev_ap_ip = ap_ip;
11581161
}
1159-
if (sta_ip && !mdns_started &&
1160-
int32_t(millis() - mdns_retry_at) >= 0) {
1162+
if (sta_ip && !mdns_started && int32_t(millis() - mdns_retry_at) >= 0) {
11611163
mdns_started = MDNS.begin(draw_param->net_hostname.c_str());
11621164
if (mdns_started) {
11631165
MDNS.addService("http", "tcp", 80);
11641166
} else {
11651167
// begin() may fail after allocating the responder.
11661168
MDNS.end();
1167-
ESP_LOGW("mDNS", "Responder startup failed; retrying in 5 seconds");
1169+
ESP_LOGW("mDNS",
1170+
"Responder startup failed; retrying in 5 seconds");
11681171
mdns_retry_at = millis() + 5000;
11691172
}
11701173
}

0 commit comments

Comments
 (0)