As I have said before, I am working on a program to create a simple Symbolic-Manipulation engine. I have created some code that runs an intro loop and I am working on the input loop. When I run the code, all I see is a black screen until I press "Enter", and then "Clear". Could someone please explain to me what is going on, or even better, help me rewrite my code so that it works?\
I am writing this project in C using SourceCoder 3.
Code:
I am writing this project in C using SourceCoder 3.
Code:
// Program Name: Csymb
// Author(s): claculator
// License: GPL 3
// Description: expression simplifier written in C
#include <tice.h>
#include <graphx.h>
#include <keypadc.h>
#include <stdbool.h>
#define InputMax 50
int main(void) {
gfx_Begin();
gfx_SetDrawBuffer();
int x = 0;
int y = 30;
int px = 160;
int py = 200;
int flashCounter = 0;
while (!kb_IsDown(kb_KeyEnter)) {
kb_Scan();
gfx_FillScreen(0);
gfx_SetTextXY(x, y);
gfx_PrintString("Csymb Pre-Alpha");
// Flash every 30 frames (~0.5 seconds at 60fps)
if (flashCounter % 30 < 15) {
gfx_SetTextXY(px, py);
gfx_PrintString("Press ENTER");
}
flashCounter++;
gfx_SwapDraw();
x += 2;
if (x > LCD_WIDTH) {
x = -gfx_GetStringWidth("Csymb Pre-Alpha");
}
}
do {
kb_Scan();
} while (kb_IsDown(kb_KeyEnter));
gfx_FillScreen(0);
gfx_SetTextFGColor(255);
gfx_SetTextXY(10, 10);
gfx_PrintString("Expression:");
char input[InputMax + 1];
input[0] = '\0';
int length = 0;
bool needsRedraw = true;
while (true) {
kb_Scan();
if (kb_IsDown(kb_KeyClear)) {
gfx_End();
return 0;
}
if (kb_IsDown(kb_KeyEnter) && length > 0) {
// TODO: Process the expression
gfx_SetTextXY(10, 50);
gfx_PrintString("Processing...");
gfx_SwapDraw();
break;
}
if (kb_IsDown(kb_KeyDel) && length > 0) {
length--;
input[length] = '\0';
needsRedraw = true;
delay(100); // Debounce
}
if (needsRedraw) {
gfx_SetColor(0);
gfx_FillRectangle(10, 30, LCD_WIDTH - 20, 20);
gfx_SetTextXY(10, 30);
gfx_SetTextFGColor(255);
gfx_PrintString(input);
gfx_SetTextXY(10 + gfx_GetStringWidth(input), 30);
gfx_PrintString("_"); // Cursor
gfx_SwapDraw();
needsRedraw = false;
}
}
gfx_End();
return 0;
}
