|
|
View previous topic :: View next topic |
Author |
Message |
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Wed Feb 08, 2017 5:34 am |
|
|
Your changes did work, PCM programmer. Even though by placing all the font of a certain size occupies of the RAM more, as predicted. Is there any other way to display letters that doesn't include the placing all the font inside the RAM?
Because what I am encountering right now is that I can not include any other size that is higher that Tahoma 10 because of RAM space. And, of course, I can not include different font sizes because that implies the usage of too much RAM.
Thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19195
|
|
Posted: Wed Feb 08, 2017 6:22 am |
|
|
It should work if you declare the array as rom, rather than const, and change the pointer declarations in the calls to char rom *. |
|
|
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Fri Feb 10, 2017 1:08 pm |
|
|
Ttelmah wrote: | It should work if you declare the array as rom, rather than const, and change the pointer declarations in the calls to char rom *. |
i have stored the font successfully in the rom but idk how to call it. When I use it a random set of pixels appears were the font should be. Any ideas how to successfully call the stored font?
thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Feb 10, 2017 11:20 pm |
|
|
Here are the changes I made to my font access test program to make it
work with the 'rom' keyword. In the case of the function prototypes and
the function declarations, the 'unsigned char' had to be removed and
replaced with 'rom'. When I did all these things, it compiled and produced
the correct output for the tilde '~' character. I also tested it for 'A'.
This was tested with compiler version 5.068.
Changes are shown in bold below:
In the font_tahoma.h file:
Quote: | unsigned char rom Tahoma10[] = |
Function prototypes in the main file:
Quote: | bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing);
bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font); |
The declaration of the draw_text() function:
Quote: | bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing)
{
bounding_box_t ret;
bounding_box_t tmp;
.
.
.
|
The declaration of the draw_char() function:
Quote: | bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font)
{
unsigned int16 pos;
unsigned char width;
bounding_box_t ret;
unsigned int i;
.
.
.
|
|
|
|
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Sun Feb 12, 2017 4:26 pm |
|
|
PCM programmer wrote: | Here are the changes I made to my font access test program to make it
work with the 'rom' keyword. In the case of the function prototypes and
the function declarations, the 'unsigned char' had to be removed and
replaced with 'rom'. When I did all these things, it compiled and produced
the correct output for the tilde '~' character. I also tested it for 'A'.
This was tested with compiler version 5.068.
Changes are shown in bold below:
In the font_tahoma.h file:
Quote: | unsigned char rom Tahoma10[] = |
Function prototypes in the main file:
Quote: | bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing);
bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font); |
The declaration of the draw_text() function:
Quote: | bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing)
{
bounding_box_t ret;
bounding_box_t tmp;
.
.
.
|
The declaration of the draw_char() function:
Quote: | bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font)
{
unsigned int16 pos;
unsigned char width;
bounding_box_t ret;
unsigned int i;
.
.
.
|
|
Hi PCM programmer, I did also try this solution but forgot to get rid off the "unsigned char" thing, thank you |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19195
|
|
Posted: Mon Feb 13, 2017 2:41 am |
|
|
It should have worked with the "unsigned char". However the declarations in the function definitions would need to be "rom unsigned char *". It's a bit of a 'black art' (unfortunately poorly documented), with the order having to be 'just right' or it won't compile or work correctly. By omitting the type (as PCM_programmer shows), the compiler 'assumes' int8 *, which happens to be treated identically to unsigned char *, so works and is a lot shorter to type...... Where the declaration would be needed, is if declaring something of a different size in rom (int16, int32 etc.).
One of those 'very poorly documented' abilities/features. Very useful (allowing you to work with tables of stuff stored in rom, without having to use a ram buffer), but requiring 'practice' to make work correctly. |
|
|
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Mon Feb 13, 2017 9:51 am |
|
|
By now trying this rom sol'n on the display itself nothing appears where the letters should be. My compiler version is 4.104.
Any ideas on why?
thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19195
|
|
Posted: Mon Feb 13, 2017 9:59 am |
|
|
Ouch 4.104...
There were quite a lot of problems with V4 around this point.
Historically V4, only started working reasonably around 4.059. Then around 4.099, they had several versions with faults again. The use of rom pointers, was a new feature, only introduced about then (about 4.090), and it didn't work reliably for quite a few versions... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19195
|
|
Posted: Mon Feb 13, 2017 10:23 am |
|
|
I may have maligned it.
Just tried a basic test accessing data declared in rom, and with a rom * pointer, and it works OK.
You need to do some basic debugging. |
|
|
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Tue Feb 14, 2017 8:23 am |
|
|
Ttelmah wrote: | I may have maligned it.
Just tried a basic test accessing data declared in rom, and with a rom * pointer, and it works OK.
You need to do some basic debugging. |
Can it be something to do with that I am trying to display letters from the ROM and RAM at the same time?
jaume |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19195
|
|
Posted: Tue Feb 14, 2017 8:43 am |
|
|
Undoubtedly.
You need to rethink your code. Fundamental understanding of the PIC needed. The PIC uses a Harvard architecture. The ROM and the RAM are in two different address spaces. This is different from chips like the Intel 808x and it's derivatives, which have a 'unified' memory architecture (Von Neumann architecture). On these latter chips, everything has a unique address, with RAM and ROM at different points in the address range. On the PIC this isn't the case. There is an 'address 0' in ROM, and another in RAM. You can't mix addresses from one to the other. This is why there is a separate rom pointer type. |
|
|
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Tue Feb 21, 2017 9:17 am |
|
|
PCM programmer wrote: | Here are the changes I made to my font access test program to make it
work with the 'rom' keyword. In the case of the function prototypes and
the function declarations, the 'unsigned char' had to be removed and
replaced with 'rom'. When I did all these things, it compiled and produced
the correct output for the tilde '~' character. I also tested it for 'A'.
This was tested with compiler version 5.068.
Changes are shown in bold below:
In the font_tahoma.h file:
Quote: | unsigned char rom Tahoma10[] = |
Function prototypes in the main file:
Quote: | bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing);
bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font); |
The declaration of the draw_text() function:
Quote: | bounding_box_t draw_text(char *string, unsigned char x, unsigned char y, rom *font, unsigned char spacing)
{
bounding_box_t ret;
bounding_box_t tmp;
.
.
.
|
The declaration of the draw_char() function:
Quote: | bounding_box_t draw_char(unsigned char c, unsigned char x, unsigned char y, rom *font)
{
unsigned int16 pos;
unsigned char width;
bounding_box_t ret;
unsigned int i;
.
.
.
|
|
When here you say "functions prototype in the main file" you mean that have to be made also in the <graphic.h> file in addition to the changes made to the <graphics.h> and in the <font_tahoma.h>? I have been trying it out lately and when the changes are made in the above mentioned files nothing appears where the letters should be.
If when here you say "functions prototype in the main file" you mean in the <main.c> file, it says not enough RAM when writing the code in the void main loop, as expected.
Any ideas how to fix this?
thanks
jaume |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 21, 2017 11:37 am |
|
|
Quote: | If when here you say "functions prototype in the main file" you mean in the <main.c> file |
Yes, I mean in main.c.
If you have function prototypes, wherever they are located, they and
the actual function declarations must match. If the function has 'rom'
in the declaration, then so must the prototype.
Quote: |
it says not enough RAM when writing the code in the void main loop, as expected |
Why would it be "as expected" ? Didn't you place the font files in 'rom' ?
They might use up a lot of ROM (flash memory), but not ram.
I don't know what is in your program. Maybe you added code to use up
all the RAM. |
|
|
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Tue Feb 21, 2017 11:45 am |
|
|
Well it says that there is not enough space for all the variables when I write it in the void main() but not when written out of the loop.
Not sure why I said as expected there.
Shouldn't this change from unsigned char*font to rom*char be also made in <graphics.h> ?
thanks
jaume |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 21, 2017 12:02 pm |
|
|
I looked at page 2 of this thread, at graphics.h, and it has function
prototypes that have the font array as a parameter. So yes, if the font
array is declared as 'rom', then you must edit all functions and function
prototypes to declare *font as 'rom'. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|