Changeset - 45c4b4d15fc5
[Not reviewed]
default
0 4 0
Ethan Zonca - 8 months ago 2024-09-28 13:14:57
ez@ethanzonca.com
Add squeeze sensing. Update chase to only do one rep.
4 files changed with 22 insertions and 6 deletions:
0 comments (0 inline, 0 general)
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"
 
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"
 
                       INCLUDE_DIRS .)
main/ledstrip.c
Show inline comments
 
@@ -89,26 +89,31 @@ void ledstrip_refresh(void)
 
    {
 
      switch(current_effect)
 
      {
 

	
 
        case EFFECT_RAINBOW:
 
        {
 
          if(process_effect_rainbow() & 0x01)
 
            led_strip_refresh(led_strip);
 
        } break;
 
        
 
        case EFFECT_SINGLECHASE:
 
        {
 
          if(process_effect_singlechase() & 0x01)
 
          uint8_t ret = process_effect_singlechase();
 
          if(ret & 0x01)
 
            led_strip_refresh(led_strip);
 
          // Chase complete, return to manual mode
 
          if(ret & 0x02)
 
            current_effect = EFFECT_NONE;
 

	
 
        } break;
 

	
 
        case EFFECT_CAULDRON:
 
        {
 
          if(process_effect_cauldron() & 0x01)
 
            led_strip_refresh(led_strip);
 
        } break;
 

	
 
        case EFFECT_NONE:
 
        default:
 
        {
 
          ledstrip_set(10,10,10);
 
@@ -184,25 +189,28 @@ static uint8_t process_effect_singlechas
 

	
 
  float intensity = (float)countloc / (float)LED_STRIP_NUM_LEDS;
 
  for(uint16_t j=0;j<LED_STRIP_NUM_LEDS;j++) {
 
    if(j == countloc)
 
    {
 
      ESP_ERROR_CHECK(led_strip_set_pixel(led_strip, j, 255, 255 * (1.0-intensity), 255 * (1.0-intensity)));
 
    }
 
    else
 
      ESP_ERROR_CHECK(led_strip_set_pixel(led_strip, j, 0,0,0));
 
  }
 
  countloc = (countloc + 1) % LED_STRIP_NUM_LEDS;
 

	
 
  return 0x01;
 
  if(countloc == 0)
 
    return 0b11;
 
  else
 
    return 0b01;
 
}
 

	
 

	
 

	
 

	
 
//127, 122
 

	
 
// static uint32_t countloc = 0;
 
float intensity = 1.0f;
 
uint8_t intensity_up = 0;
 
uint8_t modmod = 0;
 
uint32_t last_modmod = 0;
main/main.c
Show inline comments
 
@@ -7,24 +7,25 @@
 
#include "freertos/task.h"
 
#include "freertos/event_groups.h"
 
#include "esp_system.h"
 
#include "esp_event.h"
 
#include "esp_log.h"
 
#include "nvs_flash.h"
 
#include "sdkconfig.h"
 
#include "osc_control.h"
 
#include "wifi.h"
 
// #include "usb_cdc.h"
 
#include "can.h"
 
#include "display.h"
 
#include "squeeze.h"
 
#include "ledstrip.h"
 
#include "display_gui.h"
 

	
 

	
 
// Private variables
 
static const char *TAG = "main";
 

	
 

	
 
// Application entry point
 
void app_main(void)
 
{
 
    // Initialize usb-cdc interface
 
@@ -42,24 +43,25 @@ void app_main(void)
 
    display_init();
 
    display_gui_homescreen();
 

	
 
    // Connect to wifi
 
    wifi_init();
 

	
 
    ledstrip_init();
 

	
 

	
 
    // Initialize OSC
 
    osc_init();
 

	
 
    squeeze_init();
 

	
 
    // Initialize canbus
 
    //can_init();
 

	
 
    // Start tasks
 
    xTaskCreatePinnedToCore(ledstrip_refresh,    "ledstrip_refresh", 4096, NULL, 10, NULL, 1);
 
    xTaskCreatePinnedToCore(display_gui_process, "display_gui_process", 4096, NULL, 10, NULL, 1);
 

	
 

	
 
    while(1)
 
    {
 
        vTaskDelay(pdMS_TO_TICKS(100));
main/osc_control.c
Show inline comments
 
@@ -62,44 +62,50 @@ static bool callback(const char *topic, 
 
        {
 
          ledstrip_set_effect(values[i].i);
 
        }
 
      } break;
 

	
 
      case 'h':
 
      {
 
        ESP_LOGI(TAG, "==> h: %lld", values[i].h);
 
      }  break;
 

	
 
      case 'f':
 
      {
 
        if(values[i].f > 1.0)
 
          values[i].f = 1.0;
 
        if(values[i].f < 0.0)
 
          values[i].f = 0.0;
 

	
 
        snprintf(out+strlen(out), 128-strlen(out), "Value: %f", values[i].f);
 
        ESP_LOGI(TAG, "==> f: %f", values[i].f);
 
        
 
        if(strcmp(topic, "/led_modifier") == 0)
 
        {
 
          ledstrip_set_modifier(values[i].f);
 
        }
 
        else if(strcmp(topic, "/led_manual_r") == 0)
 
        {
 
          r_man = values[i].f * 255.0;
 
          ledstrip_set(r_man, g_man, b_man);
 
          ledstrip_set(g_man, r_man, b_man);
 
        }
 
        else if(strcmp(topic, "/led_manual_g") == 0)
 
        {
 
          g_man = values[i].f * 255.0;
 
          ledstrip_set(r_man, g_man, b_man);
 
          ledstrip_set(g_man, r_man, b_man);
 
        }
 
        else if(strcmp(topic, "/led_manual_b") == 0)
 
        {
 
          b_man = values[i].f * 255.0;
 
          ledstrip_set(r_man, g_man, b_man);
 
          ledstrip_set(g_man, r_man, b_man);
 
        }
 
      } break;
 

	
 
      case 'd':
 
      {
 
        ESP_LOGI(TAG, "==> d: %f", values[i].d);
 
      } break;
 

	
 
      case 's':
 
      {
 
        ESP_LOGI(TAG, "==> s: %s", values[i].s);
 
      }  break;
0 comments (0 inline, 0 general)