Clarification on "setValue" methods

Hello again everyone,

Please forgive me if I’m asking another dumb question here, but I think I just realized my understanding of how Blinks are meant to function has been completely wrong… I noticed in the API that the methods that send values to a specific face or on all faces have comments like this:

// sets a value (0-63) to be sent 
// repeatedly (every loop() cycle) on all 6 faces

Am I right in understanding that these methods only need to be called once, and that the value you set with these methods are continuously sent with each loop? I had been under the assumption that the value specified was sent every time the method itself was called until I read this a bit more closely…

There are two different ways to send data over blinks’ IR links - one that sends a small value (0-63) continuously and one that sends a potentially larger amount of data (up to 16 bytes) one time and only one time.

The continuous send functions are setValueSentOnFace() and setValueSentOnAllFaces(). Once you call one of these, the specified value is sent over and over again as quickly as possible (typically many times per second) over the IR link until you update the sent value with another call to setValueSentOnFace(). This is a great way to share state information.

The one-time send function is sendDatagramOnFace(). When you call that, the specified data is sent one time on that face. This send is best-efforts only so if, say, there is no other blink attached to that face then the sent datagram message is lost forever. This is similar to how UDP datagrams work on Ethernet.

Note that these IR send method are independent of each other, so there are separate receive functions. Sending a datagram does not change the setValueSentOnFace() value, or vice versa (although the repeated setValueSentOnFace() sending is paused for a split second while the datagram is send completes).

Also note that once a datagram has been sent, that face will go back to continuously sending whatever the last setValueSentOnFace() value was.

Does this clear things up?

2 Likes

@bigjosh Yes this was an awesome explanation. Thank you for going into detail and clearing all of this up for me!