Skip to content

Commit

Permalink
change backlight to a 0 to 1 float as input, or true and false remove…
Browse files Browse the repository at this point in the history
…d the property tag from methods
  • Loading branch information
TG-Techie committed Jan 6, 2019
1 parent 65bdd20 commit 2678bc8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,27 @@
class Joywing: # pylint: disable=too-many-public-methods
"""Represents a single mini tft featherwing. Do not use more than one at
a time."""
def __init__(self):
def __init__(self, _disp_sck = board.SCK, _disp_mosi = board.MOSI, _disp_miso = board.MISO, _disp_cs = board.D5, _disp_dc = board.D6, adress = 94):
# Only create the joywing module member when we're aren't being imported by Sphinx
if ("__module__" in dir(digitalio.DigitalInOut) and
digitalio.DigitalInOut.__module__ == "sphinx.ext.autodoc"):
return
self._disp_sck = board.SCK
self._disp_mosi = board.MOSI
self._disp_miso = board.MISO

#SPI
self._disp_sck = _disp_sck
self._disp_mosi = _disp_mosi
self._disp_miso = _disp_miso
# DS and CS pins
self._disp_cs = board.D5
self._disp_dc = board.D6
self._disp_cs = _disp_cs
self._disp_dc = _disp_dc

#I2C
self._i2c = busio.I2C(board.SCL, board.SDA)
self._seesaw = ss.Seesaw(self._i2c, 94)
self._seesaw = ss.Seesaw(self._i2c, adress)
self._backlight_pin = pwm.PWMOut(self._seesaw, 5)
self._disp_rst = dio.DigitalIO(self._seesaw, 8)
self._disp_spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)

# pylint: disable=bad-whitespace
self._BUTTON_RIGHT = const(7)
self._BUTTON_DOWN = const(4)
Expand Down Expand Up @@ -103,20 +108,28 @@ def __init__(self):
rst=(self._disp_rst), rotation=3)
self._disp.y_offset = 24
# clear screen
self._disp.fill(0)
self._clear()

@property
def black(self):
def _clear(self):
self._disp.fill(0)

@property
'''
def backlight_off(self):
self._backlite.duty_cycle = 0xffff

@property
self._backlite.duty_cycle = 255
def backlight_on(self):
self._backlite.duty_cycle = 0x0000

self._backlite.duty_cycle = 0'''

@property
def backlight(self):
return self._backlite.duty_cycle

@backlight.setter
def backlight(self, value):
self._backlite.duty_cycle = int(255* max( 0, min( 1, (1-value) )) )


@property
def button_up(self):
buttons = self._seesaw.digital_read_bulk(self._button_mask)
Expand Down Expand Up @@ -182,4 +195,4 @@ def button_sel(self):
.. code-block:: python
from adafruit_mini_tft_featherwing.joywing import wing
"""
"""
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from adafruit_mini_tft_featherwing.rgb import colorst as color
from adafruit_mini_tft_featherwing.joywing import wing
from adafruit_mini_tft_featherwing.tft_featherwing import wing
import time

# wing._disp.
"""
Expand All @@ -20,12 +21,15 @@
wing.backlight_on
"""

wing.backlight_on

wing.backlight = .6
wing._disp.pixel(0,0, 255)
wing._disp.rect(5, 5, 150, 50, color(75, 200, 50))
wing._disp.scroll(20, 15, "hello", color(0,70,255), background = None, size = 3)
wing._disp.text(10,55,"This test shows \n if it is working",color(255,255,255), background = color(0,0,0), size = 1, rect_extension = 0, italics = 0)

wing.backlight = True

while True:
if wing.button_a:
print("Button A pressed")
Expand Down

0 comments on commit 2678bc8

Please sign in to comment.