diff --git a/CMakeLists.txt b/CMakeLists.txt index 44a33927..84295fad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,4 +14,4 @@ add_subdirectory(drivers) add_subdirectory(libraries) # Example Pico Pack projects -add_subdirectory(pack) +add_subdirectory(examples) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 00000000..6c27cf82 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(pico_display) +add_subdirectory(pico_unicorn) \ No newline at end of file diff --git a/pack/display/CMakeLists.txt b/examples/pico_display/CMakeLists.txt similarity index 68% rename from pack/display/CMakeLists.txt rename to examples/pico_display/CMakeLists.txt index 984a17cd..38bb1c11 100644 --- a/pack/display/CMakeLists.txt +++ b/examples/pico_display/CMakeLists.txt @@ -2,11 +2,10 @@ add_executable( display demo.cpp image_data.cpp - pico_display.cpp ) # Pull in pico libraries that we need -target_link_libraries(display pico_stdlib hardware_spi hardware_pwm hardware_dma st7789 pico_graphics) +target_link_libraries(display pico_stdlib hardware_spi hardware_pwm hardware_dma pico_display) # create map/bin/hex file etc. pico_add_extra_outputs(display) \ No newline at end of file diff --git a/pack/display/demo.cpp b/examples/pico_display/demo.cpp similarity index 100% rename from pack/display/demo.cpp rename to examples/pico_display/demo.cpp diff --git a/pack/display/image_data.cpp b/examples/pico_display/image_data.cpp similarity index 100% rename from pack/display/image_data.cpp rename to examples/pico_display/image_data.cpp diff --git a/examples/pico_unicorn/CMakeLists.txt b/examples/pico_unicorn/CMakeLists.txt new file mode 100644 index 00000000..bdc84672 --- /dev/null +++ b/examples/pico_unicorn/CMakeLists.txt @@ -0,0 +1,10 @@ +add_executable( + unicorn + demo.cpp +) + +# Pull in pico libraries that we need +target_link_libraries(unicorn pico_stdlib hardware_pio hardware_dma pico_unicorn) + +# create map/bin/hex file etc. +pico_add_extra_outputs(unicorn) diff --git a/pack/unicorn/demo.cpp b/examples/pico_unicorn/demo.cpp similarity index 100% rename from pack/unicorn/demo.cpp rename to examples/pico_unicorn/demo.cpp diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 4da78a71..dc32b7e9 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -1 +1,3 @@ -add_subdirectory(pico_graphics) \ No newline at end of file +add_subdirectory(pico_graphics) +add_subdirectory(pico_display) +add_subdirectory(pico_unicorn) \ No newline at end of file diff --git a/libraries/pico_display/CMakeLists.txt b/libraries/pico_display/CMakeLists.txt new file mode 100644 index 00000000..78a46a8c --- /dev/null +++ b/libraries/pico_display/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(pico_display INTERFACE) + +target_sources(pico_display INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/pico_display.cpp +) + +target_include_directories(pico_display INTERFACE ${CMAKE_CURRENT_LIST_DIR}) + +# Pull in pico libraries that we need +target_link_libraries(pico_display INTERFACE pico_stdlib hardware_spi hardware_pwm hardware_dma st7789 pico_graphics) \ No newline at end of file diff --git a/pack/display/pico_display.cpp b/libraries/pico_display/pico_display.cpp similarity index 100% rename from pack/display/pico_display.cpp rename to libraries/pico_display/pico_display.cpp diff --git a/pack/display/pico_display.hpp b/libraries/pico_display/pico_display.hpp similarity index 100% rename from pack/display/pico_display.hpp rename to libraries/pico_display/pico_display.hpp diff --git a/libraries/pico_unicorn/CMakeLists.txt b/libraries/pico_unicorn/CMakeLists.txt new file mode 100644 index 00000000..fd2a3c5c --- /dev/null +++ b/libraries/pico_unicorn/CMakeLists.txt @@ -0,0 +1,12 @@ +add_library(pico_unicorn INTERFACE) + +pico_generate_pio_header(pico_unicorn ${CMAKE_CURRENT_LIST_DIR}/pico_unicorn.pio) + +target_sources(pico_unicorn INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/pico_unicorn.cpp +) + +target_include_directories(pico_unicorn INTERFACE ${CMAKE_CURRENT_LIST_DIR}) + +# Pull in pico libraries that we need +target_link_libraries(pico_unicorn INTERFACE pico_stdlib hardware_pio hardware_dma) diff --git a/pack/unicorn/pico_unicorn.cpp b/libraries/pico_unicorn/pico_unicorn.cpp similarity index 96% rename from pack/unicorn/pico_unicorn.cpp rename to libraries/pico_unicorn/pico_unicorn.cpp index 84482991..5f9901c6 100644 --- a/pack/unicorn/pico_unicorn.cpp +++ b/libraries/pico_unicorn/pico_unicorn.cpp @@ -3,7 +3,7 @@ #include "hardware/dma.h" #include "hardware/irq.h" -#include "unicorn.pio.h" +#include "pico_unicorn.pio.h" #include "pico_unicorn.hpp" // pixel data is stored as a stream of bits delivered in the diff --git a/pack/unicorn/pico_unicorn.hpp b/libraries/pico_unicorn/pico_unicorn.hpp similarity index 100% rename from pack/unicorn/pico_unicorn.hpp rename to libraries/pico_unicorn/pico_unicorn.hpp diff --git a/pack/unicorn/unicorn.pio b/libraries/pico_unicorn/pico_unicorn.pio similarity index 100% rename from pack/unicorn/unicorn.pio rename to libraries/pico_unicorn/pico_unicorn.pio diff --git a/pack/CMakeLists.txt b/pack/CMakeLists.txt deleted file mode 100644 index a48803ae..00000000 --- a/pack/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -if (NOT PICO_NO_HARDWARE) - add_subdirectory(display) - add_subdirectory(unicorn) -endif () diff --git a/pack/unicorn/CMakeLists.txt b/pack/unicorn/CMakeLists.txt deleted file mode 100644 index 501e399f..00000000 --- a/pack/unicorn/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required(VERSION 3.12) - -# Pull in PICO SDK (must be before project) -include(pico_sdk_import.cmake) - -project(pico_examples C CXX ASM) -set(CMAKE_C_STANDARD 11) -set(CMAKE_CXX_STANDARD 17) - -# Initialize the SDK -pico_sdk_init() - -add_executable( - unicorn - demo.cpp - pico_unicorn.cpp -) - -pico_generate_pio_header(unicorn ${CMAKE_CURRENT_LIST_DIR}/unicorn.pio) - -# Pull in pico libraries that we need -target_link_libraries(unicorn pico_stdlib hardware_pio hardware_dma) - -# create map/bin/hex file etc. -pico_add_extra_outputs(unicorn) diff --git a/pack/unicorn/pico_sdk_import.cmake b/pack/unicorn/pico_sdk_import.cmake deleted file mode 100644 index f63ee3f8..00000000 --- a/pack/unicorn/pico_sdk_import.cmake +++ /dev/null @@ -1,64 +0,0 @@ -# This is a copy of /external/pico_sdk_import.cmake - -# This can be dropped into an external project to help locate this SDK -# It should be include()ed prior to project() - -# todo document - -if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) - set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) - message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") -endif () - -if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT)) - set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT}) - message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')") -endif () - -if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH)) - set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH}) - message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") -endif () - -set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the PICO SDK") -set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of PICO SDK from git if not otherwise locatable") -set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") - -if (NOT PICO_SDK_PATH) - if (PICO_SDK_FETCH_FROM_GIT) - include(FetchContent) - set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) - if (PICO_SDK_FETCH_FROM_GIT_PATH) - get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") - endif () - FetchContent_Declare( - pico_sdk - GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk - GIT_TAG master - ) - if (NOT pico_sdk) - message("Downloading PICO SDK") - FetchContent_Populate(pico_sdk) - set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) - endif () - set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) - else () - message(FATAL_ERROR - "PICO SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." - ) - endif () -endif () - -get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") -if (NOT EXISTS ${PICO_SDK_PATH}) - message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found") -endif () - -set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) -if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) - message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the PICO SDK") -endif () - -set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the PICO SDK" FORCE) - -include(${PICO_SDK_INIT_CMAKE_FILE})