Because we want animations too

As explained on my previous post, the communication between the ESP and STM will append through a protocol made to discriminate data and command bytes. We already had the code to send images from the ESP to the STM and this post will be about sending animations from the ESP to the STM.

Our first idea was to start like for the images with a byte to warn the STM about the kind of data that will be transmitted. TO do so we will start the communication with the byte “ANIM”. Then we wanted to send, after the ACK_BEGIN, the size and the animation itself in one time. Yet, this created an issue: to prevent overrun, the STM is waiting a known number a byte. When waiting for an animation, we don’t know how long it will be.

To know the size of the data that will be received, we decided to send the size in the first place and then send the animation. To do so we had to add a command signal : “ACK_SIZE” to confirm to the ESP that we received the size and we are ready for the animation itself.

Then we also want to store the full animation before we start displaying it. To do so we create a variable on the STM that will contain the animation. But to instantiate this variable, we had to know it size before. We added a constraints : we defined a maximum size of the animation.

Here is a log from the STM of the exchange. At first the STM is waiting for any transmition (“IDLE” message). Then when it receive the “ANIM” byte to replies with a “ACK_BEGIN” and print “waiting for animation size”. Then the size is transmit through the same method and finally the animation’s 4 bytes (two images) are printed. I also unplugged a wire (ESP to STM) which created the error and started a reconnexion. Once the wire was replugged the execution came back to the normal.

Leave a Reply

Your email address will not be published. Required fields are marked *