Thanks for the email on the bug in SEVEN.displayF.
Need to change two lines:
if (numInt > 1) //point must move
//
if (numInt > 10) //point must move
//
//change to:
//
if (numInt >= 1) //point must move
//
if (numInt >= 10) //point must move
To use this display in my weather station I made some changes.
In the software I used PORT instructions rather than the
digital.write functions. This saves 380 bytes.
So in the .h file we have:
#define setupD8 DDRB |=0x01; // data pin 8 is set to output
#define setupD7D6 DDRD |= 0xC0; // data pin 7 and 6 is set to output
#define latchpinLOW PORTB &= ~0x01; //set latch pin 8 to low
#define latchpinHIGH PORTB |= 0x01; //set latch pin 8 to high
#define clockpinLOW PORTD &= ~0x80; //set clock pin 7 to low
#define clockpinHIGH PORTD |= 0x80; //set clock pin 7 to high
#define datapinLOW PORTD &= ~0x40; //set data pin 6 to low
#define datapinHIGH PORTD |= 0x40; //set data pin 6 to high
//
// not as before
//
const int latchPin = 8; // digital pin to latch 8 bits to parallel register
const int clockPin = 7; // digital pin to clock data through serial reg
const int dataPin = 6; // digital pin to send data to registers
In the .cpp file we have:
setupD8; //pin 8 to output
setupD7D6; //pin 7 and 6 to output
unsigned long mask = 0x01; //mask for display digit bit
latchpinLOW; //ready to latch data
while (mask != 0) //send each bit to register 32 bits total
{
clockpinLOW; //ready to clock data
datapinHIGH; //lets assume the data is high
if ((display & mask) == 0)
datapinLOW; //wrong the data was low
mask = mask<<1; //look at next bit in digit display
clockpinHIGH; //clock the data line into the reg
}//end of send 32 bits
latchpinHIGH; //latch the 8 bits to output register
//
// not as before
//
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
unsigned long mask = 0x01; //mask for display digit bit
digitalWrite (latchPin, LOW); //ready to latch data
while (mask != 0) //send each bit to register 32 bits total
{
digitalWrite (clockPin, LOW); //ready to clock data
digitalWrite (dataPin,((display & mask) > 0 ? HIGH : LOW)); //C++ only ternary operator
mask = mask<<1; //look at next bit in digit display
digitalWrite (clockPin, HIGH); //clock the data line into the reg
}//end of send 32 bits
digitalWrite (latchPin, HIGH); //latch the 8 bits to output register
For the hardware I had to make some changes as I do not use the USB supply.
I have a battery backed 12V supply. I wanted to keep the current for the display seperate from the sensitive sensors supplies.
To do this I gave the LED supply its own regulator. It is also wired so
that if power fails and the battery supplies power the display does
not operate. It draws to much current from the battery.
The new programs and circuit diagrams are available from:
Download fourdigitLED1.zip