This commit is contained in:
e2002
2022-06-28 14:53:55 +03:00
parent b7043b7d5c
commit 0d25b5fcd1
27 changed files with 246 additions and 14 deletions

View File

@@ -0,0 +1,16 @@
/**************************************************************
An example of volume control using an analog resistor.
This file must be in the root directory of the sketch.
**************************************************************/
const uint8_t volume_pin = 34;
void ctrls_on_loop() {
static uint32_t prevVolPinMillis;
uint16_t volPinVal = map(analogRead(volume_pin), 0, 4095, 0, 254);
if((abs(volPinVal-config.store.volume)>2) && (millis()-prevVolPinMillis>300)){ /* simple debounce */
player.setVol(volPinVal, false);
prevVolPinMillis=millis();
}
}

View File

@@ -0,0 +1,36 @@
/**************************************************************
Example of display backlight control depending on playback.
This file must be in the root directory of the sketch.
**************************************************************/
#include <Ticker.h>
const uint8_t backlightPin = 13;
const uint8_t backlightInitValue = HIGH;
const uint16_t turnBlOffInterval = 120; /* 2 min */
Ticker backlightTicker;
void backlightOff(){
backlightTicker.detach();
digitalWrite(backlightPin, !backlightInitValue);
}
void yoradio_on_setup() {
pinMode(backlightPin, OUTPUT);
digitalWrite(backlightPin, backlightInitValue);
backlightTicker.attach(turnBlOffInterval, backlightOff);
}
void player_on_track_change(){
digitalWrite(backlightPin, backlightInitValue);
backlightTicker.detach();
backlightTicker.attach(turnBlOffInterval, backlightOff);
}
void player_on_stop_play(){
digitalWrite(backlightPin, backlightInitValue);
backlightTicker.detach();
backlightTicker.attach(turnBlOffInterval, backlightOff);
}

View File

@@ -0,0 +1,34 @@
/**************************************************************
An example of replase a RSSI to bitrate information alternately.
This file must be in the root directory of the sketch.
**************************************************************/
#if DSP_MODEL==DSP_ILI9225 /* your DSP_MODEL */
bool dsp_before_rssi(DspCore *dsp){
static int8_t cnt;
int16_t x1, y1;
char buf[20]; /* buffer for the bitrate string */
uint16_t w, h; /* width & height of the bitrate string */
int16_t vTop = dsp->height() - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2; /* vTop - Y cordnate of the bitrate string */
sprintf(buf, "%d kBits", config.station.bitrate);
dsp->getTextBounds(buf, 0, 0, &x1, &y1, &w, &h);
dsp->setTextSize(1);
dsp->fillRect(dsp->width() - w - TFT_FRAMEWDT-40 /* left */, vTop /* top */, w+40 /* width */, TFT_LINEHGHT-4 /* height */, TFT_BG /* background color */);
if(cnt<2){
cnt++;
return true; /* print RSSI and retrn */
}
cnt++;
if(cnt>3) cnt=0;
dsp->setTextColor(SILVER,TFT_BG);
dsp->setCursor(dsp->width() - w - TFT_FRAMEWDT, vTop);
dsp->print(buf); /* print bitrate */
return false; /* disable to print RSSI */
}
#endif