JhonControl / ESP8266_GPIO_GoogleSpreadsheet

Controller GPIO ESP8266 from Google Spreadsheets
5 stars 4 forks source link

calling a variable from cpp to main program #1

Open mechanic98 opened 6 years ago

mechanic98 commented 6 years ago

hi tanks for making this project i want use line variable in this function that is in HTTPSRedirect.cpp . in the googleDos.ino

 void HTTPSRedirect::fetchData(bool disp, bool header){
 String line;
 pinMode(2, `OUTPUT)`

while (connected()) {
line = readStringUntil('\n');

if (disp)
  Serial.println(line);
  if(line == "On\r"){
//  Serial.println("Led On");
  digitalWrite(2, HIGH);
  }
    if(line == "Off\r"){
//  Serial.println("Led Off");    
  digitalWrite(2, LOW);

  }

if (line == "\r") {
  if (disp){
    if (header)
      DPRINTLN("END OF HEADER");
    else
      DPRINTLN("END OF RESPONSE");
      //DPRINTLN(line);
  }
  break;
}

} }

i want use String line in main program like this:

 String test="";
void setup(){
}

void loop (){
test=line;
}

please Help me tanks

JhonControl commented 6 years ago

Hello, sorry for the delay this version is a little old, in that case that required to activate a gpio, the quick solution was to edit directly in the library, perform tests with certain improvements, if you can see them and try: https://youtu.be/L68MxmHewww   and tell me, what are you doing ?, the creator of the library also made improvements. https://github.com/electronicsguy/ESP8266/tree/master/HTTPSRedirect

regards

mechanic98 commented 6 years ago

Thank you for the quick response this code work fine. but i need to use "String line " in the main program , my project is : esp8266 give whether forecast from wunderground and save them in google sheet and another one esp read information from google sheet i want to modify your code and the main problem is reed "String line" in main program , not in cpp i want call line string that is in cpp to main arduino program (googledocs.ino).

mechanic98 commented 6 years ago

i search in the web: 1- extern String line; ---> in my main program 2- wirte a public class in header file

i test above , but i cant , becase arduio ide show me error please help me , please tanks

JhonControl commented 6 years ago

Hello, you need the data coming from google spreadsheets to return from the function in a string and to be able to use it from void main, correct. Give me some time to edit the library and try, ready. regards

mechanic98 commented 6 years ago

thanks a lot. i send my project for you after complate that. 🙏

On Sat, Oct 7, 2017 at 1:29 AM, Jhon Valencia notifications@github.com wrote:

Hello, you need the data coming from google spreadsheets to return from the function in a string and to be able to use it from void main, correct. Give me some time to edit the library and try, ready. regards

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JhonControl/ESP8266_GPIO_GoogleSpreadsheet/issues/1#issuecomment-334880307, or mute the thread https://github.com/notifications/unsubscribe-auth/AM000uWcumeGc8Ogcqukg8to6JCNDf7Vks5spqLUgaJpZM4Pw7FX .

mechanic98 commented 6 years ago

hi i change HTTPSRedirect.cpp and HTTPSRedirect.h and write a pubic class but stil , i can not show "myline" i my serial monitor. please see my code i uplod HTTPSRedirect.cpp , HTTPSRedirect.h and googledocs.ino in pasebin website

HTTPSRedirect.h: https://pastebin.com/RhNu7VxQ HTTPSRedirect.cpp https://pastebin.com/GAGe2HeN googledocs.ino https://pastebin.com/8u8GFnbX

when i want to print my line in serial monitor (googledocs.ino line:122) i see any things :( my line return line varable in line :177 that is in HTTPSRedirect.cpp

please help me tanks