Mathematica-like environment on the mbed using USB keyboard input, VGA output, and a thermal printer.
Dependencies: mbed Thermal 4DGL-uLCD-SE USBHost_Modified uVGAIII
Diff: main.cpp
- Revision:
- 6:646d22295054
- Parent:
- 4:b79d152dec32
diff -r 1cbfc69d87b5 -r 646d22295054 main.cpp --- a/main.cpp Thu Dec 13 19:28:26 2018 +0000 +++ b/main.cpp Thu Dec 13 20:27:21 2018 +0000 @@ -4,6 +4,9 @@ #include "USBHostKeyboard.h" #include "uVGAIII.h" +extern "C" struct node* scanner(const char* es); +extern "C" float eval_expr(struct node* node, float x_value); + #include <math.h> #define SIZE_X 480 @@ -200,6 +203,10 @@ printer.printf(currentLine); printer.feed(2); + struct node* expr = scanner(currentLine); + float val = eval_expr(expr, 3.0); + uLCD.printf("Evaluate: %f \n",val); + for(size_t i = 0; i < 48; i++) { currentLine[i] = NULL; } @@ -308,6 +315,10 @@ ecran.puts("Ready!"); VGA_Lock.unlock(); + static const char es[] = "1 + 2 ^ 3 * 4 + 5 * x"; + struct node* expr = scanner(es); + float val = eval_expr(expr, 3.0); + while(1) { led=!led; Thread::wait(600); // Wait .6s in main thread