Skip to content

Commit

Permalink
Merge pull request #23 from Zakaria16/Zakaria16-fm-frequency
Browse files Browse the repository at this point in the history
fixes #22 setting and getting FM frequency
  • Loading branch information
erdemarslan authored Feb 13, 2020
2 parents 7a0168f + d1c7469 commit 8e29d0a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions GSMSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,21 +1055,21 @@ bool GSMSim::fmOpen(bool mainChannel) {
return false;
}
}
bool GSMSim::fmOpen(bool mainChannel, uint8_t freq) {
bool GSMSim::fmOpen(bool mainChannel, uint16_t freq) {
uint8_t channel = mainChannel == true ? 1 : 0;
uint8_t frekans = 875;

if (freq < 875) {
frekans = 875;
freq = 875;
}
if (freq > 1080) {
frekans = 1080;
freq = 1080;
}


this->print(F("AT+FMOPEN="));
this->print(channel);
this->print(",");
this->print(frekans);
this->print(freq);
this->print(F("\r"));

_buffer = _readSerial();
Expand Down Expand Up @@ -1109,7 +1109,7 @@ bool GSMSim::fmClose() {
}

// GET FM RADIO FREQ
uint8_t GSMSim::fmGetFreq() {
uint16_t GSMSim::fmGetFreq() {
this->print(F("AT+FMFREQ?\r"));
_buffer = _readSerial();

Expand All @@ -1124,16 +1124,16 @@ uint8_t GSMSim::fmGetFreq() {
}

// SET FM RADIO FREQ
bool GSMSim::fmSetFreq(uint8_t freq) {
bool GSMSim::fmSetFreq(uint16_t freq) {
this->print(F("AT+FMFREQ="));
uint8_t frekans = 875;

if (freq < 875) {
frekans = 875;
freq = 875;
}
if (freq > 1080) {
frekans = 1080;
freq = 1080;
}
this->print(frekans);
this->print(freq);
this->print(F("\r"));

_buffer = _readSerial();
Expand Down
6 changes: 3 additions & 3 deletions GSMSim.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ class GSMSim : public SoftwareSerial
// Radyo Kodları
bool fmOpen();
bool fmOpen(bool mainChannel);
bool fmOpen(bool mainChannel, uint8_t freq);
bool fmOpen(bool mainChannel, uint16_t freq);
bool fmIsOpened();
bool fmClose();
uint8_t fmGetFreq();
bool fmSetFreq(uint8_t freq);
uint16_t fmGetFreq();
bool fmSetFreq(uint16_t freq);
uint8_t fmGetVolume();
bool fmSetVolume(uint8_t volume);

Expand Down

0 comments on commit 8e29d0a

Please sign in to comment.