This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #330 from UltimateHackingKeyboard/make_dongle_leds…
…_functional Make dongle leds functional.
- Loading branch information
Showing
7 changed files
with
64 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,42 @@ | ||
#include "device.h" | ||
#if DEVICE_IS_UHK_DONGLE | ||
#include "dongle_leds.h" | ||
#include "device_state.h" | ||
#include "settings.h" | ||
|
||
const struct pwm_dt_spec red_pwm_led = PWM_DT_SPEC_GET(DT_ALIAS(red_pwm_led)); | ||
const struct pwm_dt_spec green_pwm_led = PWM_DT_SPEC_GET(DT_ALIAS(green_pwm_led)); | ||
const struct pwm_dt_spec blue_pwm_led = PWM_DT_SPEC_GET(DT_ALIAS(blue_pwm_led)); | ||
|
||
|
||
// There is also the following zero led. | ||
// const struct gpio_dt_spec led0 = GPIO_DT_SPEC_GET(DT_ALIAS(led0_green), gpios); | ||
// gpio_pin_configure_dt(&led0, GPIO_OUTPUT); | ||
// gpio_pin_set_dt(&led0, true); | ||
// k_sleep(K_MSEC(1000)); | ||
// gpio_pin_set_dt(&led0, false); | ||
|
||
void set_dongle_led(const struct pwm_dt_spec *device, uint8_t percentage) { | ||
pwm_set_pulse_dt(device, percentage * device->period / 100); | ||
} | ||
|
||
|
||
void DongleLeds_Set(bool r, bool g, bool b) { | ||
set_dongle_led(&red_pwm_led, r ? 100 : 0); | ||
set_dongle_led(&green_pwm_led, g ? 100 : 0); | ||
set_dongle_led(&blue_pwm_led, b ? 100 : 0); | ||
} | ||
|
||
void DongleLeds_Update() { | ||
if (DeviceState_IsConnected(ConnectionId_Right)) { | ||
DongleLeds_Set(false, true, false); | ||
return; | ||
} | ||
if (RightAddressIsSet) { | ||
DongleLeds_Set(false, false, true); | ||
return; | ||
} | ||
DongleLeds_Set(true, false, false); | ||
} | ||
|
||
#endif // DEVICE_IS_UHK_DONGLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
#ifndef __SETTINGS_H__ | ||
#define __SETTINGS_H__ | ||
|
||
// Includes | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
// Functions: | ||
|
||
extern void InitSettings(void); | ||
|
||
// Variables: | ||
|
||
extern bool RightAddressIsSet; | ||
|
||
#endif // __SETTINGS_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters