1

Topic: edit library >>>>help

hi everyone
i use node mcu esp8266
I've got a class can set time-off and time-on for led without delay function, but when i add it to my sketch and upload it to nodemcu
my phone can't see it's wifi network .
the class is working very well with UNO,
can i add the class to remotexy library and make it work with the app.
or any way to make it work please .


the class and void setup and loop is

class Flasher
{
    // Class Member Variables
    // These are initialized at startup
    int ledPin;      // the number of the LED pin
    long OnTime;     // milliseconds of on-time
    long OffTime;    // milliseconds of off-time

    // These maintain the current state
    int ledState;                     // ledState used to set the LED
    unsigned long previousMillis;      // will store last time LED was updated

  // Constructor - creates a Flasher 
  // and initializes the member variables and state
  public:
  Flasher(int pin, long on, long off)
  {
    ledPin = pin;
    pinMode(ledPin, OUTPUT);     
      
    OnTime = on;
    OffTime = off;
    
    ledState = LOW; 
    previousMillis = 0;
  }

  void Update()
  {
    // check to see if it's time to change the state of the LED
    unsigned long currentMillis = millis();
     
    if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
    {
        ledState = LOW;  // Turn it off
      previousMillis = currentMillis;  // Remember the time
      digitalWrite(ledPin, ledState);  // Update the actual LED
    }
    else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
    {
      ledState = HIGH;  // turn it on
      previousMillis = currentMillis;   // Remember the time
      digitalWrite(ledPin, ledState);      // Update the actual LED
    }
  }
};


Flasher led1(12, 100, 400);
Flasher led2(13, 350, 350);

void setup()
{
}

void loop()
{
    led1.Update();
    led2.Update();
}

2

Re: edit library >>>>help

Hello,

Show your complete sketch, because in the code you posted there is nothing about wifi or remotexy.

3

Re: edit library >>>>help

thanks for your replay
actually i found another way to do what i need-control led on and off time with milis() by remotexy app-
but it almost done
i'll paste a link under the codes of the video about the problem

the codes are


first one with arduino uno and 2 potentiometer

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

int ledPin =  8;      // the number of the LED pin
int ledState = LOW;             // ledState used to set the LED
unsigned long previousMillis = 0;        // will store last time LED was updated


void setup() {
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  lcd.init();
  lcd.backlight();

}

