|
|
@ -49,93 +49,91 @@ Kaleidoscope_::use(KaleidoscopePlugin *plugin, ...) {
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
Kaleidoscope_::replaceEventHandlerHook(eventHandlerHook oldHook, eventHandlerHook newHook) {
|
|
|
|
Kaleidoscope_::replaceEventHandlerHook(eventHandlerHook oldHook, eventHandlerHook newHook) {
|
|
|
|
for (byte i = 0; i < HOOK_MAX; i++) {
|
|
|
|
for (byte i = 0; i < HOOK_MAX; i++) {
|
|
|
|
if (eventHandlers[i] == oldHook) {
|
|
|
|
if (eventHandlers[i] == oldHook) {
|
|
|
|
eventHandlers[i] = newHook;
|
|
|
|
eventHandlers[i] = newHook;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
Kaleidoscope_::appendEventHandlerHook (eventHandlerHook hook) {
|
|
|
|
Kaleidoscope_::appendEventHandlerHook (eventHandlerHook hook) {
|
|
|
|
replaceEventHandlerHook((eventHandlerHook)NULL, hook);
|
|
|
|
replaceEventHandlerHook((eventHandlerHook)NULL, hook);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
Kaleidoscope_::useEventHandlerHook (eventHandlerHook hook) {
|
|
|
|
Kaleidoscope_::useEventHandlerHook (eventHandlerHook hook) {
|
|
|
|
for (byte i = 0; i < HOOK_MAX; i++) {
|
|
|
|
for (byte i = 0; i < HOOK_MAX; i++) {
|
|
|
|
if (eventHandlers[i] == hook)
|
|
|
|
if (eventHandlers[i] == hook)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
appendEventHandlerHook(hook);
|
|
|
|
appendEventHandlerHook(hook);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
Kaleidoscope_::replaceLoopHook(loopHook oldHook, loopHook newHook) {
|
|
|
|
Kaleidoscope_::replaceLoopHook(loopHook oldHook, loopHook newHook) {
|
|
|
|
for (byte i = 0; i < HOOK_MAX; i++) {
|
|
|
|
for (byte i = 0; i < HOOK_MAX; i++) {
|
|
|
|
if (loopHooks[i] == oldHook) {
|
|
|
|
if (loopHooks[i] == oldHook) {
|
|
|
|
loopHooks[i] = newHook;
|
|
|
|
loopHooks[i] = newHook;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
Kaleidoscope_::appendLoopHook(loopHook hook) {
|
|
|
|
Kaleidoscope_::appendLoopHook(loopHook hook) {
|
|
|
|
replaceLoopHook((loopHook)NULL, hook);
|
|
|
|
replaceLoopHook((loopHook)NULL, hook);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
Kaleidoscope_::useLoopHook(loopHook hook) {
|
|
|
|
Kaleidoscope_::useLoopHook(loopHook hook) {
|
|
|
|
for (byte i = 0; i < HOOK_MAX; i++) {
|
|
|
|
for (byte i = 0; i < HOOK_MAX; i++) {
|
|
|
|
if (loopHooks[i] == hook)
|
|
|
|
if (loopHooks[i] == hook)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
appendLoopHook (hook);
|
|
|
|
appendLoopHook (hook);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
Kaleidoscope_::focusHook(const char *command) {
|
|
|
|
Kaleidoscope_::focusHook(const char *command) {
|
|
|
|
enum {
|
|
|
|
enum {
|
|
|
|
ON,
|
|
|
|
ON,
|
|
|
|
OFF,
|
|
|
|
OFF,
|
|
|
|
GETSTATE,
|
|
|
|
GETSTATE,
|
|
|
|
} subCommand;
|
|
|
|
} subCommand;
|
|
|
|
|
|
|
|
|
|
|
|
if (strncmp_P(command, PSTR("layer."), 6) != 0)
|
|
|
|
if (strncmp_P(command, PSTR("layer."), 6) != 0)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp_P (command + 6, PSTR("on")) == 0)
|
|
|
|
if (strcmp_P (command + 6, PSTR("on")) == 0)
|
|
|
|
subCommand = ON;
|
|
|
|
subCommand = ON;
|
|
|
|
else if (strcmp_P(command + 6, PSTR("off")) == 0)
|
|
|
|
else if (strcmp_P(command + 6, PSTR("off")) == 0)
|
|
|
|
subCommand = OFF;
|
|
|
|
subCommand = OFF;
|
|
|
|
else if (strcmp_P(command + 6, PSTR("getState")) == 0)
|
|
|
|
else if (strcmp_P(command + 6, PSTR("getState")) == 0)
|
|
|
|
subCommand = GETSTATE;
|
|
|
|
subCommand = GETSTATE;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
switch (subCommand) {
|
|
|
|
switch (subCommand) {
|
|
|
|
case ON:
|
|
|
|
case ON: {
|
|
|
|
{
|
|
|
|
uint8_t layer = Serial.parseInt();
|
|
|
|
uint8_t layer = Serial.parseInt();
|
|
|
|
Layer.on(layer);
|
|
|
|
Layer.on(layer);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case OFF:
|
|
|
|
case OFF: {
|
|
|
|
{
|
|
|
|
uint8_t layer = Serial.parseInt();
|
|
|
|
uint8_t layer = Serial.parseInt();
|
|
|
|
Layer.off(layer);
|
|
|
|
Layer.off(layer);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case GETSTATE:
|
|
|
|
case GETSTATE:
|
|
|
|
Serial.println(Layer.getLayerState(), BIN);
|
|
|
|
Serial.println(Layer.getLayerState(), BIN);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Kaleidoscope_ Kaleidoscope;
|
|
|
|
Kaleidoscope_ Kaleidoscope;
|
|
|
|