Skip to content

Commit

Permalink
Merge pull request #289 from oss-slu/Pi4Micronaut-44
Browse files Browse the repository at this point in the history
4 Digit 7 Segment Display
  • Loading branch information
yrlmanoharreddy authored Nov 18, 2024
2 parents d5985ac + 64133cf commit 4b39fb3
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,24 @@ public void disable() {
displayHelper.disable();
}

@Get("/displayValue/{value}")
public void displayValue(String value) {
displayHelper.displayValue(value);
@Get("/print/{value}")
public void print(String value) {
displayHelper.print(value);
}

@Get("/clear")
public void clearDisplay() {
public void clear() {
displayHelper.clear();
}

@Get("set-digit/{digit}/{value}")
public void setDigit(int digit, char value) {
displayHelper.setDigit(digit, value);
}

@Get("set-decimal-point/{digit}/{value}")
public void setDecimalPoint(int digit, boolean value) {
displayHelper.setDecimalPoint(digit, value);
}
}
//end::ex[]
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,31 @@ This section provides details of the 4-digit 7-segment display, including its co
* Place the four resistors on the breadboard.
* Place the 4-digit 7-segment display on the breadboard.
* Connect a jumper wire from each "digit" pin of the 4-digit 7-segment to one of the resistors.
* Connect the other end of the resistors to the Raspberry Pi's pins:
* Connect the other ends of the resistors to the Raspberry Pi's pins:

- Digit 1 to GPIO17 (BCM pin 18)
- Digit 2 to GPIO27 (BCM pin 27)
- Digit 3 to GPIO22 (BCM pin 22)
- Digit 4 to SPIMOSI (BCM pin 10)
- Digit 1 (pin 12) to GPIO17 (BCM pin 18)
- Digit 2 (pin 9) to GPIO27 (BCM pin 27)
- Digit 3 (pin 8) to GPIO22 (BCM pin 22)
- Digit 4 (pin 6) to SPIMOSI (BCM pin 10)

// TODO: Describe connections to 74HC595
* Use jumper wires to connect pins on the display to pins on the 74HC595:

- A (pin 11) to Q0 (pin 15)
- B (pin 7) to Q1 (pin 1)
- C (pin 4) to Q2 (pin 2)
- D (pin 2) to Q3 (pin 3)
- E (pin 1) to Q4 (pin 4)
- F (pin 10) to Q5 (pin 5)
- G (pin 5) to Q6 (pin 6)
- DP (pin 3) to Q7 (pin 7)

* Use jumper wires to connect the 74HC595 to the Raspberry Pi:

- SHcp (pin 11) to GPIO18 (BCM pin 18)
- STcp (pin 12) to GPIO23 (BCM pin 23)
- DS (pin 14) to GPIO24 (BCM pin 24)

* Use jumper wires to connect the remaining pins of the 74HC595 to the ground rails of breadboard.

===== Circuit Diagram

Expand All @@ -69,18 +86,26 @@ Example possible values include:
===== Testing

Use the below commands to test the component.
This will cause the display to turn on and display the value `1234`.
The first two commands will cause the display to turn on and display the value `1234`.

The third command will cause the display to then show `1.234`.

The fourth command will cause the display to show `1 34`, using standard URL encoding for the space (`%20`).

[source,bash]
----
$ curl http://localhost:8080/four-digit-seven-segment/enable
$ curl http://localhost:8080/four-digit-seven-segment/displayValue/1234
$ curl http://localhost:8080/four-digit-seven-segment/set-decimal-point/0/true
$ curl http://localhost:8080/four-digit-seven-segment/displayValue/1%2034
----

* `/enable` - Enables the display.
* `/disable` - Disables the display.
* `/displayValue/{value}` - Displays a custom value on the display.
* `/print/{value}` - Displays a custom value on the display.
* `/clear` - Clears the display.
* `/set-digit/{digit}/{value}` - Sets a specific digit to a specific value.
* `/set-decimal-point/{digit}/{value}` - Sets a specific decimal point to on (true) or off (false).

===== Troubleshooting

Expand All @@ -98,11 +123,49 @@ $ curl http://localhost:8080/four-digit-seven-segment/displayValue/1234

[source,yaml]
----
i2c:
four-digit-seven-segment:
name: 4 Digit 7 Segment Display
bus: 1
device: 0x27
digital-output:
digit-0:
name: Digit 0
address: 17
shutdown: LOW
initial: LOW
provider: pigpio-digital-output
digit-1:
name: Digit 1
address: 27
shutdown: LOW
initial: LOW
provider: pigpio-digital-output
digit-2:
name: Digit 2
address: 22
shutdown: LOW
initial: LOW
provider: pigpio-digital-output
digit-3:
name: Digit 3
address: 10
shutdown: LOW
initial: LOW
provider: pigpio-digital-output
sdi:
name: SDI
address: 24
shutdown: LOW
initial: LOW
provider: pigpio-digital-output
rclk:
name: RCLK
address: 23
shutdown: LOW
initial: LOW
provider: pigpio-digital-output
srclk:
name: SRCLK
address: 18
shutdown: LOW
initial: LOW
provider: pigpio-digital-output
----

===== Constructor and Methods
Expand Down
Loading

0 comments on commit 4b39fb3

Please sign in to comment.