Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6efeda2

Browse files
author
accounter895
committed
Fixed the host part of the case compilation, such as the Basic folder Display,Speaker and other multiple files
1 parent 89bc31d commit 6efeda2

File tree

4 files changed

+873
-19
lines changed

4 files changed

+873
-19
lines changed

‎src/M5Display.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#include "M5Display.h"
22

3+
// WiFi 功能的条件编译
4+
#ifdef ESP32
5+
#include <WiFi.h>
6+
#include <HTTPClient.h>
7+
#define M5_WIFI_ENABLED
8+
#endif
9+
310
#define BLK_PWM_CHANNEL 7 // LEDC_CHANNEL_7
411

512
M5Display::M5Display() : TFT_eSPI() {
@@ -10,10 +17,20 @@ void M5Display::begin() {
1017
setRotation(1);
1118
fillScreen(0);
1219

20+
#if defined(ESP_IDF_VERSION_MAJOR) && (ESP_IDF_VERSION_MAJOR >= 5)
21+
// ESP32 Arduino 3.x 新 API
22+
ledcAttach(TFT_BL, 44100, 8);
23+
ledcWrite(TFT_BL, 80); // 直接使用 TFT_BL 引脚
24+
#else
25+
// ESP32 Arduino 2.x 旧 API
26+
ledcSetup(BLK_PWM_CHANNEL, 44100, 8);
27+
ledcAttachPin(TFT_BL, BLK_PWM_CHANNEL);
28+
ledcWrite(BLK_PWM_CHANNEL, 80);
29+
#endif
30+
1331
// Init the back-light LED PWM
14-
ledcSetup(BLK_PWM_CHANNEL, 44100, 8);
15-
ledcAttachPin(TFT_BL, BLK_PWM_CHANNEL);
16-
ledcWrite(BLK_PWM_CHANNEL, 80);
32+
// ledcSetup(BLK_PWM_CHANNEL, 44100, 8);
33+
// ledcAttachPin(TFT_BL, BLK_PWM_CHANNEL);
1734
}
1835

1936
void M5Display::sleep() {
@@ -344,7 +361,7 @@ static bool jpgDecode(jpg_file_decoder_t *jpeg,
344361
static uint8_t work[3100];
345362
JDEC decoder;
346363

347-
JRESULT jres = jd_prepare(&decoder, reader, work, 3100, jpeg);
364+
JRESULT jres = jd_prepare(&decoder, (UINT(*)(JDEC*,BYTE*,UINT))reader, work, 3100, jpeg);
348365
if (jres != JDR_OK) {
349366
log_e("jd_prepare failed! %s", jd_errors[jres]);
350367
return false;
@@ -366,7 +383,7 @@ static bool jpgDecode(jpg_file_decoder_t *jpeg,
366383
jpeg->outHeight =
367384
(jpgMaxHeight > jpeg->maxHeight) ? jpeg->maxHeight : jpgMaxHeight;
368385

369-
jres = jd_decomp(&decoder, jpgWrite, (uint8_t)jpeg->scale);
386+
jres = jd_decomp(&decoder, (UINT(*)(JDEC*,void*,JRECT*))jpgWrite, (uint8_t)jpeg->scale);
370387
if (jres != JDR_OK) {
371388
log_e("jd_decomp failed! %s", jd_errors[jres]);
372389
return false;
@@ -558,6 +575,8 @@ void M5Display::drawPngUrl(const char *url, uint16_t x, uint16_t y,
558575
uint16_t maxWidth, uint16_t maxHeight, uint16_t offX,
559576
uint16_t offY, double scale,
560577
uint8_t alphaThreshold) {
578+
#ifdef M5_WIFI_ENABLED
579+
561580
HTTPClient http;
562581

563582
if (WiFi.status() != WL_CONNECTED) {
@@ -632,4 +651,10 @@ void M5Display::drawPngUrl(const char *url, uint16_t x, uint16_t y,
632651

633652
pngle_destroy(pngle);
634653
http.end();
654+
655+
#else
656+
// WiFi 未启用时的处理
657+
Serial.println("WiFi functionality disabled - drawPngUrl not available");
658+
Serial.printf("Requested URL: %s\n", url);
659+
#endif
635660
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /