Impossible to add my own plugin

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Waryard
Normal user
Posts: 18
Joined: 16 Nov 2018, 13:48

Impossible to add my own plugin

#1 Post by Waryard » 16 Nov 2018, 14:09

Hello everybody!

I just wrote a plugin (giant LED clock with RGB strip) with the example of another plugin and the template, but I can't see it in the device list (so obviously I can't use it)

I tried with and without "#ifdef USES_P421" and also with and without "#ifdef PLUGIN_BUILD_NORMAL"

I compile with the Arduino IDE and then flash the .bin file in OTA

I don't understand the problem because I added the plugin 203 (Feeder) who is pretty simple, it don't have "#ifdef USES_Pxxx" but with "#ifdef PLUGIN_BUILD_NORMAL" I see it in the devices list and I can perfectly use it

This is a part of my code (without my own functions)

Code: Select all

// Memo : LEDClock = 116 LEDs

////////// Includes //////////

#ifdef USES_P421

//#ifdef PLUGIN_BUILD_NORMAL

#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel *Plugin_421_pixels;

#define PLUGIN_421
#define PLUGIN_ID_421         421
#define PLUGIN_NAME_421       "LED Clock by Waryard"
//#define PLUGIN_VALUENAME1_421 ""

#ifndef CONFIG
#define CONFIG(n) (Settings.TaskDevicePluginConfig[event->TaskIndex][n])
#endif

////////// PROTOTYPE //////////

void printClock();
void printWord();
void printDigit(int digit, byte value, bool power, byte clockType);
void deleteDigit(int digit);
void pixelPrint(int pixelId, int forcedColorMode, bool animation);
void printSeconds();
bool isPair(int nb);
void deleteSeconds();
void InitAnim();

////////// Déclaration des variables //////////

/* My variables */

////////// PLUGIN //////////

