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

Add: Circular display connector (bottom05flip) #380

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions edg/parts/Lcd_Er_Tft1_28_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
from edg.parts.PassiveConnector_Fpc import Fpc050BottomFlip
from edg import *
from edg.abstract_parts import *


class Er_Tft_128_3_Outline(InternalSubcircuit, FootprintBlock):
"""Footprint for TFT panel outline"""

def contents(self) -> None:
super().contents()
self.footprint('U', 'edg:Lcd_Er_Tft1_28_3_Outline', {},
Suke0811 marked this conversation as resolved.
Show resolved Hide resolved
'EastRising', 'ER-TFT1.28-3',
datasheet='https://www.buydisplay.com/download/manual/ER-TFT1.28-3_Datasheet.pdf')


class Er_Tft_128_3_Device(InternalSubcircuit, Nonstrict3v3Compatible, Block):
"""15-pin FPC connector for the ER-TFT1.28-3 device"""

def __init__(self) -> None:
super().__init__()

self.conn = self.Block(Fpc050BottomFlip(length=15))
Suke0811 marked this conversation as resolved.
Show resolved Hide resolved

# Power pins
self.vdd = self.Export(self.conn.pins.request('4').adapt_to(VoltageSink(
voltage_limits=self.nonstrict_3v3_compatible.then_else(
(2.5, 3.6) * Volt, # abs max is 4.6v
(2.5, 3.3) * Volt),
)))
self.gnd = self.Export(self.conn.pins.request('1').adapt_to(Ground()))
# Backlight control
self.ledk = self.Export(self.conn.pins.request('2'))
self.leda = self.Export(self.conn.pins.request('3'))

dio_model = DigitalBidir.from_supply(
self.gnd, self.vdd,
voltage_limit_abs=(-0.3 * Volt, self.vdd.voltage_limits.upper()),
Suke0811 marked this conversation as resolved.
Show resolved Hide resolved
input_threshold_factor=(0.3, 0.7)
)

self.rs = self.Export(self.conn.pins.request('5').adapt_to(DigitalSink()))
Suke0811 marked this conversation as resolved.
Show resolved Hide resolved

# Control pins
self.spi = self.Port(SpiPeripheral.empty())
self.cs = self.Export(self.conn.pins.request('6').adapt_to(dio_model))
self.connect(self.spi.sck, self.conn.pins.request('7').adapt_to(dio_model))
self.connect(self.spi.mosi, self.conn.pins.request('8').adapt_to(dio_model))
Suke0811 marked this conversation as resolved.
Show resolved Hide resolved

self.miso_nc = self.Block(DigitalBidirNotConnected())
self.connect(self.spi.miso, self.miso_nc.port)

self.rst = self.Export(self.conn.pins.request('9').adapt_to(DigitalSink()))

# Capacitive Touch Panel (CTP)
self.ctp_i2c = self.Port(I2cTarget(DigitalBidir.empty(), addresses=[0x15]),)

self.ctp_vdd = self.Export(self.conn.pins.request('10').adapt_to(VoltageSink(
voltage_limits=(2.7, 3.6) * Volt,
current_draw=(5 * uAmp, 2.5 * mAmp)
)))

self.connect(self.gnd, self.conn.pins.request('11').adapt_to(Ground()))

self.ctp_rst = self.Export(self.conn.pins.request('12').adapt_to(dio_model))
self.ctp_int = self.Export(self.conn.pins.request('13').adapt_to(dio_model))
self.connect(self.ctp_i2c.sda, self.conn.pins.request('14').adapt_to(dio_model))
self.connect(self.ctp_i2c.scl, self.conn.pins.request('15').adapt_to(dio_model))


class Er_Tft_128_3(Lcd, Resettable, Block):
"""GC9A01-based 1.28" 240x240 TFT, with optional capacitive touch panel."""
Suke0811 marked this conversation as resolved.
Show resolved Hide resolved

def __init__(self) -> None:
super().__init__()
self.ic = self.Block(Er_Tft_128_3_Device())
self.gnd = self.Export(self.ic.gnd, [Common])
self.pwr = self.Export(self.ic.vdd, [Power])
self.spi = self.Export(self.ic.spi)
self.cs = self.Export(self.ic.cs)
self.dc = self.Export(self.ic.rs)
# touch interface
self.ctp_i2c = self.Export(self.ic.ctp_i2c, optional=True, doc='Touch panel interface i2c')
self.ctp_rst = self.Export(self.ic.ctp_rst, optional=True, doc='Touch panel interface')
self.ctp_int = self.Export(self.ic.ctp_int, optional=True, doc='Touch panel interface')

def contents(self):
super().contents()
self.connect(self.reset, self.ic.rst)
self.require(self.reset.is_connected())

# self.lcd = self.Block(Er_Tft_128_3_Outline()) # for ic outline

self.connect(self.ic.ledk.adapt_to(Ground()), self.gnd)
forward_current = (1, 30)*mAmp
Suke0811 marked this conversation as resolved.
Show resolved Hide resolved
self.led_res = self.Block(Resistor(
resistance=(self.pwr.link().voltage.upper() / forward_current.upper(),
self.pwr.link().voltage.lower() / forward_current.lower())))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.led_res = self.Block(Resistor(
resistance=(self.pwr.link().voltage.upper() / forward_current.upper(),
self.pwr.link().voltage.lower() / forward_current.lower())))
forward_voltage = 2.9*Volt
self.led_res = self.Block(Resistor(
resistance=((self.pwr.link().voltage.upper() - forward_voltage) / forward_current.upper(),
(self.pwr.link().voltage.lower() - forward_voltage) / forward_current.lower())))

As we learned it turns out that subtracting the forward voltage is pretty important

There also is a way to do this in one expression (instead of splitting the lower and upper bounds) and have tolerancing work correctly though it's a bit more complex. Can discuss further, might be interesting to try.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Applied the current suggestions.

Is there like an array operations like that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Division can be done as a range operation, resistance = self.pwr.link().voltage / forward_current. The problem is that forward current is a spec so the tolerance of resistance needs to shrink, whereas range division semantics here have tolerances expanding.

There is Range.cancel_multiply, which does the right thing, but it needs to work on concrete values instead of RangeExpr. I'm thinking of maybe adding RangeExpr.cancel_multiply, which can then be used here. Still thinking of syntax, maybe resistance = (1/forward_current).cancel_multiply(self.pwr.link().voltage)? Possibly needs a better name too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Does that do element-wise multiplication? what does cancel mean here?

# self.led_res = self.Block(Resistor(50 * Ohm(tol=0.05))) # TODO: a optional backlight dimming circuit (using a FET from a logic-level control signal).

Suke0811 marked this conversation as resolved.
Show resolved Hide resolved
self.connect(self.led_res.a.adapt_to(VoltageSink(current_draw=(1, 40) * mAmp)), self.pwr)
Suke0811 marked this conversation as resolved.
Show resolved Hide resolved
self.connect(self.led_res.b, self.ic.leda)
self.connect(self.pwr, self.ic.ctp_vdd)
self.require(self.ctp_i2c.is_connected() == self.ctp_rst.is_connected())
self.require(self.ctp_i2c.is_connected() == self.ctp_int.is_connected())

1 change: 1 addition & 0 deletions edg/parts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
from .Neopixel import Neopixel, Ws2812b, Sk6812Mini_E, Sk6805_Ec15, Sk6812_Side_A, NeopixelArray, NeopixelArrayCircular
from .Lcd_Qt096t_if09 import Qt096t_if09
from .Lcd_Ch280qv10_Ct import Ch280qv10_Ct
from .Lcd_Er_Tft1_28_3 import Er_Tft_128_3
from .Oled_Er_Oled_091_3 import Er_Oled_091_3
from .Oled_Er_Oled_096_1_1 import Er_Oled_096_1_1
from .Oled_Er_Oled_096_1c import Er_Oled_096_1c
Expand Down
Loading