S&B Volcano vaporizer remote control with Pi Pico W
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. # ----------------------------------------------------------------------------
  2. # Copyright (c) 2023 Thomas Buck (thomas@xythobuz.de)
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # See <http://www.gnu.org/licenses/>.
  15. # ----------------------------------------------------------------------------
  16. cmake_minimum_required(VERSION 3.13)
  17. # build MCUFont encoder host tool and convert included example fonts
  18. execute_process(COMMAND make
  19. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/encoder
  20. )
  21. execute_process(COMMAND make
  22. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/fonts
  23. )
  24. # initialize pico-sdk from submodule
  25. include(pico-sdk/pico_sdk_init.cmake)
  26. project(gadget C CXX)
  27. set(CMAKE_C_STANDARD 11)
  28. set(CMAKE_CXX_STANDARD 17)
  29. # initialize the Raspberry Pi Pico SDK
  30. pico_sdk_init()
  31. # copy FatFS source files to build dir, so we can use our own ffconf.h
  32. configure_file(
  33. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/ff.c
  34. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ff.c
  35. COPYONLY
  36. )
  37. configure_file(
  38. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/ff.h
  39. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ff.h
  40. COPYONLY
  41. )
  42. configure_file(
  43. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/diskio.h
  44. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/diskio.h
  45. COPYONLY
  46. )
  47. configure_file(
  48. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/ffunicode.c
  49. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ffunicode.c
  50. COPYONLY
  51. )
  52. add_executable(gadget)
  53. target_sources(gadget PUBLIC
  54. src/main.c
  55. src/console.c
  56. src/log.c
  57. src/util.c
  58. src/usb.c
  59. src/usb_cdc.c
  60. src/usb_descriptors.c
  61. src/usb_msc.c
  62. src/fat_disk.c
  63. src/debug_disk.c
  64. src/buttons.c
  65. src/lipo.c
  66. src/ble.c
  67. src/lcd.c
  68. src/text.c
  69. src/image.c
  70. src/state.c
  71. src/volcano.c
  72. src/serial.c
  73. src/ring.c
  74. src/models.c
  75. src/state_scan.c
  76. src/workflow.c
  77. src/menu.c
  78. src/state_workflow.c
  79. src/state_volcano_run.c
  80. src/crafty.c
  81. src/state_crafty.c
  82. src/mem.c
  83. src/state_edit_workflow.c
  84. src/workflow_default.c
  85. src/state_settings.c
  86. src/state_about.c
  87. src/state_value.c
  88. src/textbox.c
  89. src/state_volcano_conf.c
  90. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ff.c
  91. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ffunicode.c
  92. st7789/src/driver_st7789.c
  93. mcufont/decoder/mf_encoding.c
  94. mcufont/decoder/mf_font.c
  95. mcufont/decoder/mf_justify.c
  96. mcufont/decoder/mf_kerning.c
  97. mcufont/decoder/mf_rlefont.c
  98. mcufont/decoder/mf_bwfont.c
  99. mcufont/decoder/mf_scaledfont.c
  100. mcufont/decoder/mf_wordwrap.c
  101. )
  102. # external dependency include directories
  103. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
  104. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/fatfs)
  105. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/st7789/src)
  106. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/st7789/interface)
  107. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/mcufont/decoder)
  108. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/mcufont/fonts)
  109. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/build)
  110. # compress source code and stuff we want to include
  111. add_custom_target(pack bash -c "./pack_data.sh"
  112. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  113. BYPRODUCTS "build/pack_data.h"
  114. )
  115. add_dependencies(gadget pack)
  116. # enable generous warnings
  117. target_compile_options(gadget PUBLIC
  118. -Wall
  119. -Wextra
  120. -Werror
  121. )
  122. # suppress some warnings for borked 3rd party files in Pico SDK
  123. set_source_files_properties(pico-sdk/lib/btstack/src/ble/sm.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  124. set_source_files_properties(pico-sdk/lib/btstack/src/btstack_hid_parser.c PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
  125. set_source_files_properties(pico-sdk/src/rp2_common/pico_cyw43_driver/cyw43_driver.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  126. set_source_files_properties(pico-sdk/lib/btstack/src/classic/avdtp_util.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  127. set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_client.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  128. set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_server.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  129. # pull in common dependencies
  130. target_link_libraries(gadget
  131. pico_stdlib
  132. pico_unique_id
  133. tinyusb_device
  134. tinyusb_board
  135. hardware_spi
  136. hardware_adc
  137. hardware_gpio
  138. hardware_pwm
  139. pico_btstack_ble
  140. pico_btstack_cyw43
  141. pico_cyw43_arch_threadsafe_background
  142. hardware_flash
  143. pico_flash
  144. )
  145. target_compile_definitions(gadget PUBLIC
  146. RUNNING_AS_CLIENT=1
  147. CYW43_LWIP=0
  148. )
  149. pico_set_linker_script(gadget ${CMAKE_CURRENT_SOURCE_DIR}/src/memmap_custom.ld)
  150. # fix for Errata RP2040-E5 (the fix requires use of GPIO 15)
  151. target_compile_definitions(gadget PUBLIC PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1)
  152. # create map/bin/hex/uf2 file etc.
  153. pico_add_extra_outputs(gadget)