Skip to content

Commit

Permalink
General enhancements
Browse files Browse the repository at this point in the history
- Add: Line element (gslc_ElemCreateLine)
- Add: Support for capacitive touch (FT6206) on Arduino (DRV_TOUCH_ADA_FT6206)
- Add: Support for touch axis swap and flipping on Arduino (ADATOUCH_SWAP_XY, ADATOUCH_FLIP_X, ADATOUCH_FLIP_Y)
- Add: Support for gauge element direction flipping (gslc_ElemXGaugeSetFlip) and improved redraw.
- Add: Support for GUIslice with LINUX mouse support in DRV_DISP_SDL* (eg. Raspberry Pi with HDMI display) using DRV_SDL_MOUSE_SHOW. Note that mouse dragging is not yet supported.
- Update: Configuration (GUIslice_config.h) updated to use more consistent notation with #define. Added GUIslice config guide (docs/GUIslice_config_guide.xlsx) to demonstrate example CPU / board / display configuration settings.
- Fix: Fixed error in DRV_TOUCH_SDL mode
- Migration Notes (from 0.8.3):
  - The following #define should now use an explicit value (1 to enable, 0 to disable): ADAGFX_SPI_HW, ADATOUCH_I2C_HW, ADATOUCH_SPI_HW, ADATOUCH_SPI_SW, DRV_SDL_FIX_START.
  • Loading branch information
ImpulseAdventure committed Mar 8, 2017
1 parent 5f17cc7 commit 95654cd
Show file tree
Hide file tree
Showing 14 changed files with 320 additions and 147 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A lightweight GUI framework suitable for embedded displays
- [Website (www.impulseadventure.com)](http://www.impulseadventure.com/elec/guislice-gui.html)
- [Documentation wiki (github)](https://github.com/ImpulseAdventure/GUIslice/wiki)
- [Release notes] (https://github.com/ImpulseAdventure/GUIslice/releases)
- **Support email**: guislice @ impulseadventure . com


- Pure C library, no dynamic memory allocation
- Widgets: text, images, buttons, checkboxes, radio buttons, sliders, etc. plus extensions and multiple pages.
Expand All @@ -23,4 +23,4 @@ Screenshots
![Example 1](http://www.impulseadventure.com/elec/images/sdl_menu1.png)
![Example 2](http://www.impulseadventure.com/elec/images/microsdl-ex07.png)
![Example 3](http://www.impulseadventure.com/elec/images/guislice-ex06.png)
![Example 4](http://www.impulseadventure.com/elec/images/guislice-ex08.png)
![Example 4](http://www.impulseadventure.com/elec/images/guislice-ex08.png)
20 changes: 15 additions & 5 deletions arduino/gslc_ex04_ard/gslc_ex04_ard.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

// Enumerations for pages, elements, fonts, images
enum {E_PG_MAIN};
enum {E_ELEM_BOX,E_ELEM_BTN_QUIT,E_ELEM_TXT_COUNT,E_ELEM_PROGRESS,
enum {E_ELEM_BOX,E_ELEM_BTN_QUIT,E_ELEM_TXT_COUNT,E_ELEM_PROGRESS,E_ELEM_PROGRESS1,
E_ELEM_CHECK1,E_ELEM_RADIO1,E_ELEM_RADIO2,E_ELEM_SLIDER,E_ELEM_TXT_SLIDER};
enum {E_FONT_BTN,E_FONT_TXT};
enum {E_GROUP1};
Expand All @@ -41,7 +41,7 @@ unsigned m_nCount = 0;
// data into Flash (PROGMEM) and those that don't, we can make the
// number of elements in Flash dependent upon GSLC_USE_PROGMEM
// - This should allow both Arduino and ARM Cortex to use the same code
#define MAX_ELEM_PG_MAIN 14 // # Elems total
#define MAX_ELEM_PG_MAIN 15 // # Elems total
#if (GSLC_USE_PROGMEM)
#define MAX_ELEM_PG_MAIN_PROG 6 // # Elems in Flash
#else
Expand All @@ -56,7 +56,7 @@ gslc_tsPage m_asPage[MAX_PAGE];
gslc_tsElem m_asPageElem[MAX_ELEM_PG_MAIN_RAM];
gslc_tsElemRef m_asPageElemRef[MAX_ELEM_PG_MAIN];

gslc_tsXGauge m_sXGauge;
gslc_tsXGauge m_sXGauge,m_sXGauge1;
gslc_tsXCheckbox m_asXCheck[3];
gslc_tsXSlider m_sXSlider;

Expand All @@ -66,6 +66,7 @@ gslc_tsXSlider m_sXSlider;
// Save some element references for quick access
gslc_tsElem* m_pElemCnt = NULL;
gslc_tsElem* m_pElemProgress = NULL;
gslc_tsElem* m_pElemProgress1 = NULL;
gslc_tsElem* m_pElemSlider = NULL;
gslc_tsElem* m_pElemSliderTxt = NULL;

Expand Down Expand Up @@ -111,13 +112,20 @@ bool InitOverlays()
gslc_ElemSetTxtCol(pElem,GSLC_COL_YELLOW);
m_pElemCnt = pElem; // Save for quick access

// Create progress bar
// Create progress bar (horizontal)
gslc_ElemCreateTxt_P(&m_gui,102,E_PG_MAIN,20,80,50,10,"Progress:",&m_asFont[1], // E_FONT_TXT
GSLC_COL_YELLOW,GSLC_COL_BLACK,GSLC_COL_BLACK,GSLC_ALIGN_MID_LEFT,false,true);
pElem = gslc_ElemXGaugeCreate(&m_gui,E_ELEM_PROGRESS,E_PG_MAIN,&m_sXGauge,
(gslc_tsRect){80,80,50,10},0,100,0,GSLC_COL_GREEN,false);
m_pElemProgress = pElem; // Save for quick access


// Second progress bar (vertical)
// - Demonstration of vertical bar with offset zero-pt showing both positive and negative range
pElem = gslc_ElemXGaugeCreate(&m_gui,E_ELEM_PROGRESS1,E_PG_MAIN,&m_sXGauge1,
(gslc_tsRect){280,80,10,100},-25,75,-15,GSLC_COL_RED,true);
gslc_ElemSetCol(pElem,GSLC_COL_BLUE_DK3,GSLC_COL_BLACK,GSLC_COL_BLACK);
m_pElemProgress1 = pElem; // Save for quick access

// Create checkbox 1
gslc_ElemCreateTxt_P(&m_gui,103,E_PG_MAIN,20,100,20,20,"Check1:",&m_asFont[1], // E_FONT_TXT
GSLC_COL_YELLOW,GSLC_COL_BLACK,GSLC_COL_BLACK,GSLC_ALIGN_MID_LEFT,false,true);
Expand Down Expand Up @@ -199,6 +207,8 @@ void loop()
snprintf(acTxt,MAX_STR,"Slider: %u",nPos);
gslc_ElemSetTxtStr(m_pElemSliderTxt,acTxt);

gslc_ElemXGaugeUpdate(m_pElemProgress1,(nPos*80.0/100.0)-15);

// Periodically call GUIslice update function
gslc_Update(&m_gui);

Expand Down
Binary file added docs/GUIslice_config_guide.xlsx
Binary file not shown.
Binary file added docs/GUIslice_ref.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion doxygen.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "GUIslice"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.8.3
PROJECT_NUMBER = 0.8.4

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
36 changes: 34 additions & 2 deletions src/GUIslice.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// - Calvin Hass
// - http://www.impulseadventure.com/elec/guislice-gui.html
//
// - Version 0.8.3 (2017/01/17)
// - Version 0.8.4 (2017/03/05)
// =======================================================================
//
// The MIT License
Expand Down Expand Up @@ -48,7 +48,7 @@
#include <stdarg.h> // For va_*

// Version definition
#define GUISLICE_VER "0.8.3"
#define GUISLICE_VER "0.8.4"


// ========================================================================
Expand Down Expand Up @@ -1302,6 +1302,30 @@ gslc_tsElem* gslc_ElemCreateBox(gslc_tsGui* pGui,int16_t nElemId,int16_t nPage,g
}
}

gslc_tsElem* gslc_ElemCreateLine(gslc_tsGui* pGui,int16_t nElemId,int16_t nPage,int16_t nX0,int16_t nY0,int16_t nX1,int16_t nY1)
{
gslc_tsElem sElem;
gslc_tsElem* pElem = NULL;
gslc_tsRect rRect;
rRect.x = nX0;
rRect.y = nY0;
rRect.w = nX1 - nX0 + 1;
rRect.h = nY1 - nY0 + 1;
sElem = gslc_ElemCreate(pGui,nElemId,nPage,GSLC_TYPE_LINE,rRect,NULL,0,GSLC_FONT_NONE);
// For line elements, we will draw it with the "fill" color
sElem.colElemFill = GSLC_COL_GRAY;
sElem.colElemFillGlow = GSLC_COL_GRAY;
sElem.bFillEn = false; // Disable boundary box fill
sElem.bFrameEn = false; // Disable boundary box frame
if (nPage != GSLC_PAGE_NONE) {
pElem = gslc_ElemAdd(pGui,nPage,&sElem,GSLC_ELEMREF_SRC_RAM);
return pElem;
} else {
// Save as temporary element
pGui->sElemTmp = sElem;
return &(pGui->sElemTmp);
}
}

gslc_tsElem* gslc_ElemCreateImg(gslc_tsGui* pGui,int16_t nElemId,int16_t nPage,
gslc_tsRect rElem,gslc_tsImgRef sImgRef)
Expand Down Expand Up @@ -1488,6 +1512,14 @@ bool gslc_ElemDrawByRef(gslc_tsGui* pGui,gslc_tsElem* pElem)
#endif


// --------------------------------------------------------------------------
// Handle special element types
// --------------------------------------------------------------------------
if (pElem->nType == GSLC_TYPE_LINE) {
gslc_DrawLine(pGui,nElemX,nElemY,nElemX+nElemW-1,nElemY+nElemH-1,pElem->colElemFill);
}


// --------------------------------------------------------------------------
// Image overlays
// --------------------------------------------------------------------------
Expand Down
18 changes: 17 additions & 1 deletion src/GUIslice.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// - Calvin Hass
// - http://www.impulseadventure.com/elec/guislice-gui.html
//
// - Version 0.8.3 (2017/01/17)
// - Version 0.8.4 (2017/03/05)
// =======================================================================
//
// The MIT License
Expand Down Expand Up @@ -1207,6 +1207,22 @@ gslc_tsElem* gslc_ElemCreateBtnImg(gslc_tsGui* pGui,int16_t nElemId,int16_t nPag
///
gslc_tsElem* gslc_ElemCreateBox(gslc_tsGui* pGui,int16_t nElemId,int16_t nPage,gslc_tsRect rElem);

///
/// Create a Line Element
/// - Draws a line with fill color
///
/// \param[in] pGui: Pointer to GUI
/// \param[in] nElemId: Element ID to assign (0..16383 or GSLC_ID_AUTO to autogen)
/// \param[in] nPage: Page ID to attach element to
/// \param[in] nX0: X coordinate of line startpoint
/// \param[in] nY0: Y coordinate of line startpoint
/// \param[in] nX1: X coordinate of line endpoint
/// \param[in] nY1: Y coordinate of line endpoint
///
/// \return Pointer to the Element or NULL if failure
///
gslc_tsElem* gslc_ElemCreateLine(gslc_tsGui* pGui,int16_t nElemId,int16_t nPage,int16_t nX0,int16_t nY0,int16_t nX1,int16_t nY1);

///
/// Create an image Element
/// - Draws an image
Expand Down
64 changes: 45 additions & 19 deletions src/GUIslice_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
// User Configuration
// - This file can be modified by the user to match the
// intended target configuration
// - Please refer to "docs/GUIslice_config_guide.xlsx" for detailed examples
// specific to board and display combinations
// =======================================================================

#ifdef __cplusplus
Expand All @@ -57,7 +59,7 @@ extern "C" {
//#define DRV_TOUCH_SDL // LINUX: Use SDL touch driver
#define DRV_TOUCH_TSLIB // LINUX: Use tslib touch driver
//#define DRV_TOUCH_ADA_STMPE610 // Arduino: Use Adafruit STMPE610 touch driver
//#define DRV_TOUCH_ADA_FT6206 // Arduino: Use Adafruit FT6206 touch driver [Untested]
//#define DRV_TOUCH_ADA_FT6206 // Arduino: Use Adafruit FT6206 touch driver



Expand All @@ -68,8 +70,10 @@ extern "C" {
// Define default device paths for framebuffer & touchscreen
#define GSLC_DEV_FB "/dev/fb1"
#define GSLC_DEV_TOUCH "/dev/input/touchscreen"
// Enable SDL startup workaround?
#define DRV_SDL_FIX_START
// Enable SDL startup workaround? (1 to enable, 0 to disable)
#define DRV_SDL_FIX_START 1
// Show SDL mouse (1 to show, 0 to hide)
#define DRV_SDL_MOUSE_SHOW 0

#define GSLC_LOCAL_STR 1

Expand All @@ -86,6 +90,9 @@ extern "C" {
#define GSLC_DEV_FB "/dev/fb0"
#define GSLC_DEV_TOUCH "/dev/input/touchscreen"

// Show SDL mouse (1 to show, 0 to hide)
#define DRV_SDL_MOUSE_SHOW 0

#define GSLC_LOCAL_STR 1

// Error reporting
Expand All @@ -107,19 +114,28 @@ extern "C" {
#define DRV_DISP_ADAGFX_ILI9341
//#define DRV_DISP_ADAGFX_SSD1306 // [TODO]


// For Adafruit-GFX drivers, define pin connections
// Define general pins (modify these example pin assignments to match your board)
#define ADAGFX_PIN_CS 10 // ProMini: 10, ATmega2560: 53, 2.8"AdaShield: 10, Feather: 10
#define ADAGFX_PIN_DC 9 // ProMini: 9, ATmega2560: 47, 2.8"AdaShield: 9, Feather: 9
#define ADAGFX_PIN_RST 11 // ProMini: 8, ATmega2560: 49, 2.8"AdaShield: 0, Feather: 11
// - Define general pins (modify these example pin assignments to match your board)
// - Please refer to "docs/GUIslice_config_guide.xlsx" for detailed examples
#define ADAGFX_PIN_CS 10 // Display chip select
#define ADAGFX_PIN_DC 9 // Display SPI data/command
#define ADAGFX_PIN_RST 11 // Display Reset
#define ADAGFX_PIN_SDCS 4 // SD card chip select

// Use hardware SPI interface?
// - Set to 1 to enable hardware SPI interface, 0 to use software SPI
// - Software SPI may support the use of custom pin selection (via ADAGFX_PIN_MOSI,
// ADAGFX_PIN_MISO, ADAGFX_PIN_CLK). These pin definitions can be left blank in
// hardware SPI mode.
#define ADAGFX_SPI_HW 1

// Define custom SPI pin connections used in software SPI mode (ADAGFX_SPI_HW=0)
// - These definitions can be left blank in hardware mode (ADAGFX_SPI_HW=1)
#define ADAGFX_PIN_MOSI
#define ADAGFX_PIN_MISO
#define ADAGFX_PIN_CLK
// SD card chip select
#define ADAGFX_PIN_SDCS 4 // ProMini: 4, ATmega2560: 48, 2.8"AdaShield: 4, Feather: 4?

// Use hardware SPI?
#define ADAGFX_SPI_HW


// Enable support for SD card
// - Set to 1 to enable, 0 to disable
Expand Down Expand Up @@ -147,15 +163,15 @@ extern "C" {

#elif defined(DRV_TOUCH_ADA_STMPE610)

// Select wiring method by uncommenting one of the following
//#define ADATOUCH_I2C_HW
#define ADATOUCH_SPI_HW
//#define ADATOUCH_SPI_SW // [TODO]
// Select wiring method by setting one of the following to 1
#define ADATOUCH_I2C_HW 0
#define ADATOUCH_SPI_HW 1
#define ADATOUCH_SPI_SW 0 // [TODO]

// For ADATOUCH_I2C_HW
// For ADATOUCH_I2C_HW=1
#define ADATOUCH_I2C_ADDR 0x41 // I2C address of touch device

// For ADATOUCH_SPI_HW
// For ADATOUCH_SPI_HW=1
#define ADATOUCH_PIN_CS 8 // From Adafruit 2.8" TFT touch shield

// Calibration values for touch display
Expand All @@ -170,11 +186,20 @@ extern "C" {
#define ADATOUCH_Y_MAX 3700

#elif defined(DRV_TOUCH_ADA_FT6206)
// Define sensitivity coefficient
// Define sensitivity coefficient (capacitive touch)
#define ADATOUCH_SENSITIVITY 40

#endif // DRV_TOUCH_*

// Define any Touch Axis Swapping and Flipping
// - Set any of the following to 1 to perform touch display
// remapping functions, 0 to disable. Use DBG_TOUCH to determine which
// remapping modes should be enabled for your display
// - Please refer to "docs/GUIslice_config_guide.xlsx" for detailed examples
#define ADATOUCH_SWAP_XY 1
#define ADATOUCH_FLIP_X 0
#define ADATOUCH_FLIP_Y 1

// -----------------------------------------------------------------------------------------


Expand All @@ -184,6 +209,7 @@ extern "C" {


// Debug modes
// - Uncomment the following to enable specific debug modes
//#define DBG_LOG // Enable debugging log output
//#define DBG_TOUCH // Enable debugging of touch-presses
//#define DBG_FRAME_RATE // Enable diagnostic frame rate reporting
Expand Down
Loading

0 comments on commit 95654cd

Please sign in to comment.