S&B Volcano vaporizer remote control with Pi Pico W
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

CMakeLists.txt 8.1KB

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