This widget shows the GRBL Buffer so other widgets can limit their flow of sending commands and other specific GRBL features.
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 |
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();
}
);
}
);
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/feedhold | Feedhold (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/plannerpause | This 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/plannerresume | This 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/axes | This 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/units | This 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/proberesponse | Publish 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/status | Publish a signal each time the GRBL status changes |
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/grblVersion | Publish the version number of the currently installed grbl |
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/distance | publish whether we are in absolute or incremental mode |
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/jogFeedRate | publish change in desired jog feed rate |
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/jogdone | We 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/recvgcode | Subscribe to receive gcode from other widgets for processing and passing on to serial port |
/com-chilipeppr-widget-grbl/com-chilipeppr-interface-cnccontroller/coordinateUnits | Subscribe to units being sent by the gcode widget |
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/send | We 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 ~ |
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/onconnect | When we see a new connect, query for status. |
/com-chilipeppr-widget-grbl/com-chilipeppr-widget-serialport/recvline | When 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/send | Subscribe to serial send and override so no other subscriptions receive command. |
/com-chilipeppr-widget-grbl/com-chilipeppr-widget-grbl-autolevel/probing | Subscribe to the autolevel widget to listen for probing commands |
/com-chilipeppr-widget-grbl/com-chilipeppr-widget-serialport/onQueue | we need to track whether someone is manually changing the config |
The table below shows, in order, the methods and properties inside the widget/element.
Method / Property | Type | Description |
---|---|---|
probing | boolean | |
id | string | "com-chilipeppr-widget-grbl" |
implements | object | |
url | string | "http://raw.githubusercontent.com/jpadie/grbl1-test-widget/master/auto-generated-widget.html" |
githuburl | string | "http://github.com/jpadie/grbl1-test-widget" |
testurl | string | "http://grbl1_test_widget-jpadie.c9users.io/widget.html" |
fiddleurl | string | "http://ide.c9.io/jpadie/grbl1_test_widget" |
name | string | "Widget / GRBL 1.1 compatibility test" |
desc | string | "This widget shows the GRBL Buffer so other widgets can limit their flow of sending commands and other specific GRBL features." |
publish | object | Please see docs above. |
subscribe | object | Please see docs above. |
foreignPublish | object | Please see docs above. |
foreignSubscribe | object | Please see docs above. |
distance | string | |
config | object | |
err_log | object | |
buffer_name | string | |
report_mode | number | |
work_mode | number | |
controller_units | object | |
status | string | "Offline" |
version | string | |
widgetVersion | string | "2017-09-03h" |
q_count | number | |
alarm | boolean | |
spindleSpeed | string | "Off" |
spindleDirection | object | |
feedRate | number | |
coolant | string | "Off" |
offsets | object | |
last_work | object | |
last_machine | object | |
g_status_reports | object | |
gcode_lookup | object | |
overrides | object | |
singleSelectPort | object | |
configFormatData | object | |
isDebugMode | function | function () |
grblConsole | function | function () |
findConfigItem | function | function (i) |
init | function | function () |
spindleEnabled | boolean | |
options | object | |
isV1 | function | function () |
setVersion | function | function (ver) |
setupUiFromCookie | function | function () |
saveOptionsCookie | function | function () |
btnSetup | function | function () |
setJogRate | function | function (rate) |
showConfigModal | function | function () |
hideConfigModal | function | function () |
saveConfigModal | function | function () |
assignConfigValue | function | function (index, val) |
commandQueue | object | |
isConnected | function | function () |
connectedToPort | boolean | |
doQueue | function | function () |
availableBuffer | number | |
harmoniseCoordinates | function | function (unitSystem) |
updateWorkUnits | function | function (units) |
updateCoordinateUnits | function | function (unitSystem) |
updateReportUnits | function | function () |
openController | function | function (isWithDelay) |
closeController | function | function (isWithDelay) |
getControllerInfo | function | function () |
trackGcodeLines | function | function () |
restartStatusInterval | function | function () |
grblResponseV1 | function | function (recvline) |
grblResponse | function | function (recvline) |
sendCode | function | function (sendline) |
clearBuffer | function | function () |
updateMachineCoords | function | function () |
publishAxisStatus | function | function (axes) |
plannerLastEvent | string | "resume" |
publishPlannerPause | function | function () |
publishPlannerResume | function | function () |
toInch | function | function (mm) |
toMM | function | function (inch) |
addError | function | function (line, msg) |
forkSetup | function | function () |
uiHover | function | function () |
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?