krzychb / EspScopeA0

On-line wave-forms of ESP8266's A0 in a web browser using web sockets
GNU Lesser General Public License v2.1
42 stars 13 forks source link

Display Binary Data #2

Open williamesp2015 opened 8 years ago

williamesp2015 commented 8 years ago

Hi @krzychb , I tested sending binary data (signed integer) and display multi-channel chart. int16_t samples[Sample number]; uint8_t u8Data[Sample number*2]; ...... u8Data[0]=samples[0]/256;//high byte u8Data[1]=samples[0]%256; ..... webSocket.sendBIN(socketNumber, u8Data, NN); /////////// index.html ......... connection = new WebSocket(host, ['arduino']); connection.binaryType = 'arraybuffer'; ........ var buffer = new Uint8Array(message.data); var dataview=new Int16Array(NN); dataview[0]=(buffer[0]<<8)+buffer[1]; ............... scopeSamples1.push({x: xVal, y:dataview[0]}); ...............

krzychb commented 8 years ago

Hi @williamesp2015,

Thank you for update on developments with binary transfer and code snippets!

To skip copying data from samples to u8Data, did you consider something like:

webSocket.sendBIN(socketNumber, samples, NN/2);

I am currently busy with another project but return to this one soon :smile:

williamesp2015 commented 8 years ago

Hi @krzychb , Thank you for your comment. I couldn't do that because the function accept only unsigned byte. bool sendBIN(uint8_t num, const uint8_t * payload, size_t length);

krzychb commented 8 years ago

@williamesp2015,

You are right. I did not consider the data type. In such case I would cast uint16_t * data type to uint8_t * :

webSocket.sendBIN(socketNumber, (uint8_t *) samples, NN);

Krzysztof

williamesp2015 commented 8 years ago

Hi Krzysztof. I want to remove Adjustable sampling threshold and sampling rate and anything that slowing visualizing highest speed EspScopeA0. Please advice. Thank you

krzychb commented 8 years ago

Hi @williamesp2015,

This looks like version Bravo that is already on my To Do list :smile:

Have you been thinking about setting a fixed number of samples and threshold or rather introducing a separate command to set them up?