HVAC_M7_MONO/MODULES/HVAC_M7_Indication/Indication.c

65 lines
1.6 KiB
C

//
// Created by cfif on 11.10.23.
//
#include "Indication.h"
#include <SystemDelayInterface.h>
#include <CmsisRtosThreadUtils.h>
#include "MainStack.h"
tStringStatic eDeviceModesNames[] = {
StringStaticInit("Запуск"),
StringStaticInit("Работа")
};
static void Indication_Update(tIndication *env) {
env->currentModeName = StringStaticGetLink(&eDeviceModesNames[env->mode]);
env->tick = ((env->tick + 1) % 10);
}
void Indication_Init(
tIndication *env,
eHvacDevModes initMode
) {
env->mode = initMode;
Indication_Update(env);
// env->thread.stack = tIndication_stack;
// InitThreadAtr(&env->thread.attr,"Indication",&env->thread.controlBlock,sizeof(env->thread.controlBlock),env->thread.stack,tIndication_stack_size,osPriorityNormal);
// env->thread.id = 0;
// InitThreadAtrStatic(&env->thread.attr, "Indication", env->thread.controlBlock, env->thread.stack, osPriorityNormal);
// env->thread.id = 0;
}
void Indication_SetMode(tIndication *env, eHvacDevModes mode) {
if (env->mode != mode) {
env->mode = mode;
Indication_Update(env);
}
}
static _Noreturn void Indication_Thread(tIndication *env) {
for (;;) {
Indication_Update(env);
SystemDelayMs(100);
}
}
void Indication_StartThread(tIndication *env) {
if (!env->thread.id) {
env->thread.id = osThreadNew((osThreadFunc_t) (Indication_Thread), (void *) (env), &env->thread.attr);
} else {
osThreadResume(env->thread.id);
}
}
void Indication_StopThread(tIndication *env) {
if (env->thread.id) {
osThreadSuspend(env->thread.id);
}
}