dv_stick
Mike Bell 2023-05-21 20:57:11 +01:00 zatwierdzone przez Phil Howard
rodzic 4ed1d61336
commit 360588ff67
5 zmienionych plików z 1767 dodań i 1621 usunięć

Wyświetl plik

@ -96,6 +96,14 @@ namespace pimoroni {
return i2c.reg_read_uint8(I2C_ADDR, I2C_REG_GPIO_HI);
}
void DVDisplay::set_led_level(uint8_t level) {
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_LED, level | 0x80);
}
void DVDisplay::set_led_heartbeat() {
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_LED, 2);
}
void DVDisplay::get_edid(uint8_t* edid) {
i2c.read_bytes(I2C_ADDR, I2C_REG_EDID, edid, 128);
}

Wyświetl plik

@ -39,6 +39,7 @@ namespace pimoroni {
static constexpr uint I2C_REG_SET_RES = 0xF8;
static constexpr uint I2C_REG_START = 0xF9;
static constexpr uint I2C_REG_GPIO = 0xC0;
static constexpr uint I2C_REG_LED = 0xC1;
static constexpr uint I2C_REG_GPIO_HI = 0xC8;
static constexpr uint I2C_REG_EDID = 0xED;
@ -109,6 +110,11 @@ namespace pimoroni {
bool is_button_b_pressed() { return (get_driver_gpio() & 0x1) != 0x1; }
bool is_button_c_pressed() { return (get_driver_gpio() & 0x2) != 0x2; }
// Valid LED levels are from 0-127.
void set_led_level(uint8_t level);
void set_led_level(float level) { set_led_level((uint8_t)(level * 127.f)); }
void set_led_heartbeat();
// The supplied buffer must be at least 128 bytes long
void get_edid(uint8_t* edid);

Wyświetl plik

@ -45,6 +45,17 @@ int main() {
display.init();
//display.test();
#if 0
uint8_t edid[128];
display.get_edid(edid);
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 16; ++j) {
printf("%02x ", edid[i*16 + j]);
}
printf("\n");
}
#endif
PicoGraphics_PenDV_RGB555 graphics(FRAME_WIDTH, FRAME_HEIGHT, display);
graphics.set_pen(0x001F);
@ -71,6 +82,7 @@ int main() {
circles[i].y = rand() % graphics.bounds.h;
}
int frames = 0;
while (true) {
//while(gpio_get(BUTTON_A) == 1) {
// sleep_ms(10);
@ -139,5 +151,9 @@ int main() {
display.flip();
uint32_t flip_time = time_us_32() - flip_start_time;
printf("Render: %.3f, flip: %.3f\n", render_time / 1000.f, flip_time / 1000.f);
++frames;
if (gpio_get(BUTTON_A) == 0) display.set_led_level((uint8_t)frames);
else display.set_led_heartbeat();
}
}