S&B Volcano vaporizer remote control with Pi Pico W
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. src/wifi.c
  91. src/venty.c
  92. src/state_venty.c
  93. src/state_wifi.c
  94. src/state_wifi_edit.c
  95. src/state_string.c
  96. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ff.c
  97. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ffunicode.c
  98. st7789/src/driver_st7789.c
  99. mcufont/decoder/mf_encoding.c
  100. mcufont/decoder/mf_font.c
  101. mcufont/decoder/mf_justify.c
  102. mcufont/decoder/mf_kerning.c
  103. mcufont/decoder/mf_rlefont.c
  104. mcufont/decoder/mf_bwfont.c
  105. mcufont/decoder/mf_scaledfont.c
  106. mcufont/decoder/mf_wordwrap.c
  107. )
  108. # external dependency include directories
  109. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
  110. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/fatfs)
  111. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/st7789/src)
  112. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/st7789/interface)
  113. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/mcufont/decoder)
  114. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/data)
  115. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/build)
  116. # compress source code and stuff we want to include
  117. add_custom_target(pack bash -c "./pack_data.sh"
  118. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  119. BYPRODUCTS "build/pack_data.h"
  120. )
  121. add_dependencies(gadget pack)
  122. # enable generous warnings
  123. target_compile_options(gadget PUBLIC
  124. -Wall
  125. -Wextra
  126. -Werror
  127. )
  128. # suppress some warnings for borked 3rd party files in Pico SDK
  129. set_source_files_properties(pico-sdk/lib/btstack/src/ble/sm.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  130. set_source_files_properties(pico-sdk/lib/btstack/src/btstack_hid_parser.c PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
  131. set_source_files_properties(pico-sdk/src/rp2_common/pico_cyw43_driver/cyw43_driver.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  132. set_source_files_properties(pico-sdk/lib/btstack/src/classic/avdtp_util.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  133. set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_client.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  134. set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_server.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  135. # pull in common dependencies
  136. target_link_libraries(gadget
  137. pico_stdlib
  138. pico_unique_id
  139. tinyusb_device
  140. tinyusb_board
  141. hardware_spi
  142. hardware_adc
  143. hardware_gpio
  144. hardware_pwm
  145. pico_btstack_ble
  146. pico_btstack_cyw43
  147. pico_cyw43_arch_lwip_threadsafe_background
  148. hardware_flash
  149. pico_flash
  150. picowota_reboot
  151. )
  152. pico_set_linker_script(gadget ${CMAKE_CURRENT_SOURCE_DIR}/src/memmap_custom.ld)
  153. # fix for Errata RP2040-E5 (the fix requires use of GPIO 15)
  154. target_compile_definitions(gadget PUBLIC PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1)
  155. set(PICOWOTA_WIFI_SSID "WIFI_SSID_HERE")
  156. set(PICOWOTA_WIFI_PASS "WIFI_PASS_HERE")
  157. set(PICOWOTA_WIFI_AP 0)
  158. target_compile_definitions(gadget PUBLIC
  159. RUNNING_AS_CLIENT=1
  160. DEFAULT_WIFI_SSID="${PICOWOTA_WIFI_SSID}"
  161. DEFAULT_WIFI_PASS="${PICOWOTA_WIFI_PASS}"
  162. )
  163. add_subdirectory(picowota)
  164. picowota_build_combined(gadget)