Skip to content

Commit

Permalink
Add text IO support Pico.
Browse files Browse the repository at this point in the history
Edit CMakeLists.txt to enable disable the communication port.
  • Loading branch information
suikan4github committed Oct 25, 2024
1 parent bfdf998 commit db3646c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 5 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @copyright Copyright (c) 2022
*
*/
#if __has_include(<hardware/gpio.h>)
#if __has_include(<hardware/stdlib.h>)
#include <pico/stdlib.h>
#else
#include <stdlib.h>
Expand All @@ -26,6 +26,10 @@
int main() {
Calc calc;

#if __has_include(<hardware/stdlib.h>)
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));
Expand Down

0 comments on commit db3646c

Please sign in to comment.