Skip to content

Commit 3eeb06a

Browse files
committed
fixing WebRadio volume and cleanup.
1 parent 002be8e commit 3eeb06a

9 files changed

+46
-58
lines changed

examples/WebRadio/WebRadio.ino

+16-26
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ OneButton menuButton(A10, true);
106106
/// Setup a seek button
107107
OneButton seekButton(A11, true);
108108

109-
char rdsServiceName[10];
110-
char rdsText[64 + 2];
109+
char rdsServiceName[8 + 2]; ///< String with the actual RDS Service name. Some senders put rotating text in here too.
110+
char rdsText[64 + 2]; ///< String with the actual RDS text.
111+
char rdsTime[6]; ///< String with the actual time from RDS as hh:mm.
111112

112113
/// The radio object has to be defined by using the class corresponding to the used chip.
113114
/// by uncommenting the right (one only) radio object definition.
@@ -670,10 +671,8 @@ void loopWebServer(unsigned long now) {
670671
} else if (webstate == PROCESS_POST) {
671672
// get data posted by a html form
672673

673-
// DEBUGVAR("uri", _httpURI);
674674
int len;
675675
len = _client.read((uint8_t *)_readBuffer, BUFSIZ);
676-
// DEBUGVAR("len", len);
677676

678677
if ((len > 0) && (len < sizeof(_readBuffer))) {
679678
_httpContentLen -= len;
@@ -777,7 +776,7 @@ void DisplayFrequency()
777776
/// and will be stored for the web interface.
778777
void DisplayServiceName(char *name)
779778
{
780-
Serial.print("RDS:"); Serial.println(name);
779+
DEBUGVAR("RDS", name);
781780
strncpy(rdsServiceName, name, sizeof(rdsServiceName));
782781

783782
if (rot_state == STATE_FREQ) {
@@ -792,20 +791,21 @@ void DisplayServiceName(char *name)
792791
/// and will be stored for the web interface.
793792
void DisplayText(char *text)
794793
{
795-
Serial.print("TEXT:"); Serial.println(text);
794+
DEBUGVAR("RDS-text", text);
796795
strncpy(rdsText, text, sizeof(rdsText));
797796
} // DisplayText()
798797

799798

800799
/// This function will be called by the RDS module when a rds time message was received.
801800
/// The time will not displayed on the LCD but written to the serial port.
802801
void DisplayTime(uint8_t hour, uint8_t minute) {
803-
Serial.print("RDS-Time:");
804-
if (hour < 10) Serial.print('0');
805-
Serial.print(hour);
806-
Serial.print(':');
807-
if (minute < 10) Serial.print('0');
808-
Serial.println(minute);
802+
rdsTime[0] = '0' + (hour / 10);
803+
rdsTime[1] = '0' + (hour % 10);
804+
rdsTime[2] = ':';
805+
rdsTime[3] = '0' + (minute / 10);
806+
rdsTime[4] = '0' + (minute % 10);
807+
rdsTime[5] = NUL;
808+
DEBUGVAR("RDS-time", rdsTime);
809809
} // DisplayTime()
810810

811811

@@ -833,7 +833,7 @@ void DisplayMono(uint8_t v)
833833
/// Display the current soft mute switch.
834834
void DisplaySoftMute(uint8_t v)
835835
{
836-
Serial.print("SMUTE: "); Serial.println(v);
836+
DEBUGFUNC1("DisplaySoftMute", v);
837837
lcd.setCursor(0, 1);
838838
lcd.print("SMUTE: "); lcd.print(v);
839839
} // DisplaySoftMute()
@@ -1087,7 +1087,6 @@ void loopSerial(unsigned long now) {
10871087
void runRadioSerialCommand(char cmd, int16_t value)
10881088
{
10891089
if (cmd == '?') {
1090-
Serial.println();
10911090
Serial.println("? Help");
10921091
Serial.println("fnnnnn: direct frequency input (n: freq*100)");
10931092
Serial.println("vnn: direct volume input (n: 0...15)");
@@ -1102,7 +1101,7 @@ void runRadioSerialCommand(char cmd, int16_t value)
11021101
Serial.println("b bass boost");
11031102
Serial.println("m mute/unmute");
11041103
Serial.println("u soft mute/unmute");
1105-
}
1104+
} // runRadioSerialCommand()
11061105

11071106
// ----- control the volume and audio output -----
11081107

@@ -1151,22 +1150,14 @@ void runRadioSerialCommand(char cmd, int16_t value)
11511150
} else if (cmd == 'i') {
11521151
char s[12];
11531152
radio.formatFrequency(s, sizeof(s));
1154-
Serial.print("Station:"); Serial.println(s);
1153+
DEBUGVAR("Station", s);
11551154
Serial.print("Radio:"); radio.debugRadioInfo();
11561155
Serial.print("Audio:"); radio.debugAudioInfo();
11571156

11581157
RADIO_INFO ri;
11591158
radio.getRadioInfo(&ri);
1160-
1161-
1162-
// Serial.print(" RSSI: ");
1163-
// Serial.print(info.rssi);
1164-
//
1165-
// for (uint8_t i = 0; i < info.rssi - 15; i+=2) { Serial.write('*'); } // Empfangspegel ab 15. Zeichen
1166-
// Serial.println();
1167-
delay(3000);
1168-
11691159
} // info
1160+
11701161
// else if (cmd == 'n') { radio.debugScan(); }
11711162
else if (cmd == 'x') { radio.debugStatus(); }
11721163

@@ -1187,7 +1178,6 @@ void loopButtons(unsigned long now) {
11871178
// check for the rotary encoder
11881179
newPos = encoder.getPosition();
11891180
if (newPos != encoderLastPos) {
1190-
Serial.println("B1");
11911181
if (rot_state == STATE_FREQ) {
11921182
RADIO_FREQ f = radio.getMinFrequency() + (newPos * radio.getFrequencyStep());
11931183
radio.setFrequency(f);

library.properties

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=Radio
2-
version=0.6
2+
version=1.0.0
33
author=Matthias Hertel
4-
maintainer=Matthias Hertel <www.mathertel.de>
5-
sentence=Controlling FM radio receiving chips.
6-
paragraph=This is a library to implement a FM Radio receiver using one of the following chips: TEA5767, RDA5807M, SI4703, SI4705.
4+
maintainer=Matthias Hertel, <www.mathertel.de>
5+
sentence=Library for controlling FM radio receiver chips.
6+
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.
77
category=Communication
8-
url=http://www.mathertel.de/Arduino/
8+
url=http://www.mathertel.de/Arduino/RadioLibrary.aspx
99
architectures=*

src/RDA5807M.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
/// Library to control the RDA5807M radio chip.
3939
class RDA5807M : public RADIO {
4040
public:
41-
// ----- RDA5807M specific implementations -----
41+
// ----- RDA5807M specific implementations -----
42+
const uint8_t MAXVOLUME = 15; ///< max volume level for radio implementations.
43+
4244
RDA5807M();
4345

4446
bool init();

src/RDSParser.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
///
1414
/// ChangeLog see RDSParser.h.
1515

16-
17-
1816
#include "RDSParser.h"
1917

2018
#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
160158
mins += 30 * (off & 0x1F);
161159
}
162160

163-
Serial.print(" >>"); Serial.print(mins / 60); Serial.print(':'); Serial.println(mins % 60);
164-
165161
if ((_sendTime) && (mins != _lastRDSMinutes)) {
166162
_lastRDSMinutes = mins;
167163
_sendTime(mins / 60, mins % 60);

src/SI4703.h

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
/// Library to control the SI4703 radio chip.
3131
class SI4703 : public RADIO {
3232
public:
33+
const uint8_t MAXVOLUME = 15; ///< max volume level for radio implementations.
34+
3335
SI4703();
3436

3537
bool init(); // initialize library and the chip.

src/SI4705.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
/// There is a special mute implementation.
3030
#define ELVRADIO
3131

32-
3332
// ----- Radio chip specific definitions including the registers
3433

3534
// Commands and Parameter definitions
@@ -123,6 +122,7 @@
123122

124123
/// Initialize the extra variables in SI4705
125124
SI4705::SI4705() {
125+
_realVolume = 0;
126126
}
127127

128128
/// Initialize the library and the chip.

src/SI4705.h

+15-19
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,34 @@
3737
/// Library to control the SI4705 radio chip.
3838
class SI4705 : public RADIO {
3939
public:
40-
SI4705();
40+
const uint8_t MAXVOLUME = 15; ///< max volume level for radio implementations.
41+
const uint8_t MAXVOLUMEX = 63; ///< max volume level for the SI4705 specific implementation.
4142

42-
const uint8_t MAXVOLUMEX = 63; ///< max volume level for the SI4705 radio implementations.
43+
SI4705();
4344

4445
bool init(); ///< Initialize the library and the chip.
4546
void term(); ///< Terminate all radio functions in the chip.
4647

4748
// ----- Audio functions -----
4849

49-
void setVolume(uint8_t newVolume); ///< Control the volume output of the radio chip in the range 0..15.
50+
void setVolume(uint8_t newVolume); ///< Control the volume output of the radio chip in the range 0..15.
5051

51-
void setVolumeX(uint8_t newVolume); ///< Control the volume output of the radio chip in the range 0..63.
52-
uint8_t getVolumeX(); ///< Retrieve the current output volume in the range 0..63.
52+
void setVolumeX(uint8_t newVolume); ///< Control the volume output of the radio chip in the range 0..63.
53+
uint8_t getVolumeX(); ///< Retrieve the current output volume in the range 0..63.
5354

54-
void setMute(bool switchOn); ///< Control the mute mode of the radio chip.
55-
void setSoftMute(bool switchOn); ///< Control the softmute mode (mute on low signals) of the radio chip.
55+
void setMute(bool switchOn); ///< Control the mute mode of the radio chip.
56+
void setSoftMute(bool switchOn); ///< Control the softmute mode (mute on low signals) of the radio chip.
5657

5758
// Overwrite audio functions that are not supported.
58-
void setBassBoost(bool switchOn); ///< regardless of the given parameter, the Bass Boost will never switch on.
59+
void setBassBoost(bool switchOn); ///< regardless of the given parameter, the Bass Boost will never switch on.
5960

6061
// ----- Radio receiver functions -----
6162

62-
/// Control mono/stereo mode of the radio chip
63-
void setMono(bool switchOn); // Switch to mono mode.
64-
65-
/// Control the mute mode of the radio chip
66-
// Control of the core receiver
63+
void setMono(bool switchOn); ///< Control the mono/stereo mode of the radio chip.
6764

68-
// Control the frequency
69-
void setBand(RADIO_BAND newBand);
65+
void setBand(RADIO_BAND newBand); ///< Control the band of the radio chip.
7066

71-
void setFrequency(RADIO_FREQ newF);
67+
void setFrequency(RADIO_FREQ newF); ///< Control the frequency.
7268
RADIO_FREQ getFrequency(void);
7369

7470
void seekUp(bool toNextSender = true); // start seek mode upwards
@@ -93,9 +89,9 @@ class SI4705 : public RADIO {
9389
uint8_t _status; ///< the status after sending a command
9490

9591
uint8_t tuneStatus[8];
96-
uint8_t rsqStatus[1+7];
97-
uint8_t rdsStatusx[1+12];
98-
uint8_t agcStatus[1+2];
92+
uint8_t rsqStatus[1 + 7];
93+
uint8_t rdsStatusx[1 + 12];
94+
uint8_t agcStatus[1 + 2];
9995

10096
/// structure used to read RDS information from the SI4705 radio chip.
10197
union {

src/TEA5767.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
/// Library to control the TEA5767 radio chip.
3131
class TEA5767 : public RADIO {
3232
public:
33+
const uint8_t MAXVOLUME = 15; ///< max volume level for radio implementations.
3334
TEA5767();
3435

3536
bool init(); // initialize library and the chip.

src/newchip.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/// This work is licensed under a BSD style license.\n
88
/// See http://www.mathertel.de/License.aspx
99
///
10-
/// This library enables the use of the Radio Chip SI4703.
10+
/// This library can be used as a starting point to implement a new radio chip for the radio library.
1111
///
1212
/// More documentation and source code is available at http://www.mathertel.de/Arduino
1313
///
@@ -30,7 +30,8 @@
3030
/// Template library control a new radio chip.
3131
class newchip : public RADIO {
3232
public:
33-
newchip();
33+
const uint8_t MAXVOLUME = 15; ///< max volume level for radio implementations.
34+
newchip();
3435

3536
bool init(); // initialize library and the chip.
3637
void term(); // terminate all radio functions.

0 commit comments

Comments
 (0)