2
2
MiniWebRadio -- Webradio receiver for ESP32
3
3
4
4
first release on 03/2017
5
- Version 2.3c , Jul 04 /2022
5
+ Version 2.4 , Jul 15 /2022
6
6
7
7
2.8" color display (320x240px) with controller ILI9341 or HX8347D (SPI) or
8
8
3.5" color display (480x320px) wiht controller ILI9486 or ILI9488 (SPI)
@@ -165,7 +165,9 @@ SemaphoreHandle_t mutex_display;
165
165
struct w_v {uint16_t x = 180 ; uint16_t y = 0 ; uint16_t w = 50 ; uint16_t h = 20 ; } const _winVolume;
166
166
struct w_m {uint16_t x = 260 ; uint16_t y = 0 ; uint16_t w = 60 ; uint16_t h = 20 ; } const _winTime;
167
167
struct w_s {uint16_t x = 0 ; uint16_t y = 220 ; uint16_t w = 60 ; uint16_t h = 20 ; } const _winStaNr;
168
- struct w_p {uint16_t x = 60 ; uint16_t y = 220 ; uint16_t w = 120 ; uint16_t h = 20 ; } const _winSleep;
168
+ struct w_p {uint16_t x = 60 ; uint16_t y = 220 ; uint16_t w = 60 ; uint16_t h = 20 ; } const _winSleep;
169
+ struct w_r {uint16_t x = 120 ; uint16_t y = 220 ; uint16_t w = 24 ; uint16_t h = 20 ; } const _winRSSID;
170
+ struct w_u {uint16_t x = 144 ; uint16_t y = 220 ; uint16_t w = 36 ; uint16_t h = 20 ; } const _winUnusedArea;
169
171
struct w_a {uint16_t x = 180 ; uint16_t y = 220 ; uint16_t w = 160 ; uint16_t h = 20 ; } const _winIPaddr;
170
172
struct w_b {uint16_t x = 0 ; uint16_t y = 120 ; uint16_t w = 320 ; uint16_t h = 14 ; } const _winVolBar;
171
173
struct w_o {uint16_t x = 0 ; uint16_t y = 154 ; uint16_t w = 64 ; uint16_t h = 64 ; } const _winButton;
@@ -222,9 +224,11 @@ SemaphoreHandle_t mutex_display;
222
224
struct w_m {uint16_t x = 390 ; uint16_t y = 0 ; uint16_t w = 90 ; uint16_t h = 30 ; } const _winTime;
223
225
struct w_i {uint16_t x = 0 ; uint16_t y = 0 ; uint16_t w = 280 ; uint16_t h = 30 ; } const _winItem;
224
226
struct w_v {uint16_t x = 280 ; uint16_t y = 0 ; uint16_t w = 110 ; uint16_t h = 30 ; } const _winVolume;
227
+ struct w_s {uint16_t x = 0 ; uint16_t y = 290 ; uint16_t w = 90 ; uint16_t h = 30 ; } const _winStaNr;
228
+ struct w_p {uint16_t x = 90 ; uint16_t y = 290 ; uint16_t w = 80 ; uint16_t h = 30 ; } const _winSleep;
229
+ struct w_r {uint16_t x = 170 ; uint16_t y = 290 ; uint16_t w = 32 ; uint16_t h = 30 ; } const _winRSSID;
230
+ struct w_u {uint16_t x = 202 ; uint16_t y = 290 ; uint16_t w = 58 ; uint16_t h = 30 ; } const _winUnusedArea;
225
231
struct w_a {uint16_t x = 260 ; uint16_t y = 290 ; uint16_t w = 220 ; uint16_t h = 30 ; } const _winIPaddr;
226
- struct w_s {uint16_t x = 0 ; uint16_t y = 290 ; uint16_t w = 100 ; uint16_t h = 30 ; } const _winStaNr;
227
- struct w_p {uint16_t x = 100 ; uint16_t y = 290 ; uint16_t w = 160 ; uint16_t h = 30 ; } const _winSleep;
228
232
struct w_b {uint16_t x = 0 ; uint16_t y = 160 ; uint16_t w = 480 ; uint16_t h = 30 ; } const _winVolBar;
229
233
struct w_o {uint16_t x = 0 ; uint16_t y = 190 ; uint16_t w = 96 ; uint16_t h = 96 ; } const _winButton;
230
234
uint16_t _alarmdaysXPos[7 ] = {2 , 70 , 138 , 206 , 274 , 342 , 410 };
@@ -511,6 +515,33 @@ void showFooterStaNr(){
511
515
tft.printf (" %03d" , _cur_station);
512
516
xSemaphoreGive (mutex_display);
513
517
}
518
+ void showFooterRSSI (){
519
+ static int old_rssi = -1 ;
520
+ int new_rssi = -1 ;
521
+ int rssi = WiFi.RSSI (); // Received Signal Strength Indicator
522
+ if (rssi < -1 ) new_rssi = 4 ;
523
+ if (rssi < -50 ) new_rssi = 3 ;
524
+ if (rssi < -65 ) new_rssi = 2 ;
525
+ if (rssi < -75 ) new_rssi = 1 ;
526
+ if (rssi < -85 ) new_rssi = 0 ;
527
+
528
+ if (new_rssi != old_rssi){
529
+ old_rssi = new_rssi; // no need to draw a rssi icon if rssiRange has not changed
530
+ if (ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO){
531
+ SerialPrintfln (" WiFI_info: RSSI is " ANSI_ESC_CYAN " %d" ANSI_ESC_WHITE " dB" , rssi);
532
+ }
533
+ switch (new_rssi){
534
+ case 4 : {drawImage (" /common/RSSI4.bmp" , _winRSSID.x , _winRSSID.y ); break ;}
535
+ case 3 : {drawImage (" /common/RSSI3.bmp" , _winRSSID.x , _winRSSID.y ); break ;}
536
+ case 2 : {drawImage (" /common/RSSI2.bmp" , _winRSSID.x , _winRSSID.y ); break ;}
537
+ case 1 : {drawImage (" /common/RSSI1.bmp" , _winRSSID.x , _winRSSID.y ); break ;}
538
+ case 0 : {drawImage (" /common/RSSI0.bmp" , _winRSSID.x , _winRSSID.y ); break ;}
539
+ }
540
+ }
541
+ }
542
+ void showFooterUnusedArea (){ // unused yet, so fill it black
543
+ tft.fillRect (_winUnusedArea.x , _winUnusedArea.y , _winUnusedArea.w , _winUnusedArea.h , TFT_BLACK);
544
+ }
514
545
void updateSleepTime (boolean noDecrement){ // decrement and show new value in footer
515
546
if (_f_sleeping) return ;
516
547
xSemaphoreTake (mutex_display, portMAX_DELAY);
@@ -519,12 +550,12 @@ void updateSleepTime(boolean noDecrement){ // decrement and show new value in f
519
550
if (_sleeptime > 0 && !noDecrement) _sleeptime--;
520
551
if (_state != ALARM){
521
552
char Slt[15 ];
522
- sprintf (Slt," S %d:%02d" , _sleeptime / 60 , _sleeptime % 60 );
553
+ sprintf (Slt," S %d:%02d" , _sleeptime / 60 , _sleeptime % 60 );
523
554
tft.setFont (_fonts[1 ]);
524
555
if (!_sleeptime) tft.setTextColor (TFT_DEEPSKYBLUE);
525
556
else tft.setTextColor (TFT_RED);
526
557
clearSleep ();
527
- tft.setCursor (_winSleep.x + 25 , _winSleep.y + 2 );
558
+ tft.setCursor (_winSleep.x + 12 , _winSleep.y + 2 );
528
559
tft.print (Slt);
529
560
}
530
561
if (sleep){ // fall asleep
@@ -555,6 +586,8 @@ void showFooter(){ // stationnumber, sleeptime, IPaddress
555
586
showFooterStaNr ();
556
587
updateSleepTime ();
557
588
showFooterIPaddr ();
589
+ showFooterRSSI ();
590
+ showFooterUnusedArea ();
558
591
}
559
592
void display_info (const char *str, int xPos, int yPos, uint16_t color, uint16_t indent, uint16_t winHeight){
560
593
tft.fillRect (xPos, yPos, tft.width () - xPos, winHeight, TFT_BLACK); // Clear the space for new info
@@ -1503,12 +1536,11 @@ void changeState(int state){
1503
1536
else if (_state == PLAYER || _state == PLAYERico){
1504
1537
setStation (_cur_station);
1505
1538
showLogoAndStationName ();
1506
- // showStreamTitle(_streamTitle);
1507
1539
_f_newStreamTitle = true ;
1508
1540
}
1509
1541
else if (_state == CLOCKico){
1510
1542
showLogoAndStationName ();
1511
- // showStreamTitle(_streamTitle) ;
1543
+ _timeCounter = 0 ;
1512
1544
_f_newStreamTitle = true ;
1513
1545
}
1514
1546
else if (_state == SLEEP){
@@ -1521,7 +1553,7 @@ void changeState(int state){
1521
1553
}
1522
1554
else {
1523
1555
showLogoAndStationName ();
1524
- showStreamTitle (_streamTitle) ;
1556
+ _f_newStreamTitle = true ;
1525
1557
}
1526
1558
break ;
1527
1559
}
@@ -1558,7 +1590,7 @@ void changeState(int state){
1558
1590
pref.putUInt (" alarm_time" , _alarmtime);
1559
1591
pref.putUShort (" alarm_weekday" , _alarmdays);
1560
1592
SerialPrintfln (" Alarm set to " ANSI_ESC_CYAN " %2d:%2d" ANSI_ESC_WHITE " on " ANSI_ESC_CYAN
1561
- " %s\n " , _alarmtime / 60 , _alarmtime % 60 , byte_to_binary (_alarmdays));
1593
+ " %s" , _alarmtime / 60 , _alarmtime % 60 , byte_to_binary (_alarmdays));
1562
1594
clearHeader ();
1563
1595
}
1564
1596
_state = CLOCK;
@@ -1704,7 +1736,7 @@ void loop() {
1704
1736
1705
1737
if (_f_1sec){
1706
1738
_f_1sec = false ;
1707
- if (_state != ALARM && !_f_sleeping) showHeadlineTime ();
1739
+ if (_state != ALARM && !_f_sleeping) { showHeadlineTime (); showFooterRSSI ();}
1708
1740
if (_state == CLOCK || _state == CLOCKico) display_time ();
1709
1741
1710
1742
if (_timeCounter){
@@ -1724,7 +1756,6 @@ void loop() {
1724
1756
time_s = rtc.gettime_s ();
1725
1757
xSemaphoreGive (mutex_rtc);
1726
1758
if (_f_eof && (_state == RADIO || _f_eof_alarm)){
1727
- log_e (" 0" );
1728
1759
_f_eof = false ;
1729
1760
if (_f_eof_alarm){
1730
1761
_f_eof_alarm = false ;
0 commit comments