Announcement

Collapse
No announcement yet.

Automatic Drawing Machine problem with "Drawing via Web Using PHPoC" Project

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

  • #16
    Thx, I added the code in there. Can I add a button to the website interface? So that after I click the button, the plotter will automatically call the letter "L"?

    Comment


    • #17
      Of course, yes. You just need to add a HTML button.
      Add onclick handler for this button.
      When button is click, a new command to PHPoC.
      currently, there is 3 command code:
      PHP Code:
       define("CMD_PEN_UP",    0);  define("CMD_PEN_DOWN",    1);  define("CMD_MOVE",        2) ; 
      you can define new cmd code, for example:
      PHP Code:
      define("CMD_DRAW_L"3); 
      on onclick handler, you just need:
      Code:
      ws.send(CMD_DRAW_L+ " " + 0 + " " + 0 + "\r\n");
      on PHPoC, you just add new case in switch($cmd):
      PHP Code:
      case CMD_DRAW_L

      Comment


      • #18
        THX!. I attached the code here. But I can't find switch($cmd) in these two php files. Where's it located?

        https://drive.google.com/open?id=1Lw...LtAFF7345AURDD

        Comment


        • #19
          PHP Code:
          case CMD_DRAW_L:  
          xy_goto(0100);
          xy_wait(); 
          xy_goto(00);  
          xy_wait(); 
          xy_goto(250); 
          xy_wait();
          break; 
          you also need to add : define("CMD_DRAW_L", 3); at line 23 of task0.php

          Comment


          • #20
            I see. Here's the updated code. After I put it in phpoc blue, then the plotter can draw the L after clicking the button in the web interface?
            https://drive.google.com/drive/folde...DD?usp=sharing

            Comment


            • #21
              It should works

              Comment


              • #22
                Thx Khanh, I have tested the code with my PHPoc Blue. It seems some problem with it.
                When I clicked the DrawL button in the website. There's no response. I think the reason maybe the PenUp PenDown Function didn't set correctly.
                Here's my code. Can you test it?
                https://drive.google.com/drive/folde...DD?usp=sharing
                Last edited by CK_05; 09-12-2018, 03:28 PM.

                Comment


                • #23
                  Moreover, I find some .svg file contain the pathdata, I have converted the pathdata from vector to coordination.
                  How can the xy plotter plot the triangle(the example) according the xy coordination..

                  For example the triangle.svg is

                  pathData="M59.895 58.531l-29 -58c-0.34 -0.678 -1.449 -0.678 -1.789 0l-29 58c-0.155 0.31 -0.139 0.678 0.044 0.973 0.182 0.294 0.504 0.474 0.85 0.474l58 0c0.347 0 0.668 -0.18 0.851 -0.474 0.182 -0.295 0.199 -0.663 0.044 -0.973zM2.618 57.978L30 3.214l27.382 54.764 -54.764 0z"
                  .svg file: https://drive.google.com/open?id=1Qv...F0xxHMb5VwYro6
                  and the xy coordination will be

                  X59.895 Y1.470 (M)
                  X30.895 Y59.470 F2000 (l)
                  X30.795 Y59.625 (c)
                  X30.668 Y59.753 (c)
                  X30.520 Y59.851 (c)
                  X30.356 Y59.922 (c)
                  X30.181 Y59.964 (c)
                  X30.001 Y59.979 (c)
                  X29.820 Y59.964 (c)
                  X29.645 Y59.922 (c)
                  X29.481 Y59.851 (c)
                  X29.333 Y59.753 (c)
                  X29.206 Y59.625 (c)
                  X29.106 Y59.470 (c)
                  X0.106 Y1.470 (l)
                  ...
                  Last edited by CK_05; 09-10-2018, 10:25 PM.

                  Comment


                  • #24
                    Sorry for disturb you, Khanh. I still can't run the code.. Moreover, Can I know what Code Editors and IDE you're using for writing those code? I don't know how to debug by using PHPOC IDE.Help me, please T^T

                    Comment


                    • #25
                      Hello,
                      I used PHPoC Debugger.
                      When you have X, Y coordinates, you just needs to each position one by one by using
                      xy_goto(x, y);
                      xy_wait();
                      fuctions.
                      when you have a file of coordinates, you need to get XY coordinates from that file by using string processing function such as: substr(), substr_replace() ....

                      For more funstion, please visit: https://www.phpoc.com/support/manual...?id=php_substr

                      Comment

                      Working...
                      X