Skip to content

Commit

Permalink
next v?
Browse files Browse the repository at this point in the history
  • Loading branch information
John Major committed Jun 19, 2021
1 parent 551d494 commit 704fbaa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,21 @@ cd environment

* Upon commit, flake 8 and black linter checks are run, as well as the pyunit tests for each commit and pull request. The status of each can be seen in the actions tab and reflected in some of the badges.

### Some Cool Stuff.
## A Fun Thing.

* I've worked up a lowtech way to demonstrating cycling through various color spaces programatically using the terminal. If you've run setup.sh, this should run for you. Try running ``conda activate HBP; python ./bin/run_color_funthing.sh [rgb-r, rgb-g, rgb-b, hsv-h, hsv-s, hsv-v]. you get a taste for how the spaces cycle differently and what the encoding for each looks like. but really, this is meant to really be helpful in extractin the RGBW signal for use with RGBW LEDs..... something I can't demonstrate withouth hardware.
* I've worked up a lowtech way to demonstrating cycling through various color spaces programatically using the terminal. If you've run setup.sh, this should run for you. Try running ``conda activate HBP; python bin/run_color_module_RGB_HSV_HEX_demo.py. you get a taste for how the spaces cycle differently and what the encoding for each looks like. but really, this is meant to really be helpful in extractin the RGBW signal for use with RGBW LEDs..... something I can't demonstrate withouth hardware.

#### Perhaps a simple hardware how-to should be on the to-do list?
## Perhaps a simple hardware how-to should be on the to-do list?

* We used OLA + DMXkings to run LEDs via DMX for many BIG projects controlling thousands of LEDS. And this library controlling and mapping colors. I'll write that up at some point. Still figuring out the vagaries of getting into pypi.

## More Examples

### A Bit More Advanced

Not only does the package allow translation of one color space to another, but it also allows modifications of the color object in real time that re-calculates all of the other color space values at the same time. This is *EXCEEDINGLY* helpful if you wish to do things like slice through HSV space, and only change the saturation, or the hue. This is simply decrementing the H or S value incremntally, but in RGB space, is a complex juggling of changing all 3 RGB values in non intuitive ways. The same applies for transversals of HSI or HSL space to RGB. We often found ourselves writing our shows in HSV/HSL and trnanslating to RGBW for the LED hardware to display b/c the showe were more natural to design in non-RGB.

If you build the developemtn branch, there is a test script in ./bin/ called 'transversals.py', which gives you a crude terminal based idea of what I'm talking about (limited to 256 colors).
If you build the developemtn branch, there is a test script in ./bin/ called 'run_color_module_RGB_HSV_HEX_demo.py', which gives you a crude terminal based idea of what I'm talking about (limited to 256 colors).

What that might look like in code could be:

Expand Down Expand Up @@ -213,8 +214,7 @@ What that might look like in code could be:

```
source ~/.bashrc
python ./bin/run_color_test.sh
python ./bin/run_color_module_RGB_HSV_HEX_demo.py
```

Expand Down
60 changes: 29 additions & 31 deletions bin/run_color_module_RGB_HSV_HEX_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,10 @@

print_codes = "no"

try:
# Set presets if none specified (wow am I going out of the way to not use argparse)
if len(sys.argv) == 1:
os.system(
"""echo '
SETTING PRESETS 'no' 70 and ''. Type -h if you wish slightly confusing instructions.
'
"""
)
sys.argv.append("no")
sys.argv.append(80)
sys.argv.append(" ")

# First argument. -h prints help. Otherwise yes or no to print color codes
if len(sys.argv) == 2:
print_codes = sys.argv[1].lower()
if print_codes in ["-h", "help", "h", "--h", "--help", "-help"]:

if sys.argv[1] in ["-h", "help", "h", "--h", "--help", "-help"]:
os.system(
"""echo "
Expand All @@ -58,31 +44,39 @@
(3)EMPTY or '-n'. Empty means new lines will be printed after every N characters printed as set above. -n means no newlines are printed.
OH! And idf you specify 'yes' for printing the color codes- options 2 and 3 are disabled.
"
"""
"
"""
)
raise ("please set command line args")
os.system("stty echo; stty +echo ;")
raise Exception("please set command line args")

if print_codes not in ["yes", "no"]:
raise Exception("the first argumnet must be 'yes' or 'no'")
except Exception as e:
del e
if len(sys.argv) == 1:
os.system(
f"""echo "
"""echo '
Arg 1 must be 'yes' or 'no' only. No will only print colors. 'yes' will also print the various color codes
SETTING PRESETS 'no' w and ' '. Type -h if you wish slightly confusing instructions.
"
'
"""
)
sys.argv.append("no")
sys.argv.append("w")
sys.argv.append(" ")

# First argument. -h prints help. Otherwise yes or no to print color codes
print_codes = sys.argv[1].lower()


# Col width, or num characters to print
col_width = os.get_terminal_size().columns
try:
if len(sys.argv) == 2:
if len(sys.argv) < 3:
sys.argv.append(col_width)
else:
col_width = int(sys.argv[2])
elif len(sys.argv) == 4:
if sys.argv[2] == "w":
pass
else:
col_width = int(sys.argv[2])
except Exception as e:
os.system(
"""echo '''
Expand All @@ -93,11 +87,13 @@
"""
)
del e
os.system("stty echo; stty +echo ;")
raise

# Only applies to color only mode. Will not break for newlines after #cols printed. aka, the blocks append
no_newlines = " "
j = "-r 0"

try:
if len(sys.argv) == 3:
no_newlines = " "
Expand All @@ -113,6 +109,7 @@
"""
)
del e
os.system("stty echo; stty +echo ;")
raise

ri = False
Expand All @@ -131,7 +128,7 @@ def _write_color(color):
# just print colors
r = 1
if ri:
r = random.randint(2, 1270)
r = random.randint(2, 270)
l = "X" * (col_width * r)
cmd = f"""colr {j} {no_newlines} "{l}" "{color.hex}" "{color.hex}" 2>/dev/null;"""
ret_code = os.system(cmd)
Expand Down Expand Up @@ -242,6 +239,7 @@ def _write_msg(msg):

ctr = ctr + 0.005
if ret_code != 0:
os.system("stty echo; stty +echo ;")
raise

_write_msg(
Expand Down

0 comments on commit 704fbaa

Please sign in to comment.