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

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

    Hi, I wanna make an Automatic Drawing Machine, which means the user just need to input a picture(.jpg, or .svg file) into the phpoc blue device, then the device can draw the draw the picture itself automatically. Is it possible by using PHPoc Blue to achieve this goal?
    Please give me some advice and direction. How can I change the code that provided in "Drawing via Web UsingPHPoC".Please help. Thanks
    Whatever you draw on a webpage will be replicated on the drawing paper. Find this and other hardware projects on Hackster.io.

  • #2
    Hello CK_05,
    in this case, you do not need Web user interface, therefore you do not need to care about index.php file. You just need to modify task0.php.
    Instead of receiving coordinates from network (via websocket), you just need to read image file, get coordinates from image file and the draw it after scaling.

    in while(1) of task0.php, It will be similar to this code:
    PHP Code:
    while(1)
    {

        
    $coordinate_1 get_next_coordinate();
        
    xy_goto($coordinate_1[0] * $scale_ratio_x$coordinate_1[1] * $scale_ratio_y);
        
    xy_wait();

        
    pen_down();

        
    $coordinate_2 get_next_coordinate();
        
    xy_goto($coordinate_2[0] * $scale_ratio_x$coordinate_2[1] * $scale_ratio_y);
        
    xy_wait();

        
    pen_up();




    The hard thing here is that in order to get coordinates from images you need to know the image file format. It means you need to know file format to implement get_next_coordinate() function.

    It is simple to read any kind of file, which is stored on PHPoC devices. You can refer to the following code:
    PHP Code:
    <?php
    $filename 
    "myimage.svg";
    $rbuf "";
    $fd pid_open($filename);
    pid_read($fd$rbuf5);
    hexdump($rbuf);
    pid_read($fd$rbuf5);
    hexdump($rbuf)
    ?>

    Comment


    • #3
      You had better to convert the image to the file format that is easy to understand.

      Comment


      • #4
        Hi, for the task0.php will be modified in this way?

        PHP Code:
        <?php

        include_once "/lib/sd_340.php";
        include_once 
        "/lib/sd_spc.php";
        include_once 
        "/lib/sn_tcp_ws.php";

        define("PWM_PERIOD"20000); // (20ms)
        define("WIDTH_MIN"600);
        define("WIDTH_MAX"2450);

        define("SID_X",            13);
        define("SID_Y",            14);

        define("MAX_X",         1710);
        define("MAX_Y",         2140);
        define("TOUCH_OFFSET",    100);

        define("PEN_UP",        0);
        define("PEN_DOWN",        1);

        define("CMD_PEN_UP",    0);
        define("CMD_PEN_DOWN",    1);
        define("CMD_MOVE",        2);

        define("SPEED_X_COEF",        20);
        define("SPEED_Y_COEF",        20);
        define("SPEED_X_OFFSET",    50);
        define("SPEED_Y_OFFSET",    50);
        define("SPEED_X_MAX",        5000);
        define("SPEED_Y_MAX",        5000);

        define("ACCEL_X_COEF",        1500);
        define("ACCEL_Y_COEF",        1000);
        define("ACCEL_X_OFFSET",    0);
        define("ACCEL_Y_OFFSET",    0);
        define("ACCEL_X_MAX",        20000);
        define("ACCEL_Y_MAX",        20000);

        define("STATE_X_LOCK",    1);
        define("STATE_X_RUN",    2);
        define("STATE_Y_LOCK",    4);
        define("STATE_Y_RUN",    8);


        function 
        step_cmd($sid$cmd)
        {
            
        $resp spc_request($sid4$cmd);

            if(
        $resp)
            {
                
        $resp explode(","$resp);

                if((int)
        $resp[0] != 200)
                {
                    echo 
        "step_cmd : '$cmd' request error "$resp[0], "\r\n";
                    return 
        false;
                }

                if(
        count($resp) > 1)
                    return 
        $resp[1];
                else
                    return 
        "";
            }
            else
                return 
        false;
        }

        function 
        spc_check_did($sid$did)
        {
            
        $resp spc_request_csv($sid0"get did");

            if(
        $resp === false)
            {
                echo 
        "spc_check_did: sid$sid - device not found\r\n";
                return 
        false;
            }

            if(
        $resp[1] != "40002405")
            {
                echo 
        "spc_check_did: unknown device "$resp[2], "\r\n";
                return 
        false;
            }

            return 
        true;
        }

        function 
        pen_up()
        {
            
        $angle 110;

            
        $width WIDTH_MIN + (int)round((WIDTH_MAX WIDTH_MIN) * $angle 180.0);

            if((
        $width >= WIDTH_MIN) && ($width <= WIDTH_MAX))
                
        ht_pwm_width(2$widthPWM_PERIOD);
        }

        function 
        pen_down()
        {
            
        $angle 180;

            
        $width WIDTH_MIN + (int)round((WIDTH_MAX WIDTH_MIN) * $angle 180.0);

            if((
        $width >= WIDTH_MIN) && ($width <= WIDTH_MAX))
                
        ht_pwm_width(2$widthPWM_PERIOD);
        }

        function 
        xy_goto($x$y)
        {
            global 
        $mode;

            if(
        $x TOUCH_OFFSET)
                
        $x TOUCH_OFFSET;
            if(
        $x > (MAX_X TOUCH_OFFSET))
                
        $x MAX_X TOUCH_OFFSET;

            if(
        $y TOUCH_OFFSET)
                
        $y TOUCH_OFFSET;
            if(
        $y > (MAX_Y TOUCH_OFFSET))
                
        $y MAX_Y TOUCH_OFFSET;

            
        $x0 = (int)step_cmd(SID_X"get pos") / $mode;
            
        $y0 = (int)step_cmd(SID_Y"get pos") / $mode;

            
        $delta_x $x $x0
            
        $delta_y $y $y0;

            if(
        $delta_x == && $delta_y == 0)
                return;

            
        $speed_x SPEED_X_COEF abs($delta_x) + SPEED_X_OFFSET;
            
        $speed_y SPEED_Y_COEF abs($delta_y) + SPEED_Y_OFFSET;

            
        $x *= $mode
            
        $y *= $mode;
            
        $speed_x *= $mode;
            
        $speed_y *= $mode;

            if(
        $speed_x SPEED_X_MAX $mode)
                
        $speed_x SPEED_X_MAX $mode;

            if(
        $speed_y SPEED_Y_MAX $mode)
                
        $speed_y SPEED_Y_MAX $mode;

            
        $accel_x ACCEL_X_COEF $speed_x ACCEL_X_OFFSET;
            
        $accel_y ACCEL_Y_COEF $speed_y ACCEL_Y_OFFSET;

            if(
        $accel_x ACCEL_X_MAX $mode)
                
        $accel_x ACCEL_X_MAX $mode;

            if(
        $accel_y ACCEL_Y_MAX $mode)
                
        $accel_y ACCEL_Y_MAX $mode;

            if(
        $delta_x == 0)
            {
                
        step_cmd(SID_Y"goto $y $speed_y $accel_y");
            }
            else if(
        $delta_y == 0)
            {
                
        step_cmd(SID_X"goto $x $speed_x $accel_x");
            }
            else
            {
                
        step_cmd(SID_X"goto $x $speed_x $accel_x");
                
        step_cmd(SID_Y"goto $y $speed_y $accel_y");
            }
            
        //echo "state: ", step_cmd(SID_Y, "get state"), "\r\n";
            //echo SID_X, ", goto $x $speed_x $accel_x\r\n";
            //echo SID_Y, ", goto $y $speed_y $accel_y\r\n";
        }

        function 
        xy_state()
        {
            
        $ret_val 0;

            
        $x_state = (int)step_cmd(SID_X"get state");
            
        $y_state = (int)step_cmd(SID_Y"get state");

            if(
        $x_state == 1// motor is locked
                
        $ret_val |= STATE_X_LOCK;
            else if(
        $x_state 1// motor is running
                
        $ret_val |= STATE_X_RUN;

            if(
        $y_state == 1// motor is locked
                
        $ret_val |= STATE_Y_LOCK;
            else if(
        $y_state 1// motor is running
                
        $ret_val |= STATE_Y_RUN;

            return 
        $ret_val;
        }

        function 
        xy_wait()
        {
            while(
        xy_state() & (STATE_X_RUN STATE_Y_RUN))
                
        usleep(1);
        }

        function 
        xy_init()
        {
            global 
        $mode;

            
        $width WIDTH_MIN + (int)round((WIDTH_MAX WIDTH_MIN) * 110 180.0);
            
        ht_pwm_setup(2$widthPWM_PERIOD);
            
        pen_up();

            
        spc_reset();
            
        spc_sync_baud(460800);

            if(!
        spc_check_did(SID_X"40002405"))
                return;
            if(!
        spc_check_did(SID_Y"40002405"))
                return;

            
        step_cmd(SID_X"set vref stop 4");
            
        step_cmd(SID_X"set vref drive 15");
            
        step_cmd(SID_X"set mode $mode");
            
        step_cmd(SID_X"set rsnc 120 250");

            
        step_cmd(SID_Y"set vref stop 4");
            
        step_cmd(SID_Y"set vref drive 15");
            
        step_cmd(SID_Y"set mode $mode");
            
        step_cmd(SID_Y"set rsnc 120 250");

            
        // move pen to (0, 0)
            
        $v 800 $mode;
            
        $a 10000 $mode;
            
        step_cmd(SID_X"goto -sw1 $v $a");
            
        step_cmd(SID_Y"goto -sw1 $v $a");
            
        xy_wait();
            
        step_cmd(SID_X"reset");
            
        step_cmd(SID_Y"reset");
            
        /*
            $time_stemp = st_free_get_count(0);
            step_cmd(SID_X, "goto 100 $v $a");
            step_cmd(SID_Y, "goto 100 $v $a");
            xy_wait();
            $time_stemp = st_free_get_count(0) - $time_stemp;

            echo $time_stemp;

            step_cmd(SID_X, "reset");
            step_cmd(SID_Y, "reset");
            */
            
        xy_goto(TOUCH_OFFSETTOUCH_OFFSET);
            
        xy_wait();

            
        // uncomment this block for the first run and change the value in line 45 of index.php
            /*
            // check max steps
            step_cmd(SID_X, "goto +sw0 1600 20000");
            step_cmd(SID_Y, "goto +sw0 1600 20000");

            xy_wait();
            // change this value in line 45 of index.php: var MAX_X * $mode = 3421, MAX_Y * $mode = 4296;
            echo "Max X:", step_cmd(SID_X, "get pos"), "\r\n";
            echo "Max Y:", step_cmd(SID_Y, "get pos"), "\r\n";
            */
        }

        function 
        send_position($pen_state)
        {
            global 
        $mode;

            
        $x = (int)step_cmd(SID_X"get pos") / $mode;
            
        $y = (int)step_cmd(SID_Y"get pos") / $mode;
            
        $wbuf "[$x$y$pen_state]";
            
        ws_write(0$wbuf);
        }

        $mode 32;

        ws_setup(0"xy_plotter""csv.phpoc");
        xy_init();

        $pre_x 0;
        $pre_y 0;
        $cur_x 0;
        $cur_y 0;
        $rbuf "";
        $pen_state CMD_PEN_UP;
        $x_is_unlock false;
        $y_is_unlock false;

        while(
        1)
        {

            
        $coordinate_1 get_next_coordinate();
            
        xy_goto($coordinate_1[0] * $scale_ratio_x$coordinate_1[1] * $scale_ratio_y);
            
        xy_wait();

            
        pen_down();

            
        $coordinate_2 get_next_coordinate();
            
        xy_goto($coordinate_2[0] * $scale_ratio_x$coordinate_2[1] * $scale_ratio_y);
            
        xy_wait();

            
        pen_up();

        }  


        ?>
        Then I have to create a new PHP file inside the phpoc blue to read the image.
        PHP Code:
        <?php
        $filename 
        "myimage.svg";
        $rbuf "";
        $fd pid_open($filename);
        pid_read($fd$rbuf5);
        hexdump($rbuf);
        pid_read($fd$rbuf5);
        hexdump($rbuf)
        ?>
        However, since I want to upload the image from the mobile device(like andriod, IOS). Can I use the websocket(website) to upload the image to phpoc.
        I will use .svg as the input source.

        Comment


        • #5
          Hey, I am just a passerby

          I think technically it is possible to send an image via WebSocket to PHPoC board. For example, you can convert the image to a base64 string and then on PHPoC side, you can read and store the base64 string of your image.

          However because of variable and string buffer size limitation on PHPoC board, I think it can only be applicable for small images.
          By the way, the hard part is to convert an image into the readable coordinates. I think it is better if you find the way to convert an image into coordinates on your mobile/PC, then you can send that information to PHPoC board.

          Comment


          • #6
            - task0.php is similar to your code. But you need to implement get_next_coordinate() function.
            - You read the image file in the task0.php, not from other file.
            task0.php is like this:
            PHP Code:
            <?php

            include_once "/lib/sd_340.php";
            include_once 
            "/lib/sd_spc.php";
            include_once 
            "/lib/sn_tcp_ws.php";

            define("PWM_PERIOD"20000); // (20ms)
            define("WIDTH_MIN"600);
            define("WIDTH_MAX"2450);

            define("SID_X",            13);
            define("SID_Y",            14);

            define("MAX_X",         1710);
            define("MAX_Y",         2140);
            define("TOUCH_OFFSET",    100);

            define("PEN_UP",        0);
            define("PEN_DOWN",        1);

            define("CMD_PEN_UP",    0);
            define("CMD_PEN_DOWN",    1);
            define("CMD_MOVE",        2);

            define("SPEED_X_COEF",        20);
            define("SPEED_Y_COEF",        20);
            define("SPEED_X_OFFSET",    50);
            define("SPEED_Y_OFFSET",    50);
            define("SPEED_X_MAX",        5000);
            define("SPEED_Y_MAX",        5000);

            define("ACCEL_X_COEF",        1500);
            define("ACCEL_Y_COEF",        1000);
            define("ACCEL_X_OFFSET",    0);
            define("ACCEL_Y_OFFSET",    0);
            define("ACCEL_X_MAX",        20000);
            define("ACCEL_Y_MAX",        20000);

            define("STATE_X_LOCK",    1);
            define("STATE_X_RUN",    2);
            define("STATE_Y_LOCK",    4);
            define("STATE_Y_RUN",    8);


            function 
            step_cmd($sid$cmd)
            {
                
            $resp spc_request($sid4$cmd);

                if(
            $resp)
                {
                    
            $resp explode(","$resp);

                    if((int)
            $resp[0] != 200)
                    {
                        echo 
            "step_cmd : '$cmd' request error "$resp[0], "\r\n";
                        return 
            false;
                    }

                    if(
            count($resp) > 1)
                        return 
            $resp[1];
                    else
                        return 
            "";
                }
                else
                    return 
            false;
            }

            function 
            spc_check_did($sid$did)
            {
                
            $resp spc_request_csv($sid0"get did");

                if(
            $resp === false)
                {
                    echo 
            "spc_check_did: sid$sid - device not found\r\n";
                    return 
            false;
                }

                if(
            $resp[1] != "40002405")
                {
                    echo 
            "spc_check_did: unknown device "$resp[2], "\r\n";
                    return 
            false;
                }

                return 
            true;
            }

            function 
            pen_up()
            {
                
            $angle 110;

                
            $width WIDTH_MIN + (int)round((WIDTH_MAX WIDTH_MIN) * $angle 180.0);

                if((
            $width >= WIDTH_MIN) && ($width <= WIDTH_MAX))
                    
            ht_pwm_width(2$widthPWM_PERIOD);
            }

            function 
            pen_down()
            {
                
            $angle 180;

                
            $width WIDTH_MIN + (int)round((WIDTH_MAX WIDTH_MIN) * $angle 180.0);

                if((
            $width >= WIDTH_MIN) && ($width <= WIDTH_MAX))
                    
            ht_pwm_width(2$widthPWM_PERIOD);
            }

            function 
            xy_goto($x$y)
            {
                global 
            $mode;

                if(
            $x TOUCH_OFFSET)
                    
            $x TOUCH_OFFSET;
                if(
            $x > (MAX_X TOUCH_OFFSET))
                    
            $x MAX_X TOUCH_OFFSET;

                if(
            $y TOUCH_OFFSET)
                    
            $y TOUCH_OFFSET;
                if(
            $y > (MAX_Y TOUCH_OFFSET))
                    
            $y MAX_Y TOUCH_OFFSET;

                
            $x0 = (int)step_cmd(SID_X"get pos") / $mode;
                
            $y0 = (int)step_cmd(SID_Y"get pos") / $mode;

                
            $delta_x $x $x0
                
            $delta_y $y $y0;

                if(
            $delta_x == && $delta_y == 0)
                    return;

                
            $speed_x SPEED_X_COEF abs($delta_x) + SPEED_X_OFFSET;
                
            $speed_y SPEED_Y_COEF abs($delta_y) + SPEED_Y_OFFSET;

                
            $x *= $mode
                
            $y *= $mode;
                
            $speed_x *= $mode;
                
            $speed_y *= $mode;

                if(
            $speed_x SPEED_X_MAX $mode)
                    
            $speed_x SPEED_X_MAX $mode;

                if(
            $speed_y SPEED_Y_MAX $mode)
                    
            $speed_y SPEED_Y_MAX $mode;

                
            $accel_x ACCEL_X_COEF $speed_x ACCEL_X_OFFSET;
                
            $accel_y ACCEL_Y_COEF $speed_y ACCEL_Y_OFFSET;

                if(
            $accel_x ACCEL_X_MAX $mode)
                    
            $accel_x ACCEL_X_MAX $mode;

                if(
            $accel_y ACCEL_Y_MAX $mode)
                    
            $accel_y ACCEL_Y_MAX $mode;

                if(
            $delta_x == 0)
                {
                    
            step_cmd(SID_Y"goto $y $speed_y $accel_y");
                }
                else if(
            $delta_y == 0)
                {
                    
            step_cmd(SID_X"goto $x $speed_x $accel_x");
                }
                else
                {
                    
            step_cmd(SID_X"goto $x $speed_x $accel_x");
                    
            step_cmd(SID_Y"goto $y $speed_y $accel_y");
                }
                
            //echo "state: ", step_cmd(SID_Y, "get state"), "\r\n";
                //echo SID_X, ", goto $x $speed_x $accel_x\r\n";
                //echo SID_Y, ", goto $y $speed_y $accel_y\r\n";
            }

            function 
            xy_state()
            {
                
            $ret_val 0;

                
            $x_state = (int)step_cmd(SID_X"get state");
                
            $y_state = (int)step_cmd(SID_Y"get state");

                if(
            $x_state == 1// motor is locked
                    
            $ret_val |= STATE_X_LOCK;
                else if(
            $x_state 1// motor is running
                    
            $ret_val |= STATE_X_RUN;

                if(
            $y_state == 1// motor is locked
                    
            $ret_val |= STATE_Y_LOCK;
                else if(
            $y_state 1// motor is running
                    
            $ret_val |= STATE_Y_RUN;

                return 
            $ret_val;
            }

            function 
            xy_wait()
            {
                while(
            xy_state() & (STATE_X_RUN STATE_Y_RUN))
                    
            usleep(1);
            }

            function 
            xy_init()
            {
                global 
            $mode;

                
            $width WIDTH_MIN + (int)round((WIDTH_MAX WIDTH_MIN) * 110 180.0);
                
            ht_pwm_setup(2$widthPWM_PERIOD);
                
            pen_up();

                
            spc_reset();
                
            spc_sync_baud(460800);

                if(!
            spc_check_did(SID_X"40002405"))
                    return;
                if(!
            spc_check_did(SID_Y"40002405"))
                    return;

                
            step_cmd(SID_X"set vref stop 4");
                
            step_cmd(SID_X"set vref drive 15");
                
            step_cmd(SID_X"set mode $mode");
                
            step_cmd(SID_X"set rsnc 120 250");

                
            step_cmd(SID_Y"set vref stop 4");
                
            step_cmd(SID_Y"set vref drive 15");
                
            step_cmd(SID_Y"set mode $mode");
                
            step_cmd(SID_Y"set rsnc 120 250");

                
            // move pen to (0, 0)
                
            $v 800 $mode;
                
            $a 10000 $mode;
                
            step_cmd(SID_X"goto -sw1 $v $a");
                
            step_cmd(SID_Y"goto -sw1 $v $a");
                
            xy_wait();
                
            step_cmd(SID_X"reset");
                
            step_cmd(SID_Y"reset");
                
            /*
                $time_stemp = st_free_get_count(0);
                step_cmd(SID_X, "goto 100 $v $a");
                step_cmd(SID_Y, "goto 100 $v $a");
                xy_wait();
                $time_stemp = st_free_get_count(0) - $time_stemp;

                echo $time_stemp;

                step_cmd(SID_X, "reset");
                step_cmd(SID_Y, "reset");
                */
                
            xy_goto(TOUCH_OFFSETTOUCH_OFFSET);
                
            xy_wait();

                
            // uncomment this block for the first run and change the value in line 45 of index.php
                /*
                // check max steps
                step_cmd(SID_X, "goto +sw0 1600 20000");
                step_cmd(SID_Y, "goto +sw0 1600 20000");

                xy_wait();
                // change this value in line 45 of index.php: var MAX_X * $mode = 3421, MAX_Y * $mode = 4296;
                echo "Max X:", step_cmd(SID_X, "get pos"), "\r\n";
                echo "Max Y:", step_cmd(SID_Y, "get pos"), "\r\n";
                */
            }

            function 
            send_position($pen_state)
            {
                global 
            $mode;

                
            $x = (int)step_cmd(SID_X"get pos") / $mode;
                
            $y = (int)step_cmd(SID_Y"get pos") / $mode;
                
            $wbuf "[$x$y$pen_state]";
                
            ws_write(0$wbuf);
            }

            $mode 32;

            ws_setup(0"xy_plotter""csv.phpoc");
            xy_init();

            $pre_x 0;
            $pre_y 0;
            $cur_x 0;
            $cur_y 0;
            $pen_state CMD_PEN_UP;
            $x_is_unlock false;
            $y_is_unlock false;

            $filename "myimage.svg";
            $rbuf "";
            $fd pid_open($filename);

            function 
            get_next_coordinate()
            {
                
            //pid_read($fd, $rbuf, 5);
                // IMPLEMENT YOUR CODE HERE
            }

            while(
            1)
            {

                
            $coordinate_1 get_next_coordinate();
                
            xy_goto($coordinate_1[0] * $scale_ratio_x$coordinate_1[1] * $scale_ratio_y);
                
            xy_wait();

                
            pen_down();

                
            $coordinate_2 get_next_coordinate();
                
            xy_goto($coordinate_2[0] * $scale_ratio_x$coordinate_2[1] * $scale_ratio_y);
                
            xy_wait();

                
            pen_up();

            }

            Comment


            • #7
              From Ardroid, iOS, you can send file to PHPoC part by part. PHPoC receives data and only can save the data to USER memory, not file system memory. For this, you need to use sc_envu.php library. If you upload via PHPoC debugger, It will be save to system file memory. They are different in term of read/write

              Comment


              • #8
                I think that I have to send the file from the android, IOS. How can I set up the communication between the PHPoc and the mobile device?
                For the "get_next_coordinate" function, should I add the coordinate of the picture? I want the XY plotter to draw the line instead of point out the line according to the coordination.
                I feel very sorry that this is the first time in touch with PHPoC. I do not very understand the structure of it and its library.

                Comment


                • #9
                  Since these project is quite big if the first time in touch with PHPoC. I would like to suggest you divide the project into three stages:
                  - stage 1: just upload file to PHPoC debugger, read it and draw using XY plotter.
                  - stage 2: transfer file though WebSocket from Android and iOS
                  - stage 3: merge two above stages.

                  For the "get_next_coordinate" function, you need to understand format of image file, extract coordinate from it. This is hardest step of this project.
                  For stage 2, I will create a example when I am free and will share you when i finish.

                  Comment


                  • #10
                    I have found some similar source code. But it's using the Bluetooth to connect the Android and the Board.
                    Can I change the code so that it can be adapted on PHPoC?
                    Here's the source code : https://drive.google.com/open?id=1uE...Fyg7vqAWypD_Th
                    PHP Code:
                      private void updatePosition(){     if(_isMoving){         long secs = (System.currentTimeMillis()-_startTime)/1000;         int min = (int)(Math.ceil(secs/60));         int sec = (int)(secs%60);         _timeView.setText("Time "+(min<10?"0"+min:min)+":"+(sec<10?"0"+sec:sec));         int len BluetoothManager.sharedManager().isConnected()?_sendCount:14;         for(int i=0;i<len;i++){             if(_isMoving){                 Point point findNearPixel();                 if(_prevPoint.x==0&&_prevPoint.y==0){                     _prevPoint point;                 }                 float scaleX = (float)_imageView.getWidth()/(float)_myBitmap.getWidth();                 float scaleY = (float)_imageView.getHeight()/(float)_myBitmap.getHeight();                 int x = (int)(point.x*scaleX);                 int y = (int)(point.y*scaleY);                 int prec _checkBox.isChecked()?3:2;                 //sendGCode((x-_prevPoint.x)*prec,(_prevPoint.y-y)*prec);                  _prevPoint.x = x;                 _prevPoint.y = y;                 sendCommand(x*prec,y*prec, false);                 _imageView.addPoint(point.x,point.y);                 x-=5;                 y-=5;                 _pointView.setPadding(x,y,x+11,y+11);             }else{                 break;             }         }         _imageView.invalidate();     } } 

                    Comment


                    • #11
                      I took a quick look at the code you found. Image is processed on Android devices, and then send coordinates to Board to control motors. I think this code is helpful for you. You can learn how it processes image and then write the PHPoC code based on the Android code.

                      Comment


                      • #12
                        Thank you for sending time on the code. I tried to modify the code. But it seems difficult to adapted on PHPoC to me... Do you have any advice which is more simpler?

                        Comment


                        • #13
                          Hello CL_05,
                          I have no idea for this, If you find any other idea, I would be great if you can share it with me.

                          Comment

                          Working...
                          X