From 55bfff7cf6541caac172b43186cf14405185b14d Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sat, 13 Apr 2019 12:40:52 -0400 Subject: fix curses on linux --- .../calculator/CEdev/examples/stopwatch/src/main.c | 120 ++++++++++----------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'frontends/calculator/CEdev/examples/stopwatch/src') diff --git a/frontends/calculator/CEdev/examples/stopwatch/src/main.c b/frontends/calculator/CEdev/examples/stopwatch/src/main.c index 3ec82b1..6dc8fdf 100644 --- a/frontends/calculator/CEdev/examples/stopwatch/src/main.c +++ b/frontends/calculator/CEdev/examples/stopwatch/src/main.c @@ -1,60 +1,60 @@ -#include -#include -#include -#include - -#include -#include -#include - -/* Print a stopwatch value on the home screen */ -void print(float elapsed) { - /* Float format for printf may be unimplemented, so go through an OS real */ - real_t elapsed_real; - - /* Max stopwatch value is (2^32 - 1) / 32768 = 131072.00, */ - /* so create a buffer with room for 9 characters plus a null terminator */ - char str[10]; - - /* If the elapsed time is small enough that the OS would print it using */ - /* scientific notation, force it down to zero before conversion */ - elapsed_real = os_FloatToReal(elapsed <= 0.001f ? 0.0f : elapsed); - - /* Convert the elapsed time real to a string */ - os_RealToStr(str, &elapsed_real, 8, 1, 2); - - /* Print the string */ - os_SetCursorPos(0, 0); - os_PutStrFull(str); -} - -/* Put all your code here */ -void main(void) { - /* Clear the homescreen */ - os_ClrHome(); - - /* Display an initial time of zero */ - print(0.0f); - - /* Disable the timer */ - timer_Control = TIMER1_DISABLE; - - /* Reset the timer's counter */ - timer_1_Counter = 0; - - /* Wait for a key press */ - while (!os_GetCSC()); - - /* Enable the timer while setting it to 32768 KHz and making it count up */ - timer_Control = TIMER1_ENABLE | TIMER1_32K | TIMER1_UP; - - /* Continue running until a key is pressed */ - do { - /* Calculate and print the elapsed time */ - float elapsed = (float)atomic_load_increasing_32(&timer_1_Counter) / 32768; - print(elapsed); - } while (!os_GetCSC()); - - /* Wait for a key press */ - while (!os_GetCSC()); -} +#include +#include +#include +#include + +#include +#include +#include + +/* Print a stopwatch value on the home screen */ +void print(float elapsed) { + /* Float format for printf may be unimplemented, so go through an OS real */ + real_t elapsed_real; + + /* Max stopwatch value is (2^32 - 1) / 32768 = 131072.00, */ + /* so create a buffer with room for 9 characters plus a null terminator */ + char str[10]; + + /* If the elapsed time is small enough that the OS would print it using */ + /* scientific notation, force it down to zero before conversion */ + elapsed_real = os_FloatToReal(elapsed <= 0.001f ? 0.0f : elapsed); + + /* Convert the elapsed time real to a string */ + os_RealToStr(str, &elapsed_real, 8, 1, 2); + + /* Print the string */ + os_SetCursorPos(0, 0); + os_PutStrFull(str); +} + +/* Put all your code here */ +void main(void) { + /* Clear the homescreen */ + os_ClrHome(); + + /* Display an initial time of zero */ + print(0.0f); + + /* Disable the timer */ + timer_Control = TIMER1_DISABLE; + + /* Reset the timer's counter */ + timer_1_Counter = 0; + + /* Wait for a key press */ + while (!os_GetCSC()); + + /* Enable the timer while setting it to 32768 KHz and making it count up */ + timer_Control = TIMER1_ENABLE | TIMER1_32K | TIMER1_UP; + + /* Continue running until a key is pressed */ + do { + /* Calculate and print the elapsed time */ + float elapsed = (float)atomic_load_increasing_32(&timer_1_Counter) / 32768; + print(elapsed); + } while (!os_GetCSC()); + + /* Wait for a key press */ + while (!os_GetCSC()); +} -- cgit v1.2.3-101-g0448