Hey Forum,
I've been working a bit on making a relatively small timer using an ATTINY85 and only a few I/O pins. I'm using the 74HC164 shift register to shift in the segments to the displays. When I run the code via the ATMEGA328, it runs great. Segments turned on are bright on, and segments that are off are 90% off or close to. My issue comes when I'm now running the code on the ATTINY because it takes longer to shift the segments in. And as this occurs 'live' you see them shift in, but really quickly. Then I have it pause afterwards for 10ms to display the finalised digit. Then because it takes longer to shift them in, it will create a ghosting affect and it's very hard to distinguish those on and off because it probably is taking 10ms to shift them all in.
It doesn't look as bad in real life, the ghosted segments are 20-50% full brighness, but it's still not too appealing. In this photo, the number that should be displayed is 01.
Ok, my question is, how do we make this process run faster like it does on the ATMEGA?
I've looked at a few options:
-Directly controlling the pins instead of the longer instruction digitalWrite() - but I can't seem to understand how
http://www.paleotechnologist.net/?p=1808
-Purpose built libraries to execute faster - but the library would take my over my 8k of space on the ATTINY85
http://forum.arduino.cc/index.php/topic,46896.0.html
-Port manipulation of the pins, but would this work on my ATTINY85? and if so how?
Code I am running to load the segments in:
...
//<<Declaration of segments and numbers>>
bool bitmap[22][8]=
{
//{h,c,d,e,g,f,a,b}, KEY
{0,1,1,1,0,1,1,1}, //0 a
{0,1,0,0,0,0,0,1}, //1 ---
{0,0,1,1,1,0,1,1}, //2 f | | b
{0,1,1,0,1,0,1,1}, //3 -g-
{0,1,0,0,1,1,0,1}, //4 e | | c
{0,1,1,0,1,1,1,0}, //5 --- .h
{0,1,1,1,1,1,1,0}, //6 d
{0,1,0,0,0,0,1,1}, //7
{0,1,1,1,1,1,1,1}, //8
{0,1,1,0,1,1,1,1} //9
};
...
...
//<<Shifting the code to the shift 74HC164>>
void displayDigit(int digit)
{
for(int pos = 0; pos < 8; pos++)
{
digitalWrite(CLK, LOW);
if(bitmap[digit][pos] == trigger) digitalWrite(DATA, HIGH);
else digitalWrite(DATA, LOW);
digitalWrite(CLK, HIGH);
}
delay(10);
}
...




