This article provides a walkthrough on setting up the LCD screen on WSTK for a Bluetooth SDK project. This process may also suit projects which are using different SDKs under the Gecko SDK Suite but it has only been tested with the soc-empty from the Bluetooth SDK.
The process is slightly different depending on which Bluetooth SDK version you are using, 2.6.x or older and 2.7.x or newer. This relates to a change on SDK 2.7.0 where the SDK projects no longer link to files in the SDK but rather copy them onto the workspace project.
For the 2.7.x and newer SDKs you can use a script that automates the manual file copying making the process a lot faster and user friendly.
Attached you can find a soc-empty Bluetooth SDK example extended with LCD functionality. The example works on BRD4153A radio board, but the process of adding LCD support is very similar for every radio board.
To add LCD support to a project follow these steps:
1- Create lcd-graphics folder in your project.
2- Drag and drop the files below to lcd-graphics folder. It is wise to select the Link to files option and choose the STUDIO_SDK_LOC symbol as a root. This makes the project portable.
Files needed for LCD handling:
Additionally, all the .c files needed from here:
Once every files added the lcd-graphics folder looks like this:
3- Add the following paths to the include paths
Include paths can be added on project properties dialog.
1- Copy the attached script lcd_support.bat into your soc-empty project directory. The script assumes that the SDK is installed in the default studio path so make sure to change this in the script if the SDK path is different.
:: Note: This is the standard installation path for the GSDK, if it's different on your installation please update the variable below SET SDKS_PATH=C:\SiliconLabs\SimplicityStudio\v4\developer\sdks\gecko_sdk_suite
Run the script and you will find 2 additional folders in your project, lcd-graphics and dmd.
2- Add the following path to the include paths:
Assuming you are using GCC this will be in project properties -> "C/C++ Build" -> Settings -> "GNU ARM C Compiler" -> Includes
3- Add this line to hal-config.h:
#define HAL_SPIDISPLAY_FREQUENCY (1000000)
There is a set of basic LCD handling functions collected in graphics.h/.c . These are:
void GRAPHICS_Init(void); void GRAPHICS_Sleep(void); void GRAPHICS_Wakeup(void); void GRAPHICS_Update(void); void GRAPHICS_AppendString(char *str); void GRAPHICS_Clear(void); void GRAPHICS_InsertTriangle(uint32_t x, uint32_t y, uint32_t size, bool up, int8_t fillPercent);
To use these functions you need to include graphics.h.
Before using the LCD it needs to be initialized by calling the GRAPHICS_Init function
GRAPHICS_Clear(); GRAPHICS_AppendString("Hello World!\n"); GRAPHICS_Update();
Note: The graphics.h is limited but easy to use. If you need features that graphics.h does not support than use glib graphics library directly. You can find the glib reference here.
This doesnt work in my code. I also get a red cross in mij project explorer for the C file displaypalemlib.c en udelay.c
Anybody some ideas?
it does not compile...
the sdk-directory ...\platform\middleware\glib\ will not be found.
for example "em_types.h"
I use: c:\SiliconLabs\SimplicityStudio\v4\developer\sdks\gecko_sdk_suite\v2.0\
In file included from ../lcd-graphics/bmp.c:16:0:
../lcd-graphics/bmp.h:23:22: fatal error: em_types.h: No such file or directory
How can I fix the Problem?
This worked for me on an EFR32xG21 kit (BRD4180A attached to PCB4001), but I didn't follow your example exactly as described. Here's what I did:
Rather than create "lcd-graphics" and "dmd" folders, I added all of the files described in lcd_support.bat to my project, putting them in folders matching the SDK hierarchy:
I then added my newly-created folders (util\silicon_labs\silabs_core\graphics, platform\middleware\glib, platform\middleware\glib\dmd and platform\middleware\glib\glib) to my project's include path.
This got everything to compile and run. I think I prefer this approach, because it is easier to locate the original SDK folders (in case I need to add more file sin the future) if my project hierarchy mimics the SDK hierarchy
The SoC Empty for the bluetooth devices initializes the system and starts advertising beacon and doesn't return from the "appMain(&config);" call. If you use Silabs Blue Gecko or Wireless Gecko smartphone app and the respective "Bluetooth Browser" you will see the "Empty Example" device show up. You can connect and disconnect from this simple application.
If you switch your code to be:
/* Initialize device */
/* Initialize board */
/* Initialize application */
/* Start application */
you should see the display with "Hello World!" now.
If you don't, please make sure you have a bootloader present. If don't want to create your own bootloader, load one of the Getting Started Demos and then flash the empty project. This will load a "dummy bootloader" that simply jumps directly to your application rather than do bootloader stuff.
Let me know if this works for you.
Great Brian. Thanks for letting me know it worked too.