[SSTV] Added Module overrides for all Arduino core functions

This commit is contained in:
jgromes 2020-08-01 16:36:31 +02:00
parent f15cc19577
commit 5eeba8fe51

View file

@ -205,7 +205,7 @@ int16_t SSTVClient::begin(float base, const SSTVMode_t& mode, float correction)
void SSTVClient::idle() { void SSTVClient::idle() {
_phy->transmitDirect(); _phy->transmitDirect();
tone(SSTV_TONE_LEADER); this->tone(SSTV_TONE_LEADER);
} }
void SSTVClient::sendHeader() { void SSTVClient::sendHeader() {
@ -214,35 +214,35 @@ void SSTVClient::sendHeader() {
_phy->transmitDirect(); _phy->transmitDirect();
// send the first part of header (leader-break-leader) // send the first part of header (leader-break-leader)
tone(SSTV_TONE_LEADER, SSTV_HEADER_LEADER_LENGTH); this->tone(SSTV_TONE_LEADER, SSTV_HEADER_LEADER_LENGTH);
tone(SSTV_TONE_BREAK, SSTV_HEADER_BREAK_LENGTH); this->tone(SSTV_TONE_BREAK, SSTV_HEADER_BREAK_LENGTH);
tone(SSTV_TONE_LEADER, SSTV_HEADER_LEADER_LENGTH); this->tone(SSTV_TONE_LEADER, SSTV_HEADER_LEADER_LENGTH);
// VIS start bit // VIS start bit
tone(SSTV_TONE_BREAK, SSTV_HEADER_BIT_LENGTH); this->tone(SSTV_TONE_BREAK, SSTV_HEADER_BIT_LENGTH);
// VIS code // VIS code
uint8_t parityCount = 0; uint8_t parityCount = 0;
for(uint8_t mask = 0x01; mask < 0x80; mask <<= 1) { for(uint8_t mask = 0x01; mask < 0x80; mask <<= 1) {
if(_mode.visCode & mask) { if(_mode.visCode & mask) {
tone(SSTV_TONE_VIS_1, SSTV_HEADER_BIT_LENGTH); this->tone(SSTV_TONE_VIS_1, SSTV_HEADER_BIT_LENGTH);
parityCount++; parityCount++;
} else { } else {
tone(SSTV_TONE_VIS_0, SSTV_HEADER_BIT_LENGTH); this->tone(SSTV_TONE_VIS_0, SSTV_HEADER_BIT_LENGTH);
} }
} }
// VIS parity // VIS parity
if(parityCount % 2 == 0) { if(parityCount % 2 == 0) {
// even parity // even parity
tone(SSTV_TONE_VIS_0, SSTV_HEADER_BIT_LENGTH); this->tone(SSTV_TONE_VIS_0, SSTV_HEADER_BIT_LENGTH);
} else { } else {
// odd parity // odd parity
tone(SSTV_TONE_VIS_1, SSTV_HEADER_BIT_LENGTH); this->tone(SSTV_TONE_VIS_1, SSTV_HEADER_BIT_LENGTH);
} }
// VIS stop bit // VIS stop bit
tone(SSTV_TONE_BREAK, SSTV_HEADER_BIT_LENGTH); this->tone(SSTV_TONE_BREAK, SSTV_HEADER_BIT_LENGTH);
} }
void SSTVClient::sendLine(uint32_t* imgLine) { void SSTVClient::sendLine(uint32_t* imgLine) {
@ -251,14 +251,14 @@ void SSTVClient::sendLine(uint32_t* imgLine) {
_firstLine = false; _firstLine = false;
// send start sync tone // send start sync tone
tone(SSTV_TONE_BREAK, 9000); this->tone(SSTV_TONE_BREAK, 9000);
} }
// send all tones in sequence // send all tones in sequence
for(uint8_t i = 0; i < _mode.numTones; i++) { for(uint8_t i = 0; i < _mode.numTones; i++) {
if((_mode.tones[i].type == tone_t::GENERIC) && (_mode.tones[i].len > 0)) { if((_mode.tones[i].type == tone_t::GENERIC) && (_mode.tones[i].len > 0)) {
// sync/porch tones // sync/porch tones
tone(_mode.tones[i].freq, _mode.tones[i].len); this->tone(_mode.tones[i].freq, _mode.tones[i].len);
} else { } else {
// scan lines // scan lines
for(uint16_t j = 0; j < _mode.width; j++) { for(uint16_t j = 0; j < _mode.width; j++) {
@ -278,7 +278,7 @@ void SSTVClient::sendLine(uint32_t* imgLine) {
case(tone_t::GENERIC): case(tone_t::GENERIC):
break; break;
} }
tone(SSTV_TONE_BRIGHTNESS_MIN + ((float)color * 3.1372549), _mode.scanPixelLen); this->tone(SSTV_TONE_BRIGHTNESS_MIN + ((float)color * 3.1372549), _mode.scanPixelLen);
} }
} }
} }
@ -289,7 +289,7 @@ uint16_t SSTVClient::getPictureHeight() const {
} }
void SSTVClient::tone(float freq, uint32_t len) { void SSTVClient::tone(float freq, uint32_t len) {
uint32_t start = micros(); uint32_t start = Module::micros();
#if !defined(RADIOLIB_EXCLUDE_AFSK) #if !defined(RADIOLIB_EXCLUDE_AFSK)
if(_audio != nullptr) { if(_audio != nullptr) {
_audio->tone(freq, false); _audio->tone(freq, false);
@ -299,8 +299,8 @@ void SSTVClient::tone(float freq, uint32_t len) {
#else #else
_phy->transmitDirect(_base + (freq / _phy->getFreqStep())); _phy->transmitDirect(_base + (freq / _phy->getFreqStep()));
#endif #endif
while(micros() - start < len) { while(Module::micros() - start < len) {
yield(); Module::yield();
} }
} }