Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 Digit 7 Segment Display #275

Merged
merged 37 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a683e84
Added 4-digit 7-segment display YAML config, basic controller, and he…
leandrumartin Oct 27, 2024
b563b5d
Added endpoint to display a number, and functionality for it using te…
leandrumartin Oct 28, 2024
1cfff19
Modified according to Seyun's in-progress seven-segment display helper
leandrumartin Oct 28, 2024
9c2f302
Updated pins. Also the 4-digit display now renders numbers to have le…
leandrumartin Oct 28, 2024
8a419ce
Merge remote-tracking branch 'refs/remotes/origin/main' into Pi4Micro…
leandrumartin Oct 28, 2024
ea01936
Added getValue(), edited 7-segment display helper function calls to c…
leandrumartin Oct 31, 2024
230c3ce
Added more tests, fixed log initialization typos
leandrumartin Oct 31, 2024
673910b
4-digit 7-segment display no longer reliant on code for 7-segment dis…
leandrumartin Nov 3, 2024
8a795a1
Added digital output multi-pin configuration, since the 4-digit 7-seg…
leandrumartin Nov 3, 2024
70b7f75
multi pin factory can generate multi digital output config
leandrumartin Nov 3, 2024
2fa3844
updates to my attempt to create a multi digital output configuration
leandrumartin Nov 3, 2024
0260263
attempt to convert to i2c
leandrumartin Nov 3, 2024
ff7f353
Commented out unused imports in 4-digit 7-segment display test class
leandrumartin Nov 4, 2024
24b0726
Attempted to copy from https://github.com/Pi4J/pi4j-example-crowpi/bl…
leandrumartin Nov 4, 2024
c53d8e0
Copied parent class methods directly into the helper class
leandrumartin Nov 4, 2024
7687084
initial
leandrumartin Nov 8, 2024
9023b62
alterations too start using custom code
leandrumartin Nov 8, 2024
a713809
changed names, fixed indentation error (which didn't actually fix any…
leandrumartin Nov 8, 2024
b2f7068
segments as separate digital outputs
leandrumartin Nov 8, 2024
7ec115c
Removed things from the now deprecated, ill-fated, late multi digital…
leandrumartin Nov 9, 2024
179c718
further deprecation for multi digital output that i missed
leandrumartin Nov 9, 2024
44efced
remove stuff from my attempt 2 do a multi digital output configur8ion
leandrumartin Nov 9, 2024
50a8d38
delete DigitalOutputMultiPinConfiguration.java
leandrumartin Nov 9, 2024
350e1c4
temp
leandrumartin Nov 9, 2024
9a0f453
ok
leandrumartin Nov 9, 2024
36af03a
Use Pi4J's seven segment component
leandrumartin Nov 10, 2024
114e6ee
Remove unused import
leandrumartin Nov 10, 2024
0e8afd7
Added test and documentation comments to the helper. Added displayVal…
leandrumartin Nov 10, 2024
df0f83c
Merge branch 'main' of https://github.com/oss-slu/Pi4Micronaut into P…
leandrumartin Nov 11, 2024
c1285c1
Added 4-digit 7-segment display documentation
leandrumartin Nov 11, 2024
18ec28e
Typo
leandrumartin Nov 11, 2024
9dd92e0
removed unnecessary SPI configuration, moved logic to FourDigitSevenS…
leandrumartin Nov 16, 2024
93bd895
Simplified decimal point, moved error handling, support more characte…
leandrumartin Nov 18, 2024
973de47
Add setLog and getDisplayValue, add value validation, add doc comment…
leandrumartin Nov 18, 2024
d772607
Merge branch '4digit7segment-spi' into Pi4Micronaut-44
leandrumartin Nov 18, 2024
a68bb7a
unnecessary application.yml config, fixed test, undid accidental chan…
leandrumartin Nov 18, 2024
66dec5b
Merge branch 'main' into Pi4Micronaut-44
yrlmanoharreddy Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.opensourcewithslu.components.controllers;

import com.opensourcewithslu.outputdevices.FourDigitSevenSegmentDisplayHelper;
import com.pi4j.io.gpio.digital.DigitalOutput;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import jakarta.inject.Named;

//tag::ex[]
@Controller("/four-digit-seven-segment")
public class FourDigitSevenSegmentDisplayController {
private final FourDigitSevenSegmentDisplayHelper displayHelper;

public FourDigitSevenSegmentDisplayController(@Named("sdi") DigitalOutput sdi,
@Named("rclk") DigitalOutput rclk,
@Named("srclk") DigitalOutput srclk,
@Named("digit-0") DigitalOutput digit0,
@Named("digit-1") DigitalOutput digit1,
@Named("digit-2") DigitalOutput digit2,
@Named("digit-3") DigitalOutput digit3) {
this.displayHelper = new FourDigitSevenSegmentDisplayHelper(sdi, rclk, srclk, digit0, digit1, digit2, digit3);
}

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

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

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

@Get("/clear")
public void clearDisplay() {
displayHelper.clear();
}
}
//end::ex[]
44 changes: 43 additions & 1 deletion components/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pi4j:
shutdown: 0
servo-motor:
name: Servo Motor
address: 17
address: 18
pwmType: SOFTWARE
provider: pigpio-pwm
initial: 0
Expand Down Expand Up @@ -166,6 +166,48 @@ pi4j:
shutdown: LOW
initial: LOW
provider: pigpio-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
# end::digitalOutput[]

# tag::multiInput[]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
:imagesdir: img/

ifndef::rootpath[]
:rootpath: ../../
endif::rootpath[]

ifdef::rootpath[]
:imagesdir: {rootpath}{imagesdir}
endif::rootpath[]

==== 4-Digit 7-Segment Display

[.text-right]
https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/fourDigitSevenSegment.adoc[Improve this doc]

===== Overview

This section provides details of the 4-digit 7-segment display, including its components and assembly instructions.

===== Components

* 1 x Raspberry Pi
* 1 x Breadboard
* 1 x T-Extension Board
* 25 x Jumper Wire
* 4 x Resistor (220Ω)
* 1 x 4-Digit 7-Segment Display
* 1 x 74HC595
* Power source (appropriate voltage, typically 3.3V)

===== Assembly Instructions

* Connect the ground (GND) pins of the Raspberry Pi to the ground rails on the breadboard.
* Connect the two ground rails of the breadboard with a jumper wire.
* Place the 74HC595 on the breadboard.
* 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:

- 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)

