diff --git a/app/app.cpp b/app/app.cpp index a12647774..1cc599cc8 100644 --- a/app/app.cpp +++ b/app/app.cpp @@ -106,15 +106,15 @@ static user_expression_t create_user_input(char* text) { static int16_t print_user_input(user_expression_t user_expression, int16_t yOffset) { if (user_expression.expression_layout) { int16_t height = user_expression.expression_layout->size().height; - if (yOffset + height < SCREEN_HEIGHT) { + if (yOffset + height < ION_SCREEN_HEIGHT) { user_expression.expression_layout->draw(KDPointMake(0, yOffset)); } yOffset += height; } if (user_expression.simplified_layout) { int16_t height = user_expression.simplified_layout->size().height; - if (yOffset + height < SCREEN_HEIGHT) { - int16_t xOffset = SCREEN_WIDTH - user_expression.simplified_layout->size().width; + if (yOffset + height < ION_SCREEN_HEIGHT) { + int16_t xOffset = ION_SCREEN_WIDTH - user_expression.simplified_layout->size().width; user_expression.simplified_layout->draw(KDPointMake(xOffset, yOffset)); } yOffset += height; @@ -126,7 +126,7 @@ static void print_user_inputs(const UserExpressions& user_inputs, uint8_t starti int16_t yOffset = 0; for (uint8_t i=startingAt; iSCREEN_HEIGHT) { + if (yOffset>ION_SCREEN_HEIGHT) { break; } } diff --git a/app/plot.cpp b/app/plot.cpp index 6544b3eef..bef6bbce0 100644 --- a/app/plot.cpp +++ b/app/plot.cpp @@ -10,8 +10,8 @@ extern "C" { #include "utils.h" #include "plot.h" -constexpr KDCoordinate kScreenWidth = SCREEN_WIDTH; -const KDCoordinate kScreenHeight = SCREEN_HEIGHT; +constexpr KDCoordinate kScreenWidth = ION_SCREEN_WIDTH; +const KDCoordinate kScreenHeight = ION_SCREEN_HEIGHT; static float plotValues[kScreenWidth]; static float yMin, yMax; diff --git a/app/utils.cpp b/app/utils.cpp index 99cc22c54..db8ab9df2 100644 --- a/app/utils.cpp +++ b/app/utils.cpp @@ -14,16 +14,16 @@ void clear_screen() { KDRect r; r.x = 0; r.y = 0; - r.width = SCREEN_WIDTH; - r.height = SCREEN_HEIGHT; + r.width = ION_SCREEN_WIDTH; + r.height = ION_SCREEN_HEIGHT; KDFillRect(r, 0x00); } static void clear_prompt() { KDRect r; r.x = 0; - r.y = SCREEN_HEIGHT - kPromptHeight; - r.width = SCREEN_WIDTH; + r.y = ION_SCREEN_HEIGHT - kPromptHeight; + r.width = ION_SCREEN_WIDTH; r.height = kPromptHeight; KDFillRect(r, 0x00); } @@ -31,19 +31,19 @@ static void clear_prompt() { static void print_prompt(char* text, int index) { char* tmp = (char*) " "; KDSize font_size = KDStringSize(tmp); - KDDrawLine(KDPointMake(0, SCREEN_HEIGHT - kPromptHeight), - KDPointMake(SCREEN_WIDTH, SCREEN_HEIGHT - kPromptHeight), 0xff); - KDDrawString(text, KDPointMake(0, SCREEN_HEIGHT - (kPromptHeight / 2)), 0); - KDDrawChar(text[index], KDPointMake(index * font_size.width, SCREEN_HEIGHT - (kPromptHeight / 2)), true); + KDDrawLine(KDPointMake(0, ION_SCREEN_HEIGHT - kPromptHeight), + KDPointMake(ION_SCREEN_WIDTH, ION_SCREEN_HEIGHT - kPromptHeight), 0xff); + KDDrawString(text, KDPointMake(0, ION_SCREEN_HEIGHT - (kPromptHeight / 2)), 0); + KDDrawChar(text[index], KDPointMake(index * font_size.width, ION_SCREEN_HEIGHT - (kPromptHeight / 2)), true); } static void clear_trig_menu() { { KDRect r; - r.x = SCREEN_WIDTH / 4 - 1; - r.y = SCREEN_HEIGHT / 4 - 1; - r.width = SCREEN_WIDTH / 2 + 2; - r.height = SCREEN_HEIGHT / 2 + 2; + r.x = ION_SCREEN_WIDTH / 4 - 1; + r.y = ION_SCREEN_HEIGHT / 4 - 1; + r.width = ION_SCREEN_WIDTH / 2 + 2; + r.height = ION_SCREEN_HEIGHT / 2 + 2; KDFillRect(r, 0x00); } } @@ -51,10 +51,10 @@ static void clear_trig_menu() { static void print_trig_menu() { { KDRect r; - r.x = SCREEN_WIDTH / 4; - r.y = SCREEN_HEIGHT / 4; - r.width = SCREEN_WIDTH / 2; - r.height = SCREEN_HEIGHT / 2; + r.x = ION_SCREEN_WIDTH / 4; + r.y = ION_SCREEN_HEIGHT / 4; + r.width = ION_SCREEN_WIDTH / 2; + r.height = ION_SCREEN_HEIGHT / 2; KDDrawRect(r, 0xff); } } @@ -72,7 +72,7 @@ static int get_trig_input(char* input) { "cos( )", "tan( )", }; - const KDPoint orig = KDPointMake(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 4); + const KDPoint orig = KDPointMake(ION_SCREEN_WIDTH / 4, ION_SCREEN_HEIGHT / 4); while (true) { print_trig_menu(); diff --git a/ion/include/ion.h b/ion/include/ion.h index d0131844f..815a5e747 100644 --- a/ion/include/ion.h +++ b/ion/include/ion.h @@ -2,8 +2,8 @@ #define ION_ION_H #include -#include #include +#include /* ION is not your regular library. It is a library you link against, but it * will take care of configuring the whole environment for you. In POSIX terms, diff --git a/ion/include/ion/framebuffer.h b/ion/include/ion/screen.h similarity index 90% rename from ion/include/ion/framebuffer.h rename to ion/include/ion/screen.h index f20905430..b4cd3d4b8 100644 --- a/ion/include/ion/framebuffer.h +++ b/ion/include/ion/screen.h @@ -1,5 +1,5 @@ -#ifndef ION_FRAMEBUFFER_H -#define ION_FRAMEBUFFER_H +#ifndef ION_SCREEN_H +#define ION_SCREEN_H /* ION abstracts pushing pixels to the screen. * @@ -33,7 +33,7 @@ void ion_fill_rect_from_buffer( ion_color_t * buffer ); -#define SCREEN_WIDTH 320 -#define SCREEN_HEIGHT 240 +#define ION_SCREEN_WIDTH 320 +#define ION_SCREEN_HEIGHT 240 #endif diff --git a/ion/src/device/display/st7789.h b/ion/src/device/display/st7789.h index 8169b452a..360b451d7 100644 --- a/ion/src/device/display/st7789.h +++ b/ion/src/device/display/st7789.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #define ST7789_USE_9BIT_SPI 1 diff --git a/ion/src/simulator/init.cpp b/ion/src/simulator/init.cpp index 177dd5458..5322856f8 100644 --- a/ion/src/simulator/init.cpp +++ b/ion/src/simulator/init.cpp @@ -22,8 +22,8 @@ void init_platform() { Fl::visual(FL_RGB); int margin = 10; - int screen_width = SCREEN_WIDTH; - int screen_height = SCREEN_HEIGHT; + int screen_width = ION_SCREEN_WIDTH; + int screen_height = ION_SCREEN_HEIGHT; int keyboard_height = screen_width; Fl_Window * window = new Fl_Window(screen_width+2*margin, margin+screen_height+margin+keyboard_height+margin); @@ -38,9 +38,9 @@ void init_platform() { } void ion_set_pixel(uint16_t x, uint16_t y, ion_color_t color) { - assert(x < SCREEN_WIDTH); - assert(y < SCREEN_HEIGHT); - char * byte = (char *)(FRAMEBUFFER_ADDRESS) + ((y*SCREEN_WIDTH)+x); + assert(x < ION_SCREEN_WIDTH); + assert(y < ION_SCREEN_HEIGHT); + char * byte = (char *)(FRAMEBUFFER_ADDRESS) + ((y*ION_SCREEN_WIDTH)+x); *byte = color; } diff --git a/quiz/src/runner.c b/quiz/src/runner.c index 7fc170be2..643a7a0b5 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}, 0); line_y += line_height; - if (line_y > SCREEN_HEIGHT) { + if (line_y > ION_SCREEN_HEIGHT) { line_y = 0; // Clear screen maybe? }