/grbl1-test-widget

grbl1 test widget

Primary LanguageHTML

com-chilipeppr-widget-grbl

This widget shows the GRBL Buffer so other widgets can limit their flow of sending commands and other specific GRBL features.

alt text

ChiliPeppr Widget / GRBL 1.1 compatibility test

All ChiliPeppr widgets/elements are defined using cpdefine() which is a method that mimics require.js. Each defined object must have a unique ID so it does not conflict with other ChiliPeppr widgets.

Item Value
ID com-chilipeppr-widget-grbl
Name Widget / GRBL 1.1 compatibility test
Description This widget shows the GRBL Buffer so other widgets can limit their flow of sending commands and other specific GRBL features.
chilipeppr.load() URL http://raw.githubusercontent.com/jpadie/grbl1-test-widget/master/auto-generated-widget.html
Edit URL http://ide.c9.io/jpadie/grbl1_test_widget
Github URL http://github.com/jpadie/grbl1-test-widget
Test URL https://preview.c9users.io/jpadie/grbl1_test_widget/widget.html

Example Code for chilipeppr.load() Statement

You can use the code below as a starting point for instantiating this widget inside a workspace or from another widget. The key is that you need to load your widget inlined into a div so the DOM can parse your HTML, CSS, and Javascript. Then you use cprequire() to find your widget's Javascript and get back the instance of it.

// Inject new div to contain widget or use an existing div with an ID
$("body").append('<' + 'div id="myDivWidgetGrbl"><' + '/div>');

chilipeppr.load(
  "#myDivWidgetGrbl",
  "http://raw.githubusercontent.com/jpadie/grbl1-test-widget/master/auto-generated-widget.html",
  function() {
    // Callback after widget loaded into #myDivWidgetGrbl
    // Now use require.js to get reference to instantiated widget
    cprequire(
      ["inline:com-chilipeppr-widget-grbl"], // the id you gave your widget
      function(myObjWidgetGrbl) {
        // Callback that is passed reference to the newly loaded widget
        console.log("Widget / GRBL 1.1 compatibility test just got loaded.", myObjWidgetGrbl);
        myObjWidgetGrbl.init();
      }
    );
  }
);

Publish

This widget/element publishes the following signals. These signals are owned by this widget/element and are published to all objects inside the ChiliPeppr environment that listen to them via the chilipeppr.subscribe(signal, callback) method. To better understand how ChiliPeppr's subscribe() method works see amplify.js's documentation at http://amplifyjs.com/api/pubsub/

Signal Description
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/feedholdFeedhold (Emergency Stop). This signal is published when user hits the Feedhold button for an emergency stop of the GRBL. Other widgets should see this and stop sending all commands such that even when the plannerresume signal is received when the user clears the queue or cycle starts again, they have to manually start sending code again. So, for example, a Gcode sender widget should place a pause on the sending but allow user to unpause.
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/plannerpauseThis widget will publish this signal when it determines that the planner buffer is too full on the GRBL and all other elements/widgets need to stop sending data. You will be sent a /plannerresume when this widget determines you can start sending again. The GRBL has a buffer of 28 slots for data. You want to fill it up with around 12 commands to give the planner enough data to work on for optimizing velocities of movement. However, you can't overfill the GRBL or it will go nuts with buffer overflows. This signal helps you fire off your data and not worry about it, but simply pause the sending of the data when you see this signal. This signal does rely on the GRBL being in {qv:2} mode which means it will auto-send us a report on the planner every time it changes. This widget watches for those changes to generate the signal. The default setting is when we hit 12 remaining planner buffer slots we will publish this signal.
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/plannerresumeThis widget will send this signal when it is ok to send data to the GRBL again. This widget watches the {qr:[val]} status report from the GRBL to determine when the planner buffer has enough room in it to send more data. You may not always get a 1 to 1 /plannerresume for every /plannerpause sent because we will keep sending /plannerpause signals if we're below threshold, but once back above threshold we'll only send you one /plannerresume. The default setting is to send this signal when we get back to 16 available planner buffer slots.
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/axesThis widget will normalize the GRBL status report of axis coordinates to send off to other widgets like the XYZ widget. The axes publish payload contains {x:float, y:float, z:float, a:float} If a different CNC controller is implemented, it should normalize the coordinate status reports like this model. The goal of this is to abstract away the specific controller implementation from generic CNC widgets.
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/unitsThis widget will normalize the GRBL units to the interface object of units {units: "mm"} or {units: "inch"}. This signal will be published on load or when this widget detects a change in units so other widgets like the XYZ widget can display the units for the coordinates it is displaying.
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/proberesponsePublish a probe response with the coordinates triggered during probing, or an alarm state if the probe does not contact a surface
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/statusPublish a signal each time the GRBL status changes
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/grblVersionPublish the version number of the currently installed grbl
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/distancepublish whether we are in absolute or incremental mode
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/jogFeedRatepublish change in desired jog feed rate

Subscribe

This widget/element subscribes to the following signals. These signals are owned by this widget/element. Other objects inside the ChiliPeppr environment can publish to these signals via the chilipeppr.publish(signal, data) method. To better understand how ChiliPeppr's publish() method works see amplify.js's documentation at http://amplifyjs.com/api/pubsub/

Signal Description
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/jogdoneWe subscribe to a jogdone event so that we can fire off an exclamation point (!) to the GRBL to force it to drop all planner buffer items to stop the jog immediately.
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/recvgcodeSubscribe to receive gcode from other widgets for processing and passing on to serial port
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/coordinateUnitsSubscribe to units being sent by the gcode widget

Foreign Publish

This widget/element publishes to the following signals that are owned by other objects. To better understand how ChiliPeppr's subscribe() method works see amplify.js's documentation at http://amplifyjs.com/api/pubsub/