void loop() {
  unsigned long currentMillis = millis();
  long OnTime = analogRead(A0);
  long OffTime = analogRead(A1);


  Serial.println(OnTime);
  Serial.println(OffTime);


  // check to see if it's time to change the state of the LED

  if ((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
  {
    ledState = LOW;  // Turn it off
    previousMillis = currentMillis;  // Remember the time
    digitalWrite(ledPin, ledState);  // Update the actual LED
  }

  else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
  {
    ledState = HIGH;  // turn it on
    previousMillis = currentMillis;   // Remember the time
    digitalWrite(ledPin, ledState);    // Update the actual LED
  }
lcd.setCursor(0,0);
  lcd.print("on time = ");
    lcd.print(OnTime);



  lcd.setCursor(0,1);
  lcd.print("off time = ");
    lcd.print(OffTime);
}

and the second one-which i need- is with remotexy app

/*
   -- test --

   This source code of graphical user interface
   has been generated automatically by RemoteXY editor.
   To compile this code using RemoteXY library 2.4.3 or later version
   download by link http://remotexy.com/en/library/
   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
     - for ANDROID 4.3.1 or later version;
     - for iOS 1.3.5 or later version;

   This source code is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.
*/

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
#include <ESP8266WiFi.h>

#include <RemoteXY.h>

// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "RemoteXY"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377


// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255, 3, 0, 22, 0, 113, 0, 8, 13, 1,
  4, 0, 11, 12, 12, 64, 2, 26, 2, 0,
  19, 87, 22, 11, 2, 26, 31, 31, 79, 78,
  0, 79, 70, 70, 0, 4, 0, 41, 12, 12,
  64, 2, 26, 129, 0, 37, 78, 18, 6, 24,
  111, 102, 102, 32, 116, 105, 109, 101, 0, 129,
  0, 6, 78, 22, 6, 24, 111, 110, 32, 116,
  105, 109, 101, 0, 67, 5, 6, 5, 20, 5,
  2, 26, 11, 67, 5, 38, 5, 20, 5, 2,
  26, 11, 129, 0, 11, 11, 11, 3, 1, 115,
  101, 99, 111, 110, 100, 0, 129, 0, 43, 11,
  11, 3, 1, 115, 101, 99, 111, 110, 100, 0
};

// this structure defines all the variables of your control interface
struct {

  // input variable
  int8_t slider_on_time; // =0..100 slider position
  uint8_t switch_1; // =1 if switch ON and =0 if OFF
  int8_t slider_off_time; // =0..100 slider position

  // output variable
  char text_on_time[11];  // string UTF8 end zero
  char text_off_time[11];  // string UTF8 end zero

  // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

int ledPin =  D3;   //led pin to D2
int ledState = LOW;
unsigned long previousMillis = 0;


void setup()
{
  RemoteXY_Init ();
  pinMode(ledPin, OUTPUT);
lcd.init();
  lcd.backlight();
}

void loop()
{
  RemoteXY_Handler ();
  unsigned long currentMillis = millis();
  long Ont;
  long Offt;
  long OnTime = Ont;
  long OffTime = Offt;

  
  Ont = map (RemoteXY. slider_on_time , 0 , 100 , 0 , 5000 ) ;
  float ont = (float)Ont;                                          //convert long to float
  float v1_1n = ont / 1000;
  dtostrf(v1_1n, 0, 1, RemoteXY.text_on_time);                     //convert float to char

  Offt = map (RemoteXY. slider_off_time , 0 , 100 , 0 , 5000 ) ;
  float offt = (float)Offt;                                     //convert long to float
  float  v1_2n = offt / 1000;
  dtostrf(v1_2n, 0, 1, RemoteXY.text_off_time);                  //convert float to char


  
    if ((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
    {
      ledState = LOW;  // Turn it off
      previousMillis = currentMillis;  // Remember the time
      digitalWrite(ledPin, ledState);  // Update the actual LED
    }
    else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
    {
      ledState = HIGH; // turn it on
      previousMillis = currentMillis;   // Remember the time
      digitalWrite(ledPin, ledState);    // Update the actual LED
    }
  
  else {
    digitalWrite(ledPin, 0);
  }
  
lcd.setCursor(0,0);
  lcd.print("on time = ");
    lcd.print(v1_1n);



  lcd.setCursor(0,1);
  lcd.print("off time = ");
    lcd.print(v1_2n);
}

i used the code below with each code above

int ledPin1 =  12;      // the number of the LED pin
int ledState1 = LOW;             // ledState used to set the LED
unsigned long previousMillis1 = 0;        // will store last time LED was updated
long OnTime1 = 250;           // milliseconds of on-time
long OffTime1 = 750;          // milliseconds of off-time

int ledPin2 =  13;      // the number of the LED pin
int ledState2 = LOW;             // ledState used to set the LED
unsigned long previousMillis2 = 0;        // will store last time LED was updated
long OnTime2 = 330;           // milliseconds of on-time
long OffTime2 = 400;          // milliseconds of off-time

void setup() 
{
  // set the digital pin as output:
  pinMode(ledPin1, OUTPUT);      
  pinMode(ledPin2, OUTPUT);      
}

void loop()
{
  // check to see if it's time to change the state of the LED
  unsigned long currentMillis = millis();
 
  if((ledState1 == HIGH) && (currentMillis - previousMillis1 >= OnTime1))
  {
    ledState1 = LOW;  // Turn it off
    previousMillis1 = currentMillis;  // Remember the time
    digitalWrite(ledPin1, ledState1);  // Update the actual LED
  }
  else if ((ledState1 == LOW) && (currentMillis - previousMillis1 >= OffTime1))
  {
    ledState1 = HIGH;  // turn it on
    previousMillis1 = currentMillis;   // Remember the time
    digitalWrite(ledPin1, ledState1);      // Update the actual LED
  }
  
  if((ledState2 == HIGH) && (currentMillis - previousMillis2 >= OnTime2))
  {
    ledState2 = LOW;  // Turn it off
    previousMillis2 = currentMillis;  // Remember the time
    digitalWrite(ledPin2, ledState2);  // Update the actual LED
  }
  else if ((ledState2 == LOW) && (currentMillis - previousMillis2 >= OffTime2))
  {
    ledState2 = HIGH;  // turn it on
    previousMillis2 = currentMillis;   // Remember the time
    digitalWrite(ledPin2, ledState2);      // Update the actual LED
  }
}

video link
https://gofile.io/?c=hQHEW1