Using Bitmaps and scroll them for bicolor matrix

This an adaption of the original function by by Bill Westfield (“WestfW”)
Now we have colors and not like the matrix only 3 colors, black doesn’t count.
We have two colors more
1.) RANDOMCOLOR will change the color for the whole bitmap
2.) MULTICOLOR for all functions, this varies the color for each point
3.) RANDOMCOLUMNCOLOR will draw columns in random colors
Additionally we have two different colors a foreground and a background color.

Sorry, in the first draw I forget to add the “color” to ht1632_putbigbitmapcolor, for distinction it is better to rename this function.

ht1632_putbigbitmapcolor
This function can show bitmaps up to 80 lines. The only thing you need to know are the name, width and height of the bitmap

/*
* Copy a bitmap from any XBM bitmap file
* Maximum possible lines are 80 lines
* Restrictions=Amount of SRAM is the maximum drawing space
* There will be a fix for the restrictons hopefully in the future
* Slightly adopted for using bitmaps
* ht1632_putbigbitmapcolor(x location, y location , bitmapname , colorname (RANDOMCOLOR for random color), name of the second color (instead of BLACK), number of columns, number of rows, 'G' for Gimp or 'T' for The Dot Factory bitmap arrays).
*/

void ht1632_putbigbitmapcolor(int x, int y, byte color, byte secondcolor, unsigned char * bitmapname, int columncountbitmap, byte rowcountbitmap, char oddeven)
{
unsigned short dots, dots2,dots3,dots4,dots5, dots6, dots7,dots8,dots9,dots10, cc,cc2,cc3, cc4,cc5,cc6,cc7,cc8, cc9,cc10, g,t,t3,t4,t5,t6,t7,t8,t9,t10, divisor, startcolum, endcolumn;

byte maximumdrawbitmap=128, showcolor, showsecondcolor; //128 for the large fonts (=8x8 and 12x8), 64 for all smaller ones
if (x>=0){
startcolum=0;
}
else{
startcolum=-x;
}

if ((-x+X_MAX+2)>=columncountbitmap){
endcolumn=columncountbitmap;
}
else{
endcolumn=-x+X_MAX+2;
}
showcolor=color;
showsecondcolor=secondcolor;
if (showcolor==4){
showcolor=random(3)+1;
}
else
{
showcolor=showcolor;}

if (showsecondcolor==4){
showsecondcolor=random(3)+1;
}
else
{
showsecondcolor=showsecondcolor;
}

for (unsigned short col=startcolum; col<endcolumn; col++) {
//for (byte col=0; col<columncountbitmap; col++) {
// Addressing the right 8 lines because 'The Dot Factory' starts from the bottom, all others from top
if (rowcountbitmap 8 && rowcountbitmap 16 && rowcountbitmap 24 && rowcountbitmap 32 && rowcountbitmap 40 && rowcountbitmap 48 && rowcountbitmap 56 && rowcountbitmap 64 && rowcountbitmap 72 && rowcountbitmap <=80){
if (oddeven=='T'){
g=0;
t=1;
t3=2;
t4=3;
t5=4;
t6=5;
t7=6;
t8=7;
t9=8;
t10=9;
}
else {
g=9;
t=8;
t3=7;
t4=6;
t5=5;
t6=4;
t7=3;
t8=2;
t9=1;
t10=0;
}
divisor=10;
cc=col*divisor+g;
cc2=col*divisor+t;
cc3=col*divisor+t3;
cc4=col*divisor+t4;
cc5=col*divisor+t5;
cc6=col*divisor+t6;
cc7=col*divisor+t7;
cc8=col*divisor+t8;
cc9=col*divisor+t9;
cc10=col*divisor+t10;
dots = pgm_read_byte_near(&bitmapname[cc]);
dots2 = pgm_read_byte_near(&bitmapname[cc2]);
dots3 = pgm_read_byte_near(&bitmapname[cc3]);
dots4 = pgm_read_byte_near(&bitmapname[cc4]);
dots5 = pgm_read_byte_near(&bitmapname[cc5]);
dots6 = pgm_read_byte_near(&bitmapname[cc6]);
dots7 = pgm_read_byte_near(&bitmapname[cc7]);
dots8 = pgm_read_byte_near(&bitmapname[cc8]);
dots9 = pgm_read_byte_near(&bitmapname[cc9]);
dots10 = pgm_read_byte_near(&bitmapname[cc10]);
}

if (color==6){
showcolor=random(3)+1;
}
else
{
showcolor=showcolor;
}
if (secondcolor==6){
showsecondcolor=random(3)+1;
}
else
{
showsecondcolor=showsecondcolor;
}

for (byte row=0; row >row))

plot(x+col, y+row, showcolor);
else

plot(x+col, y+row, showsecondcolor);

if (divisor>=2){
if (dots2 & (maximumdrawbitmap>>row))
plot(x+col, y+rowcountbitmap/divisor+row, showcolor);
else
plot(x+col, y+rowcountbitmap/divisor+row, showsecondcolor);
}
if (divisor>=3){
if (dots3 & (maximumdrawbitmap>>row))
plot(x+col, y+2*rowcountbitmap/divisor+row, showcolor);
else
plot(x+col, y+2*rowcountbitmap/divisor+row, showsecondcolor);
}
if (divisor>=4){
if (dots4 & (maximumdrawbitmap>>row))
plot(x+col, y+3*rowcountbitmap/divisor+row, showcolor);
else
plot(x+col, y+3*rowcountbitmap/divisor+row, showsecondcolor);
}
if (divisor>=5){
if (dots5 & (maximumdrawbitmap>>row))
plot(x+col, y+4*rowcountbitmap/divisor+row, showcolor);
else
plot(x+col, y+4*rowcountbitmap/divisor+row, showsecondcolor);
}
if (divisor>=6){
if (dots6& (maximumdrawbitmap>>row))
plot(x+col, y+5*rowcountbitmap/divisor+row, showcolor);
else
plot(x+col, y+5*rowcountbitmap/divisor+row, showsecondcolor);
}
if (divisor>=7){
if (dots7& (maximumdrawbitmap>>row))
plot(x+col, y+6*rowcountbitmap/divisor+row, showcolor);
else
plot(x+col, y+6*rowcountbitmap/divisor+row, showsecondcolor);
}
if (divisor>=8){
if (dots8& (maximumdrawbitmap>>row))
plot(x+col, y+7*rowcountbitmap/divisor+row, showcolor);
else
plot(x+col, y+7*rowcountbitmap/divisor+row, showsecondcolor);
}
if (divisor>=9){
if (dots9& (maximumdrawbitmap>>row))
plot(x+col, y+8*rowcountbitmap/divisor+row, showcolor);
else
plot(x+col, y+8*rowcountbitmap/divisor+row, showsecondcolor);
}
if (divisor>=10){
if (dots10& (maximumdrawbitmap>>row))
plot(x+col, y+9*rowcountbitmap/divisor+row, showcolor);
else
plot(x+col, y+9*rowcountbitmap/divisor+row, showsecondcolor);
}

}
}
}

