Files
AutoFilm-ESP32/components/app_process/app_process.c

149 lines
4.6 KiB
C

#include "app_process.h"
#include <string.h>
static const process_step_t s_c41_steps[] = {
{"Prewarm", 180, 1.f, 1.f, 37.8f, 38.f, 38.2f},
{"Developer", 195, 5.5f, 5.f, 37.8f, 38.f, 38.2f},
{"Bleach", 45, 5.5f, 5.f, 32.f, 38.f, 38.2f},
{"Fix", 180, 5.5f, 5.f, 32.f, 38.f, 38.2f},
{"Rinse 1", 60, 3.5f, 3.f, 32.f, 38.f, 38.2f},
{"Rinse 2", 60, 3.5f, 3.f, 32.f, 38.f, 38.2f},
{"Fin Rinse", 30, 1.f, 1.f, 32.f, 38.f, 38.2f},
};
static const process_step_t s_e6_steps[] = {
{"Preheat", 180, 1.f, 1.f, 37.5f, 38.f, 38.5f},
{"FirstDev", 360, 5.5f, 5.f, 37.7f, 38.f, 38.3f},
{"Wash 1", 120, 3.5f, 3.f, 33.0f, 38.f, 38.0f},
{"Reversal", 120, 5.f, 5.5f, 37.7f, 38.f, 38.3f},
{"ColorDev", 360, 5.5f, 5.f, 37.0f, 38.f, 39.0f},
{"PreBleach", 120, 5.5f, 5.5f, 37.f, 38.f, 38.f},
{"Bleach", 360, 5.5f, 5.5f, 37.5f, 38.f, 38.5f},
{"Fixer", 240, 5.5f, 5.5f, 37.5f, 38.f, 38.5f},
{"Wash 2", 120, 3.5f, 3.f, 33.0f, 38.f, 38.5f},
{"Wash 3", 120, 3.5f, 3.f, 33.0f, 38.f, 38.5f},
{"Wash 4", 120, 3.5f, 3.f, 33.0f, 38.f, 38.5f},
{"Fin Rinse", 30, 3.5f, 3.f, 19.0f, 20.f, 21.0f},
};
static const process_step_t s_ecn2_steps[] = {
{"Prebath", 180, 1.f, 1.f, 27.f, 38.f, 38.f},
{"RemJet", 0, 0.f, 0.f, 0.f, 0.f, 0.f},
{"Developer", 210, 5.5f, 5.f, 40.8f, 41.f, 41.2f},
{"Stop Bath", 60, 3.5f, 3.f, 27.f, 38.f, 38.f},
{"Wash", 180, 3.5f, 3.f, 27.f, 38.f, 38.f},
{"Bleach", 150, 5.5f, 5.f, 27.f, 38.f, 38.f},
{"Fixer", 120, 5.5f, 5.f, 27.f, 38.f, 38.f},
{"Wash 2", 300, 3.5f, 3.f, 27.f, 38.f, 38.f},
{"Fin Rinse", 120, 1.f, 1.f, 27.f, 38.f, 38.f},
};
static const process_step_t s_bw_steps[] = {
{"Developer", 510, 5.5f, 5.f, 19.f, 20.f, 21.f},
{"Stop", 30, 3.5f, 3.f, 19.f, 20.f, 21.f},
{"Fix", 300, 3.5f, 3.f, 19.f, 20.f, 21.f},
{"Rinse 1", 60, 3.5f, 3.f, 19.f, 20.f, 21.f},
{"Rinse 2", 90, 3.5f, 3.f, 19.f, 20.f, 21.f},
{"Rinse 3", 120, 3.5f, 3.f, 19.f, 20.f, 21.f},
{"Fin Rinse", 30, 1.f, 1.f, 19.f, 20.f, 21.f},
};
static const process_step_t s_custom_steps[] = {
{"Developer", 10, 5.5f, 5.f, 19.f, 20.f, 21.f},
{"Stop", 10, 3.5f, 3.f, 19.f, 20.f, 21.f},
{"Fix", 10, 3.5f, 3.f, 19.f, 20.f, 21.f},
{"Rinse", 10, 3.5f, 3.f, 19.f, 20.f, 21.f},
};
static const process_step_t s_bwrev_steps[] = {
{"FirstDev", 720, 5.5f, 5.f, 19.5f, 20.f, 20.5f},
{"Wash 1", 300, 3.5f, 3.f, 15.5f, 20.f, 22.5f},
{"Bleach", 300, 5.5f, 5.f, 19.5f, 20.f, 22.5f},
{"Wash 2", 60, 3.5f, 3.f, 15.5f, 20.f, 22.5f},
{"Clearing", 120, 5.5f, 5.f, 19.5f, 20.f, 22.5f},
{"Wash 3", 60, 3.5f, 3.f, 15.5f, 20.f, 22.5f},
{"Reversal", 120, 5.5f, 5.f, 19.5f, 20.f, 22.5f},
{"SecondDev", 360, 5.5f, 5.f, 19.5f, 20.f, 22.5f},
{"Wash 4", 60, 3.5f, 3.f, 15.5f, 20.f, 22.5f},
{"Fix", 300, 5.5f, 5.f, 19.5f, 20.f, 22.5f},
{"Wash 5", 60, 3.5f, 3.f, 15.5f, 20.f, 22.5f},
{"Fin Rinse", 60, 3.5f, 3.f, 15.5f, 20.f, 22.5f},
};
static const process_def_t s_processes[PROCESS_COUNT] = {
{"C41", 7, s_c41_steps},
{"E6", 12, s_e6_steps},
{"ECN-2", 9, s_ecn2_steps},
{"B&W", 7, s_bw_steps},
{"Custom", 4, s_custom_steps},
{"B&WREV", 12, s_bwrev_steps},
};
static int16_t s_time_delta_s[PROCESS_COUNT][PROCESS_MAX_STEPS];
void app_process_init(void)
{
memset(s_time_delta_s, 0, sizeof(s_time_delta_s));
}
const process_def_t *app_process_get(uint8_t id)
{
if (id >= PROCESS_COUNT) {
return NULL;
}
return &s_processes[id];
}
const process_def_t *app_process_find_name(const char *name)
{
if (name == NULL) {
return NULL;
}
for (uint8_t i = 0; i < PROCESS_COUNT; i++) {
if (strcmp(s_processes[i].name, name) == 0) {
return &s_processes[i];
}
}
return NULL;
}
uint16_t app_process_time_s(uint8_t id, uint8_t step)
{
if (id >= PROCESS_COUNT) {
return 0;
}
const process_def_t *p = &s_processes[id];
if (step >= p->step_count) {
return 0;
}
int32_t t = (int32_t)p->steps[step].time_s + (int32_t)s_time_delta_s[id][step];
if (t < 0) {
t = 0;
}
if (t > 36000) {
t = 36000;
}
return (uint16_t)t;
}
esp_err_t app_process_adjust_time(uint8_t id, uint8_t step, int8_t delta_s)
{
if (id >= PROCESS_COUNT) {
return ESP_ERR_INVALID_ARG;
}
if (step >= s_processes[id].step_count || step >= PROCESS_MAX_STEPS) {
return ESP_ERR_INVALID_ARG;
}
s_time_delta_s[id][step] = (int16_t)(s_time_delta_s[id][step] + delta_s);
return ESP_OK;
}
void app_process_reset_session(uint8_t id)
{
if (id >= PROCESS_COUNT) {
return;
}
memset(s_time_delta_s[id], 0, sizeof(s_time_delta_s[id]));
}