Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Brendan Johan Lee 2017-01-24 21:56:18 +01:00
commit d0db044164
6 changed files with 72 additions and 8 deletions

View file

@ -49,7 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGBLIGHT_SAT_STEP 255
#define RGBLIGHT_VAL_STEP 12
#define RGB_MIDI
// #define RGB_MIDI
#define RGBW_BB_TWI
#define RGBW 1

View file

@ -52,9 +52,9 @@ uint8_t init_mcp23018(void) {
// I2C subsystem
uint8_t sreg_prev;
sreg_prev=SREG;
cli();
// uint8_t sreg_prev;
// sreg_prev=SREG;
// cli();
if (i2c_initialized == 0) {
i2c_init(); // on pins D(1,0)
i2c_initialized++;
@ -83,7 +83,7 @@ uint8_t init_mcp23018(void) {
out:
i2c_stop();
SREG=sreg_prev;
// SREG=sreg_prev;
return mcp23018_status;
}

View file

@ -114,6 +114,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
music_sequence_interval+=10;
return false;
}
#define MUSIC_MODE_GUITAR
#ifdef MUSIC_MODE_CHROMATIC
float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(music_starting_note + record->event.key.col + music_offset)/12.0+(MATRIX_ROWS - record->event.key.row));

View file

@ -53,10 +53,13 @@ SOFTWARE.
#define "Visualizer thread priority not defined"
#endif
// mods status
#include "action_util.h"
static visualizer_keyboard_status_t current_status = {
.layer = 0xFFFFFFFF,
.default_layer = 0xFFFFFFFF,
.mods = 0xFF,
.leds = 0xFFFFFFFF,
.suspended = false,
};
@ -64,6 +67,7 @@ static visualizer_keyboard_status_t current_status = {
static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboard_status_t* status2) {
return status1->layer == status2->layer &&
status1->default_layer == status2->default_layer &&
status1->mods == status2->mods &&
status1->leds == status2->leds &&
status1->suspended == status2->suspended;
}
@ -307,6 +311,45 @@ bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_s
gdispFlush();
return false;
}
static void format_mods_bitmap_string(uint8_t mods, char* buffer) {
*buffer = ' ';
++buffer;
for (int i = 0; i<8; i++)
{
uint32_t mask = (1u << i);
if (mods & mask) {
*buffer = '1';
} else {
*buffer = '0';
}
++buffer;
if (i==3) {
*buffer = ' ';
++buffer;
}
}
*buffer = 0;
}
bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)animation;
const char* title = "Modifier states";
const char* mods_header = " CSAG CSAG ";
char status_buffer[12];
gdispClear(White);
gdispDrawString(0, 0, title, state->font_fixed5x8, Black);
gdispDrawString(0, 10, mods_header, state->font_fixed5x8, Black);
format_mods_bitmap_string(state->status.mods, status_buffer);
gdispDrawString(0, 20, status_buffer, state->font_fixed5x8, Black);
gdispFlush();
return false;
}
#endif // LCD_ENABLE
bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) {
@ -350,6 +393,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
visualizer_keyboard_status_t initial_status = {
.default_layer = 0xFFFFFFFF,
.layer = 0xFFFFFFFF,
.mods = 0xFF,
.leds = 0xFFFFFFFF,
.suspended = false,
};
@ -499,7 +543,18 @@ void update_status(bool changed) {
#endif
}
void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds) {
uint8_t visualizer_get_mods() {
uint8_t mods = get_mods();
#ifndef NO_ACTION_ONESHOT
if (!has_oneshot_mods_timed_out()) {
mods |= get_oneshot_mods();
}
#endif
return mods;
}
void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uint32_t leds) {
// Note that there's a small race condition here, the thread could read
// a state where one of these are set but not the other. But this should
// not really matter as it will be fixed during the next loop step.
@ -523,6 +578,7 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds) {
visualizer_keyboard_status_t new_status = {
.layer = state,
.default_layer = default_state,
.mods = mods,
.leds = leds,
.suspended = current_status.suspended,
};

View file

@ -34,10 +34,14 @@ SOFTWARE.
#include "lcd_backlight.h"
#endif
// use this function to merget both real_mods and oneshot_mods in a uint16_t
uint8_t visualizer_get_mods(void);
// This need to be called once at the start
void visualizer_init(void);
// This should be called at every matrix scan
void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds);
void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uint32_t leds);
// This should be called when the keyboard goes to suspend state
void visualizer_suspend(void);
// This should be called when the keyboard wakes up from suspend state
@ -61,6 +65,7 @@ struct keyframe_animation_t;
typedef struct {
uint32_t layer;
uint32_t default_layer;
uint8_t mods;
uint32_t leds; // See led.h for available statuses
bool suspended;
} visualizer_keyboard_status_t;
@ -129,6 +134,8 @@ bool keyframe_set_backlight_color(keyframe_animation_t* animation, visualizer_st
bool keyframe_display_layer_text(keyframe_animation_t* animation, visualizer_state_t* state);
// Displays a bitmap (0/1) of all the currently active layers
bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state);
// Displays a bitmap (0/1) of all the currently active mods
bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_enable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state);

View file

@ -188,7 +188,7 @@ MATRIX_LOOP_END:
#endif
#ifdef VISUALIZER_ENABLE
visualizer_update(default_layer_state, layer_state, host_keyboard_leds());
visualizer_update(default_layer_state, layer_state, visualizer_get_mods(), host_keyboard_leds());
#endif
// update LED