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
This commit is contained in:
Felix Raimundo
2016-03-21 16:00:10 +01:00
parent 16b650c5d5
commit 2778ccea11
6 changed files with 26 additions and 20 deletions

View File

@@ -7,8 +7,8 @@ extern "C" {
#include <poincare.h>
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<screenWidth; i++) {
float x = xMin + (xMax-xMin)/screenWidth*i;
@@ -106,8 +106,8 @@ void interactive_expression_parsing() {
KDRect r;
r.x = 0;
r.y = 0;
r.width = 160;
r.height = 160;
r.width = SCREEN_WIDTH;
r.height = SCREEN_HEIGHT;
KDFillRect(r, 0x00);
}
input[index++] = character;

View File

@@ -5,4 +5,7 @@
void ion_set_pixel(uint8_t x, uint8_t y, uint8_t color);
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#endif

View File

@@ -1,8 +1,16 @@
#ifndef ION_DEVICE_DISPLAY_FRAMEBUFFER_H_
#define ION_DEVICE_DISPLAY_FRAMEBUFFER_H_
#include <ion.h>
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_

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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?