Git Product home page Git Product logo

cfgui's Introduction

cfGUI

A simple GUI library for M5Stack (ESP32)

This library is intended to run on M5Stack development board (http://www.m5stack.com/), base on ESP32.

However, it should be easy to port it to any other board with an LCD screen and 3 physical buttons.

It's composed of a simple hierarchy of graphical widget that can be drawn on screen. The following widgets have been created so far:

  • Screen and AppScreen (screen with a top bar and a bottom bar)
  • Bar
  • StatusBar (Bar with uptime, clock and Wifi signal)
  • ButtonInfoBar (display the function of the physical button)
  • Button, UpDownButton
  • Mosaic of widgets

Example picture of cfGUI running on a M5Stack board

How To (Platform.io)

To use this library with your platform.io project, simply clone or download the library into the directory 'lib' of your project. Then, you just need to include the headers (e.g. #include <Screen.h>) and write some code.

Look at examples if you need some inspiration ;-)

Here is an example of platformio.ini file:

[env:m5stack-core-esp32]
platform = espressif32
board = m5stack-core-esp32
framework = arduino
lib_deps=M5Stack, NTPClient
build_flags=-std=gnu++11

Todo

  • Remove hard-coded values to make the lib more flexible
  • Add new widgets
  • Better 'focus' management

Changelog

0.3.0

  • New redraw() strategy (replace SetUpdatedFlag() by Invalidate(), performances improved and flickering reduced
  • Support new version of M5Stack lib
  • Fix crash when the center button was pushed with no widget selected

0.2.0

  • Change default font (looks better)
  • New widgets (AppScreen, StatusBar, ButtonInfoBar, UpDownButton)
  • Improved mosaic (the size and position of the widget is not hard-coded anymore)
  • Global improvements

0.1.0

  • First version of the library, with basic functionalities

cfgui's People

Contributors

jf002 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cfgui's Issues

Example outdated

Looks like the StatusBar is outdated against the M5stack library, the position of the parameters have changed and now it doesn't properly shows the wifi bitmap =(

Widget and WidgetMosaic fail to complie in a fresly installed VSCode (2021.01), [-Werror=reorder]

There is an issue with the order in which private fields are declared in cpp files. It's a trivial fix and will issue a PR soon. This issue is just to reference the branch name for PR and leave a trace in case someone hits the same error. Adding -Werror=reorder build flag workaround does not work for this issue.


Library Manager: M5Stack @ 0.1.9 has been installed!
Library Manager: Installing NTPClient
Library Manager: Warning! More than one package has been found by NTPClient requirements:
 - arduino-libraries/NTPClient @ 3.1.0
 - limiteddata/NTPClient @ 3.1.0
 - mbed-dietergraef/NTPClient @ 0.0.0-alpha+sha.584a18640e84
 - mbed-robot-arm-demo-team/NTPClient @ 0.0.0+sha.9a7b8df5fad7
 - mbed-kkempeneers/NTPClient @ 0.0.0+sha.537dcd4ff837
 - mbed-ibiltari/NTPClient @ 0.0.0+sha.f31bb718d362
 - mbed-sparkfun/NTPClient @ 0.0.0+sha.881559865a93
 - mbed-vpcola/NTPClient @ 0.0.0+sha.0b96fbd7cfca
 - mbed-kubegmbh/NTPClient @ 0.0.0+sha.c2440e1c92cc
 - mbed-lmussier/NTPClient @ 0.0.0+sha.175284afeb38
Library Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Library Manager: NTPClient @ 3.1.0 has been installed!
Found 29 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <M5Stack> 0.1.9
|   |-- <FS> 1.0
|   |-- <SPIFFS> 1.0
|   |   |-- <FS> 1.0
|   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
|   |-- <SD(esp32)> 1.0.5
|   |   |-- <FS> 1.0
|   |   |-- <SPI> 1.0
|-- <NTPClient> 3.1.0
|-- <cfGUI> 0.3.0
|   |-- <M5Stack> 0.1.9
|   |   |-- <FS> 1.0
|   |   |-- <SPIFFS> 1.0
|   |   |   |-- <FS> 1.0
|   |   |-- <SPI> 1.0
|   |   |-- <Wire> 1.0.1
|   |   |-- <SD(esp32)> 1.0.5
|   |   |   |-- <FS> 1.0
|   |   |   |-- <SPI> 1.0
|-- <WiFi> 1.0


// a usual compilation output with couple of warnings removed   


Compiling .pio\build\m5stack-core-esp32\lib66b\cfGUI\ressources\wifi3.c.o
lib\cfGUI\src\Button.cpp: In member function 'virtual void Codingfield::UI::Button::Draw()':
lib\cfGUI\src\Button.cpp:98:50: warning: 'yTitle' may be used uninitialized in this function [-Wmaybe-uninitialized]
       M5.Lcd.drawString(title.c_str(), x, yTitle);
                                                  ^
Compiling .pio\build\m5stack-core-esp32\lib5bc\WiFi\ETH.cpp.o
Archiving .pio\build\m5stack-core-esp32\libbdf\libM5Stack.a
Compiling .pio\build\m5stack-core-esp32\lib5bc\WiFi\WiFi.cpp.o
In file included from lib\cfGUI\src\Widget.cpp:1:0:
lib\cfGUI\src\Widget.h: In constructor 'Codingfield::UI::Widget::Widget(Codingfield::UI::Widget*, Codingfield::UI::Point, Codingfield::UI::Size)':
lib\cfGUI\src\Widget.h:81:24: error: 'Codingfield::UI::Widget::parent' will be initialized after [-Werror=reorder]
       Widget* parent = nullptr;
                        ^
lib\cfGUI\src\Widget.h:79:13: error:   'Codingfield::UI::Point Codingfield::UI::Widget::position' [-Werror=reorder]
       Point position;
             ^
lib\cfGUI\src\Widget.cpp:9:1: error:   when initialized here [-Werror=reorder]
 Widget::Widget(Widget* parent, Point position, Size size) :  parent{parent}, position{position}, size {size} {
 ^
Compiling .pio\build\m5stack-core-esp32\lib5bc\WiFi\WiFiAP.cpp.o
Compiling .pio\build\m5stack-core-esp32\lib5bc\WiFi\WiFiClient.cpp.o
Compiling .pio\build\m5stack-core-esp32\lib5bc\WiFi\WiFiGeneric.cpp.o
Compiling .pio\build\m5stack-core-esp32\lib5bc\WiFi\WiFiMulti.cpp.o
Compiling .pio\build\m5stack-core-esp32\lib5bc\WiFi\WiFiSTA.cpp.o
cc1plus.exe: some warnings being treated as errors
Compiling .pio\build\m5stack-core-esp32\lib5bc\WiFi\WiFiScan.cpp.o
Compiling .pio\build\m5stack-core-esp32\lib5bc\WiFi\WiFiServer.cpp.o
Compiling .pio\build\m5stack-core-esp32\lib5bc\WiFi\WiFiUdp.cpp.o
*** [.pio\build\m5stack-core-esp32\lib66b\cfGUI\Widget.cpp.o] Error 1
In file included from lib\cfGUI\src\WidgetMosaic.cpp:1:0:
lib\cfGUI\src\WidgetMosaic.h: In constructor 'Codingfield::UI::WidgetMosaic::WidgetMosaic(Codingfield::UI::Widget*, Codingfield::UI::Point, Codingfield::UI::Size, int32_t, int32_t)':
lib\cfGUI\src\WidgetMosaic.h:25:15: error: 'Codingfield::UI::WidgetMosaic::nbColumns' will be initialized after [-Werror=reorder]
       int32_t nbColumns;
               ^
lib\cfGUI\src\WidgetMosaic.h:24:15: error:   'int32_t Codingfield::UI::WidgetMosaic::nbRows' [-Werror=reorder]
       int32_t nbRows;
               ^
lib\cfGUI\src\WidgetMosaic.cpp:4:1: error:   when initialized here [-Werror=reorder]
 WidgetMosaic::WidgetMosaic(Widget* parent, Point position, Size size, int32_t nbColumns, int32_t nbRows) : Widget(parent, position,
size),
 ^
cc1plus.exe: some warnings being treated as errors
*** [.pio\build\m5stack-core-esp32\lib66b\cfGUI\WidgetMosaic.cpp.o] Error 1
==================================================== [FAILED] Took 30.94 seconds ====================================================

Issues while compiling

I am seeing these issues on the library, just wondering how to solve it

In file included from lib/cfGUI/src/Screen.h:3:0, from src/main.cpp:4: lib/cfGUI/src/Widget.h:69:12: error: 'vector' in namespace 'std' does not name a template type std::vector<Widget*> children; ^ lib/cfGUI/src/Widget.h: In member function 'virtual void Codingfield::UI::Widget::AddChild(Codingfield::UI::Widget*)': lib/cfGUI/src/Widget.h:40:47: error: 'children' was not declared in this scope virtual void AddChild(Widget* widget) { children.push_back(widget); } ^

ntpclient

hello, what library from ntpclient client did you use?

Design decision to provide compatibility with M5Stack Core2

I have a working code that supports M5Stack Core2. A couple of things require design decisions to make the cfGUI library compatible with Core and Core2 (if both should be supported by the same code base - this is also a design decision on its own):

  1. Core2 uses a different library (M5Core2 instead of M5Stack) and WIdget.h includes M5Stack,h. Since in the M5Stack codebase I have not experienced the existence of namespaces.. either one must be included. How should the conditional import be approached? is a pre-processor condition acceptable (#ifdef M5Core and #ifdef M5Core2) that would import selected header file in Widget,h?
  2. Core2 has a touchscreen and the initial support for it in the M5Core2 uses a "Point" structure which conflicts with the "Point" structure name used in cfGUI. Primitive fix is to rename the structure in cfGUI..
  3. Touchscreen input changes the navigation and widgets interaction philosophy - maybe Core2 support should be done in a different branch? Or if you (@JF002) do not plan the develop this library any further - should I continue adding features in my fork?

Adding a license

I would like to kindly ask you to add a license to your project. As it is now, neither personal nor commercial use of your code is permitted withouth potential legal issues.

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.