[AFSK] Added begin method
This commit is contained in:
parent
1a2d66305d
commit
85ba05c1f8
3 changed files with 26 additions and 2 deletions
|
@ -46,7 +46,7 @@ void setup() {
|
||||||
int state = radio.beginFSK();
|
int state = radio.beginFSK();
|
||||||
|
|
||||||
// when using one of the non-LoRa modules for AFSK
|
// when using one of the non-LoRa modules for AFSK
|
||||||
// (RF69, CC1101,, Si4432 etc.), use the basic begin() method
|
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||||
// int state = radio.begin();
|
// int state = radio.begin();
|
||||||
|
|
||||||
if(state == ERR_NONE) {
|
if(state == ERR_NONE) {
|
||||||
|
@ -56,6 +56,17 @@ void setup() {
|
||||||
Serial.println(state);
|
Serial.println(state);
|
||||||
while(true);
|
while(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialize AFSK client
|
||||||
|
Serial.print(F("[AFSK] Initializing ... "));
|
||||||
|
state = audio.begin();
|
||||||
|
if(state == ERR_NONE) {
|
||||||
|
Serial.println(F("success!"));
|
||||||
|
} else {
|
||||||
|
Serial.print(F("failed, code "));
|
||||||
|
Serial.println(state);
|
||||||
|
while(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
@ -63,10 +74,12 @@ void loop() {
|
||||||
// same as Arduino tone() function
|
// same as Arduino tone() function
|
||||||
|
|
||||||
// 400 Hz tone
|
// 400 Hz tone
|
||||||
|
Serial.print(F("[AFSK] 400 Hz tone ... "));
|
||||||
audio.tone(400);
|
audio.tone(400);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
// silence
|
// silence
|
||||||
|
Serial.println(F("done!"));
|
||||||
audio.noTone();
|
audio.noTone();
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,10 @@ AFSKClient::AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin): _pin(pin) {
|
||||||
_phy = phy;
|
_phy = phy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t AFSKClient::begin() {
|
||||||
|
return(_phy->startDirect());
|
||||||
|
}
|
||||||
|
|
||||||
int16_t AFSKClient::tone(uint16_t freq, bool autoStart) {
|
int16_t AFSKClient::tone(uint16_t freq, bool autoStart) {
|
||||||
if(freq == 0) {
|
if(freq == 0) {
|
||||||
return(ERR_INVALID_FREQUENCY);
|
return(ERR_INVALID_FREQUENCY);
|
||||||
|
|
|
@ -25,6 +25,13 @@ class AFSKClient {
|
||||||
*/
|
*/
|
||||||
AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin);
|
AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Initialization method.
|
||||||
|
|
||||||
|
\returns \ref status_codes
|
||||||
|
*/
|
||||||
|
int16_t begin();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Start transmitting audio tone.
|
\brief Start transmitting audio tone.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue