convert 16 bit value to 8 bit send over serial and then back to 16...

How can I convert 16 bit of unsigned int to 8 bit (int8_t) value send over the serial or wire.h and then get back my 16 bit value from that 8?

So basicly compress the data? It's done by look up tables right? But for me it's kinda well I need the first kick to that direction by an example...

data example:

unsigned int Azbuka [28] ={0xC800, 0xC800, 0xC800, 0x10, 0x10, 0x10, 0xFFFF, 0x10, 0x10, 0x10, 0xFFFF, 0x10, 0x10, 0x10, 0xFFFF, 0x10, 0x10, 0x10, 0xFFFF, 0x10, 0x10, 0x10, 0xFFFF, 0x10, 0x10, 0x10, 0xFFFF, 0xFFFF, };

it's all becouse of SRAM on arduinos just 2048... But flash 32kb(pro mini) ... If it would be just a little bit more of dinamic SRAM or the way get data from SRAM to flash by PROGMEM ... That would not be a question ...

You split the int into two bytes, MSB and LSB, then you send the bytes and glue them back together at the other end.

There is no way to compress a 16 bit value to an 8 bit one. Although if you have many values there are some techniques that could compress it. There are two types of compressions, lossy and loss less. No look up tables are involved.

you could use a union and pack the two 8bit values into a 16 bit var:

union MyUnion{
  uint16_t myVar;
  uint8_t myByte[2];
};

MyUnion myUnion;


void setup()
{
  Serial.begin(9600);
  myUnion.myVar = 0xF0FF;
  Serial.println("Least Significant byte: 0x");
  Serial.println(myUnion.myByte[0], HEX);
  Serial.println(" Most Significant byte: 0x");
  Serial.println(myUnion.myByte[1], HEX);
}

void loop()
{
  
}

Or you also can do like that…

send

 for(int i = 0; i<= 28; i++)
     {      
           int S =Azbuka [count]; 
            
           byte c =  S >> 8;     
           byte  d = S;
                          
           count =  count +1;

get:

 byte c = mySerial.read(); // receive byte as a character

  unsigned int total = c;
       total <<= 8;
       c = mySerial.read();
       total |= c;

But the question is what maximum buffer you can initialize/hold of 16 bit int?
What can you do if you need work with big amoun of data?

Is there anyway you can send and store some how huge amount of data like lets say 32x32 or 32x64////… It’s acuatually not much…

So initialize buffers in flash memory? no it’s static only can’t be modified from program?

So basically if you need more then 2048 what can be used as dinamic SRAM?
Can SD card be used as quick buffer for modification of gotten data? what can be used for bigger buffers to hold and modify data?

unsigned int Azbuka [1024] ={it’s too much already};

wanna send Azbuka [1024]or [2048] over serial and hold it somewhere modify it and use fruther … What’s the options?

For displays…

Slavka85:
But the question is: Is there anyway you can send and store some how huge amount of data like lets say 32x32 or 32x64////..... It's acuatually not much..

that's the maximum arduino can or there are any ways? with using of flash or has to be SD card.... SD card you can use as dinamic memory like extra SRAM right?

No, you can't use an SD card as extra SRAM. But you can store values on an SD card and only read in the ones you need at any one time if you don't need the entire table all at once.

Slavka85:
unsigned int Azbuka [1024] ={it's too much already};

wanna send Azbuka [1024] through serial and save it... no way ah?

is there any way modify the data in flash from SRAM from program running? No?

No, you can't modify program memory while the program is running. Do you need to entire array at one time? Can you work with it in pieces? If you can use it in pieces then put it on an SD or EEPROM chip and read in the parts you need as you need them.

If you need update display with each frame of 32x32 5/6/5 value if you do update entire frame it seems easy but if you wand update part of it and going after certain pixesels that's seems a lot of work..
Yee I guess entire array at once

So just because we need to use some SRAM for our program... Basically maximum arduino pro mini uno can work with 16x32 of int_16 sended from Serial or wire.h??? can do any bigger then that? by data shrink? by SD by what else?

EEPROM is just one kilobyte too small.

but flash is 32 just unused really memory..

OK, can you explain what you are trying to do? These questions are really vague and I feel like there is another answer if you tell us what the objective is.

I want send data of 1024 or 2048 pixels of 16bit each to arduno over serial or wire.h store it and display it differently...
16 bits it's 5/6/5 rgb...

Slavka85:
I want send data of 1024 or 2048 pixels of 16bit each to arduno over serial or wire.h store it and display it differently...
16 bits it's 5/6/5 rgb...

No, tell us what you want to do not how you think it should be done. For example, I want to display an image that is in some particular format or I am trying to display video that is coming from some specific device.

I want like upload the imge to arduino... Saying that arduino is the slave and in my code i want to display it difrently like shifting left or right flash it or tir appart get them back together ... This monipulations Im planning to do on slave side not the host side that's why I need alocate some buffer.... And I guess it's got to be a SD card... Save it on Sd first and then play with it. Host will be just uploading difrent images.

I don't think so for video the Arduino will be fast enough. getting and printing

The 328P isn't really a good choice for image processing like that. You might do better to step up to a due or even a raspberry pi for that sort of thing. You really need a lot more memory and speed.

You can add extra SRAM to your Arduino. This will not be part of the memory map but it will be paged. You can store data in that and get it out again. You attach it to the SPI pins and data transfer can be very fast.

But this is nothing like the question you originally asked.

An SD card is a really bad idea. It is slow and will not be able to stand the number of writes you need to do.

Give up on image processing on a device with 2K of RAM! The Mega has 8K ram which would be
better.

If you are merely transfering data (as opposed to image processing), you don't need to store it all.