hello ,
few days ago i did post to get some help on a CRC calculation and i did maneged to include a peace of code in my own code...
now i have some trouble with the char value ,i'm really a newbie so i'm sure that's not a bug but a real missundertanding of the programing language
'im able to control the LUT colors by changing the variable declaration in void( setup) but i don't know how to change that in void (loop) on demand:
void setup()
{
Serial.begin(57600);
mouse_one.initialize();
mouse_one.set_scaling_1_1();
pinMode(13, OUTPUT); // sets the digital pin as output
delay (8000);
char Header [3] = {
0x6E,0x00,0x00};
char Function [1] = {
0x10};
char ByteCount [2] = {
0x00,0x02}; //02
char CRC1[6] ={
Header[0],Header[1],Header[2], Function[0],ByteCount[0], ByteCount[1]};
char Data[2] ={
0x00,0x0B};
char CRC2[2] ={
Data[0],Data[1]};
switch (colors_LUT)
{
case 1://rainbow
{
char Function [1] = {
0x10};
char ByteCount [2] = {
0x00,0x02}; //02
char Data[2] ={
0x00,0x0B};
}
break;
case 2://sepia
{
char Function [1] = {
0x10};
char ByteCount [2] = {
0x00,0x02}; //02
char Data[2] ={
0x00,0x07};
}
if (transmit == 0)
{
//Serial.println("transmit");// rainbow colors sentence :6E,$00,$00,$10,$00,$02,$BC,$9A,$00,$0B,$B1,$6B
crc_out1 = calc_crc(CRC1,6); //Calculate CRC on-the-fly
crc_out2 = calc_crc(CRC2,2); //Calculate CRC on-the-fly
Serial.write( (uint8_t*)Header, sizeof(Header)); //why need -3 ??
Serial.write( (uint8_t*)Function, sizeof(Function));
Serial.write( (uint8_t*)ByteCount, sizeof(ByteCount));
//crc2 calculated manualy
//Serial.write(188);
//Serial.write(154);
Serial.write(crc_out1 >> 8); //MSB
Serial.write(crc_out1 & 0xFF); //LSB
Serial.write( (uint8_t*)Data, sizeof(Data));
//CRC2 cxalculated manualy
//Serial.write(177);
//Serial.write(107);
Serial.write(crc_out2 >> 8); //MSB
Serial.write(crc_out2 & 0xFF); //LSB
// Serial.write(10); //CR
// Serial.print(transmit);
transmit =1 ;
}
ok so i would like to be able to change the color LUT of my thermal camera with the select case but i have no idea how to change the values in my char buffer, i know this is a bad way to do that:
char Function [1] = {
0x10};
char ByteCount [2] = {
0x00,0x02}; //02
char Data[2] ={
0x00,0x0B};
but i would like to be able to change that values so i can send to serial port other values . and if it is possible to even write ,for example in Data[2] the two bytes as an integer (keeping the two byte to be send) it is even better ex: 000B = B
is there a way to do so, is there some advance documentation about variable (i'm kind of lost...)?
Moderator edit: quote tags swapped for code tags