Skip to content

Add screen rotation function #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions JDI_MIP_Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void JDI_MIP_Display::begin(){

void JDI_MIP_Display::refresh()
{
for(int i=0; i < height(); i++){
for(int i=0; i < HEIGHT; i++){
int lineIdx = HALF_WIDTH * i;
char *line_cmd;
#ifdef DIFF_LINE_UPDATE
Expand Down Expand Up @@ -75,7 +75,7 @@ void JDI_MIP_Display::clearScreen(){
}

void JDI_MIP_Display::sendLineCommand(char* line_cmd, int line){
if((line < 0) || (line >= height())){
if((line < 0) || (line >= HEIGHT)){
return;
}

Expand All @@ -97,8 +97,28 @@ void JDI_MIP_Display::drawPixel(int16_t x, int16_t y, uint16_t color)
if(x < 0 || x >= width() || y < 0 || y >= height()){
return;
}
int16_t t;
switch (rotation)
{
case 1:
t = x;
x = WIDTH - 1 - y;
y = t;
break;
case 2:
x = WIDTH - 1 - x;
y = HEIGHT - 1 - y;
break;
case 3:
t = x;
x = y;
y = HEIGHT - 1 - t;
break;
default:
break;
}

int pixelIdx = ((width() / 2) * y) + (x / 2);
int pixelIdx = ((WIDTH / 2) * y) + (x / 2);

if(x % 2 == 0){
_backBuffer[pixelIdx] &= 0x0F;
Expand Down Expand Up @@ -128,4 +148,4 @@ void JDI_MIP_Display::frontlightOn(){

void JDI_MIP_Display::frontlightOff(){
digitalWrite(_frontlight, LOW);
}
}