Aviso

El foro está en modo de sólo lectura.

ayuda con nextion

Más
6 años 1 mes antes #1270 por jesuslopez
Respuesta de jesuslopez sobre el tema ayuda con nextion
lo he probado tambien en ese puerto y ni pompas. he probado:
amarillo tx2
azul rx2 y tampoco
Más
6 años 1 mes antes #1271 por jesuslopez
Respuesta de jesuslopez sobre el tema ayuda con nextion
por ejemplo estoy con una ejemplo de marikan :

he conectado la nextion con el puerto 2 y un led en la salida 13, y con el codigo que pongo a continuacion no hace nada
codigo:
#include <Nextion.h>


NexButton b0 = NexButton(0, 1, "b0");
NexDSButton bt0 = NexDSButton(0, 3, "bt0");

NexTouch *nex_listen_list[] =
{
&b0, // Button added
&bt0,
NULL // String terminated
};

void b0PushCallback(void *ptr) // Press event for button b1
{
digitalWrite(13, HIGH); // Turn ON internal LED
} // End of press event

void b0PopCallback(void *ptr) // Release event for button b1
{
digitalWrite(13, LOW); // Turn OFF internal LED
} // End of release event

void bt0PopCallback(void *ptr) // Release event for button b1
{
uint32_t number5 = 0; // Create variable to store value we are going to get
bt0.getValue(&number5); // Read value of dual state button to know the state (0 or 1)

if(number5 == 1){ // If dual state button is equal to 1 (meaning is ON)...
digitalWrite(13, HIGH); // Turn ON internal LED
}else{ // Since the dual state button is OFF...
digitalWrite(13, LOW); // Turn OFF internal LED
}
} // End of release event

void setup() {

Serial.begin(9600);
delay(500); // This dalay is just in case the nextion display didn't start yet, to be sure it will receive the following command.
Serial.print("baud=115200");
Serial.write(0xff); // We always have to send this three lines after each command sent to nextion.
Serial.write(0xff);
Serial.write(0xff);

Serial.end(); // End the serial comunication of baud=9600

Serial.begin(115200); // Start serial comunication at baud=115200

// Register the event callback functions of each touch event:
// You need to register press events and release events seperatly.
// Format for press events: <object name>.attachPush(<object name>PushCallback);
// Format for release events: <object name>.attachPop(<object name>PopCallback);
b0.attachPush(b0PushCallback); // Button press
b0.attachPop(b0PopCallback); // Button release
bt0.attachPop(bt0PopCallback); // Button release
}

void loop() {
// put your main code here, to run repeatedly:

nexLoop(nex_listen_list);
}
Más
6 años 1 mes antes #1272 por Jose Luis
Respuesta de Jose Luis sobre el tema ayuda con nextion
Bueno, en ese codigo hay cosas que no acabo de entender para que las hace, pero bueno, tendrias que consultarle al creador.
De todas formas siempre hay que coger dos cosas, el codigo del arduino y el codigo de la nextion, y publicarlos los dos para que podamos probar si el codigo funciona.

Aparentemente los cables son como lo has dicho.

Abre el monitor serial a ver si te pone algo asi como comunicacion Ok y no err.
Más
6 años 1 mes antes #1273 por jesuslopez
Respuesta de jesuslopez sobre el tema ayuda con nextion
ya empiezo a ver la luz, he cogido este codigo y para probar la comunicacion con el mega le he hecho activar la salida 13. ademas me da por el monitor serie informacion asi que ya he conseguido avanzar algo. como se adjunta archivos para poder poner el hmi que lo pruebes?.

/**
* @example CompButton.ino
*
* @par How to Use
* This example shows that when the button component on the Nextion screen is released,
* the text of this button will plus one every time.
*
* @author Wu Pengfei (email:<Esta dirección de correo electrónico está siendo protegida contra los robots de spam. Necesita tener JavaScript habilitado para poder verlo.>)
* @date 2015/7/10
* @updated 2016/12/25 bring HMI up to v0.32 to avoid too old issues
* @convert by Patrick Martin, no other changes made
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/

#include "Nextion.h"

/*
* Declare a button object [page id:0,component id:1, component name: "b0"].
*/
NexButton b0 = NexButton(0, 1, "b0");

char buffer[100] = {0};

/*
* Register a button object to the touch event list.
*/
NexTouch *nex_listen_list[] =
{
&b0,
NULL
};

/*
* Button component pop callback function.
* In this example,the button's text value will plus one every time when it is released.
*/
void b0PopCallback(void *ptr)
{
uint16_t len;
uint16_t number;
NexButton *btn = (NexButton *)ptr;
dbSerialPrintln("b0PopCallback");
dbSerialPrint("ptr=");
dbSerialPrintln((uint32_t)ptr);
memset(buffer, 0, sizeof(buffer));
digitalWrite(13, HIGH); // Turn ON internal LED
delay(5000);
digitalWrite(13, LOW); // Turn ON internal LED
/* Get the text value of button component [the value is string type]. */
btn->getText(buffer, sizeof(buffer));

number = atoi(buffer);
number += 1;

memset(buffer, 0, sizeof(buffer));
itoa(number, buffer, 10);

/* Set the text value of button component [the value is string type]. */
btn->setText(buffer);
}

void setup(void)
{
/* Set the baudrate which is for debug and communicate with Nextion screen. */
nexInit();

/* Register the pop event callback function of the current button component. */
b0.attachPop(b0PopCallback, &b0);

dbSerialPrintln("setup done");
}

void loop(void)
{
/*
* When a pop or push event occured every time,
* the corresponding component
in touch event list will be asked.
*/
nexLoop(nex_listen_list);
}
Más
6 años 1 mes antes - 6 años 1 mes antes #1274 por Jose Luis
Respuesta de Jose Luis sobre el tema ayuda con nextion
Y por que no cargas algunos de los ejemplos que publicamos aqui, como el del dual state button?

Esos estan comprobados que funcionan.

Psra subir ficheros, los metes en una carpeta y la comprimes con winrar o winzip. Ya podras subirlos como fichero adjunto.
Última Edición: 6 años 1 mes antes por Jose Luis.
Más
6 años 1 mes antes #1275 por jesuslopez
Respuesta de jesuslopez sobre el tema ayuda con nextion
soy asi de complicado, mañana probaré a cargar alguno si. gracias por todo, cuando mañana haga la prueba te cuento.
Tiempo de carga de la página: 0.110 segundos
Gracias a Foro Kunena