even faster boot up and completly new start screen

This commit is contained in:
2026-01-14 20:57:32 +01:00
parent 77b7f45d90
commit f5a03c7e6c
30 changed files with 7313 additions and 7758 deletions
+1 -1
View File
@@ -574,7 +574,7 @@ class TEF6686 {
void setVolume(int8_t volume);
void tone(uint16_t time, int16_t amplitude, uint16_t frequency);
void extendBW(bool yesno);
uint16_t getBlockA(void);
uint16_t getBlockA();
uint8_t af_counter;
uint8_t eon_counter;
uint8_t logbook_counter;
+1 -6
View File
@@ -16,11 +16,6 @@
#define TOUCHIRQ 33
#define EXT_IRQ 14
#ifndef DEEPELEC_DP_66X
#define STANDBYLED 19
#define SMETERPIN 27
#endif
#define XL9555_ADDRESS 0x20 // GPIO driver used in the DP666 for the 0-9 + DX(Backspace) + Enter buttons
#define TEF668X_ADDRESS 0x64 // I2C address of the TEF itself! Not sure if this even changes
@@ -269,7 +264,7 @@
#define EE_BYTE_ROTARYMODE 2118
#define EE_BYTE_STEPSIZE 2119
#define EE_BYTE_TUNEMODE 2120
#define EE_BYTE_OPTENC 2121
// empty byte
#define EE_BYTE_CHECKBYTE 2122
#define EE_BYTE_IMSSET 2123
#define EE_BYTE_EQSET 2124
-1
View File
@@ -39,7 +39,6 @@ extern bool memorystore;
extern bool memreset, memtune;
extern bool menu, menuopen;
extern bool mwstepsize;
extern bool optenc;
extern bool rdsflagreset;
extern bool rdsreset;
extern bool rdsstatscreen;
+6420 -6442
View File
File diff suppressed because it is too large Load Diff
+12 -9
View File
@@ -16,13 +16,13 @@ private:
std::function<void(TFT_eSprite*, bool)> postDrawCallback;
int usedW;
int usedH;
static const unsigned long SCROLL_INTERVAL = 5;
static const unsigned long HOLD_DURATION = 2000;
static const int SCROLL_GAP = 10;
public:
ScrollingTextDisplay(TFT_eSprite* spr, int y, int maxW, int inuseW = -1, int inuseH = -1 ) :
ScrollingTextDisplay(TFT_eSprite* spr, int y, int maxW, int inuseW = -1, int inuseH = -1 ) :
sprite(spr), yPos(y), maxWidth(maxW), xPos(0), textWidth(0), lastTick(0), holdTick(0), isScrolling(false), postDrawCallback(nullptr), usedW(inuseW), usedH(inuseH) {}
void setPostDrawCallback(std::function<void(TFT_eSprite*, bool)> callback) {
@@ -31,7 +31,7 @@ public:
void update(const String& text, bool status, uint16_t activeColor, uint16_t activeSmooth, uint16_t dropoutColor, uint16_t dropoutSmooth, uint16_t backgroundColor) {
textWidth = sprite->textWidth(text);
if(textWidth < maxWidth) {
xPos = 0;
isScrolling = false;
@@ -41,7 +41,7 @@ public:
isScrolling = true;
if(millis() - lastTick >= SCROLL_INTERVAL) {
if(xPos <= -(textWidth + SCROLL_GAP)) xPos = 0;
if(xPos == 0) {
if(millis() - holdTick >= HOLD_DURATION) {
xPos--;
@@ -51,7 +51,7 @@ public:
xPos--;
holdTick = millis();
}
drawText(text, status, activeColor, activeSmooth, dropoutColor, dropoutSmooth, backgroundColor);
lastTick = millis();
}
@@ -77,25 +77,28 @@ private:
if(usedW > 0 && usedH > 0) {
sprite->fillSprite(TFT_TRANSPARENT);
sprite->fillRect(0, 0, usedW, usedH, backgroundColor);
sprite->setViewport(0, 0, usedW, usedH);
if(status) sprite->setTextColor(activeColor, activeSmooth, false);
else sprite->setTextColor(dropoutColor, dropoutSmooth, false);
sprite->drawString(text, xPos, 0);
if(isScrolling) sprite->drawString(text, xPos + textWidth + SCROLL_GAP, 0);
sprite->resetViewport();
} else {
sprite->fillSprite(backgroundColor);
if(status) sprite->setTextColor(activeColor, activeSmooth, false);
else sprite->setTextColor(dropoutColor, dropoutSmooth, false);
sprite->drawString(text, xPos, 0);
if(isScrolling) sprite->drawString(text, xPos + textWidth + SCROLL_GAP, 0);
}
sprite->fillRect(0, sprite->fontHeight(), sprite->width(), sprite->height() - sprite->fontHeight(), TFT_TRANSPARENT);
if(postDrawCallback) postDrawCallback(sprite, false);
sprite->pushSprite(35, yPos, TFT_TRANSPARENT);
}
+19
View File
@@ -0,0 +1,19 @@
#pragma once
#include <Arduino.h>
#include <TFT_eSPI.h>
class Console {
public:
explicit Console(TFT_eSPI* display) : tft(display), y(0) {}
void print(String text) {
tft->setTextColor(TFT_WHITE, TFT_BLACK);
tft->setTextDatum(TL_DATUM);
auto data = "[" + String(millis() / 1000.0f) + "] " + text;
tft->fillRect(0, y, tft->textWidth(data), tft->fontHeight(0), TFT_BLACK);
tft->drawString(data, 0, y, 0);
y += tft->fontHeight(0);
}
private:
TFT_eSPI* tft;
int y = 0;
};
-2
View File
@@ -1,2 +0,0 @@
*.py
-42
View File
@@ -1,42 +0,0 @@
# ESP32Time
An Arduino library for setting and retrieving internal RTC time on ESP32 boards
[![arduino-library-badge](https://www.ardu-badge.com/badge/ESP32Time.svg?)](https://www.arduinolibraries.info/libraries/esp32-time)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/fbiego/library/ESP32Time.svg)](https://registry.platformio.org/libraries/fbiego/ESP32Time)
## Functions
```
ESP32Time rtc(offset); // create an instance with a specifed offset in seconds
rtc.offset; // get or modify the current offset
setTime(30, 24, 15, 17, 1, 2021); // 17th Jan 2021 15:24:30
setTime(1609459200); // 1st Jan 2021 00:00:00
setTimeStruct(time); // set with time struct
getTime() // (String) 15:24:38
getDate() // (String) Sun, Jan 17 2021
getDate(true) // (String) Sunday, January 17 2021
getDateTime() // (String) Sun, Jan 17 2021 15:24:38
getDateTime(true) // (String) Sunday, January 17 2021 15:24:38
getTimeDate() // (String) 15:24:38 Sun, Jan 17 2021
getTimeDate(true) // (String) 15:24:38 Sunday, January 17 2021
getMicros() // (unsigned long) 723546
getMillis() // (unsigned long) 723
getEpoch() // (unsigned long) 1609459200
getLocalEpoch() // (unsigned long) 1609459200 // local epoch without offset
getSecond() // (int) 38 (0-59)
getMinute() // (int) 24 (0-59)
getHour() // (int) 3 (1-12)
getHour(true) // (int) 15 (0-23)
getAmPm() // (String) PM
getAmPm(true) // (String) pm
getDay() // (int) 17 (1-31)
getDayofWeek() // (int) 0 (0-6)
getDayofYear() // (int) 16 (0-365)
getMonth() // (int) 0 (0-11)
getYear() // (int) 2021
getTime("%A, %B %d %Y %H:%M:%S") // (String) returns time with specified format
```
[`Formatting options`](http://www.cplusplus.com/reference/ctime/strftime/)
-22
View File
@@ -1,22 +0,0 @@
ESP32Time KEYWORD1
setTime KEYWORD2
getTime KEYWORD2
setTimeStruct KEYWORD2
getTimeStruct KEYWORD2
getDateTime KEYWORD2
getTimeDate KEYWORD2
getDate KEYWORD2
getAmPm KEYWORD2
getMillis KEYWORD2
getMicros KEYWORD2
getEpoch KEYWORD2
getLocalEpoch KEYWORD2
getSecond KEYWORD2
getMinute KEYWORD2
getHour KEYWORD2
getDay KEYWORD2
getDayofWeek KEYWORD2
getDayofYear KEYWORD2
getMonth KEYWORD2
getYear KEYWORD2
-11
View File
@@ -1,11 +0,0 @@
name=ESP32Time
version=2.0.6
author=fbiego
maintainer=fbiego
sentence=Set and retrieve internal RTC time on ESP32 boards.
paragraph=No need for external RTC module or NTP time synchronization.
category=Timing
url=https://github.com/fbiego/ESP32Time
architectures=*
includes=ESP32Time.h
-32
View File
@@ -1,32 +0,0 @@
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
-7
View File
@@ -1,7 +0,0 @@
Port for Hash library from https://github.com/esp8266/Arduino/libraries/Hash
commit d6f1f0d to ESP32.
This is an experimental port that should work on ESP8266 and ESP32. This is NOT
an official repo supported by Espressif. Do not depend on this code for
anything important or expect it to be updated. Once the official repo is
created, this repo will be deleted.
-9
View File
@@ -1,9 +0,0 @@
name=Hash
version=1.0
author=Markus Sattler
maintainer=Markus Sattler
sentence=Generate Hash from data
paragraph=
category=Data Processing
url=
architectures=esp8266,esp32
+2 -2
View File
@@ -100,11 +100,11 @@
// Methods
bool initAdapter();
bool initModule();
void resetModule(void);
void resetModule();
void toggleGlobalStop(bool stopEnabled);
// Calendar
DateTime readDateTime(void);
DateTime readDateTime();
void writeDateTime(DateTime dateTime);
// Fixed cycle interrupt
+1 -1
View File
@@ -105,7 +105,7 @@
writecommand(ILI9341_SLPOUT); //Exit Sleep
end_tft_write();
delay(120);
delay(80);
begin_tft_write();
writecommand(ILI9341_DISPON); //Display on
+58 -229
View File
@@ -152,7 +152,7 @@ void TFT_eSPI::pushPixels(const void* data_in, uint32_t len){
while (READ_PERI_REG(SPI_CMD_REG(SPI_PORT))&SPI_USR);
}
bool TFT_eSPI::dmaBusy(void)
bool TFT_eSPI::dmaBusy()
{
if (!DMA_Enabled || !spiBusyCheck) return false;
@@ -169,7 +169,7 @@ bool TFT_eSPI::dmaBusy(void)
return true;
}
void TFT_eSPI::dmaWait(void)
void TFT_eSPI::dmaWait()
{
if (!DMA_Enabled || !spiBusyCheck) return;
spi_transaction_t *rtrans;
@@ -293,7 +293,7 @@ bool TFT_eSPI::initDMA(bool ctrl_cs)
if (dw < 1 || dh < 1) return;
inline void TFT_eSPI::begin_tft_write(void){
inline void TFT_eSPI::begin_tft_write() {
if (locked) {
locked = false; // Flag to show SPI access now unlocked
spi.beginTransaction(SPISettings(spi_write_speed * 1000000, MSBFIRST, TFT_SPI_MODE));
@@ -302,7 +302,7 @@ inline void TFT_eSPI::begin_tft_write(void){
}
}
void TFT_eSPI::begin_nin_write(void){
void TFT_eSPI::begin_nin_write() {
if (locked) {
locked = false; // Flag to show SPI access now unlocked
spi.beginTransaction(SPISettings(spi_write_speed * 1000000, MSBFIRST, TFT_SPI_MODE));
@@ -311,7 +311,7 @@ void TFT_eSPI::begin_nin_write(void){
}
}
inline void TFT_eSPI::end_tft_write(void){
inline void TFT_eSPI::end_tft_write() {
if(!inTransaction) { // Flag to stop ending transaction during multiple graphics calls
if (!locked) { // Locked when beginTransaction has been called
locked = true; // Flag to show SPI access now locked
@@ -345,7 +345,7 @@ inline void TFT_eSPI::begin_tft_read() {
SET_BUS_READ_MODE;
}
inline void TFT_eSPI::end_tft_read(void){
inline void TFT_eSPI::end_tft_read() {
if(!inTransaction) {
if (!locked) {
locked = true;
@@ -514,8 +514,7 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
_yPivot = 0;
}
void TFT_eSPI::initBus(void) {
void TFT_eSPI::initBus() {
#ifdef TFT_CS
if (TFT_CS >= 0) {
pinMode(TFT_CS, OUTPUT);
@@ -588,9 +587,9 @@ void TFT_eSPI::init()
if (TFT_RST >= 0) {
writecommand(0x00); // Put SPI bus in known state for TFT with CS tied low
digitalWrite(TFT_RST, HIGH);
delay(5);
delay(3);
digitalWrite(TFT_RST, LOW);
delay(20);
delay(12);
digitalWrite(TFT_RST, HIGH);
}
else writecommand(TFT_SWRST); // Software reset
@@ -598,7 +597,7 @@ void TFT_eSPI::init()
writecommand(TFT_SWRST); // Software reset
#endif
delay(150); // Wait for reset to complete
delay(50); // Wait for reset to complete
begin_tft_write();
@@ -701,15 +700,9 @@ void TFT_eSPI::writedata(uint8_t d)
end_tft_write();
}
/***************************************************************************************
** Function name: readcommand8
** Description: Read a 8-bit data value from an indexed command register
***************************************************************************************/
uint8_t TFT_eSPI::readcommand8(uint8_t cmd_function, uint8_t index)
{
uint8_t reg = 0;
// Tested with ILI9341 set to Interface II i.e. IM [3:0] = "1101"
begin_tft_read();
index = 0x10 + (index & 0x0F);
@@ -1416,8 +1409,7 @@ void TFT_eSPI::setSwapBytes(bool swap)
_swapBytes = swap;
}
bool TFT_eSPI::getSwapBytes(void)
{
bool TFT_eSPI::getSwapBytes() {
return _swapBytes;
}
@@ -1998,14 +1990,12 @@ void TFT_eSPI::setTextPadding(uint16_t x_width)
padX = x_width;
}
int16_t TFT_eSPI::width(void)
{
int16_t TFT_eSPI::width() {
if (_vpDatum) return _xWidth;
return _width;
}
int16_t TFT_eSPI::height(void)
{
int16_t TFT_eSPI::height() {
if (_vpDatum) return _yHeight;
return _height;
}
@@ -2055,12 +2045,12 @@ int16_t TFT_eSPI::textWidth(const char *string, uint8_t font) {
}
int16_t TFT_eSPI::fontHeight(uint8_t font) {
if (font > 8) return 0;
if (font > 7) return 0;
return gFonts[font].yAdvance;
}
int16_t TFT_eSPI::fontHeight(void)
int16_t TFT_eSPI::fontHeight()
{
return fontHeight(textfont);
}
@@ -2204,19 +2194,13 @@ void TFT_eSPI::pushColor(uint16_t color, uint32_t len)
end_tft_write();
}
/***************************************************************************************
** Function name: startWrite
** Description: begin transaction with CS low, MUST later call endWrite
***************************************************************************************/
void TFT_eSPI::startWrite(void)
{
void TFT_eSPI::startWrite() {
begin_tft_write();
lockTransaction = true; // Lock transaction for all sequentially run sketch functions
inTransaction = true;
}
void TFT_eSPI::endWrite(void)
{
void TFT_eSPI::endWrite() {
lockTransaction = false; // Release sketch induced transaction lock
inTransaction = false;
dmaWait(); // Safety check - user code should have checked this!
@@ -3012,7 +2996,7 @@ int16_t TFT_eSPI::drawString(const char *string, int32_t poX, int32_t poY) {
}
int16_t TFT_eSPI::drawString(const char *string, int32_t poX, int32_t poY, uint8_t font) {
if (font > 8) return 0;
if (font > 7) return 0;
int16_t sumX = 0;
uint8_t padding = 1, baseline = 0;
@@ -3249,23 +3233,6 @@ void TFT_eSPI::loadMetrics(uint8_t font)
gdX[font][gNum] = (int8_t)readInt32(); // x delta from cursor
readInt32(); // ignored
// Different glyph sets have different ascent values not always based on "d", so we could get
// the maximum glyph ascent by checking all characters. BUT this method can generate bad values
// for non-existent glyphs, so we will reply on processing for the value and disable this code for now...
/*
if (gdY[gNum] > gFont.maxAscent)
{
// Try to avoid UTF coding values and characters that tend to give duff values
if (((gUnicode[gNum] > 0x20) && (gUnicode[gNum] < 0x7F)) || (gUnicode[gNum] > 0xA0))
{
gFont.maxAscent = gdY[gNum];
#ifdef SHOW_ASCENT_DESCENT
Serial.print("Unicode = 0x"); Serial.print(gUnicode[gNum], HEX); Serial.print(", maxAscent = "); Serial.println(gFont.maxAscent);
#endif
}
}
*/
// 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)
{
@@ -3335,8 +3302,7 @@ void TFT_eSPI::unloadFont(uint8_t font)
gFonts[font].gArray = nullptr;
}
uint32_t TFT_eSPI::readInt32(void)
{
uint32_t TFT_eSPI::readInt32() {
uint32_t val = 0;
val = (uint32_t)pgm_read_byte(fontPtr++) << 24;
@@ -3434,9 +3400,7 @@ void TFT_eSPI::drawGlyph(uint16_t code, uint16_t font)
if (fillwidth > 0) {
fillheight = gFonts[font].maxAscent - gdY[font][gNum];
// Could be negative
if (fillheight > 0) {
fillRect(bg_cursor_x, cursor_y, fillwidth, fillheight, textbgcolor);
}
if (fillheight > 0) fillRect(bg_cursor_x, cursor_y, fillwidth, fillheight, textbgcolor);
}
else {
// Could be negative
@@ -3519,7 +3483,7 @@ void TFT_eSPI::drawGlyph(uint16_t code, uint16_t font)
#define Z_THRESHOLD 350 // Touch pressure threshold for validating touches
#endif
inline void TFT_eSPI::begin_touch_read_write(void){
inline void TFT_eSPI::begin_touch_read_write() {
dmaWait();
CS_H; // Just in case it has been left low
if (locked) {locked = false; spi.beginTransaction(SPISettings(SPI_TOUCH_FREQUENCY, MSBFIRST, SPI_MODE0));}
@@ -3527,7 +3491,7 @@ inline void TFT_eSPI::begin_touch_read_write(void){
digitalWrite(TOUCH_CS, LOW);
}
inline void TFT_eSPI::end_touch_read_write(void){
inline void TFT_eSPI::end_touch_read_write() {
digitalWrite(TOUCH_CS, HIGH);
if(!inTransaction) {if (!locked) {locked = true; spi.endTransaction();}}
}
@@ -3574,7 +3538,7 @@ uint8_t TFT_eSPI::getTouchRaw(uint16_t *x, uint16_t *y){
** Function name: getTouchRawZ
** Description: read raw pressure on touchpad and return Z value.
***************************************************************************************/
uint16_t TFT_eSPI::getTouchRawZ(void){
uint16_t TFT_eSPI::getTouchRawZ() {
begin_touch_read_write();
@@ -3591,10 +3555,6 @@ uint16_t TFT_eSPI::getTouchRawZ(void){
return (uint16_t)tz;
}
/***************************************************************************************
** Function name: validTouch
** Description: read validated position. Return false if not pressed.
***************************************************************************************/
#define _RAWERR 20 // Deadband error allowed in successive position samples
uint8_t TFT_eSPI::validTouch(uint16_t *x, uint16_t *y, uint16_t threshold){
uint16_t x_tmp, y_tmp, x_tmp2, y_tmp2;
@@ -3609,24 +3569,16 @@ uint8_t TFT_eSPI::validTouch(uint16_t *x, uint16_t *y, uint16_t threshold){
delay(1);
}
// Serial.print("Z = ");Serial.println(z1);
if (z1 <= threshold) return false;
getTouchRaw(&x_tmp,&y_tmp);
// Serial.print("Sample 1 x,y = "); Serial.print(x_tmp);Serial.print(",");Serial.print(y_tmp);
// Serial.print(", Z = ");Serial.println(z1);
delay(1); // Small delay to the next sample
if (getTouchRawZ() <= threshold) return false;
delay(2); // Small delay to the next sample
getTouchRaw(&x_tmp2,&y_tmp2);
// Serial.print("Sample 2 x,y = "); Serial.print(x_tmp2);Serial.print(",");Serial.println(y_tmp2);
// Serial.print("Sample difference = ");Serial.print(abs(x_tmp - x_tmp2));Serial.print(",");Serial.println(abs(y_tmp - y_tmp2));
if (abs(x_tmp - x_tmp2) > _RAWERR) return false;
if (abs(y_tmp - y_tmp2) > _RAWERR) return false;
@@ -3693,16 +3645,10 @@ void TFT_eSPI::convertRawXY(uint16_t *x, uint16_t *y)
*y = yy;
}
/***************************************************************************************
** Function name: calibrateTouch
** Description: generates calibration parameters for touchscreen.
***************************************************************************************/
void TFT_eSPI::calibrateTouch(uint16_t *parameters, uint32_t color_fg, uint32_t color_bg, uint8_t size){
void TFT_eSPI::calibrateTouch(uint16_t *parameters, uint32_t color_fg, uint32_t color_bg, uint8_t size) {
int16_t values[] = {0,0,0,0,0,0,0,0};
uint16_t x_tmp, y_tmp;
for(uint8_t i = 0; i<4; i++){
fillRect(0, 0, size+1, size+1, color_bg);
fillRect(0, _height-size-1, size+1, size+1, color_bg);
@@ -3841,12 +3787,6 @@ TFT_eSprite::TFT_eSprite(TFT_eSPI *tft) {
lockTransaction = true;
}
/***************************************************************************************
** Function name: createSprite
** Description: Create a sprite (bitmap) of defined width and height
***************************************************************************************/
// cast returned value to (uint8_t*) for 8-bit or (uint16_t*) for 16-bit colours
void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames) {
if ( _created ) return _img8_1;
@@ -3871,30 +3811,18 @@ void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames) {
_img = (uint16_t*) _img8;
_img4 = _img8;
if ( (_bpp == 16) && (frames > 1) ) {
_img8_2 = _img8 + (w * h * 2 + 1);
}
if ( (_bpp == 16) && (frames > 1) ) _img8_2 = _img8 + (w * h * 2 + 1);
// ESP32 only 16bpp check
//if (esp_ptr_dma_capable(_img8_1)) Serial.println("DMA capable Sprite pointer _img8_1");
//else Serial.println("Not a DMA capable Sprite pointer _img8_1");
//if (esp_ptr_dma_capable(_img8_2)) Serial.println("DMA capable Sprite pointer _img8_2");
//else Serial.println("Not a DMA capable Sprite pointer _img8_2");
if ( (_bpp == 8) && (frames > 1) ) {
_img8_2 = _img8 + (w * h + 1);
}
if ( (_bpp == 8) && (frames > 1) ) _img8_2 = _img8 + (w * h + 1);
// This is to make it clear what pointer size is expected to be used
// but casting in the user sketch is needed due to the use of void*
if ( (_bpp == 1) && (frames > 1) )
{
if ( (_bpp == 1) && (frames > 1) ) {
w = (w+7) & 0xFFF8;
_img8_2 = _img8 + ( (w>>3) * h + 1 );
}
if (_img8)
{
if (_img8) {
_created = true;
if ( (_bpp == 4) && (_colorMap == nullptr)) createPalette(default_4bit_palette);
@@ -3907,42 +3835,21 @@ void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames) {
return nullptr;
}
/***************************************************************************************
** Function name: getPointer
** Description: Returns pointer to start of sprite memory area
***************************************************************************************/
void* TFT_eSprite::getPointer(void)
void* TFT_eSprite::getPointer()
{
if (!_created) return nullptr;
return _img8_1;
}
/***************************************************************************************
** Function name: created
** Description: Returns true if sprite has been created
***************************************************************************************/
bool TFT_eSprite::created(void)
{
bool TFT_eSprite::created() {
return _created;
}
/***************************************************************************************
** Function name: ~TFT_eSprite
** Description: Class destructor
***************************************************************************************/
TFT_eSprite::~TFT_eSprite(void)
{
TFT_eSprite::~TFT_eSprite() {
deleteSprite();
for(int i = 0; i < 2; i++) unloadFont(i);
for(int i = 0; i < 7; i++) unloadFont(i);
}
/***************************************************************************************
** Function name: callocSprite
** Description: Allocate a memory area for the Sprite and return pointer
***************************************************************************************/
void* TFT_eSprite::callocSprite(int16_t w, int16_t h, uint8_t frames)
{
// Add one extra "off screen" pixel to point out-of-bounds setWindow() coordinates
@@ -3953,28 +3860,13 @@ void* TFT_eSprite::callocSprite(int16_t w, int16_t h, uint8_t frames)
if (frames > 2) frames = 2; // Currently restricted to 2 frame buffers
if (frames < 1) frames = 1;
if (_bpp == 16)
{
{
ptr8 = ( uint8_t*) calloc(frames * w * h + frames, sizeof(uint16_t));
//Serial.println("Normal RAM");
}
}
else if (_bpp == 8)
{
ptr8 = ( uint8_t*) calloc(frames * w * h + frames, sizeof(uint8_t));
}
else if (_bpp == 4)
{
if (_bpp == 16) ptr8 = ( uint8_t*) calloc(frames * w * h + frames, sizeof(uint16_t));
else if (_bpp == 8) ptr8 = ( uint8_t*) calloc(frames * w * h + frames, sizeof(uint8_t));
else if (_bpp == 4) {
w = (w+1) & 0xFFFE; // width needs to be multiple of 2, with an extra "off screen" pixel
_iwidth = w;
ptr8 = ( uint8_t*) calloc(((frames * w * h) >> 1) + frames, sizeof(uint8_t));
}
else // Must be 1 bpp
{
} else {// Must be 1 bpp
//_dwidth Display width+height in pixels always in rotation 0 orientation
//_dheight Not swapped for sprite rotations
// Note: for 1bpp _iwidth and _iheight are swapped during Sprite rotations
@@ -4064,55 +3956,33 @@ void* TFT_eSprite::setColorDepth(int8_t b)
return nullptr;
}
int8_t TFT_eSprite::getColorDepth(void)
{
int8_t TFT_eSprite::getColorDepth() {
if (_created) return _bpp;
else return 0;
}
/***************************************************************************************
** Function name: setBitmapColor
** Description: Set the 1bpp foreground foreground and background colour
***************************************************************************************/
void TFT_eSprite::setBitmapColor(uint16_t c, uint16_t b)
{
void TFT_eSprite::setBitmapColor(uint16_t c, uint16_t b) {
if (c == b) b = ~c;
_tft->bitmap_fg = c;
_tft->bitmap_bg = b;
}
/***************************************************************************************
** Function name: setPaletteColor
** Description: Set the 4bpp palette color at the given index
***************************************************************************************/
void TFT_eSprite::setPaletteColor(uint8_t index, uint16_t color)
{
void TFT_eSprite::setPaletteColor(uint8_t index, uint16_t color) {
if (_colorMap == nullptr || index > 15) return; // out of bounds
_colorMap[index] = color;
}
/***************************************************************************************
** Function name: getPaletteColor
** Description: Return the palette color at 4bpp index, or 0 on error.
***************************************************************************************/
uint16_t TFT_eSprite::getPaletteColor(uint8_t index)
{
uint16_t TFT_eSprite::getPaletteColor(uint8_t index) {
if (_colorMap == nullptr || index > 15) return 0; // out of bounds
return _colorMap[index];
}
/***************************************************************************************
** Function name: deleteSprite
** Description: Delete the sprite to free up memory (RAM)
***************************************************************************************/
void TFT_eSprite::deleteSprite(void)
{
void TFT_eSprite::deleteSprite() {
if (_colorMap != nullptr)
{
free(_colorMap);
@@ -4407,10 +4277,6 @@ uint16_t TFT_eSprite::readPixelValue(int32_t x, int32_t y)
return 0;
}
/***************************************************************************************
** Function name: readPixel
** Description: Read 565 colour of a pixel at defined coordinates
***************************************************************************************/
uint16_t TFT_eSprite::readPixel(int32_t x, int32_t y)
{
if (_vpOoB || !_created) return 0xFFFF;
@@ -4590,10 +4456,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_
y++;
}
}
}
else // 1bpp
{
} else { // 1bpp
// Plot a 1bpp image into a 1bpp Sprite
uint32_t ww = (w+7)>>3; // Width of source image line in bytes
uint8_t *ptr = (uint8_t *)data;
@@ -4601,8 +4464,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_
{
uint32_t yw = yp * ww; // Byte starting the line containing source pixel
int32_t ox = x;
for (int32_t xp = dx; xp < dx + dw; xp++)
{
for (int32_t xp = dx; xp < dx + dw; xp++) {
uint16_t readPixel = (ptr[(xp>>3) + yw] & (0x80 >> (xp & 0x7)) );
drawPixel(ox++, y, readPixel);
}
@@ -4615,8 +4477,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const u
pushImage(x, y, w, h, (uint16_t*) data);
}
void TFT_eSprite::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
{
void TFT_eSprite::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1) {
if (x0 > x1) transpose(x0, x1);
if (y0 > y1) transpose(y0, y1);
@@ -4671,12 +4532,10 @@ void TFT_eSprite::pushColor(uint16_t color)
else drawPixel(_xptr, _yptr, color);
// Increment x
_xptr++;
// Wrap on x and y to start, increment y if needed
if (_xptr > _xe)
{
if (_xptr > _xe) {
_xptr = _xs;
_yptr++;
if (_yptr > _ye) _yptr = _ys;
@@ -4689,14 +4548,9 @@ void TFT_eSprite::pushColor(uint16_t color, uint32_t len)
if (!_created ) return;
uint16_t pixelColor;
if (_bpp == 16)
pixelColor = (uint16_t) (color >> 8) | (color << 8);
else if (_bpp == 8)
pixelColor = (color & 0xE000)>>8 | (color & 0x0700)>>6 | (color & 0x0018)>>3;
else pixelColor = (uint16_t) color; // for 1bpp or 4bpp
if (_bpp == 16) pixelColor = (uint16_t) (color >> 8) | (color << 8);
else if (_bpp == 8) pixelColor = (color & 0xE000)>>8 | (color & 0x0700)>>6 | (color & 0x0018)>>3;
else pixelColor = (uint16_t) color;
while(len--) writeColor(pixelColor);
}
@@ -4705,24 +4559,15 @@ void TFT_eSprite::writeColor(uint16_t color)
{
if (!_created ) return;
// Write 16-bit RGB 565 encoded colour to RAM
if (_bpp == 16) _img [_xptr + _yptr * _iwidth] = color;
// Write 8-bit RGB 332 encoded colour to RAM
else if (_bpp == 8) _img8[_xptr + _yptr * _iwidth] = (uint8_t) color;
else if (_bpp == 4)
{
else if (_bpp == 4) {
uint8_t c = (uint8_t)color & 0x0F;
if ((_xptr & 0x01) == 0)
_img4[(_xptr + _yptr * _iwidth)>>1] = (c << 4) | (_img4[(_xptr + _yptr * _iwidth)>>1] & 0x0F); // new color is in bits 7 .. 4
else
_img4[(_xptr + _yptr * _iwidth)>>1] = (_img4[(_xptr + _yptr * _iwidth)>>1] & 0xF0) | c; // new color is the low bits (x is odd)
if ((_xptr & 0x01) == 0) _img4[(_xptr + _yptr * _iwidth)>>1] = (c << 4) | (_img4[(_xptr + _yptr * _iwidth)>>1] & 0x0F); // new color is in bits 7 .. 4
else _img4[(_xptr + _yptr * _iwidth)>>1] = (_img4[(_xptr + _yptr * _iwidth)>>1] & 0xF0) | c; // new color is the low bits (x is odd)
}
else drawPixel(_xptr, _yptr, color);
// Increment x
_xptr++;
// Wrap on x and y to start, increment y if needed
@@ -4738,27 +4583,18 @@ void TFT_eSprite::fillSprite(uint32_t color)
{
if (!_created || _vpOoB) return;
// Use memset if possible as it is super fast
if(_xDatum == 0 && _yDatum == 0 && _xWidth == width())
if(_xDatum == 0 && _yDatum == 0 && _xWidth == width())
{
if(_bpp == 16) {
if ( (uint8_t)color == (uint8_t)(color>>8) ) {
memset(_img, (uint8_t)color, _iwidth * _yHeight * 2);
}
if ( (uint8_t)color == (uint8_t)(color>>8) ) memset(_img, (uint8_t)color, _iwidth * _yHeight * 2);
else fillRect(_vpX, _vpY, _xWidth, _yHeight, color);
}
else if (_bpp == 8)
{
} else if (_bpp == 8) {
color = (color & 0xE000)>>8 | (color & 0x0700)>>6 | (color & 0x0018)>>3;
memset(_img8, (uint8_t)color, _iwidth * _yHeight);
}
else if (_bpp == 4)
{
} else if (_bpp == 4) {
uint8_t c = ((color & 0x0F) | (((color & 0x0F) << 4) & 0xF0));
memset(_img4, c, (_iwidth * _yHeight) >> 1);
}
else if (_bpp == 1)
{
} else if (_bpp == 1) {
if(color) memset(_img8, 0xFF, (_bitwidth>>3) * _dheight + 1);
else memset(_img8, 0x00, (_bitwidth>>3) * _dheight + 1);
}
@@ -4766,8 +4602,7 @@ void TFT_eSprite::fillSprite(uint32_t color)
else fillRect(_vpX - _xDatum, _vpY - _yDatum, _xWidth, _yHeight, color);
}
int16_t TFT_eSprite::width(void)
{
int16_t TFT_eSprite::width() {
if (!_created ) return 0;
if (_bpp > 1) {
@@ -4784,8 +4619,7 @@ int16_t TFT_eSprite::width(void)
return _dwidth;
}
int16_t TFT_eSprite::height(void)
{
int16_t TFT_eSprite::height() {
if (!_created ) return 0;
if (_bpp > 1) {
@@ -4937,11 +4771,6 @@ void TFT_eSprite::drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color)
}
}
/***************************************************************************************
** Function name: drawFastHLine
** Description: draw a horizontal line
***************************************************************************************/
void TFT_eSprite::drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color)
{
if (!_created || _vpOoB) return;
+9 -12
View File
@@ -314,12 +314,12 @@ class TFT_eSPI { friend class TFT_eSprite;
uint8_t spiBusyCheck = 0; // Number of ESP32 transfer buffers to check
// Bare metal functions
void startWrite(void); // Begin SPI transaction
void startWrite(); // Begin SPI transaction
void writeColor(uint16_t color, uint32_t len); // Deprecated, use pushBlock()
void endWrite(void); // End SPI transaction
void endWrite(); // End SPI transaction
// Global variables
static SPIClass& getSPIinstance(void); // Get SPI class handle
static SPIClass& getSPIinstance(); // Get SPI class handle
uint32_t textcolor, textbgcolor; // Text foreground and background colours
uint32_t bitmap_fg, bitmap_bg; // Bitmap foreground (bit=1) and background (bit=0) colours
@@ -370,7 +370,7 @@ class TFT_eSPI { friend class TFT_eSprite;
uint32_t* gBitmap[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //file pointer to greyscale bitmap
uint8_t getTouchRaw(uint16_t *x, uint16_t *y);
uint16_t getTouchRawZ(void);
uint16_t getTouchRawZ();
void convertRawXY(uint16_t *x, uint16_t *y);
uint8_t getTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600);
@@ -461,13 +461,13 @@ uint8_t spi_write_speed;
class TFT_eSprite : public TFT_eSPI {
public:
explicit TFT_eSprite(TFT_eSPI *tft);
~TFT_eSprite(void);
~TFT_eSprite();
void* createSprite(int16_t width, int16_t height, uint8_t frames = 1);
void* getPointer();
bool created();
void deleteSprite(void);
void deleteSprite();
void* setColorDepth(int8_t b);
int8_t getColorDepth(void);
int8_t getColorDepth();
void createPalette(uint16_t *palette = nullptr, uint8_t colors = 16);
void createPalette(const uint16_t *palette = nullptr, uint8_t colors = 16);
void setPaletteColor(uint8_t index, uint16_t color);
@@ -494,8 +494,8 @@ class TFT_eSprite : public TFT_eSPI {
bool pushToSprite(TFT_eSprite *dspr, int32_t x, int32_t y, uint16_t transparent);
int16_t drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font),
drawChar(uint16_t uniCode, int32_t x, int32_t y);
int16_t width(void),
height(void);
int16_t width(),
height();
void drawGlyph(uint16_t code, uint16_t font);
private:
@@ -504,9 +504,6 @@ class TFT_eSprite : public TFT_eSPI {
void* callocSprite(int16_t width, int16_t height, uint8_t frames = 1);
void begin_nin_write(void) { ; }
void end_nin_write(void) { ; }
protected:
uint8_t _bpp; // bits per pixel (1, 4, 8 or 16)
+2 -11
View File
@@ -9,20 +9,11 @@
#define SPI_READ_FREQUENCY 20000000
#define SPI_TOUCH_FREQUENCY 2500000
#ifdef ARS
#define TFT_RGB_ORDER TFT_RGB
#endif
#define TFT_BGR 0 // Colour order Blue-Green-Red
#define TFT_RGB 1 // Colour order Red-Green-Blue
#ifndef ARS
#define TFT_WIDTH 240
#define TFT_HEIGHT 320
#else
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
#endif
#define TFT_WIDTH 240
#define TFT_HEIGHT 320
#include <ILI9341_Defines.h>
#define TFT_DRIVER 0x9341
+1 -9
View File
@@ -289,14 +289,6 @@ boolean WiFiConnect::startConfigurationPortal(AP_Continue apcontinue, const char
DEBUG_WC(F("WiFi AP STA - Configuration Portal"));
}
_lastAPPage = millis();
// WiFi.mode(WIFI_AP);//Fix for scan bug when switching from STA to AP STA
// delay(1);
// WiFi.mode(WIFI_AP_STA);
// delay(1);
#ifdef ARDUINO_ARCH_ESP8266
WiFi.setSleepMode(WIFI_NONE_SLEEP);
#endif
delay(50);
@@ -1228,7 +1220,7 @@ void WiFiConnect::setAPCallback( void (*func)(WiFiConnect* myWiFiConnect) ) {
a flag for processing else where.
*/
/**************************************************************************/
void WiFiConnect::setSaveConfigCallback( void (*func)(void) ) {
void WiFiConnect::setSaveConfigCallback( void (*func)() ) {
_savecallback = func;
}
/**************************************************************************/
+2 -2
View File
@@ -96,7 +96,7 @@ class WiFiConnect {
//called when AP mode and config portal is started
void setAPCallback( void (*func)(WiFiConnect*) );
//called when settings have been changed and connection was successful
void setSaveConfigCallback( void (*func)(void) );
void setSaveConfigCallback( void (*func)() );
void setDebug(boolean isDebug);
@@ -161,7 +161,7 @@ class WiFiConnect {
IPAddress _sta_static_sn; ///< Variable for holding Static Subnet Mask IP Address for the network connection
void (*_apcallback)(WiFiConnect*) = NULL;
void (*_savecallback)(void) = NULL;
void (*_savecallback)() = NULL;
+19 -20
View File
@@ -8,7 +8,7 @@
uint8_t dropped_groups = 0;
bool lastBitState = false;
uint16_t TEF6686::getBlockA(void) {
uint16_t TEF6686::getBlockA() {
uint16_t blockA;
devTEF_Radio_Get_RDS_Status(NULL, &blockA, NULL, NULL, NULL, NULL);
return blockA;
@@ -106,7 +106,7 @@ uint16_t TEF6686::TestAF() {
void TEF6686::init(byte TEF) {
Tuner_Reset();
while(devTEF_APPL_Get_Operation_Status() != 0) delay(5);
while(devTEF_APPL_Get_Operation_Status() != 0) delay(2);
uint32_t clock = 12000000;
@@ -125,12 +125,12 @@ void TEF6686::init(byte TEF) {
// Start the firmware
devTEF_Set_Cmd(TEF_INIT, 0, 0);
while(devTEF_APPL_Get_Operation_Status() != 1) delay(5); // Wait for it to load
while(devTEF_APPL_Get_Operation_Status() != 1) delay(2); // Wait for it to load
if(clock != 9216000) devTEF_Set_Cmd(TEF_APPL, Cmd_Set_ReferenceClock, 6, (clock >> 16) & 0xffff, clock & 0xffff, (clock == 55466670) ? 1 : 0);
devTEF_Set_Cmd(TEF_APPL, Cmd_Set_Activate, 2, 1); // Setup done, start radio
while(devTEF_APPL_Get_Operation_Status() != 2) delay(5); // Wait for it to start
while(devTEF_APPL_Get_Operation_Status() != 2) delay(2); // Wait for it to start
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Mph, 6, 0, 360, 300);
devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Max, 4, 0, 4000);
@@ -156,7 +156,6 @@ void TEF6686::getIdentification(uint16_t *device, uint16_t *hw_version, uint16_t
void TEF6686::power(bool mode) {
devTEF_Set_Cmd(TEF_APPL, Cmd_Set_OperationMode, 2, mode);
if (mode == 0) devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 1, 10000);
}
void TEF6686::extendBW(bool yesno) {
@@ -164,7 +163,7 @@ void TEF6686::extendBW(bool yesno) {
}
void TEF6686::SetFreq(uint16_t frequency) {
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 4, frequency);
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 4, 1, frequency);
currentfreq = ((frequency + 5) / 10) * 10;
currentfreq2 = frequency;
}
@@ -359,9 +358,9 @@ void TEF6686::getStatusAM(int16_t *level, uint16_t *noise, uint16_t *cochannel,
void TEF6686::readRDS(byte showrdserrors) {
if(rds.filter && ps_process) devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
else {
for(int i = 0; i < 3; i++) {
for(int i = 0; i < 4; i++) {
devTEF_Radio_Get_RDS_Data(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
delay(2);
delay(1);
if(bitRead(rds.rdsStat, 15)) break;
}
}
@@ -437,7 +436,7 @@ void TEF6686::readRDS(byte showrdserrors) {
fs::File file;
if (rds.region == 1 && SPIFFS.begin(true)) {
delay(5);
delay(2);
if (currentfreq2 < 9000) file = SPIFFS.open("/USA_87-90.csv");
else if (currentfreq2 > 9000 && currentfreq2 < 9200) file = SPIFFS.open("/USA_90-92.csv");
else if (currentfreq2 > 9200 && currentfreq2 < 9400) file = SPIFFS.open("/USA_92-94.csv");
@@ -449,7 +448,7 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (currentfreq2 > 10400 && currentfreq2 < 10600) file = SPIFFS.open("/USA_104-106.csv");
else if (currentfreq2 > 10600) file = SPIFFS.open("/USA_106-108.csv");
delay(5);
delay(2);
if (file) {
int i = 0;
while (file.available() && !isprint(file.peek())) {
@@ -1312,21 +1311,21 @@ void TEF6686::readRDS(byte showrdserrors) {
uint16_t length_marker_1 = (rds.rdsC >> 1) & 0x3F;
uint16_t start_marker_2 = (rds.rdsD >> 5) & 0x3F;
uint16_t length_marker_2 = (rds.rdsD & 0x1F);
togglebit = bitRead(lowByte(rds.rdsB), 4);
runningbit = bitRead(lowByte(rds.rdsB), 3);
togglebit = bitRead(rds.rdsB, 4);
runningbit = bitRead(rds.rdsB, 3);
switch (rds.rdsplusTag1) {
case 0: rds.rdsplusTag1 = 169; break;
case 1 ... 53: rds.rdsplusTag1 += 111; break;
case 59 ... 63: rds.rdsplusTag1 += 105; break;
default: rds.rdsplusTag1 = 169; break;
case 0: rds.rdsplusTag1 = 168; break;
case 1 ... 53: rds.rdsplusTag1 += 110; break;
case 59 ... 63: rds.rdsplusTag1 += 104; break;
default: rds.rdsplusTag1 = 168; break;
}
switch (rds.rdsplusTag2) {
case 0: rds.rdsplusTag2 = 169; break;
case 1 ... 53: rds.rdsplusTag2 += 111; break;
case 59 ... 63: rds.rdsplusTag2 += 105; break;
default: rds.rdsplusTag2 = 169; break;
case 0: rds.rdsplusTag2 = 168; break;
case 1 ... 53: rds.rdsplusTag2 += 110; break;
case 59 ... 63: rds.rdsplusTag2 += 104; break;
default: rds.rdsplusTag2 = 168; break;
}
if (togglebit) {
+1 -1
View File
@@ -32,7 +32,7 @@ bool devTEF_Get_Cmd(TEF_MODULE module, uint8_t cmd, uint8_t *receive, uint16_t l
uint8_t devTEF_APPL_Get_Operation_Status() {
uint8_t buf[2];
while(!devTEF_Get_Cmd(TEF_APPL, Cmd_Get_Operation_Status, buf, sizeof(buf))) delay(2);
while(!devTEF_Get_Cmd(TEF_APPL, Cmd_Get_Operation_Status, buf, sizeof(buf))) delay(3);
return Convert8bto16b(buf);
}
+1 -1
View File
@@ -9,7 +9,7 @@ bool Tuner_WriteBuffer(unsigned char *buf, uint16_t len) {
Wire.beginTransmission(TEF668X_ADDRESS);
for (uint16_t i = 0; i < len; i++) Wire.write(buf[i]);
uint8_t r = Wire.endTransmission();
if (!Data_Accelerator) delay(2);
if (!Data_Accelerator) delay(1);
return (r == 0) ? true : false;
}
+4 -4
View File
@@ -778,7 +778,7 @@ void XDRGTKRoutine() {
if (!screenmute) {
tft.drawRoundRect(10, 30, 300, 170, 5, ActiveColor);
tft.fillRoundRect(12, 32, 296, 166, 5, BackgroundColor);
tftPrint(ACENTER, textUI(34), 160, 100, ActiveColor, ActiveColorSmooth, 28);
tftPrint(ACENTER, textUI(33), 160, 100, ActiveColor, ActiveColorSmooth, 28);
}
DataPrint("U");
@@ -905,7 +905,7 @@ void tryWiFi() {
if (!setupmode && wifi) {
tft.drawRoundRect(1, 20, 319, 180, 5, ActiveColor);
tft.fillRoundRect(3, 22, 315, 176, 5, BackgroundColor);
Infoboxprint(textUI(55));
Infoboxprint(textUI(54));
}
if (wifi) {
if (wc.autoConnect()) {
@@ -917,9 +917,9 @@ void tryWiFi() {
webserver.begin();
NTPupdate();
remoteip = IPAddress(WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], subnetclient);
if (!setupmode) tftPrint(ACENTER, textUI(57), 155, 128, InsignificantColor, InsignificantColorSmooth, 28);
if (!setupmode) tftPrint(ACENTER, textUI(56), 155, 128, InsignificantColor, InsignificantColorSmooth, 28);
} else {
if (!setupmode) tftPrint(ACENTER, textUI(56), 155, 128, SignificantColor, SignificantColorSmooth, 28);
if (!setupmode) tftPrint(ACENTER, textUI(55), 155, 128, SignificantColor, SignificantColorSmooth, 28);
Server.end();
webserver.stop();
Udp.stop();
-1
View File
@@ -25,7 +25,6 @@ bool memorystore;
bool memreset, memtune;
bool menu, menuopen;
bool mwstepsize;
bool optenc;
bool rdsflagreset;
bool rdsreset;
bool rdsstatscreen;
+629 -633
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -41,9 +41,9 @@ void handleRoot() {
html += "<img src=\"/logo.png\" alt=\"FMDX website\">";
html += "</a>";
html += "<h1>" + String(textUI(286)) + "</h1>";
html += "<button onclick=\"window.location.href='/downloadCSV'\">" + String(textUI(287)) + "</button>";
html += "<button class=\"go-to-bottom\" onclick=\" window.scrollTo(0, document.body.scrollHeight);\">" + String(textUI(289)) + "</button>";
html += "<h1>" + String(textUI(285)) + "</h1>";
html += "<button onclick=\"window.location.href='/downloadCSV'\">" + String(textUI(286)) + "</button>";
html += "<button class=\"go-to-bottom\" onclick=\" window.scrollTo(0, document.body.scrollHeight);\">" + String(textUI(288)) + "</button>";
// Sorting function with icons
html += "<script>";
@@ -143,9 +143,9 @@ void handleRoot() {
}
file.close();
} else html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(299)) + "</td></tr>";
} else html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(298)) + "</td></tr>";
if (!hasData) html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(288)) + "</td></tr>";
if (!hasData) html += "<tr><td colspan=\"100%\" style=\"text-align: center; color: red;\">" + String(textUI(287)) + "</td></tr>";
html += "</table>";
html += "</body></html>";
+119 -234
View File
@@ -20,8 +20,12 @@ using fs::FS;
#include "touch.h"
#include "nonvolatile.h"
#include "utils.h"
#include "system_console.h"
#pragma endregion
Console console(&tft);
bool gpio_chip = false;
#pragma region to move
void Round30K(unsigned int freq) {
if (freq % FREQ_OIRT_STEP_30K == 1) frequency_OIRT = (freq + 1);
@@ -59,13 +63,6 @@ void Touch_IRQ_Handler() {
}
void deepSleep() {
#ifdef SMETERPIN
analogWrite(SMETERPIN, 0);
#endif
#ifdef STANDBYLED
pinMode(STANDBYLED, OUTPUT);
digitalWrite(STANDBYLED, LOW);
#endif
MuteScreen(1);
StoreFrequency();
radio.power(1);
@@ -108,9 +105,7 @@ void EdgeBeeper() {
const char* textUI(uint16_t number) {
if (number >= language_entrynumber) return "Overflow";
else {
return (const char*)pgm_read_ptr(&(myLanguage[language][number]));
}
else return (const char*)pgm_read_ptr(&(myLanguage[language][number]));
}
void doBWtuneUp() {
@@ -158,13 +153,10 @@ void ShowRSSI() {
if (wifi) rssi = WiFi.RSSI(); else rssi = 0;
if (rssiold != rssi) {
rssiold = rssi;
if (!wifi && batterydetect) {
tft.drawBitmap(282, 3, WiFi4, 30, 25, BackgroundColor);
} else if (rssi == 0) {
tft.drawBitmap(282, 3, WiFi4, 30, 25, GreyoutColor);
} else if (rssi > -50 && rssi < 0) {
tft.drawBitmap(282, 3, WiFi4, 30, 25, WifiColorHigh);
} else if (rssi > -60) {
if (!wifi && batterydetect) tft.drawBitmap(282, 3, WiFi4, 30, 25, BackgroundColor);
else if (rssi == 0) tft.drawBitmap(282, 3, WiFi4, 30, 25, GreyoutColor);
else if (rssi > -50 && rssi < 0) tft.drawBitmap(282, 3, WiFi4, 30, 25, WifiColorHigh);
else if (rssi > -60) {
tft.drawBitmap(282, 3, WiFi4, 30, 25, GreyoutColor);
tft.drawBitmap(282, 3, WiFi3, 30, 25, WifiColorHigh);
} else if (rssi > -70) {
@@ -245,7 +237,7 @@ void SetTunerPatch() {
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
if(FORBIDDEN_TUNER(TEF)) {
tftPrint(ACENTER, textUI(35), 150, 78, ActiveColor, ActiveColorSmooth, 28);
tftPrint(ACENTER, textUI(34), 150, 78, ActiveColor, ActiveColorSmooth, 28);
for (;;);
}
EEPROM.writeByte(EE_BYTE_TEF, TEF);
@@ -556,7 +548,7 @@ void BANDBUTTONPress() {
}
}
while (digitalRead(BANDBUTTON) == LOW) delay(50);
delay(100);
delay(75);
}
void LimitAMFrequency() {
@@ -615,7 +607,7 @@ void BWButtonPress() {
}
}
while (digitalRead(BWBUTTON) == LOW) delay(50);
delay(100);
delay(75);
}
void doStereoToggle() {
@@ -830,7 +822,7 @@ void ShowNum(int val) {
byte numval[16] = {2, 3, 127, 5, 6, 0, 9, 13, 8, 7, 4, 1, 0, 0, 0, 0};
int GetNum() {
if(!gpio_chip) return -1;
// Get input port 0 and 1
Wire.beginTransmission(XL9555_ADDRESS);
Wire.write(0x00);
@@ -1156,9 +1148,11 @@ void setup() {
setupmode = true;
bool tef_found = false;
Wire.begin();
Wire.setClock(400000);
delay(3);
delay(1);
Serial.begin(115200);
Serial.println();
@@ -1174,9 +1168,13 @@ void setup() {
if(address == RX8010SJ_ADDRESS) {
Serial.print(" RTC");
rx_rtc_avail = true;
} else if(address == TEF668X_ADDRESS) {
Serial.print(" TEF");
tef_found = true;
} else if(address == XL9555_ADDRESS) {
Serial.print(" GPIO");
gpio_chip = true;
}
else if(address == TEF668X_ADDRESS) Serial.print(" TEF");
else if(address == XL9555_ADDRESS) Serial.print(" GPIO");
Serial.println(" !");
} else if (error == 4) {
Serial.print("Unknown error at 0x");
@@ -1185,26 +1183,6 @@ void setup() {
}
}
rtc.setTime(0);
if(rx_rtc_avail) {
bool reset = rx_rtc.initModule(); // initModule, not initAdapter, adapter also reinits wire
if(reset) {
RX8010SJ::DateTime defaulttime = RX8010SJ::DateTime();
defaulttime.second = 00;
defaulttime.minute = 00;
defaulttime.hour = 18;
defaulttime.dayOfWeek = 1;
defaulttime.dayOfMonth = 13;
defaulttime.month = 1;
defaulttime.year = 26;
Serial.println("RTC reset with defaults");
rx_rtc.writeDateTime(defaulttime);
} else {
rtcset = true;
sync_from_rx_rtc();
}
}
Serial.flush();
Serial.end();
@@ -1268,19 +1246,8 @@ void setup() {
doTheme();
if (displayflip == 0) {
#ifdef ARS
tft.setRotation(0);
#else
tft.setRotation(3);
#endif
} else {
#ifdef ARS
tft.setRotation(2);
#else
tft.setRotation(1);
#endif
}
if (displayflip == 0) tft.setRotation(3);
else tft.setRotation(1);
tft.invertDisplay(!invertdisplay);
@@ -1290,10 +1257,6 @@ void setup() {
pinMode(ROTARY_BUTTON, INPUT);
pinMode(ROTARY_PIN_A, INPUT);
pinMode(ROTARY_PIN_B, INPUT);
#ifdef STANDBYLED
pinMode(STANDBYLED, OUTPUT);
digitalWrite(STANDBYLED, HIGH);
#endif
pinMode(TOUCHIRQ, INPUT);
pinMode(EXT_IRQ, INPUT_PULLUP);
@@ -1302,7 +1265,6 @@ void setup() {
attachInterrupt(digitalPinToInterrupt(ROTARY_PIN_B), read_encoder, CHANGE);
tft.setSwapBytes(true);
tft.fillScreen(BackgroundColor);
SPIFFS.begin();
@@ -1342,6 +1304,7 @@ void setup() {
SignalSprite.setSwapBytes(true);
UpdateFonts();
tft.fillScreen(BackgroundColor);
if (digitalRead(BWBUTTON) == LOW && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == HIGH) {
if (rotarymode == 0) rotarymode = 1; else rotarymode = 0;
@@ -1356,18 +1319,10 @@ void setup() {
if (digitalRead(BWBUTTON) == HIGH && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == LOW && digitalRead(BANDBUTTON) == HIGH) {
if (displayflip == 0) {
displayflip = 1;
#ifdef ARS
tft.setRotation(2);
#else
tft.setRotation(1);
#endif
} else {
displayflip = 0;
#ifdef ARS
tft.setRotation(0);
#else
tft.setRotation(3);
#endif
}
EEPROM.writeByte(EE_BYTE_DISPLAYFLIP, displayflip);
EEPROM.commit();
@@ -1378,37 +1333,16 @@ void setup() {
}
if (digitalRead(BWBUTTON) == HIGH && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == LOW) {
#ifdef SMETERPIN
analogWrite(SMETERPIN, 511);
#endif
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
Infoboxprint(textUI(4));
tftPrint(ACENTER, textUI(2), 155, 130, ActiveColor, ActiveColorSmooth, 28);
while (digitalRead(BANDBUTTON) == LOW) delay(50);
#ifdef SMETERPIN
analogWrite(SMETERPIN, 0);
#endif
}
if (digitalRead(BWBUTTON) == HIGH && digitalRead(ROTARY_BUTTON) == LOW && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == HIGH) {
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
if (optenc == 0) {
optenc = 1;
Infoboxprint(textUI(6));
} else {
optenc = 0;
Infoboxprint(textUI(7));
}
EEPROM.writeByte(EE_BYTE_OPTENC, optenc);
EEPROM.commit();
tftPrint(ACENTER, textUI(2), 155, 130, ActiveColor, ActiveColorSmooth, 28);
while (digitalRead(ROTARY_BUTTON) == LOW) delay(50);
}
if (digitalRead(BWBUTTON) == LOW && digitalRead(ROTARY_BUTTON) == LOW && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == HIGH) {
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
DefaultSettings();
Infoboxprint(textUI(66));
Infoboxprint(textUI(65));
tftPrint(ACENTER, textUI(2), 155, 130, ActiveColor, ActiveColorSmooth, 28);
while (digitalRead(ROTARY_BUTTON) == LOW && digitalRead(BWBUTTON) == LOW) delay(50);
esp_restart();
@@ -1416,8 +1350,8 @@ void setup() {
if (digitalRead(BWBUTTON) == LOW && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == LOW && digitalRead(BANDBUTTON) == HIGH) {
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
Infoboxprint(textUI(282));
tftPrint(ACENTER, textUI(283), 155, 100, ActiveColor, ActiveColorSmooth, 28);
Infoboxprint(textUI(281));
tftPrint(ACENTER, textUI(282), 155, 100, ActiveColor, ActiveColorSmooth, 28);
tft.calibrateTouch(TouchCalData, PrimaryColor, BackgroundColor, 30);
EEPROM.writeUInt(EE_UINT16_CALTOUCH1, TouchCalData[0]);
EEPROM.writeUInt(EE_UINT16_CALTOUCH2, TouchCalData[1]);
@@ -1429,7 +1363,7 @@ void setup() {
if (digitalRead(BWBUTTON) == LOW && digitalRead(ROTARY_BUTTON) == HIGH && digitalRead(MODEBUTTON) == HIGH && digitalRead(BANDBUTTON) == LOW) {
analogWrite(CONTRASTPIN, map(ContrastSet, 0, 100, 15, 255));
Infoboxprint(textUI(69));
Infoboxprint(textUI(68));
tftPrint(ACENTER, textUI(2), 155, 130, ActiveColor, ActiveColorSmooth, 28);
invertdisplay = !invertdisplay;
tft.invertDisplay(!invertdisplay);
@@ -1440,26 +1374,58 @@ void setup() {
tft.setTouch(TouchCalData);
tft.fillScreen(BackgroundColor);
tftPrint(ACENTER, textUI(8), 160, 3, PrimaryColor, PrimaryColorSmooth, 28);
tftPrint(ACENTER, "Firmware " + String(VERSION), 160, 152, PrimaryColor, PrimaryColorSmooth, 16);
tft.fillScreen(TFT_BLACK);
tft.fillRect(120, 230, 16, 6, GreyoutColor);
tft.fillRect(152, 230, 16, 6, GreyoutColor);
tft.fillRect(184, 230, 16, 6, GreyoutColor);
tft.pushImage(78, 34, 163, 84, radiologo);
tft.drawBitmap(130, 124, TEFLogo, 59, 23, ActiveColor);
tft.pushImage((tft.width() - 163) / 2, (tft.height() - 84) / 2, 163, 84, radiologo, TFT_BLACK);
tft.drawBitmap((tft.width() - 59) / 2, 24, TEFLogo, 59, 23, ActiveColor);
for (int x = 0; x <= ContrastSet; x++) {
analogWrite(CONTRASTPIN, map(x, 0, 100, 15, 255));
delay(10);
}
tft.fillRect(120, 230, 16, 6, PrimaryColor);
console.print("Firmware " + String(VERSION));
if(!tef_found) {
console.print(textUI(8));
while (true) delay(1);
}
rtc.setTime(0);
if(rx_rtc_avail) {
bool reset = rx_rtc.initModule(); // initModule, not initAdapter, adapter also reinits wire
if(reset) {
RX8010SJ::DateTime defaulttime = RX8010SJ::DateTime();
defaulttime.second = 00;
defaulttime.minute = 5;
defaulttime.hour = 19;
defaulttime.dayOfWeek = 2;
defaulttime.dayOfMonth = 14;
defaulttime.month = 1;
defaulttime.year = 26;
rx_rtc.writeDateTime(defaulttime);
console.print("RX8010SJ was reset, no time");
} else {
rtcset = true;
console.print("RX8010SJ is used as a time source");
sync_from_rx_rtc();
}
} else console.print("RX8010SJ is not available at address " + String(RX8010SJ_ADDRESS, HEX));
if(gpio_chip) {
console.print("XL9555 found, setting up");
// Configures the GPIO chip for input in every pin
Wire.beginTransmission(XL9555_ADDRESS);
Wire.write(0x06);
Wire.write(0xFF);
Wire.write(0xFF);
Wire.endTransmission();
} else console.print("XL9555 found not found on address " + String(XL9555_ADDRESS, HEX) + ". Numpad will not work");
TEF = EEPROM.readByte(EE_BYTE_TEF);
if(FORBIDDEN_TUNER(TEF)) SetTunerPatch();
// The tuner being missing here, would cause a infinite loop with no exit and no error, as it resets and polls the chip if it reset, if no response then we try again, and now, you see?
radio.init(TEF);
uint16_t device, hw, sw;
@@ -1470,55 +1436,46 @@ void setup() {
fullsearchrds = false;
fmsi = false;
chipmodel = 0;
tft.fillRect(152, 230, 16, 6, PrimaryColor);
tftPrint(ACENTER, "TEF6686 Lithio", 160, 172, ActiveColor, ActiveColorSmooth, 28);
console.print("Detected a TEF6686 Lithio");
#ifndef DEEPELEC_DP_66X
} else if (lowByte(device) == 1) {
fullsearchrds = true;
chipmodel = 1;
tft.fillRect(152, 230, 16, 6, PrimaryColor);
tftPrint(ACENTER, "TEF6687 Lithio FMSI", 160, 172, ActiveColor, ActiveColorSmooth, 28);
console.print("Detected a TEF6687 Lithio FMSI");
} else if (lowByte(device) == 9) {
fullsearchrds = false;
chipmodel = 2;
fmsi = false;
tft.fillRect(152, 230, 16, 6, PrimaryColor);
tftPrint(ACENTER, "TEF6688 Lithio DR", 160, 172, ActiveColor, ActiveColorSmooth, 28);
console.print("Detected a TEF6688 Lithio DR");
} else if (lowByte(device) == 3) {
fullsearchrds = true;
chipmodel = 3;
tft.fillRect(152, 230, 16, 6, PrimaryColor);
tftPrint(ACENTER, "TEF6689 Lithio FMSI DR", 160, 172, ActiveColor, ActiveColorSmooth, 28);
console.print("Detected a TEF6689 Lithio FMSI DR");
#endif
} else {
tftPrint(ACENTER, textUI(9), 160, 172, SignificantColor, SignificantColorSmooth, 28);
tft.fillRect(152, 230, 16, 6, SignificantColor);
while (true);
}
tftPrint(ACENTER, "Patch: v" + String(TEF) + " HW " + String(hw >> 8) + "." + String(hw & 0xff) + " SW " + String(sw >> 8) + "." + String(sw & 0xff), 160, 202, ActiveColor, ActiveColorSmooth, 16);
console.print("Chip Patch: v" + String(TEF) + " HW " + String(hw >> 8) + "." + String(hw & 0xff) + " SW " + String(sw >> 8) + "." + String(sw & 0xff));
// Configures the GPIO chip for input in every pin
Wire.beginTransmission(XL9555_ADDRESS);
Wire.write(0x06);
Wire.write(0xFF);
Wire.write(0xFF);
Wire.endTransmission();
if(analogRead(BATTERY_PIN) < 200) batterydetect = false;
else console.print("Battery detected.");
if (analogRead(BATTERY_PIN) < 200) batterydetect = false;
if (!SPIFFS.exists("/logbook.csv")) handleCreateNewLogbook();
if(!SPIFFS.exists("/logbook.csv")) {
handleCreateNewLogbook();
console.print("Creating a new logbook.");
}
if (wifi) {
console.print("Trying WiFi");
tryWiFi();
tft.fillRect(184, 230, 16, 6, PrimaryColor);
delay(1750);
} else {
Server.end();
Udp.stop();
tft.fillRect(184, 230, 16, 6, SignificantColor);
}
while(digitalRead(ROTARY_BUTTON) == LOW) delay(75);
console.print("Init done.");
radio.setVolume(VolSet);
radio.setOffset(LevelOffset);
radio.setAMOffset(AMLevelOffset);
@@ -1669,7 +1626,7 @@ void loop() {
flashingtimer = millis();
}
if (!scanholdflag) delay(100);
if (!scanholdflag) delay(75);
radio.getStatus(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
if (!initdxscan) {
@@ -1705,7 +1662,7 @@ void loop() {
if (advancedRDS) {
tft.drawRoundRect(10, 30, 300, 170, 2, ActiveColor);
tft.fillRoundRect(12, 32, 296, 166, 2, BackgroundColor);
tftPrint(ACENTER, textUI(34), 160, 100, ActiveColor, ActiveColorSmooth, 28);
tftPrint(ACENTER, textUI(33), 160, 100, ActiveColor, ActiveColorSmooth, 28);
} else ShowFreq(1);
}
@@ -2356,8 +2313,6 @@ void SelectBand() {
if (tunemode == TUNE_MI_BAND) tunemode = TUNE_MAN;
if (!leave) {
radio.power(0);
delay(50);
if (band == BAND_FM) radio.SetFreq(frequency);
if (band == BAND_OIRT) radio.SetFreq(frequency_OIRT);
}
@@ -2367,9 +2322,8 @@ void SelectBand() {
freqold = frequency_AM;
if (!externaltune && tunemode != TUNE_MEM) CheckBandForbiddenFM();
doBW();
if (radio.rds.region == 0) {
tftPrint(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth, 16);
} else {
if (radio.rds.region == 0) tftPrint(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth, 16);
else {
tftPrint(ALEFT, "PI", 212, 184, ActiveColor, ActiveColorSmooth, 16);
tftPrint(ALEFT, "ID", 212, 201, ActiveColor, ActiveColorSmooth, 16);
}
@@ -2394,18 +2348,18 @@ void SelectBand() {
ShowTuneMode();
ShowStepSize();
tftPrint(ALEFT, textUI(101), 70, 32, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(102), 70, 32, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(103), 70, 32, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(104), 70, 32, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(105), 70, 32, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(106), 70, 32, BackgroundColor, BackgroundColor, 16);
switch (band) {
case BAND_LW: tftPrint(ALEFT, textUI(102), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_MW: tftPrint(ALEFT, textUI(103), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_SW: tftPrint(ALEFT, textUI(104), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_FM: tftPrint(ALEFT, textUI(105), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_OIRT: tftPrint(ALEFT, textUI(106), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_LW: tftPrint(ALEFT, textUI(101), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_MW: tftPrint(ALEFT, textUI(102), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_SW: tftPrint(ALEFT, textUI(103), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_FM: tftPrint(ALEFT, textUI(104), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_OIRT: tftPrint(ALEFT, textUI(105), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
}
}
leave = false;
@@ -2501,7 +2455,7 @@ void ModeButtonPress() {
}
}
while (digitalRead(MODEBUTTON) == LOW) delay(50);
delay(100);
delay(75);
}
void RoundStep() {
@@ -2951,11 +2905,11 @@ void ShowFreq(int mode) {
FrequencySprite.drawString(String(freq / 100) + "." + (freq % 100 < 10 ? "0" : "") + String(freq % 100) + " ", 218, -6, freqfont);
freqold = freq;
break;
case 1: Infoboxprint(textUI(34)); break;
case 2: Infoboxprint(textUI(290)); break;
case 3: Infoboxprint(textUI(291)); break;
case 4: Infoboxprint(textUI(295)); break;
case 5: Infoboxprint(textUI(284)); break;
case 1: Infoboxprint(textUI(33)); break;
case 2: Infoboxprint(textUI(289)); break;
case 3: Infoboxprint(textUI(290)); break;
case 4: Infoboxprint(textUI(294)); break;
case 5: Infoboxprint(textUI(283)); break;
}
FrequencySprite.pushSprite(46, 46);
@@ -3004,19 +2958,6 @@ void ShowSignalLevel() {
SAvg4 = (((SAvg4 * 9) + 5) / 10) + WAM;
SAvg5 = (((SAvg5 * 9) + 5) / 10) + USN;
#ifdef SMETERPIN
float sval = 0;
int16_t smeter = 0;
if (SStatus > 0) {
if (SStatus < 1000) {
sval = 51 * ((pow(10, (((float)SStatus) / 1000))) - 1);
smeter = int16_t(sval);
} else smeter = 511;
}
smeter = int16_t(sval);
#endif
SStatus = SAvg / 10;
CN = SAvg2 / 10;
MP = SAvg4 / 10;
@@ -3052,10 +2993,6 @@ void ShowSignalLevel() {
}
}
#ifdef SMETERPIN
if (!menu) analogWrite(SMETERPIN, smeter);
#endif
int SStatusprint = 0;
if (unit == 0) SStatusprint = SStatus;
if (unit == 1) SStatusprint = ((SStatus * 100) + 10875) / 100;
@@ -3838,26 +3775,16 @@ void read_encoder() {
encval += enc_states[( old_AB & 0x0f )];
if (!(255 - old_AB)) encval = 0;
if (optenc) {
if (encval > 4) {
if (rotarymode) rotary = -1; else rotary = 1;
encval = 0;
} else if (encval < -4) {
if (rotarymode) rotary = 1; else rotary = -1;
encval = 0;
}
} else {
if (encval > 3) {
if (rotarymode) rotary = -1; else rotary = 1;
rotarycounter++;
rotarytimer = millis();
encval = 0;
} else if (encval < -3) {
if (rotarymode) rotary = 1; else rotary = -1;
rotarycounter++;
rotarytimer = millis();
encval = 0;
}
if (encval > 3) {
if (rotarymode) rotary = -1; else rotary = 1;
rotarycounter++;
rotarytimer = millis();
encval = 0;
} else if (encval < -3) {
if (rotarymode) rotary = 1; else rotary = -1;
rotarycounter++;
rotarytimer = millis();
encval = 0;
}
}
@@ -3867,26 +3794,19 @@ void tftReplace(int8_t offset, const String & textold, const String & text, int1
else if (fontsize == 28) selectedFont = 1;
else if (fontsize == 48) selectedFont = 2;
switch (offset) {
case -1: tft.setTextDatum(TL_DATUM); break;
case 0: tft.setTextDatum(TC_DATUM); break;
case 1: tft.setTextDatum(TR_DATUM); break;
}
tft.setTextColor(background, background, false);
switch (offset) {
case -1: tft.setTextDatum(TL_DATUM); break;
case 0: tft.setTextDatum(TC_DATUM); break;
case 1: tft.setTextDatum(TR_DATUM); break;
}
tft.drawString(textold, x, y, selectedFont);
tft.setTextColor(color, smoothcolor, false);
switch (offset) {
case -1: tft.setTextDatum(TL_DATUM); break;
case 0: tft.setTextDatum(TC_DATUM); break;
case 1: tft.setTextDatum(TR_DATUM); break;
}
String modifiedText = text;
modifiedText.replace("\n", " ");
tft.setTextColor(color, smoothcolor, false);
tft.drawString(modifiedText, x, y, selectedFont);
}
@@ -3953,7 +3873,7 @@ uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, ui
tft.drawRect(59, 109, 202, 8, FrameColor);
tft.fillRect(60, 110, 200, 6, GreyoutColor);
tftPrint(ARIGHT, textUI(272), 120, 155, ActiveColor, ActiveColorSmooth, 16);
tftPrint(ARIGHT, textUI(271), 120, 155, ActiveColor, ActiveColorSmooth, 16);
for (frequency = startfreq * 10; frequency <= stopfreq * 10; frequency += 10) {
if (stopScanning) break;
@@ -4046,39 +3966,4 @@ uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, ui
SQ = false;
return error;
}
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_task_wdt.h"
#ifndef ARDUINO_LOOP_STACK_SIZE
#ifndef CONFIG_ARDUINO_LOOP_STACK_SIZE
#define ARDUINO_LOOP_STACK_SIZE 8192
#else
#define ARDUINO_LOOP_STACK_SIZE CONFIG_ARDUINO_LOOP_STACK_SIZE
#endif
#endif
TaskHandle_t loopTaskHandle = NULL;
bool loopTaskWDTEnabled;
__attribute__((weak)) size_t getArduinoLoopTaskStackSize(void) {
return ARDUINO_LOOP_STACK_SIZE;
}
void loopTask(void *pvParameters)
{
setup();
for(;;) {
if(loopTaskWDTEnabled) esp_task_wdt_reset();
loop();
if (serialEventRun) serialEventRun();
}
}
extern "C" void app_main() {
initArduino();
xTaskCreateUniversal(loopTask, "loopTask", getArduinoLoopTaskStackSize(), NULL, 1, &loopTaskHandle, ARDUINO_RUNNING_CORE);
}
-2
View File
@@ -155,7 +155,6 @@ void loadData() {
rotarymode = EEPROM.readByte(EE_BYTE_ROTARYMODE);
tunemode = EEPROM.readByte(EE_BYTE_TUNEMODE);
if (tunemode == TUNE_MAN) stepsize = EEPROM.readByte(EE_BYTE_STEPSIZE); else stepsize = 0;
optenc = EEPROM.readByte(EE_BYTE_OPTENC);
iMSset = EEPROM.readByte(EE_BYTE_IMSSET);
EQset = EEPROM.readByte(EE_BYTE_EQSET);
band = EEPROM.readByte(EE_BYTE_BAND);
@@ -267,7 +266,6 @@ void DefaultSettings() {
EEPROM.writeByte(EE_BYTE_TEF, 0);
EEPROM.writeByte(EE_BYTE_STEPSIZE, 0);
EEPROM.writeByte(EE_BYTE_TUNEMODE, 0);
EEPROM.writeByte(EE_BYTE_OPTENC, 0);
EEPROM.writeByte(EE_BYTE_IMSSET, 1);
EEPROM.writeByte(EE_BYTE_EQSET, 1);
EEPROM.writeByte(EE_BYTE_BAND, BAND_FM);
+7 -7
View File
@@ -54,7 +54,7 @@ void ShowAdvancedRDS() {
if (radio.rds.ECC.changed(0)) {
if (!screenmute) {
if (radio.rds.hasECC) ECCString = (radio.rds.ECCtext.length() == 0 ? textUI(73) : radio.rds.ECCtext); else ECCString = "N/A";
if (radio.rds.hasECC) ECCString = (radio.rds.ECCtext.length() == 0 ? textUI(72) : radio.rds.ECCtext); else ECCString = "N/A";
}
if (wifi) {
@@ -68,7 +68,7 @@ void ShowAdvancedRDS() {
if(!screenmute) eccDisplay.update(ECCString, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
String eonstring;
if (radio.eon_counter > 0) for (byte i = 0; i < radio.eon_counter; i++) eonstring += String(radio.eon[i].picode) + (radio.eon[i].ps.length() > 0 ? String(": " + String(radio.eon[i].ps)) : "") + (radio.eon[i].mappedfreq > 0 ? String(" " + String(radio.eon[i].mappedfreq / 100) + "." + String((radio.eon[i].mappedfreq % 100) / 10)) : "") + (radio.eon[i].mappedfreq2 > 0 ? String(" / " + String(radio.eon[i].mappedfreq2 / 100) + "." + String((radio.eon[i].mappedfreq2 % 100) / 10)) : "") + (radio.eon[i].mappedfreq3 > 0 ? String(" / " + String(radio.eon[i].mappedfreq3 / 100) + "." + String((radio.eon[i].mappedfreq3 % 100) / 10)) : "") + (i == radio.eon_counter - 1 ? " " : " | "); else eonstring = textUI(88);
if (radio.eon_counter > 0) for (byte i = 0; i < radio.eon_counter; i++) eonstring += String(radio.eon[i].picode) + (radio.eon[i].ps.length() > 0 ? String(": " + String(radio.eon[i].ps)) : "") + (radio.eon[i].mappedfreq > 0 ? String(" " + String(radio.eon[i].mappedfreq / 100) + "." + String((radio.eon[i].mappedfreq % 100) / 10)) : "") + (radio.eon[i].mappedfreq2 > 0 ? String(" / " + String(radio.eon[i].mappedfreq2 / 100) + "." + String((radio.eon[i].mappedfreq2 % 100) / 10)) : "") + (radio.eon[i].mappedfreq3 > 0 ? String(" / " + String(radio.eon[i].mappedfreq3 / 100) + "." + String((radio.eon[i].mappedfreq3 % 100) / 10)) : "") + (i == radio.eon_counter - 1 ? " " : " | "); else eonstring = textUI(87);
if (radio.rds.hasEON.changed(0)) {
if (!screenmute) {
if (radio.eon_counter > 0) tftPrint(ALEFT, "EON", 153, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "EON", 153, 51, GreyoutColor, BackgroundColor, 16);
@@ -78,7 +78,7 @@ void ShowAdvancedRDS() {
if(!screenmute) eonDisplay.update(eonstring, RDSstatus, RDSColor, RDSColorSmooth, RDSDropoutColor, RDSDropoutColorSmooth, BackgroundColor);
String rtplusstring;
if (radio.rds.hasRTplus) rtplusstring = (radio.rds.rdsplusTag1 != 169 ? String(textUI(radio.rds.rdsplusTag1)) + ": " + String(radio.rds.RTContent1) : "") + (radio.rds.rdsplusTag2 != 169 ? " - " + String(textUI(radio.rds.rdsplusTag2)) + ": " + String(radio.rds.RTContent2) : "") + " "; else rtplusstring = textUI(89);
if (radio.rds.hasRTplus) rtplusstring = (radio.rds.rdsplusTag1 != 169 ? String(textUI(radio.rds.rdsplusTag1)) + ": " + String(radio.rds.RTContent1) : "") + (radio.rds.rdsplusTag2 != 169 ? " - " + String(textUI(radio.rds.rdsplusTag2)) + ": " + String(radio.rds.RTContent2) : "") + " "; else rtplusstring = textUI(88);
if (radio.rds.hasRTplus.changed(0)) {
if (!screenmute) {
if (radio.rds.hasRTplus) tftPrint(ALEFT, "RT+", 123, 51, RDSColor, RDSColorSmooth, 16); else tftPrint(ALEFT, "RT+", 123, 51, GreyoutColor, BackgroundColor, 16);
@@ -404,7 +404,7 @@ void showPI() {
void showPTY() {
if(radio.rds.PTY.changed(0)) {
String PTYString = String(radio.rds.PTY) + "/" + (radio.rds.region != 0 ? (radio.rds.region == 0 ? PTY_EU[radio.rds.PTY] : PTY_USA[radio.rds.PTY]) : textUI(228 + radio.rds.PTY));
String PTYString = String(radio.rds.PTY) + "/" + (radio.rds.region != 0 ? (radio.rds.region == 0 ? PTY_EU[radio.rds.PTY] : PTY_USA[radio.rds.PTY]) : textUI(227 + radio.rds.PTY));
GeneralTextSprite.fillSprite(TFT_TRANSPARENT);
GeneralTextSprite.fillRect(0, 0, 160, 19, BackgroundColor);
if(RDSstatus) GeneralTextSprite.setTextColor(RDSColor, RDSColorSmooth, false);
@@ -596,7 +596,7 @@ void ShowAFEON() {
if (radio.rds.hasAF && afpagenr == 1) {
if (!hasafold) {
tftPrint(ALEFT, textUI(87), 6, 48, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(86), 6, 48, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, "AF:", 4, 32, ActiveColor, ActiveColorSmooth, 16);
hasafold = true;
}
@@ -619,7 +619,7 @@ void ShowAFEON() {
if (radio.eon_counter > 0 && afpagenr > 1) {
if (!haseonold) {
tftPrint(ALEFT, textUI(88), 6, 48, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(87), 6, 48, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, "PI", 4, 32, ActiveColor, ActiveColorSmooth, 16);
tftPrint(ACENTER, "TA", 250, 32, ActiveColor, ActiveColorSmooth, 16);
tftPrint(ACENTER, "TP", 276, 32, ActiveColor, ActiveColorSmooth, 16);
@@ -756,7 +756,7 @@ void ShowAFEON() {
aid_counterold = radio.rds.aid_counter;
if (AIDStringTemp != AIDStringold) {
AIDString = String(textUI(33)) + " - " + String(textUI(79)) + ": " + AIDStringTemp + " ";
AIDString = String(textUI(32)) + " - " + String(textUI(78)) + ": " + AIDStringTemp + " ";
AIDWidth = FullLineSprite.textWidth(AIDString);
AIDStringold = AIDString;
}