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.

main.c 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * main.c
  3. *
  4. * Copyright (c) 2022 - 2023 Thomas Buck (thomas@xythobuz.de)
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * See <http://www.gnu.org/licenses/>.
  17. */
  18. #include "pico/stdlib.h"
  19. #include "pico/cyw43_arch.h"
  20. #include "hardware/watchdog.h"
  21. #include "hardware/adc.h"
  22. #include "config.h"
  23. #include "util.h"
  24. #include "console.h"
  25. #include "log.h"
  26. #include "usb.h"
  27. #include "fat_disk.h"
  28. #include "buttons.h"
  29. #include "ble.h"
  30. #include "lcd.h"
  31. #include "text.h"
  32. #include "image.h"
  33. int main(void) {
  34. // required for debug console
  35. cnsl_init();
  36. usb_init();
  37. debug("lcd_init");
  38. lcd_init();
  39. draw_splash();
  40. lcd_set_backlight(0x1000);
  41. if (watchdog_caused_reboot()) {
  42. debug("reset by watchdog");
  43. }
  44. debug("buttons_init");
  45. buttons_init();
  46. // required for LiPo voltage reading
  47. debug("adc_init");
  48. adc_init();
  49. // required for BLE and LiPo voltage reading
  50. debug("cyw43_arch_init");
  51. if (cyw43_arch_init()) {
  52. debug("cyw43_arch_init failed");
  53. }
  54. debug("heartbeat_init");
  55. heartbeat_init();
  56. debug("ble_init");
  57. ble_init();
  58. debug("fat_disk_init");
  59. fat_disk_init();
  60. // trigger after 1000ms
  61. watchdog_enable(1000, 1);
  62. debug("init done");
  63. lcd_set_backlight(0x8000);
  64. while (1) {
  65. watchdog_update();
  66. heartbeat_run();
  67. buttons_run();
  68. usb_run();
  69. cnsl_run();
  70. battery_run();
  71. }
  72. return 0;
  73. }