summaryrefslogtreecommitdiff
path: root/keyboards/rama/m6_b
diff options
context:
space:
mode:
authorWilba <Jason.S.Williams@gmail.com>2018-11-14 03:31:25 +1100
committerDrashna Jaelre <drashna@live.com>2018-11-13 08:31:25 -0800
commit2dea540afbfcffaea82f70b6642c39aedb9e3b5b (patch)
treec61a59306a52a4d12d6b62eec5370721e0777bf4 /keyboards/rama/m6_b
parentcaa293a8f77447891b02d5f8c91b209f9a082cc9 (diff)
downloadqmk_firmware-2dea540afbfcffaea82f70b6642c39aedb9e3b5b.tar.gz
qmk_firmware-2dea540afbfcffaea82f70b6642c39aedb9e3b5b.zip
Refactoring M6-A, M6-B, Zeal60, Zeal65, WT60-A, WT65-A, WT80-A (#4417)
* Refactored M6-B to use Zeal60 RGB backlight code * Fixed M6-B LED co-ordinates * Minor changes to RGB config for Zeal65 * Added dynamic keymaps to WT80-A, WT60-A, WT-80A, U80-A
Diffstat (limited to 'keyboards/rama/m6_b')
-rw-r--r--keyboards/rama/m6_b/config.h33
-rw-r--r--keyboards/rama/m6_b/m6_b.c216
-rw-r--r--keyboards/rama/m6_b/m6_b_api.h39
-rw-r--r--keyboards/rama/m6_b/rgb_backlight.c139
-rw-r--r--keyboards/rama/m6_b/rgb_backlight.h34
-rw-r--r--keyboards/rama/m6_b/rules.mk24
6 files changed, 47 insertions, 438 deletions
diff --git a/keyboards/rama/m6_b/config.h b/keyboards/rama/m6_b/config.h
index 1adaad3f9e..c016703e04 100644
--- a/keyboards/rama/m6_b/config.h
+++ b/keyboards/rama/m6_b/config.h
@@ -109,8 +109,38 @@
#define RGB_BACKLIGHT_ENABLED 1
-#define DYNAMIC_KEYMAP_LAYER_COUNT 4
+// This conditionally compiles the backlight code for M6-B specifics
+#define RGB_BACKLIGHT_M6_B
+
+// enable/disable LEDs based on layout
+#define RGB_BACKLIGHT_USE_SPLIT_BACKSPACE 0
+#define RGB_BACKLIGHT_USE_SPLIT_LEFT_SHIFT 0
+#define RGB_BACKLIGHT_USE_SPLIT_RIGHT_SHIFT 0
+#define RGB_BACKLIGHT_USE_7U_SPACEBAR 0
+#define RGB_BACKLIGHT_USE_ISO_ENTER 0
+#define RGB_BACKLIGHT_DISABLE_HHKB_BLOCKER_LEDS 0
+
+// disable backlight when USB suspended (PC sleep/hibernate/shutdown)
+#define RGB_BACKLIGHT_DISABLE_WHEN_USB_SUSPENDED 0
+
+// disable backlight after timeout in minutes, 0 = no timeout
+#define RGB_BACKLIGHT_DISABLE_AFTER_TIMEOUT 0
+
+// the default effect (RGB test)
+#define RGB_BACKLIGHT_EFFECT 255
+
+// These define which keys in the matrix are alphas/mods
+// Used for backlight effects so colors are different for
+// alphas vs. mods
+// Each value is for a row, bit 0 is column 0
+// Alpha=0 Mod=1
+#define RGB_BACKLIGHT_ALPHAS_MODS_ROW_0 0
+#define RGB_BACKLIGHT_ALPHAS_MODS_ROW_1 0
+#define RGB_BACKLIGHT_ALPHAS_MODS_ROW_2 0
+#define RGB_BACKLIGHT_ALPHAS_MODS_ROW_3 0
+#define RGB_BACKLIGHT_ALPHAS_MODS_ROW_4 0
+#define DYNAMIC_KEYMAP_LAYER_COUNT 4
// EEPROM usage
@@ -127,3 +157,4 @@
#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35
// Dynamic keymap starts after backlight config (35+37)
#define DYNAMIC_KEYMAP_EEPROM_ADDR 72
+
diff --git a/keyboards/rama/m6_b/m6_b.c b/keyboards/rama/m6_b/m6_b.c
index e7cd2f6287..581b31d753 100644
--- a/keyboards/rama/m6_b/m6_b.c
+++ b/keyboards/rama/m6_b/m6_b.c
@@ -13,218 +13,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "m6_b.h"
-#include "m6_b_api.h"
-
-// Check that no backlight functions are called
-#if RGB_BACKLIGHT_ENABLED
-#include "rgb_backlight.h"
-#endif // RGB_BACKLIGHT_ENABLED
-
-#include "raw_hid.h"
-#include "dynamic_keymap.h"
-#include "timer.h"
-#include "tmk_core/common/eeprom.h"
-
-bool eeprom_is_valid(void)
-{
- return (eeprom_read_word(((void*)EEPROM_MAGIC_ADDR)) == EEPROM_MAGIC &&
- eeprom_read_byte(((void*)EEPROM_VERSION_ADDR)) == EEPROM_VERSION);
-}
-
-void eeprom_set_valid(bool valid)
-{
- eeprom_update_word(((void*)EEPROM_MAGIC_ADDR), valid ? EEPROM_MAGIC : 0xFFFF);
- eeprom_update_byte(((void*)EEPROM_VERSION_ADDR), valid ? EEPROM_VERSION : 0xFF);
-}
-
-void eeprom_reset(void)
-{
- // Set the keyboard-specific EEPROM state as invalid.
- eeprom_set_valid(false);
- // Set the TMK/QMK EEPROM state as invalid.
- eeconfig_disable();
-}
-
-#ifdef RAW_ENABLE
-
-void raw_hid_receive( uint8_t *data, uint8_t length )
-{
- uint8_t *command_id = &(data[0]);
- uint8_t *command_data = &(data[1]);
- switch ( *command_id )
- {
- case id_get_protocol_version:
- {
- command_data[0] = PROTOCOL_VERSION >> 8;
- command_data[1] = PROTOCOL_VERSION & 0xFF;
- break;
- }
- case id_get_keyboard_value:
- {
- if ( command_data[0] == id_uptime )
- {
- uint32_t value = timer_read32();
- command_data[1] = (value >> 24 ) & 0xFF;
- command_data[2] = (value >> 16 ) & 0xFF;
- command_data[3] = (value >> 8 ) & 0xFF;
- command_data[4] = value & 0xFF;
- }
- else
- {
- *command_id = id_unhandled;
- }
- break;
- }
-#ifdef DYNAMIC_KEYMAP_ENABLE
- case id_dynamic_keymap_get_keycode:
- {
- uint16_t keycode = dynamic_keymap_get_keycode( command_data[0], command_data[1], command_data[2] );
- command_data[3] = keycode >> 8;
- command_data[4] = keycode & 0xFF;
- break;
- }
- case id_dynamic_keymap_set_keycode:
- {
- dynamic_keymap_set_keycode( command_data[0], command_data[1], command_data[2], ( command_data[3] << 8 ) | command_data[4] );
- break;
- }
- case id_dynamic_keymap_reset:
- {
- dynamic_keymap_reset();
- break;
- }
-#endif // DYNAMIC_KEYMAP_ENABLE
-#if RGB_BACKLIGHT_ENABLED
- case id_backlight_config_set_value:
- {
- //backlight_config_set_value(command_data);
- break;
- }
- case id_backlight_config_get_value:
- {
- //backlight_config_get_value(command_data);
- break;
- }
- case id_backlight_config_save:
- {
- //backlight_config_save();
- break;
- }
-#endif // RGB_BACKLIGHT_ENABLED
- case id_eeprom_reset:
- {
- eeprom_reset();
- break;
- }
- case id_bootloader_jump:
- {
- // Need to send data back before the jump
- // Informs host that the command is handled
- raw_hid_send( data, length );
- // Give host time to read it
- wait_ms(100);
- bootloader_jump();
- break;
- }
- default:
- {
- // Unhandled message.
- *command_id = id_unhandled;
- break;
- }
- }
-
- // Return same buffer with values changed
- raw_hid_send( data, length );
-
-}
-
+#ifndef RGB_BACKLIGHT_M6_B
+#error RGB_BACKLIGHT_M6_B not defined, you done goofed somehao, brah
#endif
-
-void main_init(void)
-{
- // If the EEPROM has the magic, the data is good.
- // OK to load from EEPROM.
- if (eeprom_is_valid()) {
-#if RGB_BACKLIGHT_ENABLED
- //backlight_config_load();
-#endif // RGB_BACKLIGHT_ENABLED
- } else {
-#if RGB_BACKLIGHT_ENABLED
- // If the EEPROM has not been saved before, or is out of date,
- // save the default values to the EEPROM. Default values
- // come from construction of the zeal_backlight_config instance.
- //backlight_config_save();
-#endif // RGB_BACKLIGHT_ENABLED
-#ifdef DYNAMIC_KEYMAP_ENABLE
- // This resets the keymaps in EEPROM to what is in flash.
- dynamic_keymap_reset();
-#endif
- // Save the magic number last, in case saving was interrupted
- eeprom_set_valid(true);
- }
-#if RGB_BACKLIGHT_ENABLED
- // Initialize LED drivers for backlight.
- backlight_init_drivers();
-
- backlight_timer_init();
- backlight_timer_enable();
-#endif // RGB_BACKLIGHT_ENABLED
-}
-
-void bootmagic_lite(void)
-{
- // The lite version of TMK's bootmagic.
- // 100% less potential for accidentally making the
- // keyboard do stupid things.
-
- // We need multiple scans because debouncing can't be turned off.
- matrix_scan();
- wait_ms(DEBOUNCING_DELAY);
- wait_ms(DEBOUNCING_DELAY);
- matrix_scan();
-
- // If the Esc (matrix 0,0) is held down on power up,
- // reset the EEPROM valid state and jump to bootloader.
- if ( matrix_get_row(0) & (1<<0) ) {
- eeprom_reset();
- bootloader_jump();
- }
-}
-
-void matrix_init_kb(void) {
- bootmagic_lite();
- main_init();
- matrix_init_user();
-}
-
-void matrix_scan_kb(void) {
-#if RGB_BACKLIGHT_ENABLED
- // This only updates the LED driver buffers if something has changed.
- backlight_update_pwm_buffers();
-#endif // BACKLIGHT_ENABLED
- matrix_scan_user();
-}
-
-bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
- return process_record_user(keycode, record);
-}
-
-void led_set_kb(uint8_t usb_led) {
- led_set_user(usb_led);
-}
-
-void suspend_power_down_kb(void)
-{
-#if RGB_BACKLIGHT_ENABLED
- //backlight_set_suspend_state(true);
-#endif // BACKLIGHT_ENABLED
-}
-
-void suspend_wakeup_init_kb(void)
-{
-#if RGB_BACKLIGHT_ENABLED
- //backlight_set_suspend_state(false);
-#endif // BACKLIGHT_ENABLED
-}
diff --git a/keyboards/rama/m6_b/m6_b_api.h b/keyboards/rama/m6_b/m6_b_api.h
deleted file mode 100644
index 041fd6e6ee..0000000000
--- a/keyboards/rama/m6_b/m6_b_api.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright 2017 Jason Williams (Wilba)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#pragma once
-
-#define PROTOCOL_VERSION 0x0001
-
-enum m6_b_command_id
-{
- id_get_protocol_version = 0x01, // always 0x01
- id_get_keyboard_value,
- id_set_keyboard_value,
- id_dynamic_keymap_get_keycode,
- id_dynamic_keymap_set_keycode,
- id_dynamic_keymap_reset,
- id_backlight_config_set_value,
- id_backlight_config_get_value,
- id_backlight_config_save,
- id_eeprom_reset,
- id_bootloader_jump,
- id_unhandled = 0xFF,
-};
-
-enum m6_b_keyboard_value_id
-{
- id_uptime = 0x01
-};
diff --git a/keyboards/rama/m6_b/rgb_backlight.c b/keyboards/rama/m6_b/rgb_backlight.c
deleted file mode 100644
index 8f7ac06303..0000000000
--- a/keyboards/rama/m6_b/rgb_backlight.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Copyright 2018 Jason Williams (Wilba)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#if RGB_BACKLIGHT_ENABLED
-
-#include "rgb_backlight.h"
-//#include "rgb_backlight_api.h"
-
-#include <avr/io.h>
-#include <util/delay.h>
-#include <avr/interrupt.h>
-#include "progmem.h"
-
-#include "quantum/color.h"
-#include "drivers/avr/i2c_master.h"
-#include "drivers/issi/is31fl3218.h"
-
-bool g_suspend_state = false;
-
-// Global tick at 20 Hz
-uint32_t g_tick = 0;
-uint8_t g_config_effect_speed = 0;
-uint8_t g_config_brightness = 255;
-
-void backlight_update_pwm_buffers(void)
-{
- IS31FL3218_update_pwm_buffers();
-}
-
-void backlight_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
-{
- IS31FL3218_set_color( index, red, green, blue );
-}
-
-void backlight_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
-{
- IS31FL3218_set_color_all( red, green, blue );
-}
-
-
-// This is (F_CPU/1024) / 20 Hz
-// = 15625 Hz / 20 Hz
-// = 781
-#define TIMER3_TOP 260
-
-void backlight_timer_init(void)
-{
- static uint8_t backlight_timer_is_init = 0;
- if ( backlight_timer_is_init )
- {
- return;
- }
- backlight_timer_is_init = 1;
-
- // Timer 3 setup
- TCCR3B = _BV(WGM32) | // CTC mode OCR3A as TOP
- _BV(CS32) | _BV(CS30); // prescale by /1024
- // Set TOP value
- uint8_t sreg = SREG;
- cli();
-
- OCR3AH = (TIMER3_TOP >> 8) & 0xff;
- OCR3AL = TIMER3_TOP & 0xff;
- SREG = sreg;
-}
-
-void backlight_timer_enable(void)
-{
- TIMSK3 |= _BV(OCIE3A);
-}
-
-void backlight_timer_disable(void)
-{
- TIMSK3 &= ~_BV(OCIE3A);
-}
-
-void backlight_set_suspend_state(bool state)
-{
- g_suspend_state = state;
-}
-
-void backlight_effect_cycle_all(void)
-{
- uint8_t hueOffset = ( g_tick << g_config_effect_speed ) & 0xFF;
- uint8_t satOffset = 127;
- // Relies on hue being 8-bit and wrapping
- for ( int i=0; i<6; i++ )
- {
- HSV hsv = { .h = hueOffset, .s = satOffset, .v = g_config_brightness };
- RGB rgb = hsv_to_rgb( hsv );
- backlight_set_color( i, rgb.r, rgb.g, rgb.b );
- }
-}
-
-ISR(TIMER3_COMPA_vect)
-{
- // delay 1 second before driving LEDs or doing anything else
- static uint8_t startup_tick = 0;
- if ( startup_tick < 20 )
- {
- startup_tick++;
- return;
- }
-
- g_tick++;
-
- if ( g_suspend_state )
- {
- backlight_set_color_all( 0, 0, 0 );
- }
- else
- {
- //HSV hsv = { .h = 240, .s = 255, .v = g_config_brightness };
- //RGB rgb = hsv_to_rgb( hsv );
- //backlight_set_color_all( rgb.r, rgb.g, rgb.b );
- backlight_effect_cycle_all();
- }
-}
-
-void backlight_init_drivers(void)
-{
- // Initialize I2C
- i2c_init();
- IS31FL3218_init();
-}
-
-#endif // RGB_BACKLIGHT_ENABLED
diff --git a/keyboards/rama/m6_b/rgb_backlight.h b/keyboards/rama/m6_b/rgb_backlight.h
deleted file mode 100644
index bbf605284b..0000000000
--- a/keyboards/rama/m6_b/rgb_backlight.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2018 Jason Williams (Wilba)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#pragma once
-
-#if RGB_BACKLIGHT_ENABLED
-#else
-#error rgb_backlight.h included when RGB_BACKLIGHT_ENABLED == 0
-#endif // RGB_BACKLIGHT_ENABLED
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include "quantum/color.h"
-
-void backlight_init_drivers(void);
-void backlight_update_pwm_buffers(void);
-void backlight_timer_init(void);
-void backlight_timer_enable(void);
-void backlight_timer_disable(void);
-void backlight_set_suspend_state(bool state);
-
diff --git a/keyboards/rama/m6_b/rules.mk b/keyboards/rama/m6_b/rules.mk
index 8226debd45..1a7466af37 100644
--- a/keyboards/rama/m6_b/rules.mk
+++ b/keyboards/rama/m6_b/rules.mk
@@ -1,5 +1,6 @@
# project specific files
-SRC = rgb_backlight.c \
+SRC = ../zeal60/zeal60.c \
+ ../zeal60/rgb_backlight.c \
quantum/color.c \
drivers/issi/is31fl3218.c \
drivers/avr/i2c_master.c
@@ -56,22 +57,23 @@ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
# Build Options
# change yes to no to disable
#
-BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
+BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
-CONSOLE_ENABLE = no # Console for debug(+400)
+CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration
-# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
-SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
-# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
-NKRO_ENABLE = yes # USB Nkey Rollover
-BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
-MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
+NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
+MIDI_ENABLE = no # MIDI controls
+AUDIO_ENABLE = no # Audio output on port C6
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
-AUDIO_ENABLE = no # Audio output on port C6
-FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
+RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
+
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
RAW_ENABLE = yes
DYNAMIC_KEYMAP_ENABLE = yes
CIE1931_CURVE = yes
+