コード例 #1
0
 public static string [] FastMove(MoveReference reference, GVector3 value)
 {
     return(new string[] {
         reference == MoveReference.Absolute? AsAbsolute(): AsRelative(),
         GCode3018Pro.FastMove(value)
     });
 }
コード例 #2
0
    public string[] GetCommands()
    {
        List <string> cmds    = new List <string>();
        int           centerX = (int)(m_width * m_mmPerPixels / 2f);
        int           centerY = (int)(m_height * m_mmPerPixels / 2f);

        cmds.Add(GCode3018Pro.AsAbsolute());
        for (int i = 0; i < m_pixels.Length; i++)
        {
            float x, y;
            GetCoordonateOf(i, out x, out y);
            x -= centerX;
            y -= centerY;
            x *= m_mmPerPixels;
            y *= m_mmPerPixels;
            if (m_pixels[i] != Color.white)
            {
                cmds.Add("Z0");
                cmds.Add(GCode3018Pro.FastMove(new GVector3(x, y, 0)));
                cmds.Add("Z-1");
                cmds.Add("Z0");
            }
        }
        return(cmds.ToArray());
    }
コード例 #3
0
    private void MoveInDirection(GVector3 direction)
    {
        if (m_moveReference == MoveReference.Relative)
        {
            SendCommandIfConnection(GCode3018Pro.AsRelative());
        }
        else
        {
            SendCommandIfConnection(GCode3018Pro.AsAbsolute());
        }

        if (!m_isMotorTheoriclyOn)
        {
            SendCommandIfConnection(GCode3018Pro.FastMove(direction));
        }
        else
        {
            SendCommandIfConnection(GCode3018Pro.ControlledMove(direction, m_speedRateInMm));
        }
    }
コード例 #4
0
    void Update()
    {
        Vector2 bedDirectionPrevious = bedDirection;

        bedDirection.x = Input.GetAxis("Horizontal");
        bedDirection.y = Input.GetAxis("Vertical");

        if (bedDirectionPrevious == Vector2.zero && bedDirection != bedDirectionPrevious)
        {
            m_sender.SendCommandDirectly(
                m_moveType == MoveReference.Relative ?
                GCode3018Pro.AsRelative() :
                GCode3018Pro.AsAbsolute());
        }
        if (bedDirection != Vector2.zero)
        {
            m_sender.OverrideAllToPush(
                GCode3018Pro.FastMove(
                    new GVector3(
                        bedDirection.x * m_incrementInMM,
                        bedDirection.y * m_incrementInMM,
                        0)));
        }
    }