Disable device for 3 sec from rule

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Disable device for 3 sec from rule

#1 Post by mackowiakp » 12 May 2021, 06:17

I have have several sensors connected to ESP, including 20x4 LCD, ultrasonic sensor (working as a switch) and ordinary push on button.
Ultrasonic sensor is time consuming device and LCD is slow device so both "disable" processor for a while.
If in the same moment something is loaded to LCD, ultrasonic is working constantly of course and I try to do double click on push-on button, it sometimes does not recognize double click and takes it as a long press.
If ultrasonic disabled manually from menu, everything works correctly.
Is any possibility to disable ultrasonic for 3 sec from rule for proper recognize double click?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#2 Post by TD-er » 12 May 2021, 10:16

See: https://espeasy.readthedocs.io/en/lates ... l-commands
TaskEnable / TaskDisable.
So in the rules you can act on some event (e.g. a button press) and disable the task + set a timer for 3 seconds. (command TimerSet)
On the timer event you enable it again.

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#3 Post by mackowiakp » 12 May 2021, 11:56

Hmmm. My FW is probably too old. mega-20191208

Code: Select all

Command unknown: "taskenable,5"

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#4 Post by TD-er » 12 May 2021, 12:11

Yep, probably.
But I did give you one recently which got really positive reviews :)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#5 Post by mackowiakp » 12 May 2021, 12:16

:D

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#6 Post by mackowiakp » 15 May 2021, 20:12

Yep it works !
There is only one problem. You made some tweaks to some software that does not yet have official release.
The compiled FW version you sent me in this post https://www.letscontrolit.com/forum/vi ... 28#p52439 did not have a directive in Custom.h

Code: Select all

#define USES_P012_POLISH_CHARS
Would you be so kind and could you compile the same for me but with the above directive?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#7 Post by TD-er » 15 May 2021, 20:54

New build:
https://www.dropbox.com/s/z3blareqkux85 ... M.bin?dl=0

It also has the latest changes from Ton included for P012 with a new "button inversed" option.
So test it first on a 'reachable' node, as I just used the latest source code of today.
Just to be sure, so there will be no new bugs. You know that if you don't test it first on a reachable node, you will introduce new bugs.
Schreudinger, Heisenberg and Murphy will all agree on that, albeit for different reasons :)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#8 Post by mackowiakp » 16 May 2021, 09:08

I just downloaded new FW on test device, but Polish letters are not display

LCD config:
Screenshot_20210516_090113.png
Screenshot_20210516_090113.png (75.79 KiB) Viewed 8641 times
Display result:
Attachments
Letters.jpg
Letters.jpg (4.8 MiB) Viewed 8641 times

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#9 Post by mackowiakp » 16 May 2021, 09:34

One more problem I noticed with this FW.
If reboot will be done from the "Tools" menu either by command or by clicking menu option, ESP will not connect to the network.
You have to do power cycle.

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Disable device for 3 sec from rule

#10 Post by Ath » 16 May 2021, 13:30

mackowiakp wrote: 16 May 2021, 09:34 One more problem I noticed with this FW.
If reboot will be done from the "Tools" menu either by command or by clicking menu option, ESP will not connect to the network.
You have to do power cycle.
That must be related to your hardware or network, working here as expected.
Do you have any (serial) log available from your NodeMCU during that reboot?
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Disable device for 3 sec from rule

#11 Post by Ath » 16 May 2021, 13:40

Please try attached (Custom) .bin file, with USES_P012_POLISH_CHARS enabled during compilation.

Reboot command should also work (tested this build on a Wemos D1 mini clone).
Attachments
ESP_Easy_mega_20210516_custom_ESP8266_4M1M.zip
(652.38 KiB) Downloaded 131 times
/Ton (PayPal.me)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#12 Post by mackowiakp » 16 May 2021, 14:52

With this software above, there is no problems with connection to WiFi AP after intended soft reboot.
But still no Polish letters as on photo already posted.
Two test devices was used in this case. Node MCU v2 and v3. Practically no difference between units but from different producer (probably).
To install and test on target device I need additionally "Position - HC-SR04, RCW-0001, etc." named device, that is _P013_HCSR04.
Dont know is it difference (probably no) for tests I use 2x16 LCD but target device has 4x20 LCD.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#13 Post by TD-er » 16 May 2021, 20:07

