Changing Arduino image loaded via PatternPaint
Hi All,
I used blinkytape to make a hula hoop and to do this I needed to extend the tape by soldering on another length of tape. The tape is compatible and with minor changes to ColorSwirl/PatternPlayer it works great (I just changed the number of LEDS #define to 180 rather than 60).
It would be great to use PatternPaint to define patterns for the extended tape, but the problem is that I need to update the Arduino .hex file encoded into PatternPaint to support the larger tape.
Is there an easy way to update the hex image in PatternPaint? Do you have a script that does this or can you just explain which parts of the .hex should go into PatternPlayer.h? I could probably figure this out by pattern matching but I thought I would ask first
Thanks for creating blinky tape -- great product and very easy to use!
I used blinkytape to make a hula hoop and to do this I needed to extend the tape by soldering on another length of tape. The tape is compatible and with minor changes to ColorSwirl/PatternPlayer it works great (I just changed the number of LEDS #define to 180 rather than 60).
It would be great to use PatternPaint to define patterns for the extended tape, but the problem is that I need to update the Arduino .hex file encoded into PatternPaint to support the larger tape.
Is there an easy way to update the hex image in PatternPaint? Do you have a script that does this or can you just explain which parts of the .hex should go into PatternPlayer.h? I could probably figure this out by pattern matching but I thought I would ask first
Thanks for creating blinky tape -- great product and very easy to use!
Comments
Yes, I believe I just need to replace the .hex file, but I was not sure how to do it. I can produce a .hex file using the arduino build, but somehow it needs to get put into the array defined in PatternPlayer_Sketch.h
I wanted to find out an easy way to put it into the .h file. I assume that only part of the .hex file goes in there (since part of the .hex is the pattern itself). I was also not sure whether or not it is the .hex file straight up (including checksum and address) or just the binary data.
I guess I just need to know how to regenerate it!
Just checked, and apparently I made a mistake and replaced the .ino source for the sketch with the .h output (oops!). The version I just checked in should be correct.
PatternPaint doesn't use a .hex file directly, there is a python script in the patternplayer_sketch directory that is used to convert the .hex file to a c++ header, which patternpaint loads into a data array. All of the actual program code from the hex file is contained here. There is a readme file in that directory that describes the process.
When you initiate an upload in patternpaint, it converts the image into a compressed format, stores it in an array, and then also generates a header table that describes the number of LEDs, compression type, and number of frames of data in the animation. There's a second secret hiding in the source, it can actually support multiple animations, it's just that the gui doesn't have a way of selecting them yet.
Incidentally, I wrote an implementation of the AVR upload protocol into patternpaint, so it can talk directly to the bootloader and load the program data (followed by the pattern data, and finally the pattern header) into the device's flash memory. This way, I was able to sidestep generating .hex files and calling avrdude :-). There's one more feature I've been wanting to add, which is to only re-flash the program section of the device flash if it's actually changed (new version of patternpaint). I think that would make the upload process just a bit more reliable, because if the animation data gets corrupted it's not nearly as big a deal as if the program data was corrupted.
> supports changing the strip length! Just go to edit->resize pattern and change
> 60 to the length you need.
Strange.. I thought that I tried that and it did not work.. but I will try it again. Perhaps I only tried this using the release version of PatternPaint before.
I am now using the PatternPaint out of github so I will pull the latest and give it a try.
> PatternPaint doesn't use a .hex file directly, there is a python script in the
> patternplayer_sketch directory that is used to convert the .hex file to a c++
> header, which patternpaint loads into a data array. All of the actual program
> code from the hex file is contained here. There is a readme file in that directory
> that describes the process.
Ah.. I hadn't noticed the patternplayer_sketch directory before.. Now this all makes sense!
I don't have the hardware with me but I'll give it a try tonight and let you know if I am successful or not.
Thanks for the explanation too.
Thanks again for the help!
I gave the github version a try but unfortunately found that it wasn't working properly for me. I tried setting the pattern size to 180 leds x 30 frames, then tried connecting, restoring to colorswirl, and then trying to do playback. Loading colorswirl acted strangely - it seemed to do nothing at first, but after unplugging and replugging USB it appeared that it had indeed loaded the firmware image. However, live playback did not seem to work.
I will paste some errors from the console here.
I only had a few minutes to try it out last night so I didn't have time to do any serious debugging.. I will return to this later. A few things I plan to try:
* checkout the release version from git and see whether I can modify the sketch in the patternplayer directory.. see if that works.
* test the git version using the standard settings
* It also occurs to me now that vmware was running on the machine (but the guest OS was closed) -- i should also try quitting from vmware because sometimes this can cause contention for ports and slow down port discovery.
In the mean time here are some errors. One thing is it seemed to be having trouble connecting to the tape, yet it did still seem to change the program on the tape.. so not sure how to interpret this. I wonder if after programming the tape the controller resets and fails to connect again by USB? (or connects too slowly?)
Starting /Users/girod/cvs/build-PatternPaint-Desktop_Qt_5_1_1_clang_64bit-Debug/src/PatternPaint/PatternPaint.app/Contents/MacOS/PatternPaint...
debug PatternEditor::lazyUpdate: Dropping update due to rate limiting. Last update 12 ms ago
debug MainWindow::drawTimer_timeout: Dropping timer update due to rate limiting. Last update 4 ms ago
debug MainWindow::on_actionResize_Pattern_triggered: Resizing pattern, length: 30 height: 180
debug MainWindow::drawTimer_timeout: Dropping timer update due to rate limiting. Last update 7 ms ago
debug MainWindow::on_tapeConnectDisconnect_clicked: Tapes found: 1
debug MainWindow::on_tapeConnectDisconnect_clicked: Attempting to connect to tape on: "usbmodemfd121"
debug BlinkyTape::open: Connecting to BlinkyTape on "usbmodemfd121"
critical BlinkyTape::handleSerialError: Serial resource error, BlinkyTape unplugged? "Bad file descriptor"
debug MainWindow::on_tapeConnectionStatusChanged: status changed, connected= false
warning QCFSocketNotifier::registerSocketNotifier: QSocketNotifier::Exception is not supported on iOS
debug MainWindow::on_tapeConnectionStatusChanged: status changed, connected= true
debug BlinkyTape::sendUpdate: Output data still in buffer, dropping this update frame
debug BlinkyTape::sendUpdate: Output data still in buffer, dropping this update frame
debug BlinkyTape::sendUpdate: Output data still in buffer, dropping this update frame
debug BlinkyTape::sendUpdate: Output data still in buffer, dropping this update frame
.....
debug MainWindow::on_tapeConnectDisconnect_clicked: Disconnecting from tape
warning QCFSocketNotifier::unregisterSocketNotifier: QSocketNotifier::Exception is not supported on iOS
debug MainWindow::on_tapeConnectionStatusChanged: status changed, connected= false
debug MainWindow::on_tapeConnectDisconnect_clicked: Tapes found: 1
debug MainWindow::on_tapeConnectDisconnect_clicked: Attempting to connect to tape on: "usbmodemfd121"
debug BlinkyTape::open: Connecting to BlinkyTape on "usbmodemfd121"
critical BlinkyTape::handleSerialError: Serial resource error, BlinkyTape unplugged? "Bad file descriptor"
debug MainWindow::on_tapeConnectionStatusChanged: status changed, connected= false
warning QCFSocketNotifier::registerSocketNotifier: QSocketNotifier::Exception is not supported on iOS
debug MainWindow::on_tapeConnectionStatusChanged: status changed, connected= true
critical BlinkyTape::handleSerialError: Serial resource error, BlinkyTape unplugged? "Device not configured"
warning QCFSocketNotifier::unregisterSocketNotifier: QSocketNotifier::Exception is not supported on iOS
debug MainWindow::on_tapeConnectionStatusChanged: status changed, connected= false
debug MainWindow::on_tapeConnectDisconnect_clicked: Tapes found: 1
debug MainWindow::on_tapeConnectDisconnect_clicked: Attempting to connect to tape on: "usbmodemfd121"
debug BlinkyTape::open: Connecting to BlinkyTape on "usbmodemfd121"
critical BlinkyTape::handleSerialError: Serial resource error, BlinkyTape unplugged? "Bad file descriptor"
debug MainWindow::on_tapeConnectionStatusChanged: status changed, connected= false
warning QCFSocketNotifier::registerSocketNotifier: QSocketNotifier::Exception is not supported on iOS
debug MainWindow::on_tapeConnectionStatusChanged: status changed, connected= true
debug MainWindow::on_uploaderProgressChanged: Got a progress event while the progress dialog is hidden, event order problem?
debug PatternUploader::startUpload: Sketch size: 10096B
debug BlinkyTape::reset: Attempting to reset BlinkyTape
warning QCFSocketNotifier::unregisterSocketNotifier: QSocketNotifier::Exception is not supported on iOS
debug MainWindow::on_tapeConnectionStatusChanged: status changed, connected= false
debug PatternUploader::doWork: Bootloader waiting on: "usbmodemfd121"
debug AvrProgrammer::openSerial: connecting to "usbmodemfd121"
critical AvrProgrammer::handleSerialError: "Bad file descriptor"
critical PatternUploader::handleProgrammerError: "Bad file descriptor"
debug MainWindow::on_uploaderFinished: Uploader finished! Result: false
debug MainWindow::on_uploaderFinished: Tapes found: 0
warning QCFSocketNotifier::registerSocketNotifier: QSocketNotifier::Exception is not supported on iOS
debug PatternUploader::doWork: Connected to programmer!
debug MainWindow::on_uploaderProgressChanged: Got a progress event while the progress dialog is hidden, event order problem?
debug MainWindow::on_uploaderProgressChanged: Got a progress event while the progress dialog is hidden, event order problem?
....
debug AvrProgrammer::handleReadData: Disconnecting from programmer
warning QCFSocketNotifier::unregisterSocketNotifier: QSocketNotifier::Exception is not supported on iOS
debug MainWindow::on_uploaderProgressChanged: Got a progress event while the progress dialog is hidden, event order problem?
warning QSocketNotifier::QSocketNotifier: QSocketNotifier: Invalid socket specified
warning QCFSocketNotifier::registerSocketNotifier: QEventDispatcherMac::registerSocketNotifier: Failed to create CFSocket
debug MainWindow::on_uploaderFinished: Uploader finished! Result: true
debug MainWindow::on_uploaderFinished: Tapes found: 1
debug MainWindow::on_uploaderFinished: Attempting to connect to tape on: "usbmodemfd121"
debug BlinkyTape::open: Connecting to BlinkyTape on "usbmodemfd121"
critical BlinkyTape::handleSerialError: Serial resource error, BlinkyTape unplugged? "Bad file descriptor"
debug MainWindow::on_tapeConnectionStatusChanged: status changed, connected= false
warning QCFSocketNotifier::registerSocketNotifier: QSocketNotifier::Exception is not supported on iOS
debug MainWindow::on_tapeConnectionStatusChanged: status changed, connected= true
debug BlinkyTape::sendUpdate: Output data still in buffer, dropping this update frame
debug BlinkyTape::sendUpdate: Output data still in buffer, dropping this update frame