From 721a69e6cd43c91bbaf1a67833afb530bdec9a20 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Thu, 3 Jul 2025 18:35:21 +0200 Subject: [PATCH] put wifi and server config in a separate file --- pico/src/main.c | 14 ++++++-------- pico/src/wifi_cred.h | 8 ++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 pico/src/wifi_cred.h diff --git a/pico/src/main.c b/pico/src/main.c index e40c4e9..34ba1e5 100644 --- a/pico/src/main.c +++ b/pico/src/main.c @@ -3,20 +3,19 @@ #include "pico/cyw43_arch.h" #include "pico/cyw43_driver.h" #include "hardware/adc.h" - #include "lwip/tcp.h" -#include "lwip/apps/http_client.h" + +#include "wifi_cred.h" #define u32 uint32_t #define u16 uint16_t #define u8 uint8_t -char ssid[] = "TODO"; -char pass[] = "secret"; - -const ip_addr_t SERVER_IP = IPADDR4_INIT_BYTES(192, 168, 0, 108); -#define SERVER_PORT 25564 +char ssid[] = CONFIG_WIFI_SSID; +char pass[] = CONFIG_WIFI_PASSWORD; +const ip_addr_t SERVER_IP = CONFIG_SERVER_IP; +#define SERVER_PORT CONFIG_SERVER_PORT #define SET_LED(state) cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, state) @@ -80,7 +79,6 @@ void update_encoder_value() { rotary_encoder_bits |= !rotary_encoder_bit[b]; // inverse to make white = 0 } - // const u8 reverse_gray_code[1 << ENCODER_BITS] = {0, 1, 3, 2, 7, 6, 4, 5}; // gray code: 0 1 5 7 3 2 6 4 // index: 0 1 2 3 4 5 6 7 // reverse : 0 1 5 4 7 2 6 3 diff --git a/pico/src/wifi_cred.h b/pico/src/wifi_cred.h new file mode 100644 index 0000000..df80bbd --- /dev/null +++ b/pico/src/wifi_cred.h @@ -0,0 +1,8 @@ + +#define CONFIG_WIFI_SSID "Wifi network here" +#define CONFIG_WIFI_PASSWORD "password123" + +// local IP of the computer running the server software +// public IP would work too but requires port forwarding +#define CONFIG_SERVER_IP IPADDR4_INIT_BYTES(192, 168, 0, 108) +#define CONFIG_SERVER_PORT 13122