This commit is contained in:
e2002
2022-10-14 11:00:49 +03:00
parent dbe0f32e14
commit 1c4b1dec6e
94 changed files with 5320 additions and 6613 deletions

View File

@@ -9,8 +9,10 @@ Uncomment the lines you need, to override the default value and set the values a
The connection tables are located here https://github.com/e2002/yoradio#connection-tables
********************************************************/
#define LED_BUILTIN 2 /* Onboard LED Pin */
#define L10N_LANGUAGE EN /* Language (EN, RU). More info in yoRadio/locale/displayL10n_(en|ru).h
/* DSP_MODEL. See description/available values in the options.h file */
/* DSP_MODEL. See description/available values in https://github.com/e2002/yoradio/wiki/Available-display-models */
/* This option is required. Use DSP_DUMMY if no display is connected */
#define DSP_MODEL DSP_DUMMY
/*
@@ -58,7 +60,7 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti
//#define ENC_BTNL 255 /* Left rotation */
//#define ENC_BTNB 255 /* Encoder button */
//#define ENC_BTNR 255 /* Right rotation */
//#define ENC_INTERNALPULLUP true /* Enable the weak pull up resistors */
//#define ENC_INTERNALPULLUP true /* Enabl//#define LED_BUILTIN 2 /* LED Pin */e the weak pull up resistors */
//#define ENC_HALFQUARD true /* Experiment with it */
/******************************************/
@@ -108,7 +110,6 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti
/* INITR_MINI160x80 // 0.96' 160x80 ST7735S https://???? */
/* INITR_GREENTAB */
/* INITR_REDTAB */
//#define LED_BUILTIN 2 /* LED Pin */
//#define MUTE_PIN 255 /* MUTE Pin */
//#define MUTE_VAL HIGH /* Write this to MUTE_PIN when player is stopped */
//#define BRIGHTNESS_PIN 255 /* Pin for adjusting the brightness of the display (output 0 - 3v3) */

View File

@@ -17,7 +17,9 @@
/* | color name | R G B | */
/*----------------------------------------------------------------------------------------------------------------*/
//#define COLOR_BACKGROUND 255, 255, 0 /* background */
//#define COLOR_STATION_NAME 91, 118, 255 /* station name */
//#define COLOR_STATION_NAME 0, 0, 0 /* station name */
//#define COLOR_STATION_BG 91, 118, 255 /* station name background */
//#define COLOR_STATION_FILL 231, 211, 90 /* station name fill background */
//#define COLOR_SNG_TITLE_1 255, 0, 0 /* first title */
//#define COLOR_SNG_TITLE_2 0, 0, 0 /* second title */
//#define COLOR_WEATHER 255, 0, 216 /* weather string */
@@ -36,6 +38,7 @@
//#define COLOR_VOLBAR_IN 189, 189, 189 /* volume bar fill */
//#define COLOR_DIGITS 100, 100, 255 /* volume / station number */
//#define COLOR_DIVIDER 0, 255, 0 /* divider color (DSP_ST7789, DSP_ILI9341, DSP_ILI9225) */
//#define COLOR_BITRATE 231, 211, 90 /* bitrate */
//#define COLOR_PLAYLIST_0 255, 0, 0 /* playlist string 0 */
//#define COLOR_PLAYLIST_1 0, 255, 0 /* playlist string 1 */
//#define COLOR_PLAYLIST_2 255, 0, 255 /* playlist string 2 */

View File

