Skip to content

Commit 14c5178

Browse files
committed
psram for sprites is now optional (default enabled)
1 parent 8a12d29 commit 14c5178

File tree

4 files changed

+6
-39
lines changed

4 files changed

+6
-39
lines changed

src/utility/CommUtil.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -151,37 +151,3 @@ void CommUtil::scanID(bool *result) {
151151
*(result+i)=writeCommand(i,0x00);
152152
}
153153
}
154-
155-
// I2C Scanner, scavengered from https://github.com/MartyMacGyver/Arduino_I2C_Scanner
156-
void CommUtil::scan() {
157-
Serial.println();
158-
Serial.println("Scanning I2C Bus: ");
159-
Serial.println();
160-
Serial.print(" ");
161-
for (int i = 0; i < 0x10; i++) {
162-
Serial.printf(" %2x", i);
163-
}
164-
Serial.println();
165-
Serial.print(" ");
166-
for(uint8_t addr = 0x03; addr <= 0x77; addr++ ) {
167-
// Address the device
168-
Wire.beginTransmission(addr);
169-
// Check for ACK (detection of device), NACK or error
170-
uint8_t deviceStatus = Wire.endTransmission();
171-
172-
if (!(addr % 0x10)) { // Start of a line
173-
Serial.printf("%02x:", addr / 0x10);
174-
}
175-
if (deviceStatus == 0) {
176-
Serial.printf(" %02x", addr);
177-
} else if (deviceStatus == 4) {
178-
Serial.printf(" %02s", "??");
179-
} else {
180-
Serial.printf(" %02s", "--");
181-
}
182-
if (!((addr+1) % 0x10) ) {
183-
Serial.println();
184-
}
185-
}
186-
Serial.println();
187-
}

src/utility/CommUtil.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class CommUtil {
2222
bool readBytes(uint8_t address, uint8_t count,uint8_t * dest);
2323
bool readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t * dest);
2424
void scanID(bool *result);
25-
void scan();
2625
private:
2726
};
2827
#endif

src/utility/Sprite.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void* TFT_eSprite::callocSprite(int16_t w, int16_t h, uint8_t frames)
107107
{
108108

109109
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
110-
if ( psramFound() ) ptr8 = ( uint8_t*) ps_calloc(w * h + 1, sizeof(uint16_t));
110+
if ( psramFound() && _usePsram ) ptr8 = ( uint8_t*) ps_calloc(w * h + 1, sizeof(uint16_t));
111111
else
112112
#endif
113113
ptr8 = ( uint8_t*) calloc(w * h + 1, sizeof(uint16_t));
@@ -116,7 +116,7 @@ void* TFT_eSprite::callocSprite(int16_t w, int16_t h, uint8_t frames)
116116
else if (_bpp == 8)
117117
{
118118
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
119-
if ( psramFound() ) ptr8 = ( uint8_t*) ps_calloc(w * h + 1, sizeof(uint8_t));
119+
if ( psramFound() && _usePsram ) ptr8 = ( uint8_t*) ps_calloc(w * h + 1, sizeof(uint8_t));
120120
else
121121
#endif
122122
ptr8 = ( uint8_t*) calloc(w * h + 1, sizeof(uint8_t));
@@ -135,7 +135,7 @@ void* TFT_eSprite::callocSprite(int16_t w, int16_t h, uint8_t frames)
135135
if (frames > 2) frames = 2; // Currently restricted to 2 frame buffers
136136
if (frames < 1) frames = 1;
137137
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
138-
if ( psramFound() ) ptr8 = ( uint8_t*) ps_calloc(frames * (w>>3) * h + frames, sizeof(uint8_t));
138+
if ( psramFound() && _usePsram ) ptr8 = ( uint8_t*) ps_calloc(frames * (w>>3) * h + frames, sizeof(uint8_t));
139139
else
140140
#endif
141141
ptr8 = ( uint8_t*) calloc(frames * (w>>3) * h + frames, sizeof(uint8_t));

src/utility/Sprite.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class TFT_eSprite : public TFT_eSPI {
109109
void printToSprite(String string);
110110
void printToSprite(char *cbuffer, uint16_t len);
111111
int16_t printToSprite(int16_t x, int16_t y, uint16_t index);
112+
void setPsram( bool enabled );
112113

113114
private:
114115

@@ -129,7 +130,8 @@ class TFT_eSprite : public TFT_eSPI {
129130
int16_t _ypivot; // y pivot point coordinate
130131

131132
bool _created; // A Sprite has been created and memory reserved
132-
bool _gFont = false;
133+
bool _gFont = false;
134+
bool _usePsram = true; // use Psram if available
133135

134136
// int32_t _icursor_x, _icursor_y;
135137
uint8_t _rotation = 0;

0 commit comments

Comments
 (0)