You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

308 lines
10 KiB

void GxepdPage4()
{
int Dn=dow;
if(p==1)
{Dn=Dn+3;
if(Dn>6)Dn=Dn-7;
}
if(Dn==0){Dn=7;}//день недели определяем и переводим в интервал 1-7
display.setRotation(4);
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.setFont();
// DisplayWeatherIcon(64, 100); // Display weather icon scale = Large;
DrawBattery( 0, 21);
//DrawRSSI(105, 21, wifi_signal);
display.setTextColor(GxEPD_RED);
clok(70, 19);
display.setTextColor(GxEPD_BLACK);
display.drawLine(10,25, 128, 25, GxEPD_BLACK);//x1 y1 x2 y2
display.drawLine(127, 25, 127, 295, GxEPD_BLACK);//x1 y1 x2 y2
//display.drawLine(0, 40, 120, 40, GxEPD_BLACK);//x1 y1 x2 y2
//display.drawLine(0, 70, 120, 70, GxEPD_BLACK);//x1 y1 x2 y2
for (int i=0;i<3;i++)
{int index =i;
if(p==1) index =i+3;
DisplayForecastWeather3(0, 55, index,Dn);//x,y,index ,день недели
Dn++;
if(Dn>7)Dn=1;
}
//display.drawLine(0, 230, 120, 230, GxEPD_BLACK);//x1 y1 x2 y2
//display.drawLine(64, 170, 64, 230, GxEPD_BLACK);//x1 y1 x2 y2
display.update();
//***************** опрос клавиш **********************************
for (int i = 0; i < 200; i++) {
// покинуть цикл при достижении 100
delay (100);
if ((i == 70)||(i == 80)||(i == 90)) testSpeaker2();
if (i == 100) break;
bool gpio_get_level_38 = digitalRead(38);
if (gpio_get_level_38 == 1)
{testSpeaker();
if(p==0){p=1; }
else
{p=0; }
GxepdPage42();
break;
}
bool gpio_get_level_37 = digitalRead(37);
if (gpio_get_level_37 == 1)
{testSpeaker();
kalen=1;
GxepdPage2();
// Kalendar();
break;
}
bool gpio_get_level_39 = digitalRead(39);
if (gpio_get_level_39 == 1)
{testSpeaker();
GxepdPage2();
break;
}
}
//**************************************************************///////////////////////////////////////////////////////////////
}
void GxepdPage42()
{
int Dn=dow;
if(p==1)
{Dn=Dn+3;
if(Dn>6)Dn=Dn-7;
}
if(Dn==0){Dn=7;}//день недели определяем и переводим в интервал 1-7
display.setRotation(4);
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.setFont();
// DisplayWeatherIcon(64, 100); // Display weather icon scale = Large;
DrawBattery( 0, 21);
//DrawRSSI(105, 21, wifi_signal);
display.setTextColor(GxEPD_RED);
clok(70, 19);
display.setTextColor(GxEPD_BLACK);
display.drawLine(10,25, 128, 25, GxEPD_BLACK);//x1 y1 x2 y2
display.drawLine(127, 25, 127, 295, GxEPD_BLACK);//x1 y1 x2 y2
//display.drawLine(0, 40, 120, 40, GxEPD_BLACK);//x1 y1 x2 y2
//display.drawLine(0, 70, 120, 70, GxEPD_BLACK);//x1 y1 x2 y2
for (int i=0;i<3;i++)
{int index =i;
if(p==1) index =i+3;
DisplayForecastWeather3(0, 55, index,Dn);//x,y,index ,день недели
Dn++;
if(Dn>7)Dn=1;
}
//display.drawLine(0, 230, 120, 230, GxEPD_BLACK);//x1 y1 x2 y2
//display.drawLine(64, 170, 64, 230, GxEPD_BLACK);//x1 y1 x2 y2
display.update();
//***************** опрос клавиш **********************************
for (int i = 0; i < 200; i++) {
// покинуть цикл при достижении 100
delay (100);
if ((i == 70)||(i == 80)||(i == 90)) testSpeaker2();
if (i == 100) break;
bool gpio_get_level_38 = digitalRead(38);
if (gpio_get_level_38 == 1)
{testSpeaker();
Serial.println("GxepdPage4");
if(p==0){p=1; }
else
{p=0; }
GxepdPage4();
break;
}
bool gpio_get_level_37 = digitalRead(37);
if (gpio_get_level_37 == 1)
{testSpeaker();
// Kalendar();
GxepdPage2();
break;
}
bool gpio_get_level_39 = digitalRead(39);
if (gpio_get_level_39 == 1)
{testSpeaker();
GxepdPage2();
break;
}
}
//**************************************************************
}
//***************************************************************************************************
void DisplayForecastWeather3(int x, int y, int index,int Dn) {
int fwidth = 90;//высота
const char* wek[] = { "П","В","С","Ч","П","С","В","н","т","р","т","т","б","с"};
if(index>2)
{y = y +45+ fwidth * (index-3);
}
else
{y = y +45+ fwidth * index;
}
x=x+10;
//**************День недели*************************
if(Dn<6)
{display.fillRect(0, y-29-38-7 , 10,y+9-3,GxEPD_BLACK);
}
else
{
display.fillRect(0, y-29-38-7 , 10,y+9-3,GxEPD_RED);
}
display.setFont();
display.setTextColor(GxEPD_WHITE);
display.setCursor(2,y-40+3);
display.print(utf8rus(wek[Dn-1]));
display.setCursor(2,y-30+3);
display.print(utf8rus(wek[Dn-1+7]));
//*********************
DisplayConditionsSection(x+30-3 , y-48 , WxForecast[index].Icon, SmallIcon);//вывод иконки погоды
display.setTextColor(GxEPD_RED);
display.setFont();
display.setTextSize(2);
static char outstr[15];
display.setCursor(62,y-24-46);
dtostrf(WxForecast[index].day,5, 1, outstr);
display.print(outstr);
display.setTextColor(GxEPD_BLACK);
display.setCursor(62,y-4-48);
dtostrf(WxForecast[index].night,5, 1, outstr);
display.print(outstr);
display.setTextSize(1);
display.drawLine(0, y+15, 128, y+15, GxEPD_WHITE);//x1 y1 x2 y2
display.drawLine(10, y+15, 128, y+15, GxEPD_BLACK);//x1 y1 x2 y2
// drawString(x + fwidth / 2, y + 30, String(ConvertUnixTime(WxForecast[index].Dt + WxConditions[0].Timezone).substring(0, 5)), CENTER);
// drawString(x + fwidth / 2, y + 125, String(WxForecast[index].High, 0) + "°/" + String(WxForecast[index].Low, 0) + "°", CENTER);
display.setTextColor(GxEPD_BLACK);
display.setFont();
display.setTextSize(1);
display.setCursor(82-60,y-45+15+5);
int h=WxForecast[index].Humidity;
display.print(h);//WxForecast[index].Humidity
display.setCursor(96-60,y-45+15+5);
display.print("%");
display.setCursor(82-60,y-45+30);
h=WxForecast[index].Pressure*1000/1333;//WxForecast[index].Pressure
display.print(h);
display.setCursor(102-60,y-45+30);
display.print("mm");
display.setCursor(82-60,y-45+45-5);
if(WxForecast[index].Windspeed>7)
{display.setTextColor(GxEPD_RED);
}
else
{ display.setTextColor(GxEPD_BLACK);
}
display.print(WxForecast[index].Windspeed);//WxForecast[index].Windspeed WxForecast[index].Winddir
display.setCursor(108-60,y-45+45-5);
display.print("m/s");
display.setTextColor(GxEPD_BLACK);
//******************************************************************************************
DisplayDisplayWindSection(x+30+58, y-12, WxForecast[index].Winddir,WxForecast[index].Windspeed, 16);//роза ветров
}
void DisplayDisplayWindSection(int x, int y, float angle, float windspeed, int Cradius) {
arrow(x, y, Cradius-7, angle, 5, 15); // Show wind direction on outer circle of width and length
display.setFont();
int dxo, dyo, dxi, dyi;
display.drawCircle(x, y, Cradius, GxEPD_BLACK); // Draw compass circle
display.drawCircle(x, y, Cradius + 1, GxEPD_BLACK); // Draw compass circle
display.drawCircle(x, y, Cradius * 0.7, GxEPD_BLACK); // Draw compass inner circle
for (float a = 0; a < 360; a = a + 22.5) {
dxo = Cradius * cos((a - 90) * PI / 180);
dyo = Cradius * sin((a - 90) * PI / 180);
//if (a == 45) drawString(dxo + x + 15, dyo + y - 18, TXT_NE, CENTER);
// if (a == 135) drawString(dxo + x + 20, dyo + y - 2, TXT_SE, CENTER);
// if (a == 225) drawString(dxo + x - 20, dyo + y - 2, TXT_SW, CENTER);
// if (a == 315) drawString(dxo + x - 15, dyo + y - 18, TXT_NW, CENTER);
dxi = dxo * 0.9;
dyi = dyo * 0.9;
display.drawLine(dxo + x, dyo + y, dxi + x, dyi + y, GxEPD_BLACK);
dxo = dxo * 0.7;
dyo = dyo * 0.7;
dxi = dxo * 0.9;
dyi = dyo * 0.9;
display.drawLine(dxo + x, dyo + y, dxi + x, dyi + y, GxEPD_BLACK);
}
display.setTextColor(GxEPD_RED);
drawString(x-2, y - Cradius - 9, TXT_N, CENTER);
drawString(x-2, y + Cradius +3, TXT_S, CENTER);
drawString(x - Cradius - 9, y - 3, TXT_W, CENTER);
drawString(x + Cradius + 5, y - 3, TXT_E, CENTER);
// drawString(x + 3, y + 50, String(angle, 0) + "°", CENTER);
display.setFont();
drawString(35, y + 17, WindDegToOrdinalDirection(angle), CENTER);
display.setTextColor(GxEPD_BLACK);
// display.setFont(OpenSans24B);
// drawString(x + 3, y - 18, String(windspeed, 1), CENTER);
// display.setFont(OpenSans12B);
// drawString(x, y + 25, ( "m/s"), CENTER);
}
String WindDegToOrdinalDirection(float winddirection) {
if (winddirection >= 348.75 || winddirection < 11.25) return TXT_N;
if (winddirection >= 11.25 && winddirection < 33.75) return TXT_NNE;
if (winddirection >= 33.75 && winddirection < 56.25) return TXT_NE;
if (winddirection >= 56.25 && winddirection < 78.75) return TXT_ENE;
if (winddirection >= 78.75 && winddirection < 101.25) return TXT_E;
if (winddirection >= 101.25 && winddirection < 123.75) return TXT_ESE;
if (winddirection >= 123.75 && winddirection < 146.25) return TXT_SE;
if (winddirection >= 146.25 && winddirection < 168.75) return TXT_SSE;
if (winddirection >= 168.75 && winddirection < 191.25) return TXT_S;
if (winddirection >= 191.25 && winddirection < 213.75) return TXT_SSW;
if (winddirection >= 213.75 && winddirection < 236.25) return TXT_SW;
if (winddirection >= 236.25 && winddirection < 258.75) return TXT_WSW;
if (winddirection >= 258.75 && winddirection < 281.25) return TXT_W;
if (winddirection >= 281.25 && winddirection < 303.75) return TXT_WNW;
if (winddirection >= 303.75 && winddirection < 326.25) return TXT_NW;
if (winddirection >= 326.25 && winddirection < 348.75) return TXT_NNW;
return "?";
}
void arrow(int x, int y, int asize, float aangle, int pwidth, int plength) {
float dx = (asize - 10) * cos((aangle - 90) * PI / 180) + x; // calculate X position
float dy = (asize - 10) * sin((aangle - 90) * PI / 180) + y; // calculate Y position
float x1 = 0; float y1 = plength;
float x2 = pwidth / 2; float y2 = pwidth / 2;
float x3 = -pwidth / 2; float y3 = pwidth / 2;
float angle = aangle * PI / 180 - 135;
float xx1 = x1 * cos(angle) - y1 * sin(angle) + dx;
float yy1 = y1 * cos(angle) + x1 * sin(angle) + dy;
float xx2 = x2 * cos(angle) - y2 * sin(angle) + dx;
float yy2 = y2 * cos(angle) + x2 * sin(angle) + dy;
float xx3 = x3 * cos(angle) - y3 * sin(angle) + dx;
float yy3 = y3 * cos(angle) + x3 * sin(angle) + dy;
display.fillTriangle(xx1, yy1, xx3, yy3, xx2, yy2, GxEPD_RED);
}