Spencer upload custom animations

Can I upload animations to my Spencer? Where can I find instructions how to do this?

I tried downloading the Spencer firmware from Github and replacing some of the .gif files, but I cannot get the firmware recompiled onto the board. There is an error when I use Arduino.app to try to upload it:
Multiple libraries were found for “SPI.h”
Used: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI
Not used: /Users/user/Documents/Arduino/libraries/SPI
In file included from /Users/user/Documents/Arduino/libraries/CircuitOS/src/Input/Input.h:5:0,
from /Users/user/Documents/Arduino/libraries/CircuitOS/src/Input/InputGPIO.h:4,
from /Users/user/Documents/Arduino/libraries/Spencer-Library/src/Spencer.h:5,
from /Users/user/Library/Mobile Documents/com~apple~CloudDocs/Downloads/Spencer-Firmware-master/Spencer/Spencer.ino:2:
/Users/user/Documents/Arduino/libraries/CircuitOS/src/Input/…/Util/Vector.h:5:10: fatal error: vector: No such file or directory
#include
^~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Esplora.

Als worried that I cannot chose a ESP32 board in my Arduino. Any help would be appreciated!

Greetings,

Firstly, you should make sure that you have the Spencer board installed.

To do this, follow the steps in this repository and install the Spencer board in Arduino IDE.

You should also delete (or temporarily move) all the dependency libraries from your Arduino/libraries/ folder since all the working libraries are already included with the Spencer board files, and having duplicates in your libraries folder could cause conflicts. This includes CircuitOS, the Spencer library, SerialFlash, etc.

After doing so, you should now be able to see the Spencer board in the Boards menu:

As for the custom GIFs, they should be 16x9 to fit on the screen. You can draw them in a pixel art editor such as Aseprite.

Then, you need to convert them into a c-style array. This is easily done using a tool such as
xxd or hexdump. (For example, xxd has the -i option just for that!)
Here is an example of using xxd to convert one of the gifs from our repository.

$ xxd -i angry.gif

unsigned char angry_gif[] = {
0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x10, 0x00, 0x09, 0x00, 0x77, 0x00,
0x00, 0x21, 0xf9, 0x04, 0x09, 0x28, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00,
0x00, 0x00, 0x10, 0x00, 0x09, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0x02, 0x11, 0x84, 0x8f, 0x99, 0x11, 0xc8, 0x6a, 0xde, 0x91, 0xb0,
0xda, 0xbb, 0x98, 0xc6, 0xbc, 0xfb, 0x53, 0x00, 0x00, 0x21, 0xf9, 0x04,
0x09, 0x28, 0x00, 0x00, 0x00, 0x2c, 0x04, 0x00, 0x01, 0x00, 0x08, 0x00,
0x06, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x02, 0x0b, 0x0c,
0x8e, 0x66, 0x89, 0xed, 0x1f, 0xa2, 0x04, 0xb1, 0xc5, 0x02, 0x00, 0x3b
};
unsigned int angry_gif_len = 96;

You can now copy this array in your code, here is a basic example:

#include <Arduino.h>
#include <CircuitOS.h>
#include <Spencer.h>
#include <FS/PGMFile.h>
const unsigned char angry_gif[] PROGMEM = {
0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x10, 0x00, 0x09, 0x00, 0x77, 0x00,
0x00, 0x21, 0xf9, 0x04, 0x09, 0x28, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00,
0x00, 0x00, 0x10, 0x00, 0x09, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0x02, 0x11, 0x84, 0x8f, 0x99, 0x11, 0xc8, 0x6a, 0xde, 0x91, 0xb0,
0xda, 0xbb, 0x98, 0xc6, 0xbc, 0xfb, 0x53, 0x00, 0x00, 0x21, 0xf9, 0x04,
0x09, 0x28, 0x00, 0x00, 0x00, 0x2c, 0x04, 0x00, 0x01, 0x00, 0x08, 0x00,
0x06, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x02, 0x0b, 0x0c,
0x8e, 0x66, 0x89, 0xed, 0x1f, 0xa2, 0x04, 0xb1, 0xc5, 0x02, 0x00, 0x3b
};
unsigned int angry_gif_len = 96;

void setup() {
Serial.begin(115200);
Serial.println();
Spencer.begin();
Spencer.loadSettings();

LEDmatrix.startAnimation(new Animation(new PGMFile(angry_gif, angry_gif_len)), true);
}

void loop() {
LoopManager::loop();

}

(Note: make sure to place the const PROGMEM keywords in the array definition)

I hope this helps you!

Sincerely
-Emil from CM

1 Like

Thanks for your reply, This is awesome. I will give it a try this weekend. Cheers!

1 Like

hi Emil,
Thanks to your help I have been able to compile and upload the code. That much closer to modding Spencer! However, I’m still stuck.

My first thought was to replace the idle0.gif etc animations in the folder Spencer/data/GIF/ However, these are apparently not being processed during compilation.

I looked at the code you sent but I’m hesitant to put it in; so I thought maybe I could replace the current .gif files in the code in stead of in folder, but they don’t seem to be there. Can you help me along? I don’t have any experience programming Arduino but I know a fair bit of javascript so I can read it.

Thanks!

The GIF files in the /data folder aren’t included in the compilation, we have just stored them in the repository for convenience.

The files are flashed during production on a separate flash chip on the Spencer PCB. We have only used this tool during the development process for debugging purposes, but you could use it to flash the chip over the serial port and place your own files on it.

However, it is quite a hassle to flash the external storage chip, since it has to be fully erased whenever you wish to copy something over, and the whole process of erasing and flashing over the serial port takes quite a long time (~20mins).

The easiest way to use custom animations is to put them in your code (like in the example above), but if you want to give it a shot here’s the flashing utility mentioned previously. The documentation included with it should suffice, but feel free to ask if you have any questions about it.

Important notice: restoring Spencer’s firmware through CircuitBlocks DOES NOT restore the animation and sound files on the flash chip! So, proceed with caution when experimenting with the flash chip.

Hope this helps!
-Emil from CM

Hello Emil,

I’m Marko and I’m trying to make Spencer speak Serbo-Croatian.I’ve followed this tutorial for Slovenian, and I got stuck at the Serial Uploader part.

What should be uploaded in order to have a working Spencer? The whole firmware or just the data folder with the .mp3 and .gif files?

Currently my Spencer is dead, but I hope I can rejuvenate him :sweat_smile: