Fix SPI speed by mod tft_eSpi library
1. Raplace tft_eSpi by https://github.com/ohmytime/TFT_eSPI_DynamicSpeed 2.uncomment to enable dynamic SPI Speed // #define DYNAMIC_SPI_SPEED
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#define SMETERPIN 27
|
#define SMETERPIN 27
|
||||||
// #define ARS // uncomment for BGR type display (ARS version)
|
// #define ARS // uncomment for BGR type display (ARS version)
|
||||||
// #define CHINA_PORTABLE // uncomment for China Portable build (Simplified Chinese)
|
// #define CHINA_PORTABLE // uncomment for China Portable build (Simplified Chinese)
|
||||||
|
// #define DYNAMIC_SPI_SPEED // uncomment to enable dynamic SPI Speed https://github.com/ohmytime/TFT_eSPI_DynamicSpeed
|
||||||
|
|
||||||
#ifdef ARS
|
#ifdef ARS
|
||||||
#define VERSION "v2.00ARS"
|
#define VERSION "v2.00ARS"
|
||||||
|
|||||||
+11
-8
@@ -389,7 +389,7 @@ void BuildMenu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (spispeed == SPI_SPEED_DEFAULT) tftPrint(1, String(myLanguage[language][78]) + " " + String(SPI_FREQUENCY / 1000000, DEC), 270, ITEM3 + 6, PrimaryColor, PrimaryColorSmooth, 16);
|
if (spispeed == SPI_SPEED_DEFAULT) tftPrint(1, String(myLanguage[language][78]) + " " + String(SPI_FREQUENCY / 1000000, DEC), 270, ITEM3 + 6, PrimaryColor, PrimaryColorSmooth, 16);
|
||||||
else tftPrint(1, String(spispeed * 10 , DEC), 270, ITEM3 + 6, PrimaryColor, PrimaryColorSmooth, 16);
|
else tftPrint(1, String(spispeed * 10, DEC), 270, ITEM3 + 6, PrimaryColor, PrimaryColorSmooth, 16);
|
||||||
|
|
||||||
if (touchrotating) tftPrint(1, myLanguage[language][42], 310, ITEM2 + 6, PrimaryColor, PrimaryColorSmooth, 16); else tftPrint(1, myLanguage[language][30], 310, ITEM2 + 6, PrimaryColor, PrimaryColorSmooth, 16);
|
if (touchrotating) tftPrint(1, myLanguage[language][42], 310, ITEM2 + 6, PrimaryColor, PrimaryColorSmooth, 16); else tftPrint(1, myLanguage[language][30], 310, ITEM2 + 6, PrimaryColor, PrimaryColorSmooth, 16);
|
||||||
break;
|
break;
|
||||||
@@ -897,15 +897,16 @@ void MenuUp() {
|
|||||||
|
|
||||||
case ITEM3:
|
case ITEM3:
|
||||||
if (spispeed == SPI_SPEED_DEFAULT) tftPrint(1, String(myLanguage[language][78]) + " " + String(SPI_FREQUENCY / 1000000, DEC), 155, 118, BackgroundColor, BackgroundColor, 28);
|
if (spispeed == SPI_SPEED_DEFAULT) tftPrint(1, String(myLanguage[language][78]) + " " + String(SPI_FREQUENCY / 1000000, DEC), 155, 118, BackgroundColor, BackgroundColor, 28);
|
||||||
else tftPrint(1, String(spispeed * 10 , DEC), 155, 118, BackgroundColor, BackgroundColor, 28);
|
else tftPrint(1, String(spispeed * 10, DEC), 155, 118, BackgroundColor, BackgroundColor, 28);
|
||||||
|
|
||||||
spispeed++;
|
spispeed++;
|
||||||
if (spispeed > SPI_SPEED_COUNT - 1) spispeed = 0;
|
if (spispeed > SPI_SPEED_COUNT - 1) spispeed = 0;
|
||||||
|
|
||||||
if (spispeed == SPI_SPEED_DEFAULT) tftPrint(1, String(myLanguage[language][78]) + " " + String(SPI_FREQUENCY / 1000000, DEC), 155, 118, PrimaryColor, PrimaryColorSmooth, 28);
|
if (spispeed == SPI_SPEED_DEFAULT) tftPrint(1, String(myLanguage[language][78]) + " " + String(SPI_FREQUENCY / 1000000, DEC), 155, 118, PrimaryColor, PrimaryColorSmooth, 28);
|
||||||
else tftPrint(1, String(spispeed * 10 , DEC), 155, 118, PrimaryColor, PrimaryColorSmooth, 28);
|
else tftPrint(1, String(spispeed * 10, DEC), 155, 118, PrimaryColor, PrimaryColorSmooth, 28);
|
||||||
|
#ifdef DYNAMIC_SPI_SPEED
|
||||||
if (spispeed == SPI_SPEED_DEFAULT) SPI.setFrequency(SPI_FREQUENCY); else SPI.setFrequency(spispeed * 1000000);
|
if (spispeed == SPI_SPEED_DEFAULT) tft.setSPISpeed(SPI_FREQUENCY / 1000000); else tft.setSPISpeed(spispeed * 10);
|
||||||
|
#endif
|
||||||
spispeedold = spispeed;
|
spispeedold = spispeed;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1456,15 +1457,17 @@ void MenuDown() {
|
|||||||
break;
|
break;
|
||||||
case ITEM3:
|
case ITEM3:
|
||||||
if (spispeed == SPI_SPEED_DEFAULT) tftPrint(1, String(myLanguage[language][78]) + " " + String(SPI_FREQUENCY / 1000000, DEC), 155, 118, BackgroundColor, BackgroundColor, 28);
|
if (spispeed == SPI_SPEED_DEFAULT) tftPrint(1, String(myLanguage[language][78]) + " " + String(SPI_FREQUENCY / 1000000, DEC), 155, 118, BackgroundColor, BackgroundColor, 28);
|
||||||
else tftPrint(1, String(spispeed * 10 , DEC), 155, 118, BackgroundColor, BackgroundColor, 28);
|
else tftPrint(1, String(spispeed * 10, DEC), 155, 118, BackgroundColor, BackgroundColor, 28);
|
||||||
|
|
||||||
spispeed--;
|
spispeed--;
|
||||||
if (spispeed > SPI_SPEED_COUNT - 1) spispeed = SPI_SPEED_COUNT - 1;
|
if (spispeed > SPI_SPEED_COUNT - 1) spispeed = SPI_SPEED_COUNT - 1;
|
||||||
|
|
||||||
if (spispeed == SPI_SPEED_DEFAULT) tftPrint(1, String(myLanguage[language][78]) + " " + String(SPI_FREQUENCY / 1000000, DEC), 155, 118, PrimaryColor, PrimaryColorSmooth, 28);
|
if (spispeed == SPI_SPEED_DEFAULT) tftPrint(1, String(myLanguage[language][78]) + " " + String(SPI_FREQUENCY / 1000000, DEC), 155, 118, PrimaryColor, PrimaryColorSmooth, 28);
|
||||||
else tftPrint(1, String(spispeed * 10 , DEC), 155, 118, PrimaryColor, PrimaryColorSmooth, 28);
|
else tftPrint(1, String(spispeed * 10, DEC), 155, 118, PrimaryColor, PrimaryColorSmooth, 28);
|
||||||
|
|
||||||
if (spispeed == SPI_SPEED_DEFAULT) SPI.setFrequency(SPI_FREQUENCY); else SPI.setFrequency(spispeed * 1000000);
|
#ifdef DYNAMIC_SPI_SPEED
|
||||||
|
if (spispeed == SPI_SPEED_DEFAULT) tft.setSPISpeed(SPI_FREQUENCY / 1000000); else tft.setSPISpeed(spispeed * 10);
|
||||||
|
#endif
|
||||||
spispeedold = spispeed;
|
spispeedold = spispeed;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user