Permalink
Browse files

Added checks on PB6/PB7 on OpenSegment hardware.

Checks to see if jumpers are closed on PB6/PB7 and sets mode to counter
or analog meter appropriately.
  • Loading branch information...
1 parent 5f1b66b commit 88e7a67a44b97dcafdfa0adbfe5d00ac6bf9ed44 @nseidle nseidle committed Mar 18, 2013
@@ -15,7 +15,7 @@
brightness, UART baud rate, i2c address or factory reset.
Note: To use the additional pins, PB6 and PB7, on the ATmega328 we have to add
- some maps to the pins_arduino.h file. This allows Arduino to identify PB6 and
+ some maps to the pins_arduino.h file. This allows Arduino to identify PB6 as
digital pin 22, and PB7 as digital pin 23. Because the Serial 7-Segment runs on
the ATmega328's internal oscillator, these two pins open up for our use.
@@ -35,7 +35,7 @@ SevSeg myDisplay; //Create an instance of the object
//OpenSegment uses PNP and NPN transistors to drive larger displays
#define S7S 1
#define OPENSEGMENT 2
-#define DISPLAY_TYPE S7S
+#define DISPLAY_TYPE OPENSEGMENT
//Global variables
unsigned int analogValue6 = 0; //These are used in analog meter mode
@@ -250,6 +250,31 @@ void setupMode()
deviceMode = MODE_DEFAULT;
EEPROM.write(MODE_ADDRESS, MODE_DEFAULT);
}
+
+#if DISPLAY_TYPE == OPENSEGMENT
+ //See if any solder jumpers have been closed
+
+ //Arduino doesn't really support PB6 and PB7 and GPIOs (normally the 16MHz
+ //crystal is there) so let's do it the old school way
+ //digitalWrite(JUMPER_COUNTER, HIGH); //Enable internal pullup
+ //pinMode(JUMPER_METER, INPUT_PULLUP);
+
+ DDRB &= 0b00111111; //Set PB7 and PB6 to inputs
+ PORTB |= 0b11000000; //Enable external pull ups
+
+ Serial.println("Jumper check:");
+ if( (PINB & 1<<6) == 0) //If counter pin is low
+ {
+ deviceMode = MODE_COUNTER;
+ Serial.println("PB6 jumper closed");
+ }
+ else if( (PINB & 1<<7) == 0) //digitalRead(JUMPER_METER) == LOW)
+ {
+ deviceMode = MODE_ANALOG;
+ Serial.println("PB7 jumper closed");
+ }
+#endif
+
}
//This sets up the two analog inputs

0 comments on commit 88e7a67

Please sign in to comment.