@@ -1,16 +0,0 @@
/**************************************************************
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

@@ -1,202 +0,0 @@
/**************************************************************
An example of displaying user information on the display.
This file must be in the root directory of the sketch.
**************************************************************/
#if (DSP_MODEL==DSP_ST7735) || (DSP_MODEL==DSP_ST7789) || (DSP_MODEL==DSP_SSD1327) || (DSP_MODEL==DSP_ILI9341) || (DSP_MODEL==DSP_ILI9225)
#define WEATHER_REQUEST_INTERVAL 1800 //30min
#define WEATHER_REQUEST_INTERVAL_FAULTY 30
#include <WiFiClient.h>
#include <Ticker.h>
const char* host = "api.openweathermap.org";
const char* lat = "55.7512";
const char* lon = "37.6184";
const char* key = "********************************";
Ticker ticker;
/***********************************************
scrolled line
***********************************************/
Scroll hello;
char weather[254] = { 0 };
bool weatherRequest = false;
TaskHandle_t weatherUpdateTaskHandle;
bool getForecast() {
WiFiClient client;
if (!client.connect(host, 80)) {
Serial.println("## OPENWEATHERMAP ###: connection failed");
return false;
}
char httpget[250] = {0};
sprintf(httpget, "GET /data/2.5/weather?lat=%s&lon=%s&units=metric&lang=ru&appid=%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", lat, lon, key, host);
client.print(httpget);
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 2000UL) {
Serial.println("## OPENWEATHERMAP ###: client available timeout !");
client.stop();
return false;
}
}
timeout = millis();
String line = "";
if (client.connected()) {
while (client.available())
{
line = client.readStringUntil('\n');
if (strstr(line.c_str(), "\"temp\"") != NULL) {
client.stop();
break;
}
if ((millis() - timeout) > 500)
{
client.stop();
Serial.println("## OPENWEATHERMAP ###: client read timeout !");
return false;
}
}
}
if (strstr(line.c_str(), "\"temp\"") == NULL) {
Serial.println("## OPENWEATHERMAP ###: weather not found !");
return false;
}
char *tmpe;
char *tmps;
const char* cursor = line.c_str();
char desc[120], temp[20], hum[20], press[20];
tmps = strstr(cursor, "\"description\":\"");
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: description not found !"); return false;}
tmps += 15;
tmpe = strstr(tmps, "\",\"");
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: description not found !"); return false;}
strlcpy(desc, tmps, tmpe - tmps + 1);
cursor = tmpe + 3;
tmps = strstr(cursor, "\"temp\":");
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: temp not found !"); return false;}
tmps += 7;
tmpe = strstr(tmps, ",\"");
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: temp not found !"); return false;}
strlcpy(temp, tmps, tmpe - tmps + 1);
cursor = tmpe + 2;
float tempf = atof(temp);
tmps = strstr(cursor, "\"pressure\":");
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;}
tmps += 11;
tmpe = strstr(tmps, ",\"");
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;}
strlcpy(press, tmps, tmpe - tmps + 1);
cursor = tmpe + 2;
int pressi = (float)atoi(press) / 1.333;
tmps = strstr(cursor, "humidity\":");
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: humidity not found !"); return false;}
tmps += 10;
tmpe = strstr(tmps, ",\"");
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: humidity not found !"); return false;}
strlcpy(hum, tmps, tmpe - tmps + 1);
Serial.printf("## OPENWEATHERMAP ###: description: %s, temp:%.1f C, pressure:%dmmHg, humidity:%s%%\n", desc, tempf, pressi, hum);
sprintf(weather, "%s, %.1f C * давление: %d мм * влажность: %s%%", desc, tempf, pressi, hum);
return true;
}
void getWeather( void * pvParameters ) {
delay(200);
if (getForecast()) {
weatherRequest = true;
ticker.detach();
ticker.attach(WEATHER_REQUEST_INTERVAL, updateWeather);
} else {
ticker.detach();
ticker.attach(WEATHER_REQUEST_INTERVAL_FAULTY, updateWeather);
}
vTaskDelete( NULL );
}
void updateWeather() {
xTaskCreatePinnedToCore(
getWeather, /* Task function. */
"getWeather1", /* name of task. */
1024 * 4, /* Stack size of task */
NULL, /* parameter of the task */
0, /* priority of the task */
&weatherUpdateTaskHandle, /* Task handle to keep track of created task */
0); /* pin task to core CORE_FOR_LOOP_CONTROLS */
}
/***********************************************
Occurs when the network is connected
***********************************************/
void network_on_connect() {
updateWeather();
}
/*********************************************************************************************
The display has initialized, the network is connected, the player is ready to play.
DspCore class documentation is missing :^( See the source in src/displays
*********************************************************************************************/
void dsp_on_start(DspCore *dsp) {
}
/***********************************************
Occurs when the display is initialized
***********************************************/
void dsp_on_init() {
if (DSP_MODEL == DSP_ST7735 || (DSP_MODEL == DSP_SSD1327)) {
hello.init(5, " * ", 1, TFT_LINEHGHT * 4 + 6, 0, config.theme.weather, config.theme.background);
}else if(DSP_MODEL == DSP_ILI9225){
hello.init(5, " * ", 1, TFT_LINEHGHT * 6 + 5, 0, config.theme.weather, config.theme.background);
} else {
hello.init(5, " * ", 2, TFT_LINEHGHT * 9 + 5, 0, config.theme.weather, config.theme.background);
}
}
/************************
The loop cycle
************************/
void dsp_on_loop(DspCore *dsp) {
if (weatherRequest) {
weatherRequest = false;
hello.setText(dsp->utf8Rus(weather, true));
}
if (display.mode == PLAYER) hello.loop();
}
/***********************************************
Occurs when the display changes mode
***********************************************/
void dsp_on_newmode(displayMode_e newmode) {
if (newmode == PLAYER) {
hello.reset();
} else {
hello.lock();
}
}
/************************
Before print the clock
************************/
bool dsp_before_clock(DspCore *dsp, bool dots) {
if (display.mode == PLAYER) {
dsp->setFont();
dsp->setTextSize(1);
display.centerText(dsp->utf8Rus("Hello from plugin!", true), display.screenheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2, 0xF97F, config.theme.background);
}
return true; // false, if you need to disable the drawing of the clock
}
#endif

View File

@@ -1,34 +0,0 @@
/**************************************************************
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, "RSSI:000dBm");
dsp->setTextSize(1);
dsp->getTextBounds(buf, 0, 0, &x1, &y1, &w, &h);
dsp->fillRect(dsp->width() - w - TFT_FRAMEWDT /* left */, vTop /* top */, w /* width */, TFT_LINEHGHT-2 /* height */, config.theme.background /* background color */);
sprintf(buf, "%dkBits", config.station.bitrate);
dsp->getTextBounds(buf, 0, 0, &x1, &y1, &w, &h);
if(cnt<2){
cnt++;
return true; /* print RSSI and retrn */
}
cnt++;
if(cnt>3) cnt=0;
dsp->setTextColor(config.theme.rssi,config.theme.background);
dsp->setCursor(dsp->width() - w - TFT_FRAMEWDT, vTop);
dsp->print(buf); /* print bitrate */
return false; /* disable to print RSSI */
}
#endif