diff --git a/include/constants.h b/include/constants.h index 04529da..49c343f 100644 --- a/include/constants.h +++ b/include/constants.h @@ -454,11 +454,6 @@ enum RADIO_FM_DEEMPHASIS { DEEMPHASIS_COUNT }; -enum SPI_SPEED_ENUM { - SPI_SPEED_DEFAULT = 0, SPI_SPEED_10M, SPI_SPEED_20M, SPI_SPEED_30M, SPI_SPEED_40M, SPI_SPEED_50M, SPI_SPEED_60M, SPI_SPEED_70M, - SPI_SPEED_COUNT -}; - enum RADIO_MEM_POS_STATUS { MEM_DARK, MEM_NORMAL, MEM_EXIST }; diff --git a/include/language.h b/include/language.h index ed9cf10..89d744e 100644 --- a/include/language.h +++ b/include/language.h @@ -226,7 +226,7 @@ static const char* const myLanguage[22][298] PROGMEM = { "Large", // 198 "All", // 199 "Fast PS", // 200 - "Default", // 201 + "Default", // 201 TODO: remove "Mute screen on\nXDRGTK connection", // 202 "FMSI stereo\nimprovement", // 203 "Function only available\non TEF6687/6689!", // 204 diff --git a/lib/TFT_eSPI/TFT_eSPI.cpp b/lib/TFT_eSPI/TFT_eSPI.cpp index be15c5a..b48b60b 100644 --- a/lib/TFT_eSPI/TFT_eSPI.cpp +++ b/lib/TFT_eSPI/TFT_eSPI.cpp @@ -39,7 +39,7 @@ void TFT_eSPI::pushBlock(uint16_t color, uint32_t len) { len = len - rem; if (rem) { - while (*_spi_cmd&SPI_USR); + SPI_BUSY_CHECK; for (i=0; i < rem; i+=2) *spi_w++ = color32; *_spi_mosi_dlen = (rem << 4) - 1; *_spi_cmd = SPI_USR; @@ -47,12 +47,12 @@ void TFT_eSPI::pushBlock(uint16_t color, uint32_t len) { i = i>>1; while(i++<16) *spi_w++ = color32; } - while (*_spi_cmd&SPI_USR); + SPI_BUSY_CHECK; if (!rem) while (i++<16) *spi_w++ = color32; *_spi_mosi_dlen = 511; while(len) { - while (*_spi_cmd&SPI_USR); + SPI_BUSY_CHECK; *_spi_cmd = SPI_USR; len -= 32; } @@ -70,17 +70,17 @@ void TFT_eSPI::pushSwapBytePixels(const void* data_in, uint32_t len) { color[i++] = DAT8TO32(data); data += 4; } - while (READ_PERI_REG(SPI_CMD_REG(VSPI))&SPI_USR); - WRITE_PERI_REG(SPI_W0_REG(VSPI), color[0]); - WRITE_PERI_REG(SPI_W1_REG(VSPI), color[1]); - WRITE_PERI_REG(SPI_W2_REG(VSPI), color[2]); - WRITE_PERI_REG(SPI_W3_REG(VSPI), color[3]); - WRITE_PERI_REG(SPI_W4_REG(VSPI), color[4]); - WRITE_PERI_REG(SPI_W5_REG(VSPI), color[5]); - WRITE_PERI_REG(SPI_W6_REG(VSPI), color[6]); - WRITE_PERI_REG(SPI_W7_REG(VSPI), color[7]); - WRITE_PERI_REG(SPI_W8_REG(VSPI), color[8]); - WRITE_PERI_REG(SPI_W9_REG(VSPI), color[9]); + SPI_BUSY_CHECK; + WRITE_PERI_REG(SPI_W0_REG(VSPI), color[0]); + WRITE_PERI_REG(SPI_W1_REG(VSPI), color[1]); + WRITE_PERI_REG(SPI_W2_REG(VSPI), color[2]); + WRITE_PERI_REG(SPI_W3_REG(VSPI), color[3]); + WRITE_PERI_REG(SPI_W4_REG(VSPI), color[4]); + WRITE_PERI_REG(SPI_W5_REG(VSPI), color[5]); + WRITE_PERI_REG(SPI_W6_REG(VSPI), color[6]); + WRITE_PERI_REG(SPI_W7_REG(VSPI), color[7]); + WRITE_PERI_REG(SPI_W8_REG(VSPI), color[8]); + WRITE_PERI_REG(SPI_W9_REG(VSPI), color[9]); WRITE_PERI_REG(SPI_W10_REG(VSPI), color[10]); WRITE_PERI_REG(SPI_W11_REG(VSPI), color[11]); WRITE_PERI_REG(SPI_W12_REG(VSPI), color[12]); @@ -96,9 +96,9 @@ void TFT_eSPI::pushSwapBytePixels(const void* data_in, uint32_t len) { uint32_t i = 0; while(i<8) { color[i++] = DAT8TO32(data); - data +=4 ; + data += 4; } - while (READ_PERI_REG(SPI_CMD_REG(VSPI))&SPI_USR); + SPI_BUSY_CHECK; WRITE_PERI_REG(SPI_MOSI_DLEN_REG(VSPI), 255); WRITE_PERI_REG(SPI_W0_REG(VSPI), color[0]); WRITE_PERI_REG(SPI_W1_REG(VSPI), color[1]); @@ -113,15 +113,14 @@ void TFT_eSPI::pushSwapBytePixels(const void* data_in, uint32_t len) { } if (len) { - while (READ_PERI_REG(SPI_CMD_REG(VSPI))&SPI_USR); + SPI_BUSY_CHECK; WRITE_PERI_REG(SPI_MOSI_DLEN_REG(VSPI), (len << 4) - 1); for (uint32_t i=0; i <= (len<<1); i+=4) { WRITE_PERI_REG(SPI_W0_REG(VSPI)+i, DAT8TO32(data)); data += 4; } SET_PERI_REG_MASK(SPI_CMD_REG(VSPI), SPI_USR); } - while (READ_PERI_REG(SPI_CMD_REG(VSPI))&SPI_USR); - + SPI_BUSY_CHECK; } void TFT_eSPI::pushPixels(const void* data_in, uint32_t len){ @@ -136,7 +135,7 @@ void TFT_eSPI::pushPixels(const void* data_in, uint32_t len){ if (len > 31) { WRITE_PERI_REG(SPI_MOSI_DLEN_REG(VSPI), 511); while(len>31) { - while (READ_PERI_REG(SPI_CMD_REG(VSPI))&SPI_USR); + SPI_BUSY_CHECK; WRITE_PERI_REG(SPI_W0_REG(VSPI), *data++); WRITE_PERI_REG(SPI_W1_REG(VSPI), *data++); WRITE_PERI_REG(SPI_W2_REG(VSPI), *data++); @@ -159,12 +158,12 @@ void TFT_eSPI::pushPixels(const void* data_in, uint32_t len){ } if (len) { - while (READ_PERI_REG(SPI_CMD_REG(VSPI))&SPI_USR); + SPI_BUSY_CHECK; WRITE_PERI_REG(SPI_MOSI_DLEN_REG(VSPI), (len << 4) - 1); for (uint32_t i=0; i <= (len<<1); i+=4) WRITE_PERI_REG((SPI_W0_REG(VSPI) + i), *data++); SET_PERI_REG_MASK(SPI_CMD_REG(VSPI), SPI_USR); } - while (READ_PERI_REG(SPI_CMD_REG(VSPI))&SPI_USR); + SPI_BUSY_CHECK; } // Clipping macro for pushImage @@ -224,8 +223,7 @@ inline void TFT_eSPI::end_tft_read() { SET_BUS_WRITE_MODE; } -void TFT_eSPI::setViewport(int32_t x, int32_t y, int32_t w, int32_t h, bool vpDatum) -{ +void TFT_eSPI::setViewport(int32_t x, int32_t y, int32_t w, int32_t h, bool vpDatum) { _xDatum = x; _yDatum = y; _xWidth = w; @@ -404,7 +402,7 @@ void TFT_eSPI::init() { gpio_set_level((gpio_num_t)TFT_RST, 1); } - delay(35); // Wait for reset to complete + delay(34); // Wait for reset to complete begin_tft_write(); @@ -420,7 +418,7 @@ void TFT_eSPI::setRotation(uint8_t m) { #include "ILI9341_Rotation.h" - delayMicroseconds(10); + delayMicroseconds(9); end_tft_write(); @@ -1568,8 +1566,7 @@ void TFT_eSPI::readAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h) ** Function name: drawPixel ** Description: push a single pixel at an arbitrary position ***************************************************************************************/ -void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color) -{ +void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color) { if (_vpOoB) return; x+= _xDatum; @@ -1578,13 +1575,8 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color) // Range checking if ((x < _vpX) || (y < _vpY) ||(x >= _vpW) || (y >= _vpH)) return; -#if defined (MULTI_TFT_SUPPORT) - addr_row = 0xFFFF; - addr_col = 0xFFFF; -#endif - begin_tft_write(); - SPI_BUSY_CHECK; + SPI_BUSY_CHECK; // No need to send x if it has not changed (speeds things up) if (addr_col != x) { @@ -1607,12 +1599,7 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color) end_tft_write(); } -/*************************************************************************************** -** Function name: pushColor -** Description: push a single pixel -***************************************************************************************/ -void TFT_eSPI::pushColor(uint16_t color) -{ +void TFT_eSPI::pushColor(uint16_t color) { begin_tft_write(); SPI_BUSY_CHECK; @@ -1622,12 +1609,7 @@ void TFT_eSPI::pushColor(uint16_t color) } -/*************************************************************************************** -** Function name: pushColor -** Description: push a single colour to "len" pixels -***************************************************************************************/ -void TFT_eSPI::pushColor(uint16_t color, uint32_t len) -{ +void TFT_eSPI::pushColor(uint16_t color, uint32_t len) { begin_tft_write(); pushBlock(color, len); @@ -1635,14 +1617,6 @@ void TFT_eSPI::pushColor(uint16_t color, uint32_t len) end_tft_write(); } -void TFT_eSPI::startWrite() { - begin_tft_write(); -} - -void TFT_eSPI::endWrite() { - end_tft_write(); // Release SPI bus -} - void TFT_eSPI::writeColor(uint16_t color, uint32_t len) { pushBlock(color, len); } @@ -2546,8 +2520,7 @@ void TFT_eSPI::loadFont(const uint8_t array[], uint8_t font) { fontOwned[font] = true; } -void TFT_eSPI::loadMetrics(uint8_t font) -{ +void TFT_eSPI::loadMetrics(uint8_t font) { uint32_t headerPtr = 24; uint32_t bitmapPtr = headerPtr + gFonts[font].gCount * 28; @@ -2562,20 +2535,18 @@ void TFT_eSPI::loadMetrics(uint8_t font) uint16_t gNum = 0; while (gNum < gFonts[font].gCount) { - gUnicode[font][gNum] = (uint16_t)readInt32(); // Unicode code point value - gHeight[font][gNum] = (uint8_t)readInt32(); // Height of glyph - gWidth[font][gNum] = (uint8_t)readInt32(); // Width of glyph - gxAdvance[font][gNum] = (uint8_t)readInt32(); // xAdvance - to move x cursor - gdY[font][gNum] = (int16_t)readInt32(); // y delta from baseline - gdX[font][gNum] = (int8_t)readInt32(); // x delta from cursor + gUnicode[font][gNum] = (uint16_t)readInt32(); // Unicode code point value + gHeight[font][gNum] = (uint8_t)readInt32(); // Height of glyph + gWidth[font][gNum] = (uint8_t)readInt32(); // Width of glyph + gxAdvance[font][gNum] = (uint8_t)readInt32(); // xAdvance - to move x cursor + gdY[font][gNum] = (int16_t)readInt32(); // y delta from baseline + gdX[font][gNum] = (int8_t)readInt32(); // x delta from cursor readInt32(); // ignored // Different glyph sets have different descent values not always based on "p", so get maximum glyph descent - if (((int16_t)gHeight[font][gNum] - (int16_t)gdY[font][gNum]) > gFonts[font].maxDescent) - { + if (((int16_t)gHeight[font][gNum] - (int16_t)gdY[font][gNum]) > gFonts[font].maxDescent) { // Avoid UTF coding values and characters that tend to give duff values - if (((gUnicode[font][gNum] > 0x20) && (gUnicode[font][gNum] < 0xA0) && (gUnicode[font][gNum] != 0x7F)) || (gUnicode[font][gNum] > 0xFF)) - { + if (((gUnicode[font][gNum] > 0x20) && (gUnicode[font][gNum] < 0xA0) && (gUnicode[font][gNum] != 0x7F)) || (gUnicode[font][gNum] > 0xFF)) { gFonts[font].maxDescent = gHeight[font][gNum] - gdY[font][gNum]; } } @@ -2698,9 +2669,7 @@ void TFT_eSPI::drawGlyph(uint16_t code, uint16_t font) { uint16_t gNum = 0; bool found = getUnicodeIndex(code, &gNum, font); - if (found) - { - + if (found) { if (textwrapX && (cursor_x + gWidth[font][gNum] + gdX[font][gNum] > width())) { cursor_y += gFonts[font].yAdvance; @@ -2710,7 +2679,6 @@ void TFT_eSPI::drawGlyph(uint16_t code, uint16_t font) { if (textwrapY && ((cursor_y + gFonts[font].yAdvance) >= height())) cursor_y = 0; if (cursor_x == 0) cursor_x -= gdX[font][gNum]; - uint8_t* pbuffer = nullptr; const uint8_t* gPtr = (const uint8_t*) gFonts[font].gArray; int16_t cy = cursor_y + gFonts[font].maxAscent - gdY[font][gNum]; @@ -2726,7 +2694,7 @@ void TFT_eSPI::drawGlyph(uint16_t code, uint16_t font) { int16_t bx = 0; uint8_t pixel; - startWrite(); + begin_tft_write(); int16_t fillwidth = 0; int16_t fillheight = 0; @@ -2751,14 +2719,10 @@ void TFT_eSPI::drawGlyph(uint16_t code, uint16_t font) { } } - for (int32_t y = 0; y < gHeight[font][gNum]; y++) - { - for (int32_t x = 0; x < gWidth[font][gNum]; x++) - { + for (int32_t y = 0; y < gHeight[font][gNum]; y++) { + for (int32_t x = 0; x < gWidth[font][gNum]; x++) { pixel = pgm_read_byte(gPtr + gBitmap[font][gNum] + x + gWidth[font][gNum] * y); - - if (pixel) - { + if (pixel) { if (bl) { drawFastHLine( bxs, y + cy, bl, textbgcolor); bl = 0; } if (pixel != 0xFF) { @@ -2799,9 +2763,8 @@ void TFT_eSPI::drawGlyph(uint16_t code, uint16_t font) { } } - if (pbuffer) free(pbuffer); cursor_x += gxAdvance[font][gNum]; - endWrite(); + end_tft_write(); } else { @@ -3296,14 +3259,12 @@ uint16_t TFT_eSprite::getPaletteColor(uint8_t index) { void TFT_eSprite::deleteSprite() { - if (_colorMap != nullptr) - { + if (_colorMap != nullptr) { free(_colorMap); _colorMap = nullptr; } - if (_created) - { + if (_created) { free(_img8_1); _img8 = nullptr; _created = false; @@ -3483,7 +3444,7 @@ bool TFT_eSprite::pushSprite(int32_t tx, int32_t ty, int32_t sx, int32_t sy, int sw--; uint32_t yp = (_xs + ds + _iwidth * _ys)>>1; - _tft->startWrite(); + _tft->begin_tft_write(); while (sh--) { if (ds) _tft->drawPixel(tx, ty, readPixel(_xs, _ys) ); @@ -3493,22 +3454,19 @@ bool TFT_eSprite::pushSprite(int32_t tx, int32_t ty, int32_t sx, int32_t sy, int ty++; yp += (_iwidth>>1); } - _tft->endWrite(); + _tft->end_tft_write(); } } else // 1bpp { // Check if a faster block copy to screen is possible if ( sx == 0 && sw == _dwidth) - _tft->pushImage(tx, ty, sw, sh, _img8 + (_bitwidth>>3) * _ys, (bool)false ); + _tft->pushImage(tx, ty, sw, sh, _img8 + (_bitwidth>>3) * _ys, false); else // Render line by line { - _tft->startWrite(); - while (sh--) - { - _tft->pushImage(tx, ty++, sw, 1, _img8 + (_bitwidth>>3) * _ys++, (bool)false ); - } - _tft->endWrite(); + _tft->begin_tft_write(); + while (sh--) _tft->pushImage(tx, ty++, sw, 1, _img8 + (_bitwidth>>3) * _ys++, false); + _tft->end_tft_write(); } } @@ -3644,8 +3602,7 @@ uint16_t TFT_eSprite::readPixel(int32_t x, int32_t y) else return _tft->bitmap_bg; } -void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data, uint8_t sbpp) -{ +void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data, uint8_t sbpp) { if (data == nullptr || !_created) return; PI_CLIP; @@ -3774,7 +3731,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_ } } -void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data) { +void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data) { pushImage(x, y, w, h, (uint16_t*) data); } @@ -4217,9 +4174,7 @@ void TFT_eSprite::drawGlyph(uint16_t code, uint16_t font) { bg_cursor_x = cursor_x; last_cursor_x = cursor_x; return; - } - - if (code == '\n') { + } else if (code == '\n') { cursor_x = 0; bg_cursor_x = 0; last_cursor_x = 0; @@ -4253,7 +4208,6 @@ void TFT_eSprite::drawGlyph(uint16_t code, uint16_t font) { if ( cursor_x == 0) cursor_x -= gdX[font][gNum]; } - uint8_t* pbuffer = nullptr; const uint8_t* gPtr = (const uint8_t*) gFonts[font].gArray; int16_t cy = cursor_y + gFonts[font].maxAscent - gdY[font][gNum]; @@ -4325,15 +4279,13 @@ void TFT_eSprite::drawGlyph(uint16_t code, uint16_t font) { if (fillheight > 0) fillRect(bg_cursor_x, cy + gHeight[font][gNum], fillwidth, fillheight, textbgcolor); } - if (pbuffer) free(pbuffer); cursor_x += gxAdvance[font][gNum]; if (newSprite) { pushSprite(cx, cursor_y); deleteSprite(); } - } - else { + } else { drawRect(cursor_x, cursor_y + gFonts[font].maxAscent - gFonts[font].ascent, gFonts[font].spaceWidth, gFonts[font].ascent, textcolor); cursor_x += gFonts[font].spaceWidth + 1; } @@ -4355,4 +4307,8 @@ void TFT_eSprite::copyFontFromTFT(uint8_t source, uint8_t destination) { memcpy(&gFonts[destination], &_tft->gFonts[source], sizeof(fontMetrics)); fontOwned[destination] = false; +} + +void TFT_eSprite::copyAllFontsFromTFT() { + for(uint8_t i = 0; i < FONT_COUNT; i++) copyFontFromTFT(i, i); } \ No newline at end of file diff --git a/lib/TFT_eSPI/TFT_eSPI.h b/lib/TFT_eSPI/TFT_eSPI.h index 4d9584e..1107709 100644 --- a/lib/TFT_eSPI/TFT_eSPI.h +++ b/lib/TFT_eSPI/TFT_eSPI.h @@ -362,10 +362,7 @@ class TFT_eSPI { friend class TFT_eSprite; uint8_t spiBusyCheck = 0; // Number of ESP32 transfer buffers to check - // Bare metal functions - void startWrite(); // Begin SPI transaction void writeColor(uint16_t color, uint32_t len); // Deprecated, use pushBlock() - void endWrite(); // End SPI transaction // Global variables uint32_t textcolor, textbgcolor; // Text foreground and background colours @@ -504,7 +501,7 @@ class TFT_eSprite : public TFT_eSPI { public: explicit TFT_eSprite(TFT_eSPI *tft); ~TFT_eSprite(); - void* createSprite(int16_t width, int16_t height, uint8_t frames = 1); + void* createSprite(int16_t width = TFT_WIDTH, int16_t height = TFT_HEIGHT, uint8_t frames = 1); void* getPointer(); bool created(); void deleteSprite(); @@ -538,6 +535,7 @@ class TFT_eSprite : public TFT_eSPI { height(); void drawGlyph(uint16_t code, uint16_t font); void copyFontFromTFT(uint8_t source, uint8_t destination); + void copyAllFontsFromTFT(); private: diff --git a/src/globals.cpp b/src/globals.cpp index d2b8acb..689076a 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -2,7 +2,6 @@ bool RDSstatus; bool RDSstatusold; -TFT_eSPI tft = TFT_eSPI(); bool Data_Accelerator = false; @@ -327,6 +326,7 @@ const size_t language_entrynumber = sizeof(myLanguage[0]) / sizeof(myLanguage[0] mem presets[EE_PRESETS_CNT]; TEF6686 radio; +TFT_eSPI tft = TFT_eSPI(); // FrequencySprite.createSprite(200, 50); // PSSprite.createSprite(150, 32); diff --git a/src/gui.cpp b/src/gui.cpp index 5cffbbe..c47c68b 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -1635,14 +1635,14 @@ void ShowOneLine(byte position, byte item, bool selected) { FullLineSprite.setTextDatum(TR_DATUM); - if (spispeed == 7) { + if (spispeed == 0) { FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); FullLineSprite.drawString(textUI(83), 298, 2); } else { FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); FullLineSprite.drawString("MHz", 298, 2); FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); - FullLineSprite.drawString((spispeed == SPI_SPEED_DEFAULT ? String(textUI(201)) + " " + String(SPI_FREQUENCY / 1000000, DEC) : String(spispeed * 10, DEC)), 258, 2); + FullLineSprite.drawString(String(spispeed), 258, 2); } break; @@ -2723,7 +2723,7 @@ void ShowOneButton(byte position, byte item, bool selected) { PSSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); PSSprite.drawString(shortLine(removeNewline(textUI(78))), 75, 1); - if (spispeed == 7) { + if (spispeed == 0) { PSSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); PSSprite.drawString(textUI(83), 75, 15); } else { @@ -2732,7 +2732,7 @@ void ShowOneButton(byte position, byte item, bool selected) { PSSprite.drawString("MHz", 77, 15); PSSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); PSSprite.setTextDatum(TR_DATUM); - PSSprite.drawString((spispeed == SPI_SPEED_DEFAULT ? String(textUI(201)) + " " + String(SPI_FREQUENCY / 1000000, DEC) : String(spispeed * 10, DEC)), 73, 15); + PSSprite.drawString(String(spispeed), 73, 15); } break; @@ -2836,9 +2836,8 @@ void BuildMenu() { default: tft.pushImage (0, 0, 320, 240, configurationbackground); break; } - if (!submenu) { - tftPrint(ACENTER, textUI(29), 160, 6, PrimaryColor, PrimaryColorSmooth, 16); - } else { + if (!submenu) tftPrint(ACENTER, textUI(29), 160, 6, PrimaryColor, PrimaryColorSmooth, 16); + else { tftPrint(ALEFT, textUI(181), (hardwaremodel == PORTABLE_TOUCH_ILI9341 ? 20 : 8), 6, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(ARIGHT, textUI(186 + menupage - 1), 312, 6, ActiveColor, ActiveColorSmooth, 16); } @@ -3351,32 +3350,46 @@ void MenuUpDown(bool dir) { case ITEM10: if (dir) { - spispeed++; - if (spispeed > SPI_SPEED_COUNT - 1) spispeed = 0; + if (spispeed == 0) { + spispeed = 4; + } else if (spispeed < 10) { + spispeed += 1; + if (spispeed == 10) spispeed = 10; + } else { + spispeed += 10; + if (spispeed > 80) spispeed = 0; + } } else { - spispeed--; - if (spispeed > SPI_SPEED_COUNT - 1) spispeed = SPI_SPEED_COUNT - 1; + if (spispeed == 0) { + spispeed = 80; + } else if (spispeed <= 10) { + spispeed -= 1; + if (spispeed < 4) spispeed = 0; + } else { + spispeed -= 10; + if (spispeed < 10) spispeed = 9; + } } OneBigLineSprite.setTextDatum(TL_DATUM); OneBigLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); - if (spispeed != 7) { + + if (spispeed == 0) { + // Auto mode + OneBigLineSprite.setTextDatum(TC_DATUM); + OneBigLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); + OneBigLineSprite.drawString(textUI(83), 135, 0); + setAutoSpeedSPI(); + } else { + // Manual speed mode OneBigLineSprite.drawString("MHz", 175, 0); OneBigLineSprite.setTextDatum(TR_DATUM); - } else { - OneBigLineSprite.setTextDatum(TC_DATUM); - } - - OneBigLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); - if (spispeed == 7) { - OneBigLineSprite.drawString(textUI(83), 135, 0); - } else { - OneBigLineSprite.drawString((spispeed == SPI_SPEED_DEFAULT ? String(textUI(201)) + " " + String(SPI_FREQUENCY / 1000000, DEC) : String(spispeed * 10, DEC)), 160, 0); + OneBigLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); + OneBigLineSprite.drawString(String(spispeed), 160, 0); + tft.setSPISpeed(spispeed); } + OneBigLineSprite.pushSprite(24, 118); - if (spispeed == SPI_SPEED_DEFAULT) tft.setSPISpeed(SPI_FREQUENCY / 1000000); - else if (spispeed == 7) setAutoSpeedSPI(); - else tft.setSPISpeed(spispeed * 10); break; } break; @@ -3633,11 +3646,11 @@ void MenuUpDown(bool dir) { switch (CurrentTheme) { case 7: OneBigLineSprite.pushImage(-11, -88, 292, 170, popupbackground_wo); - tft.pushImage (13, 30, 292, 170, popupbackground_wo); + tft.pushImage(13, 30, 292, 170, popupbackground_wo); break; default: OneBigLineSprite.pushImage(-11, -88, 292, 170, popupbackground); - tft.pushImage (13, 30, 292, 170, popupbackground); + tft.pushImage(13, 30, 292, 170, popupbackground); break; } @@ -4443,15 +4456,15 @@ void DoMenu() { if (menupage != INDEX) { menuopen = true; switch (CurrentTheme) { - case 7: tft.pushImage (13, 30, 292, 170, popupbackground_wo); break; - default: tft.pushImage (13, 30, 292, 170, popupbackground); break; + case 7: tft.pushImage(13, 30, 292, 170, popupbackground_wo); break; + default: tft.pushImage(13, 30, 292, 170, popupbackground); break; } showMenuOpenTouchButtons(); if (menupage == CONNECTIVITY && menuoption == ITEM3) { switch (CurrentTheme) { - case 7: tft.pushImage (0, 0, 320, 240, configurationbackground_wo); break; - default: tft.pushImage (0, 0, 320, 240, configurationbackground); break; + case 7: tft.pushImage(0, 0, 320, 240, configurationbackground_wo); break; + default: tft.pushImage(0, 0, 320, 240, configurationbackground); break; } tftPrint(ACENTER, textUI(189 + menupage - 1), 160, 6, ActiveColor, ActiveColorSmooth, 16); } @@ -4546,7 +4559,7 @@ void DoMenu() { tft.fillRoundRect(12, 8, 296, 226, 5, BackgroundColor); tftPrint(ACENTER, textUI(68), 155, 13, ActiveColor, ActiveColorSmooth, 28); tftPrint(ACENTER, textUI(69), 155, 55, ActiveColor, ActiveColorSmooth, 28); - tftPrint(ACENTER, "PE5PVB", 155, 38, PrimaryColor, PrimaryColorSmooth, 16); + tftPrint(ACENTER, "KubaPro010", 155, 38, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(ARIGHT, "ohmytime", 145, 80, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(ARIGHT, "HyperDX", 145, 95, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(ALEFT, "MCelliotG", 155, 80, PrimaryColor, PrimaryColorSmooth, 16); @@ -4564,7 +4577,7 @@ void DoMenu() { tftPrint(ARIGHT, "marsel90-1", 145, 185, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(ALEFT, "lawendel", 155, 185, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(ARIGHT, "KB8U", 145, 200, PrimaryColor, PrimaryColorSmooth, 16); - tftPrint(ALEFT, "KubaPro010", 155, 200, PrimaryColor, PrimaryColorSmooth, 16); + tftPrint(ALEFT, "PE5PVB", 155, 200, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(ACENTER, "github.com/KubaPro010/TEF6686_ESP32", 155, 215, ActiveColor, ActiveColorSmooth, 16); if (hardwaremodel == PORTABLE_TOUCH_ILI9341) { tft.fillRoundRect(240, 36, 60, 40, 6, FrameColor); @@ -4690,18 +4703,15 @@ void DoMenu() { OneBigLineSprite.setTextDatum(TL_DATUM); OneBigLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); - if (spispeed != 7) { + if (spispeed != 0) { OneBigLineSprite.drawString("MHz", 175, 0); OneBigLineSprite.setTextDatum(TR_DATUM); } else { OneBigLineSprite.setTextDatum(TC_DATUM); } OneBigLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); - if (spispeed == 7) { - OneBigLineSprite.drawString(textUI(83), 135, 0); - } else { - OneBigLineSprite.drawString((spispeed == SPI_SPEED_DEFAULT ? String(textUI(201)) + " " + String(SPI_FREQUENCY / 1000000, DEC) : String(spispeed * 10, DEC)), 160, 0); - } + if (spispeed == 0) OneBigLineSprite.drawString(textUI(83), 135, 0); + else OneBigLineSprite.drawString(String(spispeed), 160, 0); OneBigLineSprite.pushSprite(24, 118); break; } diff --git a/src/main.cpp b/src/main.cpp index 6edf548..2d73f6b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1042,7 +1042,6 @@ void NumpadProcess(int num) { menuoption = ITEM1; menupage = DXMODE; menuitem = 0; - if (spispeed == 7) tft.setSPISpeed(40); submenu = true; menu = true; if (language == LANGUAGE_CHS) PSSprite.setTextFont(1); else PSSprite.setTextFont(0); @@ -1111,7 +1110,7 @@ void setAutoSpeedSPI() { case 1069 ... 1074: tft.setSPISpeed(14); break; case 1075: tft.setSPISpeed(17); break; case 1076 ... 1080: tft.setSPISpeed(15); break; - default: tft.setSPISpeed(30); break; + default: tft.setSPISpeed(35); break; } } @@ -1326,9 +1325,8 @@ void setup() { loadData(); - if (spispeed == SPI_SPEED_DEFAULT) tft.setSPISpeed(SPI_FREQUENCY / 1000000); - else if (spispeed == 7) setAutoSpeedSPI(); - else tft.setSPISpeed(spispeed * 10); + if (spispeed == 0) setAutoSpeedSPI(); + else tft.setSPISpeed(spispeed); if(esp_reset_reason() != ESP_RST_DEEPSLEEP) setup_periph(); @@ -1509,7 +1507,7 @@ void setup() { tft.fillScreen(TFT_BLACK); - tft.pushImage((tft.width() - 163) / 2, (tft.height() - 84) / 2, 163, 84, radiologo, TFT_BLACK); + tft.pushImage((tft.width() - 163) / 2, (tft.height() - 84) / 2, 163, 84, (uint16_t*)radiologo, TFT_BLACK); tft.drawBitmap((tft.width() - 59) / 2, 24, TEFLogo, 59, 23, ActiveColor); for (int x = 0; x <= ContrastSet; x++) { @@ -2455,9 +2453,7 @@ void ModeButtonPress() { freq_in = 0; } else { if (!BWtune && !menu) { - if (!screenmute) { - tft.drawBitmap(249, 4, Speaker, 28, 24, GreyoutColor); - } + if (!screenmute) tft.drawBitmap(249, 4, Speaker, 28, 24, GreyoutColor); memorystore = false; unsigned long counterold = millis(); unsigned long counter = millis(); @@ -2470,7 +2466,6 @@ void ModeButtonPress() { menuoption = ITEM1; menupage = INDEX; menuitem = 0; - if (spispeed == 7) tft.setSPISpeed(40); if (language == LANGUAGE_CHS) PSSprite.setTextFont(1); else PSSprite.setTextFont(0); BuildMenu(); freq_in = 0; @@ -2831,7 +2826,6 @@ void ShowMemoryPos() { } void DoMemoryPosTune() { - if (spispeed == 7) tft.setSPISpeed(50); radio.clearRDS(); if (IsStationEmpty()) { @@ -2984,7 +2978,6 @@ void ShowFreq(int mode) { } } - if (spispeed == 7) setAutoSpeedSPI(); rdsreset = true; afmethodBold = false; aid_counterold = 0; diff --git a/src/nonvolatile.cpp b/src/nonvolatile.cpp index 43038be..54cb3e7 100644 --- a/src/nonvolatile.cpp +++ b/src/nonvolatile.cpp @@ -344,7 +344,7 @@ void DefaultSettings() { EEPROM.writeByte(EE_BYTE_CLOCKAMPM, 0); EEPROM.writeUInt(EE_UINT16_PICTLOCK, 0); - EEPROM.writeByte(EE_BYTE_SPISPEED, 7); + EEPROM.writeByte(EE_BYTE_SPISPEED, 0); #ifdef DEEPELEC_DP_66X EEPROM.writeByte(EE_BYTE_ROTARYMODE, 1);