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

                    Working...
                    X