Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
int dataPin = 2; // ic: 14, ser_in Define which pins will be used for the Shift Register control
int latchPin = 3; // ic:12 silkscreen numbers!
int clockPin = 4;
char displayPointer=0; // for interrupt use...
static uint8_t font [80] = //numbers stored here
{
0x00, 0x7c, 0xa2, 0x92, 0x8a, 0x7c, 0x00, 0x00, // 0
0x00, 0x42, 0xfe, 0x02, 0x00, 0x00, 0x00, 0x00, // 1
0x00, 0x42, 0x86, 0x8a, 0x92, 0x62, 0x00, 0x00, // 2
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 3
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 4
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 5
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 6
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 7
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 8
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 9
};
unsigned char buffer[32]; // buffer for screen
unsigned char backbuffer[32]; // Spare screen for drawing on
char power[8]={128,64,32,16,8,4,2,1};
ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
for (int i = 0; i < 8; i++)
{
PORTD = B00000000; //turn latch low
shiftOut(dataPin, clockPin, MSBFIRST, 1 << i); //Send the data #2 (what columns to power)
shiftOut(dataPin, clockPin, MSBFIRST, 1 << i); //Send the data #2 (what columns to power)
shiftOut(dataPin, clockPin, MSBFIRST, 1 << i); //Send the data #2 (what columns to power)
shiftOut(dataPin, clockPin, MSBFIRST, 1 << i); //Send the data #2 (what columns to power)
shiftOut(dataPin, clockPin, LSBFIRST, font[i + 8]); //Send the data #1 ( what data to draw)
PORTD = B00001000;
}
/*
if(displayPointer == 0 ) // 1st frame..
PORTB = buffer[displayPointer]; // Move buffer row by row( 4 row sections per row )
if(++displayPointer==32) // 32 LED row sections in total
displayPointer = 0; // Back to first row..*/
}
void pixel(signed char x,signed char y,int cond)
{
int tmp;
char pix,msk;
if(x<0 || y<0) return; // outside drawing limits negative
if(x>31 || y>7) return; // outside drawing limits positive
tmp = (y << 2) + (x>>3); // Linear position
pix = x%8; // pixel required
pix = power[pix];
msk = backbuffer[tmp]; // get exsisting data
if(cond == 2)
pix ^= msk; // XOR data to screen
if (cond == 1)
{
pix = ~pix;
pix &= msk; // AND data to screen
}
if(cond == 0)
pix |= msk; // OR data to screen
backbuffer[tmp] = pix; // apply changes
}
void charput(char ch, signed char x,signed char y)
{
signed char x1, y1;
const uint8_t* addr2; // pointer to character
char disp;
ch -= 0x20; // characters starts a 0 not 0x20
addr2 = &font[0]; // start of font array
addr2 = addr2 + ((int)ch * 8); // start place in font array
for( y1=0;y1<8;y1++) // eight rows
{
disp = *addr2;
for (x1 = 0; x1<8; x1++) // eight pixels
{
if(disp & power[x1])
pixel(x+x1,y+y1,0); // OR the pixel to the display buffer
}
addr2++;
}
}
void strput(const char* ch, signed char x,signed char y)
{
int addr;
while (*ch )
{
charput(*ch++,x,y); // write a string to the display buffer
x+=7;
}
}
void clr() //clear
{
int addr;
for(addr=0;addr<32;addr++) // Empty display buffer
backbuffer[addr]= 0;
}
void Blit() //transfers data between display buffer to screen buffer
{
int addr=0;
noInterrupts(); // disable all interrupts during setup
for(addr=0;addr < 32;addr ++)
{
buffer[addr] = backbuffer[addr]; // put all data from display buffer
} // to screen buffer
interrupts(); // enable all interrupts
}
void displaystring(void) // this routine prints through the screen buffer
{ // moving one pixel at a time
signed char x=32,y=0; // I made these signed so I could print
for(y = 0;y < 96 ;y++) // to nowhere so I could produce the scrolling effect
{
clr(); // Clear the display buffer
strput("HELLO WORLD!!",x--,0); // adjust the scrolling string
Blit(); // pass to screen buffer
delay(80); // time to view
}
}
void setup() //setup runs once
{
noInterrupts(); // disable all interrupts during setup
DDRD = DDRD | B11111100; //port registers used to set pin directions
//int sx,sy; //these two necessary? couldn't see them anywhere else than ball-thingy
//int xdir=1, ydir=1;
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 31250; // compare match register 16MHz/256/2Hz
TCCR1B |= (1 << WGM12); // CTC mode, free-running, clear on match
TCCR1B |= (1 << CS12); // 256 prescaler
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
interrupts(); // enable all interrupts
displaystring(); //prints just hello world at startup
while(1) //essentially loop()? but loop is still needed...
{
clr(); //clear buffer first
/*sx += xdir; sy += ydir; no balls needed so can be omitted
strput("]",sx,sy); // this is a ball character for bouncing routine
if(sx>27) xdir = -1; /// Wall limits
if(sy>4) ydir = -1;
if(sx<0) xdir = 1;
if(sy<0) ydir = 1;*/
delay(80); //delay, but won't effect ISR
Blit(); //swap buffers
}
} // End main
void loop() //just sitting here
{}
i think you are referring to the blit function, so what happens is you write what you want to display in the backbuffer, when you are done editing you call the blit function where it takes the info from backbuffer and passes it to buffer, then when the isr is called it displays all info in buffer. Blit is like the apply button , so the micro displays with proper timing, but giving you the extra time needed to populate your data.(Ian mentioned about it earlier about keeping leds alive?)
int dataPin = 2; // ic: 14, ser_in Define which pins will be used for the Shift Register control
int latchPin = 3; // ic:12 silkscreen numbers!
int clockPin = 4;
char displayPointer=0; // for interrupt use...
static char font [80] = //numbers stored here
{
0x00, 0x7c, 0xa2, 0x92, 0x8a, 0x7c, 0x00, 0x00, // 0
0x00, 0x42, 0xfe, 0x02, 0x00, 0x00, 0x00, 0x00, // 1
0x00, 0x42, 0x86, 0x8a, 0x92, 0x62, 0x00, 0x00, // 2
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 3
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 4
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 5
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 6
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 7
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 8
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 9
};
unsigned char buffer[32]; // buffer for screen
unsigned char backbuffer[32]; // Spare screen for drawing on
char power[8]={128,64,32,16,8,4,2,1};
ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
unsigned char columndata;
unsigned char columnnumber;
if(TIFR2) // Make sure its the timer interrupt.
{
columndata= buffer[displayPointer]; // 32 bits of column
columnnumber = displayPointer;
setcolumn(columnnumber);
setdata(columndata);
storeclock();
if(++displayPointer==32) { displayPointer = 0; } // 32 LED row sections in total
}
TIFR2 = 0; // Clear timer 2 interrupt flag
}
void setcolumn(unsigned char col){
unsigned char pos;
for (pos = 0;pos<32;pos++){
if (col == pos){digitalWrite(dataPin ,HIGH);}else {digitalWrite(dataPin ,LOW);} // replace PIN1 with DATA pin
shiftclock();
}}
void setdata(unsigned char dat){
unsigned char pos;
for (pos = 0;pos<8;pos++){
if (dat & 128){dat-=128;digitalWrite(dataPin ,HIGH);}else { digitalWrite(dataPin ,LOW);} // Replace PIN1 with DATA pin
dat = dat * 2;
shiftclock();
}}
void shiftclock(void){
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);// change PIN2 to SHIFTCLOCK pin, add delay if this is too fast for shift registers
}
void storeclock(void){
digitalWrite(latchPin ,HIGH);digitalWrite(latchPin , LOW ); // change PIN3 to STORECLOCK, add delay if this is too fast for shift registers
}
void pixel(signed char x,signed char y,int cond)
{
int tmp;
char pix,msk;
if(x<0 || y<0) return; // outside drawing limits negative
if(x>31 || y>7) return; // outside drawing limits positive
tmp = (y << 2) + (x>>3); // Linear position
pix = x%8; // pixel required
pix = power[pix];
msk = backbuffer[tmp]; // get exsisting data
if(cond == 2)
pix ^= msk; // XOR data to screen
if (cond == 1)
{
pix = ~pix;
pix &= msk; // AND data to screen
}
if(cond == 0)
pix |= msk; // OR data to screen
backbuffer[tmp] = pix; // apply changes
}
void charput(char ch, signed char x,signed char y)
{
signed char x1, y1;
const char* addr2; // pointer to character
char disp;
ch -= 0x20; // characters starts a 0 not 0x20
addr2 = &font[0]; // start of font array
addr2 = addr2 + ((int)ch * 8); // start place in font array
for( y1=0;y1<8;y1++) // eight rows
{
disp = *addr2;
for (x1 = 0; x1<8; x1++) // eight pixels
{
if(disp & power[x1])
pixel(x+x1,y+y1,0); // OR the pixel to the display buffer
}
addr2++;
}
}
void strput(const char* ch, signed char x,signed char y)
{
int addr;
while (*ch )
{
charput(*ch++,x,y); // write a string to the display buffer
x+=7;
}
}
void clr() //clear
{
int addr;
for(addr=0;addr<32;addr++) // Empty display buffer
backbuffer[addr]= 0;
}
void Blit() //transfers data between display buffer to screen buffer
{
int addr=0;
noInterrupts(); // disable all interrupts during setup
for(addr=0;addr < 32;addr ++)
{
buffer[addr] = backbuffer[addr]; // put all data from display buffer
} // to screen buffer
interrupts(); // enable all interrupts
}
void displaystring(void) // this routine prints through the screen buffer
{ // moving one pixel at a time
signed char x=32,y=0; // I made these signed so I could print
for(y = 0;y < 96 ;y++) // to nowhere so I could produce the scrolling effect
{
clr(); // Clear the display buffer
strput("HELLO WORLD!!",x--,0); // adjust the scrolling string
Blit(); // pass to screen buffer
delay(1000); // time to view
}
}
void setup() //setup runs once
{
noInterrupts(); // disable all interrupts during setup
DDRD = DDRD | B11111100; //port registers used to set pin directions
//int sx,sy; //these two necessary? couldn't see them anywhere else than ball-thingy
//int xdir=1, ydir=1;
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 31250; // compare match register 16MHz/256/2Hz
TCCR1B |= (1 << WGM12); // CTC mode, free-running, clear on match
TCCR1B |= (1 << CS12); // 256 prescaler
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
interrupts(); // enable all interrupts
displaystring(); //prints just hello world at startup
while(1) //essentially loop()? but loop is still needed...
{
clr(); //clear buffer first
/*sx += xdir; sy += ydir; no balls needed so can be omitted
strput("]",sx,sy); // this is a ball character for bouncing routine
if(sx>27) xdir = -1; /// Wall limits
if(sy>4) ydir = -1;
if(sx<0) xdir = 1;
if(sy<0) ydir = 1;*/
delay(80); //delay, but won't effect ISR
Blit(); //swap buffers
}
} // End main
void loop() //just sitting here
{}
int dataPin = 2; // ic: 14, ser_in Define which pins will be used for the Shift Register control
int latchPin = 3; // ic:12 silkscreen numbers!
int clockPin = 4;
char displayPointer=0; // for interrupt use...
static char font [80] = //numbers stored here
{
0x00, 0x7c, 0xa2, 0x92, 0x8a, 0x7c, 0x00, 0x00, // 0
0x00, 0x42, 0xfe, 0x02, 0x00, 0x00, 0x00, 0x00, // 1
0x00, 0x42, 0x86, 0x8a, 0x92, 0x62, 0x00, 0x00, // 2
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 3
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 4
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 5
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 6
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 7
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 8
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 9
};
unsigned char buffer[32]; // buffer for screen
unsigned char backbuffer[32]; // Spare screen for drawing on
char power[8]={128,64,32,16,8,4,2,1};
ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
unsigned char columndata;
unsigned char columnnumber;
if(TIFR2) // Make sure its the timer interrupt.
{
columndata= buffer[displayPointer]; // 32 bits of column
columnnumber = displayPointer;
setcolumn(columnnumber);
setdata(columndata);
storeclock();
if(++displayPointer==32) { displayPointer = 0; } // 32 LED row sections in total
}
TIFR2 = 0; // Clear timer 2 interrupt flag
}
void setcolumn(unsigned char col){
unsigned char pos;
for (pos = 0;pos<32;pos++){
if (col == pos){digitalWrite(dataPin ,HIGH);}else {digitalWrite(dataPin ,LOW);} // replace PIN1 with DATA pin
shiftclock();
}}
void setdata(unsigned char dat){
unsigned char pos;
for (pos = 0;pos<8;pos++){
if (dat & 128){dat-=128;digitalWrite(dataPin ,HIGH);}else { digitalWrite(dataPin ,LOW);} // Replace PIN1 with DATA pin
dat = dat * 2;
shiftclock();
}}
void shiftclock(void){
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);// change PIN2 to SHIFTCLOCK pin, add delay if this is too fast for shift registers
}
void storeclock(void){
digitalWrite(latchPin ,HIGH);digitalWrite(latchPin , LOW ); // change PIN3 to STORECLOCK, add delay if this is too fast for shift registers
}
void pixel(signed char x,signed char y,int cond)
{
int tmp;
char pix,msk;
if(x<0 || y<0) return; // outside drawing limits negative
if(x>31 || y>7) return; // outside drawing limits positive
tmp = (y << 2) + (x>>3); // Linear position
pix = x%8; // pixel required
pix = power[pix];
msk = backbuffer[tmp]; // get exsisting data
if(cond == 2)
pix ^= msk; // XOR data to screen
if (cond == 1)
{
pix = ~pix;
pix &= msk; // AND data to screen
}
if(cond == 0)
pix |= msk; // OR data to screen
backbuffer[tmp] = pix; // apply changes
}
void charput(char ch, signed char x,signed char y)
{
signed char x1, y1;
const char* addr2; // pointer to character
char disp;
ch -= 0x20; // characters starts a 0 not 0x20
addr2 = &font[0]; // start of font array
addr2 = addr2 + ((int)ch * 8); // start place in font array
for( y1=0;y1<8;y1++) // eight rows
{
disp = *addr2;
for (x1 = 0; x1<8; x1++) // eight pixels
{
if(disp & power[x1])
pixel(x+x1,y+y1,0); // OR the pixel to the display buffer
}
addr2++;
}
}
void strput(const char* ch, signed char x,signed char y)
{
int addr;
while (*ch )
{
charput(*ch++,x,y); // write a string to the display buffer
x+=7;
}
}
void clr() //clear
{
int addr;
for(addr=0;addr<32;addr++) // Empty display buffer
backbuffer[addr]= 0;
}
void Blit() //transfers data between display buffer to screen buffer
{
int addr=0;
noInterrupts(); // disable all interrupts during setup
for(addr=0;addr < 32;addr ++)
{
buffer[addr] = backbuffer[addr]; // put all data from display buffer
} // to screen buffer
interrupts(); // enable all interrupts
}
void displaystring(void) // this routine prints through the screen buffer
{ // moving one pixel at a time
signed char x=32,y=0; // I made these signed so I could print
for(y = 0;y < 32 ;y++) // to nowhere so I could produce the scrolling effect
{
clr(); // Clear the display buffer
backbuffer[y] = y/4 + 1;
Blit(); // pass to screen buffer
delay(500); // time to view
}
}
void setup() //setup runs once
{
noInterrupts(); // disable all interrupts during setup
DDRD = DDRD | B11111100; //port registers used to set pin directions
//int sx,sy; //these two necessary? couldn't see them anywhere else than ball-thingy
//int xdir=1, ydir=1;
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 31250; // compare match register 16MHz/256/2Hz
TCCR1B |= (1 << WGM12); // CTC mode, free-running, clear on match
TCCR1B |= (1 << CS12); // 256 prescaler
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
interrupts(); // enable all interrupts
displaystring(); //prints just hello world at startup
while(1) //essentially loop()? but loop is still needed...
{
clr(); //clear buffer first
/*sx += xdir; sy += ydir; no balls needed so can be omitted
strput("]",sx,sy); // this is a ball character for bouncing routine
if(sx>27) xdir = -1; /// Wall limits
if(sy>4) ydir = -1;
if(sx<0) xdir = 1;
if(sy<0) ydir = 1;*/
delay(80); //delay, but won't effect ISR
Blit(); //swap buffers
}
} // End main
void loop() //just sitting here
{}
Indeed, there is living on matrixlooks good, somehow
presactly!Indeed, there is living on matrix
int dataPin = 2; // ic: 14, ser_in Define which pins will be used for the Shift Register control
int latchPin = 3; // ic:12 silkscreen numbers!
int clockPin = 4;
char displayPointer=0; // for interrupt use...
static char font [80] = //numbers stored here
{
0x00, 0x7c, 0xa2, 0x92, 0x8a, 0x7c, 0x00, 0x00, // 0
0x00, 0x42, 0xfe, 0x02, 0x00, 0x00, 0x00, 0x00, // 1
0x00, 0x42, 0x86, 0x8a, 0x92, 0x62, 0x00, 0x00, // 2
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 3
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 4
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 5
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 6
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 7
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 8
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 9
};
unsigned char buffer[32]; // buffer for screen
unsigned char backbuffer[32]; // Spare screen for drawing on
char power[8]={128,64,32,16,8,4,2,1};
ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
unsigned char columndata;
unsigned char columnnumber;
if(TIFR2) // Make sure its the timer interrupt.
{
columndata= buffer[displayPointer]; // 32 bits of column
columnnumber = displayPointer;
setcolumn(columnnumber);
setdata(columndata);
storeclock();
if(--displayPointer==0) { displayPointer = 32; } // 32 LED row sections in total
}
TIFR2 = 0; // Clear timer 2 interrupt flag
}
void setcolumn(unsigned char col){
unsigned char pos;
for (pos = 0;pos<32;pos++){
if (col == pos){digitalWrite(dataPin ,HIGH);}else {digitalWrite(dataPin ,LOW);} // replace PIN1 with DATA pin
shiftclock();
}}
void setdata(unsigned char dat){
unsigned char pos;
for (pos = 0;pos<8;pos++){
if (dat & 128){dat-=128;digitalWrite(dataPin ,HIGH);}else { digitalWrite(dataPin ,LOW);} // Replace PIN1 with DATA pin
dat = dat * 2;
shiftclock();
}}
void shiftclock(void){
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);// change PIN2 to SHIFTCLOCK pin, add delay if this is too fast for shift registers
}
void storeclock(void){
digitalWrite(latchPin ,HIGH);digitalWrite(latchPin , LOW ); // change PIN3 to STORECOCK, add delay if this is too fast for shift registers
}
void pixel(signed char x,signed char y,int cond)
{
int tmp;
char pix,msk;
if(x<0 || y<0) return; // outside drawing limits negative
if(x>31 || y>7) return; // outside drawing limits positive
tmp = (y << 2) + (x>>3); // Linear position
pix = x%8; // pixel required
pix = power[pix];
msk = backbuffer[tmp]; // get exsisting data
if(cond == 2)
pix ^= msk; // XOR data to screen
if (cond == 1)
{
pix = ~pix;
pix &= msk; // AND data to screen
}
if(cond == 0)
pix |= msk; // OR data to screen
backbuffer[tmp] = pix; // apply changes
}
void charput(char ch, signed char x,signed char y)
{
signed char x1, y1;
const char* addr2; // pointer to character
char disp;
ch -= 0x20; // characters starts a 0 not 0x20
addr2 = &font[0]; // start of font array
addr2 = addr2 + ((int)ch * 8); // start place in font array
for( y1=0;y1<8;y1++) // eight rows
{
disp = *addr2;
for (x1 = 0; x1<8; x1++) // eight pixels
{
if(disp & power[x1])
pixel(x+x1,y+y1,0); // OR the pixel to the display buffer
}
addr2++;
}
}
void strput(const char* ch, signed char x,signed char y)
{
int addr;
while (*ch )
{
charput(*ch++,x,y); // write a string to the display buffer
x+=7;
}
}
void clr() //clear
{
int addr;
for(addr=0;addr<32;addr++) // Empty display buffer
backbuffer[addr]= 0;
}
void Blit() //transfers data between display buffer to screen buffer
{
int addr=0;
noInterrupts(); // disable all interrupts during setup
for(addr=0;addr < 32;addr ++)
{
buffer[addr] = backbuffer[addr]; // put all data from display buffer
} // to screen buffer
interrupts(); // enable all interrupts
}
void displaystring(void) // this routine prints through the screen buffer
{ // moving one pixel at a time
signed char x=32,y=0; // I made these signed so I could print
for(y = 0;y < 96 ;y++) // to nowhere so I could produce the scrolling effect
{
clr(); // Clear the display buffer
strput("HELLO WORLD!!",x--,0); // adjust the scrolling string
Blit(); // pass to screen buffer
delay(500); // time to view
}
}
void displaystring2(void) // this routine prints through the screen buffer
{ // moving one pixel at a time
clr(); // Clear the display buffer
pixel(1,1,0);
pixel(2,2,0);
pixel(32,8,0);
pixel(31,8,0);
Blit(); // pass to screen buffer
delay(500); // time to view
}
void displaystring3(void) // this routine prints through the screen buffer
{ // moving one pixel at a time
clr(); // Clear the display buffer
charput("H", 1,1)
charput("I", 12,12)
Blit(); // pass to screen buffer
delay(500); // time to view
}
void displaystring4(void) // this routine prints through the screen buffer
{ // moving one pixel at a time
clr(); // Clear the display buffer
strput("WOOF",0,0); // adjust the scrolling string
Blit(); // pass to screen buffer
delay(500); // time to view
}
void setup() //setup runs once
{
noInterrupts(); // disable all interrupts during setup
DDRD = DDRD | B11111100; //port registers used to set pin directions
//int sx,sy; //these two necessary? couldn't see them anywhere else than ball-thingy
//int xdir=1, ydir=1;
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 31250; // compare match register 16MHz/256/2Hz
TCCR1B |= (1 << WGM12); // CTC mode, free-running, clear on match
TCCR1B |= (1 << CS12); // 256 prescaler
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
interrupts(); // enable all interrupts
displaystring(); //prints just hello world at startup
displaystring2(); //prints just hello world at startup
displaystring3(); //prints just hello world at startup
displaystring4(); //prints just hello world at startup
while(1) //essentially loop()? but loop is still needed...
{
clr(); //clear buffer first
/*sx += xdir; sy += ydir; no balls needed so can be omitted
strput("]",sx,sy); // this is a ball character for bouncing routine
if(sx>27) xdir = -1; /// Wall limits
if(sy>4) ydir = -1;
if(sx<0) xdir = 1;
if(sy<0) ydir = 1;*/
delay(80); //delay, but won't effect ISR
Blit(); //swap buffers
}
} // End main
void loop() //just sitting here
{}