From 2778ccea112b7c4267afc0e14f2f6aab68cc252b Mon Sep 17 00:00:00 2001 From: Felix Raimundo Date: Mon, 21 Mar 2016 16:00:10 +0100 Subject: [PATCH] Use the same macro for the screen size. The screen size used to be defined by the framebuffer size, this was weird, the creen size can be defined in the makefile if needed (in order to have different one for different targets) Change-Id: Ie294fba5f6cf5e942b4b35847ae8ccd18d3ddf85 --- app/app.cpp | 12 ++++++------ ion/include/ion/framebuffer.h | 3 +++ ion/src/device/display/framebuffer.h | 12 ++++++++++-- ion/src/simulator/init.cpp | 12 +++++------- kandinsky/src/line.c | 5 +---- quiz/src/runner.c | 2 +- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/app/app.cpp b/app/app.cpp index 54af34abd..c94c7b061 100644 --- a/app/app.cpp +++ b/app/app.cpp @@ -7,8 +7,8 @@ extern "C" { #include void draw_lines_from_center() { - KDCoordinate width = 240; - KDCoordinate height = 160; + KDCoordinate width = SCREEN_WIDTH; + KDCoordinate height = SCREEN_HEIGHT; KDColor c = 0xFF; @@ -36,8 +36,8 @@ void draw_lines_from_center() { void plot(Expression * e, float xMin, float xMax, float yMin, float yMax) { Context plotContext; - KDCoordinate screenWidth = 240; - KDCoordinate screenHeight = 160; + KDCoordinate screenWidth = SCREEN_WIDTH; + KDCoordinate screenHeight = SCREEN_HEIGHT; KDPoint previousPoint; for (KDCoordinate i=0;i + extern char _framebuffer_start; extern char _framebuffer_end; #define FRAMEBUFFER_ADDRESS (&_framebuffer_start) #define FRAMEBUFFER_LENGTH (&_framebuffer_end-&_framebuffer_start) -#define FRAMEBUFFER_WIDTH 240 -#define FRAMEBUFFER_HEIGHT 160 +#define FRAMEBUFFER_WIDTH SCREEN_WIDTH +#define FRAMEBUFFER_HEIGHT SCREEN_HEIGHT + #define FRAMEBUFFER_BITS_PER_PIXEL 4 + +#endif // ION_DEVICE_DISPLAY_FRAMEBUFFER_H_ diff --git a/ion/src/simulator/init.cpp b/ion/src/simulator/init.cpp index a449dae66..ee18e00ae 100644 --- a/ion/src/simulator/init.cpp +++ b/ion/src/simulator/init.cpp @@ -16,16 +16,14 @@ static FltkLCD * sDisplay; static FltkKbd * sKeyboard; #define FRAMEBUFFER_ADDRESS (sDisplay->m_framebuffer) -#define FRAMEBUFFER_WIDTH 320 -#define FRAMEBUFFER_HEIGHT 240 #define FRAMEBUFFER_BITS_PER_PIXEL 8 void init_platform() { Fl::visual(FL_RGB); int margin = 10; - int screen_width = FRAMEBUFFER_WIDTH; - int screen_height = FRAMEBUFFER_HEIGHT; + int screen_width = SCREEN_WIDTH; + int screen_height = SCREEN_HEIGHT; // keyboard_width == screen_width int keyboard_height = screen_width; @@ -41,9 +39,9 @@ void init_platform() { } void ion_set_pixel(uint8_t x, uint8_t y, uint8_t color) { - assert(x <= FRAMEBUFFER_WIDTH); - assert(y <= FRAMEBUFFER_HEIGHT); - char * byte = (char *)(FRAMEBUFFER_ADDRESS) + ((y*FRAMEBUFFER_WIDTH)+x); + assert(x <= SCREEN_WIDTH); + assert(y <= SCREEN_HEIGHT); + char * byte = (char *)(FRAMEBUFFER_ADDRESS) + ((y*SCREEN_WIDTH)+x); *byte = color; } diff --git a/kandinsky/src/line.c b/kandinsky/src/line.c index ef548100f..1deb9dd6b 100644 --- a/kandinsky/src/line.c +++ b/kandinsky/src/line.c @@ -49,10 +49,7 @@ void KDDrawLine(KDPoint p1, KDPoint p2, KDColor c) { KDCoordinate scanCounter = 0; while (scanCounter++ < scanLength) { - // FIXME - if (p.x>=0 && p.x < 240 && p.y>=0 && p.y<=160) { - KDSetPixel(p, c); - } + KDSetPixel(p, c); p = KDPointTranslate(p, alwaysTranslate); error = error - minusError; if (error <= 0) { diff --git a/quiz/src/runner.c b/quiz/src/runner.c index 68cb48fa9..a19e202d8 100644 --- a/quiz/src/runner.c +++ b/quiz/src/runner.c @@ -8,7 +8,7 @@ void print(char * message) { int line_height = KDStringSize("M").height; KDDrawString(message, (KDPoint){.x = 0, .y = line_y}); line_y += line_height; - if (line_y > 160) { + if (line_y > SCREEN_HEIGHT) { line_y = 0; ion_getchar(); // Clear screen maybe?