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

Merging develop into main #87

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -62,6 +62,17 @@ public void setColor(int redVal, int greenVal, int blueVal, int frequency1, int
rgbledHelper.setColor(colors, frequency);
}

@Get("/setColorHex/{hexValue}")
public void setColorHex(String hexValue) {
rgbledHelper.setColorHex(hexValue);
}

@Get("/setColorHex/{hexValue},{frequency1},{frequency2},{frequency3}")
public void setColorHex(String hexValue, int frequency1, int frequency2, int frequency3) {
int[] frequency = new int[] {frequency1, frequency2, frequency3};
rgbledHelper.setColorHex(hexValue, frequency);
}

@Get("/ledOff")
public void ledOff() {
rgbledHelper.ledOff();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,63 @@
==== RGB LED
== RGB LED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will having two == instead of four ==== make documentation not build?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build is successful. I made it two == because the heading looks small.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting it to == will make the table of contents incorrect. It will not have rgb led under the output components.
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @SwindleA. @ruthvikm since this already got merged, can you fix the problem asap (small fix here)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll change it to 4

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

===== Overview
This document provides details of the RGB (Red-Green-Blue) LED circuit,
including its components, assembly instructions, and functionality.

===== Components
. RGB LED
. 3 x 220Ω resistors (for current limiting)
. Breadboard
. Jumper wires
. Power source (appropriate voltage, typically 3.3V or 5V)

===== Assembly Instructions
. Place the RGB LED on the Breadboard. The LED has four pins - one for each of the
colors (Red, Green, and Blue) and one common pin (either cathode or anode).
. Connect the Resistors. Attach a 220Ω resistor to each of the RGB pins of the LED.
This is to limit the current and protect the LED.
. Power Connections:
** If using a common cathode RGB LED, connect the common pin directly to the
ground (GND) and the other ends of the resistors to the respective positive
terminals (like GPIO pins of a microcontroller or direct power source).
** If using a common anode RGB LED, connect the common pin directly to the
positive voltage source (VCC) and the other ends of the resistors to the respective
negative terminals (like GPIO pins set to OUTPUT and LOW on a microcontroller).

===== Circuit Diagram
Model:

image::https://docs.sunfounder.com/projects/raphael-kit/en/latest/_images/image61.png[]

Circuit Diagram:

image::https://docs.sunfounder.com/projects/raphael-kit/en/latest/_images/rgb_led_schematic.png[]

===== Functionality
The RGB LED can produce a wide range of colors by mixing different intensities of
Red, Green, and Blue. By adjusting the power to each pin, various colors can be
produced. For instance:

* Red: Power the Red pin while keeping Green and Blue off.
* Green: Power the Green pin while keeping Red and Blue off.
* Blue: Power the Blue pin while keeping Red and Green off.
* Yellow: Power both Red and Green pins while keeping Blue off.
* Cyan: Power both Green and Blue pins while keeping Red off.
* Magenta: Power both Red and Blue pins while keeping Green off.
* White: Power all three pins

===== Troubleshooting
. LED not lighting up: Check all connections, ensure the LED is placed correctly,
and check the power source.
. Only one color is working: One of the pins might have a loose connection. Verify
each color pin's connection.
. LED is too dim: The resistor value might be too high. Ensure you're using 220Ω or
adjust according to your power source and LED specifications

===== Note: The Hex value format must start with "0x" not "#" while passing it as a parameter of "setColorHex()" method. For example, use "0x0000ff" for blue.

===== YAML Pin Order
The order for declaring pins for a RGB LED component in the application.yaml file is as follows

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public RGBLEDHelper(MultipinConfiguration pwm)
public void setColor(int[] colors)
//end::method[]
{
red.on(colors[0], 50);
green.on(colors[1], 50);
blue.on(colors[2], 50);
red.on(colors[0], 200);
green.on(colors[1], 200);
blue.on(colors[2], 200);
}

//tag::method[]
Expand All @@ -45,22 +45,42 @@ public void setColor(int[] colors, int[] frequency)
blue.on(colors[2], frequency[2]);
}

public void setColorHex(String hex) {
//tag::method[]
public void setColorHex(String hex)
//end::method[]
{
log.trace("setting the color via hex");
//input the hex splitting and frequency stuff
// hex splitting into rbg int values
int r = (Integer.decode(hex) & 0xFF0000) >> 16;
int g = (Integer.decode(hex) & 0xFF00) >> 8;
int b = (Integer.decode(hex) & 0xFF);

// no frequency input, default value 200
red.on(r, 200);
green.on(g, 200);
blue.on(b, 200);
}

public void setColorHex(String hex, int frequency) {
//tag::method[]
public void setColorHex(String hex, int[] frequency)
//end::method[]
{
log.trace("setting the color and frequency via hex and int");
// input the hex splitting and frequency stuff
// hex splitting into rbg int values
int r = (Integer.decode(hex) & 0xFF0000) >> 16;
int g = (Integer.decode(hex) & 0xFF00) >> 8;
int b = (Integer.decode(hex) & 0xFF);

red.on(r, frequency[0]);
green.on(g, frequency[1]);
blue.on(b, frequency[2]);
}

//tag::method[]
public void setRed(int red)
//end::method[]
{
log.trace("Set red");
this.red.on(red, 50);
this.red.on(red, 200);
}

//tag::method[]
Expand All @@ -76,7 +96,7 @@ public void setBlue(int blue)
//end::method[]
{
log.trace("set blue");
this.blue.on(blue, 50);
this.blue.on(blue, 200);
}

//tag::method[]
Expand All @@ -92,7 +112,7 @@ public void setGreen(int green)
//end::method[]
{
log.trace("set green");
this.green.on(green, 50);
this.green.on(green, 200);
}

//tag::method[]
Expand All @@ -117,8 +137,8 @@ public void ledOn()
//end::method[]
{
log.trace("turning on each LED pin and setting to 100");
this.red.on(100, 50);
this.green.on(100, 50);
this.blue.on(100, 50);
this.red.on(100, 200);
this.green.on(100, 200);
this.blue.on(100, 200);
}
}