Skip to content

Commit

Permalink
ili9341 transpose
Browse files Browse the repository at this point in the history
  • Loading branch information
sylefeb committed Jan 18, 2024
1 parent 512a20f commit ee13769
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
45 changes: 37 additions & 8 deletions frameworks/verilator/ParallelScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ void ParallelScreen::cmd_idle_ILI9341()
case 0x3A:
m_command = std::bind( &ParallelScreen::cmd_mode_ILI9341, this );
break;
case 0x36:
m_command = std::bind( &ParallelScreen::cmd_madctl_ILI9341, this );
break;
default:
break;
}
Expand All @@ -123,6 +126,19 @@ void ParallelScreen::cmd_mode_ILI9341()

// ----------------------------------------------------------------------------

void ParallelScreen::cmd_madctl_ILI9341()
{
if ((m_byte & 0x20) != 0) {
fprintf(stdout,"screen in row major mode\n");
m_row_major = true;
} else {
m_row_major = false;
}
set_idle();
}

// ----------------------------------------------------------------------------

void ParallelScreen::cmd_start_end(int *p_start,int *p_end,int nbytes)
{
fprintf(stdout,"cmd_start_end, byte: %x (step:%d)\n",m_byte,m_step);
Expand Down Expand Up @@ -151,8 +167,9 @@ void ParallelScreen::cmd_start_end(int *p_start,int *p_end,int nbytes)
void ParallelScreen::cmd_write_ram()
{
if (!m_dc) {
// exit
set_idle();
// command
cmd_idle_ILI9341();
return;
}
if (m_step == 0) {
// first time
Expand All @@ -178,13 +195,25 @@ void ParallelScreen::cmd_write_ram()
if (m_step > 2) {
// move to next pixel
m_step = 1;
++ m_y_cur;
if (m_y_cur > m_y_end) {
m_y_cur = m_y_start;
if (!m_row_major) {
++ m_y_cur;
if (m_y_cur > m_y_end) {
m_y_cur = m_y_start;
++ m_x_cur;
if (m_x_cur > m_x_end) {
m_x_cur = m_x_start;
m_framebuffer_changed = true;
}
}
} else {
++ m_x_cur;
if (m_x_cur > m_x_end) {
m_x_cur = m_x_start;
m_framebuffer_changed = true;
if (m_x_cur > m_y_end) {
m_x_cur = m_y_start;
++ m_y_cur;
if (m_y_cur > m_x_end) {
m_y_cur = m_x_start;
m_framebuffer_changed = true;
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions frameworks/verilator/ParallelScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class ParallelScreen : public DisplayChip

int m_x_cur = 0;
int m_y_cur = 0;

bool m_row_major = false;

LibSL::Math::v4b m_rgb;

Expand All @@ -77,6 +79,7 @@ class ParallelScreen : public DisplayChip

void cmd_idle_ILI9341();
void cmd_mode_ILI9341();
void cmd_madctl_ILI9341();

void cmd_start_end(int *p_start,int *p_end,int nbytes);
void cmd_write_ram();
Expand Down

0 comments on commit ee13769

Please sign in to comment.