summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Leonhardt <sebastian.leonhardt@web.de>2016-04-11 23:13:35 +0200
committerSebastian Leonhardt <sebastian.leonhardt@web.de>2018-04-02 20:29:01 +0200
commit96335a7eb2e9cf1e452feac0c8ae0c489197500f (patch)
tree4b324ed3c75d91aebf4b6caf6e68879445a2cff1
parentd5847e8cb2cf6eb5bc6929a13c95a1c563df8bc6 (diff)
pacbox: clean-up screen size code
removes the code duplication for lcd scaling in pacbox.h/pacbox_lcd.h Change-Id: Ib0aeacc9934351c5e32cd4b7576cdc840e6ff7da
-rw-r--r--apps/plugins/pacbox/pacbox.h37
-rw-r--r--apps/plugins/pacbox/pacbox_lcd.c16
2 files changed, 38 insertions, 15 deletions
diff --git a/apps/plugins/pacbox/pacbox.h b/apps/plugins/pacbox/pacbox.h
index bb132f7c4c..77a107bec4 100644
--- a/apps/plugins/pacbox/pacbox.h
+++ b/apps/plugins/pacbox/pacbox.h
@@ -373,22 +373,42 @@
#endif
#endif
-#if (LCD_HEIGHT >= 288)
+/* Calculate scaling and screen offset/clipping.
+ Put native portrait mode before landscape, if a screen resulution allows both.
+ */
+#if (LCD_WIDTH >= 224) && (LCD_HEIGHT >= 288)
+#define LCD_SCALE 100
+#define LCD_ROTATE 0
#define XOFS ((LCD_WIDTH-224)/2)
#define YOFS ((LCD_HEIGHT-288)/2)
-#elif (LCD_WIDTH >= 288)
+
+#elif (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224)
+#define LCD_SCALE 100
+#define LCD_ROTATE 1
#define XOFS ((LCD_WIDTH-288)/2)
#define YOFS ((LCD_HEIGHT-224)/2)
-#elif (LCD_WIDTH >= 220)
-#define XOFS ((LCD_WIDTH-(288*3/4))/2)
-#define YOFS ((LCD_HEIGHT-(224*3/4))/2)
+
#elif (LCD_WIDTH >= 168) && (LCD_HEIGHT >= 216)
+#define LCD_SCALE 75
+#define LCD_ROTATE 0
#define XOFS ((LCD_WIDTH-(224*3/4))/2)
#define YOFS ((LCD_HEIGHT-(288*3/4))/2)
-#elif (LCD_WIDTH >= 144)
+
+#elif (LCD_WIDTH >= 216) && (LCD_HEIGHT >= 168)
+#define LCD_SCALE 75
+#define LCD_ROTATE 1
+#define XOFS ((LCD_WIDTH-(288*3/4))/2)
+#define YOFS ((LCD_HEIGHT-(224*3/4))/2)
+
+#elif (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112)
+#define LCD_SCALE 50
+#define LCD_ROTATE 1
#define XOFS ((LCD_WIDTH-288/2)/2)
#define YOFS ((LCD_HEIGHT-224/2)/2)
-#elif (LCD_WIDTH >= 128)
+
+#elif (LCD_WIDTH >= 112) && (LCD_HEIGHT >= 128)
+#define LCD_SCALE 50
+#define LCD_ROTATE 0
#define XOFS ((LCD_WIDTH-224/2)/2)
#if LCD_HEIGHT < 144
#define YCLIP ((288-2*LCD_HEIGHT)/2)
@@ -397,6 +417,9 @@
#define YCLIP 0
#define YOFS ((LCD_HEIGHT-288/2)/2)
#endif
+
+#else
+#error "unsupported screen resolution"
#endif
/* How many video frames (out of a possible 60) we display each second.
diff --git a/apps/plugins/pacbox/pacbox_lcd.c b/apps/plugins/pacbox/pacbox_lcd.c
index bc2de20858..6bb51a038d 100644
--- a/apps/plugins/pacbox/pacbox_lcd.c
+++ b/apps/plugins/pacbox/pacbox_lcd.c
@@ -35,7 +35,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
int x,y;
#ifdef HAVE_LCD_COLOR
-#if (LCD_WIDTH >= 224) && (LCD_HEIGHT >= 288)
+#if LCD_SCALE==100 && LCD_ROTATE==0
/* Native resolution = 224x288 */
(void)next_dst;
dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS];
@@ -45,7 +45,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
}
dst += XOFS*2;
}
-#elif (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224)
+#elif LCD_SCALE==100 && LCD_ROTATE==1
/* Native resolution - rotated 90 degrees = 288x224 */
next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight-1];
for( y=ScreenHeight-1; y>=0; y-- ) {
@@ -55,7 +55,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
dst+=LCD_WIDTH;
}
}
-#elif (LCD_WIDTH >= 216) && (LCD_HEIGHT >= 168)
+#elif LCD_SCALE==75 && LCD_ROTATE==1
/* 0.75 scaling - display 3 out of 4 pixels - rotated = 216x168
Skipping pixel #2 out of 4 seems to give the most legible display
*/
@@ -74,7 +74,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
vbuf+=ScreenWidth;
}
}
-#elif (LCD_WIDTH >= 168) && (LCD_HEIGHT >= 216)
+#elif LCD_SCALE==75 && LCD_ROTATE==0
/* 0.75 scaling - display 3 out of 4 pixels - = 168x216
Skipping pixel #2 out of 4 seems to give the most legible display
*/
@@ -93,7 +93,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
vbuf+=ScreenWidth;
}
}
-#elif (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112)
+#elif LCD_SCALE==50 && LCD_ROTATE==1
/* 0.5 scaling - display every other pixel - rotated = 144x112 */
next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight/2-1];
for (y=(ScreenHeight/2)-1;y >= 0; y--) {
@@ -105,7 +105,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
}
vbuf+=ScreenWidth;
}
-#elif (LCD_WIDTH >= 128) && (LCD_HEIGHT >= 128)
+#elif LCD_SCALE==50 && LCD_ROTATE==0
/* 0.5 scaling - display every other pixel
* LCD_HEIGHT < 144: 112x144, crop to 112x128
* else center vertically without clipping */
@@ -126,7 +126,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
}
#endif
#else /* Greyscale LCDs */
-#if (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112)
+#if LCD_SCALE==50 && LCD_ROTATE==1
#if LCD_PIXELFORMAT == VERTICAL_PACKING
/* 0.5 scaling - display every other pixel = 144x112 */
next_dst=&lcd_framebuffer[YOFS/4*LCD_WIDTH+XOFS+ScreenHeight/2-1];
@@ -140,6 +140,6 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
vbuf+=ScreenWidth;
}
#endif /* Vertical Packing */
-#endif /* Size >= 144x112 */
+#endif /* scale 50% rotated */
#endif /* Not Colour */
}