#include <ESP32Servo.h>
#include <ESP32Time.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
//#include <Stepper.h>
//----------------------------------------------------------------------------------------
// ULN2003 Motor Driver Pins
#define IN1 16
#define IN2 4
#define IN3 0
#define IN4 2
#define add_time_button 19
#define set_button 18
#define increase_button 5
#define decrease_button 15
#define ShowTimeDoseBtn 23
#define MaxNumberOfDoses 7
#define StartPositionOfDoses 1 // we will start adding doses from room 1 and room 0 is reserved
//---------------------------------------------------------------------------------------------
// set the LCD number of columns and rows
int lcdColumns = 20;
int lcdRows = 4;
// set LCD address, number of columns and rows
// if you don't know your display address, run an I2C scanner sketch
const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
int pos = 0; // variable to store the servo position
int TimeBetweenPresses=50;
//variables to keep track of the timing of recent interrupts
unsigned long button_time = 0;
unsigned long last_button_time = 0;
// initialize the stepper library
//Stepper myStepper(stepsPerRevolution, IN1, IN3, IN2, IN4);
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);
ESP32Time rtc(0);
//--------------------------------- flags for buttons -------------------------------------------------------//
volatile int flag_to_check_pressing_AddTimeBtn =0;
volatile int flag_to_check_pressing_setTimeBtn =0; // flags will be 1 when the Button pressed
volatile int flag_to_check_pressing_IncreaseBtn =0;
volatile int flag_to_check_pressing_DecreaseBtn =0;
volatile int FlagForShowButton=0;
//-----------------------------------------------------------------------------------
//--------------------------- for setting current date and time ----------------------------------------//
int FlagToSetTime=1; //1 for day ---- 2 for month ---- 3 for year ------ 4 for hour ---- 5 for minute
int current_day=0;
int current_month=0;
int current_year=2022;
int current_hour=0;
int current_minute=0;
// ----------------------------for adding new dose -----------------------------//
void AddNewDose_Button();
void Increase_Button();
void Decrease_Button();
void Set_Button();
void AddDoseToDosesTable();
volatile int flagForClearingScreen=0;
volatile int IndexOfTheArray=3*StartPositionOfDoses;
volatile int HourGotFromUser=0;
volatile int MinuteGotFromUser=0;
volatile unsigned int Dose_PositionGotFromUser=0;
int TimeOfDoses_PositionsHoursAndMinutes[3*MaxNumberOfDoses]; //{position of dose,hour,minute,position of dose,hour,minute,position of dose,hour,minute}
int TimeOfDoses_ArraySize=3*MaxNumberOfDoses;
int duplicate_time=0;
volatile int flag_to_check_if_we_are_in_main_screen=0; // 1 for main and 2 for add time page
volatile int flag_to_check_Setting_RoomNumberOrHoursOrMinutes=1; // 1 for room number 2 for hours and 3 for minutes
//-----------------------------------------------------------------------------------
void ShowDoses_Button();
void MainScreenLcd();
void LcdWelcomeMessaage();
void Show_Doses();
void GetCurrentDateAndTime();
void selectionSort(int arr[], int n);
void swap(int *dose1_Position,int* dose1_Hour, int* dose1_Minute,int *dose2_Position,int* dose2_Hour, int* dose2_Minute);
void check_duplicate_time(int position,int Hour,int Minute);
//--------------------------------------------------------------------------
void setup() {
// Allow allocation of all timers
ESP32PWM::allocateTimer(0);
ESP32PWM::allocateTimer(1);
ESP32PWM::allocateTimer(2);
ESP32PWM::allocateTimer(3);
//myservo.setPeriodHertz(50); // standard 50 hz servo
//myservo.attach(servoPin, 500, 2400); // attaches the servo on pin 18 to the servo object
pinMode(add_time_button, INPUT_PULLUP);
pinMode(set_button, INPUT_PULLUP);
pinMode(increase_button, INPUT_PULLUP);
pinMode(decrease_button, INPUT_PULLUP);
pinMode(ShowTimeDoseBtn, INPUT_PULLUP);
attachInterrupt( add_time_button,AddNewDose_Button , FALLING);
attachInterrupt(set_button ,Set_Button , FALLING);
attachInterrupt( increase_button,Increase_Button , FALLING);
attachInterrupt(decrease_button ,Decrease_Button, FALLING);
attachInterrupt(ShowTimeDoseBtn ,ShowDoses_Button, FALLING);
// initialize LCD
lcd.init();
// turn on LCD backlight
lcd.backlight();
LcdWelcomeMessaage();
GetCurrentDateAndTime(); // configure date and time
rtc.setTime(0, current_minute, current_hour, current_day, current_month, current_year);
for(int j=0;j<TimeOfDoses_ArraySize;j++){ // loop to fill the array with value -1
TimeOfDoses_PositionsHoursAndMinutes[j]=-1;
}
// set the speed at 5 rpm
//myStepper.setSpeed(10);
// initialize the serial port
Serial.begin(115200);
// using default min/max of 1000us and 2000us
// different servos may require different min/max settings
// for an accurate 0 to 180 sweep
/*Serial.begin (115200);
// Leonardo: wait for serial port to connect
while (!Serial)
{
}
Serial.println ();
Serial.println ("I2C scanner. Scanning ...");
byte count = 0;
Wire.begin();
for (byte i = 8; i < 120; i++)
{
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0)
{
Serial.print ("Found address: ");
Serial.print (i, DEC);
Serial.print (" (0x");
Serial.print (i, HEX);
Serial.println (")");
count++;
delay (1); // maybe unneeded?
} // end of good response
} // end of for loop
Serial.println ("Done.");
Serial.print ("Found ");
Serial.print (count, DEC);
Serial.println (" device(s).");*/
}
void loop()
{
int current_hour=rtc.getHour(true);
int current_minute=rtc.getMinute();
if(flag_to_check_if_we_are_in_main_screen==1)
{
MainScreenLcd();
}
else if(flag_to_check_if_we_are_in_main_screen==2){
AddDoseToDosesTable();
}
if(FlagForShowButton){
Show_Doses();
}
}
//*******************************************************
//*********** we set flags with interrupts **************
//*******************************************************
//-----------------------------------------------------
void AddNewDose_Button()
{
button_time = millis();
if (button_time - last_button_time > TimeBetweenPresses)
{
flag_to_check_pressing_AddTimeBtn=1;
HourGotFromUser=0;
MinuteGotFromUser=0;
Dose_PositionGotFromUser=0;
FlagForShowButton=0;
flag_to_check_if_we_are_in_main_screen=2;
flagForClearingScreen=1;
last_button_time = button_time;
}
}
//-----------------------------------------------------
void Increase_Button()
{
button_time = millis();
if (button_time - last_button_time > TimeBetweenPresses)
{
if(flag_to_check_pressing_AddTimeBtn) // confirm that we press add_time_btn first
{
flag_to_check_pressing_IncreaseBtn=1;
}
last_button_time = button_time;
}
}
//------------------------------------------------
void Decrease_Button()
{
button_time = millis();
if (button_time - last_button_time > TimeBetweenPresses)
{
if(flag_to_check_pressing_AddTimeBtn) // confirm that we press add_time_btn first
{
flag_to_check_pressing_DecreaseBtn=1;
}
last_button_time = button_time;
}
}
//---------------------------------------------
void Set_Button()
{
button_time = millis();
if (button_time - last_button_time > TimeBetweenPresses)
{
if(flag_to_check_pressing_AddTimeBtn) // confirm that we press add_time_btn first
{
flag_to_check_pressing_setTimeBtn=1;
}
last_button_time = button_time;
}
}
//-------------------------------------------
void ShowDoses_Button()
{
button_time = millis();
if (button_time - last_button_time > TimeBetweenPresses)
{ FlagForShowButton=1;
}
last_button_time = button_time;
flag_to_check_if_we_are_in_main_screen=0;
flagForClearingScreen=1;
flag_to_check_pressing_AddTimeBtn =0;
}
//---------------------------------------------
//*****************************************************************
//**************** function to add new dose ***********************
//*****************************************************************
//------------------------------------------------------------------
void AddDoseToDosesTable()
{
if (flagForClearingScreen==1){lcd.clear();flagForClearingScreen=0;}
if(flag_to_check_pressing_AddTimeBtn)
{
if(IndexOfTheArray<TimeOfDoses_ArraySize){// check if there is empty place or not
//.............................turn to choose room position.........................................//
if(flag_to_check_Setting_RoomNumberOrHoursOrMinutes==1){ // 1 for position of the dose
lcd.setCursor(0, 0);
lcd.print("choose room number");
if(flag_to_check_pressing_IncreaseBtn){
if(Dose_PositionGotFromUser==(MaxNumberOfDoses-1)){
Dose_PositionGotFromUser=1;
}
else
{
Dose_PositionGotFromUser++;
//delay(200);
}
lcd.setCursor(0, 1);
lcd.print(Dose_PositionGotFromUser);
flag_to_check_pressing_IncreaseBtn=0;
}
if(flag_to_check_pressing_DecreaseBtn){
if(Dose_PositionGotFromUser==0||Dose_PositionGotFromUser==1){
Dose_PositionGotFromUser=6;
}
else
{
Dose_PositionGotFromUser--;
}
lcd.setCursor(0, 1);
lcd.print(Dose_PositionGotFromUser);
flag_to_check_pressing_DecreaseBtn=0;
}
if(flag_to_check_pressing_setTimeBtn){
if(Dose_PositionGotFromUser==0){Dose_PositionGotFromUser=1;}
lcd.setCursor(0, 1);
lcd.print("room choosed is : ");
lcd.print(Dose_PositionGotFromUser);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("choose Hour ");
flag_to_check_pressing_setTimeBtn=0;
flag_to_check_Setting_RoomNumberOrHoursOrMinutes=2; // set the turn for hours
}
}
//..............................turn to choose hour...........................................//
else if(flag_to_check_Setting_RoomNumberOrHoursOrMinutes==2){ // 2 for hours
if(flag_to_check_pressing_IncreaseBtn){
if(HourGotFromUser==23){
HourGotFromUser=0;
}
else
{
HourGotFromUser++;
}
lcd.setCursor(0, 1);
lcd.print(HourGotFromUser);
flag_to_check_pressing_IncreaseBtn=0;
}
if(flag_to_check_pressing_DecreaseBtn){
if(HourGotFromUser==0){
HourGotFromUser=23;
}
else
{
HourGotFromUser--;
//delay(200);
}
lcd.setCursor(0, 1);
lcd.print(HourGotFromUser);
//delay(1000);
//Serial.print(HourGotFromUser);
//Serial.print(" ");
flag_to_check_pressing_DecreaseBtn=0;
}
if(flag_to_check_pressing_setTimeBtn){
lcd.setCursor(0, 1);
lcd.print("hour chooses is :");
lcd.print(HourGotFromUser);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("choose minute");
flag_to_check_pressing_setTimeBtn=0;
flag_to_check_Setting_RoomNumberOrHoursOrMinutes=3; // set the turn for minutes
}
}
//................................turn to choose minute.........................................//
else if(flag_to_check_Setting_RoomNumberOrHoursOrMinutes==3){ // 3 for minutes
//Serial.println("choose Minte : ");
if(flag_to_check_pressing_IncreaseBtn){
if(MinuteGotFromUser==59){
MinuteGotFromUser=0;
}
else
{
MinuteGotFromUser++;
}
lcd.setCursor(0, 1);
lcd.print(MinuteGotFromUser);
flag_to_check_pressing_IncreaseBtn=0;
}
if(flag_to_check_pressing_DecreaseBtn){
if(MinuteGotFromUser==0){
MinuteGotFromUser=59;
}
else
{
MinuteGotFromUser--;
}
lcd.setCursor(0, 1);
lcd.print(MinuteGotFromUser);
flag_to_check_pressing_DecreaseBtn=0;
}
if(flag_to_check_pressing_setTimeBtn){
//delay(200);
check_duplicate_time(Dose_PositionGotFromUser,HourGotFromUser,MinuteGotFromUser);
if(!duplicate_time) // check if the dose is exist or not
{
int temp_position=0;
int Edit_dose=0;
for(int i=3;i<IndexOfTheArray;i+=3){ // for editing time of a dose in a room
if(TimeOfDoses_PositionsHoursAndMinutes[i]==Dose_PositionGotFromUser){
temp_position=i;
Edit_dose=1;
}
}
if(Edit_dose==1){
TimeOfDoses_PositionsHoursAndMinutes[temp_position]=Dose_PositionGotFromUser;
TimeOfDoses_PositionsHoursAndMinutes[temp_position+1]=HourGotFromUser;
TimeOfDoses_PositionsHoursAndMinutes[temp_position+2]=MinuteGotFromUser;
}
else{
TimeOfDoses_PositionsHoursAndMinutes[IndexOfTheArray]=Dose_PositionGotFromUser;
TimeOfDoses_PositionsHoursAndMinutes[IndexOfTheArray+1]=HourGotFromUser;
TimeOfDoses_PositionsHoursAndMinutes[IndexOfTheArray+2]=MinuteGotFromUser;
}
lcd.setCursor(0, 1);
lcd.print("minute choosed is:");
lcd.print(MinuteGotFromUser);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Room num : ");
lcd.print(Dose_PositionGotFromUser);
lcd.setCursor(0, 1);
lcd.print("has time of ");
lcd.print(HourGotFromUser);
lcd.print(" : ");
lcd.print(MinuteGotFromUser);
delay(2000);
lcd.clear();
flag_to_check_Setting_RoomNumberOrHoursOrMinutes=1;
flag_to_check_pressing_setTimeBtn=0;
flag_to_check_pressing_AddTimeBtn=0;
Dose_PositionGotFromUser=0;
HourGotFromUser=0;
MinuteGotFromUser=0;
IndexOfTheArray+=3;
selectionSort(TimeOfDoses_PositionsHoursAndMinutes,IndexOfTheArray); //sort doses by their time
flag_to_check_if_we_are_in_main_screen=1;
}
else{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("dose is exist");
delay(2000);
lcd.clear();
duplicate_time=0;
HourGotFromUser=0;
MinuteGotFromUser=0;
flag_to_check_Setting_RoomNumberOrHoursOrMinutes=1;
flag_to_check_pressing_setTimeBtn=0;
flag_to_check_pressing_AddTimeBtn=0;
flag_to_check_if_we_are_in_main_screen=1;
}
}
}
else{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("time table is full !!!");
}
}
}
}
//---------------------------------------------------------------------------
//***********************************************************************************
//****************************function to show added doses***************************
//***********************************************************************************
//-----------------------------------------------------------------------
void Show_Doses(){
if (flagForClearingScreen==1){lcd.clear();flagForClearingScreen=0;}
lcd.setCursor(0, 0);
lcd.print("ROOM TIME");
int rpos=1;
lcd.setCursor(0, 1);
lcd.print("----------------");
for(int i=3*StartPositionOfDoses;i<IndexOfTheArray;i+=3)
{if(TimeOfDoses_PositionsHoursAndMinutes[i]==-1){}
else{
if(flag_to_check_pressing_AddTimeBtn==1){FlagForShowButton=0;}// here we give the priority for add new dose
else{
lcd.setCursor(0, 2);
lcd.print(TimeOfDoses_PositionsHoursAndMinutes[i]);
lcd.print(" ");
lcd.print(TimeOfDoses_PositionsHoursAndMinutes[i+1]);
lcd.print(" : ");
lcd.print(TimeOfDoses_PositionsHoursAndMinutes[i+2]);
lcd.print(" ");
delay(1000);
}
}
}
flag_to_check_if_we_are_in_main_screen=1;
FlagForShowButton=0;
lcd.clear();
}
//-----------------------------------------------------------------------
void swap(int *dose1_Position,int* dose1_Hour, int* dose1_Minute,int *dose2_Position,int* dose2_Hour, int* dose2_Minute)
{
int temp1 = *dose1_Hour;
*dose1_Hour = *dose2_Hour;
*dose2_Hour = temp1;
int temp2=*dose1_Minute;
*dose1_Minute = *dose2_Minute;
*dose2_Minute = temp2;
int temp3 = *dose1_Position;
*dose1_Position = *dose2_Position;
*dose2_Position = temp3;
}
//-----------------------------------------------------------------------
// Function to perform Selection Sort
void selectionSort(int arr[], int n)
{
int i, j, min_idx;
// One by one move boundary of unsorted subarray
for (i = 3*StartPositionOfDoses; i < n ; i+=3) { // the first position is reserved till now
// Find the minimum element in unsorted array
min_idx = i;
for (j = i + 3; j < n; j+=3){
if (arr[j+1] <= arr[min_idx+1]) // EX : 1:15 ----2:10
{
if(arr[j+1] == arr[min_idx+1]) // EX: 1:15 --- 1:10 hours are the same so check the minte next
{
if (arr[j+2] < arr[min_idx+2]){min_idx = j;}
}
else{min_idx = j;}
}
}
// Swap the found minimum element
// with the first element
swap(&arr[min_idx],&arr[min_idx+1],&arr[min_idx+2], &arr[i], &arr[i+1], &arr[i+2]);
}
}
//-----------------------------------------------------------------------
void check_duplicate_time(int position,int Hour,int Minute){
int temp=IndexOfTheArray;
for(int i=3*StartPositionOfDoses;i<temp;i+=3){
if((TimeOfDoses_PositionsHoursAndMinutes[i+2]==Minute&&TimeOfDoses_PositionsHoursAndMinutes[i+1]==Hour)){
duplicate_time=1;return;
}
}
}
//-----------------------------------------------------------------------
void MainScreenLcd(){
lcd.setCursor(0, 0);
//lcd.print("Time : ");
lcd.print(rtc.getTime());
lcd.setCursor(0, 1);
//lcd.print("Date :");
lcd.print(rtc.getDate());
lcd.setCursor(0, 2);
lcd.print("press black button ");
lcd.setCursor(0, 3);
lcd.print("to add new dose");
}
void LcdWelcomeMessaage(){
char welcomemeesage[50]="Hi ... We wish you speedy recovery ";
// set cursor to first column, first row
lcd.setCursor(0, 0);
for(int i=0;i<50;i++){
lcd.print(welcomemeesage[i]);
delay(100);
}
delay(1000);
lcd.clear();
}
//-----------------------------------------------------------------------
void GetCurrentDateAndTime(){
lcd.clear();
flag_to_check_pressing_AddTimeBtn=1;
lcd.setCursor(0, 0);
lcd.print("enter current day");
//.............................choose current hour...........................................//
while(1){
if(FlagToSetTime==1){ // 1 for day
if(flag_to_check_pressing_IncreaseBtn){
if(current_day==31){
current_day=1;
}
else
{
current_day++;
}
lcd.setCursor(0, 1);
lcd.print(current_day);
lcd.print(" ");
flag_to_check_pressing_IncreaseBtn=0;
}
if(flag_to_check_pressing_DecreaseBtn){
if(current_day<=1){
current_day=31;
}
else
{
current_day--;
//delay(200);
}
lcd.setCursor(0, 1);
lcd.print(current_day);
lcd.print(" ");
flag_to_check_pressing_DecreaseBtn=0;
}
if(flag_to_check_pressing_setTimeBtn){
if(current_day==0){current_day=1;}
lcd.setCursor(0, 1);
lcd.print("day choosed is :");
lcd.print(current_day);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("enter current month");
flag_to_check_pressing_setTimeBtn=0;
FlagToSetTime=2; // set the turn for month
}
}
else if(FlagToSetTime==2){ // 2 for month
// lcd.setCursor(0, 0);
//lcd.print("enter current month");
if(flag_to_check_pressing_IncreaseBtn){
if(current_month==12){
current_month=1;
}
else
{
current_month++;
}
lcd.setCursor(0, 1);
lcd.print(current_month);
lcd.print(" ");
flag_to_check_pressing_IncreaseBtn=0;
}
if(flag_to_check_pressing_DecreaseBtn){
if(current_month<=1){
current_month=12;
}
else
{
current_month--;
//delay(200);
}
lcd.setCursor(0, 1);
lcd.print(current_month);
lcd.print(" ");
flag_to_check_pressing_DecreaseBtn=0;
}
if(flag_to_check_pressing_setTimeBtn){
if(current_month==0){current_month=1;}
lcd.setCursor(0, 1);
lcd.print("month choosed is :");
lcd.print(current_month);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("enter current year");
flag_to_check_pressing_setTimeBtn=0;
FlagToSetTime=3; // set the turn for year
}
}
else if(FlagToSetTime==3){ // 3 for year
// lcd.setCursor(0, 0);
// lcd.print("enter current year");
if(flag_to_check_pressing_IncreaseBtn){
current_year++;
lcd.setCursor(0, 1);
lcd.print(current_year);
lcd.print(" ");
flag_to_check_pressing_IncreaseBtn=0;
}
if(flag_to_check_pressing_DecreaseBtn){
if(current_year==2022){}
else{current_year--;}
lcd.setCursor(0, 1);
lcd.print(current_year);
lcd.print(" ");
flag_to_check_pressing_DecreaseBtn=0;
}
if(flag_to_check_pressing_setTimeBtn){
lcd.setCursor(0, 1);
lcd.print("year is :");
lcd.print(current_year);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("enter current hour");
flag_to_check_pressing_setTimeBtn=0;
FlagToSetTime=4; // set the turn for year
}
}
else if(FlagToSetTime==4){ // 1 for hours
// lcd.setCursor(0, 0);
// lcd.print("enter current hour");
if(flag_to_check_pressing_IncreaseBtn){
if(HourGotFromUser==23){
HourGotFromUser=0;
}
else
{
HourGotFromUser++;
}
lcd.setCursor(0, 1);
lcd.print(HourGotFromUser);
lcd.print(" ");
flag_to_check_pressing_IncreaseBtn=0;
}
if(flag_to_check_pressing_DecreaseBtn){
if(HourGotFromUser==0){
HourGotFromUser=23;
}
else
{
HourGotFromUser--;
//delay(200);
}
lcd.setCursor(0, 1);
lcd.print(HourGotFromUser);
lcd.print(" ");
flag_to_check_pressing_DecreaseBtn=0;
}
if(flag_to_check_pressing_setTimeBtn){
lcd.setCursor(0, 1);
lcd.print("hour chooses is :");
lcd.print(HourGotFromUser);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("enter current minute");
flag_to_check_pressing_setTimeBtn=0;
FlagToSetTime=5; // set the turn for minutes
}
}
//................................turn to choose current minute.........................................//
else if(FlagToSetTime==5){ // 2 for minutes
//Serial.println("choose Minte : ");
//lcd.setCursor(0, 0);
//lcd.print("enter current minute");
if(flag_to_check_pressing_IncreaseBtn){
if(MinuteGotFromUser==59){
MinuteGotFromUser=0;
}
else
{
MinuteGotFromUser++;
}
lcd.setCursor(0, 1);
lcd.print(MinuteGotFromUser);
lcd.print(" ");
flag_to_check_pressing_IncreaseBtn=0;
}
if(flag_to_check_pressing_DecreaseBtn){
if(MinuteGotFromUser==0){
MinuteGotFromUser=59;
}
else
{
MinuteGotFromUser--;
}
lcd.setCursor(0, 1);
lcd.print(MinuteGotFromUser);
lcd.print(" ");
flag_to_check_pressing_DecreaseBtn=0;
}
if(flag_to_check_pressing_setTimeBtn){
lcd.setCursor(0, 1);
lcd.print("minute choosed is:");
lcd.print(MinuteGotFromUser);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("date is ");
lcd.print(current_day);
lcd.print("/");
lcd.print(current_month);
lcd.print("/");
lcd.print(current_year);
lcd.setCursor(0, 2);
lcd.print("time is ");
lcd.print(HourGotFromUser);
lcd.print(" : ");
lcd.print(MinuteGotFromUser);
delay(2500);
current_hour=HourGotFromUser;
current_minute=MinuteGotFromUser;
lcd.clear();
flag_to_check_pressing_setTimeBtn=0;
flag_to_check_pressing_AddTimeBtn=0;
HourGotFromUser=0;
MinuteGotFromUser=0;
flag_to_check_pressing_AddTimeBtn=0;
flag_to_check_if_we_are_in_main_screen=1;
break;
}
}
}
}