You are not logged in.

#1 2017-10-25 12:26:16

qingquan
Member
Registered: 2017-10-19
Posts: 24

I added a button on nextion to send the Gcode "M806" to the RAMPS

I added a button on nextion to send the Gcode "M806" to the RAMPS,How can I implement this?

Offline

#2 2017-10-26 06:42:30

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,546

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

You need to post gcode with key called gcode to /gcode path.

Offline

#3 2017-10-26 10:08:52

qingquan
Member
Registered: 2017-10-19
Posts: 24

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

Where is the /gcode path? Can you teach me a little more detail?

Offline

#4 2017-10-26 10:26:40

qingquan
Member
Registered: 2017-10-19
Posts: 24

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

How can I send the Gcode from nextion to RPI?

Offline

#5 2017-10-26 13:07:42

sgraber
Member
From: Indiana
Registered: 2016-03-11
Posts: 54
Website

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

I'm looking at the source available at https://github.com/Tibus/TouchScreen-For-NanoDLP

I do not see a /gcode directory.   I, too, would like to add a custom button or two to the Nextion touchscreen.

Offline

#6 2017-10-26 16:40:37

MaxJewels
Member
Registered: 2017-08-10
Posts: 88

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

qingquan wrote:

How can I send the Gcode from nextion to RPI?

Do you know a minimum of js programming? If you know it then just insert a custom button on nanoDLP and then retrieve it from the .js file on the page where you're hugging the button indicating the id from the nanoDLP .json file

Offline

#7 2017-10-26 19:59:35

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,546

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

You need to send post request from nextion side to nanodlp /gcode path.

Offline

#8 2017-10-26 21:04:37

sgraber
Member
From: Indiana
Registered: 2016-03-11
Posts: 54
Website

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

Shahin wrote:

You need to send post request from nextion side to nanodlp /gcode path.

Is there an example of a proper post request that we could use?

Offline

#9 2017-10-27 05:07:19

Shahin
Administrator
Registered: 2016-02-17
Posts: 3,546

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

It is very easy to do but it depends on your programming language.

If you want it to send through Linux terminal.
wget --post-data "gcode=M806" http://rpi_ip/gcode

Or with jquery
$.post("http://rpi_ip/gcode", {gcode: "M806"})

OR with nodejs
var request = require('request');
request.post('http://rpi_ip/gcode').form({gcode:'M806'})

Offline

#10 2017-10-27 23:44:03

qingquan
Member
Registered: 2017-10-19
Posts: 24

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

Is this code written to Nextion's button event?

Offline

#11 2017-10-28 07:03:00

MaxJewels
Member
Registered: 2017-08-10
Posts: 88

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

qingquan wrote:

Is this code written to Nextion's button event?

Look at Julien Delnatte's z-axis page (bin / nextion/plugin / page /) or (src / nextion / plugin / page) there are some lines of code that point to other custom buttons so you can give a precise idea

Last edited by MaxJewels (2017-10-28 08:08:48)

Offline

#12 2017-10-29 04:53:44

qingquan
Member
Registered: 2017-10-19
Posts: 24

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

Hi MaxJewels,Thank you very much for your reply.Where can I find Julien Delnatte's z-axis page, or where can I download it?

Offline

#13 2017-10-30 15:23:39

sgraber
Member
From: Indiana
Registered: 2016-03-11
Posts: 54
Website

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

I believe this is what he's referring to:  https://github.com/Tibus/TouchScreen-Fo … s/zAxis.js

Offline

#14 2017-11-02 21:03:31

sgraber
Member
From: Indiana
Registered: 2016-03-11
Posts: 54
Website

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

Ok, I've used the Nextion Editor to add buttons to the home screen (id's are b0 and b2) and I've adjusted the home.js file to include the following:

                this.addListener("click_b0", function (e) {
                  _this2.changePage("/button/press/0");
                });

                this.addListener("click_b2", function (e) {
                  _this2.changePage("/button/press/1");
                });

From what I see, this should allow me to press on these two buttons and get a changePage call to my buttons I made in NanoDLP.

I assume I hit compile and compiling adds all of the .js files from the repository into the .tft?

Offline

#15 2017-11-08 01:02:29

qingquan
Member
Registered: 2017-10-19
Posts: 24

Re: I added a button on nextion to send the Gcode "M806" to the RAMPS

MaxJewels wrote:
qingquan wrote:

How can I send the Gcode from nextion to RPI?

Do you know a minimum of js programming? If you know it then just insert a custom button on nanoDLP and then retrieve it from the .js file on the page where you're hugging the button indicating the id from the nanoDLP .json file

Hi

I want to add code to this file"/home/pi/nextion/bin/plugins/nextion/pages/projector.js" to send "M806" code to ramps, can you tell me the specific code?

Replace the original instruction in this sentence:

this.addListener("click_b4", function () {
                 return _this2.nanoDLP.command("/shutter/open");
                });

Offline

Board footer

Powered by FluxBB