let HSTone be generated by HamShield itself

This commit is contained in:
Morgan Redfield 2019-04-28 11:41:29 -07:00
parent 1d0eb281e2
commit 12fd074aed
5 changed files with 21 additions and 24 deletions

View File

@ -74,6 +74,7 @@ void loop() {
//Serial.println(messagebuff); //Serial.println(messagebuff);
prepMessage(); prepMessage();
msgptr = 0; msgptr = 0;
messagebuff = "";
Serial.print("!!"); Serial.print("!!");
} }
else { else {
@ -140,7 +141,6 @@ void prepMessage() {
} }
Serial.println("Done sending"); Serial.println("Done sending");
radio.setModeReceive(); radio.setModeReceive();
messagebuff = "";
} }

View File

@ -1062,6 +1062,24 @@ void HamShield::setDTMFCode(uint16_t code){
} }
// Tone Transmission
void HamShield::HStone(uint8_t pin, unsigned int frequency) {
HSwriteBitsW(devAddr, 0x79, 15, 2, 0x3); // transmit single tone (not dtmf)
HSwriteBitsW(devAddr, A1846S_DTMF_ENABLE_REG, 15, 2, 0x1); // transmit single tone (not dtmf)
// bypass pre/de-emphasis
HSwriteBitsW(devAddr, A1846S_FILTER_REG, A1846S_EMPH_FILTER_EN, 1, 1);
HSwriteWord(devAddr, A1846S_TONE1_FREQ, frequency*10);
setTxSourceTone1();
}
void HamShield::HSnoTone(uint8_t pin) {
HSwriteBitsW(devAddr, A1846S_DTMF_ENABLE_REG, 15, 2, 0x0); // disable tone and dtmf
setTxSourceMic();
}
// Tone detection // Tone detection
void HamShield::lookForTone(uint16_t t_hz) { void HamShield::lookForTone(uint16_t t_hz) {
float tone_hz = (float) t_hz; float tone_hz = (float) t_hz;

View File

@ -398,6 +398,8 @@ class HamShield {
void setDTMFCode(uint16_t code); void setDTMFCode(uint16_t code);
// Tone // Tone
void HStone(uint8_t pin, unsigned int frequency);
void HSnoTone(uint8_t pin);
void lookForTone(uint16_t tone_hz); void lookForTone(uint16_t tone_hz);
uint8_t toneDetected(); uint8_t toneDetected();

View File

@ -145,23 +145,3 @@ void HSdelay(unsigned long ms) {
void HSdelayMicroseconds(unsigned int us) { void HSdelayMicroseconds(unsigned int us) {
delayMicroseconds(us); delayMicroseconds(us);
} }
void HStone(uint8_t pin, unsigned int frequency) {
#if defined(ARDUINO_ARCH_NRF52)
//TODO
#elif defined(ARDUINO)
tone(pin, frequency);
#else
softToneCreate(pin);
softToneWrite(pin, frequency);
#endif
}
void HSnoTone(uint8_t pin) {
#if defined(ARDUINO_ARCH_NRF52)
//TODO
#elif defined(ARDUINO)
noTone(pin);
#else
softToneWrite(pin, 0);
#endif
}

View File

@ -41,8 +41,5 @@ unsigned long HSmillis();
void HSdelay(unsigned long ms); void HSdelay(unsigned long ms);
void HSdelayMicroseconds(unsigned int us); void HSdelayMicroseconds(unsigned int us);
void HStone(uint8_t pin, unsigned int frequency);
void HSnoTone(uint8_t pin);
#endif /* _HAMSHIELD_COMMS_H_ */ #endif /* _HAMSHIELD_COMMS_H_ */