Nextion Waveforms

how to save data in buffer from arduino to waveforms while go to another page

(deleted)

Thank you for your support
for your information waveforms will be read Temperature data from Arduino , sow how to use nextion editor in buffering by sendme command

(deleted)

my WaveForms in page16 :frowning:

not working

///////////////////////////////////////////////////////////////////////////////
void WaveForms()
{
strcpy(buffer_Wave, “page 16”);
send_to_nextion(buffer_Wave);

nex_waveform_data.clear();

randomSeed(analogRead(0));

// initialize and fill waveform on page 0
for (uint16_t ii = 0; ii < waveform_size; ii++) {
uint8_t temp_DS18B20_in = random(0, 255);
nex_waveform_data.addValue(temp_DS18B20_in);
sprintf(buffer_Wave, “add 16,0,%d”, temp_DS18B20_in);
send_to_nextion(buffer_Wave);
}

}
//////////////////////////////////////////////////////////

void wave_refresh()
{
uint8_t temp_DS18B20_in = random(0, 255);

nex_waveform_data.addValue(temp_DS18B20_in);
sprintf(buffer_Wave, “add 0,0,%d”, temp_DS18B20_in);
send_to_nextion(buffer_Wave);

//go to another page
strcpy(buffer_Wave, “page 1”);
send_to_nextion(buffer_Wave);

//wait 2 secounds on other page
delay(2000);

//go back to page 0 with waveform
strcpy(buffer_Wave, “page 0”);
send_to_nextion(buffer_Wave);

//fill up waveform again
for (uint16_t ii = 0; ii < waveform_size; ii++) {
sprintf(buffer_Wave, “add 16,0,%d”, (uint8_t)nex_waveform_data.getElement(ii));
send_to_nextion(buffer_Wave);
}
}
///////////////////////////////////////////////////////////////////////
void send_to_nextion(char ss) {
/*
send_to_nextion():
sends nextion string and terminates it
*/
Serial1.print(ss);
Serial1.write(0xFF);
Serial1.write(0xFF);
Serial1.write(0xFF);
}

anwofis how can I change this code to work with a Uno

There is a huge problem with RunningAverage. First of all if you look at the library it is limited to an array of floats size of 255 (uint8_t = 8-bit unsigned, 0 to 255), so with x-row of 480 it is of no use. Secondly when the row is full the new add start at the beginning, there is NO row shift. So there is no way you can use it other the in my case 224 rows and adding a function to the library so you can redesign the correct row to show in the waveform.

// returns the first added
uint8_t RunningAverage::getFirstID() const
{ if (_cnt < _size) return 0;

return _idx;
}

Two conditions
if return is 0
members from getCount()
for (uint8_t ii = 0; ii < members; ii++) { etc}
if return idx (= OldestData)
for (uint8_t ii = OldestData; ii < members; ii++){ etc}
and
for (uint8_t ii = 0; ii < OldestData; ii++) {cascade}

Rob Tillaart implemented a more easy solution version 0.2.14 pushed including getValue() to get the internal values in order of addition. See example code.