Changeset - 755225bf1731
[Not reviewed]
default
0 4 0
Ethan Zonca - 8 months ago 2024-09-29 20:02:43
ez@ethanzonca.com
Add discovery message TX. Add unused nonvolatile flash saving.
4 files changed with 25 insertions and 11 deletions:
0 comments (0 inline, 0 general)
components/esp-osc/esp_osc.c
Show inline comments
 
@@ -79,7 +79,7 @@ bool esp_osc_send_v(esp_osc_client_t *cl
 
    return false;
 
  }
 
  else{
 
    ESP_LOGI(TAG, "sent message OK");
 
    // ESP_LOGI(TAG, "sent message OK");
 
  }
 

	
 
  return true;
main/CMakeLists.txt
Show inline comments
 
idf_component_register(SRCS "main.c" "wifi.c" "usb_cdc.c" "can.c" "display.c" "display_gui.c" "osc_control.c" "ledstrip.c" "squeeze.c"
 
idf_component_register(SRCS "main.c" "wifi.c" "usb_cdc.c" "can.c" "display.c" "display_gui.c" "osc_control.c" "ledstrip.c" "squeeze.c" "flash.c"
 
                       INCLUDE_DIRS .)
main/main.c
Show inline comments
 
@@ -9,7 +9,7 @@
 
#include "esp_system.h"
 
#include "esp_event.h"
 
#include "esp_log.h"
 
#include "nvs_flash.h"
 
#include "flash.h"
 
#include "sdkconfig.h"
 
#include "osc_control.h"
 
#include "wifi.h"
 
@@ -24,7 +24,6 @@
 
// Private variables
 
static const char *TAG = "main";
 

	
 

	
 
// Application entry point
 
void app_main(void)
 
{
 
@@ -32,12 +31,18 @@ void app_main(void)
 
    // usb_cdc_init();
 

	
 
    // Initialize NVS
 
    esp_err_t ret = nvs_flash_init();
 
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
 
        ESP_ERROR_CHECK(nvs_flash_erase());
 
        ret = nvs_flash_init();
 
    }
 
    ESP_ERROR_CHECK(ret);
 
    // esp_err_t ret = nvs_flash_init();
 
    // if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
 
    //     ESP_ERROR_CHECK(nvs_flash_erase());
 
    //     ret = nvs_flash_init();
 
    // }
 
    // ESP_ERROR_CHECK(ret);
 

	
 
    flash_init();
 
    int32_t cnt = flash_read("count");
 
    cnt += 1;
 
    flash_write("count", cnt);
 

	
 

	
 
    // Initialize display
 
    display_init();
 
@@ -64,6 +69,8 @@ void app_main(void)
 

	
 
    while(1)
 
    {
 
        // ESP_LOGI(TAG, "cnt=%ld\n", cnt);
 

	
 
        vTaskDelay(pdMS_TO_TICKS(100));
 
    }
 

	
main/osc_control.c
Show inline comments
 
@@ -148,6 +148,7 @@ static void osc_send()
 
    vTaskDelay(pdMS_TO_TICKS(2000));
 

	
 
  uint32_t last_tx = 0;
 
  uint32_t last_discover = 0;
 

	
 
  for (;;) {
 

	
 
@@ -165,12 +166,18 @@ static void osc_send()
 
      esp_osc_send(&client, &target, "/squeeze_value", "f", squeeze_value());
 
    }
 

	
 
    if(xTaskGetTickCount()*portTICK_PERIOD_MS - last_discover > 1000)
 
    {
 
      last_discover = xTaskGetTickCount() * portTICK_PERIOD_MS;
 
      esp_osc_send(&client, &target, "/discover", "s", "ledstrip");
 
    }
 

	
 
    vTaskDelay(pdMS_TO_TICKS(10));
 
  }
 
}
 

	
 
void osc_init() {
 
  esp_osc_init(&client, 1024, 5005);
 
  esp_osc_init(&client, 1024, 5000);
 

	
 
  xTaskCreatePinnedToCore(osc_process, "osc_process", 1024*8, NULL, 10, NULL, 1);
 
  xTaskCreatePinnedToCore(osc_send, "osc_send", 1024*4, NULL, 10, NULL, 1);
0 comments (0 inline, 0 general)