Hmm what system was Ath's version built on?
I assume it is also built from the same point in the 'mega' branch?
Seeing "WiFi issues" which differ from build to build using the same sources are things I get nightmares from if I think back to those issues in the past.

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Disable device for 3 sec from rule

#14 Post by Ath » 16 May 2021, 21:12

TD-er wrote: 16 May 2021, 20:07 Hmm what system was Ath's version built on?
I assume it is also built from the same point in the 'mega' branch?
Yes, current mega state plus some local development stuff, absolutely not related to WiFi (I try to stay away from that as much as possible).
/Ton (PayPal.me)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#15 Post by mackowiakp » 17 May 2021, 03:50

I revert for additional test to FW from this previous link:

https://www.dropbox.com/s/z3blareqkux85 ... M.bin?dl=0

What I notice by testing bit longer (using NodeMCU v2 and 3) is WiFi connection problem again. Connection to AP was finally established, but it takes appx. 12-15 min.
Using the last posted FW, such connection take place just in several sec, including reboot procedure.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#16 Post by TD-er » 17 May 2021, 08:49

"Including reboot" as in power cycle?
If not, then it is using the last used connection stored in RTC memory.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#17 Post by TD-er » 17 May 2021, 09:12

I just kept thinking of why the Polish char set is not included in the build.
The only thing I can come up with is that the #ifdef check is done in the .ino file.
So maybe we should move this P012_parseTemplate function to the P012_data_struct file.
That way we can absolutely be sure the defines are properly set when compiling it.

I also plan to do this for the setup() and loop() functions in ESPEasy.ino, as I am really done with the fact (!!!) the build stability is related to the order files are compiled and linked.
Especially with WiFi this flaky behavior is obvious, but now you can also see it in the missing Polish character set decoding.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#18 Post by TD-er » 17 May 2021, 09:26

Can you test this build: https://www.dropbox.com/s/xk04vkay9fu3s ... M.bin?dl=0
The WiFi issues are probably not fixed, but at least the Polish characters should be included. (based on your Custom.h)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#19 Post by mackowiakp » 17 May 2021, 09:49

Still no Polish letters. Did not notice WiFi issue.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#20 Post by TD-er » 17 May 2021, 09:53

The exact same strings (so exact same settings, without changing) do run on an older version of ESPEasy?
Just to make sure we're not looking at some strange unicode issue here.

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#21 Post by mackowiakp » 17 May 2021, 10:38

I test Your current binary on NodeMCU with 2x16 LCD while target unit (properly displying Polish characters) use 4x20 LCD and mega-20191208 sources.

Also be so kind to include in Custom.h driver _P013_HCSR04 (ultrasonic sensor).
I would like to quote one of my very old posts here with (i think very important notice).
Perhaps depending on the item, the LCD displays differs in the way of programming?
The problem is that it is possibility to define only 8 characters while in my language are 18 characters different to ASCII (9 lower and 9 upper case).
At this moment definitions are static. So now I work on possibility to dynamically define such characters. Of course at the one "page" of display there will be always possibility to use only 8 from 18 characters. But it is enough.
During this work, I came across an obstacle that I "fought" for quite a long time.
Well, if we define anything on the address 0x00 CGRAM, then this character is displayed as "null" (not "space") and the character defined on the address 0x01 is distorted.
However, if we define the same character at address 0x00 and at the same time at address 0x08 (which according to docu is not possible), then the character with address 0x00 is still displayed as "null" but the character with address 0x08 is displayed correctly. In addition, the character with address 0x01 is not distorted.

I realize that all what I write here is completely incompatible with the documentation or examples that are available on the Internet. I wonder now. Is it the fault of particular display copies I bought or is it some "undocumented feature" of the LiquidCrystal_I2C.h library. In particular the lcd.createChar command. Or maybe something else?
And properly working LCD as a photo:
LCD.jpg
LCD.jpg (49.68 KiB) Viewed 8553 times
And LCD driver dedicated for mega-20191208 (_P012_LCD.ino) working properly.

Code: Select all

#ifdef USES_P012
//#######################################################################################################
//#################################### Plugin 012: LCD ##################################################
//#######################################################################################################

// Sample templates
//  Temp: [DHT11#Temperature]   Hum:[DHT11#humidity]
//  DS Temp:[Dallas1#Temperature#R]
//  Lux:[Lux#Lux#R]
//  Baro:[Baro#Pressure#R]
//  Pump:[Pump#on#O] -> ON/OFF
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C *lcd=NULL;
int Plugin_012_cols = 16;
int Plugin_012_rows = 2;
int Plugin_012_mode = 1;

#define PLUGIN_012
#define PLUGIN_ID_012         12
#define PLUGIN_NAME_012       "Display - LCD2004"
#define PLUGIN_VALUENAME1_012 "LCD"

#define P12_Nlines 4        // The number of different lines which can be displayed
#define P12_Nchars 80

byte LETTER_null[8] = { // spacja 
  0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000
};
byte LETTER_a[8] = { // a
  0b00000, 0b00000, 0b01110, 0b00001, 0b01111, 0b10001, 0b01111, 0b00010
};
byte LETTER_c[8] = { // c
  0b00010, 0b00100, 0b01110, 0b10000, 0b10000, 0b10001, 0b01110, 0b00000
};
byte LETTER_e[8] = { // e
  0b00000, 0b00000, 0b01110, 0b10001, 0b11111, 0b10000, 0b01110, 0b00010
};
byte LETTER_l[8] = { // l
  0b01100, 0b00100, 0b00101, 0b00110, 0b01100, 0b00100, 0b01110, 0b00000
};
byte LETTER_n[8] = { // n
  0b00010, 0b00100, 0b10110, 0b11001, 0b10001, 0b10001, 0b10001, 0b00000
};
byte LETTER_o[8] = { // o
  0b00010, 0b00100, 0b01110, 0b10001, 0b10001, 0b10001, 0b01110, 0b00000
};
byte LETTER_s[8] = { // s
  0b00010, 0b00100, 0b01110, 0b10000, 0b01110, 0b00001, 0b11110, 0b00000
};
byte LETTER_z1[8] = { // z z kreska
  0b00010, 0b00100, 0b11111, 0b00010, 0b00100, 0b01000, 0b11111, 0b00000
};
byte LETTER_z2[8] = { // z z kropka
  0b00100, 0b00000, 0b11111, 0b00010, 0b00100, 0b01000, 0b11111, 0b00000
};
byte LETTER_A[8] = { // A duze
  0b01110, 0b10001, 0b10001, 0b10001, 0b11111, 0b10001, 0b10001, 0b00010
};
byte LETTER_C[8] = { // C duze
  0b00010, 0b01110, 0b10001, 0b10000, 0b10000, 0b10001, 0b01110, 0b00000
};
byte LETTER_E[8] = { // E duze
  0b11111, 0b10000, 0b10000, 0b11110, 0b10000, 0b10000, 0b11111, 0b00010
};
byte LETTER_L[8] = { // L duze
  0b10000, 0b10000, 0b10010, 0b10100, 0b11000, 0b10000, 0b11111, 0b00000
};
byte LETTER_N[8] = { // N duze
  0b00010, 0b10101, 0b10001, 0b11001, 0b10101, 0b10011, 0b10001, 0b00000
};
byte LETTER_O[8] = { // O duze
  0b00010, 0b01110, 0b10101, 0b10001, 0b10001, 0b10001, 0b01110, 0b00000
};
byte LETTER_S[8] = { // S duze
  0b00010, 0b01111, 0b10100, 0b10000, 0b01110, 0b00001, 0b11110, 0b00000
};
byte LETTER_Z1[8] = { // Z z kreska
  0b00100, 0b11111, 0b01001, 0b00010, 0b00100, 0b01000, 0b11111, 0b00000
};
byte LETTER_Z2[8] = { // Z z kropka
  0b00100, 0b11111, 0b00001, 0b00010, 0b00100, 0b01000, 0b11111, 0b00000
};