Signal Description
/com-chilipeppr-widget-grbl/com-chilipeppr-widget-serialport/sendWe send to the serial port certain commands like the initial configuration commands for the GRBL to be in the correct mode and to get initial statuses like planner buffers and XYZ coords. We also send the Emergency Stop and Resume of ! and ~

Foreign Subscribe

This widget/element publishes to the following signals that are owned by other objects. To better understand how ChiliPeppr's publish() method works see amplify.js's documentation at http://amplifyjs.com/api/pubsub/

Signal Description
/com-chilipeppr-widget-grbl/com-chilipeppr-widget-serialport/ws/onconnectWhen we see a new connect, query for status.
/com-chilipeppr-widget-grbl/com-chilipeppr-widget-serialport/recvlineWhen we get a dataline from serialport, process it and fire off generic CNC controller signals to the /com-chilipeppr-interface-cnccontroller channel.
/com-chilipeppr-widget-grbl/com-chilipeppr-widget-serialport/sendSubscribe to serial send and override so no other subscriptions receive command.
/com-chilipeppr-widget-grbl/com-chilipeppr-widget-grbl-autolevel/probingSubscribe to the autolevel widget to listen for probing commands
/com-chilipeppr-widget-grbl/com-chilipeppr-widget-serialport/onQueuewe need to track whether someone is manually changing the config

Methods / Properties

The table below shows, in order, the methods and properties inside the widget/element.

Method / Property Type Description
probingboolean
idstring"com-chilipeppr-widget-grbl"
implementsobject
urlstring"http://raw.githubusercontent.com/jpadie/grbl1-test-widget/master/auto-generated-widget.html"
githuburlstring"http://github.com/jpadie/grbl1-test-widget"
testurlstring"http://grbl1_test_widget-jpadie.c9users.io/widget.html"
fiddleurlstring"http://ide.c9.io/jpadie/grbl1_test_widget"
namestring"Widget / GRBL 1.1 compatibility test"
descstring"This widget shows the GRBL Buffer so other widgets can limit their flow of sending commands and other specific GRBL features."
publishobjectPlease see docs above.
subscribeobjectPlease see docs above.
foreignPublishobjectPlease see docs above.
foreignSubscribeobjectPlease see docs above.
distancestring
configobject
err_logobject
buffer_namestring
report_modenumber
work_modenumber
controller_unitsobject
statusstring"Offline"
versionstring
widgetVersionstring"2017-09-03h"
q_countnumber
alarmboolean
spindleSpeedstring"Off"
spindleDirectionobject
feedRatenumber
coolantstring"Off"
offsetsobject
last_workobject
last_machineobject
g_status_reportsobject
gcode_lookupobject
overridesobject
singleSelectPortobject
configFormatDataobject
isDebugModefunctionfunction ()
grblConsolefunctionfunction ()
findConfigItemfunctionfunction (i)
initfunctionfunction ()
spindleEnabledboolean
optionsobject
isV1functionfunction ()
setVersionfunctionfunction (ver)
setupUiFromCookiefunctionfunction ()
saveOptionsCookiefunctionfunction ()
btnSetupfunctionfunction ()
setJogRatefunctionfunction (rate)
showConfigModalfunctionfunction ()
hideConfigModalfunctionfunction ()
saveConfigModalfunctionfunction ()
assignConfigValuefunctionfunction (index, val)
commandQueueobject
isConnectedfunctionfunction ()
connectedToPortboolean
doQueuefunctionfunction ()
availableBuffernumber
harmoniseCoordinatesfunctionfunction (unitSystem)
updateWorkUnitsfunctionfunction (units)
updateCoordinateUnitsfunctionfunction (unitSystem)
updateReportUnitsfunctionfunction ()
openControllerfunctionfunction (isWithDelay)
closeControllerfunctionfunction (isWithDelay)
getControllerInfofunctionfunction ()
trackGcodeLinesfunctionfunction ()
restartStatusIntervalfunctionfunction ()
grblResponseV1functionfunction (recvline)
grblResponsefunctionfunction (recvline)
sendCodefunctionfunction (sendline)
clearBufferfunctionfunction ()
updateMachineCoordsfunctionfunction ()
publishAxisStatusfunctionfunction (axes)
plannerLastEventstring"resume"
publishPlannerPausefunctionfunction ()
publishPlannerResumefunctionfunction ()
toInchfunctionfunction (mm)
toMMfunctionfunction (inch)
addErrorfunctionfunction (line, msg)
forkSetupfunctionfunction ()
uiHoverfunctionfunction ()

About ChiliPeppr

ChiliPeppr is a hardware fiddle, meaning it is a website that lets you easily create a workspace to fiddle with your hardware from software. ChiliPeppr provides a Serial Port JSON Server that you run locally on your computer, or remotely on another computer, to connect to the serial port of your hardware like an Arduino or other microcontroller.

You then create a workspace at ChiliPeppr.com that connects to your hardware by starting from scratch or forking somebody else's workspace that is close to what you are after. Then you write widgets in Javascript that interact with your hardware by forking the base template widget or forking another widget that is similar to what you are trying to build.

ChiliPeppr is massively capable such that the workspaces for TinyG and Grbl CNC controllers have become full-fledged CNC machine management software used by tens of thousands.

ChiliPeppr has inspired many people in the hardware/software world to use the browser and Javascript as the foundation for interacting with hardware. The Arduino team in Italy caught wind of ChiliPeppr and now ChiliPeppr's Serial Port JSON Server is the basis for the Arduino's new web IDE. If the Arduino team is excited about building on top of ChiliPeppr, what will you build on top of it?