Implement the delay macro action

This commit is contained in:
Eric Tang
2018-06-26 12:36:58 -07:00
parent 314eb0d771
commit 5988fce59b

View File

@@ -1,6 +1,7 @@
#include "macros.h"
#include "config_parser/parse_macro.h"
#include "config_parser/config_globals.h"
#include "timer.h"
macro_reference_t AllMacros[MAX_MACRO_NUM];
uint8_t AllMacrosCount;
@@ -242,11 +243,27 @@ bool processKeyMacroAction(void)
return false;
}
bool processDelayMacroAction(void)
{
static bool inDelay;
static uint32_t delayStart;
if (inDelay) {
if (Timer_GetElapsedTime(&delayStart) >= currentMacroAction.delay.delay) {
inDelay = false;
}
} else {
Timer_SetCurrentTime(&delayStart);
inDelay = true;
}
return inDelay;
}
bool processCurrentMacroAction(void)
{
switch (currentMacroAction.type) {
case MacroActionType_Delay:
return false;
return processDelayMacroAction();
case MacroActionType_Key:
return processKeyMacroAction();
case MacroActionType_MouseButton: