Skip to content

Commit 90279c6

Browse files
authored
#64: Add data rate adjusting support (#67)
Aligned to the `Edzelf/Esp-radio` parent project. Added the `adjustRate` method, which was probably missing at the forking time.
1 parent 1c02f52 commit 90279c6

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/VS1053.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,17 @@ void VS1053::clearDecodedTime() {
350350
write_register(SCI_DECODE_TIME, 0x00);
351351
write_register(SCI_DECODE_TIME, 0x00);
352352
}
353+
354+
/**
355+
* Fine tune the data rate
356+
*/
357+
void VS1053::adjustRate(long ppm2) {
358+
write_register(SCI_WRAMADDR, 0x1e07);
359+
write_register(SCI_WRAM, ppm2);
360+
write_register(SCI_WRAM, ppm2 >> 16);
361+
// oldClock4KHz = 0 forces adjustment calculation when rate checked.
362+
write_register(SCI_WRAMADDR, 0x5b1c);
363+
write_register(SCI_WRAM, 0);
364+
// Write to AUDATA or CLOCKF checks rate and recalculates adjustment.
365+
write_register(SCI_AUDATA, read_register(SCI_AUDATA));
366+
}

src/VS1053.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ class VS1053 {
152152
return (digitalRead(dreq_pin) == HIGH);
153153
}
154154

155+
// Fine tune the data rate
156+
void adjustRate(long ppm2);
157+
155158
// An optional switch preventing the module starting up in MIDI mode
156159
void switchToMp3Mode();
157160

@@ -164,8 +167,9 @@ class VS1053 {
164167
// Clears SCI_DECODE_TIME register (sets 0x00)
165168
void clearDecodedTime();
166169

170+
// A low level method for a direct data register manipulation.
167171
// Made public to enable loading firmware patches in user code
168-
void write_register(uint8_t _reg, uint16_t _value) const;
172+
void write_register(uint8_t _reg, uint16_t _value) const;
169173
};
170174

171175
#endif

0 commit comments

Comments
 (0)