Skip to content

Commit

Permalink
Make the Agent icon of the LED display light up when Agent is running.
Browse files Browse the repository at this point in the history
…Resolves #126.
  • Loading branch information
mondalaci committed Dec 3, 2019
1 parent bb4429c commit ef8b26a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions right/src/usb_commands/usb_command_get_device_state.c
Expand Up @@ -5,6 +5,7 @@
#include "peripherals/merge_sensor.h"
#include "slave_drivers/uhk_module_driver.h"
#include "usb_report_updater.h"
#include "timer.h"

void UsbCommand_GetKeyboardState(void)
{
Expand All @@ -14,4 +15,5 @@ void UsbCommand_GetKeyboardState(void)
SetUsbTxBufferUint8(4, UhkModuleStates[UhkModuleDriverId_LeftModule].moduleId);
SetUsbTxBufferUint8(5, UhkModuleStates[UhkModuleDriverId_RightModule].moduleId);
SetUsbTxBufferUint8(6, PreviousLayer); // It's actually the active layer in practice, but with stable state.
LastUsbGetKeyboardStateRequestTimestamp = CurrentTime;
}
4 changes: 4 additions & 0 deletions right/src/usb_protocol_handler.h
Expand Up @@ -51,6 +51,10 @@
UsbStatusCode_InvalidCommand = 1,
} usb_status_code_general_t;

// Variables:

extern uint32_t LastUsbGetKeyboardStateRequestTimestamp;

// Functions:

void UsbProtocolHandler(void);
Expand Down
4 changes: 4 additions & 0 deletions right/src/usb_report_updater.c
Expand Up @@ -343,6 +343,8 @@ static inline void preprocessKeyState(key_state_t *keyState) {
}
}

uint32_t LastUsbGetKeyboardStateRequestTimestamp;

static void updateActiveUsbReports(void)
{
if (MacroPlaying) {
Expand Down Expand Up @@ -373,6 +375,8 @@ static void updateActiveUsbReports(void)
}
LedDisplay_SetLayer(activeLayer);

LedDisplay_SetIcon(LedDisplayIcon_Agent, CurrentTime - LastUsbGetKeyboardStateRequestTimestamp < 1000);

if (TestUsbStack) {
static bool simulateKeypresses, isEven, isEvenMedia;
static uint32_t mediaCounter = 0;
Expand Down

0 comments on commit ef8b26a

Please sign in to comment.