Announcement

Collapse
No announcement yet.

Using a keyboard on A IoD-32T

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using a keyboard on A IoD-32T

    So I've already done some work on this system and have successfully added buttons and gauges with a little work; however, I'm having trouble making the keyboard widget work properly.
    At this point, I'm able to use the normal keys; however, the shift and caps lock keys do not do their functions.

    I should also state that most of my experience has been with Java, so its possible I'm missing something obvious or misusing some terms.

    Looking at the 4duino keyboard example was not as helpful as I would have hoped because it's for a different system and I'm a little daft.

    When I paste the static code, it just adds these lines :
    Code:
        gfx.imageTouchEnable(iKeyboard1, true) ;   // Keyboard1 show initialy, if required
        gfx.UserImages(iKeyboard1,0) ;             // Keyboard1 show initialy, if required
    and
    Code:
        if ((n >= iKeyboard1) && (n <= iKeyboard1+oKeyboard1[KbButtons]))
          kbDown(iKeyboard1, oKeyboard1, iKeyboard1keystrokes, n-iKeyboard1, KbHandler) ;  // Keyboard1
        endif
        // This is for the keyup event
        if (oKeyboard1[KbDown] != -1) kbUp(iKeyboard1, oKeyboard1) ;  // Keyboard1
    There are several problems at this point.
    1. I could not press the buttons individually, I could only pick the whole keyboard or nothing.
    2. Niether the kbDown or kbUp method is defined
    3. the variables KbButtons, KbDown, KbHandler, and n are undefined. (n is obvious though)


    To solve the first problem, I made this method :
    Code:
        
         void initializeKeyboard () {
          gfx.imageTouchEnable(iKeyboard1, false) ;   // Keyboard1 show initialy, if required
          gfx.UserImages(iKeyboard1,1) ;           // Keyboard1 show initialy, if required
          int keyboardStart = iKeyboard1;
          for (int i = keyboardStart + 1; i < iWinbutton2; i++) {
            gfx.imageTouchEnable(i, true) ;   // Keyboard1 show initialy, if required
            gfx.UserImages(i,0) ;             // Keyboard1 show initialy, if required
          }
        }
    That worked, and I could now press individual keys.

    I'm not going to share my implementation of the kbUp and kbDown methods; however, I think it's very strange that they weren't built in or atleast started when i pasted static code.

    I'm pretty sure the KbDown variable should just be an int corresponding to the key that was pressed, so i just set it equal to n right now.

    Finally I guess I just have some questions :
    1. What do the KbDown variable and oKeyboard1 array (or pointer i guess) represent?
    2. Should KbHandler be an object that I pass in? How will I make it interact with the keyboard so that it changes to show caps?
    3. Is there some guide for doing stuff with the IoD-32T on Workshop 4? It feels like pulling teeth to use most of its unique functionalities.

    Sorry this has gotten pretty long, I just figured that i should ask before spending more time grinding through this.

  • #2
    Hi,

    Welcome to the forum!

    Unfortunately, we don’t have a guide for gen4-IoD modules yet, especially for the keyboard widget. As we are taking steps to fix this issue, would you please send us your zip file code for further analysis.

    You can attach it in here (in the forum) or you can email me here: pearl at 4dsystems dot com dot au.

    It also would help if you can minimize your code retaining only the significant part of the code and the issue.

    Thank you and sorry for any inconvenience.

    Best Regards,
    Pearl
    Last edited by Pearl; 9th August 2018, 05:23 PM.
    Pearl

    Comment


    • #3
      Okay, I've attached my code.

      I should note that in my code, the keyboard writes in a console window, so you need to open one with the "open window" button to see the keys working.

      My primary concern is how to make the shift and caps lock keys work. I think that what I need to do is just write my own handler that will be called in the kbDown method.

      On another not, I was wondering is it easily possible to give the keyboard 3 "states?" One where it shows all the normal letters in lowercase, one with the letters in uppercase, and one that just shows all the symbols and numbers. I figure if I cant do that, I could just make another keyboard and hide/ show it based on key presses.
      Attached Files

      Comment


      • #4
        Hi, again Jay,

        For now, the keyboard object isn't supported for the IoD library.
        Although we’ve been working on this issue, we still haven’t completed it yet. Here’s what we’ve done so far:

        IoDkBTestAuto.zip
        IoDLibrary.zip

        You can run this example code together with this library attached. You can do it by replacing this new GFX4d.h and GFX4d.cpp to the old library, then copy the gci and dat file to your SD card and finally run the Arduino code.

        With this example, you can already press the keyboard key and print the character on the text window. Furthermore the shift and caps lock key are also working.

        Again, we apologize for any inconvenience.
        You can rest assured that keyboard library will be added in IoD library in no time.

        Best Regards,
        Pearl
        Pearl

        Comment


        • #5
          Hey Pearl,

          Thank you! Using that library I was able to complete my project!

          That said, I did have a couple problems with the keyboard.

          1) Keys mapped to the @ and _ symbols would return . and ` when pressed. To make them show up, I had to change their key values in the keyboard editor from -1 to 64 and 95.

          2) If caps lock is pressed (or caps are on at all) it will make other buttons appear as a red box with an X. I assume this is them trying to draw a certain from they do not have.
          I fixed this by setting all of my iWinbuttons to be not momentary. This was also a problem for a second keyboard I had made, and the only solution I found was to a caps lock
          key to that board.

          Since these displays are so small, I think you guys should think about a keyboard system that allows for users to switch between multiple keyboards so that the keys on each board could be bigger. For example: My project will be for old people, so to maximize the size of each key, I wanted a keyboard that toggled between showing lowercase letters, uppercase letters, and symbols. To achieve this I had to create a second keyboard with just the symbols and then make a key that would switch between them.

          I ended up just making a class that allows you to add as many keyboards to one of my keyboard objects and lets you assign functions to specific keys and stuff like that.

          I'll attach my class. I doubt it will be useful to anyone, but I think it's just important to highlight to your developers that they should consider some sort of system for this.

          Lastly, I was wondering if there was an ETA for library to be finished, and if will I have to make any changes to my code when it is.

          P.S. It would seem they dont want me attaching a .cpp file, so I've zipped it.

          Thanks for all your help,
          -JayLTheGreat
          Attached Files

          Comment


          • #6
            Originally posted by JaylTheGreat View Post
            Hey Pearl,

            Thank you! Using that library I was able to complete my project!

            That said, I did have a couple problems with the keyboard.

            1) Keys mapped to the @ and _ symbols would return . and ` when pressed. To make them show up, I had to change their key values in the keyboard editor from -1 to 64 and 95.

            2) If caps lock is pressed (or caps are on at all) it will make other buttons appear as a red box with an X. I assume this is them trying to draw a certain from they do not have.
            I fixed this by setting all of my iWinbuttons to be not momentary. This was also a problem for a second keyboard I had made, and the only solution I found was to a caps lock
            key to that board.

            Since these displays are so small, I think you guys should think about a keyboard system that allows for users to switch between multiple keyboards so that the keys on each board could be bigger. For example: My project will be for old people, so to maximize the size of each key, I wanted a keyboard that toggled between showing lowercase letters, uppercase letters, and symbols. To achieve this I had to create a second keyboard with just the symbols and then make a key that would switch between them.

            I ended up just making a class that allows you to add as many keyboards to one of my keyboard objects and lets you assign functions to specific keys and stuff like that.

            I'll attach my class. I doubt it will be useful to anyone, but I think it's just important to highlight to your developers that they should consider some sort of system for this.

            Lastly, I was wondering if there was an ETA for library to be finished, and if will I have to make any changes to my code when it is.

            P.S. It would seem they dont want me attaching a .cpp file, so I've zipped it.

            Thanks for all your help,
            -JayLTheGreat
            Hi,

            Thank you for the feedback, it is very helpful. The added keyboard support was a work in progress and I am pleased you managed to make it workable for your project. The new library will be finished over the next few days and I hope to have the completed keyboard support working correctly.

            Many thanks

            Paul

            Comment


            • #7
              Hey Paul,

              Is the library finished yet? Where can I get it?

              I would like to make sure my stuff works properly with the new official library release rather than just the library I got off the forum.

              Also is there/ will there be documentation for the new library like the old library had?

              This pdf was very helpful to me while working up to this point. https://www.4dsystems.com.au/product...ries_R_1_0.pdf

              Thanks,

              JayLtheGreat

              Comment


              • #8
                Hi,

                It is close to being finished, just adding the modifications to the keypad handler. We should be finished by the end of the week. I will look into the documentation also.

                Best regards

                Paul

                Comment


                • #9
                  Hey Paul,

                  Has it been finished yet?

                  Also, my boss has been considering switching to another 4D systems device so that we could include audio.

                  Could you recommend any of your audio capable boards with displays that I could easily transfer the code from my IoD-32T to?

                  Thanks,

                  JayLTheGreat

                  Comment


                  • #10
                    Hello Jay,

                    It is being thoroughly tested at the moment so nearly there.

                    The gen4 Diablo range of displays would be a good choice however your code would have to be re-written for this display. If you don't like the idea of re-writing your code, we do have a library that emulates the GFX4d library which is flashed to one of our Wifi MOTG modules and communicates with the Diablo via serial at high speed. The Wifi MOTG attaches to the rear of the gen4 Diablo display using an AC board. The library was 99% compatible with gen4-IoD code before keypad support was added and these new features could be added to the library along with Audio support. It is a possible easy way of porting a project over to a Diablo display that was created with an IoD. You can find details of our MOTG range here.

                    https://www.4dsystems.com.au/product/MOTG/

                    The AC board that fits the gen4-uLCD-32DT also features a speaker and the necessary audio hardware.

                    I hope this helps

                    Best regards

                    Paul

                    Comment

                    Working...
                    X