Skip to content

Implement grayscale support #4

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

Merged
merged 6 commits into from
May 22, 2022
Merged

Implement grayscale support #4

merged 6 commits into from
May 22, 2022

Conversation

HDR
Copy link
Contributor

@HDR HDR commented May 19, 2022

Adds grayscale support for displays like GDEW0154T8D, based on https://github.com/adafruit/Adafruit_CircuitPython_IL0373/blob/main/adafruit_il0373.py

image

Test image used (github doesn't allow .bmp):
Grayscale

@tekktrik
Copy link
Member

Hi @HDR! Thanks for the submission! It looks like the Github Actions CI had an issue with some of the formatting. You can use pre-commit locally to auto-format everything and then submit a commit with the changes. That will fix the CI error!

If you aren't familiar with using pre-commit, here's a tutorial that should help you get setup with it: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code

@tekktrik tekktrik requested a review from a team May 20, 2022 17:16
@HDR
Copy link
Contributor Author

HDR commented May 20, 2022

Looks like Sphinx is throwing an error now instead

Copy link
Member

@tekktrik tekktrik left a comment

Choose a reason for hiding this comment

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

Looks like this is the problem:

@HDR
Copy link
Contributor Author

HDR commented May 20, 2022

Looks like this is the problem:

Yep, already resolved it

@tekktrik tekktrik mentioned this pull request May 20, 2022
@tekktrik
Copy link
Member

2fast4me 😆

@tekktrik
Copy link
Member

Unfortunately I don't have the hardware to test, but just wanted to help with everything preceding!

@tekktrik tekktrik requested a review from a team May 20, 2022 18:14
@tekktrik tekktrik linked an issue May 20, 2022 that may be closed by this pull request
@ladyada
Copy link
Member

ladyada commented May 21, 2022

nice work @HDR and thank you @tekktrik for helping shephard
@HDR can you add an example like the one photo'd so folks can try it?

@HDR
Copy link
Contributor Author

HDR commented May 21, 2022

nice work @HDR and thank you @tekktrik for helping shephard @HDR can you add an example like the one photo'd so folks can try it?

Sure, i currently have this hooked up to Raspberry Pi Pico, example.zip contains a bmp and the example code.

import time
import board
import displayio
import busio
import adafruit_uc8151d

displayio.release_displays()

clk = board.GP10
si = board.GP11
dc = board.GP8
cs = board.GP9
rst = board.GP12
busy = board.GP13

display_bus = displayio.FourWire(
    busio.SPI(clk, si), command=dc, chip_select=cs, reset=rst, baudrate=1000000
)

time.sleep(1)

display = adafruit_uc8151d.UC8151D(
    display_bus, width=152, height=152, busy_pin=busy, rotation=180, grayscale=True
)


pic = displayio.OnDiskBitmap('Grayscale.bmp')
g = displayio.Group()
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
g.append(t)
display.show(g)
display.refresh()

Example.zip

@ladyada
Copy link
Member

ladyada commented May 21, 2022

instead of a bmp, could you rework the example to draw 4 rectangles/bitmap tiles that have a similar pattern? that way we dont have a file dependancy

@HDR
Copy link
Contributor Author

HDR commented May 21, 2022

instead of a bmp, could you rework the example to draw 4 rectangles/bitmap tiles that have a similar pattern? that way we dont have a file dependancy

Here is a quick and simple example that does not depend on a bmp :)

import time
import board
import displayio
import busio
import adafruit_uc8151d

displayio.release_displays()

clk = board.GP10
si = board.GP11
dc = board.GP8
cs = board.GP9
rst = board.GP12
busy = board.GP13

display_bus = displayio.FourWire(
    busio.SPI(clk, si), command=dc, chip_select=cs, reset=rst, baudrate=1000000
)

time.sleep(1)

display = adafruit_uc8151d.UC8151D(
    display_bus, width=152, height=152, busy_pin=busy, rotation=180, grayscale=True
)


bitmap = displayio.Bitmap(152, 152, 4)

# Draw Black
for x in range(0,152):
    for y in range(0,38):
        bitmap[x, y] = 0
#Draw Dark Gray
for x in range(0,152):
    for y in range(38,76):
        bitmap[x, y] = 1
#Draw Light Gray
for x in range(0,152):
    for y in range(76,114):
        bitmap[x, y] = 2
#Draw White
for x in range(0,152):
    for y in range(114,152):
        bitmap[x, y] = 3

palette = displayio.Palette(4)
palette[0] = 0x000000 # Black
palette[1] = 0x404040 # Dark Gray
palette[2] = 0x808080 # Light Gray
palette[3] = 0xFFFFFF # White

g = displayio.Group()
t = displayio.TileGrid(bitmap, pixel_shader=palette)
g.append(t)
display.show(g)
display.refresh()

@ladyada
Copy link
Member

ladyada commented May 21, 2022

perfect, can you add that to the PR as a new file? then we'll merge it together

@HDR
Copy link
Contributor Author

HDR commented May 21, 2022

Hopefully the Copyright and License stuff is correct, if not please let me know :)

@ladyada ladyada merged commit 3f3f7bd into adafruit:main May 22, 2022
@ladyada
Copy link
Member

ladyada commented May 22, 2022

ya got it, nice work!!!!

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 24, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_BH1750 to 1.1.0 from 1.0.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_BH1750#6 from DeadSix27/main
  > Patch .pre-commit-config.yaml
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground to 5.2.1 from 5.2.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_CircuitPlayground#117 from Neradoc/frozen-module-subdirectory

Updating https://github.com/adafruit/Adafruit_CircuitPython_DS1307 to 2.1.10 from 2.1.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_DS1307#24 from coplate/main
  > Patch .pre-commit-config.yaml
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_UC8151D to 1.1.0 from 1.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_UC8151D#4 from HDR/main
  > Patch .pre-commit-config.yaml
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.
  > Fixed readthedocs build
  > Post-patch cleanup
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_BitmapSaver to 1.2.1 from 1.2.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_BitmapSaver#23 from matt-land/add-typing
  > Patch .pre-commit-config.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI issue with docstring of UC8151D
3 participants