boolean Plugin_012(byte function, struct EventStruct *event, String& string)
{
  boolean success = false;
  static byte displayTimer = 0;

  switch (function)
  {

    case PLUGIN_DEVICE_ADD:
      {
        Device[++deviceCount].Number = PLUGIN_ID_012;
        Device[deviceCount].Type = DEVICE_TYPE_I2C;
        Device[deviceCount].VType = SENSOR_TYPE_NONE;
        Device[deviceCount].Ports = 0;
        Device[deviceCount].PullUpOption = false;
        Device[deviceCount].InverseLogicOption = false;
        Device[deviceCount].FormulaOption = false;
        Device[deviceCount].ValueCount = 0;
        Device[deviceCount].SendDataOption = false;
        Device[deviceCount].TimerOption = true;
        break;
      }

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

    case PLUGIN_GET_DEVICEVALUENAMES:
      {
        strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_012));
        break;
      }

    case PLUGIN_WEBFORM_LOAD:
      {
        byte choice = PCONFIG(0);
        //String options[16];
        int optionValues[16];
        for (byte x = 0; x < 16; x++)
        {
          if (x < 8)
            optionValues[x] = 0x20 + x;
          else
            optionValues[x] = 0x30 + x;
          //options[x] = F("0x");
          //options[x] += String(optionValues[x], HEX);
        }
        addFormSelectorI2C(F("p012_adr"), 16, optionValues, choice);


        byte choice2 = PCONFIG(1);
        String options2[2];
        options2[0] = F("2 x 16");
        options2[1] = F("4 x 20");
        int optionValues2[2] = { 1, 2 };
        addFormSelector(F("Display Size"), F("p012_size"), 2, options2, optionValues2, choice2);

        {
          String strings[P12_Nlines];
          LoadCustomTaskSettings(event->TaskIndex, strings, P12_Nlines, P12_Nchars);
          for (byte varNr = 0; varNr < P12_Nlines; varNr++)
          {
            addFormTextBox(String(F("Line ")) + (varNr + 1), getPluginCustomArgName(varNr), strings[varNr], P12_Nchars);
          }
        }

        addRowLabel(F("Display button"));
        addPinSelect(false, F("taskdevicepin3"), CONFIG_PIN3);

        addFormNumericBox(F("Display Timeout"), F("p012_timer"), PCONFIG(2));

        String options3[3];
        options3[0] = F("Continue to next line (as in v1.4)");
        options3[1] = F("Truncate exceeding message");
        options3[2] = F("Clear then truncate exceeding message");
        int optionValues3[3] = { 0,1,2 };
        addFormSelector(F("LCD command Mode"), F("p012_mode"), 3, options3, optionValues3, PCONFIG(3));

        success = true;
        break;
      }

    case PLUGIN_WEBFORM_SAVE:
      {
        PCONFIG(0) = getFormItemInt(F("p012_adr"));
        PCONFIG(1) = getFormItemInt(F("p012_size"));
        PCONFIG(2) = getFormItemInt(F("p012_timer"));
        PCONFIG(3) = getFormItemInt(F("p012_mode"));

        char deviceTemplate[P12_Nlines][P12_Nchars];
        String error;
        for (byte varNr = 0; varNr < P12_Nlines; varNr++)
        {
          if (!safe_strncpy(deviceTemplate[varNr], WebServer.arg(getPluginCustomArgName(varNr)), P12_Nchars)) {
            error += getCustomTaskSettingsError(varNr);
          }
        }
        if (error.length() > 0) {
          addHtmlError(error);
        }
        SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
        success = true;
        break;
      }

    case PLUGIN_INIT:
      {
        if (PCONFIG(1) == 2) {
          Plugin_012_rows = 4;
          Plugin_012_cols = 20;
        } else if (PCONFIG(1) == 1) {
          Plugin_012_rows = 2;
          Plugin_012_cols = 16;
        }

        Plugin_012_mode = PCONFIG(3);

        //TODO:LiquidCrystal_I2C class doesn't have destructor. So if LCD type (size) is changed better reboot for changes to take effect.
        // workaround is to fix the cols and rows at its maximum (20 and 4)
        if (!lcd)
          lcd = new LiquidCrystal_I2C(PCONFIG(0), 20, 4); //Plugin_012_cols, Plugin_012_rows);

        // Setup LCD display
        lcd->init();                      // initialize the lcd
        lcd->backlight();
        lcd->print(F("Czekaj...")); 
        lcd->createChar(0,LETTER_o); // komorka pamieci uszkodzona zastapiona przez 8
        lcd->createChar(1,LETTER_l); 
        lcd->createChar(2,LETTER_e);
        lcd->createChar(3,LETTER_c);
        lcd->createChar(4,LETTER_n);
        lcd->createChar(5,LETTER_a);
        lcd->createChar(6,LETTER_s);
        lcd->createChar(7,LETTER_z2);
        lcd->createChar(8,LETTER_o);

        displayTimer = PCONFIG(2);
        if (CONFIG_PIN3 != -1)
          pinMode(CONFIG_PIN3, INPUT_PULLUP);
        success = true;
        break;
      }

    case PLUGIN_TEN_PER_SECOND:
      {
        if (CONFIG_PIN3 != -1)
        {
          if (!digitalRead(CONFIG_PIN3))
          {
            if (lcd) {
              lcd->backlight();
            }
            displayTimer = PCONFIG(2);
          }
        }
        break;
      }

    case PLUGIN_ONCE_A_SECOND:
      {
        if ( displayTimer > 0)
        {
          displayTimer--;
          if (lcd && displayTimer == 0)
            lcd->noBacklight();
        }
        break;
      }

    case PLUGIN_READ:
      {
        char deviceTemplate[P12_Nlines][P12_Nchars];
        LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));

        for (byte x = 0; x < Plugin_012_rows; x++)
        {
          String tmpString = deviceTemplate[x];
          if (lcd && tmpString.length())
          {
            String newString = P012_parseTemplate(tmpString, Plugin_012_cols);
            lcd->setCursor(0, x);
            lcd->print(newString);
          }
        }
        success = false;
        break;
      }

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

        if (lcd && tmpString.equalsIgnoreCase(F("LCDCMD")))
        {
          success = true;
          argIndex = string.lastIndexOf(',');
          tmpString = string.substring(argIndex + 1);
          if (tmpString.equalsIgnoreCase(F("Off"))){
              lcd->noBacklight();
          }
          else if (tmpString.equalsIgnoreCase(F("On"))){
              lcd->backlight();
          }
          else if (tmpString.equalsIgnoreCase(F("Clear"))){
              lcd->clear();
          }
        }
        else if (lcd && tmpString.equalsIgnoreCase(F("LCD")))
        {
          success = true;
          tmpString = P012_parseTemplate(string, Plugin_012_cols);
          argIndex = tmpString.lastIndexOf(',');
          tmpString = tmpString.substring(argIndex + 1);

          int colPos = event->Par2 - 1;
          int rowPos = event->Par1 - 1;

          //clear line before writing new string
          if (Plugin_012_mode == 2){
              lcd->setCursor(colPos, rowPos);
              for (byte i = colPos; i < Plugin_012_cols; i++) {
                  lcd->print(" ");
              }
          }

          // truncate message exceeding cols
          lcd->setCursor(colPos, rowPos);
          if(Plugin_012_mode == 1 || Plugin_012_mode == 2){
              lcd->setCursor(colPos, rowPos);
              for (byte i = 0; i < Plugin_012_cols - colPos; i++) {
                  if(tmpString[i]){
                     lcd->print(tmpString[i]);
                  }
              }
          }

          // message exceeding cols will continue to next line
          else{
              // Fix Weird (native) lcd display behaviour that split long string into row 1,3,2,4, instead of 1,2,3,4
              boolean stillProcessing = 1;
              byte charCount = 1;
              while(stillProcessing) {
                   if (++colPos > Plugin_012_cols) {    // have we printed 20 characters yet (+1 for the logic)
                        rowPos += 1;
                        lcd->setCursor(0,rowPos);   // move cursor down
                        colPos = 1;
                   }

                   //dont print if "lower" than the lcd
                   if(rowPos < Plugin_012_rows  ){
                       lcd->print(tmpString[charCount - 1]);
                   }

                   if (!tmpString[charCount]) {   // no more chars to process?
                        stillProcessing = 0;
                   }
                   charCount += 1;
              }
              //lcd->print(tmpString.c_str());
              // end fix
          }

        }
        break;
      }

  }
  return success;
}

