Skip to content

Commit 88e7a67

Browse files
committed
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.
1 parent 5f1b66b commit 88e7a67

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

firmware/Serial 7-Segment Display/Serial_7_Segment_Display_Firmware/Serial_7_Segment_Display_Firmware.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
brightness, UART baud rate, i2c address or factory reset.
1616
1717
Note: To use the additional pins, PB6 and PB7, on the ATmega328 we have to add
18-
some maps to the pins_arduino.h file. This allows Arduino to identify PB6 and
18+
some maps to the pins_arduino.h file. This allows Arduino to identify PB6 as
1919
digital pin 22, and PB7 as digital pin 23. Because the Serial 7-Segment runs on
2020
the ATmega328's internal oscillator, these two pins open up for our use.
2121
@@ -35,7 +35,7 @@ SevSeg myDisplay; //Create an instance of the object
3535
//OpenSegment uses PNP and NPN transistors to drive larger displays
3636
#define S7S 1
3737
#define OPENSEGMENT 2
38-
#define DISPLAY_TYPE S7S
38+
#define DISPLAY_TYPE OPENSEGMENT
3939

4040
//Global variables
4141
unsigned int analogValue6 = 0; //These are used in analog meter mode

firmware/Serial 7-Segment Display/Serial_7_Segment_Display_Firmware/System_Functions.ino

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,31 @@ void setupMode()
250250
deviceMode = MODE_DEFAULT;
251251
EEPROM.write(MODE_ADDRESS, MODE_DEFAULT);
252252
}
253+
254+
#if DISPLAY_TYPE == OPENSEGMENT
255+
//See if any solder jumpers have been closed
256+
257+
//Arduino doesn't really support PB6 and PB7 and GPIOs (normally the 16MHz
258+
//crystal is there) so let's do it the old school way
259+
//digitalWrite(JUMPER_COUNTER, HIGH); //Enable internal pullup
260+
//pinMode(JUMPER_METER, INPUT_PULLUP);
261+
262+
DDRB &= 0b00111111; //Set PB7 and PB6 to inputs
263+
PORTB |= 0b11000000; //Enable external pull ups
264+
265+
Serial.println("Jumper check:");
266+
if( (PINB & 1<<6) == 0) //If counter pin is low
267+
{
268+
deviceMode = MODE_COUNTER;
269+
Serial.println("PB6 jumper closed");
270+
}
271+
else if( (PINB & 1<<7) == 0) //digitalRead(JUMPER_METER) == LOW)
272+
{
273+
deviceMode = MODE_ANALOG;
274+
Serial.println("PB7 jumper closed");
275+
}
276+
#endif
277+
253278
}
254279

255280
//This sets up the two analog inputs

0 commit comments

Comments
 (0)