Skip to content

Commit

Permalink
fixing WebRadio volume and cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathertel committed May 17, 2015
1 parent 002be8e commit 3eeb06a
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 58 deletions.
42 changes: 16 additions & 26 deletions examples/WebRadio/WebRadio.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -792,20 +791,21 @@ 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()


/// 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()


Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)");
Expand All @@ -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 -----

Expand Down Expand Up @@ -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(); }

Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=Radio
version=0.6
version=1.0.0
author=Matthias Hertel
maintainer=Matthias Hertel <www.mathertel.de>
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, <www.mathertel.de>
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=*
4 changes: 3 additions & 1 deletion src/RDA5807M.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 0 additions & 4 deletions src/RDSParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
///
/// ChangeLog see RDSParser.h.



#include "RDSParser.h"

#define DEBUG_FUNC0(fn) { Serial.print(fn); Serial.println("()"); }
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/SI4703.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/SI4705.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
/// There is a special mute implementation.
#define ELVRADIO


// ----- Radio chip specific definitions including the registers

// Commands and Parameter definitions
Expand Down Expand Up @@ -123,6 +122,7 @@

/// Initialize the extra variables in SI4705
SI4705::SI4705() {
_realVolume = 0;
}

/// Initialize the library and the chip.
Expand Down
34 changes: 15 additions & 19 deletions src/SI4705.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/TEA5767.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions src/newchip.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -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.
Expand Down

0 comments on commit 3eeb06a

Please sign in to comment.