You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
762 B
34 lines
762 B
public static final char HEADER = 'H';
|
|
public static final char A_TAG = 'M';
|
|
public static final char B_TAG = 'X';
|
|
|
|
void ephSerial() {
|
|
|
|
for(int i = 0; i<colorsN; i++) {
|
|
colorByteValues[i] = byte(colorValues[i]/(cellN/100));
|
|
print(colorByteValues[i] + "\t");
|
|
}
|
|
println("");
|
|
sendMessage(A_TAG, colorByteValues);
|
|
}
|
|
|
|
|
|
void sendMessage(char tag, byte[] cbv){
|
|
// send the given index and value to the serial port
|
|
port.write(HEADER);
|
|
port.write(tag);
|
|
|
|
for(int i=0; i<cbv.length; i++) {
|
|
port.write(cbv[i]);
|
|
}
|
|
port.clear();
|
|
}
|
|
|
|
|
|
void serialEvent(Serial p) {
|
|
// handle incoming serial data
|
|
String inString = port.readStringUntil('\n');
|
|
if(inString != null) {
|
|
print( inString ); // echo text string from Arduino
|
|
}
|
|
}
|