// TODO: Describe connections to 74HC595

===== Circuit Diagram

image::four_digit_circuit.webp[]

===== Schematic Diagram

image::four_digit_schematic.webp[]

===== Functionality

The display can be enabled/disabled, display a custom value, or cleared.

Each digit of the display can display a digit 0 to 9, an uppercase letter A to F, a hypen (-), or a blank space.
Each of the four decimal points can also be turned on or off.

Example possible values include:

* "1" (displayed with the 1 in the first digit and the others blank)
* "8.8.8.8." (displayed with all segments enabled as `8.8.8.8.`)
* "A.-.42" (displayed as ```A.-.42```)

===== Testing

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

[source,bash]
----
$ curl http://localhost:8080/four-digit-seven-segment/enable
$ curl http://localhost:8080/four-digit-seven-segment/displayValue/1234
----

* `/enable` - Enables the display.
* `/disable` - Disables the display.
* `/displayValue/{value}` - Displays a custom value on the display.
* `/clear` - Clears the display.

===== Troubleshooting

* Display does not turn on
- Ensure all connections are secure and correct.
- Check the 74HC595 for proper orientation and placement.
- Ensure the software configuration matches the hardware setup.
- Look for any error messages in the console or logs.

* Display turns on but does not respond to commands
- Check the software configuration for any discrepancies.
- Ensure the 74HC595 is functioning properly.

===== YAML Configuration

[source,yaml]
----
i2c:
four-digit-seven-segment:
name: 4 Digit 7 Segment Display
bus: 1
device: 0x27
----

===== Constructor and Methods

To see the constructor and methods of our FourDigitSevenSegmentHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/outputdevices/FourDigitSevenSegmentHelper.html[here]
for more details.

===== An Example Controller

[source,java]
----
include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/FourDigitSevenSegmentDisplayController.java[tag=ex]
----
Binary file not shown.
Binary file not shown.
Loading
Loading