Start a new topic

touch screen missing touches events

 every time which I send any command from arduino to nextion, if I touch the screen in this moment I will lose this command in arduino. If I actualize the temperature at 1 second per time, I will have several problems with the touch
How can I solve this problem?


thank you



maybe wrong program-logic?

neither your Arduino nor your Nextion is a multitasking device, they only can do ONE thing at same time ...

btw. you don't have an issue with the Nextion touch, you have an issue at Arduino side catching the incoming touch ...

 

How speedy is your baud rate set to?

 - each incoming byte uses 10 bits: 1 parity bit, 8 data bits, 1 stop bit.

 - At 9600 bps (bits per second) / 10 bits per byte = 960 bytes.

 - at 115200 bps / 10 bits = 11520 bytes.


"actualize the temperature at 1 sec" ... how is the done?

 - if use of delay() ... certainly loss.  delay() means: do nothing.



@marcos


Are you using the Itead Nextion library for Arduino?

hi,
I don´t use "delay" command in Arduino.
I try all speed baud rate, and have no significant changes.
I used all libraries about Nextion, and a have the same results.
let's take a look in Fish tank program as example:
we have this;
   if (timer > update)
    {
        temperatureDisplay();
        update += 30;
    }

in that example there is a waiting time to update. it is because we have a "delay 1000" command when we read temperature.

let´s change a little.
fist uncommnet:
   if (timer > update)
    {
       // temperatureDisplay();
        update += 30;
    }


second copy and paste temperaturedisplay:
    if (number%2)
        {
temperatureDisplay();
 
strcpy(buffer,":"); second.setText(buffer); buffer_second = number; }
third  uncommnet "delay 1000":

void temperatureDisplay(void)
{
    byte i;
    byte present = 0;
    byte type_s = 0;
    byte data[12];
    byte addr[8];
    float celsius;

    ds.search(addr);

    ds.reset();
    ds.select(addr);
    ds.write(0x44,1);                       /* start conversion, with parasite power on at the end */

    // delay(1000);                            /* maybe 750ms is enough, maybe not */
                                            /* we might do a ds.depower() here, but the reset will take care of it. */
    present = ds.reset();
    ds.select(addr);    
    ds.write(0xBE);                         /* Read Scratchpad */

    for ( i = 0; i < 9; i++) 
    {   /* we need 9 bytes */
        data[i] = ds.read();
    }
    /* convert the data to actual temperature*/
    unsigned int raw = (data[1] << 8) | data[0];
    if (type_s) 
    {
        raw = raw << 3;                         /* 9 bit resolution default */
        if (data[7] == 0x10) 
        {
            /* count remain gives full 12 bit resolution */
            raw = (raw & 0xFFF0) + 12 - data[6];
        }
    } 
    else 
    {
        byte cfg = (data[4] & 0x60);
        if (cfg == 0x00) raw = raw << 3; 
        else if (cfg == 0x20) raw = raw << 2; 
        else if (cfg == 0x40) raw = raw << 1; 
        /* default is 12 bit resolution, 750 ms conversion time */
    }
    celsius = (float)raw / 16.0;
    number = ((float)celsius/60)*180+30;
    pointer.setValue(number);

    memset(buffer, 0, sizeof(buffer));
    itoa(celsius, buffer, 10);
    temperature.setText(buffer);
     
    
}

 now we have uptade temperature every second. in this case sometimes I touch the screen and nothing happens, but still ok, the problem is if you have 2 or more uptades. I use Nextion to made pcb to commercial ovens when I have too many temperatures for uptade.


any one you have any solution?

thank you

I have this project, and I have 4 temperatures for uptate

 

let me ask something objectively

Can I send any arduino command to nextion and receive nextion command for arduino at the same time?

 

at exactly the same time, NO


Arduino is no Multitasking device ... but I already stated this in the first answer ... pls. read ...


1 person likes this

yes gerry, I know, so the question is! how can I solve this problem? I have many updates for send to nextion every time which I send commands to nextion I can't touch the screen!

In theory if I increase the baud rate is better, but if I increase too much does not work very well

when you know, why do you ask????

this problem CANT be solved. Your Arduino can NEVER do 2 things at the same time, sorry.

 

just to make my point!
ok, that is it? there is no way to minimize this problem?

 

"let me ask something ..." is not making a point, that's a question ... and with such a question, which was already answered at the very beginning, you only waste time of the ones who are maybe willing to help.


As also already posted in my first answer, you just have the wrong program strategy ... that's all ...


You can surely minimize or even avoid this problem, but you won't find a ready to use answer out. That's something you must do by yourself ...





I just wanted to make the point clear.

A good answer for those who do not know how to solve.
Nextion can never be used in industry and commerce is just for hobby.

I made a nice correction in your Fish Tanke program and you tell me that I make you waste your time? No you're wasting my time.

 

@marcos


Have a read through this thread, it may be connected to your issue...

http://support.iteadstudio.com/support/discussions/topics/11000011561

Now I will be clear.


Your opinion is flawed, such statement is childish.

>  Nextion can never be used in industry and commerce is just for hobby.


When someone lacks programming skills, or understandings

then how does this make it no good for commercial and industry.


Are there not already temperatures used in commercial and industry?  Yes.

So it is not impossible just because someone particular can not reproduce.


Now regardless of any justification for why you used a delay

 - the fact remains delay() is a halt in code - an all stop till time passes.

 - in such halted time, your are purposefully pause and miss incoming.


It is user code on MCU side that is responsible for your problem

It is not code on Nextion side, but yet you blame the Nextion


Do you also say University is useless for students

  when a student of University has issue opening a can at home?


Fact: such temperature is being done, and quite successfully by others

Your code troubles do not make your statement true

And with more effort, you too could even be successful with

But code for a Temperature Sensor is not a Nextion issue


Arduino.cc has much written on OneWire and even a couple of

methods that users could consider to their code approaches.


Login or Signup to post a comment