boolean Plugin_421(byte function, struct EventStruct *event, String& string)
{
  boolean success = false;

  switch (function)
  {

    case PLUGIN_DEVICE_ADD:
    {
      Device[++deviceCount].Number = PLUGIN_ID_421;
        Device[deviceCount].Type = DEVICE_TYPE_SINGLE;  //how the device is connected
        Device[deviceCount].VType = SENSOR_TYPE_SWITCH; //type of value the plugin will return, used only for Domoticz
        Device[deviceCount].Ports = 0;
        Device[deviceCount].PullUpOption = false;
        Device[deviceCount].InverseLogicOption = false;
        Device[deviceCount].FormulaOption = false;
        Device[deviceCount].ValueCount = 0;             //number of output variables. The value should match the number of keys PLUGIN_VALUENAME1_xxx
        Device[deviceCount].SendDataOption = false;
        Device[deviceCount].TimerOption = false;
        Device[deviceCount].TimerOptional = false;
        Device[deviceCount].GlobalSyncOption = true;
        Device[deviceCount].DecimalsOnly = true;
        break;
    }

    case PLUGIN_GET_DEVICENAME:
    {
      string = F(PLUGIN_NAME_421);
      break;
    }

    case PLUGIN_GET_DEVICEVALUENAMES:
    {
      //strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_421));   // A commenter
      break;
    }

    case PLUGIN_WEBFORM_LOAD:
    {
      const String colorModeSelection[] = { F("3 Couleurs fixes"), F("3 Couleurs aléatoires"), F("6 Couleurs Aléatoires") };
      int indices[] = { 1, 2, 3 };

      addFormNumericBox(F("Led Count"), F("plugin_421_leds"), Settings.TaskDevicePluginConfig[event->TaskIndex][0],1,999);
      addFormPinSelect(F("GPIO"), F("taskdevicepin1"), Settings.TaskDevicePin1[event->TaskIndex]);
      addFormSelector(F("ColorMode"), F("plugin_421_colorMode"), 2, colorModeSelection, indices, Settings.TaskDevicePluginConfig[event->TaskIndex][1] );

      success = true;
      break;
    }

    case PLUGIN_WEBFORM_SAVE:
    {
      Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_421_leds"));
      MaxPixels = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
      Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_421_colorMode"));
      colorMode = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
      success = true;
      break;
    }

    case PLUGIN_INIT:
    {
      if (!Plugin_421_pixels)
      {
        Plugin_421_pixels = new Adafruit_NeoPixel(Settings.TaskDevicePluginConfig[event->TaskIndex][0], Settings.TaskDevicePin1[event->TaskIndex], NEO_GRB + NEO_KHZ800);
        Plugin_421_pixels->begin(); // This initializes the NeoPixel library.
      }
      MaxPixels = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
      success = true;
      break;
    }

    case PLUGIN_WRITE:
    {
      if (Plugin_421_pixels)
      {
        /*String command = parseString(string, 1);

        if (command == F("test"))
        {
          // Do something... later
        }*/

        String tmpString  = string;
        int argIndex = tmpString.indexOf(',');
        if (argIndex)
          tmpString = tmpString.substring(0, argIndex);

        if (tmpString.equalsIgnoreCase(F("LEDClockBrightness")))
        {
          brightness = event->Par1*10;
          printClock();
          printSeconds();
          success = true;
        }

        /*if (tmpString.equalsIgnoreCase(F("NeoPixelAll")))
        {
          // char Line[80];
          // char TmpStr1[80];
          // TmpStr1[0] = 0;
          // string.toCharArray(Line, 80);
          for (int i = 0; i < MaxPixels; i++)
          {
              Plugin_421_pixels->setPixelColor(i, Plugin_421_pixels->Color(event->Par1, event->Par2, event->Par3, event->Par4));
          }
          Plugin_421_pixels->show();
          success = true;
        }

        if (tmpString.equalsIgnoreCase(F("NeoPixelLine")))
        {
          // char Line[80];
          // char TmpStr1[80];
          // TmpStr1[0] = 0;
          // string.toCharArray(Line, 80);
          // int Par4 = 0;
          // int Par5 = 0;
          // if (GetArgv(Line, TmpStr1, 5)) Par4 = str2int(TmpStr1);
          // if (GetArgv(Line, TmpStr1, 6)) Par5 = str2int(TmpStr1);
          for (int i = event->Par1 - 1; i < event->Par2; i++)
          {
            Plugin_421_pixels->setPixelColor(i, Plugin_421_pixels->Color(event->Par3, event->Par4, event->Par5));
          }
          Plugin_421_pixels->show();
          success = true;
        }*/
      }
      break;
    }

    case PLUGIN_ONCE_A_SECOND:
    {
      if (second() == 0)
      {
        printClock();   // Changer l'heure
        deleteSeconds();  // Effacer les secondes
      }
      //Imprimer la seconde actuelle
    }

  }
  return success;
}

////////// Fonctions //////////

/* My own functions for displaying clock */
Sorry for my english, I'm french
Thank you all and have a good day!

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Impossible to add my own plugin

#2 Post by grovkillen » 16 Nov 2018, 14:16

What IDE?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Waryard
Normal user
Posts: 18
Joined: 16 Nov 2018, 13:48

Re: Impossible to add my own plugin

#3 Post by Waryard » 16 Nov 2018, 14:20

grovkillen wrote: 16 Nov 2018, 14:16What IDE?
Arduino IDE (version 1.8.5)
2018-11-16_14-18-45.jpg
2018-11-16_14-18-45.jpg (215.66 KiB) Viewed 7892 times

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Impossible to add my own plugin

#4 Post by grovkillen » 16 Nov 2018, 17:11

We use Platformio/Atom officially and load the plugins dynamically at compile time. If you want to use Arduino IDE you're left on your own since time is scarce on our side.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Waryard
Normal user
Posts: 18
Joined: 16 Nov 2018, 13:48

Re: Impossible to add my own plugin

#5 Post by Waryard » 17 Nov 2018, 18:15

grovkillen wrote: 16 Nov 2018, 17:11 We use Platformio/Atom officially and load the plugins dynamically at compile time. If you want to use Arduino IDE you're left on your own since time is scarce on our side.
I really don't understand why. Arduino IDE compile fine and I added the playground plugin Feeder in the source folder then compile with Arduino IDE and I can see and use the plugin once I Have uploaded the new bin firmware

