Hallo.
Ich habe mir einen Nextion Touch Display besorgt nur bin ich aufgrud der verwirrend api langsam am verzweifeln
Mein Bild sieht so aus : Siehe Anhang
Wenn ich auf Test klicke soll der ARduino in den Test Modus gehen.
Dort will ich dann auf heat klick oder cool und er soll die Werte der Beiden Schiebebaren als PWM werte nutzen. Ich habe mehre Sachen ausprobiert über Softerserial Nextion liabry etc nichts hat geholfen kann mir jemand helfen?
Mein Code:
// Project: DIY Thermocyler V2.0 Arduino
// Creator: Tobias and Torben
// Date of Creation: 10.12.16
//#include <Wire.h>
#include <SoftwareSerial.h>
#include "NexButton.h"
SoftwareSerial softser(2,3); //RX,TX
int cycle = 0;
int cycle_help = 0;
int cycle_temp[] = {};
int cycle_time[] = {};
String softread = "";
//Nextions Display Buttons
char buffer[100] = {0};
NexButton b4 = NexButton(0, 6, "b4");
NexTouch *nex_listen_list[] =
{
&b4,
NULL
};
void setup() {
// put your setup code here, to run once:
Serial.begin(57600);
while (!Serial){
}
Serial.print("test");
softser.begin(9600);
nexInit();
}
void b0PopCallback(void *ptr)
{
NexButton *btn = (NexButton *)ptr;
memset(buffer, 0, sizeof(buffer));
btn->getText(buffer, sizeof(buffer));
if (strcmp(buffer,"ON"))
{
digitalWrite(9, HIGH);
strcpy(buffer, "ON");
}
else
{
digitalWrite(9, LOW);
strcpy(buffer, "OFF");
}
btn->setText(buffer);
}
void loop() {
if (softser.available()){
softread = softser.read();
Serial.print(softser.read());
}
if (softread == "test_mode"){
test_mode();
}
if (softread == "cycle"){
while (1){
cycle = softser.read();
if (cycle > 0){
break;
}
}
}
if (softread == "temp"){
while(1){
//myNextion.print("Value" + cycle_help);
cycle_temp[cycle_help] = softser.read();
cycle_help++;
if (cycle_help == cycle){
cycle_help = 0;
break;
}
}
}
if (softread == "time"){
while(1){
//softserial.print("Value" + cycle_help);
cycle_time[cycle_help] = softser.read();
cycle_help++;
if (cycle_help == cycle){
break;
}
}
}
if (softread == "go"){
sendData();
}
}
void sendData(){
int temp_ok = 0;
int time_ok = 0;
while(!Serial){
}
while(temp_ok == 0){
Serial.print("Ready");
temp_ok = Serial.read();
}
int i;
for (i = 0; i < sizeof(cycle_temp); i++) {
Serial.print(cycle_temp[i]);
}
i = 0;
while(time_ok == 0){
time_ok = Serial.read();
}
for (i = 0; i < sizeof(cycle_time); i++) {
Serial.print(cycle_time[i]);
}
delay(100);
Serial.print("Finished");
}
void test_mode(){
Serial.begin(9600);
Serial.print("Entered test_mode");
if (softser.read()=="heat"){
Serial.print("heat");
}
if (softser.read()=="cool"){
Serial.print("cool");
}
if (softser.read()=="pwm_fan"){
Serial.print("pwm_fan");
Serial.print(softser.read());
}else if(softser.read()=="pwm_heat"){
Serial.print("pwm_heat");
Serial.print(softser.read());
}
}
Ich nutze die offizelle Itea Nextion Libary