pre-first-release

This commit is contained in:
ADElectronics 2017-12-26 20:49:06 +03:00
parent c6c5eeed6f
commit 9e39a46764
76 changed files with 190786 additions and 90598 deletions

View file

@ -9,50 +9,48 @@ SemaphoreHandle_t cfg_sema = NULL;
ctx_rainbow_t filt_rainbow;
ctx_fade_t filt_fade;
ctx_const_t filt_const;
ctx_wave_t filt_wave;
void ledEffectsServer_Init()
{
cfg_sema = xSemaphoreCreateMutex();
ws2812_cfg = ws2812_Init(WS2812_LEDS_MAX);
if (ws2812_cfg == NULL)
{
printf("[%s] ws2812_Init() failed\n", __func__);
goto error;
return;
}
ledFilter_Init(&strip, ws2812_cfg);
ledFilter_InitRainbow(&filt_rainbow);
ledFilter_InitFade(&filt_fade);
ledFilter_InitConstant(&filt_const);
ledFilter_InitWave(&filt_wave);
ledFilter_SetDefualtValue(&strip, MAX_STRIP_BRIGHT);
filt_fade.enabled = 1;
}
void ledEffectsServer_Task()
{
cfg_sema = xSemaphoreCreateMutex();
while (1)
{
if(xSemaphoreTake(cfg_sema, 5 * configTICK_RATE_HZ))
if (xSemaphoreTake(cfg_sema, 5 * configTICK_RATE_HZ))
{
ledFilter_Rainbow(&filt_rainbow, &strip);
ledFilter_Constant(&filt_const, &strip);
ledFilter_Wave(&filt_wave, &strip);
ledFilter_Fade(&filt_fade, &strip);
ws2812_Update(ws2812_cfg, strip.hsv_vals, strip.strip_len, strip.delay);
xSemaphoreGive(cfg_sema);
}
WDGRefresh();
}
error:
while (1)
{
vTaskDelay(1000);
}
}
/*
void ledEffectsServer_LoadConfigFromFlash()

View file

@ -5,14 +5,14 @@
// Ïóáëè÷íûå êîíôèíãè ôèëüòðîâ
extern strip_handler_t strip;
extern ctx_rainbow_t filt_rainbow;
extern ctx_fade_t filt_fade;
extern ctx_const_t filt_const;
extern ctx_wave_t filt_wave;
void ledEffectsServer_Init();
void ledEffectsServer_Task();
#endif // _LEDEFFECTSSERVER_H_

View file

@ -2,6 +2,41 @@
extern uint32_t cfg_updated;
uint8_t s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, 0x0A, 0x08, 0x07, 0x06, 0x06, 0x05, 0x04,
0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03,
0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0A,
0x0B, 0x0C, 0x0D, 0x0F, 0x10, 0x11, 0x13, 0x15,
0x16, 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24,
0x26, 0x28, 0x2B, 0x2D, 0x2F, 0x32, 0x34, 0x37,
0x39, 0x3C, 0x3F, 0x41, 0x44, 0x47, 0x4A, 0x4D,
0x4F, 0x52, 0x55, 0x58, 0x5B, 0x5E, 0x61, 0x64,
0x67, 0x6A, 0x6D, 0x70, 0x74, 0x77, 0x7A, 0x7D
};
#pragma region Áàçîâûå ôóíêöèè ïî ðàáîòå ñ ôèëüòðàìè
int32_t ledFilter_Init(strip_handler_t *strip, ws2812_t *ws2812)
{
@ -12,7 +47,7 @@ int32_t ledFilter_Init(strip_handler_t *strip, ws2812_t *ws2812)
strip->strip_len = DEF_STRIP_LEN;
strip->delay = 10;
strip->brightness = MAX_STRIP_BRIGHT;
strip->isEnable = 1;
cfg_updated = 1;
}
@ -79,7 +114,7 @@ void ledFilter_Rainbow(ctx_rainbow_t *ctx, strip_handler_t *strip)
ws2812_hsv_t tmp_hsv;
uint8_t tmp_hue;
if (ctx->enabled == 0) return;
if (ctx->enabled == 0 || strip->isEnable == 0) return;
tmp_hue = ctx->curr_hue;
tmp_hsv.sat = 255;
@ -96,7 +131,7 @@ void ledFilter_Rainbow(ctx_rainbow_t *ctx, strip_handler_t *strip)
tmp_hsv.value = strip->hsv_vals[i].value;
strip->hsv_vals[i] = tmp_hsv;
tmp_hue += 255/ ctx->hue_steps;
tmp_hue %= 256;
//tmp_hue %= 256;
}
ctx->curr_hue += ctx->cycle_steps;
@ -109,11 +144,11 @@ void ledFilter_InitFade(ctx_fade_t *ctx)
{
if (ctx->valid != LEDFILTERS_CFG_CHECKWORD)
{
ctx->valid = 1;
ctx->valid = LEDFILTERS_CFG_CHECKWORD;
ctx->min = 0;
ctx->max = 255;
ctx->steps = LEDFILTERS_MAX_STEPS;
ctx->enabled = 1;
ctx->enabled = 0;
cfg_updated = 1;
}
@ -130,7 +165,7 @@ void ledFilter_Fade(ctx_fade_t *ctx, strip_handler_t *strip)
{
uint32_t i;
if (ctx->enabled == 0) return;
if (ctx->enabled == 0 || strip->isEnable == 0) return;
if (ctx->curr_val == 0)
{
@ -186,24 +221,84 @@ void ledFilter_Fade(ctx_fade_t *ctx, strip_handler_t *strip)
#pragma region Wave
void ledFilter_InitWave(ctx_wave_t *ctx)
{
if (ctx->valid != LEDFILTERS_CFG_CHECKWORD)
{
ctx->valid = LEDFILTERS_CFG_CHECKWORD;
ctx->enabled = 0;
ctx->wave_steps = 20;
ctx->angle = 0;
ctx->step = 1;
cfg_updated = 1;
}
//for (uint16_t i = 0; i < 255; i++)
// sin_table[i] = (uint16_t)(sin((double)(((double)i + 2.0) * M_PI)/ 255.0) * UINT8_MAX);
}
void ledFilter_Wave(ctx_wave_t *ctx, strip_handler_t *strip)
{
uint32_t i, j;
uint8_t tmp_angle = 0;
if (ctx->enabled == 0 || strip->isEnable == 0) return;
tmp_angle = ctx->angle;
for (i = 0, j = ctx->wave_steps; i < strip->strip_len; i++)
{
if (i == j)
{
j += ctx->wave_steps;
tmp_angle = ctx->angle;
}
strip->hsv_vals[i].value = sin_table[tmp_angle]/2;
tmp_angle += 255 / ctx->wave_steps;
//tmp_angle %= 256;
}
ctx->angle += ctx->step;
}
#pragma endregion
#pragma region Constant
void ledFilter_InitConstant(ctx_const_t *ctx)
{
if (ctx->valid != LEDFILTERS_CFG_CHECKWORD)
{
ctx->valid = LEDFILTERS_CFG_CHECKWORD;
ctx->hue = 128;
ctx->sat = 255;
ctx->value = 255;
ctx->enabled = 0;
ctx->update = 0;
cfg_updated = 1;
}
}
void ledFilter_Constant(ctx_const_t *ctx, strip_handler_t *strip)
{
uint32_t i;
if (strip->isEnable == 0)
{
for (i = 0; i < strip->strip_len; i++)
{
if (strip->hsv_vals[i].value > 0)
strip->hsv_vals[i].value--;
}
return;
}
else if (ctx->enabled == 0) return;
if (ctx->update > 0)
{
for (i = 0; i < strip->strip_len; i++)
{
strip->hsv_vals[i].hue = ctx->hue;
strip->hsv_vals[i].sat = ctx->sat;
strip->hsv_vals[i].value = ctx->value;
}
ctx->update = 0;
}
}
#pragma endregion

View file

@ -48,6 +48,9 @@ typedef struct
{
uint8_t enabled;
uint32_t valid;
uint8_t wave_steps;
uint8_t step;
uint8_t angle;
} ctx_wave_t;
#pragma endregion
@ -55,6 +58,10 @@ typedef struct
typedef struct
{
uint8_t enabled;
uint8_t hue;
uint8_t sat;
uint8_t value;
uint8_t update;
uint32_t valid;
} ctx_const_t;
#pragma endregion
@ -66,6 +73,7 @@ typedef struct
uint32_t strip_len;
uint32_t brightness;
uint32_t delay;
uint8_t isEnable;
} strip_handler_t;
int32_t ledFilter_Init(strip_handler_t *strip, ws2812_t *ws2812);
@ -76,7 +84,8 @@ void ledFilter_InitFade(ctx_fade_t *ctx);
void ledFilter_Fade(ctx_fade_t *ctx, strip_handler_t *strip);
void ledFilter_InitWave(ctx_wave_t *ctx);
void ledFilter_Wave(ctx_wave_t *ctx, strip_handler_t *strip);
void ledFilter_InitConstant(ctx_const_t *ctx);
void ledFilter_Constant(ctx_const_t *ctx, strip_handler_t *strip);
void ledFilter_SetDefualtValue(strip_handler_t *strip, uint8_t val);
#endif // _LEDFILTERS_H_

View file

@ -1,6 +1,6 @@
#define UTS_VERSION "2017/12/24-02:16:14"
#define RTL8195AFW_COMPILE_TIME "2017/12/24-02:16:14"
#define RTL8195AFW_COMPILE_DATE "20171224"
#define UTS_VERSION "2017/12/26-19:51:38"
#define RTL8195AFW_COMPILE_TIME "2017/12/26-19:51:38"
#define RTL8195AFW_COMPILE_DATE "20171226"
#define RTL8195AFW_COMPILE_BY "Andrew"
#define RTL8195AFW_COMPILE_HOST ""
#define RTL8195AFW_COMPILE_DOMAIN

View file

@ -77,11 +77,13 @@ extern void console_init(void);
void user_ws_thrd(void)
{
ledEffectsServer_Init();
while (1)
{
if (xSemaphoreTake(sema_WEBReady, 10 * configTICK_RATE_HZ))
{
ledEffectsServer_Init();
ledEffectsServer_Task();
}
WDGRefresh();
}

View file

@ -404,7 +404,26 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr)
else ifcmp("max") tcp_puts("%d", filt_fade.max);
else ifcmp("cyclesteps") tcp_puts("%d", filt_fade.steps);
}
else ifcmp("wave_")
{
cstr += 5;
ifcmp("enbl") tcp_puts("%d", filt_wave.enabled);
else ifcmp("step") tcp_puts("%d", filt_wave.step);
else ifcmp("wavesteps") tcp_puts("%d", filt_wave.wave_steps);
}
else ifcmp("const_")
{
cstr += 6;
ifcmp("enbl") tcp_puts("%d", filt_const.enabled);
else ifcmp("hue") tcp_puts("%d", filt_const.hue);
else ifcmp("sat") tcp_puts("%d", filt_const.sat);
else ifcmp("value") tcp_puts("%d", filt_const.value);
}
}
else ifcmp("isenable") tcp_puts("%d", strip.isEnable);
else ifcmp("striplen") tcp_puts("%d", strip.strip_len);
}
// **************************************************************************************************** //
// **************************************************************************************************** //

View file

@ -113,7 +113,27 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *
else ifcmp("max") filt_fade.max = (uint8_t)val;
else ifcmp("cyclesteps") filt_fade.steps = (uint8_t)val;
}
else ifcmp("wave_")
{
cstr += 5;
ifcmp("enbl") filt_wave.enabled = (uint8_t)val;
else ifcmp("step") filt_wave.step = (uint8_t)val;
else ifcmp("wavesteps") filt_wave.wave_steps = (uint8_t)val;
}
else ifcmp("const_")
{
cstr += 6;
ifcmp("enbl") filt_const.enabled = (uint8_t)val;
else ifcmp("hue") filt_const.hue = (uint8_t)val;
else ifcmp("sat") filt_const.sat = (uint8_t)val;
else ifcmp("value") filt_const.value = (uint8_t)val;
else ifcmp("update") filt_const.update = (uint8_t)val;
}
}
else ifcmp("isenable") strip.isEnable = (uint8_t)val;
//else ifcmp("striplen") strip.strip_len = (uint8_t)val;
}
// **************************************************************************************************** //
// **************************************************************************************************** //

View file

@ -10,7 +10,7 @@
// ====================================================================================================================================
// ============================================ Wlan Config ===========================================================================
#define DEF_WIFI_MODE RTW_MODE_STA // Стартовый режим WiFi: RTW_MODE_STA_AP, RTW_MODE_AP, RTW_MODE_STA, RTW_MODE_NONE
#define DEF_WIFI_MODE RTW_MODE_STA_AP // Стартовый режим WiFi: RTW_MODE_STA_AP, RTW_MODE_AP, RTW_MODE_STA, RTW_MODE_NONE
#define DEF_WIFI_AP_STATIONS 3 // Max number of STAs, should be 1..3, default is 3
#define DEF_WIFI_COUNTRY RTW_COUNTRY_RU // Регион использования WiFi...
#define DEF_WIFI_TX_PWR RTW_TX_PWR_PERCENTAGE_12_5 // RTW_TX_PWR_PERCENTAGE_75 // RTW_TX_PWR_PERCENTAGE_100