// Perform some specific changes for LCD display
// https://www.letscontrolit.com/forum/viewtopic.php?t=2368
String P012_parseTemplate(String &tmpString, byte lineSize) {
  String result = parseTemplate(tmpString, lineSize);
  const char degree[3] = {0xc2, 0xb0, 0};  // Unicode degree symbol
  const char degree_lcd[2] = {0xdf, 0};  // P012_LCD degree symbol
  result.replace(degree, degree_lcd);

    // See: https://github.com/letscontrolit/ESPEasy/issues/2081

  const char znak_a_uni[3] = {0xc4, 0x85, 0}; // Unicode znak a
  const char znak_a_lcd[2] = {0x05, 0}; // P012_LCD znak a
  result.replace(znak_a_uni, znak_a_lcd);

  const char znak_A_uni[3] = {0xc4, 0x84, 0}; // Unicode znak A
  result.replace(znak_A_uni, znak_a_lcd);

  const char znak_c_uni[3] = {0xc4, 0x87, 0}; // Unicode znak c
  const char znak_c_lcd[2] = {0x03, 0}; // P012_LCD znak c
  result.replace(znak_c_uni, znak_c_lcd);

  const char znak_C_uni[3] = {0xc4, 0x86, 0}; // Unicode znak C
  result.replace(znak_C_uni, znak_c_lcd);

  const char znak_e_uni[3] = {0xc4, 0x99, 0}; // Unicode znak e
  const char znak_e_lcd[2] = {0x02, 0}; // P012_LCD znak e
  result.replace(znak_e_uni, znak_e_lcd);

  const char znak_E_uni[3] = {0xc4, 0x98, 0}; // Unicode znak E
  result.replace(znak_E_uni, znak_e_lcd);

  const char znak_l_uni[3] = {0xc5, 0x82, 0}; // Unicode znak l
  const char znak_l_lcd[2] = {0x01, 0}; // P012_LCD znak l
  result.replace(znak_l_uni, znak_l_lcd);

  const char znak_L_uni[3] = {0xc5, 0x81, 0}; // Unicode znak L
  result.replace(znak_L_uni, znak_l_lcd);

  const char znak_n_uni[3] = {0xc5, 0x84, 0}; // Unicode znak n
  const char znak_n_lcd[2] = {0x04, 0}; // P012_LCD znak n
  result.replace(znak_n_uni, znak_n_lcd);

  const char znak_N_uni[3] = {0xc5, 0x83, 0}; // Unicode znak N
  result.replace(znak_N_uni, znak_n_lcd);

  const char znak_o_uni[3] = {0xc3, 0xB3, 0}; // Unicode znak o
  const char znak_o_lcd[2] = {0x08, 0}; // P012_LCD znak o
  result.replace(znak_o_uni, znak_o_lcd);

  const char znak_O_uni[3] = {0xc3, 0x93, 0}; // Unicode znak O
  result.replace(znak_O_uni, znak_o_lcd);

  const char znak_s_uni[3] = {0xc5, 0x9b, 0}; // Unicode znak s
  const char znak_s_lcd[2] = {0x06, 0}; // P012_LCD znak s
  result.replace(znak_s_uni, znak_s_lcd);

  const char znak_S_uni[3] = {0xc5, 0x9a, 0}; // Unicode znak S
  result.replace(znak_S_uni, znak_s_lcd);

  const char znak_z1_uni[3] = {0xc5, 0xba, 0}; // Unicode znak z z kreska
  const char znak_z1_lcd[2] = {0x07, 0}; // P012_LCD znak z z kropka
  result.replace(znak_z1_uni, znak_z1_lcd);

  const char znak_Z1_uni[3] = {0xc5, 0xb9, 0}; // Unicode znak Z z kreska
  result.replace(znak_Z1_uni, znak_z1_lcd);

  const char znak_z2_uni[3] = {0xc5, 0xbc, 0}; // Unicode znak z z kropka
  const char znak_z2_lcd[2] = {0x07, 0}; // P012_LCD znak z z kropka
  result.replace(znak_z2_uni, znak_z2_lcd);

  const char znak_Z2_uni[3] = {0xc5, 0xbb, 0}; // Unicode znak Z z kropka
  result.replace(znak_Z2_uni, znak_z2_lcd);

   char unicodePrefix = 0xc3;
  if (result.indexOf(unicodePrefix) != -1) {
    // See: https://github.com/letscontrolit/ESPEasy/issues/2081

    const char umlautAE_uni[3] = {0xc3, 0x84, 0}; // Unicode Umlaute AE
    const char umlautAE_lcd[2] = {0xe1, 0}; // P012_LCD Umlaute
    result.replace(umlautAE_uni, umlautAE_lcd);

    const char umlaut_ae_uni[3] = {0xc3, 0xa4, 0}; // Unicode Umlaute ae
    result.replace(umlaut_ae_uni, umlautAE_lcd);

    const char umlautOE_uni[3] = {0xc3, 0x96, 0}; // Unicode Umlaute OE
    const char umlautOE_lcd[2] = {0xef, 0}; // P012_LCD Umlaute
    result.replace(umlautOE_uni, umlautOE_lcd);

    const char umlaut_oe_uni[3] = {0xc3, 0xb6, 0}; // Unicode Umlaute oe
    result.replace(umlaut_oe_uni, umlautOE_lcd);

    const char umlautUE_uni[3] = {0xc3, 0x9c, 0}; // Unicode Umlaute UE
    const char umlautUE_lcd[2] = {0xf5, 0}; // P012_LCD Umlaute
    result.replace(umlautUE_uni, umlautUE_lcd);

    const char umlaut_ue_uni[3] = {0xc3, 0xbc, 0}; // Unicode Umlaute ue
    result.replace(umlaut_ue_uni, umlautUE_lcd);

    const char umlaut_sz_uni[3] = {0xc3, 0x9f, 0}; // Unicode Umlaute sz
    const char umlaut_sz_lcd[2] = {0xe2, 0}; // P012_LCD Umlaute
    result.replace(umlaut_sz_uni, umlaut_sz_lcd);
  } 
  return result;
}
#endif // USES_P012

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Disable device for 3 sec from rule

