Mxgui OLED example: Difference between revisions

From Miosix Wiki
Jump to navigation Jump to search
Created page with "= Before you begin = This tutorial assumes that you have read the Miosix and git workflow and that you have already downloaded and configured the kernel. The code of this..."
 
Update instructions to latest Miosix version.
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
= Before you begin =
= Before you begin =
This tutorial is mainly focused at showing
* How to add Mxgui to your project
* How to drive a small OLED display that can be easily found on ebay with Mxgui
[[File:Small_oled.jpg]]


This tutorial assumes that you have read the [[Miosix and git workflow]] and that you have already downloaded and configured the kernel.
This tutorial assumes that you have read the [[Miosix and git workflow]] and that you have already downloaded and configured the kernel.
Line 28: Line 34:
Add the mxgui directory to SUBDIRS so when you run make, the graphics library will be compiled
Add the mxgui directory to SUBDIRS so when you run make, the graphics library will be compiled
<source lang="bash">
<source lang="bash">
SUBDIRS := $(KPATH) mxgui
SUBDIRS += mxgui
</source>
</source>


Line 38: Line 44:
Add both the mxgui directory and the directory one level upper to INCLUDE_DIRS so includes will work
Add both the mxgui directory and the directory one level upper to INCLUDE_DIRS so includes will work
<source lang="bash">
<source lang="bash">
INCLUDE_DIRS := -I. -Imxgui
INCLUDE_DIRS := -Imxgui
</source>
</source>


Now, edit mxgui_settings.h as follows, commenting out these two lines.
Now, edit mxgui_settings.h as follows, commenting out the following line.
The second line serves to disable the input module of the library, as in this example we don't have a touchscreen driver.
The purpose of this change is to disable the input module of the library, as in this example we don't have a touchscreen driver.
<source lang="bash">
<source lang="C">
#error This error is a reminder that you have not edited mxgui_settings.h yet.
#define MXGUI_LEVEL_2
#define MXGUI_LEVEL_2
</source>
</source>

Latest revision as of 00:18, 18 December 2025

Before you begin

This tutorial is mainly focused at showing

  • How to add Mxgui to your project
  • How to drive a small OLED display that can be easily found on ebay with Mxgui

This tutorial assumes that you have read the Miosix and git workflow and that you have already downloaded and configured the kernel. The code of this example can be found in the mxgui library itself https://github.com/fedetft/mxgui/tree/master/_examples/display_ly091wg14

Configuration

In the Miosix top-level directory (or in the directory of your project if you are using an out of git tree project download the mxgui library. If you are under a git repository

git submodule add https://github.com/fedetft/mxgui.git

or if your project directory is not under git

git clone https://github.com/fedetft/mxgui.git

If you are using an out of git tree project setup is is recomended to copy the mxgui/config/mxgui_settings.h file in your project config directory as you'll need to edit it.

cp mxgui/config/mxgui_settings.h config

Now edit your makefile to add the following:

Add the mxgui directory to SUBDIRS so when you run make, the graphics library will be compiled

SUBDIRS += mxgui

Add libmxgui.a to LIBS so the the graphics library will be linked

LIBS := mxgui/libmxgui.a

Add both the mxgui directory and the directory one level upper to INCLUDE_DIRS so includes will work

INCLUDE_DIRS := -Imxgui

Now, edit mxgui_settings.h as follows, commenting out the following line. The purpose of this change is to disable the input module of the library, as in this example we don't have a touchscreen driver.

#define MXGUI_LEVEL_2

Replace your main with the example code and edit it as needed to match the pins to the ones of the display

cp mxgui/_examples/display_ly091wg14/main.cpp .

Build the example with make, and flash it with make program.