(Solved)Again problem with matrix, this time 8x32

Status
Not open for further replies.
dafug? I did try initilazing that addr2 at void where it points at, but those others are mystery
errors:
C:
Arduino: 1.6.5 (Windows 7), Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"

sketch_jan15a.ino: In function 'void charput(char, unsigned char, signed char)':
sketch_jan15a:93: error: uninitialized const 'addr2' [-fpermissive]
sketch_jan15a:96: error: assignment of read-only variable 'addr2'
sketch_jan15a:96: error: invalid conversion from 'unsigned char*' to 'unsigned char' [-fpermissive]
sketch_jan15a:97: error: assignment of read-only variable 'addr2'
sketch_jan15a:100: error: invalid type argument of unary '*' (have 'unsigned char')
sketch_jan15a:106: error: increment of read-only variable 'addr2'
uninitialized const 'addr2' [-fpermissive]

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
 
Last edited:
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;

unsigned char displayPointer=0; // for interrupt use...
static unsigned char font [80] = //numbers stored here
{
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 0
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, // 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 buffer1[32]; // buffer for screen
unsigned char backbuffer[32]; // Spare screen for drawing on
unsigned char power[8]={128,64,32,16,8,4,2,1};

ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
if(TIFR2) // Make sure its the timer interrupt.
{
setcolumn(displayPointer);
setdata(buffer1[displayPointer]);
digitalWrite(latchPin ,HIGH);digitalWrite(latchPin , LOW ); // STORECLOCK
if(++displayPointer==32) { displayPointer = 0; } // 32 LED row sections in total
}
TIFR2 = 0; // Clear timer 2 interrupt flag


}

void setcolumn(unsigned char col){
signed char pos;
for (pos = 32;pos>-1;pos--){
if (col == pos){digitalWrite(dataPin ,HIGH);}else {digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}

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);} // PIN1 DATA pin
dat = dat * 2;
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}
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 ++)
{
buffer1[addr] = backbuffer[addr]; // put all data from display buffer
} // to screen buffer
interrupts(); // enable all interrupts
}

void pixel(signed char x,signed char y,int cond)
{
unsigned char pix,msk;
if(x<0 || y<0) return; // outside drawing limits negative
if(x>31 || y>7) return; // outside drawing limits positive
pix = power[y];
msk = backbuffer[x]; // 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[x] = pix; // apply changes
}

void charput(unsigned char ch, signed char x,signed char y)
{
signed char x1, y1;
const unsigned 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 setup() //setup runs once
{
noInterrupts(); // disable all interrupts during setup
DDRD = DDRD | B11111100; //port registers used to set pin directions
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
} // End main

void loop() //just sitting here
{
clr();

pixel(0,0,0);
pixel(31,7,0);

charput( 0,0,0);

charput( 8,0,1);

charput( 16,0,2);

//charput("1",0,2);



Blit();
delay(500);
}
 
Doggy, sorry for delay, had migraine and it finally relieved....hate migraines!
But, that code showed long bars lit in leftmost matrix, upload shot in a few
 
Last edited:
take the time! we are just having fun anyway!


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;

unsigned char displayPointer=0; // for interrupt use...
static unsigned char font [300] = //numbers stored here
{
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 0
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, // 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 buffer1[32]; // buffer for screen
unsigned char backbuffer[32]; // Spare screen for drawing on
unsigned char power[8]={128,64,32,16,8,4,2,1};

ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
if(TIFR2) // Make sure its the timer interrupt.
{
setcolumn(displayPointer);
setdata(buffer1[displayPointer]);
digitalWrite(latchPin ,HIGH);digitalWrite(latchPin , LOW ); // STORECLOCK
if(++displayPointer==32) { displayPointer = 0; } // 32 LED row sections in total
}
TIFR2 = 0; // Clear timer 2 interrupt flag


}

void setcolumn(unsigned char col){
signed char pos;
for (pos = 32;pos>-1;pos--){
if (col == pos){digitalWrite(dataPin ,HIGH);}else {digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}

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);} // PIN1 DATA pin
dat = dat * 2;
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}
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 ++)
{
buffer1[addr] = backbuffer[addr]; // put all data from display buffer
} // to screen buffer
interrupts(); // enable all interrupts
}

void pixel(signed char x,signed char y,int cond)
{
unsigned char pix,msk;
if(x<0 || y<0) return; // outside drawing limits negative
if(x>31 || y>7) return; // outside drawing limits positive
pix = power[y];
msk = backbuffer[x]; // 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[x] = pix; // apply changes
}


void charput(unsigned char ch, signed char x,signed char y)
{
signed char x1, y1;
unsigned char disp;
for( x1=0;x1<8;x1++) // eight rows
{
disp = font[x1+(ch * 8)];
for (y1 = 0; y1<8; y1++) // eight pixels
{
if(disp & power[y1] > 0)
{
pixel(x+x1,y+y1,0); // OR the pixel to the display buffer
}
}

}
}

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 setup() //setup runs once
{
noInterrupts(); // disable all interrupts during setup
DDRD = DDRD | B11111100; //port registers used to set pin directions
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
} // End main

void loop() //just sitting here
{
clr();

pixel(0,0,0);
pixel(31,8,0);

charput( 0,1,0);

charput( 1,11,0);




Blit();
delay(500);
}
 
tiney eh? hows that workin so far? all i have used is the atmega2560 and just recently got it, so far if this is c++ i can't tell, from c#, im happy i havn't had to use the confusing symbols from that lang so far... this conversion is common when switching compilers, btw , what is the chip you are using for this array? if this works....i am going to look at that interrupt setup next, but hard to find proper example.



unsigned char displayPointer=0; // for interrupt use...
static unsigned char font [300] = //numbers stored here
{
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 0
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, // 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 buffer1[32]; // buffer for screen
unsigned char backbuffer[32]; // Spare screen for drawing on
unsigned char power[8]={128,64,32,16,8,4,2,1};

ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
if(TIFR2) // Make sure its the timer interrupt.
{
setcolumn(displayPointer);
setdata(buffer1[displayPointer]);
digitalWrite(latchPin ,HIGH);digitalWrite(latchPin , LOW ); // STORECLOCK
if(++displayPointer==32) { displayPointer = 0; } // 32 LED row sections in total
}
TIFR2 = 0; // Clear timer 2 interrupt flag


}

void setcolumn(unsigned char col){
signed char pos;
for (pos = 32;pos>-1;pos--){
if (col == pos){digitalWrite(dataPin ,HIGH);}else {digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}

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);} // PIN1 DATA pin
dat = dat * 2;
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}
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 ++)
{
buffer1[addr] = backbuffer[addr]; // put all data from display buffer
} // to screen buffer
interrupts(); // enable all interrupts
}

void pixel(signed char x,signed char y,int cond)
{
unsigned char pix,msk;
if(x<0 || y<0) return; // outside drawing limits negative
if(x>31 || y>7) return; // outside drawing limits positive
pix = power[y];
msk = backbuffer[x]; // 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[x] = pix; // apply changes
}

void charput(unsigned char ch, signed char x,signed char y)
{
signed char x1, y1;
unsigned char disp;
unsigned char disp2;
for( x1=0;x1<8;x1++) // eight rows
{
disp = font[x1+(ch * 8)];
for (y1 = 0; y1<8; y1++) // eight pixels
{
disp2 = disp & power[y1];
if(disp2 > 0)
{
pixel(x+x1,y+y1,0); // OR the pixel to the display buffer
}
}

}
}

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 setup() //setup runs once
{
noInterrupts(); // disable all interrupts during setup
DDRD = DDRD | B11111100; //port registers used to set pin directions
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
} // End main

void loop() //just sitting here
{
clr();

pixel(0,0,0);
pixel(31,8,0);

charput( 0,1,0);

charput( 1,11,0);




Blit();
delay(500);
}
 
Last edited:
Teensy is cool, much more power and space in both flash & RAM and all considered better than UNO, coding is also done by arduino IDE when teensyduino is installed....too bad I forgot audio shield, then that would do pretty much all audio stuff, at least it has more than enough power for it. Tested 2.2" TFT and it's way faster than UNO.
What I use currently doggy is pro mini, atmega 328. Your code missed pin declarations, fixed those, screen show 01010101 drawn vertically, taking shot in a few
 
Last edited:
OK lookin good, almost there!, this time we are going to do a twist, goto Sketch, Add File, and create a new file in project library called FontMap.h, let me kno if any questions.
don t bother building yet.

In the FontMap file add this:



static unsigned char font [1000] = //numbers stored here
{ //Position, Character
0x00, 0x00, 0x7E, 0x87, 0x99, 0xE1, 0x7E, 0x00, // 0 0
0x00, 0x80, 0x01, 0xC1, 0xFF, 0x01, 0x01, 0x00, // 1 1
0x00, 0x80, 0x41, 0x83, 0x85, 0x89, 0x71, 0x00, // 2 2
0x00, 0x00, 0x82, 0x81, 0xA1, 0xD1, 0x8E, 0x00, // 3 3
0x00, 0x0C, 0x14, 0x24, 0x44, 0xFF, 0x0C, 0x00, // 4 4
0x00, 0x00, 0xE4, 0x22, 0xA2, 0xA2, 0x9C, 0x00, // 5 5
0x00, 0x00, 0x3C, 0x4A, 0x92, 0x92, 0x0C, 0x00, // 6 6
0x00, 0x00, 0x80, 0x0F, 0x90, 0xA0, 0xC0, 0x00, // 7 7
0x00, 0x00, 0x76, 0x89, 0x89, 0x89, 0x76, 0x00, // 8 8
0x00, 0x00, 0x60, 0x91, 0x91, 0x92, 0x7C, 0x00, // 9 9

0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 10
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, // 11
0x81, 0x42, 0x00, 0x18, 0x18, 0x00, 0x42, 0x01, // 12
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 13
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 14
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 15
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 16
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 17
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 18
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 19
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 20
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, // 21
0x81, 0x42, 0x00, 0x18, 0x18, 0x00, 0x42, 0x01, // 22
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 23
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 24
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 25
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 26
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 27
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 28
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 29
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 30
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, // 31


0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 32 "space"
0x00, 0x00, 0x00, 0xFB, 0xFB, 0x00, 0x00, 0x00, // 33 !
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 34
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 35
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 36
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 37
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 38
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 39


0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 40
0x00, 0x81, 0x21, 0xC1, 0xFF, 0x01, 0x01, 0x00, // 41
0x81, 0x42, 0x00, 0x18, 0x18, 0x00, 0x42, 0x01, // 42
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 43
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 44
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 45
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 46
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 47

0x00, 0x00, 0x7E, 0x87, 0x99, 0xE1, 0x7E, 0x00, // 48 0
0x00, 0x80, 0x01, 0xC1, 0xFF, 0x01, 0x01, 0x00, // 49 1
0x00, 0x80, 0x41, 0x83, 0x85, 0x89, 0x71, 0x00, // 50 2
0x00, 0x00, 0x82, 0x81, 0xA1, 0xD1, 0x8E, 0x00, // 51 3
0x00, 0x0C, 0x14, 0x24, 0x44, 0xFF, 0x0C, 0x00, // 52 4
0x00, 0x00, 0xE4, 0x22, 0xA2, 0xA2, 0x9C, 0x00, // 53 5
0x00, 0x00, 0x3C, 0x4A, 0x92, 0x92, 0x0C, 0x00, // 54 6
0x00, 0x00, 0x80, 0x0F, 0x90, 0xA0, 0xC0, 0x00, // 55 7
0x00, 0x00, 0x76, 0x89, 0x89, 0x89, 0x76, 0x00, // 56 8
0x00, 0x00, 0x60, 0x91, 0x91, 0x92, 0x7C, 0x00, // 57 9

0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 58
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 59
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 60
0x00, 0x81, 0x21, 0xC1, 0xFF, 0x01, 0x01, 0x00, // 61
0x81, 0x42, 0x00, 0x18, 0x18, 0x00, 0x42, 0x01, // 62
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 63
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 64
0x00, 0x80, 0x3F, 0x48, 0x48, 0x48, 0x3F, 0x00, // 65 A
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 66
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 67
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 68
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 69

0x00, 0x80, 0xFF, 0x08, 0x88, 0x88, 0x80, 0x00, // 70 F
0x00, 0x81, 0x21, 0xC1, 0xFF, 0x01, 0x01, 0x00, // 71
0x00, 0x80, 0xFF, 0x18, 0x08, 0x08, 0xFF, 0x00, // 72 H
0x00, 0x80, 0x81, 0x81, 0xFF, 0x81, 0x81, 0x00, // 73 I
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 74
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 75
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 76
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 77
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 78
0x00, 0x00, 0x7E, 0x81, 0x81, 0x81, 0x7E, 0x00, // 79 O

0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 80
0x00, 0x81, 0x21, 0xC1, 0xFF, 0x01, 0x01, 0x00, // 81
0x81, 0x42, 0x00, 0x18, 0x18, 0x00, 0x42, 0x01, // 82
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 83
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 84
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 85
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 86
0x00, 0x00, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x00, // 87 W
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 88
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 89

0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 90
0x00, 0x81, 0x21, 0xC1, 0xFF, 0x01, 0x01, 0x00, // 91
0x81, 0x42, 0x00, 0x18, 0x18, 0x00, 0x42, 0x01, // 92
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 93
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 94
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 95
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 96
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 97
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 98
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 99

0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 100
0x00, 0x81, 0x21, 0xC1, 0xFF, 0x01, 0x01, 0x00, // 101
0x81, 0x42, 0x00, 0x18, 0x18, 0x00, 0x42, 0x01, // 102
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 103
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 104
0x00, 0x00, 0x00, 0x91, 0xBF, 0x01, 0x00, 0x00, // 105 i
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 106
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 107
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 108
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 109


0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 110
0x00, 0x81, 0x21, 0xC1, 0xFF, 0x01, 0x01, 0x00, // 111
0x81, 0x42, 0x00, 0x18, 0x18, 0x00, 0x42, 0x01, // 112
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 113
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 114
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 115
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 116
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 117
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 118
0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 119

0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // 120
0x00, 0x81, 0x21, 0xC1, 0xFF, 0x01, 0x01, 0x00, // 121
0x81, 0x42, 0x00, 0x18, 0x18, 0x00, 0x42, 0x01, // 122
0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 123
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00 // 124



};
 
