Hi Aubrey,
It's not a long message at all, the more you explain the easier for me to answer (most of the time :-), don't worry my answer is going to be wayyyy longer!
Ok, let's start from the top:
1. is there a way to confirm the device is "connected" to ChipChopYup, you were on the right track. The main way is to use
ChipChop.connected it's a boolean variable (not a function...so no brackets at the end) and you can check it at any time like this:
if(ChipChop.connected) or
if(ChipChop.connected == true) or
if(ChipChop.connected == 1) it's all the same
The ChipChop.connected "should" only ever be true if: there is WiFi, the socket connection has been established, the handshake has been fully completed and the ChipChop engine has sent a welcome message.
And if for any reason any of these conditions change "connected" should drop to false (0)
2. numerical slider to input a value Your plan was good...but...one thing to keep in mind, the "command values" are for flexibility sake always sent as strings.
That means that"overloading" the
ChipChop_onCommandReceived and changing the "command_value" into an int() wouldn't really work.
It's actually quite simple if you know that the value for some component will be coming as a number is to "cast" it to the corresponding data type - to.Int() or .toFloat() or .toDouble()
That allows you handle anything in the same ChipChop_onCommandReceived callback
void ChipChop_onCommandReceived(String target_component, String command_value, String command_source, int command_age){
If (target_component == "temp_setting"){
temp_setting = command_value.toInt(); //<< simply cast to to.Int() or .toFloat() or .toDouble()
}
}
3.... maybe a numerical input example in the future docs/examples?LOL??I have heard from a reliable source on TikTok that that particular sentence means that you have volunteered yourself to write all future ChipChop documentation and the "LOL" in caps with two question marks at the end signifies that it's all legally binding.
Well, thank you so much for your sacrifice, I always knew that Canada is a great nation 🍁💕. I will send you shortly the few hundred pages I've never managed to finish, don't rush and I'll leave the choice of font to you!
I agree, in the library examples > all_functions.ino between lines 73 and 78 it is a bit unclear and easy to miss (I honestly do)
//EXAMPLE: command sent to a component called "brightness" that expects an integer value
if(target_component == "brightness"){
// do something here to change the brightness to the received percentage....
int brightness_percent = command_value.toInt(); // or .toFloat() or .toDouble()
}
4. Is "ChipChop.run();" function blocking- The short answer is...no, it's not blocking as I don't like blocking stuff
- The long answer is, that was a small lie, yes there is one place on line 257 in the ChipChopManager.cpp where a delay was necessary in case you go trigger happy and start firing triggerEvents like mad.
- The even longer answer is that I have completely re-written the way events are handled (at the great sacrifice of mr @Hossrod who is helping testing it) and I am hoping to tidy it all up in the next few days and publish it. It will be vs. 1.40 and there won't be a single blocking line of code anywhere. You won't need to change anything in the existing code but there will be an extra little feature added if you want to use it.
-
Important: You should avoid using delay() in your code if you can help is as it can block the chip from checking the websocket buffer so you could miss something. ESP's aren't too bad handling delay() and on dual core processors it could be possible to completely move the sockets from the main loop(), if there is enough need/interest I could look into that. But, in general you will be better of using non-blocking methods if you can.
5. future ideasDon't worry about how complicated it is, it's only code and any suggestion is a good suggestion
(unless it's a stupid suggestion)- I have already prepped a radial gauge and honestly I want it out there but I really need some constructive input...where/how do I integrate it in the interface?
I want to do a complete redesign of the app and that was kinda the plan to do it at the same time but if you have any suggestions how you think it could work in the interface please jot something, don't care if it's on a back of a napkin.
(I know you are busy writing the docs, so no pressure)- Historical state is already possible using the "small log" option for up to 3 components per device. There is no time limit though, so if you don't have large data you should be able to easily store 2 weeks at 10 min logs per component.
@jnogues is already on my ass for couple of weeks for a "graph" log display and it will be out soon.
I have to impose some limitations on the log simply to reduce the storage costs but I am working on some options.
So, I don't know, is that's what you meant with historical state?
Actually I just thought of an interesting concept...hmm...I need to have a little think...I'll get back to you (everyone)
This was a proper long answer! Let me know if I've missed something or you are not sure...all this really benefits everyone
Right need to dash now, laters 👋