How do I initialize a huge static buffer?
gis667en11
Posts: 73
I'm currently working on my first really ambitious propeller project. Ironically, I'm making a propeller clock, like the one linked but larger. The thing is, at least for now, I just want to have one clock design in a buffer of, let me do the math... 5kBytes. How would you get that data into the ram? I don't want to call out a variable of BYTE clockFrameBuff[5160] and then in the main cog, during initialization set those bytes equal to the design of the clock. I'm concerned that would use twice as much space- wouldn't it? I could add a microSD, put the pattern into a file, and read in the data over SPI to fill the buffer on a loop. But that just seems... stupid.
Comments
Some Prop boards have only the minimum 32k EEPROM, others have 64k or larger.
[edit] Oops. Since this was in the Learn subforum, I assumed you were using C.
Why don't you just put it in a DAT block, maybe using the file directive?
No reason that cannot be done while still using much less memory. You do not need to have all 419 frames stored, only enough frames to draw the hands, digits, and other markings needed for the clock face. BTW, how did you decide on 419 frames. I would have expected either 256, 360, 512, or 720. 360/720 because it is divisible by 60 and the display is circular, and 256/512 being an easy to work with binary number.
Perhaps you could post a more detailed description of how you will be approaching this. Twelve bytes is enough data to control 96 leds unless you are using multiple bits to control the color or intensity of each led. That's a lot of leds to twirl.
Hey Electrodude- I have not yet played with file directives. Is this within the context of an Eeprom data file like Jones suggested?
Kwinn- You're right. There's a more elegant way to do it. More elegant and harder. There's always time to go back and add some recursive fancy handshaking program, but I need to get this done fast for a competition. I'm running off to dinner, but essentially I'm planning to have one Cog run a spin main program, one speak with a real time chip, one builds the working frame buffer from the base frame buffer design and the real time second minute hoiur registers, one detects the IR phototransistor pulse for 12 o'clock timing and speed calcs, one shifts out bits from working buffer to 595 shift registers.
The data would end up hubram. If you burn it to EEPROM, though, it will also end up in lower EEPROM like the rest of the program.
Good idea. How many pixels are you going to have between the center and circumference of the clock face? Will the leds be rgb or single color?
Yeah, I just ordered much smaller, surface mount 595's, 541's, and 100 SMD leds and resistors. It's crazy how cheap surface mount stuff is. I just got 5,000 150 ohm 1% 1206 resistors for $10, free shipping. And it looked like that seller had that kind of deal for every resistance. I will never, EVER need to buy another 150 ohm surface mount resistor for the rest of my life.
Back to the original question. If you use the file directive as shown above you can access your array via byte[@data] and add the index.
Having your 5k buffer in a separate file might be nice to change designs by simply changing one file and recompile/load.
The file directive includes the file as a binary, not source. Since you just need 5K I think using the upper EEPROM is overkill.
Enjoy!
Mike
Use a paint program, like paint.net, and output an 8 bit bitmap. You will get one byte per pixel, and that can be filtered down to bit values pretty easy.
Older paint programs will output 2 color bitmaps, which contain bit per pixel data. Strip the header, and it's close to ready to use.
Here is your portable bitmap save plugin, ascii and binary http://forums.getpaint.net/index.php?/topic/27982-portable-anymap-filetype-plugin-pam-pbm-pgm-ppm/
Get paint.net http://www.getpaint.net/download.html
Here is a polar transform plugin: http://paint.net.amihotornot.com.au/features/effects/plugins/Distort/Polar_Transormation/
I would start with your 480x96 bitmap, and drop your graphics in. Then transform that to view it in polar form. When you are happy, save the 480x96 bitmap off in the portable bitmap file, binary or ascii, and use file: directive to get it into the Prop.
That transform works both ways, so you could also design the clock face and go the other way, resulting in that 480x96 bitmap...
Building the pcb's as 8 led modules is a good idea. At that size making it sturdy and balancing the the propeller will be critical. Placing it behind some protective barrier for testing is also a good idea. Having it fly apart at full speed might be a bit more excitement than you want.
Paint.net is a tool Roy mentioned. I had been using a hodge podge of things for years. That one has an insane number of plug-ins and options. Worth learning to use, IMHO.
Knew I could sort out a tool chain in a few minutes, figured it might save you a bit of time
And thanks again potato, I'll give paint.net a shot.