cancel
Showing results for 
Search instead for 
Did you mean: 

Join a font in a main.C

JJoao.1
Associate III

Hi everybody,

 

After several attempts, I cannot correctly declare my variables in the files. I'm a little lost with file declarations to reach certain variables delcared elsewhere

This is why I decided to come and ask for help.

 

I 'm actually work on a screen with st7567 driver.

For that I have create à font.h to stock some font : like this

 

 

 

 

// Character bitmaps for Microsoft Sans Serif 10pt
const uint8_t microsoftSansSerif_10pt[] =
{
	// @0 '!' (1 pixels wide)
	// #
	// #
	// #
	// #
	// #
	// #
	// #
	// #
	//
	// #
	0xFF,
	0x02,

	// @2 '"' (3 pixels wide)
	// # #
	// # #
	// # #
	// # #
	0x0F, 0x00, 0x0F,

 

 

 

 

 

after I have create a driver to communciate with the st7567 driver.

I have call this files st7567_driver.h and st7567_driver.c .

In the st7567_driver.c I declared file like this :

 

 

 

 

/**************************************************************************************
 * Included Files
 **************************************************************************************/

#include <stdint.h>
#include <stdbool.h>
#include <string.h>

#include "stm32l031xx.h"
#include "main.h"
#include "st7567_driver.h"
#include "font.h"


extern SPI_HandleTypeDef hspi1;  // Je mets extern pour signifier que la déclaration de la fonction est ailleurs ( dans le main.c)

 

 

 

 

 

Now the problem begin because I'm A noob :

 

In my main.c , I would like to use a function which sends the name of the font to use.

 

 

 

 

  Draw_text(0,0,'K', &microsoftSansSerif_10pt);

 

 

 

 

 

microsoftSansSerif_10pt is the name of my font in the font.h

 

But the comoler send me an error :

../Core/Src/main.c:110:23: error: 'microsoftSansSerif_10pt' undeclared (first use in this function)

 

I tried several ways to do it with the words "extern" to declare antoher file etc...

I also read the documentation, but I did not succeed in understanding the process.

 

IF someone who knows this subject well could guide me on how and where to declare the files that would be super nice.

Thank you vcery much

dje8269

 

1 ACCEPTED SOLUTION

Accepted Solutions

@JJoao.1 wrote:

After several attempts, I cannot correctly declare my variables in the files. I'm a little lost with file declarations to reach certain variables delcared elsewhere

 


This is standard C programming stuff:

https://community.st.com/t5/stm32cubeide-mcus/adding-new-c-source-files-to-my-project-and-navigating-through/m-p/657455/highlight/true#M25847

 

View solution in original post

7 REPLIES 7
AScha.3
Chief III

Hi,

how did you get your files to the project ?

-> You have to "import" them, so the IDE/compiler knows, they are part of project now:

right click on folder to import -> file system-> select directory: files to import ; 2x , for .h and .c then.

Then compile again...

If you feel a post has answered your question, please click "Accept as Solution".
SofLit
ST Employee

Create font.c file and put your fonts declaration there.

in font .h export these fonts as extern.

in main.c include font.h.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Thank you for the reply AScha.3 ,

I created them and not imported them

I wonder if I should create a font.c instead of font.h

oooo, just if you have .h and c. files !!! Only import, what you need. :)

 

If you feel a post has answered your question, please click "Accept as Solution".

@JJoao.1 wrote:

After several attempts, I cannot correctly declare my variables in the files. I'm a little lost with file declarations to reach certain variables delcared elsewhere

 


This is standard C programming stuff:

https://community.st.com/t5/stm32cubeide-mcus/adding-new-c-source-files-to-my-project-and-navigating-through/m-p/657455/highlight/true#M25847

 

SofLit
ST Employee

This is an example:

https://github.com/STMicroelectronics/STM32CubeF1/tree/master/Utilities/Fonts

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
JJoao.1
Associate III

Thank you s omuch for your answwers !

I think I succeeded!


I redid the configuration as in the link sent by Andrew Neil.
I had to create a .c and a .h file

In the .h i declared extern variable

in my .c file I write my font normaly.

And in my Main.c I include font.h

 

Thank you so much