kopia lustrzana https://github.com/pimoroni/pimoroni-pico
DV Display: External I2C interface option
rodzic
de4aaa80b6
commit
4b57162c06
|
@ -81,10 +81,10 @@ namespace pimoroni {
|
||||||
mp_printf(&mp_plat_print, "Start I2C\n");
|
mp_printf(&mp_plat_print, "Start I2C\n");
|
||||||
|
|
||||||
if (res_mode != 0xFF) {
|
if (res_mode != 0xFF) {
|
||||||
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_SET_RES, res_mode);
|
i2c->reg_write_uint8(I2C_ADDR, I2C_REG_SET_RES, res_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_START, 1);
|
i2c->reg_write_uint8(I2C_ADDR, I2C_REG_START, 1);
|
||||||
mp_printf(&mp_plat_print, "Started\n");
|
mp_printf(&mp_plat_print, "Started\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,18 +111,18 @@ namespace pimoroni {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t DVDisplay::get_gpio() {
|
uint8_t DVDisplay::get_gpio() {
|
||||||
return i2c.reg_read_uint8(I2C_ADDR, I2C_REG_GPIO);
|
return i2c->reg_read_uint8(I2C_ADDR, I2C_REG_GPIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t DVDisplay::get_gpio_hi() {
|
uint8_t DVDisplay::get_gpio_hi() {
|
||||||
return i2c.reg_read_uint8(I2C_ADDR, I2C_REG_GPIO_HI);
|
return i2c->reg_read_uint8(I2C_ADDR, I2C_REG_GPIO_HI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::i2c_modify_bit(uint8_t reg, uint bit, bool enable) {
|
void DVDisplay::i2c_modify_bit(uint8_t reg, uint bit, bool enable) {
|
||||||
uint8_t val = i2c.reg_read_uint8(I2C_ADDR, reg);
|
uint8_t val = i2c->reg_read_uint8(I2C_ADDR, reg);
|
||||||
if (enable) val |= 1u << bit;
|
if (enable) val |= 1u << bit;
|
||||||
else val &= ~(1u << bit);
|
else val &= ~(1u << bit);
|
||||||
i2c.reg_write_uint8(I2C_ADDR, reg, val);
|
i2c->reg_write_uint8(I2C_ADDR, reg, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::set_gpio_hi_dir(uint pin, bool output) {
|
void DVDisplay::set_gpio_hi_dir(uint pin, bool output) {
|
||||||
|
@ -130,7 +130,7 @@ namespace pimoroni {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::set_gpio_hi_dir_all(uint8_t val) {
|
void DVDisplay::set_gpio_hi_dir_all(uint8_t val) {
|
||||||
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_GPIO_HI_OE, val);
|
i2c->reg_write_uint8(I2C_ADDR, I2C_REG_GPIO_HI_OE, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::set_gpio_hi(uint pin, bool on) {
|
void DVDisplay::set_gpio_hi(uint pin, bool on) {
|
||||||
|
@ -138,7 +138,7 @@ namespace pimoroni {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::set_gpio_hi_all(uint8_t val) {
|
void DVDisplay::set_gpio_hi_all(uint8_t val) {
|
||||||
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_GPIO_HI_OUT, val);
|
i2c->reg_write_uint8(I2C_ADDR, I2C_REG_GPIO_HI_OUT, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::set_gpio_hi_pull_up(uint pin, bool on) {
|
void DVDisplay::set_gpio_hi_pull_up(uint pin, bool on) {
|
||||||
|
@ -146,7 +146,7 @@ namespace pimoroni {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::set_gpio_hi_pull_up_all(uint8_t val) {
|
void DVDisplay::set_gpio_hi_pull_up_all(uint8_t val) {
|
||||||
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_GPIO_HI_PULL_UP, val);
|
i2c->reg_write_uint8(I2C_ADDR, I2C_REG_GPIO_HI_PULL_UP, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::set_gpio_hi_pull_down(uint pin, bool on) {
|
void DVDisplay::set_gpio_hi_pull_down(uint pin, bool on) {
|
||||||
|
@ -154,19 +154,19 @@ namespace pimoroni {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::set_gpio_hi_pull_down_all(uint8_t val) {
|
void DVDisplay::set_gpio_hi_pull_down_all(uint8_t val) {
|
||||||
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_GPIO_HI_PULL_DOWN, val);
|
i2c->reg_write_uint8(I2C_ADDR, I2C_REG_GPIO_HI_PULL_DOWN, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::set_led_level(uint8_t level) {
|
void DVDisplay::set_led_level(uint8_t level) {
|
||||||
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_LED, level | 0x80);
|
i2c->reg_write_uint8(I2C_ADDR, I2C_REG_LED, level | 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::set_led_heartbeat() {
|
void DVDisplay::set_led_heartbeat() {
|
||||||
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_LED, 2);
|
i2c->reg_write_uint8(I2C_ADDR, I2C_REG_LED, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::get_edid(uint8_t* edid) {
|
void DVDisplay::get_edid(uint8_t* edid) {
|
||||||
i2c.read_bytes(I2C_ADDR, I2C_REG_EDID, edid, 128);
|
i2c->read_bytes(I2C_ADDR, I2C_REG_EDID, edid, 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVDisplay::write(uint32_t address, size_t len, const uint16_t colour)
|
void DVDisplay::write(uint32_t address, size_t len, const uint16_t colour)
|
||||||
|
|
|
@ -25,25 +25,11 @@ namespace pimoroni {
|
||||||
MODE_RGB888 = 3,
|
MODE_RGB888 = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------
|
// I2C pins
|
||||||
// Variables
|
|
||||||
//--------------------------------------------------
|
|
||||||
protected:
|
|
||||||
// Ram accessed through the APS6404 driver
|
|
||||||
APS6404 ram;
|
|
||||||
|
|
||||||
// I2C interface to driver
|
|
||||||
I2C i2c;
|
|
||||||
|
|
||||||
// interface pins
|
|
||||||
static constexpr uint CS = 17;
|
|
||||||
static constexpr uint D0 = 19;
|
|
||||||
static constexpr uint VSYNC = 16;
|
|
||||||
static constexpr uint RAM_SEL = 8;
|
|
||||||
static constexpr uint I2C_SDA = 6;
|
static constexpr uint I2C_SDA = 6;
|
||||||
static constexpr uint I2C_SCL = 7;
|
static constexpr uint I2C_SCL = 7;
|
||||||
|
|
||||||
// I2C
|
// I2C address and registers
|
||||||
static constexpr uint I2C_ADDR = 0x0D;
|
static constexpr uint I2C_ADDR = 0x0D;
|
||||||
static constexpr uint I2C_REG_SET_RES = 0xF8;
|
static constexpr uint I2C_REG_SET_RES = 0xF8;
|
||||||
static constexpr uint I2C_REG_START = 0xF9;
|
static constexpr uint I2C_REG_START = 0xF9;
|
||||||
|
@ -56,6 +42,22 @@ namespace pimoroni {
|
||||||
static constexpr uint I2C_REG_GPIO_HI_PULL_DOWN = 0xCC;
|
static constexpr uint I2C_REG_GPIO_HI_PULL_DOWN = 0xCC;
|
||||||
static constexpr uint I2C_REG_EDID = 0xED;
|
static constexpr uint I2C_REG_EDID = 0xED;
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Variables
|
||||||
|
//--------------------------------------------------
|
||||||
|
protected:
|
||||||
|
// Ram accessed through the APS6404 driver
|
||||||
|
APS6404 ram;
|
||||||
|
|
||||||
|
// I2C interface to driver
|
||||||
|
I2C* i2c;
|
||||||
|
|
||||||
|
// interface pins
|
||||||
|
static constexpr uint CS = 17;
|
||||||
|
static constexpr uint D0 = 19;
|
||||||
|
static constexpr uint VSYNC = 16;
|
||||||
|
static constexpr uint RAM_SEL = 8;
|
||||||
|
|
||||||
static constexpr uint32_t base_address = 0x10000;
|
static constexpr uint32_t base_address = 0x10000;
|
||||||
uint16_t width = 0;
|
uint16_t width = 0;
|
||||||
uint16_t height = 0;
|
uint16_t height = 0;
|
||||||
|
@ -71,8 +73,16 @@ namespace pimoroni {
|
||||||
// Note resolutions on the second line require quite extreme overclocking and may not work on all hardware.
|
// Note resolutions on the second line require quite extreme overclocking and may not work on all hardware.
|
||||||
// Either or both of the horizontal or vertical component of any resolution may be halved.
|
// Either or both of the horizontal or vertical component of any resolution may be halved.
|
||||||
DVDisplay(uint16_t width, uint16_t height, Mode mode = MODE_RGB555)
|
DVDisplay(uint16_t width, uint16_t height, Mode mode = MODE_RGB555)
|
||||||
: ram(CS, D0)
|
: ram(CS, D0, pio0)
|
||||||
, i2c(I2C_SDA, I2C_SCL)
|
, i2c(new I2C(I2C_SDA, I2C_SCL))
|
||||||
|
, width(width), height(height)
|
||||||
|
, mode(mode)
|
||||||
|
, pixel_buffer_location(-1, -1)
|
||||||
|
{}
|
||||||
|
|
||||||
|
DVDisplay(uint16_t width, uint16_t height, I2C* i2c, Mode mode = MODE_RGB555)
|
||||||
|
: ram(CS, D0, pio0)
|
||||||
|
, i2c(i2c)
|
||||||
, width(width), height(height)
|
, width(width), height(height)
|
||||||
, mode(mode)
|
, mode(mode)
|
||||||
, pixel_buffer_location(-1, -1)
|
, pixel_buffer_location(-1, -1)
|
||||||
|
|
Ładowanie…
Reference in New Issue