From db3646c619a7f691ad4abd4cf20e2dc8f688f7af Mon Sep 17 00:00:00 2001 From: Seiichi <26223147+suikan4github@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:10:03 +0900 Subject: [PATCH] Add text IO support Pico. Edit CMakeLists.txt to enable disable the communication port. --- src/CMakeLists.txt | 5 +++++ src/main.cpp | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0040a03..bef9dc7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,11 @@ if(NOT(${WIN32}) AND NOT (${UNIX})) # Is Target Pico? # create map/bin/hex/uf2 file etc. pico_add_extra_outputs(${PROJECT_NAME}) + + # enable usb output, disable uart output + pico_enable_stdio_usb(${PROJECT_NAME} 1) # 1 enable, 0 disable + pico_enable_stdio_uart(${PROJECT_NAME} 0) # 1 enable, 0 disable + endif() # (NOT(${WIN32}) AND NOT (${UNIX})) add_subdirectory(lib) diff --git a/src/main.cpp b/src/main.cpp index 5148926..908fc93 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2022 * */ -#if __has_include() +#if __has_include() #include #else #include @@ -26,6 +26,10 @@ int main() { Calc calc; +#if __has_include() + stdio_init_all(); +#endif + // count from 1 to num for (int i = 1; i <= 10; i++) printf("[CalcSqrt] The square root of %d is %f \n", i, calc.sqrt(i));