At the moment I am using a separate function to display byte arrays like these:
const PROGMEM unsigned char arab4[] = {
0x00, 0x00, 0x00, 0x00,
0xf0, 0xff, 0xff, 0x01,
0xf8, 0xff, 0xff, 0x01,
0xf8, 0xff, 0xff, 0x00,
0x04, 0xf8, 0x0f, 0x00,
0x00, 0x7c, 0x00, 0x00,
0x00, 0x0e, 0x00, 0x00,
0x80, 0x03, 0x00, 0x00,
0xc0, 0x01, 0x00, 0x00,
0x60, 0x00, 0x00, 0x00,
0x20, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00,
0x08, 0x10, 0x06, 0x00,
0x0c, 0x70, 0x0f, 0x00,
0x04, 0xf8, 0x0f, 0x00,
0x04, 0x78, 0x06, 0x00,
0x06, 0x20, 0x00, 0x00,
0x06, 0x80, 0x00, 0x00,
0x06, 0xc0, 0x01, 0x00,
0x06, 0xc0, 0x03, 0x00,
0x0e, 0xe0, 0x01, 0x00,
0x1c, 0x80, 0x01, 0x00,
0x1c, 0x00, 0x00, 0x00,
0x7c, 0x00, 0x00, 0x00,
0xf8, 0x00, 0x00, 0x00,
0xf0, 0x07, 0x00, 0x00,
0xe0, 0x7f, 0x00, 0x3c,
0xc0, 0xff, 0xff, 0x0f,
0x00, 0xff, 0xff, 0x01,
0x00, 0xf0, 0x1f, 0x00,
0x00, 0x00, 0x00, 0x00};
My function for displaying uses Adafruit libraries
#include <RGBmatrixPanel.h>
#include <Adafruit_GFX.h>
Finally my Function:
void xbm32_n (const PROGMEM unsigned char bild[32],word cchsv) {
int i = 0;
while(i<32){
for(int k=4*i;k<(4+4*i);k++)
{
for(int ii = 0; ii<8; ii++){
int bit = ((pgm_read_byte(&(bild[k]))) >> ii) & 1;
if(bit == 1) { matrix.drawPixel(ii+8*k-4*8*i, i, cchsv);}}}
i++ ;
}
}
The inner workings are as follows:
The function draws each 32 bit row with the color chosen on the Panel depending on the 4 bytes in each "row" of the hex array.
Essentially 2 loops (to draw the row in byte increments) with outer while loop (to move to next row).
The calculation of the pixel positions can be seen inside the matrix.drawPixel(x-pos,y-pos,color-value) Adafruit-function, and were made up by experimenting long hours.
See for the whole .ino File here
Notes on the file
It also features among others
(like a displaying shifting 8x8 symbol-array saved in
const PROGMEM byte IMAGES2[][8]used in the functionbildlauf(1,...)
an updated function void xbm32_4c(char bild[32],word* cchsvar[4], int duration,int cseq[4])) where:
word* cchsvar[4]points to four color data valuescseq[4]is the sequence for displaying the colors in each panel quadrant
The subdivision of the panel is realized via if() and else if() commands checking the conditions for positions:
x = (ii+8*k-4*8*i) </> some value
&& y = i </> some value
Function input:
bild[32]is used for the hex array as in my casearab4[]cchsvis a color data value . I am using sparkfun 32 LED Matrix and found the following function for hsv color space to work well:word hsvcolor(int h, int s, int b ) { //Try HSV colors http://colorizer.org/ int hue1, sat1, bright1; word result; hue1=map(h, 0, 360, 0, 1535); sat1=map(s, 0, 100, 0, 255); bright1=map(b, 0, 100, 0, 255); result = matrix.ColorHSV(hue1,sat1,bright1,true); return result; }
Current Issues to solve:
I am using Font Forge to create XBM Files in helping me create the hex letter array, but found it very clumsy to export, as the width size must be a multiple of eight to adjust height by deleting 0x00 rows.
At the moment I am searching for easier ways to "correct" the exported XBM arrays (like using 8x8 Editor 8x8 Editor, only for 32x32 Matrices). Is there a possibility for this?
Alternatively it would also help to create a function to truncate hex arrays to fit 32x32 dimensions somehow.
Additionally, in Arabic there is the issue of variant glyphs for the different letter positions (isolated, medial, initial, final). It seems possible to create byte arrays for all variants but "correcting" each bitmap so that a scrolling effect (I plan to upgrade to 64x32 LED Matrix) "adds up" visually seems daunting. I am happy for suggestion on realizing this challenge as well.
I am aware that there is a Adafruit function for bitmaps:
void Adafruit_GFX::drawBitmap()
I couldn't get it to work with my hex array, also the possibility on how to change quadrant colors or other subdivisions lead me to write my own version I modified from 8x8 Panel case. I am not sure whether there are inefficiencies in the code I have written, I therefore am happy for suggestions.