From 5a1638986fa5f613f147963e956643a996e0fcc2 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Wed, 3 May 2023 22:56:59 +0200 Subject: [PATCH] examples/embedding-full: Enable floating point numbers and math module. Signed-off-by: Christian Walther --- examples/embedding-full/Makefile | 2 +- examples/embedding-full/main.c | 4 +++- examples/embedding-full/mpconfigport.h | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/embedding-full/Makefile b/examples/embedding-full/Makefile index b0ce3daf14..abdf8866e0 100644 --- a/examples/embedding-full/Makefile +++ b/examples/embedding-full/Makefile @@ -22,7 +22,7 @@ SRC += $(filter-out $(EMBED_DIR)/lib/%.c,$(wildcard $(EMBED_DIR)/*/*/*.c)) OBJ += $(SRC:.c=.o) $(PROG): $(OBJ) - $(CC) -o $@ $^ + $(CC) -o $@ $^ -lm clean: /bin/rm -f $(OBJ) $(PROG) diff --git a/examples/embedding-full/main.c b/examples/embedding-full/main.c index 5fc31ec638..457af0b24e 100644 --- a/examples/embedding-full/main.c +++ b/examples/embedding-full/main.c @@ -8,7 +8,7 @@ // This is example 1 script, which will be compiled and executed. static const char *example_1 = - "print('hello world!', list(x + 1 for x in range(10)), end='eol\\n')"; + "print('hello world!', list(x + 1.5 for x in range(10)), end='eol\\n')"; // This is example 2 script, which will be compiled and executed. static const char *example_2 = @@ -35,6 +35,8 @@ static const char *example_2 = "help(random)\n" "import time\n" "help(time)\n" + "import math\n" + "help(math)\n" "import frozenhello\n" "help(frozenhello)\n" "print('frozenhello.hello():', frozenhello.hello())\n" diff --git a/examples/embedding-full/mpconfigport.h b/examples/embedding-full/mpconfigport.h index 103172687a..2678c722b8 100644 --- a/examples/embedding-full/mpconfigport.h +++ b/examples/embedding-full/mpconfigport.h @@ -19,6 +19,9 @@ #define MICROPY_HW_BOARD_NAME "embedded" #define MICROPY_HW_MCU_NAME "C" +// Enable floating point numbers and the math module. +#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) + // Requires shared/readline/readline.h, don't bother as we have no input. #define MICROPY_PY_BUILTINS_INPUT (0)