diff --git a/examples/WebRadio/WebRadio.ino b/examples/WebRadio/WebRadio.ino index 881e7fd..18adddd 100644 --- a/examples/WebRadio/WebRadio.ino +++ b/examples/WebRadio/WebRadio.ino @@ -106,8 +106,9 @@ OneButton menuButton(A10, true); /// Setup a seek button OneButton seekButton(A11, true); -char rdsServiceName[10]; -char rdsText[64 + 2]; +char rdsServiceName[8 + 2]; ///< String with the actual RDS Service name. Some senders put rotating text in here too. +char rdsText[64 + 2]; ///< String with the actual RDS text. +char rdsTime[6]; ///< String with the actual time from RDS as hh:mm. /// The radio object has to be defined by using the class corresponding to the used chip. /// by uncommenting the right (one only) radio object definition. @@ -670,10 +671,8 @@ void loopWebServer(unsigned long now) { } else if (webstate == PROCESS_POST) { // get data posted by a html form - // DEBUGVAR("uri", _httpURI); int len; len = _client.read((uint8_t *)_readBuffer, BUFSIZ); - // DEBUGVAR("len", len); if ((len > 0) && (len < sizeof(_readBuffer))) { _httpContentLen -= len; @@ -777,7 +776,7 @@ void DisplayFrequency() /// and will be stored for the web interface. void DisplayServiceName(char *name) { - Serial.print("RDS:"); Serial.println(name); + DEBUGVAR("RDS", name); strncpy(rdsServiceName, name, sizeof(rdsServiceName)); if (rot_state == STATE_FREQ) { @@ -792,7 +791,7 @@ void DisplayServiceName(char *name) /// and will be stored for the web interface. void DisplayText(char *text) { - Serial.print("TEXT:"); Serial.println(text); + DEBUGVAR("RDS-text", text); strncpy(rdsText, text, sizeof(rdsText)); } // DisplayText() @@ -800,12 +799,13 @@ void DisplayText(char *text) /// This function will be called by the RDS module when a rds time message was received. /// The time will not displayed on the LCD but written to the serial port. void DisplayTime(uint8_t hour, uint8_t minute) { - Serial.print("RDS-Time:"); - if (hour < 10) Serial.print('0'); - Serial.print(hour); - Serial.print(':'); - if (minute < 10) Serial.print('0'); - Serial.println(minute); + rdsTime[0] = '0' + (hour / 10); + rdsTime[1] = '0' + (hour % 10); + rdsTime[2] = ':'; + rdsTime[3] = '0' + (minute / 10); + rdsTime[4] = '0' + (minute % 10); + rdsTime[5] = NUL; + DEBUGVAR("RDS-time", rdsTime); } // DisplayTime() @@ -833,7 +833,7 @@ void DisplayMono(uint8_t v) /// Display the current soft mute switch. void DisplaySoftMute(uint8_t v) { - Serial.print("SMUTE: "); Serial.println(v); + DEBUGFUNC1("DisplaySoftMute", v); lcd.setCursor(0, 1); lcd.print("SMUTE: "); lcd.print(v); } // DisplaySoftMute() @@ -1087,7 +1087,6 @@ void loopSerial(unsigned long now) { void runRadioSerialCommand(char cmd, int16_t value) { if (cmd == '?') { - Serial.println(); Serial.println("? Help"); Serial.println("fnnnnn: direct frequency input (n: freq*100)"); Serial.println("vnn: direct volume input (n: 0...15)"); @@ -1102,7 +1101,7 @@ void runRadioSerialCommand(char cmd, int16_t value) Serial.println("b bass boost"); Serial.println("m mute/unmute"); Serial.println("u soft mute/unmute"); - } + } // runRadioSerialCommand() // ----- control the volume and audio output ----- @@ -1151,22 +1150,14 @@ void runRadioSerialCommand(char cmd, int16_t value) } else if (cmd == 'i') { char s[12]; radio.formatFrequency(s, sizeof(s)); - Serial.print("Station:"); Serial.println(s); + DEBUGVAR("Station", s); Serial.print("Radio:"); radio.debugRadioInfo(); Serial.print("Audio:"); radio.debugAudioInfo(); RADIO_INFO ri; radio.getRadioInfo(&ri); - - - // Serial.print(" RSSI: "); - // Serial.print(info.rssi); - // - // for (uint8_t i = 0; i < info.rssi - 15; i+=2) { Serial.write('*'); } // Empfangspegel ab 15. Zeichen - // Serial.println(); - delay(3000); - } // info + // else if (cmd == 'n') { radio.debugScan(); } else if (cmd == 'x') { radio.debugStatus(); } @@ -1187,7 +1178,6 @@ void loopButtons(unsigned long now) { // check for the rotary encoder newPos = encoder.getPosition(); if (newPos != encoderLastPos) { - Serial.println("B1"); if (rot_state == STATE_FREQ) { RADIO_FREQ f = radio.getMinFrequency() + (newPos * radio.getFrequencyStep()); radio.setFrequency(f); diff --git a/library.properties b/library.properties index 37e50dd..51b12bd 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=Radio -version=0.6 +version=1.0.0 author=Matthias Hertel -maintainer=Matthias Hertel -sentence=Controlling FM radio receiving chips. -paragraph=This is a library to implement a FM Radio receiver using one of the following chips: TEA5767, RDA5807M, SI4703, SI4705. +maintainer=Matthias Hertel, +sentence=Library for controlling FM radio receiver chips. +paragraph=This library implements the functions to control the FM radio receiver chips TEA5767, RDA5807M, SI4703, SI4705 to build a FM radio receiver. The library unifies the functions for all the chips so they may be swapped on demand. category=Communication -url=http://www.mathertel.de/Arduino/ +url=http://www.mathertel.de/Arduino/RadioLibrary.aspx architectures=* \ No newline at end of file diff --git a/src/RDA5807M.h b/src/RDA5807M.h index 1cdd868..0a98463 100644 --- a/src/RDA5807M.h +++ b/src/RDA5807M.h @@ -38,7 +38,9 @@ /// Library to control the RDA5807M radio chip. class RDA5807M : public RADIO { public: - // ----- RDA5807M specific implementations ----- + // ----- RDA5807M specific implementations ----- + const uint8_t MAXVOLUME = 15; ///< max volume level for radio implementations. + RDA5807M(); bool init(); diff --git a/src/RDSParser.cpp b/src/RDSParser.cpp index b9d307b..30cd688 100644 --- a/src/RDSParser.cpp +++ b/src/RDSParser.cpp @@ -13,8 +13,6 @@ /// /// ChangeLog see RDSParser.h. - - #include "RDSParser.h" #define DEBUG_FUNC0(fn) { Serial.print(fn); Serial.println("()"); } @@ -160,8 +158,6 @@ void RDSParser::processData(uint16_t block1, uint16_t block2, uint16_t block3, u mins += 30 * (off & 0x1F); } - Serial.print(" >>"); Serial.print(mins / 60); Serial.print(':'); Serial.println(mins % 60); - if ((_sendTime) && (mins != _lastRDSMinutes)) { _lastRDSMinutes = mins; _sendTime(mins / 60, mins % 60); diff --git a/src/SI4703.h b/src/SI4703.h index a715fa8..831c8ad 100644 --- a/src/SI4703.h +++ b/src/SI4703.h @@ -30,6 +30,8 @@ /// Library to control the SI4703 radio chip. class SI4703 : public RADIO { public: + const uint8_t MAXVOLUME = 15; ///< max volume level for radio implementations. + SI4703(); bool init(); // initialize library and the chip. diff --git a/src/SI4705.cpp b/src/SI4705.cpp index 8cb62ac..b157f55 100644 --- a/src/SI4705.cpp +++ b/src/SI4705.cpp @@ -29,7 +29,6 @@ /// There is a special mute implementation. #define ELVRADIO - // ----- Radio chip specific definitions including the registers // Commands and Parameter definitions @@ -123,6 +122,7 @@ /// Initialize the extra variables in SI4705 SI4705::SI4705() { + _realVolume = 0; } /// Initialize the library and the chip. diff --git a/src/SI4705.h b/src/SI4705.h index 5406c92..59962e7 100644 --- a/src/SI4705.h +++ b/src/SI4705.h @@ -37,38 +37,34 @@ /// Library to control the SI4705 radio chip. class SI4705 : public RADIO { public: - SI4705(); + const uint8_t MAXVOLUME = 15; ///< max volume level for radio implementations. + const uint8_t MAXVOLUMEX = 63; ///< max volume level for the SI4705 specific implementation. - const uint8_t MAXVOLUMEX = 63; ///< max volume level for the SI4705 radio implementations. + SI4705(); bool init(); ///< Initialize the library and the chip. void term(); ///< Terminate all radio functions in the chip. // ----- Audio functions ----- - void setVolume(uint8_t newVolume); ///< Control the volume output of the radio chip in the range 0..15. + void setVolume(uint8_t newVolume); ///< Control the volume output of the radio chip in the range 0..15. - void setVolumeX(uint8_t newVolume); ///< Control the volume output of the radio chip in the range 0..63. - uint8_t getVolumeX(); ///< Retrieve the current output volume in the range 0..63. + void setVolumeX(uint8_t newVolume); ///< Control the volume output of the radio chip in the range 0..63. + uint8_t getVolumeX(); ///< Retrieve the current output volume in the range 0..63. - void setMute(bool switchOn); ///< Control the mute mode of the radio chip. - void setSoftMute(bool switchOn); ///< Control the softmute mode (mute on low signals) of the radio chip. + void setMute(bool switchOn); ///< Control the mute mode of the radio chip. + void setSoftMute(bool switchOn); ///< Control the softmute mode (mute on low signals) of the radio chip. // Overwrite audio functions that are not supported. - void setBassBoost(bool switchOn); ///< regardless of the given parameter, the Bass Boost will never switch on. + void setBassBoost(bool switchOn); ///< regardless of the given parameter, the Bass Boost will never switch on. // ----- Radio receiver functions ----- - /// Control mono/stereo mode of the radio chip - void setMono(bool switchOn); // Switch to mono mode. - - /// Control the mute mode of the radio chip - // Control of the core receiver + void setMono(bool switchOn); ///< Control the mono/stereo mode of the radio chip. - // Control the frequency - void setBand(RADIO_BAND newBand); + void setBand(RADIO_BAND newBand); ///< Control the band of the radio chip. - void setFrequency(RADIO_FREQ newF); + void setFrequency(RADIO_FREQ newF); ///< Control the frequency. RADIO_FREQ getFrequency(void); void seekUp(bool toNextSender = true); // start seek mode upwards @@ -93,9 +89,9 @@ class SI4705 : public RADIO { uint8_t _status; ///< the status after sending a command uint8_t tuneStatus[8]; - uint8_t rsqStatus[1+7]; - uint8_t rdsStatusx[1+12]; - uint8_t agcStatus[1+2]; + uint8_t rsqStatus[1 + 7]; + uint8_t rdsStatusx[1 + 12]; + uint8_t agcStatus[1 + 2]; /// structure used to read RDS information from the SI4705 radio chip. union { diff --git a/src/TEA5767.h b/src/TEA5767.h index aee5ad3..f7d7633 100644 --- a/src/TEA5767.h +++ b/src/TEA5767.h @@ -30,6 +30,7 @@ /// Library to control the TEA5767 radio chip. class TEA5767 : public RADIO { public: + const uint8_t MAXVOLUME = 15; ///< max volume level for radio implementations. TEA5767(); bool init(); // initialize library and the chip. diff --git a/src/newchip.h b/src/newchip.h index bfd118a..84c1122 100644 --- a/src/newchip.h +++ b/src/newchip.h @@ -7,7 +7,7 @@ /// This work is licensed under a BSD style license.\n /// See http://www.mathertel.de/License.aspx /// -/// This library enables the use of the Radio Chip SI4703. +/// This library can be used as a starting point to implement a new radio chip for the radio library. /// /// More documentation and source code is available at http://www.mathertel.de/Arduino /// @@ -30,7 +30,8 @@ /// Template library control a new radio chip. class newchip : public RADIO { public: - newchip(); + const uint8_t MAXVOLUME = 15; ///< max volume level for radio implementations. + newchip(); bool init(); // initialize library and the chip. void term(); // terminate all radio functions.