mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
ION: SCREEN_WIDTH becomes ION_SCREEN_WIDTH
Change-Id: Ifc7d06b773f8660cff30e727f510eea448b23852
This commit is contained in:
@@ -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; i<user_inputs.numberOfExpressions(); i++) {
|
||||
yOffset = print_user_input(user_inputs.get_expression(i), yOffset);
|
||||
if (yOffset>SCREEN_HEIGHT) {
|
||||
if (yOffset>ION_SCREEN_HEIGHT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#define ION_ION_H
|
||||
|
||||
#include <ion/events.h>
|
||||
#include <ion/framebuffer.h>
|
||||
#include <ion/keyboard.h>
|
||||
#include <ion/screen.h>
|
||||
|
||||
/* 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,
|
||||
|
||||
@@ -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
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <ion/framebuffer.h>
|
||||
#include <ion/screen.h>
|
||||
|
||||
#define ST7789_USE_9BIT_SPI 1
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user