Announcement

Collapse
No announcement yet.

Keyboard Object Question

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

  • #46
    Hi Eran, using the WriteObject method I created a loop and sent my string one character at a time. It works and is generally a bit faster than the WriteMagicBytes option. Before I decide on a final direction, it would be really good to know if I am doing something wrong with WriteMagicBytes, the fact it works instantly on the first attempt but is then delayed is really frustrating

    Comment


    • #47
      Hi Tim,

      You’re missing an acknowledgment in your magicObject code. You can add the line serout(ACK) ; at the end of your magicObject code. This is an acknowledgment from the display to the Arduino that the Display is done receiving data from the Arduino.

      You can choose either way you want and can always ask for clarifications.

      *Please have a look at the modified version of your magicObject code:


      Code:
      func rMagicObject0(var action, var object, var newVal, var *ptr)
          var  i;
      
          print([CHR]newVal);
          print("\n");
      
          for (i:=0; i<newVal;i++)
            print([CHR]ptr[i]);
          next
      
          print("\n");
      
          serout(ACK) ;    // send back an ACK to command, do this last, otherwise the master may send the
                               // next command which is cannot be started until this is finished.
      
      endfunc
      Thanks and I hope this helps,

      Eran
      Eran

      Comment


      • #48
        Eran, that's perfect. Tested and working perfectly. What a dope Thank you again for the amazing help and support!

        Comment


        • #49
          Hi Eran, made good progress today thanks to your help with the comms

          Is there a limit to the number of bytes of memory that can be allocated to variables? I ran into a stack overflow error today which was only solved when I reduced the number of bytes of memory I am allocating in my variables section. The good news is that now the comms are nice an slick I won't need to download massive chunks of data but it did alarm me. On compilation the message tells me I am using around 14K (of the 32K) available so far so I though I had plenty of head room left.

          Comment


          • #50
            Hi Tim,

            Stack Overflow usually happens when you’re calling functions recursively without returning.

            You may take a look at these forum threads for more information about stack overflow.
            https://forum.4dsystems.com.au/forum...o-15#post43996
            https://forum.4dsystems.com.au/forum...2057#post22057
            https://forum.4dsystems.com.au/forum...rflow#post4458
            https://forum.4dsystems.com.au/forum...0468#post60468

            You may also change the Stack Size and see if the error’s still there.

            https://forum.4dsystems.com.au/forum...tion#post46574

            If the stack overflow still gets to be an issue, I recommend that you execute your code part-by-part and determine which part results to the error so debugging will be much easier.

            Best Regards,
            Eran
            Eran

            Comment


            • #51
              Thanks Eran, as ever that's very useful information.

              I don't think I am recursively calling any functions but certainly worth bearing in mind. In my test mode I am declaring a lot of big arrays and the problem occurred when I tried to initialise another 150bytes within my magicObject code. I did move these out to the glabal variables area as I wil need them in other parts of the code and cut back on some of the silly initialisations I was doing and this seemed to help.

              Useful to know I can increase the stack size though

              Thanks again

              Comment


              • #52
                No worries Tim! Glad it helped you.

                Best Regards,
                Eran
                Eran

                Comment


                • #53
                  Hi Eran,

                  So my development is going great thanks to your amazing support and advice.

                  I just wanted to pick your brains before I set off on the next bit of the development.

                  Essentially I want to implement some 'drag and drop' type functionality. In my Arduino I have a list of string type data (100 entries in the list each a 5 characters long). The 'list box' screen you helped my create calls up 5 entries from this list (using magic byte messages), displays them and when the entry is touched, I can go off and edit it and then return the edited version to the Arduino in order to update the list.

                  What I'd like to do next is two things:

                  1) if I do a long touch on the item in the list (i'd like my strings object containing the data to change colour) and then drag it to a 'trash icon' on the screen, I'd like to send a message back to the Arduino to delete this entry.
                  2) if I do a long touch and then drag the item up or down, I'd like to be able to call up the next or previously entries in the list and depending on when I release the screen generate a message to insert the data from its original position into the new position. I'm thinking this might be possible via a combination of the magic move and magic release functions? Does that sound possible? What I'm a bit worried about is somehow being able to make repeated requests for data and update that data (ie scroll a long way through my list) whilst the user continues to hold their finger n the screen

                  I suppose my initial query is, do you think this kind of list 'management' is possible?

                  Comment


                  • #54
                    Hi Tim,

                    Glad to know that we have helped you in building your project and that you’re enjoying the Magic codes.

                    About your first question, Yes, "Drag and drop" is possible with Workshop4. This function, however, is limited to strings having dynamic texts. Just a short overview about string objects: A static text can be touched, but its text cannot be changed; a dynamic string’s text can be changed, but it cannot be touched. When moving a non-fixed object, it needs to be printed every time you move from one point to another, so it should be “touchable” and “dynamic”.

                    Still, I have made a sample project for a “long press” function to delete a certain object. Feel free to use/ modify it.

                    I’m not sure if my comprehension with your second question is right, but just in case it is, I have added a few lines in your previously uploaded code. Just drag the “Action lists” to move the lists up or down.

                    You’re free to clarify your inquiry if I got it wrong of course.

                    Best Regards,
                    Attached Files
                    Eran

                    Comment


                    • #55
                      Hi Eran, hope you are well. Our project is going well (slower than we'd like as ever but going well)

                      Quick question if I may. Is it possible for me to create an 'executable' file of my code such that my development partner can upload it to his screen? He doesn't have the pro licence so I assume my code won't load in his free version of the environment? Going forwards this will also help my users to load up firmware updates too without needing the pro licence?

                      Thanks in advance

                      Tim

                      Comment


                      • #56
                        Hi Tim,

                        Congratulations on building your project.

                        Workshop4 IDE folder has actually a program called LoadProgram.exe that lets you upload code without opening Workshop4 itself. The program is a straightforward program and is easy to use. You can find this in C:\Program Files (x86)\4D Labs\4D Workshop 4 IDE\DEP folder. The gci files and dat files should be manually copied to the SDCard and your project is ready.

                        programLoader.mp4

                        Also, Workshop4 offers a 7-day free trial of its Pro version. Just go to Files > Options > License and Click Start Pro Trial.

                        There is another option as well that lets you transfer files using Serial Cable Utility and is posted here: https://forum.4dsystems.com.au/forum...lity#post62492


                        Hope this helps and all the best for your project.
                        Eran

                        Comment


                        • #57
                          Thanks Eran, will give that a try.

                          Couple more questions if I may (I'm trying to optimise my code and the number of screens I'm using)

                          1) Is it possible to 'cast' a numeric value held in a variable such that I can display it in a string object using the printstrings function?

                          for example I have a value (say 127) held in a byte variable called editvalue, and I'd like to display the value in a stringobject using something like PrintStrings(2, editvalue, 1) ;

                          I've been looking for a numeric to string convertor function but can't seem to find one?

                          2) Is it possible to hide an object on a screen. I have a screen with some led digits and a string objects but sometimes I would like to hide them. Is there an attribute I can set to hide/show them?

                          Comment


                          • #58
                            Hi Tim,

                            You can hide an object using a userButton to overlap your object to hide. I have made a workaround with your other concern. Please see the sample code and compare it with what you've already made.

                            Best Regards,
                            Attached Files
                            Eran

                            Comment


                            • #59
                              Thanks Eran. If i use the userbutton to hide my object, how would i go about revealing it?

                              thanks for the casting code. Im away for a few days but that will certainly be a big help

                              Comment


                              • #60
                                Hi Tim,

                                You can show the Leddigits by Writing a value to it again. The latest object to be updated will be the one shown on top.

                                I have actually included the hiding/revealing of Leddigits in the sample code.

                                You can always ask if you need more clarifications.

                                Best Regards,
                                Eran

                                Comment

                                Working...
                                X