-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logical issue with image.sram() functions #18
Comments
Why would it only work with saved images? |
For my purposes I an trying to define a bitmap image in a byte array that is changed within the program. I was pointed towards the image.SRAM function to achieve this but it is counterintuitive using a const parameter for a buffer...unless I'm completely off base here |
Do not declare your buffer const, and pass it to the function - should work fine. Check C++ FAQ or stack exchange, etc. for help with the language. |
But a buffer can't be passed to the function because the parameter in question is defined as a cost.. Therefore, image.sram(buffer) won't work.. |
What error message do you get when you try it? |
I did try the image.sram() function with my declared byte array which stemmed this whole discussion. When I received an error that I could not pass a buffer to the function, I digged into the libraries to find out the problem. To my suprise, the image.sram() function had the parameters declared as consts. It could be that the original writer of the library intended for the image.sram() method to do something other than what I am looking for...because otherwise the const parameter doesn't make sense. My proposed solution which I havent had time to try yet, would be just to change those parameters to (non-const) uint8_t* and see if that works. There could be a reason that you cant upload buffers into the display but I'm not sure what that is yet...If you have any insight please let me know. Date: Thu, 6 Nov 2014 22:16:31 -0800 What error message do you get when you try it? If you haven't tried it, don't say it can't be done. Suggest you re-read your C++ manual on constants, and do some experiments. —
|
Have you tried running the thermo demo? Declaring the argument const just tells the compiler that this method does not change the array. Which means that |
I have not, but upon just trying I got this error: C:\Program Files (x86)\Arduino\libraries\Adafruit-GFX-Library-master\glcdfont.c:13:23: error: variable 'font' must be const in order to be put into read-only section by means of 'attribute((progmem))' |
You have an old copy of the Adafruit-GFX library. Download the latest version (which fixes that problem). https://github.com/adafruit/Adafruit-GFX-Library/blob/master/glcdfont.c |
Hi, Ive downloaded the new versions of all libraries. However, the thermo demo doesnt seem to support 2.7". Is there a reason for this? Note: I'm using a mega2560 with 8K ram. |
The problem with the 2.7" display is that you need two buffers for V1 COG so there is not enough SRAM For the "const" in normal C programs const indicates that the routine does not modify the buffer, e.g.:
(you can add const to the count [parameter also to stop the routines changing the value just in case you need to be sure that the value stays constant inside read/write - C parameters are always pass by value so the caller's variable is never affected) However the AVR MCUs in the Arduino have two memory spaces; FLASH, SRAM. Which do not map wee on to C's const, you acutally need three states:
They error seems to indicate you are trying to pass PROGMEM data to the image_sram which is not possible since you a mixing memory types. PROGMEM must use the plain image function and SRAM data can only use the image_sram function. I have not tried to compile this recently. Has there been an Arduino IDE update with a new compiler that changed the semanics of PROGMEM/const. When I wrote the code the meaing of PROGMEM/const was:
(the line() function uses the above depending on which memory area is being accessed - there is a read_progmem boolean to control this) Hope that clears things up - but let me know if something is wrong. |
image.sram() functions take in two parameters that are both const uint8_t. This would only work with saved images rather than a buffer as described...unless I am missing something?
The text was updated successfully, but these errors were encountered: