2024-04-22 02:12 AM
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', µsoftSansSerif_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
Solved! Go to Solution.
2024-04-22 02:58 AM
@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:
2024-04-22 02:33 AM - edited 2024-04-22 02:34 AM
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...
2024-04-22 02:36 AM
Create font.c file and put your fonts declaration there.
in font .h export these fonts as extern.
in main.c include font.h.
2024-04-22 02:37 AM
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
2024-04-22 02:48 AM
oooo, just if you have .h and c. files !!! Only import, what you need. :)
2024-04-22 02:58 AM
@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:
2024-04-22 03:03 AM
This is an example:
https://github.com/STMicroelectronics/STM32CubeF1/tree/master/Utilities/Fonts
2024-04-22 03:17 AM
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