Skip to content

Commit 954ec75

Browse files
authored
add rssi icon to footer
1 parent 86ce8f3 commit 954ec75

File tree

3 files changed

+51
-19
lines changed

3 files changed

+51
-19
lines changed

platformio.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ lib_deps =
3333

3434

3535
platform_packages =
36-
; platformio/tool-esptoolpy@~1.40200.0
3736
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1-RC1
38-
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.3
39-
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.4 ;
40-
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#master
37+
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.3
38+
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.4 ; run bootloader in dio mode
39+
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#master : newest release
4140

4241
board_upload.maximum_size = 3145728
4342
board_upload.flash_size = 4MB
43+
board_build.flash_mode = dio
4444

4545
;build_flags = -DCORE_DEBUG_LEVEL=0 ; None
4646
;build_flags = -DCORE_DEBUG_LEVEL=1 ; Error

src/common.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// created: 10.02.2022
2-
// updated: 04.07.2022
2+
// updated: 15.07.2022
33

44
#pragma once
55

66
#define _SSID "mySSID" // Your WiFi credentials here
77
#define _PW "myWiFiPassword"
88
#define TZName "CET-1CEST,M3.5.0,M10.5.0/3" // Timezone (more TZNames in "rtime.cpp")
99
#define DECODER 1 // (0)VS1053 , (1)MAX98357A PCM5102A... (2)AC101 (3)ES8388 (4)WM8978
10-
#define TFT_CONTROLLER 4 // (0)ILI9341, (1)HX8347D, (2)ILI9486a, (3)ILI9486b, (4)ILI9488
10+
#define TFT_CONTROLLER 3 // (0)ILI9341, (1)HX8347D, (2)ILI9486a, (3)ILI9486b, (4)ILI9488
1111
#define DISPLAY_INVERSION 0 // (0) off (1) on
1212
#define TFT_FREQUENCY 40000000 // 27000000, 40000000, 80000000
1313
#define TFT_ROTATION 3 // 1 or 3 (landscape)
14-
#define TP_VERSION 4 // (0)ILI9341, (1)ILI9341RPI, (2)HX8347D, (3)ILI9486, (4)ILI9488
14+
#define TP_VERSION 3 // (0)ILI9341, (1)ILI9341RPI, (2)HX8347D, (3)ILI9486, (4)ILI9488
1515
#define TP_ROTATION 3 // 1 or 3 (landscape)
1616
#define AUDIOTASK_CORE 1 // 0 or 1
1717
#define AUDIOTASK_PRIO 2 // 0 ... 24 Priority of the Task (0...configMAX_PRIORITIES -1)
@@ -143,6 +143,7 @@ void showHeadlineTime();
143143
void showHeadlineItem(uint8_t idx);
144144
void showFooterIPaddr();
145145
void showFooterStaNr();
146+
void showFooterRSSI();
146147
void updateSleepTime(boolean noDecrement = false);
147148
void showVolumeBar();
148149
void showBrightnessBar();

