From 60699af63f92f43cc4b4b9e3050fcdd2a8468281 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Wed, 10 Apr 2019 15:14:00 -0400 Subject: add opengl fronend, remove sdl frontend, refactor build system --- .../calculator/CEdev/examples/os_input/src/main.c | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 frontends/calculator/CEdev/examples/os_input/src/main.c (limited to 'frontends/calculator/CEdev/examples/os_input/src') diff --git a/frontends/calculator/CEdev/examples/os_input/src/main.c b/frontends/calculator/CEdev/examples/os_input/src/main.c new file mode 100644 index 0000000..7674897 --- /dev/null +++ b/frontends/calculator/CEdev/examples/os_input/src/main.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include + +/* Make sure to adjust those sizes according to your usage! */ +#define INPUT_SIZE 10 +#define RESP_SIZE 20 + +/* Draw text on the homescreen at the given X/Y location */ +void print(const char* text, uint8_t xpos, uint8_t ypos) { + os_SetCursorPos(ypos, xpos); + os_PutStrFull(text); +} + +void main(void) { + char inputBuffer[INPUT_SIZE]; + char response[RESP_SIZE]; + + /* Clear the homescreen */ + os_ClrHome(); + + /* Ask the user to type a string, which gets stored in `inputBuf` */ + os_GetStringInput("What is N? ", inputBuffer, INPUT_SIZE); + + /* Build the user response */ + sprintf(response, "N is %s.", inputBuffer); + + /* Clear the homescreen and display the built response */ + os_ClrHome(); + print(response, 0, 0); + + /* Wait for a key press before quitting */ + while (!os_GetCSC()); +} -- cgit v1.2.3-101-g0448