Post about your Basic project here

Moderator: Mmiscool

User avatar
By Electroguard
#61711
I am still having a problem with adding more than 5 on off times and the winsock connect/disconnect working correctly, but will keep playing. Please let me know if you have any ideas about this.

Instead of assigning individual alarms, perhaps read and parse them all out of an alarm string saved to flash, then perhaps feed them into an array, so you could reduce the required winsock connections to 1 from many, by perhaps selecting one required alarm from a dropdown list of many configured alarms.
Also, it may be more efficient to just calculate the 'next' pending on and off times, rather than holding all individual alarm on and off times in memory at the same time.
User avatar
By robert badiduwitz
#61826 Thanks for the suggestions. As far as winsocks, there is only one connection at a time when this crashes when using more than 5 on off times. The idea behind this was to be able to enter quite a few on off times using the gui to make it very user friendly for the end user who would have no idea about what is going on inside. The amount of gui defined variables seems to be the limitation here i guess.

I was hoping to use the same principle for an easy to update gui webpage for a clock that you can set many attributes like weekly timers etc. But this one limitation kind of kills it as far as a "simple" user interface. Can you give me a small example of what you are suggesting, and does that method require the user to have to get out of the program and use edit to enter times, in which case, wouldn't work here. This was more or less a futile attempt at an easy to use (for the end user) web based timer. I also wanted to expand this to multiple relays, etc. Using the string for date and time made it very easy to check to see if there was a match and to do what needed to be done. Maybe parsing would work better, don't know, have to try it. Having a small limit on variables (if that is indeed what is killing it) and/or gui elements, I seem to have found the limits at this point. I'll keep playing, but I wish there was more information concerning these limits without having to actually "try till it fails".
User avatar
By Electroguard
#61837 I was merely suggesting a possible way to get past a vars limitation if that was a problem, but if the vars limitation is not a problem then it would cause unnecessary complication.

So here's what I was thinking just in case...
If I've understood mmiscool correctly, there is a limit on how many variables you can use, but it does not include arrays.
So rather than define all the different alarm On and Off times as individual variables, you could have more room for more if you bunged them into an array.

Esp_Basic doesn't have multi-dimensional arrays, but it can have multiple arrays. So you could use similarly-dimensioned On and Off arrays, with corresponding 'enabled/disabled ' status arrays if that's how you chose to do it. Doesn't matter how many alarms you have, cos you would only ever be using a single cell's currently selected data at any one time. And when you access that cells data to change the alarm time for instance, it would only be that single cell data that would be winsocked to the browser.
Your GUI could still function as it currently does, but only on the currently selected alarm at any one time, rather than all jostling together side by side.


Obviously array data loss could be a problem with power fails etc, so the array data would need saving to non-volatile memory. It might be possible to treat all the different alarm times as different saved files, but if not, then all the arrays data will need saving into a non-volatile var string.

When reading that string back, if you know how many words are in the string then you can easily do a 'for count = 1 to words' operation to extract them. But if not, there is no WordCount function, so you will need to sequence through the WORDS while counting a DO LOOP UNTIL the WORD(count) = "" (empty cos it's reached end of string).

Parsing strings of words for different things is problematic using just the Word() function because there is no way of relating the WORD(count) result string to the corresponding original underlying strings characters. So you would need to set up a nested inner WORD() search on the results of an outer WORD() search (which can get rather convoluted and difficult to mentally keep track of for troubleshooting).
For that reason you'd probably be better off saving the different types of data to different strings, ie: On times to an ONstring, Off times to an OFFstring, Alarm Status to a STATstring etc, each of which is much more easily managed, rather than trying to extract them all from the same string.

The array could be sequenced to display/edit all alarms in turn, but only the currently selected alarms data would be accessed by the browser at any moment no matter how many alarms were defined and in use.

I think that may be relevent, because I suspect the 'busy' browser page may be more of a reliability issue than the vars limitation.
User avatar
By gsrathore97
#90290 This program is not working in ESP8266 normal module. I am uploading program with arduino IDE. is that work only with Olimex board, please confirm or any suggestions. please help