Using Bitmaps and scroll them for single color matrix

This an adaption of the original function by by Bill Westfield (“WestfW”)

ht1632_putbigbitmap
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_putbigbitmap(x location, y location , bitmapname , number of columns, number of rows, 'G' for Gimp or 'T' for The Dot Factory bitmap arrays).
*/
void ht1632_putbigbitmap(int x, int y, 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; //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;
}

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]);
}

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

}
}
}

This function could be called in the loop function with:
// Draws the Bitmap at 0,0
// ht1632_putbigbitmap(x location, y location , bitmapname , number of columns, number of rows, 'G' for Gimp or 'T' for The Dot Factory bitmap arrays).
ht1632_putbigbitmap(0,0 , lady_bits , 23,65, '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,bitmapnae , number of columns, number of rows, 'G' for Gimp or 'T' for The Dot Factory bitmap arrays, delaytime in milliseconds).
*/
void scrollbitmapx(int y, unsigned char * bitmapname,int columncountbitmap, byte rowcountbitmap,char oddeven,int delaytime) {

int xa = 0;
while (xa (-1 * ( columncountbitmap))) {
for (int i = 0; i < 1; i++) {
ht1632_putbigbitmap(xpos + (columncountbitmap *i), y, bitmapname , columncountbitmap,rowcountbitmap, oddeven);
}
delay(delaytime);// reduce speed of scroll
xpos--;
}
xa =1;
}
}

This function could be called in the loop function with:
// 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).
scrollbitmapx (0,lady_bits , 23,65, 'T', 30);

Scrolling a bitmap from bottom to up

/*
* scrollbitmapy()
* Scrolls a bitmap from bottom to up
* Original function by Bill Ho
* scrollbitmapy (y location,bitmapnae , number of columns, number of rows, 'G' for Gimp or 'T' for The Dot Factory bitmap arrays, delaytime in milliseconds).
*/
void scrollbitmapy(int x,unsigned char * bitmapname ,int columncountbitmap, byte rowcountbitmap,char oddeven, int delaytime) {
int ya = 0;
while (ya (-1 * ( rowcountbitmap))) {
for (int i = 0; i < 1; i++) {
ht1632_putbigbitmap(x, ypos + ( rowcountbitmap *i), bitmapname , columncountbitmap,rowcountbitmap, oddeven);
}
delay(delaytime);// reduce speed of scroll
ypos --;
}
ya = 1;
}
}

This function could be called in the loop function with:
//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).
scrollbitmapy (0,lady_bits ,23,65, '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