Add active3 pinout (only first connector works)

This commit is contained in:
Jeff Epler 2025-03-06 13:49:24 -06:00
parent d26bba84ba
commit d008684e5d
2 changed files with 55 additions and 10 deletions

View file

@ -40,4 +40,42 @@ struct adafruit_matrix_bonnet_pinout_bgr {
static constexpr uint32_t post_addr_delay = 500; static constexpr uint32_t post_addr_delay = 500;
}; };
struct active3_pinout {
static constexpr pin_t PIN_RGB[] = {7, 27, 11, 10, 9, 8, 6, 5, 12,
20, 13, 19, 3, 2, 14, 21, 16, 26};
static constexpr pin_t PIN_ADDR[] = {22, 23, 24, 25, 15};
static constexpr pin_t PIN_OE = 18; // /OE: output enable when LOW
static constexpr pin_t PIN_CLK = 17; // SRCLK: clocks on RISING edge
static constexpr pin_t PIN_LAT = 4; // RCLK: latches on RISING edge
static constexpr uint32_t clk_bit = 1u << PIN_CLK;
static constexpr uint32_t lat_bit = 1u << PIN_LAT;
static constexpr uint32_t oe_bit = 1u << PIN_OE;
static constexpr uint32_t oe_active = 0;
static constexpr uint32_t oe_inactive = oe_bit;
static constexpr uint32_t post_oe_delay = 0;
static constexpr uint32_t post_latch_delay = 0;
static constexpr uint32_t post_addr_delay = 500;
};
struct active3_pinout_bgr {
static constexpr pin_t PIN_RGB[] = {11, 27, 7, 8, 9, 10, 12, 5, 6,
19, 13, 20, 14, 2, 3, 26, 16, 21};
static constexpr pin_t PIN_ADDR[] = {22, 23, 24, 25, 15};
static constexpr pin_t PIN_OE = 18; // /OE: output enable when LOW
static constexpr pin_t PIN_CLK = 17; // SRCLK: clocks on RISING edge
static constexpr pin_t PIN_LAT = 4; // RCLK: latches on RISING edge
static constexpr uint32_t clk_bit = 1u << PIN_CLK;
static constexpr uint32_t lat_bit = 1u << PIN_LAT;
static constexpr uint32_t oe_bit = 1u << PIN_OE;
static constexpr uint32_t oe_active = 0;
static constexpr uint32_t oe_inactive = oe_bit;
static constexpr uint32_t post_oe_delay = 0;
static constexpr uint32_t post_latch_delay = 0;
static constexpr uint32_t post_addr_delay = 500;
};
} // namespace piomatter } // namespace piomatter

View file

@ -54,6 +54,8 @@ enum Colorspace { RGB565, RGB888, RGB888Packed };
enum Pinout { enum Pinout {
AdafruitMatrixBonnet, AdafruitMatrixBonnet,
AdafruitMatrixBonnetBGR, AdafruitMatrixBonnetBGR,
Active3,
Active3BGR,
}; };
template <class pinout> template <class pinout>
@ -70,12 +72,10 @@ make_piomatter_p(Colorspace c, py::buffer buffer,
case RGB888Packed: case RGB888Packed:
return make_piomatter_pc<pinout, piomatter::colorspace_rgb888_packed>( return make_piomatter_pc<pinout, piomatter::colorspace_rgb888_packed>(
buffer, geometry); buffer, geometry);
default:
throw std::runtime_error(py::str("Invalid colorspace {!r}")
.attr("format")(c)
.template cast<std::string>());
} }
throw std::runtime_error(py::str("Invalid colorspace {!r}")
.attr("format")(c)
.template cast<std::string>());
} }
std::unique_ptr<PyPiomatter> std::unique_ptr<PyPiomatter>
@ -88,11 +88,15 @@ make_piomatter(Colorspace c, Pinout p, py::buffer buffer,
case AdafruitMatrixBonnetBGR: case AdafruitMatrixBonnetBGR:
return make_piomatter_p<piomatter::adafruit_matrix_bonnet_pinout_bgr>( return make_piomatter_p<piomatter::adafruit_matrix_bonnet_pinout_bgr>(
c, buffer, geometry); c, buffer, geometry);
default: case Active3:
throw std::runtime_error(py::str("Invalid pinout {!r}") return make_piomatter_p<piomatter::active3_pinout>(c, buffer, geometry);
.attr("format")(p) case Active3BGR:
.template cast<std::string>()); return make_piomatter_p<piomatter::active3_pinout_bgr>(c, buffer,
geometry);
} }
throw std::runtime_error(py::str("Invalid pinout {!r}")
.attr("format")(p)
.template cast<std::string>());
} }
} // namespace } // namespace
@ -138,7 +142,10 @@ PYBIND11_MODULE(_piomatter, m) {
.value("AdafruitMatrixHat", Pinout::AdafruitMatrixBonnet, .value("AdafruitMatrixHat", Pinout::AdafruitMatrixBonnet,
"Adafruit Matrix Bonnet or Matrix Hat") "Adafruit Matrix Bonnet or Matrix Hat")
.value("AdafruitMatrixHatBGR", Pinout::AdafruitMatrixBonnetBGR, .value("AdafruitMatrixHatBGR", Pinout::AdafruitMatrixBonnetBGR,
"Adafruit Matrix Bonnet or Matrix Hat with BGR color order"); "Adafruit Matrix Bonnet or Matrix Hat with BGR color order")
.value("Active3", Pinout::Active3, "Active-3 or compatible board")
.value("Active3BGR", Pinout::Active3BGR,
"Active-3 or compatible board with BGR color order");
py::enum_<Colorspace>( py::enum_<Colorspace>(
m, "Colorspace", m, "Colorspace",