ChrisMicro / GuiPittix

absolute minimum TFT GUI for Arduino
9 stars 3 forks source link

Keyboard #1

Open universam1 opened 7 years ago

universam1 commented 7 years ago

Great work, just in time, lucky I discovered your great work. I was all about to write a GUI lib similar to your... ( Oder auf gut deutsch Hammer!)

I wanted to ask about some idea to create a keypad. Since the objects are declared globally I thought to enumerate them better via an array like

GUI_Button btnarray[] = {
    "1","2","3",
    "4","5","6",
    "7","8","9",
    "DEL","0","OK",
};
setup() {
for (int i=0;i<12;i++)
  btnarray[i].show();
}

Now this is not handy to align them in a loop as to set them later in runtime, for instance if I have multiple pages. Any advice in this regard?

Thanks!

ChrisMicro commented 7 years ago

Hi uinversam, a keypad class is really missing because it is a little bit cumbersome to create every key himself. One example his here

https://github.com/ChrisMicro/ArduinoOnPc/blob/master/src/examples/TekSpriteEditor2.ino

There are several GUI-elements missing right now:

One method for the keypad element could be to define every button first without positioning and than add them to the keypad element where a the are auto-positioned. The keypad element could than provide a general getKey() or wasKeyPressed() function which provides all the keylogic.

Let me think a little bit ...

universam1 commented 7 years ago

Thanks!

The auto arranging is a good approach, only currently it does not respect display limits so it falls over the boarders. If the raster would be a custom value one could set the origin plus these raster values and would provide already some usable arrangement. Just an idea. Besides of that I like the approach of overloading the root object and the hardware layer!