Hello,
I'm currently trying to write an image to RAM_G and display it on a display using BT817. I've converted the png to and EVE bitmap and then a C array using EAB, but I think I'm missing something when loading it into RAM_G.
void write_ram_g(uint32_t image_size)
{
printf("Writing to RAM_G... ");
cmd_loadimage(RAM_G, OPT_FULLSCREEN);
for (int i = 0; i < image_size; i += 4)
{
uint32_t write_data = (flash_image[i+3] >> 24) | (flash_image[i+2] >> 16) | (flash_image[i+1] >> 8) | flash_image[i];
Send_CMD(write_data);
}
UpdateFIFO();
Wait4CoProFIFOEmpty();
printf("complete\n");
}
void verify_ram(uint32_t image_size)
{
for (int i = 0; i < image_size; i++)
{
printf("%d\n", rd8(RAM_G + i));
}
}
void screen_logo()
{
printf("Writing...\n");
write_ram_g(4250);
printf("Displaying... ");
Send_CMD(CMD_DLSTART);
Send_CMD(CLEAR_COLOR_RGB(255, 255, 255));
Send_CMD(CLEAR(1, 1, 1));
cmd_setbitmap(RAM_G, ARGB1555, 252, 72);
Send_CMD(BEGIN(BITMAPS));
Send_CMD(VERTEX2II(10, 10, 0, 0));
Send_CMD(END());
Send_CMD(DISPLAY());
Send_CMD(CMD_SWAP);
UpdateFIFO();
printf("done\n");
}
I'm using write_ram_g() to cycle through the bytes in the C array and write them starting at address 0, verify_ram() to print the relevant RAM_G to TeraTerm, and screen_logo() to display the image with a white background. I can see the white background, but the printed RAM_G is the same as default and no image appears.
It's clear to me that the image isn't being loaded into RAM_G, does anyone have an in-depth example they could point me to to load a C array into RAM like this? I am new to loading anything into RAM/flash with the BT817.
Hi,
If your image is in the raw format (e.g. converted to RGB565 or RGB332 or ARGB1555 etc. from the asset builder) then you can just write to RAM_G directly like writing to a SPI memory device. You dont need to use the co-processor for this and you can stream the data direct.
To do this you would use these steps:
Chip Select Low
Write the 3-byte address in RAM_G that you want the data to be written to (with the read/write bits set for writing)
Stream the data whilst holding CS low for a SPI burst write
Chip Select High
for the address it uses the two most significant bits as 10 and so for writing to RAM_G + 0 you would use 0x80 0x00 0x00 in step 2 above
Here is a small code snippet. This assumes the data is a multiple of 4 bytes but you can add code to pad to a multiple of 4 bytes with 1, 2 or 3 extra 0x00 bytes at the end (before the CS high)
MCU_CSlow(); // CS low begins SPI transaction
EVE_AddrForWr(DestAddress); // Send address to which first value will be written
while(DataPointer < DataSize)
{
EVE_Write8(ImgData[DataPointer]); // Send data byte-by-byte from array
DataPointer ++;
}
MCU_CShigh();
Here is a 32-bit write example too,
// Writes a block of data to the RAM_G
void EVE_LIB_WriteDataToRAMG(const uint8_t *ImgData, uint32_t DataSize, uint32_t DestAddress)
{
HAL_ChipSelect(low); // Begins SPI transaction - CS low
HAL_SetWriteAddress(DestAddress); // Send address to which first value will be written
DataSize = (DataSize + 3) & (~3); // Pad data length to multiple of 4.
while (DataSize) // Send data as 32 bits.
{
HAL_Write32(*(uint32_t *)ImgData);
ImgData += 4;
DataSize -= 4;
}
HAL_ChipSelect(high); // End SPI transaction - CS high
}
Best Regards, BRT Community