Drive the LED_PWM line of the left half via TPM which doesn't work yet for some reason. Add protocol command for setting the LED_PWM brightness of the left half. Expose UpdateUsbReports()

This commit is contained in:
László Monda
2017-01-13 21:43:47 +01:00
parent 0ded50b43a
commit 9ef9e5f734
10 changed files with 89 additions and 8 deletions

View File

@@ -15,7 +15,7 @@ void LedPwm_Init() {
ftmParam[0].chnlNumber = (ftm_chnl_t)LED_PWM_FTM_CHANNEL;
ftmParam[0].level = kFTM_LowTrue;
ftmParam[0].dutyCyclePercent = INITIAL_DUTY_CYCLE_PERCENT - 100;
ftmParam[0].dutyCyclePercent = 100 - INITIAL_DUTY_CYCLE_PERCENT;
ftmParam[0].firstEdgeDelayPercent = 0;
FTM_GetDefaultConfig(&ftmInfo);
@@ -28,6 +28,6 @@ void LedPwm_Init() {
void LedPwm_SetBrightness(uint8_t brightnessPercent)
{
FTM_UpdatePwmDutycycle(LED_PWM_FTM_BASEADDR, LED_PWM_FTM_CHANNEL, kFTM_EdgeAlignedPwm, brightnessPercent-100);
FTM_UpdatePwmDutycycle(LED_PWM_FTM_BASEADDR, LED_PWM_FTM_CHANNEL, kFTM_EdgeAlignedPwm, 100 - brightnessPercent);
FTM_SetSoftwareTrigger(LED_PWM_FTM_BASEADDR, true); // Triggers register update.
}

View File

@@ -59,7 +59,7 @@ static const uint8_t testData[] =
0x0a, 0x02, 0x2d, 0x02, 0x1d, 0x02, 0x1b, 0x02, 0x06, 0x02, 0x19, 0x02, 0x05, 0x02, 0x04, 0x02, 0x05, 0x02, 0x06,
0x02, 0x07, 0x02, 0x08, 0x02, 0x09, 0x02, 0x02, 0x00 };
void updateUsbReports()
void UpdateUsbReports()
{
ResetActiveUsbKeyboardReport();
@@ -82,13 +82,13 @@ void main() {
InitClock();
LedDriver_InitAllLeds(1);
KeyMatrix_Init(&KeyMatrix);
updateUsbReports();
UpdateUsbReports();
InitUsb();
// deserialize_Layer(testData, 0);
while (1) {
updateUsbReports();
UpdateUsbReports();
asm("wfi");
}
}

View File

@@ -19,5 +19,6 @@
extern key_matrix_t KeyMatrix;
extern uint8_t PreviousKeyStates[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE];
extern uint8_t CurrentKeyStates[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE];
extern void UpdateUsbReports();
#endif

View File

@@ -207,8 +207,10 @@ void applyConfig()
void setLedPwm()
{
uint8_t brightnessPercent = GenericHidInBuffer[1];
#if UHK_PCB_MAJOR_VERSION == 7
uint8_t brightnessPercent = GenericHidInBuffer[1];
LedPwm_SetBrightness(brightnessPercent);
uint8_t data[] = {2, brightnessPercent};
I2cWrite(I2C_MAIN_BUS_BASEADDR, I2C_ADDRESS_LEFT_KEYBOARD_HALF, data, sizeof(data));
#endif
}