Skip to content

Commit

Permalink
Feature/maxou/wormhole experiment (#71)
Browse files Browse the repository at this point in the history
* attempt to fix wifi
* small test .. + idf 5.1
* blackhole effect
* Wormhole address
* hell mode
* move fluid movements
* lower speed
  • Loading branch information
pinkymaxou authored Sep 17, 2023
1 parent 64a9c69 commit 6aa3145
Show file tree
Hide file tree
Showing 11 changed files with 1,899 additions and 1,690 deletions.
9 changes: 9 additions & 0 deletions Source/base-fw/dependencies.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
idf:
component_hash: null
source:
type: idf
version: 4.4.4
manifest_hash: dcf4d39b94252de130019eadceb989d72b0dbc26b552cfdcbb50f6da531d2b92
target: esp32
version: 1.0.0
2 changes: 1 addition & 1 deletion Source/base-fw/main/GPIO.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void GPIO_Init()
#endif

const int i2c_master_port = HWCONFIG_I2C_MASTER_NUM;
i2c_config_t conf;
i2c_config_t conf = {0};
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = HWCONFIG_I2C_SDA;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
Expand Down
18 changes: 11 additions & 7 deletions Source/base-fw/main/GateStepper.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,24 @@ static IRAM_ATTR void tmr_signal_callback(void* arg)
{
const int32_t s32 = MIN(abs(m_s32Count) , abs(m_s32Target - m_s32Count));

if (s32 < 100*2)
m_s32Period = 1500/2;
if (s32 < 50*2)
m_s32Period = 2000/2;
else if (s32 < 100*2)
m_s32Period = 1800/2;
else if (s32 < 200*2)
m_s32Period = 1250/2;
m_s32Period = 1600/2;
else if (s32 < 300*2)
m_s32Period = 1000/2;
m_s32Period = 1400/2;
else if (s32 < 400*2)
m_s32Period = 750/2;
m_s32Period = 1200/2;
else if (s32 < 500*2)
m_s32Period = 675/2;
m_s32Period = 1000/2;
else if (s32 < 600*2)
m_s32Period = 800/2;
else if (s32 < 700*2)
m_s32Period = 600/2;
else
m_s32Period = 500/2;
m_s32Period = 400/2;

// Count every two
m_s32Count++;
Expand Down
31 changes: 11 additions & 20 deletions Source/base-fw/main/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,12 @@ static void wifi_init_all(void)
NULL,
NULL));

wifi_config_t wifi_configAP = {
.ap = {
//.ssid = FWCONFIG_SOFTAP_WIFI_SSID,
//.ssid_len = strlen(FWCONFIG_SOFTAP_WIFI_SSID),
.channel = FWCONFIG_SOFTAP_WIFI_CHANNEL,
.password = FWCONFIG_SOFTAP_WIFI_PASS,
.max_connection = FWCONFIG_SOFTAP_MAX_CONN,
.authmode = WIFI_AUTH_WPA_WPA2_PSK
},
};
wifi_config_t wifi_configAP;
memset(&wifi_configAP, 0, sizeof(wifi_configAP));
//wifi_configAP.ap.channel = FWCONFIG_SOFTAP_WIFI_CHANNEL;
strcpy((char*)wifi_configAP.ap.password, FWCONFIG_SOFTAP_WIFI_PASS);
wifi_configAP.ap.max_connection = FWCONFIG_SOFTAP_MAX_CONN;
wifi_configAP.ap.authmode = WIFI_AUTH_WPA_WPA2_PSK;

uint8_t macAddr[6];
esp_read_mac(macAddr, ESP_MAC_WIFI_SOFTAP);
Expand Down Expand Up @@ -172,16 +168,11 @@ static void wifi_init_all(void)
NULL,
&instance_got_ip));

wifi_config_t wifi_configSTA = {
.sta = {
.threshold.authmode = WIFI_AUTH_WPA2_PSK,

.pmf_cfg = {
.capable = true,
.required = false
},
},
};
wifi_config_t wifi_configSTA;
memset(&wifi_configSTA, 0, sizeof(wifi_configSTA));
//wifi_configSTA.sta.threshold.authmode = WIFI_AUTH_OPEN;
wifi_configSTA.sta.threshold.authmode = WIFI_AUTH_WPA_PSK;
wifi_configSTA.sta.sae_pwe_h2e = WPA3_SAE_PWE_BOTH;

size_t staSSIDLength = 32;
NVSJSON_GetValueString(&g_sSettingHandle, SETTINGS_EENTRY_WSTASSID, (char*)wifi_configSTA.sta.ssid, &staSSIDLength);
Expand Down
113 changes: 72 additions & 41 deletions Source/base-fw/main/Wormhole.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,53 +91,84 @@ void WORMHOLE_Run(volatile bool* pIsCancelled)
SOUNDFX_WormholeIdling();
}

