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.

CMakeLists.txt 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. # remove Options.h from BittyHTTP so we can use our own (TODO ugly)
  25. execute_process(COMMAND rm Options.h
  26. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/BittyHTTP/src
  27. )
  28. # initialize pico-sdk from submodule
  29. include(pico-sdk/pico_sdk_init.cmake)
  30. project(gadget C CXX)
  31. set(CMAKE_C_STANDARD 11)
  32. set(CMAKE_CXX_STANDARD 17)
  33. # initialize the Raspberry Pi Pico SDK
  34. pico_sdk_init()
  35. # copy FatFS source files to build dir, so we can use our own ffconf.h
  36. configure_file(
  37. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/ff.c
  38. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ff.c
  39. COPYONLY
  40. )
  41. configure_file(
  42. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/ff.h
  43. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ff.h
  44. COPYONLY
  45. )
  46. configure_file(
  47. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/diskio.h
  48. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/diskio.h
  49. COPYONLY
  50. )
  51. configure_file(
  52. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/ffunicode.c
  53. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ffunicode.c
  54. COPYONLY
  55. )
  56. add_executable(gadget)
  57. target_sources(gadget PUBLIC
  58. src/main.c
  59. src/console.c
  60. src/log.c
  61. src/util.c
  62. src/usb.c
  63. src/usb_cdc.c
  64. src/usb_descriptors.c
  65. src/usb_msc.c
  66. src/fat_disk.c
  67. src/debug_disk.c
  68. src/buttons.c
  69. src/lipo.c
  70. src/ble.c
  71. src/lcd.c
  72. src/text.c
  73. src/image.c
  74. src/state.c
  75. src/volcano.c
  76. src/serial.c
  77. src/ring.c
  78. src/models.c
  79. src/state_scan.c
  80. src/workflow.c
  81. src/menu.c
  82. src/state_workflow.c
  83. src/state_volcano_run.c
  84. src/crafty.c
  85. src/state_crafty.c
  86. src/mem.c
  87. src/state_edit_workflow.c
  88. src/workflow_default.c
  89. src/state_settings.c
  90. src/state_about.c
  91. src/state_value.c
  92. src/textbox.c
  93. src/state_volcano_conf.c
  94. src/wifi.c
  95. src/venty.c
  96. src/state_venty.c
  97. src/state_wifi.c
  98. src/state_wifi_edit.c
  99. src/state_string.c
  100. src/http.c
  101. src/http_socket.c
  102. src/http_files.c
  103. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ff.c
  104. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ffunicode.c
  105. st7789/src/driver_st7789.c
  106. mcufont/decoder/mf_encoding.c
  107. mcufont/decoder/mf_font.c
  108. mcufont/decoder/mf_justify.c
  109. mcufont/decoder/mf_kerning.c
  110. mcufont/decoder/mf_rlefont.c
  111. mcufont/decoder/mf_bwfont.c
  112. mcufont/decoder/mf_scaledfont.c
  113. mcufont/decoder/mf_wordwrap.c
  114. BittyHTTP/src/WebServer.c
  115. )
  116. # external dependency include directories
  117. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/conf)
  118. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
  119. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/fatfs)
  120. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/st7789/src)
  121. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/st7789/interface)
  122. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/mcufont/decoder)
  123. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/data)
  124. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/build)
  125. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/BittyHTTP/src)
  126. # compress source code and stuff we want to include
  127. add_custom_target(pack bash -c "./pack_data.sh"
  128. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  129. BYPRODUCTS "build/pack_data.h"
  130. )
  131. add_dependencies(gadget pack)
  132. # enable generous warnings
  133. target_compile_options(gadget PUBLIC
  134. -Wall
  135. -Wextra
  136. -Werror
  137. )
  138. # suppress some warnings for borked 3rd party files in Pico SDK
  139. set_source_files_properties(pico-sdk/lib/btstack/src/ble/sm.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  140. set_source_files_properties(pico-sdk/lib/btstack/src/btstack_hid_parser.c PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
  141. set_source_files_properties(pico-sdk/src/rp2_common/pico_cyw43_driver/cyw43_driver.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  142. set_source_files_properties(pico-sdk/lib/btstack/src/classic/avdtp_util.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  143. set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_client.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  144. set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_server.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  145. # suppress warnings for BittyHTTP
  146. set_source_files_properties(BittyHTTP/src/WebServer.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter -Wno-maybe-uninitialized")
  147. # pull in common dependencies
  148. target_link_libraries(gadget
  149. pico_stdlib
  150. pico_unique_id
  151. tinyusb_device
  152. tinyusb_board
  153. hardware_spi
  154. hardware_adc
  155. hardware_gpio
  156. hardware_pwm
  157. pico_btstack_ble
  158. pico_btstack_cyw43
  159. pico_cyw43_arch_lwip_threadsafe_background
  160. hardware_flash
  161. pico_flash
  162. picowota_reboot
  163. )
  164. pico_set_linker_script(gadget ${CMAKE_CURRENT_SOURCE_DIR}/conf/memmap_custom.ld)
  165. # fix for Errata RP2040-E5 (the fix requires use of GPIO 15)
  166. target_compile_definitions(gadget PUBLIC PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1)
  167. set(PICOWOTA_WIFI_SSID "WIFI_SSID_HERE")
  168. set(PICOWOTA_WIFI_PASS "WIFI_PASS_HERE")
  169. set(PICOWOTA_WIFI_AP 0)
  170. # TODO set DOCVER to hash of static http files?
  171. target_compile_definitions(gadget PUBLIC
  172. RUNNING_AS_CLIENT=1
  173. DEFAULT_WIFI_SSID="${PICOWOTA_WIFI_SSID}"
  174. DEFAULT_WIFI_PASS="${PICOWOTA_WIFI_PASS}"
  175. DOCVER="1.0.0.0"
  176. )
  177. add_subdirectory(picowota)
  178. picowota_build_combined(gadget)