summaryrefslogtreecommitdiff
path: root/keyboard/lightsaber
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard/lightsaber')
-rw-r--r--keyboard/lightsaber/backlight.c48
-rw-r--r--keyboard/lightsaber/backlight.h9
-rw-r--r--keyboard/lightsaber/keymap_winkey.h14
3 files changed, 59 insertions, 12 deletions
diff --git a/keyboard/lightsaber/backlight.c b/keyboard/lightsaber/backlight.c
index b28200807c..59b8b4a633 100644
--- a/keyboard/lightsaber/backlight.c
+++ b/keyboard/lightsaber/backlight.c
@@ -26,8 +26,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* Backside PD6 (high)
* TopRight PD7 (low)
* F-Row PE6 (high)
- *
*/
+
void backlight_set(uint8_t level)
{
// Set as output.
@@ -35,22 +35,52 @@ void backlight_set(uint8_t level)
DDRD |= (1<<6) | (1<<7);
DDRE |= (1<<6);
- if(level & (1<<0))
+ if (level & BACKLIGHT_ALPHA)
{
- PORTB &= ~(1<<1);
- PORTB &= ~(1<<2);
- PORTB &= ~(1<<3);
- PORTD &= ~(1<<6);
- PORTD |= (1<<7);
- PORTE &= ~(1<<6);
+ PORTB |= (1<<1);
}
else
{
- PORTB |= (1<<1);
+ PORTB &= ~(1<<1);
+ }
+ if (level & BACKLIGHT_NUMERIC)
+ {
PORTB |= (1<<2);
+ }
+ else
+ {
+ PORTB &= ~(1<<2);
+ }
+ if (level & BACKLIGHT_MODNUM)
+ {
PORTB |= (1<<3);
+ }
+ else
+ {
+ PORTB &= ~(1<<3);
+ }
+ if (level & BACKLIGHT_BACKSIDE)
+ {
PORTD |= (1<<6);
+ }
+ else
+ {
+ PORTD &= ~(1<<6);
+ }
+ if (level & BACKLIGHT_TOPRIGHT)
+ {
PORTD &= ~(1<<7);
+ }
+ else
+ {
+ PORTD |= (1<<7);
+ }
+ if (level & BACKLIGHT_FROW)
+ {
PORTE |= (1<<6);
}
+ else
+ {
+ PORTE &= ~(1<<6);
+ }
}
diff --git a/keyboard/lightsaber/backlight.h b/keyboard/lightsaber/backlight.h
new file mode 100644
index 0000000000..6dc7967a62
--- /dev/null
+++ b/keyboard/lightsaber/backlight.h
@@ -0,0 +1,9 @@
+
+enum backlight_level {
+ BACKLIGHT_ALPHA = 0b0000001,
+ BACKLIGHT_NUMERIC = 0b0000010,
+ BACKLIGHT_MODNUM = 0b0000100,
+ BACKLIGHT_BACKSIDE = 0b0001000,
+ BACKLIGHT_TOPRIGHT = 0b0010000,
+ BACKLIGHT_FROW = 0b0100000,
+};
diff --git a/keyboard/lightsaber/keymap_winkey.h b/keyboard/lightsaber/keymap_winkey.h
index 59ffd4a8fc..3e8367083c 100644
--- a/keyboard/lightsaber/keymap_winkey.h
+++ b/keyboard/lightsaber/keymap_winkey.h
@@ -1,3 +1,5 @@
+#include "backlight.h"
+
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KEYMAP(\
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, PSCR, SLCK, BRK, \
@@ -8,14 +10,20 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
LCTL,LGUI,LALT, SPC, NO, RALT,RGUI,RCTL, KP_0, NO, KP_DOT, NO), \
KEYMAP(\
CALC,MYCM,WSCH,WHOM,MAIL,MUTE,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS, TRNS, WAKE, PWR, SLEP, \
- TRNS,TRNS,TRNS,TRNS,END ,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \
+ FN1, FN2, FN3, FN4, FN5, FN6, FN7, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS,TRNS,TRNS,TRNS,PGDN,TRNS,LEFT,DOWN,UP ,RGHT,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \
TRNS, TRNS,TRNS,TRNS,TRNS,PGUP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \
- TRNS,TRNS,TRNS, FN1, TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS)
+ TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS)
};
static const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
- [1] = ACTION_BACKLIGHT_STEP()
+ [1] = ACTION_BACKLIGHT_TOGGLE(),
+ [2] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_ALPHA),
+ [3] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_MODNUM),
+ [4] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_NUMERIC),
+ [5] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_FROW),
+ [6] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_BACKSIDE),
+ [7] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_TOPRIGHT)
};