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

Update scale to remove self._scale that conflicts with Blinka #117

Merged
merged 1 commit into from
Feb 11, 2021

Conversation

kmatch98
Copy link
Contributor

@kmatch98 kmatch98 commented Feb 9, 2021

Removing usage of self._scale in bitmap_label that is causing conflict with Blinka displayio.Group library's internal variable with the same name.

I verified the code on a PyPortal and also on Blinka.

This is targeted to resolve this issue on Adafruit_Blinka_Displayio adafruit/Adafruit_Blinka_Displayio#45.

Blinka: Currently released version
image

Blinka: Version with this PR
image

Test code with Blinka and pygamedisplay:

import sys

sys.path.append("./lib")


import displayio
import time
import random
import terminalio
from adafruit_blinka import board
from blinka_displayio_pygamedisplay import PyGameDisplay

# The key here is "auto_refresh=False". Failing to do so will create a new thread
# for the rendering, and macOS (or the Python implementation for it) can only be
# performed on the main (UI) thread.
display = PyGameDisplay(width=320, height=240, auto_refresh=False)


# This is a trial of the switch_round_horizontal
# for use on the PyPortal
#
#from adafruit_display_text import label
from adafruit_display_text import bitmap_label as label

# Make the display context
splash = displayio.Group(max_size=10)
display.show(splash)

WIDTH = 320
HEIGHT = 240

# Draw a black background
bg_bitmap = displayio.Bitmap(WIDTH, HEIGHT , 1)
bg_palette = displayio.Palette(1)
bg_palette[0] = 0x000000
splash.append(displayio.TileGrid(bg_bitmap, pixel_shader=bg_palette))

test_label1 = label.Label(terminalio.FONT, text="Scale", scale=1, color=0xFFFFFF, x=8, y=8)
print("Test1 : before append to splash")
print(f"  Scale {test_label1.scale}")
splash.append(test_label1)
print("Test1 : after append to splash")
print(f"  Scale {test_label1.scale}")
print("test_label1.bounding_box: {}".format(test_label1.bounding_box))

print()
test_label2 = label.Label(terminalio.FONT, text="Scale", scale=2, color=0xFFFFFF, x=8, y=38)
print("Test2 : before append to splash")
print(f"  Scale {test_label2.scale}")
splash.append(test_label2)
print("Test2 : after append to splash")
print(f"  Scale {test_label2.scale}")
print("test_label2.bounding_box: {}".format(test_label2.bounding_box))

print()
test_label3 = label.Label(terminalio.FONT, text="Scale", scale=3, color=0xFFFFFF, x=8, y=88)
print("Test3 : before append to splash")
print(f"  Scale {test_label3.scale}")
splash.append(test_label3)
print("Test3 : after append to splash")
print(f"  Scale {test_label3.scale}")
print("test_label3.bounding_box: {}".format(test_label3.bounding_box))

while display.running:
    display.refresh()

@lesamouraipourpre
Copy link
Contributor

Using a slightly modified script (attached) which also tests anchored_position and anchor_point, I've verified the code on PyPortal and my SH1107 OLED.
test_bitmap_label.py

screenshot_pygame
screenshot_oled

@kmatch98
Copy link
Contributor Author

kmatch98 commented Feb 9, 2021

@lesamouraipourpre Looks like it works fine. (But initially it had me confused with the smaller sized display in the second photo.) Thanks for the testing and for the earlier PR on label.py!

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

Looks good to me. Tested with Blinka_Displayio and PyPortal bitmap_label scaling works the same across both now.

Thank you @kmatch98 for handling this one, and @lesamouraipourpre for pointing out the fix to this!

@FoamyGuy FoamyGuy merged commit f45b71b into adafruit:master Feb 11, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 12, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_BME680 to 3.3.1 from 3.3.0:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_BME680#40 from caternuson/iss39
  > Merge pull request adafruit/Adafruit_CircuitPython_BME680#36 from adafruit/REUSE
  > Merge pull request adafruit/Adafruit_CircuitPython_BME680#38 from caternuson/iss37_spi_example
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_CLUE to 2.2.7 from 2.2.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_CLUE#37 from adafruit/REUSE
  > Hardcoded Black and REUSE versions
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_FONA to 2.1.2 from 2.1.1:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_FONA#12 from adafruit/REUSE
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_HTS221 to 1.1.3 from 1.1.2:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_HTS221#6 from adafruit/REUSE
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_MSA301 to 1.2.5 from 1.2.4:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_MSA301#14 from adafruit/REUSE
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel to 6.0.2 from 6.0.1:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_NeoPixel#103 from adafruit/REUSE
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_RockBlock to 1.3.1 from 1.3.0:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_RockBlock#19 from adafruit/REUSE

Updating https://github.com/adafruit/Adafruit_CircuitPython_SCD30 to 2.0.2 from 2.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_SCD30#9 from caternuson/iss2_mcp2221

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1327 to 1.2.1 from 1.2.0:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1327#9 from adafruit/REUSE
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_ST7789 to 1.4.3 from 1.4.2:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_ST7789#21 from wildestpixel/patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_TCA9548A to 0.3.4 from 0.3.3:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_TCA9548A#23 from SAK917/adafruit/Adafruit_CircuitPython_TCA9548A#20-remove-obsolete-code

Updating https://github.com/adafruit/Adafruit_CircuitPython_AWS_IOT to 2.0.5 from 2.0.4:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_AWS_IOT#16 from adafruit/REUSE
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT to 2.3.3 from 2.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_AzureIoT#25 from adafruit/REUSE
  > Hardcoded Black and REUSE versions
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font to 1.3.4 from 1.3.3:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_Bitmap_Font#37 from jfurcean/fix_api_docs

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_MIDI to 1.0.3 from 1.0.2:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE_MIDI#6 from adafruit/REUSE

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 1.12.3 from 2.12.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#117 from kmatch98/bitmap_label_scale
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#116 from lesamouraipourpre/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_Hue to 1.1.3 from 1.1.2:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_Hue#14 from adafruit/REUSE

Updating https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad to 0.13.2 from 0.13.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#43 from adafruit/REUSE
  > Hardcoded Black and REUSE versions
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_LIFX to 1.9.4 from 1.1.2:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_LIFX#10 from adafruit/REUSE

Updating https://github.com/adafruit/Adafruit_CircuitPython_MagTag to 1.6.0 from 1.5.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_MagTag#54 from makermelissa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.9.6 from 1.9.5:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#68 from jfabernathy/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_SimpleIO to 3.0.1 from 3.0.0:
  > Hardcoded Black and REUSE versions
  > Merge pull request adafruit/Adafruit_CircuitPython_SimpleIO#60 from adafruit/REUSE
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.

None yet

3 participants