src/main.cpp

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MiniWebRadio -- Webradio receiver for ESP32
33
44
first release on 03/2017
5-
Version 2.3c, Jul 04/2022
5+
Version 2.4, Jul 15/2022
66
77
2.8" color display (320x240px) with controller ILI9341 or HX8347D (SPI) or
88
3.5" color display (480x320px) wiht controller ILI9486 or ILI9488 (SPI)
@@ -165,7 +165,9 @@ SemaphoreHandle_t mutex_display;
165165
struct w_v {uint16_t x = 180; uint16_t y = 0; uint16_t w = 50; uint16_t h = 20; } const _winVolume;
166166
struct w_m {uint16_t x = 260; uint16_t y = 0; uint16_t w = 60; uint16_t h = 20; } const _winTime;
167167
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;
169171
struct w_a {uint16_t x = 180; uint16_t y = 220; uint16_t w = 160; uint16_t h = 20; } const _winIPaddr;
170172
struct w_b {uint16_t x = 0; uint16_t y = 120; uint16_t w = 320; uint16_t h = 14; } const _winVolBar;
171173
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;
222224
struct w_m {uint16_t x = 390; uint16_t y = 0; uint16_t w = 90; uint16_t h = 30; } const _winTime;
223225
struct w_i {uint16_t x = 0; uint16_t y = 0; uint16_t w = 280; uint16_t h = 30; } const _winItem;
224226
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;
225231
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;
228232
struct w_b {uint16_t x = 0; uint16_t y = 160; uint16_t w = 480; uint16_t h = 30; } const _winVolBar;
229233
struct w_o {uint16_t x = 0; uint16_t y = 190; uint16_t w = 96; uint16_t h = 96; } const _winButton;
230234
uint16_t _alarmdaysXPos[7] = {2, 70, 138, 206, 274, 342, 410};
@@ -511,6 +515,33 @@ void showFooterStaNr(){
511515
tft.printf("%03d", _cur_station);
512516
xSemaphoreGive(mutex_display);
513517
}
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+
}
514545
void updateSleepTime(boolean noDecrement){ // decrement and show new value in footer
515546
if(_f_sleeping) return;
516547
xSemaphoreTake(mutex_display, portMAX_DELAY);
@@ -519,12 +550,12 @@ void updateSleepTime(boolean noDecrement){ // decrement and show new value in f
519550
if(_sleeptime > 0 && !noDecrement) _sleeptime--;
520551
if(_state != ALARM){
521552
char Slt[15];
522-
sprintf(Slt,"S %d:%02d", _sleeptime / 60, _sleeptime % 60);
553+
sprintf(Slt,"S %d:%02d", _sleeptime / 60, _sleeptime % 60);
523554
tft.setFont(_fonts[1]);
524555
if(!_sleeptime) tft.setTextColor(TFT_DEEPSKYBLUE);
525556
else tft.setTextColor(TFT_RED);
526557
clearSleep();
527-
tft.setCursor(_winSleep.x + 25 , _winSleep.y + 2);
558+
tft.setCursor(_winSleep.x + 12 , _winSleep.y + 2);
528559
tft.print(Slt);
529560
}
530561
if(sleep){ // fall asleep
@@ -555,6 +586,8 @@ void showFooter(){ // stationnumber, sleeptime, IPaddress
555586
showFooterStaNr();
556587
updateSleepTime();
557588
showFooterIPaddr();
589+
showFooterRSSI();
590+
showFooterUnusedArea();
558591
}
559592
void display_info(const char *str, int xPos, int yPos, uint16_t color, uint16_t indent, uint16_t winHeight){
560593
tft.fillRect(xPos, yPos, tft.width() - xPos, winHeight, TFT_BLACK); // Clear the space for new info
@@ -1503,12 +1536,11 @@ void changeState(int state){
15031536
else if(_state == PLAYER || _state == PLAYERico){
15041537
setStation(_cur_station);
15051538
showLogoAndStationName();
1506-
//showStreamTitle(_streamTitle);
15071539
_f_newStreamTitle = true;
15081540
}
15091541
else if(_state == CLOCKico){
15101542
showLogoAndStationName();
1511-
//showStreamTitle(_streamTitle);
1543+
_timeCounter = 0;
15121544
_f_newStreamTitle = true;
15131545
}
15141546
else if(_state == SLEEP){
@@ -1521,7 +1553,7 @@ void changeState(int state){
15211553
}
15221554
else{
15231555
showLogoAndStationName();
1524-
showStreamTitle(_streamTitle);
1556+
_f_newStreamTitle = true;
15251557
}
15261558
break;
15271559
}
@@ -1558,7 +1590,7 @@ void changeState(int state){
15581590
pref.putUInt("alarm_time", _alarmtime);
15591591
pref.putUShort("alarm_weekday", _alarmdays);
15601592
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));
15621594
clearHeader();
15631595
}
15641596
_state = CLOCK;
@@ -1704,7 +1736,7 @@ void loop() {
17041736

17051737
if(_f_1sec){
17061738
_f_1sec = false;
1707-
if(_state != ALARM && !_f_sleeping) showHeadlineTime();
1739+
if(_state != ALARM && !_f_sleeping) {showHeadlineTime(); showFooterRSSI();}
17081740
if(_state == CLOCK || _state == CLOCKico) display_time();
17091741

17101742
if(_timeCounter){
@@ -1724,7 +1756,6 @@ void loop() {
17241756
time_s = rtc.gettime_s();
17251757
xSemaphoreGive(mutex_rtc);
17261758
if(_f_eof && (_state == RADIO || _f_eof_alarm)){
1727-
log_e("0");
17281759
_f_eof = false;
17291760
if(_f_eof_alarm){
17301761
_f_eof_alarm = false;

0 commit comments

Comments
 (0)