Call in the loop section:
//ht1632_putbigbitmapcolor(x location, y location , bitmapname , colorname (RANDOMCOLOR for random color), name of the second color (instead of BLACK), number of columns, number of rows, 'G' for Gimp or 'T' for The Dot Factory bitmap arrays).
ht1632_putbigbitmapcolor(0,0 , RED, GREEN, lady_bits, 23,72, 'T');

Scrolling the Bitmap
The original Scrolling fumction is by Bill Ho, adapted by roomtek http://code.google.com/p/sure-green-matrix/

Scroll a bitmap from left to right

/*
* scrollbitmapx()
* Scrolls a bitmap from left to right
* Original function by Bill Ho
* scrollbitmapx (x location, colorname (RANDOMCOLOR for random color), name of the second color (instead of BLACK), bitmapnae , number of columns, number of rows, 'G' for Gimp or 'T' for The Dot Factory bitmap arrays, delaytime in milliseconds).
*/

void scrollbitmapxcolor(int y, byte color, byte secondcolor,unsigned char * bitmapname,int columncountbitmap, byte rowcountbitmap,char oddeven,int delaytime) {
byte showcolor,showsecondcolor;
int xa = 0;
while (xa (-1 * ( columncountbitmap))) {
for (int i = 0; i < 1; i++) {
if (color==4){
showcolor=random(3)+1;
}
else
{
showcolor=color;}
if (secondcolor==4){
showsecondcolor=random(3)+1;
}
else
{
showsecondcolor=secondcolor;
}

ht1632_putbigbitmapcolor(xpos + (columncountbitmap *i), y, showcolor, showsecondcolor, bitmapname , columncountbitmap,rowcountbitmap, oddeven);
}
delay(delaytime);// reduce speed of scroll
xpos--;
}
xa =1;
}
}

Call in the loop section:
// Scrolls the Bitmap from left to right
// scrollbitmapx (x location,bitmapnae , number of columns, number of rows, 'G' for Gimp or 'T' for The Dot Factory bitmap arrays, delaytime in milliseconds).
scrollbitmapxcolor (0,RANDOMCOLOR, ORANGE,lady_bits, 23,72,'T', 30);

Scroll a bitmap from bottom to up
/*
* scrollbitmapy()
* Scrolls a bitmap from bottom to up
* Original function by Bill Ho
* scrollbitmapy (y location, colorname (RANDOMCOLOR for random color), name of the second color (instead of BLACK), bitmapnae , number of columns, number of rows, 'G' for Gimp or 'T' for The Dot Factory bitmap arrays, delaytime in milliseconds).
*/
void scrollbitmapycolor(int x,byte color, byte secondcolor,unsigned char * bitmapname ,int columncountbitmap, byte rowcountbitmap,char oddeven, int delaytime) {
byte showcolor,showsecondcolor;
int ya = 0;
while (ya (-1 * ( rowcountbitmap))) {
for (int i = 0; i < 1; i++) {
if (color==4){
showcolor=random(3)+1;
}
else
{
showcolor=color;}
if (secondcolor==4){
showsecondcolor=random(3)+1;
}
else
{
showsecondcolor=secondcolor;
}
ht1632_putbigbitmapcolor(x, ypos + ( rowcountbitmap *i), showcolor, showsecondcolor, bitmapname ,columncountbitmap,rowcountbitmap, oddeven);
}
delay(delaytime);// reduce speed of scroll
ypos --;
}
ya = 1;
}
}

Call in the loop section:
//Scrolls a bitmap from bottom to up
// scrollbitmapx (x location,bitmapnae , number of columns, number of rows, 'G' for Gimp or 'T' for The Dot Factory bitmap arrays, delaytime in milliseconds).
scrollbitmapycolor (0,MULTICOLOR, 0,lady_bits , 23,72,'T', 30);

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s