Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Create keypad element #5

Closed
ImpulseAdventure opened this issue Apr 29, 2017 · 3 comments
Closed

Request: Create keypad element #5

ImpulseAdventure opened this issue Apr 29, 2017 · 3 comments
Assignees
Milestone

Comments

@ImpulseAdventure
Copy link
Owner

Build a keypad element. For flexibility in supporting custom button appearance by users, it may be easiest to use the compound element definition (simple example in XSelNum).

Probably want to support a couple variants:

  • Numeric
  • Alphanumeric

Ideally, we would have a textarea, a set of input keys plus a Save and Cancel button.
To keep things simple, the textarea can be static and not accept touch presses itself.

Enhancements:

  • Backspace character
  • Flashing cursor indicator
@ImpulseAdventure ImpulseAdventure changed the title Create keypad element Request: Create keypad element Feb 12, 2019
@ImpulseAdventure ImpulseAdventure added this to the 0.12.0 milestone Apr 1, 2019
@ImpulseAdventure
Copy link
Owner Author

ImpulseAdventure commented May 7, 2019

XKeyPad components have now been developed in a local branch and undergoing final testing. The initial code was based on great contributions by @Pconti31 .

  • XKeyPad_Num: Numeric input, with support for floating point & negation
  • XKeyPad_Alpha: Character input
  • Custom KeyPad creation supports flexibility in the styling of each key
  • Callback functions for text update, OK and escape
  • KeyPads can be used as a popup

Effort was put into making a base XKeyPad element type that can be easily extended by the user to create their own data entry controls. The Num & Alpha are example variants that extend/derive from the XKeyPad base functionality, but it should be straightforward to create one's own.

Example usage for numeric input

  // Configure keypad options
  gslc_tsXKeyPadCfg sCfg = gslc_ElemXKeyPadCfgInit_Num();
  gslc_ElemXKeyPadCfgSetFloatEn(&sCfg, true);
  gslc_ElemXKeyPadCfgSetButtonSz(&sCfg, 25, 25);
  // Create keypad
  pElemRef = gslc_ElemXKeyPadCreate_Num(&m_gui, E_ELEM_KEYPAD, E_PG_POPUP,
    &m_sXKeyPad, 20, 50, E_FONT_SANS1, &sCfg);
  // Optionally register a callback function from the keypad
  gslc_ElemXKeyPadSetCb(&m_gui, pElemRef, &CbInputKeyPad);

Example as a popup

The keypad can be used as a popup dialog, in which case the return value can be fetched from the callback:

  // Show the popup
  gslc_PopupShow(&m_gui, E_PG_POPUP, true); // Show the popup "page" containing the keypad
  ...
  // Upon the callback from the KeyPad:
    case XKEYPAD_CB_STATE_DONE:
      GSLC_DEBUG_PRINT("KeyPad returned value [%s]\n", (char*)pvData);
      gslc_PopupHide(&m_gui);
      break;

Implementation Notes

This first version of the XKeyPad has not been optimized for memory consumption. In particular, it does not yet leverage PROGMEM / Flash memory for keypad label storage. In addition, it utilizes compound elements, which can place moderate demands on memory for larger keypads.

A revised XKeyPad will create a simple element that handles its own custom redraw and touch handling (w/o compound elements), enabling far more memory efficiency.

@ImpulseAdventure
Copy link
Owner Author

ImpulseAdventure commented May 14, 2019

XKeyPad is now available for testing in the WIP005-XKeyPad branch.

Example ex26_ard_calc has been added to demonstrate the use of the numeric keypad input (XKeyPad_Num), but XKeyPad_Alpha is also available for testing.

Outstanding edits:

  • Integration with GUIslice Builder
  • Optimize redraw
  • Create example for XKeyPad_Alpha
  • Show cursor position (caret) indicator

@ImpulseAdventure
Copy link
Owner Author

XKeyPad component merged and now available from master

Examples added:

  • ex26_ard_calc (numeric, basic calculator)
  • ex27_ard_alpha (alphabet, initial draft version)

Outstanding feature development will continue on this component as noted earlier.
Note that the APIs are subject to changes as the Builder integration completes in parallel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant