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 */
Thank you all and have a good day!