Widget / TinyG v2

This widget shows the TinyG planner buffer so other widgets can limit their flow of sending commands and other specific TinyG features.

by tpet93

HTML

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="http://www.chilipeppr.com/js/require.js"></script>
<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <title><!--(auto-fill by runme.js--></title>

    <!-- ChiliPeppr is based on bootstrap CSS. -->
    <link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">

    <!-- Customized version of require.js for ChiliPeppr. Please see require.js docs for how
    ChiliPeppr's dependency system works as it's based on require.js. -->
    <script type='text/javascript' src="//i2dcui.appspot.com/js/require.js"></script>

    <!-- widget.css DON'T REMOVE -->
    <style type='text/css'>
        /* widget.css will get inlined here by runme.js. don't remove this comment or inlining will fail. */
    </style>
    <link rel="stylesheet" type="text/css" href="widget.css">
    <!-- DON'T REMOVE end widget.css -->

    <!-- widget.js DON'T REMOVE -->
    <script type='text/javascript'>
        //<![CDATA[
        /* widget.js will get inlined here by runme.js. don't remove this comment or inlining will fail. */
        //]]>
    </script>
    <script type='text/javascript' src="widget.js"></script>
    <!-- DON'T REMOVE end widget.js -->

</head>

<body>

    <!--Put HTML Contents of Widget Here-->
    <div id="com-chilipeppr-widget-xyz" class="panel panel-default">
        <div id="com-chilipeppr-widgetholder-wcs" style="position: absolute;left:-80px;top:10px;"></div>
        <div class="panel-heading">
            <div class="btn-group pull-left" style="margin-left:-6px;padding-right:6px;">
                <button type="button" class="btn btn-xs btn-default btnToggleShowWcs" data-delay="500" data-animation="true" data-placement="auto" data-container="body" data-trigger="hover" data-title="Show Work Coordinate System" data-content="Open up the WCS widget to be...

CSS

#com-chilipeppr-widget-xyz-body {
    padding:2px;
}
#com-chilipeppr-widget-xyz-body .col {
    padding:0;
}
#com-chilipeppr-widget-xyz-ftr .hilite {
    background-color: #dff0d8;
}
#com-chilipeppr-widget-xyz-ftr .hiliteblue {
    background-color: #d9edf7;
}
.col {
    float:left;
}
.rotate90 {
    display:block;
    -webkit-transform: rotate(-90deg);
    -webkit-font-smoothing: none;
    -moz-transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);
    transform: rotate(-90deg);
}
.btnincrements .btn {
    font-size:9px;
    padding:1px 3px;
}
.com-chilipeppr-xyz-pos {
    padding:0 0 0 0px;
    margin:0;
}
.com-chilipeppr-xyz-label {
    padding:0;
    margin:0;
}
.com-chilipeppr-xyz-label-well h2 {
    text-align: center;
}
#com-chilipeppr-widget-xyz-body .com-chilipeppr-xyz-label-well {
    background-color: white;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0px;
    margin-right: 2px;
}
#com-chilipeppr-widget-xyz-body .com-chilipeppr-xyz-well {
    overflow: hidden;
    /* position: relative; */
    margin-bottom: 0px;
    padding: 3px 16px;
}
#com-chilipeppr-widget-xyz-body .com-chilipeppr-xyz-pos-well {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}
#com-chilipeppr-widget-xyz-body .com-chilipeppr-xyz-menu {
    /* z-index: 2; */
    position: absolute;
    left: 3px;
    top: 3px;
}
.com-chilipeppr-xyz-menu > .btn {
    border:0;
}
.com-chilipeppr-xyz-dim {
    position: absolute;
    top:0px;
    right:14px;
    font-size:13px;
}
#com-chilipeppr-widget-xyz-ftr {
    overflow-x: visible;
    overflow-y: visible;
}
#com-chilipeppr-widget-xyz-ftr:focus {
    background-color: #428bca;
}
#com-chilipeppr-widget-xyz-ftr.panel-primary {
    background-color: #428bca;
}
.xyz-dimmed {
    color:#e9e9e9;
}
.xyz-limitswitch {
    color:#804040;
    font-size:11px;
}
.xyz-active {
    color: black;
}
.flatbottom {
    border-bottom-left-radius: 0;
   ...

JavaScript

/* global cprequire_test macro chilipeppr THREE $ requirejs cprequire cpdefine chilipeppr */
// Test this element. This code is auto-removed by the chilipeppr.load()
cprequire_test(["inline:com-chilipeppr-widget-xyz"], function (xyz) {
    console.log("test running of " + xyz.id);
    //sp.init("192.168.1.7");
    //xyz.initAs3dPrinting();
    xyz.init();
    xyz.showBody("com-chilipeppr-widget-xyz");
    xyz.currentUnits = 'mm'

    // load the WCS widget to left
    //$('body').css('margin-left', '80px');
    var wrapDiv = $('<div class="testdiv" style="margin-left:80px;position:relative;">');

    $('#com-chilipeppr-widget-xyz').wrap(wrapDiv);

    // test out planner resume/pause
    var testPauseResume = function () {
        setTimeout(function () {
            chilipeppr.publish('/com-chilipeppr-interface-cnccontroller/plannerpause', "");
        }, 5000);
        setTimeout(function () {
            chilipeppr.publish('/com-chilipeppr-interface-cnccontroller/plannerresume', "");
        }, 10000);
        setTimeout(function () {
            chilipeppr.publish('/com-chilipeppr-interface-cnccontroller/plannerpause', "");
        }, 15000);
        setTimeout(function () {
            chilipeppr.publish('/com-chilipeppr-interface-cnccontroller/plannerresume', "");
        }, 20000);
    };

    var testAxesValUpdates = function () {
        setTimeout(function () {
            chilipeppr.publish("/com-chilipeppr-interface-cnccontroller/axes", {
                x: 0.005,
                y: 10.46,
                z: 0.304,
                a: 0,
                type: "work",
                mpo: {
                    x: 0.005,
                    y: 10.46,
                    z: 0.304,
                    a: 0,
                    type: "machine"
                }
            });
        }, 1000);
        setTimeout(function () {
            chilipeppr.publish("/com-chilipeppr-interface-cnccontroller/axes", {
                x: 192,
                y: 0.028,
 ...