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.
 
 
 

164 lines
6.0 KiB

void Kalendar()
{
int N=31;//переменная числа дней в месяце
//int mon=1;
//int date=23;
//int dow=6;
int a1=0;
boolean sun=0;
if(mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==12){N=31;}else {if(mon==2){N=28;}else{N=30;}}//условия определения числа дней в месяцах
int D = date;//число месяца
int Dn=dow;
//Serial.println(D);
// Serial.println(Dn);
if(Dn==0){Dn=7;}//день недели определяем и переводим в интервал 1-7
for(int i=D-1;i>=1;i--){Dn=Dn-1;if(Dn==0){Dn=7;}}//определяем день недели для первого числа (от 1 до 7 результат пн.-вс.)
int k=Dn-2;
display.setRotation(4);
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.setFont();
DrawBattery( 0, 20);
DrawRSSI(95, 20, wifi_signal);
int xk=0;
int yk=160;
//display.drawRect( 0+xk, 0+yk,125,85, GxEPD_BLACK);
display.setCursor(3+xk, 4+yk);
display.println(utf8rus("Пн"));
// display.print("Mo");
display.setCursor(20+xk, 4+yk);
display.println(utf8rus("Вт"));
display.setCursor(37+xk, 4+yk);
display.println(utf8rus("Ср"));
display.setCursor(54+xk, 4+yk);
display.println(utf8rus("Чт"));
display.setCursor(71+xk, 4+yk);
display.println(utf8rus("Пт"));
//display.fillRect(85+xk, 0+yk, 18, 11, GxEPD_BLACK);//x y w h
// display.fillRect(102+xk, 0+yk, 18, 11, GxEPD_BLACK);//x y w h
display.fillRect(85+xk, 0+yk, 35, 87, GxEPD_BLACK);//x y w h***
display.drawLine(0+xk, 13+yk, 84+xk, 13+yk, GxEPD_BLACK);//x1 y1 x2 y2
display.setTextColor(GxEPD_WHITE);
display.drawLine(85+xk,13+yk, 124+xk, 13+yk, GxEPD_WHITE);//x1 y1 x2 y2
display.drawLine(102+xk, 0+yk, 102+xk, 85+yk, GxEPD_WHITE);//x1 y1 x2 y2
display.setCursor(88+xk, 4+yk);
display.println(utf8rus("Сб"));
display.setCursor(105+xk, 4+yk);
display.println(utf8rus("Вс"));
display.setTextColor(GxEPD_BLACK);
for(int i=0;i<6;i++){//вертикаль
for(int j=0;j<7;j++){//горизонталь
if(j-k+7*i<=N&&j-k+7*i>0){
if((j==5)||(j==6))
{//display.fillRect(j*18, i*11+10, 16, 11, GxEPD_BLACK);//x y w h
display.setTextColor(GxEPD_WHITE);
display.setCursor(j*17+3+1+xk, i*11+18+yk);
display.print(j-k+7*i);
display.setTextColor(GxEPD_BLACK);
sun=1;
}
else
{display.setCursor(j*17+3+1+xk, i*11+18+yk);
display.print(j-k+7*i);
sun=0;
}
}
//
if(j-k+7*i==D){
if(sun==1)
{display.drawRect( j*17+1+xk, i*11+9+7+yk,15,11, GxEPD_WHITE);
}
else{
display.drawRect( j*17+1+xk, i*11+9+7+yk,15,11, GxEPD_BLACK);
}
display.setTextColor(GxEPD_BLACK);
sun=0;
} //
}
}
display.drawRect( 0+xk, 0+yk,123,87, GxEPD_BLACK);
display.drawLine(10, 25, 110, 25, GxEPD_BLACK);//x1 y1 x2 y2
display.drawLine(10, 132, 110, 132, GxEPD_BLACK);//x1 y1 x2 y2
display.drawLine(20, 40, 98, 40, GxEPD_BLACK);//x1 y1 x2 y2
//***********************ДАТА***************************************
display.setFont(&FreeMonoBold9pt7b);
// display.setCursor(135, 15);
display.setCursor(38, 38);
// display.print(date);
// display.print(".");
// if(mon<10){display.print("0");}
// display.print(mon);
// display.print(".");
display.print(years);
display.setFont(&FreeMonoBold18pt7b);
// display.setCursor(136, 60);
display.setCursor(7, 157);
if(CurrentHour<10){ display.setCursor(18, 157);}
display.print(CurrentHour);//время с нтп часы
display.print(":");
if(CurrentMin<10){display.print("0");}
display.print(CurrentMin );//минуты
const char* monrus[] = { "ЯНВАРЬ", "ФЕВРАЛЬ", "МАРТ", "АПРЕЛЬ", "МАЙ", "ИЮНЬ", "ИЮЛЬ", "АВГУСТ", "СЕНТЯБРЬ", "ОКТЯБРЬ", "НОЯБРЬ", "ДЕКАБРЬ" };
int curmon[]={27,20,37,24,43,37,37,25,12,19,25,19};
const char* wek[] = { "Понедельн","Вторник","Среда","Четверг","Пятница","Суббота","Воскресен"};
int curwek[]={8,19,31,19,19,19,8};
display.setFont();
display.setTextSize(2);
// display.setCursor(38, 30);
// display.print(years);
//mon=12;
display.setCursor(curmon[mon-1],45);
display.println(utf8rus(monrus[mon-1]));
// dow=7;
display.setCursor(curwek[dow-1],115);
display.println(utf8rus(wek[dow-1]));
display.setCursor(21,63);
display.setTextSize(7);
if(date<10){ display.print(utf8rus("0"));}
display.print(date);
display.update();
//delay(5000);
SleepPage();
}
//***************************** СОН НА 1 МИНУТУ ************************
// после сна переход в режим термометра
void SleepPage()
{
touchAttachInterrupt(T7, callback7, Threshold);
touchAttachInterrupt(T8, callback8, Threshold);
touchAttachInterrupt(T9, callback9, Threshold);
// SleepTimer = (SleepDuration * 60 - ((CurrentMin % SleepDuration) * 60 + CurrentSec)) + Delta; //Some ESP32 have a RTC that is too fast to maintain accurate time, so add an offset
SleepTimer = 60;
esp_sleep_enable_timer_wakeup(SleepTimer * 1000000LL); // in Secs, 1000000LL converts to Secs as unit = 1uSec
// Serial.println("Awake for : " + String((millis() - StartTime) / 1000.0, 3) + "-secs");
// Serial.println("Entering " + String(SleepTimer) + " (secs) of sleep time");
// Serial.println("Starting deep-sleep period...");
tik = 0;
esp_sleep_enable_ext1_wakeup(((uint64_t)(((uint64_t)1) << BUTTON_1)), ESP_EXT1_WAKEUP_ALL_LOW);
esp_sleep_enable_touchpad_wakeup();
esp_deep_sleep_start(); // Sleep for e.g. 30 minutes
}