then try this one in main sketch:


#include "FontMap.h"

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;


unsigned char displayPointer=0; // for interrupt use...
unsigned char buffer1[32]; // buffer for screen
unsigned char backbuffer[32]; // Spare screen for drawing on
unsigned char power[8]={128,64,32,16,8,4,2,1};

ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
if(TIFR2) // Make sure its the timer interrupt.
{
setcolumn(displayPointer);
setdata(buffer1[displayPointer]);
digitalWrite(latchPin ,HIGH);digitalWrite(latchPin , LOW ); // STORECLOCK
if(++displayPointer==32) { displayPointer = 0; } // 32 LED row sections in total
}
TIFR2 = 0; // Clear timer 2 interrupt flag


}

void setcolumn(unsigned char col){
signed char pos;
for (pos = 32;pos>-1;pos--){
if (col == pos){digitalWrite(dataPin ,HIGH);}else {digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}

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);} // PIN1 DATA pin
dat = dat * 2;
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}
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 ++)
{
buffer1[addr] = backbuffer[addr]; // put all data from display buffer
} // to screen buffer
interrupts(); // enable all interrupts
}

void pixel(signed char x,signed char y,int cond)
{
unsigned char pix,msk;
if(x<0 || y<0) return; // outside drawing limits negative
if(x>31 || y>7) return; // outside drawing limits positive
pix = power[y];
msk = backbuffer[x]; // 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[x] = pix; // apply changes
}

