Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Autocompletion and handling unimplemented methods #299

Merged
merged 12 commits into from
Apr 7, 2020

Conversation

andreamah
Copy link
Contributor

Description:

Handling Unimplemented Methods:

  • Changing (mostly base_circuitpython) methods from public to private and implementing missing methods that are simple. For non-simple unimplemented methods, it warns the user that the method is unusable in the simulator.
  • Some methods were also completely removed if they were not needed and not in the spec.
  • Additional pin constants were added to board.py in order to allow code to compile if they reference any board pins.
    • I made the active choice to not print anything if people reference the board pin constants, although they actually return a pin object within the real Circuitpython.
      • This was due to the fact that many tutorials use them & it might be really annoying to always see print statements (when all you want to do is run code that would run on the board). Feel free to comment on this, though!! :)

Autocompletion:

  • Used docstrings from the official Circuitpython Github in order to have info on public methods.
  • Added compatibility with Pylint and autocompletion on the front-end

Notes:

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Testing:

Here are some tests I ran:

For new group manipulation methods (also, feel free to hover on class names and method names to potentially see some info!):

import board
import displayio
from adafruit_display_shapes.rect import Rect
from adafruit_display_shapes.circle import Circle
from adafruit_display_shapes.roundrect import RoundRect
from adafruit_display_shapes.triangle import Triangle
from adafruit_display_shapes.line import Line
from adafruit_display_shapes.polygon import Polygon

# Make the display context
splash = displayio.Group(max_size=20)
board.DISPLAY.show(splash)
# Make a background color fill
color_bitmap = displayio.Bitmap(320, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0xFFFFFF
bg_sprite = displayio.TileGrid(color_bitmap, x=0, y=0, pixel_shader=color_palette)
splash.append(bg_sprite)
##########################################################################

splash.append(Line(220, 130, 270, 210, 0xFF0000))
splash.append(Line(270, 210, 220, 210, 0xFF0000))
splash.append(Line(220, 210, 270, 130, 0xFF0000))
splash.append(Line(270, 130, 220, 130, 0xFF0000))

# Draw a blue star
polygon = Polygon(
    [
        (155, 40),
        (162, 62),
        (185, 62),
        (165, 76),
        (175, 100),
        (155, 84),
        (135, 100),
        (145, 76),
        (125, 62),
        (148, 62),
    ],
    outline=0x0000FF,
)
splash.append(polygon)

triangle = Triangle(170, 50, 120, 140, 210, 160, fill=0x00FF00, outline=0xFF00FF)
splash.append(triangle)

rect = Rect(80, 20, 41, 41, fill=0x0)
splash.append(rect)

circle = Circle(100, 100, 20, fill=0x00FF00, outline=0xFF00FF)
splash.append(circle)

rect2 = Rect(50, 100, 61, 81, outline=0x0, stroke=3)
splash.insert(4,rect2)

roundrect = RoundRect(10, 10, 61, 81, 10, fill=0x0, outline=0xFF00FF, stroke=6)
splash.append(roundrect)
splash.remove(rect)
del splash[splash.index(triangle)]
splash.hidden = True
while True:
    pass

For unimplemented method testing:

from adafruit_slideshow import SlideShow, PlayBackDirection, PlayBackOrder
import board
import pulseio
# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(
    board.DISPLAY,
    pulseio.PWMOut(board.TFT_BACKLIGHT),
    dwell=1,
    loop=True,
    fade_effect=True,
    auto_advance=True,
    order=PlayBackOrder.ALPHABETICAL,
    direction=PlayBackDirection.FORWARD,
)
for i in range(2):
    slideshow.advance()
while slideshow.update():
    pass

Checklist:

  • My code follows the style guidelines of this project
  • My code has been formatted with npm run format and passes the checks in npm run check
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Copy link

@nasadigital nasadigital left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@vandyliu vandyliu left a comment

Choose a reason for hiding this comment

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

LGTM!

@andreamah andreamah merged commit e24cb75 into dev Apr 7, 2020
@andreamah andreamah deleted the users/t-anmah/autocompletion-and-unimplemented-methods branch April 7, 2020 18:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants