B4R Question Problem with size of array

daveinhull

Active Member
Licensed User
Longtime User
Hi,

Hope someone can help.
I've got my ESP32 with GC9A01 now working and can acess the display with some basic uniform graphics, e.g. fill screen, checker pattern basic, shapes created in simple loops.
I'm now trying to load images. The GC9A01 uses 12, 16 or 18bit graphics whcih means using (at least for the start) a tool to take a 24bit image and create a n 18bit image, which I've done. The tool produces a C array as follows which I've embeded as inline code along with some additonal code:
B4X:
#if C
const unsigned char gImage_MickyMouse[117128] = { 0X00,0X20,0XF0,0X00,0X7A,0X00,0X00,0XE4,
0XFF,0XFF,0XFF,0X00,0XFF,0XFF,0XFF,0X00,0XFF,0XFF,0XFF,0X00,0XFF,0XFF,0XFF,0X00,
......etc
......etc
};
void Load_Image(B4R::Object* o) 
{
    b4r_image::_myimage->data = gImage_MickyMouse;
    b4r_image::_myimage->length = sizeof(gImage_MickyMouse);
    b4r_image::_mysize = sizeof(gImage_MickyMouse);
}
#End If
and I call a small B4R routine to load this into a B4R array which I can then use to write to the display
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public myImage() As Byte
    Public mySize As UInt
End Sub

Public Sub Load_Image
    RunNative ("Load_Image", Null)
End Sub
I have two problems:
1. With 'const unsigned char...' it fails to compile with error "error: invalid conversion from 'const void*' to 'void*' [-fpermissive]", but it at least compiles without the 'const'
2. The size of the B4R array is only 51592 (both from mySize and SizeOf(myImage) when the C array is 117128

I know its me, but if anyone could advise that would be great.

Thanks
Dave
 

daveinhull

Active Member
Licensed User
Longtime User
Can anyone help me with this please.

I'm still going round in circles a bit with the GC9A01 device.
a) I’ve got it fully working in Arduino C code using the Adafruit GFX and the Adafruit_GC9A01 libraries
b) I've got it working using B4R and inline C code using the Adafruit GFX and the Adafruit_GC9A01 libraries
c) I'm struggling getting a wrapper for the Adafruit_GC9A01 library - almost there but it appears to need the latest version of the Adafruit GFX library so trying to imitate the Adafruit_ILI9341 wrapper doesn't work

However, the Adafruit GFX library is very slow on drawing bitmap (in Arduino) - it takes around 4 sec to draw a 240x240 and further read that it write bit by bit taking around 187ms where it can be possible to do the same around 10ms. The GC9A01 can accept just a stream of bytes (this is how fill screen works) and that would be much quicker.

I've written my own B4R routines to access the device, but I need to get a byte array of the image into memory to do this, hence my OP.

I think my final aim will be to just stay in B4R and write a set of routines to do most tasks, but would really need some more help.

Just for reference this is how I'm tryin gto use the data to do a write to the device.
B4X:
    Image.Load_Image
    GC9A01_set_data_command(False)
    GC9A01_set_chip_select(False)
    GC9A01_spi_tx (Array As Byte(0x2C))
    GC9A01_set_data_command(True)
    Log ("My image size is ",SizeOf(Image.myImage))
    GC9A01_spi_tx (Image.myImage)
    Delay(5000)
Thanks in advance
Dave
 
Upvote 0
Top