void charput(unsigned char ch, signed char x,signed char y)
{
signed char x1, y1;
unsigned char disp;
unsigned char disp2;
for( x1=0;x1<8;x1++) // eight rows
{
disp = font[x1+(ch * 8)];
for (y1 = 0; y1<8; y1++) // eight pixels
{
disp2 = disp & power[y1];
if(disp2 > 0)
{
pixel(x+x1,y+y1,0); // OR the pixel to the display buffer
}
}

}
}

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 setup() //setup runs once
{
noInterrupts(); // disable all interrupts during setup
DDRD = DDRD | B11111100; //port registers used to set pin directions
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
} // End main

void loop() //just sitting here
{
clr();

pixel(0,0,0); //(x,y,cond)
pixel(31,8,0);

charput( 10,1,0); //(ch,x,y)
charput( 11,7,0);

strput("Hi", 15,0); //(const char* ch, signed char x,signed char y);


Blit();
delay(500);
}
 
Hmm, I made file called FontMap.h, in libraby folder, inside FontMap.h folder, but still gives error saying
C:
Arduino: 1.6.7 (Windows 7), TD: 1.27, Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"

C:\Users\Atte\AppData\Local\Temp\arduino_2644eeef3843ed767f171c329ce5fc54\sketch_jan21b.ino:1:21: fatal error: FontMap.h: No such file or directory

#include "FontMap.h"

  ^

compilation terminated.

exit status 1
Error compiling.
  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
 
Last edited:
Adruino Compiler.....sketch....add file.....""

if it added it will show as a tab across the top, just under the "verify, build, ect..." buttons

no need for fontmap folder, just fontmap.h file, same folder as where the sketch file is
 
Hmm, ok with that same result, I see fontmap file in tab next to main skecth, it adds it ok but gives that error
FontMap.h is at same folder as sketch not
 
is case sensitive...(>?)

alt-prtScn key will do a snap shot, or else add your project to zip file and upload.....

is working on my end.....





 
k, go to my computer, c , docs, adruino, "project folder, right click , add text file, name "FontMap.h" , ok to change file extention
 
ya, its glitch in software, it just happened to me too when i was reviewing your steps... when it created the file it deleted the old but forgot to save new...

you will notice i expanded the font table, I started to fill it out , you will see in the // that first i show position, then character ,
so to call it you use the charput(position, x,y); <-- so x,y are the start points, then position calls the array at that position, which will display the character, so for example if position=9, then display will output 9.... if position= 65 it will display the letter "A", you will also notice that if position=57, it will also display "9". i did this cause 57 is the ascii text value for number 9

It is being arranged special like this so that it match the ascii value which will help when you want to put in a string with strput()

so now you can easily send a message out like this: strput("9", x,y); which will display 9, but is calling from ascii value, ie position 57.......... or strput("hi",x,y);

or to do a number value out like this charput(9,x,y); --which will display a 9 too! (calling from position9)

also this leaves position 10-31 to display your own character fonts
also i am writing this using the font type from my lcd screen , so if you dont like how character looks, feel free to edit map.

we can hold off on this though for now, i did cheater program to help

but first one last test an then ima go after the interrupt settings,.. so we can start to see results better
 
void loop() //just sitting here
{
clr();
pixel(0,0,0);
pixel(31,7,0);
strput("WOOF",1,0);
Blit();
delay(500);
}
 
Last edited:
after that ,
there are 2 occurrences happening in your code rite now called TIFR2, change them both to TIFR0,
then change this:


void setup() //setup runs once
{
noInterrupts(); // disable all interrupts during setup
DDRD = DDRD | B11111100; //port registers used to set pin directions


// Set the Timer Mode to CTC
TCCR0A |= (1 << WGM01);

// Set the value that you want to count to
OCR0A = 0xF9;

// start the timer
TCCR0B |= (1 << CS01) | (1 << CS00);
// set prescaler to 64 and start the timer

while ( (TIFR0 & (1 << TOV0) ) > 0) // wait for the overflow event
{
}

TIFR0 &= ~(1 << TOV0);
// reset the overflow flag
interrupts(); // enable all interrupts
} // End main
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…