redo spi freq stuff

This commit is contained in:
2026-02-14 15:04:39 +01:00
parent f5c810f42e
commit 8d5e41846b
8 changed files with 117 additions and 165 deletions
-5
View File
@@ -454,11 +454,6 @@ enum RADIO_FM_DEEMPHASIS {
DEEMPHASIS_COUNT 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 { enum RADIO_MEM_POS_STATUS {
MEM_DARK, MEM_NORMAL, MEM_EXIST MEM_DARK, MEM_NORMAL, MEM_EXIST
}; };
+1 -1
View File
@@ -226,7 +226,7 @@ static const char* const myLanguage[22][298] PROGMEM = {
"Large", // 198 "Large", // 198
"All", // 199 "All", // 199
"Fast PS", // 200 "Fast PS", // 200
"Default", // 201 "Default", // 201 TODO: remove
"Mute screen on\nXDRGTK connection", // 202 "Mute screen on\nXDRGTK connection", // 202
"FMSI stereo\nimprovement", // 203 "FMSI stereo\nimprovement", // 203
"Function only available\non TEF6687/6689!", // 204 "Function only available\non TEF6687/6689!", // 204
+40 -84
View File
@@ -39,7 +39,7 @@ void TFT_eSPI::pushBlock(uint16_t color, uint32_t len) {
len = len - rem; len = len - rem;
if (rem) { if (rem) {
while (*_spi_cmd&SPI_USR); SPI_BUSY_CHECK;
for (i=0; i < rem; i+=2) *spi_w++ = color32; for (i=0; i < rem; i+=2) *spi_w++ = color32;
*_spi_mosi_dlen = (rem << 4) - 1; *_spi_mosi_dlen = (rem << 4) - 1;
*_spi_cmd = SPI_USR; *_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; 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; if (!rem) while (i++<16) *spi_w++ = color32;
*_spi_mosi_dlen = 511; *_spi_mosi_dlen = 511;
while(len) { while(len) {
while (*_spi_cmd&SPI_USR); SPI_BUSY_CHECK;
*_spi_cmd = SPI_USR; *_spi_cmd = SPI_USR;
len -= 32; len -= 32;
} }
@@ -70,7 +70,7 @@ void TFT_eSPI::pushSwapBytePixels(const void* data_in, uint32_t len) {
color[i++] = DAT8TO32(data); 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_W0_REG(VSPI), color[0]); WRITE_PERI_REG(SPI_W0_REG(VSPI), color[0]);
WRITE_PERI_REG(SPI_W1_REG(VSPI), color[1]); WRITE_PERI_REG(SPI_W1_REG(VSPI), color[1]);
WRITE_PERI_REG(SPI_W2_REG(VSPI), color[2]); WRITE_PERI_REG(SPI_W2_REG(VSPI), color[2]);
@@ -98,7 +98,7 @@ void TFT_eSPI::pushSwapBytePixels(const void* data_in, uint32_t len) {
color[i++] = DAT8TO32(data); 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_MOSI_DLEN_REG(VSPI), 255);
WRITE_PERI_REG(SPI_W0_REG(VSPI), color[0]); WRITE_PERI_REG(SPI_W0_REG(VSPI), color[0]);
WRITE_PERI_REG(SPI_W1_REG(VSPI), color[1]); 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) { 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); WRITE_PERI_REG(SPI_MOSI_DLEN_REG(VSPI), (len << 4) - 1);
for (uint32_t i=0; i <= (len<<1); i+=4) { for (uint32_t i=0; i <= (len<<1); i+=4) {
WRITE_PERI_REG(SPI_W0_REG(VSPI)+i, DAT8TO32(data)); data += 4; WRITE_PERI_REG(SPI_W0_REG(VSPI)+i, DAT8TO32(data)); data += 4;
} }
SET_PERI_REG_MASK(SPI_CMD_REG(VSPI), SPI_USR); 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){ 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) { if (len > 31) {
WRITE_PERI_REG(SPI_MOSI_DLEN_REG(VSPI), 511); WRITE_PERI_REG(SPI_MOSI_DLEN_REG(VSPI), 511);
while(len>31) { 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_W0_REG(VSPI), *data++);
WRITE_PERI_REG(SPI_W1_REG(VSPI), *data++); WRITE_PERI_REG(SPI_W1_REG(VSPI), *data++);
WRITE_PERI_REG(SPI_W2_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) { 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); 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++); 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); 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 // Clipping macro for pushImage
@@ -224,8 +223,7 @@ inline void TFT_eSPI::end_tft_read() {
SET_BUS_WRITE_MODE; 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; _xDatum = x;
_yDatum = y; _yDatum = y;
_xWidth = w; _xWidth = w;
@@ -404,7 +402,7 @@ void TFT_eSPI::init() {
gpio_set_level((gpio_num_t)TFT_RST, 1); 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(); begin_tft_write();
@@ -420,7 +418,7 @@ void TFT_eSPI::setRotation(uint8_t m) {
#include "ILI9341_Rotation.h" #include "ILI9341_Rotation.h"
delayMicroseconds(10); delayMicroseconds(9);
end_tft_write(); 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 ** Function name: drawPixel
** Description: push a single pixel at an arbitrary position ** 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; if (_vpOoB) return;
x+= _xDatum; x+= _xDatum;
@@ -1578,11 +1575,6 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color)
// Range checking // Range checking
if ((x < _vpX) || (y < _vpY) ||(x >= _vpW) || (y >= _vpH)) return; 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(); begin_tft_write();
SPI_BUSY_CHECK; SPI_BUSY_CHECK;
@@ -1607,12 +1599,7 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color)
end_tft_write(); end_tft_write();
} }
/*************************************************************************************** void TFT_eSPI::pushColor(uint16_t color) {
** Function name: pushColor
** Description: push a single pixel
***************************************************************************************/
void TFT_eSPI::pushColor(uint16_t color)
{
begin_tft_write(); begin_tft_write();
SPI_BUSY_CHECK; SPI_BUSY_CHECK;
@@ -1622,12 +1609,7 @@ void TFT_eSPI::pushColor(uint16_t color)
} }
/*************************************************************************************** void TFT_eSPI::pushColor(uint16_t color, uint32_t len) {
** Function name: pushColor
** Description: push a single colour to "len" pixels
***************************************************************************************/
void TFT_eSPI::pushColor(uint16_t color, uint32_t len)
{
begin_tft_write(); begin_tft_write();
pushBlock(color, len); pushBlock(color, len);
@@ -1635,14 +1617,6 @@ void TFT_eSPI::pushColor(uint16_t color, uint32_t len)
end_tft_write(); 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) { void TFT_eSPI::writeColor(uint16_t color, uint32_t len) {
pushBlock(color, len); pushBlock(color, len);
} }
@@ -2546,8 +2520,7 @@ void TFT_eSPI::loadFont(const uint8_t array[], uint8_t font) {
fontOwned[font] = true; fontOwned[font] = true;
} }
void TFT_eSPI::loadMetrics(uint8_t font) void TFT_eSPI::loadMetrics(uint8_t font) {
{
uint32_t headerPtr = 24; uint32_t headerPtr = 24;
uint32_t bitmapPtr = headerPtr + gFonts[font].gCount * 28; uint32_t bitmapPtr = headerPtr + gFonts[font].gCount * 28;
@@ -2571,11 +2544,9 @@ void TFT_eSPI::loadMetrics(uint8_t font)
readInt32(); // ignored readInt32(); // ignored
// Different glyph sets have different descent values not always based on "p", so get maximum glyph descent // 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 // 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]; 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; uint16_t gNum = 0;
bool found = getUnicodeIndex(code, &gNum, font); bool found = getUnicodeIndex(code, &gNum, font);
if (found) if (found) {
{
if (textwrapX && (cursor_x + gWidth[font][gNum] + gdX[font][gNum] > width())) if (textwrapX && (cursor_x + gWidth[font][gNum] + gdX[font][gNum] > width()))
{ {
cursor_y += gFonts[font].yAdvance; 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 (textwrapY && ((cursor_y + gFonts[font].yAdvance) >= height())) cursor_y = 0;
if (cursor_x == 0) cursor_x -= gdX[font][gNum]; if (cursor_x == 0) cursor_x -= gdX[font][gNum];
uint8_t* pbuffer = nullptr;
const uint8_t* gPtr = (const uint8_t*) gFonts[font].gArray; const uint8_t* gPtr = (const uint8_t*) gFonts[font].gArray;
int16_t cy = cursor_y + gFonts[font].maxAscent - gdY[font][gNum]; 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; int16_t bx = 0;
uint8_t pixel; uint8_t pixel;
startWrite(); begin_tft_write();
int16_t fillwidth = 0; int16_t fillwidth = 0;
int16_t fillheight = 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 y = 0; y < gHeight[font][gNum]; y++) {
{ for (int32_t x = 0; x < gWidth[font][gNum]; x++) {
for (int32_t x = 0; x < gWidth[font][gNum]; x++)
{
pixel = pgm_read_byte(gPtr + gBitmap[font][gNum] + x + gWidth[font][gNum] * y); 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 (bl) { drawFastHLine( bxs, y + cy, bl, textbgcolor); bl = 0; }
if (pixel != 0xFF) 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]; cursor_x += gxAdvance[font][gNum];
endWrite(); end_tft_write();
} }
else else
{ {
@@ -3296,14 +3259,12 @@ uint16_t TFT_eSprite::getPaletteColor(uint8_t index) {
void TFT_eSprite::deleteSprite() { void TFT_eSprite::deleteSprite() {
if (_colorMap != nullptr) if (_colorMap != nullptr) {
{
free(_colorMap); free(_colorMap);
_colorMap = nullptr; _colorMap = nullptr;
} }
if (_created) if (_created) {
{
free(_img8_1); free(_img8_1);
_img8 = nullptr; _img8 = nullptr;
_created = false; _created = false;
@@ -3483,7 +3444,7 @@ bool TFT_eSprite::pushSprite(int32_t tx, int32_t ty, int32_t sx, int32_t sy, int
sw--; sw--;
uint32_t yp = (_xs + ds + _iwidth * _ys)>>1; uint32_t yp = (_xs + ds + _iwidth * _ys)>>1;
_tft->startWrite(); _tft->begin_tft_write();
while (sh--) while (sh--)
{ {
if (ds) _tft->drawPixel(tx, ty, readPixel(_xs, _ys) ); 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++; ty++;
yp += (_iwidth>>1); yp += (_iwidth>>1);
} }
_tft->endWrite(); _tft->end_tft_write();
} }
} }
else // 1bpp else // 1bpp
{ {
// Check if a faster block copy to screen is possible // Check if a faster block copy to screen is possible
if ( sx == 0 && sw == _dwidth) 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 else // Render line by line
{ {
_tft->startWrite(); _tft->begin_tft_write();
while (sh--) while (sh--) _tft->pushImage(tx, ty++, sw, 1, _img8 + (_bitwidth>>3) * _ys++, false);
{ _tft->end_tft_write();
_tft->pushImage(tx, ty++, sw, 1, _img8 + (_bitwidth>>3) * _ys++, (bool)false );
}
_tft->endWrite();
} }
} }
@@ -3644,8 +3602,7 @@ uint16_t TFT_eSprite::readPixel(int32_t x, int32_t y)
else return _tft->bitmap_bg; 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; if (data == nullptr || !_created) return;
PI_CLIP; PI_CLIP;
@@ -4217,9 +4174,7 @@ void TFT_eSprite::drawGlyph(uint16_t code, uint16_t font) {
bg_cursor_x = cursor_x; bg_cursor_x = cursor_x;
last_cursor_x = cursor_x; last_cursor_x = cursor_x;
return; return;
} } else if (code == '\n') {
if (code == '\n') {
cursor_x = 0; cursor_x = 0;
bg_cursor_x = 0; bg_cursor_x = 0;
last_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]; if ( cursor_x == 0) cursor_x -= gdX[font][gNum];
} }
uint8_t* pbuffer = nullptr;
const uint8_t* gPtr = (const uint8_t*) gFonts[font].gArray; const uint8_t* gPtr = (const uint8_t*) gFonts[font].gArray;
int16_t cy = cursor_y + gFonts[font].maxAscent - gdY[font][gNum]; 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 (fillheight > 0) fillRect(bg_cursor_x, cy + gHeight[font][gNum], fillwidth, fillheight, textbgcolor);
} }
if (pbuffer) free(pbuffer);
cursor_x += gxAdvance[font][gNum]; cursor_x += gxAdvance[font][gNum];
if (newSprite) { if (newSprite) {
pushSprite(cx, cursor_y); pushSprite(cx, cursor_y);
deleteSprite(); deleteSprite();
} }
} } else {
else {
drawRect(cursor_x, cursor_y + gFonts[font].maxAscent - gFonts[font].ascent, gFonts[font].spaceWidth, gFonts[font].ascent, textcolor); drawRect(cursor_x, cursor_y + gFonts[font].maxAscent - gFonts[font].ascent, gFonts[font].spaceWidth, gFonts[font].ascent, textcolor);
cursor_x += gFonts[font].spaceWidth + 1; cursor_x += gFonts[font].spaceWidth + 1;
} }
@@ -4356,3 +4308,7 @@ void TFT_eSprite::copyFontFromTFT(uint8_t source, uint8_t destination) {
fontOwned[destination] = false; fontOwned[destination] = false;
} }
void TFT_eSprite::copyAllFontsFromTFT() {
for(uint8_t i = 0; i < FONT_COUNT; i++) copyFontFromTFT(i, i);
}
+2 -4
View File
@@ -362,10 +362,7 @@ class TFT_eSPI { friend class TFT_eSprite;
uint8_t spiBusyCheck = 0; // Number of ESP32 transfer buffers to check 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 writeColor(uint16_t color, uint32_t len); // Deprecated, use pushBlock()
void endWrite(); // End SPI transaction
// Global variables // Global variables
uint32_t textcolor, textbgcolor; // Text foreground and background colours uint32_t textcolor, textbgcolor; // Text foreground and background colours
@@ -504,7 +501,7 @@ class TFT_eSprite : public TFT_eSPI {
public: public:
explicit TFT_eSprite(TFT_eSPI *tft); explicit TFT_eSprite(TFT_eSPI *tft);
~TFT_eSprite(); ~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(); void* getPointer();
bool created(); bool created();
void deleteSprite(); void deleteSprite();
@@ -538,6 +535,7 @@ class TFT_eSprite : public TFT_eSPI {
height(); height();
void drawGlyph(uint16_t code, uint16_t font); void drawGlyph(uint16_t code, uint16_t font);
void copyFontFromTFT(uint8_t source, uint8_t destination); void copyFontFromTFT(uint8_t source, uint8_t destination);
void copyAllFontsFromTFT();
private: private:
+1 -1
View File
@@ -2,7 +2,6 @@
bool RDSstatus; bool RDSstatus;
bool RDSstatusold; bool RDSstatusold;
TFT_eSPI tft = TFT_eSPI();
bool Data_Accelerator = false; bool Data_Accelerator = false;
@@ -327,6 +326,7 @@ const size_t language_entrynumber = sizeof(myLanguage[0]) / sizeof(myLanguage[0]
mem presets[EE_PRESETS_CNT]; mem presets[EE_PRESETS_CNT];
TEF6686 radio; TEF6686 radio;
TFT_eSPI tft = TFT_eSPI();
// FrequencySprite.createSprite(200, 50); // FrequencySprite.createSprite(200, 50);
// PSSprite.createSprite(150, 32); // PSSprite.createSprite(150, 32);
+41 -31
View File
@@ -1635,14 +1635,14 @@ void ShowOneLine(byte position, byte item, bool selected) {
FullLineSprite.setTextDatum(TR_DATUM); FullLineSprite.setTextDatum(TR_DATUM);
if (spispeed == 7) { if (spispeed == 0) {
FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
FullLineSprite.drawString(textUI(83), 298, 2); FullLineSprite.drawString(textUI(83), 298, 2);
} else { } else {
FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
FullLineSprite.drawString("MHz", 298, 2); FullLineSprite.drawString("MHz", 298, 2);
FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); 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; break;
@@ -2723,7 +2723,7 @@ void ShowOneButton(byte position, byte item, bool selected) {
PSSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); PSSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
PSSprite.drawString(shortLine(removeNewline(textUI(78))), 75, 1); PSSprite.drawString(shortLine(removeNewline(textUI(78))), 75, 1);
if (spispeed == 7) { if (spispeed == 0) {
PSSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); PSSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
PSSprite.drawString(textUI(83), 75, 15); PSSprite.drawString(textUI(83), 75, 15);
} else { } else {
@@ -2732,7 +2732,7 @@ void ShowOneButton(byte position, byte item, bool selected) {
PSSprite.drawString("MHz", 77, 15); PSSprite.drawString("MHz", 77, 15);
PSSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); PSSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
PSSprite.setTextDatum(TR_DATUM); 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; break;
@@ -2836,9 +2836,8 @@ void BuildMenu() {
default: tft.pushImage (0, 0, 320, 240, configurationbackground); break; default: tft.pushImage (0, 0, 320, 240, configurationbackground); break;
} }
if (!submenu) { if (!submenu) tftPrint(ACENTER, textUI(29), 160, 6, PrimaryColor, PrimaryColorSmooth, 16);
tftPrint(ACENTER, textUI(29), 160, 6, PrimaryColor, PrimaryColorSmooth, 16); else {
} else {
tftPrint(ALEFT, textUI(181), (hardwaremodel == PORTABLE_TOUCH_ILI9341 ? 20 : 8), 6, PrimaryColor, PrimaryColorSmooth, 16); 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); tftPrint(ARIGHT, textUI(186 + menupage - 1), 312, 6, ActiveColor, ActiveColorSmooth, 16);
} }
@@ -3351,32 +3350,46 @@ void MenuUpDown(bool dir) {
case ITEM10: case ITEM10:
if (dir) { if (dir) {
spispeed++; if (spispeed == 0) {
if (spispeed > SPI_SPEED_COUNT - 1) spispeed = 0; spispeed = 4;
} else if (spispeed < 10) {
spispeed += 1;
if (spispeed == 10) spispeed = 10;
} else { } else {
spispeed--; spispeed += 10;
if (spispeed > SPI_SPEED_COUNT - 1) spispeed = SPI_SPEED_COUNT - 1; if (spispeed > 80) spispeed = 0;
}
} else {
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.setTextDatum(TL_DATUM);
OneBigLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); 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.drawString("MHz", 175, 0);
OneBigLineSprite.setTextDatum(TR_DATUM); OneBigLineSprite.setTextDatum(TR_DATUM);
} else { OneBigLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
OneBigLineSprite.setTextDatum(TC_DATUM); OneBigLineSprite.drawString(String(spispeed), 160, 0);
tft.setSPISpeed(spispeed);
} }
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.pushSprite(24, 118); 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;
} }
break; break;
@@ -4546,7 +4559,7 @@ void DoMenu() {
tft.fillRoundRect(12, 8, 296, 226, 5, BackgroundColor); tft.fillRoundRect(12, 8, 296, 226, 5, BackgroundColor);
tftPrint(ACENTER, textUI(68), 155, 13, ActiveColor, ActiveColorSmooth, 28); tftPrint(ACENTER, textUI(68), 155, 13, ActiveColor, ActiveColorSmooth, 28);
tftPrint(ACENTER, textUI(69), 155, 55, 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, "ohmytime", 145, 80, PrimaryColor, PrimaryColorSmooth, 16);
tftPrint(ARIGHT, "HyperDX", 145, 95, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(ARIGHT, "HyperDX", 145, 95, PrimaryColor, PrimaryColorSmooth, 16);
tftPrint(ALEFT, "MCelliotG", 155, 80, 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(ARIGHT, "marsel90-1", 145, 185, PrimaryColor, PrimaryColorSmooth, 16);
tftPrint(ALEFT, "lawendel", 155, 185, PrimaryColor, PrimaryColorSmooth, 16); tftPrint(ALEFT, "lawendel", 155, 185, PrimaryColor, PrimaryColorSmooth, 16);
tftPrint(ARIGHT, "KB8U", 145, 200, 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); tftPrint(ACENTER, "github.com/KubaPro010/TEF6686_ESP32", 155, 215, ActiveColor, ActiveColorSmooth, 16);
if (hardwaremodel == PORTABLE_TOUCH_ILI9341) { if (hardwaremodel == PORTABLE_TOUCH_ILI9341) {
tft.fillRoundRect(240, 36, 60, 40, 6, FrameColor); tft.fillRoundRect(240, 36, 60, 40, 6, FrameColor);
@@ -4690,18 +4703,15 @@ void DoMenu() {
OneBigLineSprite.setTextDatum(TL_DATUM); OneBigLineSprite.setTextDatum(TL_DATUM);
OneBigLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false); OneBigLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
if (spispeed != 7) { if (spispeed != 0) {
OneBigLineSprite.drawString("MHz", 175, 0); OneBigLineSprite.drawString("MHz", 175, 0);
OneBigLineSprite.setTextDatum(TR_DATUM); OneBigLineSprite.setTextDatum(TR_DATUM);
} else { } else {
OneBigLineSprite.setTextDatum(TC_DATUM); OneBigLineSprite.setTextDatum(TC_DATUM);
} }
OneBigLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false); OneBigLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
if (spispeed == 7) { if (spispeed == 0) OneBigLineSprite.drawString(textUI(83), 135, 0);
OneBigLineSprite.drawString(textUI(83), 135, 0); else OneBigLineSprite.drawString(String(spispeed), 160, 0);
} else {
OneBigLineSprite.drawString((spispeed == SPI_SPEED_DEFAULT ? String(textUI(201)) + " " + String(SPI_FREQUENCY / 1000000, DEC) : String(spispeed * 10, DEC)), 160, 0);
}
OneBigLineSprite.pushSprite(24, 118); OneBigLineSprite.pushSprite(24, 118);
break; break;
} }
+5 -12
View File
@@ -1042,7 +1042,6 @@ void NumpadProcess(int num) {
menuoption = ITEM1; menuoption = ITEM1;
menupage = DXMODE; menupage = DXMODE;
menuitem = 0; menuitem = 0;
if (spispeed == 7) tft.setSPISpeed(40);
submenu = true; submenu = true;
menu = true; menu = true;
if (language == LANGUAGE_CHS) PSSprite.setTextFont(1); else PSSprite.setTextFont(0); 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 1069 ... 1074: tft.setSPISpeed(14); break;
case 1075: tft.setSPISpeed(17); break; case 1075: tft.setSPISpeed(17); break;
case 1076 ... 1080: tft.setSPISpeed(15); 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(); loadData();
if (spispeed == SPI_SPEED_DEFAULT) tft.setSPISpeed(SPI_FREQUENCY / 1000000); if (spispeed == 0) setAutoSpeedSPI();
else if (spispeed == 7) setAutoSpeedSPI(); else tft.setSPISpeed(spispeed);
else tft.setSPISpeed(spispeed * 10);
if(esp_reset_reason() != ESP_RST_DEEPSLEEP) setup_periph(); if(esp_reset_reason() != ESP_RST_DEEPSLEEP) setup_periph();
@@ -1509,7 +1507,7 @@ void setup() {
tft.fillScreen(TFT_BLACK); 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); tft.drawBitmap((tft.width() - 59) / 2, 24, TEFLogo, 59, 23, ActiveColor);
for (int x = 0; x <= ContrastSet; x++) { for (int x = 0; x <= ContrastSet; x++) {
@@ -2455,9 +2453,7 @@ void ModeButtonPress() {
freq_in = 0; freq_in = 0;
} else { } else {
if (!BWtune && !menu) { if (!BWtune && !menu) {
if (!screenmute) { if (!screenmute) tft.drawBitmap(249, 4, Speaker, 28, 24, GreyoutColor);
tft.drawBitmap(249, 4, Speaker, 28, 24, GreyoutColor);
}
memorystore = false; memorystore = false;
unsigned long counterold = millis(); unsigned long counterold = millis();
unsigned long counter = millis(); unsigned long counter = millis();
@@ -2470,7 +2466,6 @@ void ModeButtonPress() {
menuoption = ITEM1; menuoption = ITEM1;
menupage = INDEX; menupage = INDEX;
menuitem = 0; menuitem = 0;
if (spispeed == 7) tft.setSPISpeed(40);
if (language == LANGUAGE_CHS) PSSprite.setTextFont(1); else PSSprite.setTextFont(0); if (language == LANGUAGE_CHS) PSSprite.setTextFont(1); else PSSprite.setTextFont(0);
BuildMenu(); BuildMenu();
freq_in = 0; freq_in = 0;
@@ -2831,7 +2826,6 @@ void ShowMemoryPos() {
} }
void DoMemoryPosTune() { void DoMemoryPosTune() {
if (spispeed == 7) tft.setSPISpeed(50);
radio.clearRDS(); radio.clearRDS();
if (IsStationEmpty()) { if (IsStationEmpty()) {
@@ -2984,7 +2978,6 @@ void ShowFreq(int mode) {
} }
} }
if (spispeed == 7) setAutoSpeedSPI();
rdsreset = true; rdsreset = true;
afmethodBold = false; afmethodBold = false;
aid_counterold = 0; aid_counterold = 0;
+1 -1
View File
@@ -344,7 +344,7 @@ void DefaultSettings() {
EEPROM.writeByte(EE_BYTE_CLOCKAMPM, 0); EEPROM.writeByte(EE_BYTE_CLOCKAMPM, 0);
EEPROM.writeUInt(EE_UINT16_PICTLOCK, 0); EEPROM.writeUInt(EE_UINT16_PICTLOCK, 0);
EEPROM.writeByte(EE_BYTE_SPISPEED, 7); EEPROM.writeByte(EE_BYTE_SPISPEED, 0);
#ifdef DEEPELEC_DP_66X #ifdef DEEPELEC_DP_66X
EEPROM.writeByte(EE_BYTE_ROTARYMODE, 1); EEPROM.writeByte(EE_BYTE_ROTARYMODE, 1);