Adafruit's 16x32 RGB LED matrix c++
Cree
Posts: 132
in Propeller 1
Hi my name is chris and I am trying to program Adafruit's 16x32 RGB LED matrix in c++.
I am having trouble programming the matrix in c++.
I have looked at the links below and played around with some of the demo code
Ray's Logic
Forum Post
Attached is the original spin code and my attempt to translate it to c++.
Can someone tell me what I am doing wrong in translating the code.
attached is a cpp file i translated from the spin test file I attached
The most likely errors I probably have would be the clk because I am not sure if it is in the correct mode, (I believe the default frequency is 80MHz)
Or also, I'm not sure if I got this right in my c++ code.
Any help would greatly appreciated,
-- chris
I am having trouble programming the matrix in c++.
I have looked at the links below and played around with some of the demo code
Ray's Logic
Forum Post
Attached is the original spin code and my attempt to translate it to c++.
Can someone tell me what I am doing wrong in translating the code.
attached is a cpp file i translated from the spin test file I attached
The most likely errors I probably have would be the clk because I am not sure if it is in the correct mode, (I believe the default frequency is 80MHz)
Or also, I'm not sure if I got this right in my c++ code.
'Need to toggle the A line or else the protection circuit will turn off the de-multiplexer.
repeat
OUTA[Pin_A..Pin_C]++
Any help would greatly appreciated,
-- chris
Comments
Which I modified to:
Spin2Cpp translates your spin code to these CPP files (Adafruit_Test2.cpp & Adafruit2_Test.h):
Do they work (I don't think I have the LED matrix from Adafruit to test here...)?
dgately
Sorry, I needed to include the "--main" option to spin2cpp...
These slightly changed files should now build:
dgately
--Chris
I think I'm going to re-code my game in spin if I don't get it to work in c++.
Chris
Here is the code for those that would like it in c++.
--Chris
This time i'm trying to convert the Adafruit_Test5 spin file from Ray's logic for display .bmp files.
I managed to convert it to cpp, but I get an object error when I compile:
Another option for me is using spinwrap, but I don't know how to use it from my searching.
Can someone help me with this issue?
Thanks,
--Chris
dgately
I believe I know the problem.
The Data section of the spin code:
is turned into:
Other than that, I am not sure what the issue would be.
--Chris
But, as you note, the code compiles but does not actually work... It appears that the code tries to access the array of bitmap bytes in a very out-of-bounds manner, "dat[460932]" which is far outside the scope of the prop's memory. I mistakenly used larger Test.bmp & Test2.bmp files (found in one of Ray's posts) than you had, which skewed the code.
Your dat[] array appears much smaller and will probably allow creation of better code.
If you could, try to create a C version of the Spin code with:
The created Adafruit_Test5.c & Adafruit_Test5.h files should contain a correct access of your dat[] array. If that does not work, please attach the test.bmp & test2.bmp files that you are using and I will re-build the project.
EDIT: see the next post for attached project files...
dgately
I rebuilt the project as a std C project and it builds with reasonable results. Could you try the attached project files?
dgately
No lights on the matrix lit up.
-- Chris
Sorry, I can't test as I don't have the Adafruit 16x32 RGB LED matrix... I'll take a look at the code and see if I can get something set up to test that the pins are getting activity...
Sorry I didn't respond earlier, I had a busy weekend. If you do mange to get any good results, ill test it. Thanks for the help so far.
But at the moment I am working on the sing led placement code that works to turn on more than just a single LED. The issue that I am working on is caused by a loop when I turn on x amount of LEDs, they flicker. If I take out the loop, the LEDs don't turn on.
I'll post the code below, if someone wants to look at it.
--Chris
What kind of Prop board are you using? Are you using something like SimpleIDE where you can set the frequency?
If not, looks like you have to do this:
I don't think its a clock issue, I have used several spin examples from you're website and they worked fine.
I am using the Propeller Activity Board(Rev A, ID: 32910)
I am able to change the clk speed in the H file:
Just so it's clear... You're saying that you have Spin code that works but when you run Spin2Cpp on it, then it doesn't work?
Are you using SimpleIDE or command line or something else for C?
I'm using simple ide. I converted ur spin code of example 4 for the adafruit 16x32 led matrix with the spin2copper. I have used the bit map spin example(5) that doesn't flicker.
Unfortunately, changing the _clkfreq definition in the .H file won't do anything. The clock frequency is hard coded elsewhere in the .cpp file (in the __asm__ definition for _clkfreqval). If you want to change the clock frequency you'll have to change it in the .spin file and then re-run spin2cpp on it. That;s a known issue with spin2cpp, and I haven't had a chance to fix it yet (although in theory with the --gas flag it would be possible to make the clock frequency editable).
Thanks ersmith, Ill try that. I think I figured a way without changing the clock speed. Ill tell you guys how it turns out.
--Chris
Results: Increasing the clock speed in the spin file before converting it partially worked.
I believe the flicker is caused by this function used multiple times: