tft fixes

This commit is contained in:
Bane Stojkovic
2026-10-07 11:32:17 +02:00
parent 61657bea4b
commit 30dfac3f7d
2 changed files with 27 additions and 23 deletions
@@ -363,9 +363,9 @@ public class TFTDisplay extends AbstractMakerBoard {
// The lit area belongs to the panel rather than to the board, so it is centred in the
// glass -- which is the same thing as centring it on the board for every variant whose
// glass spans the board, and is not for the 0.96", whose panel is pushed to one side.
// It is centred vertically too unless the variant states its own figure, which the two
// ILI9341s and the 1.8" do: their panels carry the driver's bonding region along the
// bottom, so the lit area sits high in the frame and centring it would drop it.
// It is centred vertically too unless the variant states its own figure, which every
// board here does but the 0.96": their panels carry the driver's bonding region along
// the bottom, so the lit area sits high in the frame and centring it would drop it.
screenX = glassX + (glassW - screenW) / 2.0;
screenY = controller.hasMeasuredScreenTop() ? boardY + px(controller.getScreenTopMm())
: glassY + (glassH - screenH) / 2.0;
@@ -467,13 +467,16 @@ public class TFTDisplay extends AbstractMakerBoard {
// family's rule and sits centred, which on a board whose holes share one inset is the same as
// centred in the PCB.
ST7735_0_96("0.96\" ST7735 80x160", 30.0d, 24.0d, 21.7d, 10.8d,
new Glass(12.8d, 23.7d, 2.0d), 1.44d, 2.0d, 2.0d, 0d, PIN_NAMES_SPI_8PIN, 0d, null, 0d,
2.0d, true),
new Glass(12.8d, 23.7d, 2.0d), 1.44d, 2.5d, 2.0d, 0d, PIN_NAMES_SPI_8PIN, 0d, null, 0d,
2.5d, true),
GC9A01_1_28("1.28\" GC9A01 240x240 Round", 38.0d, 45.5d, 32.5d, 32.5d, null, 1.76d, 0d, 0d,
22.9d,
new String[] {"RST", "CS", "DC", "SDA", "SCL", "GND", "VCC"}, false),
// The lit area sits 1.5 mm above the middle of the bezel, which the centring rule puts at
// 5.01 mm from the top edge, so the 6.53 mm here; move the hole rows and it has to be
// rederived.
ST7789_1_54("1.54\" ST7789 240x240", 32.0d, 43.72d, 27.66d, 27.66d, new Glass(33.7d), 1.5d,
2.5d, 2.0d, 0d, PIN_NAMES_SPI_8PIN, true),
2.5d, 2.0d, 0d, PIN_NAMES_SPI_8PIN, 6.53d, null, 0d, 2.5d, true),
// Measured throughout, and the second board whose bezel is narrower than the PCB -- 33 mm of
// a 35 mm board -- but centred across it rather than pushed to one side as the 0.96"'s is.
// Down the board the centring rule puts the bezel 5.09 mm from the top edge, which is the
@@ -416,19 +416,18 @@ public class TFTDisplayTest {
}
/**
* Three boards state their own lit area rather than take the centred one, and the reason is
* worth asserting rather than only commenting: their panels carry the driver's bonding region
* along the bottom, so the lit area sits high in the glass and the family's centring rule would
* drop it 4.85 mm on the 2.4", 2.75 mm on the 2.8" and 2 mm on the 1.8". The assertion is that
* the two disagree -- if a later correction ever makes them agree, the field has stopped earning
* its place.
* Every board with a bezel states its own lit area rather than take the centred one, bar the
* 0.96", and the reason is worth asserting rather than only commenting: their panels carry the
* driver's bonding region along the bottom, so the lit area sits high in the glass and the
* family's centring rule would drop it, by 4.85 mm on the 2.4" down to 1.5 mm on the 1.54". The
* assertion is that the two disagree -- if a later correction ever makes them agree, the field
* has stopped earning its place.
*/
@Test
public void theLitAreaIsMeasuredOnlyWhereCentringWouldBeWrong() {
for (Controller controller : Controller.values()) {
Assert.assertEquals(controller + " measured lit area",
controller == Controller.ILI9341_2_4 || controller == Controller.ILI9341_2_8
|| controller == Controller.ST7735_1_8 || controller == Controller.ST7735_1_8_SD,
controller.hasGlass() && controller != Controller.ST7735_0_96,
controller.hasMeasuredScreenTop());
if (!controller.hasMeasuredScreenTop()) {
continue;
@@ -449,13 +448,14 @@ public class TFTDisplayTest {
// are the assertions that say the stored figure has to be rederived. What was arrived at
// differs by board: the ILI9341s were measured as a frame below the top of the bezel, the
// 1.8" as a lift off the position the centring rule gives.
if (controller == Controller.ST7735_1_8 || controller == Controller.ST7735_1_8_SD) {
Assert.assertEquals(controller + " lift off the centred lit area", 2.0d,
glassTop + (glassH - controller.getScreenLengthMm()) / 2.0 - screenTop, 0.01d);
} else {
if (controller == Controller.ILI9341_2_4 || controller == Controller.ILI9341_2_8) {
double frameAbove = controller == Controller.ILI9341_2_4 ? 2.76d : 3.05d;
Assert.assertEquals(controller + " frame above the lit area", frameAbove,
screenTop - glassTop, 0.01d);
} else {
double lift = controller == Controller.ST7789_1_54 ? 1.5d : 2.0d;
Assert.assertEquals(controller + " lift off the centred lit area", lift,
glassTop + (glassH - controller.getScreenLengthMm()) / 2.0 - screenTop, 0.01d);
}
}
}
@@ -514,14 +514,15 @@ public class TFTDisplayTest {
/**
* Each board's holes are one drill at one inset from each of the two edges nearest them, but the
* figures are the board's own rather than the package's: the two ILI9341s are 3 mm at 3 mm, the
* 0.96" is 2 mm at 2 mm, and the 1.8" and the 1.54" are 2 mm at 2.5 mm. The 2.8" had a narrower
* 2.5 mm drill for a while and this guards against it coming back. Both ILI9341 boards hold their
* header-side pair deeper than their other one, by their own figure and for their own reason,
* which is asserted beside this rather than within it so the two cannot be read as one rule.
* 1.8" with the socket is 2 mm at 3 mm, and the other three are 2 mm at 2.5 mm. The 2.8" had a
* narrower 2.5 mm drill for a while and this guards against it coming back. Both ILI9341 boards
* hold their header-side pair deeper than their other one, by their own figure and for their own
* reason, which is asserted beside this rather than within it so the two cannot be read as one
* rule.
*/
@Test
public void mountingHoleFiguresAreEachBoardsOwn() {
double[][] expected = {{3.0d, 3.0d}, {3.0d, 3.0d}, {2.0d, 2.0d}, {2.5d, 2.0d}, {3.0d, 2.0d},
double[][] expected = {{3.0d, 3.0d}, {3.0d, 3.0d}, {2.5d, 2.0d}, {2.5d, 2.0d}, {3.0d, 2.0d},
{2.5d, 2.0d}};
Controller[] withHoles = {Controller.ILI9341_2_8, Controller.ILI9341_2_4,
Controller.ST7735_0_96, Controller.ST7735_1_8, Controller.ST7735_1_8_SD,