Why should I use Platformio (which is more complicated) if the Arduino IDE works well? What is the relationship with my problem ?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Impossible to add my own plugin

#6 Post by grovkillen » 17 Nov 2018, 19:13

You're free to use whatever you like. ;) I just say that Platformio.ini is the setup file we use officially.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Waryard
Normal user
Posts: 18
Joined: 16 Nov 2018, 13:48

Re: Impossible to add my own plugin

#7 Post by Waryard » 17 Nov 2018, 20:29

grovkillen wrote: 17 Nov 2018, 19:13 You're free to use whatever you like. ;) I just say that Platformio.ini is the setup file we use officially.
Okay, good! I thought there might be a compatibility issue with user code while compiling with Arduino IDE
I will try to compile via Platformio soon, to be sure that it is not the fault of Arduino IDE
did you eventually find an obvious error in my code that could be the cause of not appearing my plugin in the Devices list ?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Impossible to add my own plugin

#8 Post by grovkillen » 17 Nov 2018, 21:21

No #endif ?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Waryard
Normal user
Posts: 18
Joined: 16 Nov 2018, 13:48

Re: Impossible to add my own plugin

#9 Post by Waryard » 17 Nov 2018, 21:41

grovkillen wrote: 17 Nov 2018, 21:21 No #endif ?
Oh, at the bottom of my code I have one #endif for #ifdef USES_P421 and one disabled (commented) #endif for #ifdef PLUGIN_BUILD_NORMAL (this line is also disabled), this two lines are after my functions so I forgot to copy/paste it here

Waryard
Normal user
Posts: 18
Joined: 16 Nov 2018, 13:48

Re: Impossible to add my own plugin

#10 Post by Waryard » 19 Nov 2018, 02:04

Hello,

I have installed Atom, Platformio and some packages, I just spend 4 hours trying hundred things, nothing worked

- Totally impossible to build Mega release, I have always the error "Environment normal_ESP8266_4096 [ERROR]" without any further informations.
- With v2.0 release, it compile fine but once I uploaded the .bin file in OTA, the built-in LED doesn't turn on anymore, and I can't see my plugin in the Devices list.
- With v2.0 release uploaded via USB, the built-in LED works fine (as always) but my plugin isn't displayed in the Devices list.

The plugin 42 Candle is totally unusable (once it is selected, the configuration web page is empty after the GPIO selection (but when I move to another page (like the Devices list), all the settings appear for 1sec before the new page is loaded)
So, because I don't use this plugin and he is displayed in the device list, I tried to replace the code of Candle plugin by my code (just to see if it will be displayed)
Result : The Candle plugin disappears from the Devices list.

I don't know what to do next, for this moment I use an Arduino Uno with DS3231 but I would like to use ESPEasy instead, if ESPEasy would accept my plugin....

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Impossible to add my own plugin

#11 Post by grovkillen » 19 Nov 2018, 06:00

Send me your files and I'll try to compile it myself.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:


Waryard
Normal user
Posts: 18
Joined: 16 Nov 2018, 13:48

Re: Impossible to add my own plugin

#13 Post by Waryard » 21 Nov 2018, 15:59

I solved the problem by myself. Now my code is private.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Impossible to add my own plugin

#14 Post by grovkillen » 21 Nov 2018, 16:34

Sorry! I didn't get the time for it (busy at work). Great that you got it sorted!

I will get more time to spend on this project soon.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Waryard
Normal user
Posts: 18
Joined: 16 Nov 2018, 13:48

Re: Impossible to add my own plugin

#15 Post by Waryard » 21 Nov 2018, 16:40

No problem, I understand ;) Now I can work on it and apply the changes in real-time on the clock, when I've corrected everything (and get the clock working) and implemented the letters for displaying messages via URL it will be back on Github, actually the plugin is not usable

Post Reply

Who is online

Users browsing this forum: No registered users and 110 guests