for(int i = 0; i < HWCONFIG_WORMHOLELEDS_LEDCOUNT; i++)
if (m_sArg.eType == WORMHOLE_ETYPE_Blackhole)
{
SLedEffect* psLedEffect = &m_sLedEffects[i];
static int32_t ix = 0;

// Not optimized at all, basically I'm testing many trick until I'm satisfied
const int d = GetRing(i);
float fFactor = 1.0f;
switch(d)
for(int ppp = 0; ppp < 3; ppp++)
{
case 3:
fFactor = 2.5f;
break;
case 2:
fFactor = 1.5f;
break;
case 1:
fFactor = 0.6f;
break;
case 0:
fFactor = 0.25f;
break;
int32_t ix2 = (ix + ppp*16) % HWCONFIG_WORMHOLELEDS_LEDCOUNT;

for(int j = 1; j < 5; j++)
{
int z = 85 - j*20;
int zzz = (ix2-j);
if (zzz < 0)
zzz = HWCONFIG_WORMHOLELEDS_LEDCOUNT + zzz;

GPIO_SetPixel(zzz, z, 0, z);
}

for(int j = 0; j < 5; j++)
{
int z = 85 - j*20;
GPIO_SetPixel( (ix2+j) % HWCONFIG_WORMHOLELEDS_LEDCOUNT, z, 0, z);
}
}
ix = (ix + 1) % HWCONFIG_WORMHOLELEDS_LEDCOUNT;


if (m_sArg.eType == WORMHOLE_ETYPE_NormalSGU)
GPIO_SetPixel(i, MIN(psLedEffect->fOne*u32MaxBrightness * fFactor, 255), MIN(psLedEffect->fOne*u32MaxBrightness * fFactor, 255), MIN(psLedEffect->fOne*u32MaxBrightness * fFactor, 255));
else if (m_sArg.eType == WORMHOLE_ETYPE_NormalSG1)
GPIO_SetPixel(i, MAX(psLedEffect->fOne*u32MaxBrightness * fFactor, 16), MAX(psLedEffect->fOne*u32MaxBrightness * fFactor, 16), 16+MIN(psLedEffect->fOne*u32MaxBrightness * fFactor, 255-16));
else if (m_sArg.eType == WORMHOLE_ETYPE_Hell)
GPIO_SetPixel(i, MIN(psLedEffect->fOne*u32MaxBrightness * fFactor, 255), 1, 1);

const float fInc = 0.005f + ( 0.01f * (esp_random() % 100) ) * 0.001f;

if (psLedEffect->bUp)
psLedEffect->fOne += fInc;
else
psLedEffect->fOne -= fInc;

if (psLedEffect->fOne >= maxF)
{
psLedEffect->fOne = maxF;
psLedEffect->bUp = false;
}
else if (psLedEffect->fOne <= minF)
GPIO_RefreshPixels();
vTaskDelay(pdMS_TO_TICKS(20));
}
else
{
for(int i = 0; i < HWCONFIG_WORMHOLELEDS_LEDCOUNT; i++)
{
psLedEffect->fOne = minF;
psLedEffect->bUp = true;
SLedEffect* psLedEffect = &m_sLedEffects[i];

// Not optimized at all, basically I'm testing many trick until I'm satisfied
const int d = GetRing(i);
float fFactor = 1.0f;
switch(d)
{
case 3:
fFactor = 2.5f;
break;
case 2:
fFactor = 1.5f;
break;
case 1:
fFactor = 0.6f;
break;
case 0:
fFactor = 0.25f;
break;
}

if (m_sArg.eType == WORMHOLE_ETYPE_NormalSGU)
GPIO_SetPixel(i, MIN(psLedEffect->fOne*u32MaxBrightness * fFactor, 255), MIN(psLedEffect->fOne*u32MaxBrightness * fFactor, 255), MIN(psLedEffect->fOne*u32MaxBrightness * fFactor, 255));
else if (m_sArg.eType == WORMHOLE_ETYPE_NormalSG1)
GPIO_SetPixel(i, MAX(psLedEffect->fOne*u32MaxBrightness * fFactor, 16), MAX(psLedEffect->fOne*u32MaxBrightness * fFactor, 16), 16+MIN(psLedEffect->fOne*u32MaxBrightness * fFactor, 255-16));
else if (m_sArg.eType == WORMHOLE_ETYPE_Hell)
GPIO_SetPixel(i, MIN(psLedEffect->fOne*u32MaxBrightness * fFactor, 255), 1, 1);

const float fInc = 0.005f + ( 0.01f * (esp_random() % 100) ) * 0.001f;

if (psLedEffect->bUp)
psLedEffect->fOne += fInc;
else
psLedEffect->fOne -= fInc;

if (psLedEffect->fOne >= maxF)
{
psLedEffect->fOne = maxF;
psLedEffect->bUp = false;
}
else if (psLedEffect->fOne <= minF)
{
psLedEffect->fOne = minF;
psLedEffect->bUp = true;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions Source/base-fw/main/Wormhole.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
typedef enum
{
WORMHOLE_ETYPE_NormalSGU = 0,
WORMHOLE_ETYPE_NormalSG1,
WORMHOLE_ETYPE_Hell,
/* WORMHOLE_ETYPE_Blackhole = 3 */
WORMHOLE_ETYPE_NormalSG1 = 1,
WORMHOLE_ETYPE_Hell = 2,
WORMHOLE_ETYPE_Blackhole = 3,
/* WORMHOLE_ETYPE_Glitch = 4 */
WORMHOLE_ETYPE_Count
} WORMHOLE_ETYPE;
Expand Down
Loading

0 comments on commit 6aa3145

Please sign in to comment.