kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Ability to choose the resolution for the display
rodzic
1d8c836635
commit
c7049f4ff1
|
@ -1,6 +1,6 @@
|
|||
#include "dv_display.hpp"
|
||||
#include "swd_load.hpp"
|
||||
#include "pico-stick.h"
|
||||
#include "pico-stick-wide.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <math.h>
|
||||
|
@ -9,6 +9,31 @@
|
|||
namespace pimoroni {
|
||||
|
||||
void DVDisplay::init() {
|
||||
uint8_t mode = 0xFF;
|
||||
if (width == 640) {
|
||||
mode = 0;
|
||||
}
|
||||
else if (width == 720) {
|
||||
if (height == 480) mode = 1;
|
||||
else if (height == 400) mode = 2;
|
||||
else if (height == 576) mode = 3;
|
||||
}
|
||||
else if (width == 800) {
|
||||
if (height == 600) mode = 0x10;
|
||||
else if (height == 480) mode = 0x11;
|
||||
else if (height == 450) mode = 0x12;
|
||||
}
|
||||
else if (width == 960) {
|
||||
if (height == 540) mode = 0x14;
|
||||
}
|
||||
else if (width == 1280) {
|
||||
if (height == 720) mode = 0x15;
|
||||
}
|
||||
|
||||
if (mode == 0xFF) {
|
||||
printf("Resolution %dx%d is not supported. Will use 720x480.\n", width, height);
|
||||
}
|
||||
|
||||
gpio_init(RAM_SEL);
|
||||
gpio_put(RAM_SEL, 0);
|
||||
gpio_set_dir(RAM_SEL, GPIO_OUT);
|
||||
|
@ -31,13 +56,12 @@ namespace pimoroni {
|
|||
sleep_ms(100);
|
||||
|
||||
printf("Start I2C\n");
|
||||
//i2c_init(i2c0, 100000);
|
||||
//gpio_set_function(I2C_SDA, GPIO_FUNC_I2C); gpio_pull_up(I2C_SDA);
|
||||
//gpio_set_function(I2C_SCL, GPIO_FUNC_I2C); gpio_pull_up(I2C_SCL);
|
||||
|
||||
if (mode != 0xFF) {
|
||||
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_SET_RES, mode);
|
||||
}
|
||||
|
||||
i2c.reg_write_uint8(I2C_ADDR, I2C_REG_START, 1);
|
||||
//uint8_t i2c_cmd[] = {I2C_REG_START, 1};
|
||||
//i2c_write_blocking(i2c0, I2C_ADDR, i2c_cmd, 2, false);
|
||||
printf("Started\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace pimoroni {
|
|||
|
||||
// I2C
|
||||
static constexpr uint I2C_ADDR = 0x0D;
|
||||
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_GPIO_HI = 0xC8;
|
||||
|
@ -46,7 +47,11 @@ namespace pimoroni {
|
|||
uint8_t bank = 0;
|
||||
|
||||
public:
|
||||
DVDisplay(uint16_t width, uint16_t height)
|
||||
// Valid resolutions are:
|
||||
// 640x480 (60Hz), 720x480 (60Hz), 720x400 (70Hz), 720x576 (50Hz)
|
||||
// 800x600 (60Hz), 800x480 (60Hz), 800x450 (60Hz), 960x540 (50Hz), 1280x720 (30Hz)
|
||||
// Note resolutions on the second line require quite extreme overclocking and may not work on all hardware.
|
||||
DVDisplay(uint16_t width, uint16_t height)
|
||||
: ram(CS, D0)
|
||||
, i2c(I2C_SDA, I2C_SCL)
|
||||
, width(width), height(height)
|
||||
|
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
|
@ -12,8 +12,8 @@
|
|||
|
||||
using namespace pimoroni;
|
||||
|
||||
#define FRAME_WIDTH 720
|
||||
#define FRAME_HEIGHT 480
|
||||
#define FRAME_WIDTH 1280
|
||||
#define FRAME_HEIGHT 720
|
||||
|
||||
FATFS fs;
|
||||
FRESULT fr;
|
||||
|
@ -146,12 +146,13 @@ int main() {
|
|||
auto dir = new DIR();
|
||||
bool first = true;
|
||||
constexpr int ms_per_image = 5000;
|
||||
const TCHAR* dirname = "/images720/";
|
||||
while (1) {
|
||||
f_opendir(dir, "/images/");
|
||||
f_opendir(dir, dirname);
|
||||
while(f_readdir(dir, &file) == FR_OK && file.fname[0]) {
|
||||
printf("- %s %lld\n", file.fname, file.fsize);
|
||||
|
||||
draw_jpeg(std::string("/images/") + file.fname);
|
||||
draw_jpeg(std::string(dirname) + file.fname);
|
||||
|
||||
if (!first) {
|
||||
for (int w = 0; w < ms_per_image && gpio_get(BUTTON_A) == 1; w += 10) {
|
||||
|
|
Ładowanie…
Reference in New Issue