Good evening everyone
I have been working this issue for a while. I'm simply trying to change the default struct values to a set of new values that I set by using pot1, pot2.
Here is my struct.h
Now for main.
Ok so when i hit the button it calls attachInterrupt(digitalPinToInterrupt(1), SendValuesflag, HIGH) which will call Sendvaluesflag. This funtion is in the OLED_RTC.cpp
when I hit the switch (digitalPinToInterrupt(0)) it changes the screen, i then change the values of potvalue1 and potvalue2. I now hit the button (digitalPinToInterrupt(1)) and it sets Timervalues.timer = potvalue1 and Timervalues.clockset = potvalue2;
this then gets passed up to void SendValuesflag() // Button Flag
the output of the message in the terminal is:
New timer Length: 1
New clock start alarm: 22
I am tap.timer :1
I am tap.clock: 22
I am tap.timer :12000 // default value
I am tap.clock: 6 // default value
it sets the values back to default after I flip the switch (digitalPinToInterrupt(0)) back to LOW and returns to the default OLED screen
I have been working this issue for a while. I'm simply trying to change the default struct values to a set of new values that I set by using pot1, pot2.
Here is my struct.h
Code:
struct timeralarmpara
{
int timer = 12000; // This is a member of the struct
int clockset = 6;
}; // ; is needed when using a struct
Now for main.
Code:
#include <potentiometer.h>
#include <OLED_RTC.h>
#include <timer.h>
#include <avr/io.h> // interrupt
#include <avr/interrupt.h> // interrupt
//******************************************Declare*****************************//
Timerhour Timerhour0; // Setting Object 0 for Timer12hour0
OLED OLED0; // Setting Object 0 for OLED
struct timeralarmpara tap; // Struct Declare for timeralarmpara
//******************************************Setup*****************************//
void setup()
{
Timerhour0.setuptimer();
OLED0.intdisplay();
pinMode(0, INPUT);
pinMode(1, INPUT);
attachInterrupt(digitalPinToInterrupt(0), OLEDflag, HIGH); // Setting interrupt pin D0
attachInterrupt(digitalPinToInterrupt(1), SendValuesflag, HIGH); // Setting interrupt pin D1
Serial.begin(9600);
} //end setup
//******************************************Main******************************//
void loop()
{
// map Timerhour0.timer(Tap) return to currenttimer , map Timerhour0.getRelayString() return to Relaystring
OLED0.OLEDdraw(Timerhour0.timer(tap), Timerhour0.getRelayString());
Timerhour0.timer(tap);
} // end void loop
Ok so when i hit the button it calls attachInterrupt(digitalPinToInterrupt(1), SendValuesflag, HIGH) which will call Sendvaluesflag. This funtion is in the OLED_RTC.cpp
Code:
#include <G_structure.h>
#include <OLED_RTC.h>
#include <Potentiometer.h>
//******************************************Declare*****************************//
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/U8X8_PIN_NONE);
RTC_DS3231 rtc;
//******************************************Setup*****************************//
void OLED::intdisplay()
{
u8g2.begin(); // Start the Library code for the OLED
} // end void OLED
//*****************************************Functions**************************//
void SendValuesflag() // Button Flag
{
struct timeralarmpara tap; // declare a new variable named tap
while (digitalRead(1) == HIGH && digitalRead(0) == HIGH)
{
OLED OLED2;
Potentiometer Potentiometer2;
OLED2.sendvaluestimer(tap, Potentiometer2.getpot1(), Potentiometer2.getpot2());
break;
}
Serial.print("I am tap.timer :");
Serial.print(tap.timer);
Serial.println();
Serial.print("I am tap.clock: ");
Serial.print(tap.clockset);
Serial.println();
} // end void SendValuesflag
[b]
void OLED::sendvaluestimer(struct timeralarmpara &Timervalues, int potvalue1, int potvalue2)
{
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_helvB12_te);
u8g2.drawStr(35, 25, "Vaules");
u8g2.drawStr(35, 45, "Saved!");
u8g2.sendBuffer();
Timervalues.timer = (potvalue1); // setting timer to hour length in sec
Timervalues.clockset = potvalue2;
Serial.print("New timer Length: ");
Serial.print(Timervalues.timer);
Serial.println();
Serial.print("New clock start alarm: ");
Serial.print(Timervalues.clockset);
Serial.println();
delay(500);
} // ending sendvaluestimer
when I hit the switch (digitalPinToInterrupt(0)) it changes the screen, i then change the values of potvalue1 and potvalue2. I now hit the button (digitalPinToInterrupt(1)) and it sets Timervalues.timer = potvalue1 and Timervalues.clockset = potvalue2;
this then gets passed up to void SendValuesflag() // Button Flag
the output of the message in the terminal is:
New timer Length: 1
New clock start alarm: 22
I am tap.timer :1
I am tap.clock: 22
I am tap.timer :12000 // default value
I am tap.clock: 6 // default value
it sets the values back to default after I flip the switch (digitalPinToInterrupt(0)) back to LOW and returns to the default OLED screen
Code:
void OLEDflag() // Switch Flag
{
while (digitalRead(0) == HIGH && digitalRead(1) == LOW)
{
OLED OLED1;
Potentiometer Potentiometer1; // why should I use a different Object here ? is it because it is a saporate .cpp file?
OLED1.clocktimerset(Potentiometer1.getpot1(), Potentiometer1.getpot2());
}
} // end void OLEDflag