#22 Post by Ath » 17 May 2021, 11:08

That part of the code:

Code: Select all

byte LETTER_null[8] = { // spacja 
and accompanying stuff isn't present in the latest P012 release, so I think that should be added to the update TD-er already PR'ed today, as it sets up some extra characters. Haven't yet been able to track when that part of code was removed.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#23 Post by TD-er » 18 May 2021, 10:48


TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#24 Post by TD-er » 18 May 2021, 10:59


mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#25 Post by mackowiakp » 18 May 2021, 11:39

Yep. WORKS on test device !
No WiFi issue too (so far).

One small remark. I place in my code string "Czekaj..." ("Wait" in my language) in place "ESP Easy".
So current binary during initialization LCD display "ESP EasyCzekaj..". Be kind to remove one of them, probably my one.
Will try on target device later

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#26 Post by TD-er » 18 May 2021, 11:49

I removed the Polish Wait...
I will merge it, but be aware the WiFi issues have not yet been fixed.

Last night I had one of my own units (connected to serial log) showing the issue of not reconnecting.
So I could see what was wrong then. It appeared the WiFi events were not considered to timeout, so if not all events were processed (e.g. more likely to happen on static IP) it would wait forever (until it crashed....)
So I do have to take a closer look at it, as it is possible to get in the situation where a new connection cannot be started as there are unprocessed wifi events and those events cannot be processed as they are waiting for another event to happen first.

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#27 Post by mackowiakp » 18 May 2021, 12:26

OK. Work in progress !

When the new, official release of the sources will be available, and I get from China the LCD version with a character generator containing Cyrillic characters in the second half of CharROM (such version is available on Ali), I will add mapping of Cyrillic codes to CharROM addresses.
This is important in my country because we have over 1.8 million immigrants from Ukraine, Belarus and Russia.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Disable device for 3 sec from rule

#28 Post by TD-er » 18 May 2021, 12:31

mackowiakp wrote: 18 May 2021, 12:26 [...]
This is important in my country because we have over 1.8 million immigrants from Ukraine, Belarus and Russia.
And they all plan on using ESPEasy? ;)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Disable device for 3 sec from rule

#29 Post by mackowiakp » 18 May 2021, 13:06

Probably not all of them ;-).
But for example most ticket vending machines, ATM machines, information lines in banks, information boards in state offices, shops etc. have the option of Ukrainian and/or Russian language.
So for future projects.

And these are beavers 150 meters from my house. Pests ...

https://www.dropbox.com/s/g8opspy49yi0jxg/Bobr.mp4?dl=0

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests