16/12 tasks ?

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#51 Post by Smotek7 » 18 Jan 2022, 16:53

@TD-er
Yes 1 commrail and X button
4x mcp23017
each use 16 input (pullup)
for that
MonitorRange, MCP, 1,64
Each input has an optotransistor

schematic mcp23017, 4X, everyone has a different address A0,A1,A2
mcp.JPG
mcp.JPG (45.2 KiB) Viewed 6145 times
each input, foreign 64X
in.JPG
in.JPG (17.7 KiB) Viewed 6145 times

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#52 Post by Smotek7 » 19 Jan 2022, 08:47

@TD-er
this rule does not work

Code: Select all

on mcp do
  let,1,!%eventvalue1% 
  SendToUDP,192.168.1.100,550,IN%eventvalue0%=[int#1]
endon
But I managed a small miracle.

I installed VSCODE and PIO
I modified plugin 61
I added a quarter mod
MCP23017 (Direct 16)

Code: Select all

uint8_t MCP23017_KeyPadDirectScan(uint8_t addr)
{
  uint8_t colDataA;
  uint8_t colDataB;

  colDataA = MCP23017_getReg(addr, MCP23017_GPIOA);
  colDataB = MCP23017_getReg(addr, MCP23017_GPIOB);

      if (colDataA == 0xFF) { // no key pressed?
        if (colDataB == 0xFF){
           return 0;            // no key pressed!
          }
        }
      uint8_t colMask = 1;
     
      for (uint8_t col = 1; col <= 8; col++)
      {
        if ((colDataA & colMask) == 0)                   // this key pressed?
        {
          return col;
        }
        
      
        if ((colDataB & colMask) == 0)                   // this key pressed?
        {
          return col+8;
        }
        colMask <<= 1;
        
      }

      
  return 0;                                     // no key pressed!
}
It's probably not quite right,
But it works
It returns Scancode input

MCP#ScanCode=9
MCP#ScanCode=0

I would like to improve it so that it sends me the input status as plugin 009
MCP # ScanCode = 9 = 1
MCP # ScanCode = 9 = 0

Therefore, I probably have to postpone the previous situation
I did not find what ensures that the Scancode is sent once, even if the input is still active

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#53 Post by Smotek7 » 19 Jan 2022, 09:35

The joy was premature
if I define more than one task
so plugin 061 will stop working
does not work even if I use two tasks in matrix mode, original code

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

Re: 16/12 tasks ?

#54 Post by Ath » 19 Jan 2022, 09:46

Smotek7 wrote: 19 Jan 2022, 08:47 @TD-er
this rule does not work

Code: Select all

on mcp do
  let,1,!%eventvalue1% 
  SendToUDP,192.168.1.100,550,IN%eventvalue0%=[int#1]
endon
As TD-er wrote, that's not implemented (yet), so indeed won't work :)
Smotek7 wrote: 19 Jan 2022, 08:47 But I managed a small miracle.

I installed VSCODE and PIO
I modified plugin 61
I added a quarter mod
MCP23017 (Direct 16)

Code: Select all

uint8_t MCP23017_KeyPadDirectScan(uint8_t addr)
{
  uint8_t colDataA;
  uint8_t colDataB;

  colDataA = MCP23017_getReg(addr, MCP23017_GPIOA);
  colDataB = MCP23017_getReg(addr, MCP23017_GPIOB);

      if (colDataA == 0xFF) { // no key pressed?
        if (colDataB == 0xFF){
           return 0;            // no key pressed!
          }
        }
      uint8_t colMask = 1;
     
      for (uint8_t col = 1; col <= 8; col++)
      {
        if ((colDataA & colMask) == 0)                   // this key pressed?
        {
          return col;
        }
        
      
        if ((colDataB & colMask) == 0)                   // this key pressed?
        {
          return col+8;
        }
        colMask <<= 1;
        
      }

      
  return 0;                                     // no key pressed!
}
It's probably not quite right,
But it works
It returns Scancode input

MCP#ScanCode=9
MCP#ScanCode=0

I would like to improve it so that it sends me the input status as plugin 009
MCP # ScanCode = 9 = 1
MCP # ScanCode = 9 = 0

Therefore, I probably have to postpone the previous situation
I did not find what ensures that the Scancode is sent once, even if the input is still active
That ScanCode part was already working, even without your modification, I'd expect, but indeed didn't support Port_B yet.
Smotek7 wrote: 19 Jan 2022, 09:35 The joy was premature
if I define more than one task
so plugin 061 will stop working
does not work even if I use two tasks in matrix mode, original code
Ah, there is always the chance that a plugin is not (yet) multi-instance compatible (hadn't looked closely at the code to determine that), and that is probably what you are now running into.
I'll put that on my list of "plugins to make multi-instance" ;)
/Ton (PayPal.me)

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#55 Post by Smotek7 » 19 Jan 2022, 19:42

Ath wrote: 19 Jan 2022, 09:46 I'll put that on my list of "plugins to make multi-instance" ;)
What does this mean? Is it something complicated?
What position will it get on the list?
Just out of curiosity.
I considered trying to insert 4xMCP into one task for myself.
I2C addresses to hard.

But today I found out that MCP23017 are unavailable until 10/2022.
I have assembled one 64 input board and one 32 out.

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

Re: 16/12 tasks ?

#56 Post by Ath » 19 Jan 2022, 20:24

Smotek7 wrote: 19 Jan 2022, 19:42 What does this mean? Is it something complicated?
What position will it get on the list?
Just out of curiosity.
Well, that list is mostly imaginary, I'm a software developer by profession, but ESPEasy is a hobby for me, working on it in my spare time (that I have plenty of, though), I can pick up the tasks that I like, when I feel like it. Putting pressure on that kind of creative processes (how I like to call it) usually works counter-productive.
I do see the usefulness of this improvement, so that is one of the factors that determines the position on the list. How complicated it is, I'll have to see when I get started, it may be easy, but it can also be hard. I've done it before, making a plugin multi-instance compatible, so that helps :D (Multi-instance means that multiple tasks using the same plugin can be used independently, older plugins, like this one, tend to use global variables, that in fact can't really be shared between tasks, that's why the second and further tasks won't work as expected).
Smotek7 wrote: 19 Jan 2022, 19:42 I considered trying to insert 4xMCP into one task for myself.
I2C addresses to hard.

But today I found out that MCP23017 are unavailable until 10/2022.
I have assembled one 64 input board and one 32 out.
You could consider buying some MCP23017 boards on Aliexpress, EBay or Banggood, and wire them onto your board, that should work for the time being, and the boards are available plenty and cheap 8-)
/Ton (PayPal.me)

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#57 Post by Smotek7 » 19 Jan 2022, 21:21

Thank you for the info.
I also do it only when there is free time.
I'm not a programmer. But I'm happy to be able to program something simple.
HW I have been assembled for this since March 2021 and lay in a drawer.
The last few days I've been trying to finish the SW.
I have a couple of PCBs with Ali, and that's a possibility.

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#58 Post by Smotek7 » 20 Jan 2022, 13:29

I would still like to try the possibility to modify TASK_MAX but somehow I can't find the config.h file
Am I looking wrong?
I look in Arduino IDE and VSCODE, it's not there :(

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

Re: 16/12 tasks ?

#59 Post by Ath » 20 Jan 2022, 13:44

If you set this:

Code: Select all

#define USE_NON_STANDARD_24_TASKS
in your Custom.h file, and compile a custom build using VSCode, then you should get a build having 24 tasks. This define was added to produce what you want.

The define is actually called TASKS_MAX, and is hiding in src/src/CustomBuild/ESPEasyLimits.h

Don't try to upgrade an existing ESP with this build, unless you blank out the flash first, as the settings file isn't compatible because of this change. After you have configured the device you can upgrade with a build with the same setting enabled.
/Ton (PayPal.me)

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

Re: 16/12 tasks ?

#60 Post by TD-er » 20 Jan 2022, 13:54

There is no Config.h file. You have to rename the Config-sample.h file to Config.h (mind the capital C) to get some starting template for this .h file.

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#61 Post by Smotek7 » 20 Jan 2022, 15:25

TD-er wrote: 20 Jan 2022, 13:54 There is no Config.h file. You have to rename the Config-sample.h file to Config.h (mind the capital C) to get some starting template for this .h file.
Now I understand why the edits in Config-sample.h :D didn't work for me.

I think that
#define USE_NON_STANDARD_24_TASKS
is only for ESP8266.

I changed it here

Code: Select all

#if defined(ESP32)
  #ifndef TASKS_MAX
    #define TASKS_MAX                          64
  #endif
  #ifndef MAX_GPIO
    #ifdef ESP32S2
      #define MAX_GPIO                           46
    #else
      #define MAX_GPIO                           39
    #endif
  #endif
#endif
I deleted, I flash ESP
it works after Task 48 as @ TD-er wrote
A message when saving reports
FS : Error while reading/writing /config.dat in 3934
How to change settings file from 128k to 160k?

Is there any way to edit config.dat?
Not via ESPEasy, somehow on PC.

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

Re: 16/12 tasks ?

#62 Post by TD-er » 20 Jan 2022, 15:31

See CONFIG_FILE_SIZE in StorageLayout.h
You can define it in your Custom.h file:

Code: Select all

#define CONFIG_FILE_SIZE               163840 // 160k
This will then be used to create a new blank config.dat file after a factory reset.

But I think you may run into other issues as the file size is significant compared to the available free space on an ESP32 build with 4M flash.
If you get errors while saving, a reboot may help as it calls the garbage collection on mounting the file system at boot.

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#63 Post by Smotek7 » 20 Jan 2022, 17:57

So far, everything is working
only when defining the 16th input did I come across a message
Daily flash write rate exceeded! (powercycle to reset this)
Does plugin 009 save anything while working?
Or just during configuration?

It would like to edit config.dat externally.

I don't know why it doesn't take the Config.h file when compiling
a report is displayed
include errors detected. Please update your includePath. Squiggles are disabled for this translation unit ....
annot open source file "string" (dependency of "Arduino.h")

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

Re: 16/12 tasks ?

#64 Post by TD-er » 20 Jan 2022, 19:17

Are you building using VScode and PlatformIO?

Flash write count is kept in RTC memory as long as the device is powered.
So if you exceed 100 writes in a day, you will get this warning.
Each time you press submit, something is saved, thus increasing the write counter.

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#65 Post by Smotek7 » 20 Jan 2022, 19:26

Yes, VScode and PlatformIO
but only day 2
So far, I'm having a hard time.
Trial / error....

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

Re: 16/12 tasks ?

#66 Post by Ath » 20 Jan 2022, 19:29

/Ton (PayPal.me)

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

Re: 16/12 tasks ?

#67 Post by TD-er » 20 Jan 2022, 19:31


Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#68 Post by Smotek7 » 21 Jan 2022, 19:23

I managed what is in the video.
what is in help i read.
It's hard for me: D
I created a new branch
renamed to Config.h
but when compiling it gives me the 2 errors in Config.h

Yesterday I created 64 tasks and ESP runs.
I tested on the table with wifi.
I switched to LAN today.
The task will now be moved to a real life in the house.
I will replace the old module with a new ESP board.
I hope everything will be ok and my wife is not collapsing :D

So far, thank you for the great support
I'm sure I'll have some more questions.

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

Re: 16/12 tasks ?

#69 Post by TD-er » 21 Jan 2022, 19:55

Great to hear you managed to build it.

Just for your information/inspiration.
I know a guy here on the forum, who started using ESPEasy years ago.
He now has his own designed boards for automating stuff and guess who's soldering those boards?
Those look even better than assembled by a machine (I kid you not!)
His wife does the soldering and assembling of the units.

So don't be surprised if one day your wife thinks things can be improved in your design and just starts doing it :)
If that happens, you better try to keep up with her as women often are much faster in grasping these things than us men.

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#70 Post by Smotek7 » 21 Jan 2022, 20:53

I have to fully agree with the fact that women are suitable for PCB mounting.
In my previous job, women made and sold cable.

But this is not my wife's case.

Otherwise, is there a list or place where the HW for ESP is published?
E.g. thread on the forum.
There must be a lot of good solutions. Also commercial.

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

Re: 16/12 tasks ?

#71 Post by TD-er » 21 Jan 2022, 22:49

I am -as we speak- working on a very nice dev board, which is quite easy to assemble yourself and relatively cheap.
After my next revision, I will make it public (open source) so everyone can make it.
It does allow very simple add-on boards which you can plugin. Even by using normal standard experimental boards to mount some sensors.


By the way, I didn't just mean assembling which women can do probably better than us men, but also programming.
I (sadly) only know very few girls/women who studied computer science, but all of them are way better at it than most of the guys I know who have a degree in programming from university.
So I really don't know why fiddling with these things we do, does not appear to appeal to the other gender. (at least not in the Netherlands)

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

Re: 16/12 tasks ?

#72 Post by Ath » 22 Jan 2022, 22:50

Apparently, the P061 Keypad using an MCP23017 supports a matrix of up to 9*8 = 72 keys, so no need to support anything on the PORT_B pins, they are already supported :)

Working on the multi-instance implementation, so: work in progress.
/Ton (PayPal.me)

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#73 Post by Smotek7 » 23 Jan 2022, 12:07

Yes, 061 supports matrix, but I need Direct.
He's not there.
Direct is for PCF8574 only.
And I also miss the inversed mode.
And in Direct mode, both sending and status.
MCP IN 9 Status = 1
MCP IN 9 Status = 0

But I'm glad you're working on multi-instance,

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

Re: 16/12 tasks ?

#74 Post by Ath » 23 Jan 2022, 14:10

Using the Keypad plugin, you can still use the PBx as inputs, and GND as the common row. That will use only 8 of the inputs, I realize that, but that's still better than 1 per task when using the 'Switch input - MCP23017' (P009) plugin. And the ScanCode values will be unique per button within each task.

I'll create a PR for making the Keypad plugin multi-instance later today (tests are working as expected, so far).

Edit: And for a Keypad implementation, no Inversed Logic option is needed.
/Ton (PayPal.me)

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

Re: 16/12 tasks ?

#75 Post by Ath » 23 Jan 2022, 15:35

I have created PR #3927 for enabling Multi-instance use. Also planning to add MCP23017 Direct configuration, and support for PCF8575 (like PCF8574 but with 16 I/O ports) in both Matrix and Direct configuration.
/Ton (PayPal.me)

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

Re: 16/12 tasks ?

#76 Post by Ath » 22 Apr 2022, 11:18

Smotek7 wrote: 23 Jan 2022, 12:07 Yes, 061 supports matrix, but I need Direct.
I've added Direct mode for all 3 supported I/O chips via PR #3927, can you test this please, and report here or in Github your results?
/Ton (PayPal.me)

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#77 Post by Smotek7 » 08 May 2022, 21:24

@Ath
In which .bin can I find this edit?
test_E?

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

Re: 16/12 tasks ?

#78 Post by Ath » 08 May 2022, 22:06

This plugin is included in any TEST build, so TEST_E will do most of the new features. Except the PCF8575 support is not included when LIMIT_BUILD_SIZE is set, and that is set for all TEST builds :shock:

So you can test the other new features like MCP23017 Direct 16 is available. For testing PCF8575 you will have to create a custom build yourself (P061 is not included in the regular Custom builds from Github).
/Ton (PayPal.me)

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: 16/12 tasks ?

#79 Post by Smotek7 » 08 May 2022, 22:18

OK I will test
I just have to prepare the HW.
I only have MCP23017,
I don't have PCF8575.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 26 guests