For some gifs, my original convert command mangled the deltas and produced
completly wrong frames.
This is due to a couple of mistakes in the order of operations
1. The -coalesce option to flatten all layers up to the current frame
needs to be before the output, not the input
2. Resizing was done *before* the coalesce option, leading to invalid
delta frames and image corruption
3. This was emphasized by the thresholding, making it look mangled.
Update the command in the script and the example in the README.
As our RFID tags cannot co-exist on the same reader as originally plan,
handle another reader on SPI1.
Checking tags is not time sensitive and can be made in successive loops, which
minimizes the changes needed from the original code.
Previously, checkTag() returned 0 when it failed or when there was no changes.
This is fine if we are only expecting already programmed tags, but as tags
arrive new with blocks zeroed out, which conflicts with the 0 return value.
Introduce a new constant to RFID for the return error, -1, and use it
instead of 0 everywhere.
Update comments and README to highlight this new reserved ID.
Our HID implementation sends fixed-length reports, that will be parsed
by the receiving software.
Serial outputs are more geared towards debugging, thus splitting the
messages sent is much more usable.
We keep track of the detected tag UUIDs and their figurine ID, but
we don't update it when a programming request succeeds.
Search through the tracked tags for the programmed UUID and update
the stored ID when the change suceeds.
The RFID library expects a 16 bytes buffer for writing blocks.
However, we re-use the 18 bytes buffer needed for reading blocks.
Properly remove those two extra bytes when writing blocks.
We want to check for new messages at the end of the loop, when all
other events should have happenned.
Handle the two supported messages there : tag info request and tag
programming command.
The timing might need some testing, hopefully it is short enough.
The software needs tag data to be able to send programming requests, so
go through the active tags and extract the data in the new Com structs.
programTag() handles tag wakeup and selection, so might fail if the
requested tag is on another reader. This allows chaining them together
and not keeping track of which tag which reader sees.
Add an assert in case the communication buffer would get too small to
send all active tags as the protocol does not define a multi-message
response.
Define the protocol allowing the software to track tags
and program them, in the README.
The data structure is shared between a programming command and an
information message, so create a new struct for it and an array
to keep track of it and expose to the rest of the program.
The goal is to keep the protocol core and message construction
entirely inside Com, so this intermediary buffer allows exposing
it outside while hiding the protocol details.
This means that we are starting to receive data from the software,
so implement generic functions to check and receive data as well
as receiveMessage() which parses the message and handles them.
In order to set the ID to the tag, we need to be able to write blocks.
Implement writeBlock() similarly to readBlock() to allow that.
Make sure to clean the communication buffer and handle failure states,
this will become more important for dual RFID readers as will allow
'chaining' calls and cover both readers without keeping track of
what reader sees what tag.
Only allow to write a byte for now, we don't need more.
Add a constant for the ID block used and replace it.
Clean up some comments and clarify expectations.
readBlock() did not properly halt tags after errors and the else
clause was superfluous. Properly handle error status.
Move currentActiveTags to be static and initialize it.
This allows for keeping track of max/current tags accross multiple instances.
Remove the overide of the tag value used for testing.
We don't plan yet on playing effects when a tag leaves, so avoid
playing the effects twice and only do so when arriving.
The board has a second SPI bus wired up for communication with two RFID readers
if needed.
However, the code only provided a constructor with no arguments, preventing
the use of a second instance on the different bus.
Update the constructor and the definitions to allow changing the chip select
and SPI bus used when creating an RFID reader.
Platformio supports multiple environments and sharing a global configuration.
Make use of this to easily allow switching between the production build, with HID,
and the development build, with serial.
Update the README with information on how to build those environments.
Introduce the Speaker class to play audio from the SD card when detecting
tags.
The only audio supported is WAV.
Audio playback is handled via interrupts, so it might try to read from the
SD card at the same time as the LCD class is trying to read new frames.
Update the LCD animation code to temporarily disable audio interrupts while
reading from the SD card.
sendComment cannot send more than 62 bytes, as limited by the HID report.
Sending more is prevented by vsnprintf, but change the function signature
to make it explicit that the array passed to it should be at most 62 bytes.
Add support for the LCD and using it for displaying animations.
Animations are automatically played if available for the ID of the
detected tag.
The code should support adding other kind of animations, for tags being
removed or for other UI interactions for example.
The next commit implements the LCD and animation support. To enable an easy
way to create animations for it, add details in the README regarding the way
the SD card is used and how the files need to be formatted.
Create the Utils directory and add a Rust project to do the bit flipping and
a script that automates all the steps described in the README.
Add a README for Utils explaining how to use them.
Implement a set of functions to create messages following the protocols
defined in the README for communication.
Handle HID, which is used to communicate with the interactive application.
Update README with details on the message structures.
Previously, the return value when a tag was gone was the negative ID.
However, this isn't the most effective to process later as a negative
number uses two's complement, changing all lower bits in addition
to the sign bit.
Change this to just set the sign bit instead. This still produces
a negative number, which is what we want to check to konw if the tag
is new or went away, but maintains the lower bits so the ID can be
retrieved with a simple bit-wise and.
Add a new class to handle the RFID module and associated data
in order to track active tags.
Update main with RFID initialization and a minimal usage to
check it is working as expected.
pinMode most of what could be useful in the main and put modules
LOW to minimize power draw before the regulator is ON.
Add the skeleton for the setup, main loop and battery level checking.