Organize pomodoro

main
Ashelyn Dawn 3 years ago
parent 00010e432a
commit 2a6e36bf62

@ -1,5 +1,6 @@
#include "keymap.h"
#include "lighting.h"
#include "pomodoro.h"
#define _TL _TALI_LAYER
#define _T2 _TALI_LAYER2
@ -338,89 +339,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}
#define POM_CURRENT_INDEX 68
#define POM_LIGHT_COUNT 9
#define POM_COMPLETE_INDEX POM_CURRENT_INDEX + POM_LIGHT_COUNT + 1
#define POM_DURATION 1500 /* 25 * 60 */
void draw_pom(void) {
static bool blink_on;
static short last_pos;
const uint8_t complete_hsv[3] = {HSV_TEAL};
const uint8_t current_hsv[3] = {HSV_GOLDENROD};
const uint8_t hidden_hsv[3] = C_MODI;
// Clear row
if (pom_visible) {
if (current_pom_state != STOPPED) {
for(int i = POM_CURRENT_INDEX; i < POM_CURRENT_INDEX + POM_LIGHT_COUNT; i++)
hsv_matrix_set_color(i, (uint8_t[3]){0, 0, 0});
}
for(int i = POM_COMPLETE_INDEX; i < POM_COMPLETE_INDEX + 3; i++)
hsv_matrix_set_color(i, (uint8_t[3]){0, 0, 0});
}
// Draw completed
if (pom_visible) {
for(int i = POM_COMPLETE_INDEX; i < POM_COMPLETE_INDEX + poms_completed && i < POM_COMPLETE_INDEX + 3; i++ ) {
hsv_matrix_set_color(i, complete_hsv);
}
} else if (poms_completed > 0 && poms_completed <= 3) {
const short completed_position = POM_COMPLETE_INDEX + poms_completed - 1;
hsv_matrix_set_color(completed_position, hidden_hsv);
}
if (current_pom_state == STOPPED)
return;
const short current_pos = POM_CURRENT_INDEX + (short)((float)pom_current_secs / POM_DURATION * POM_LIGHT_COUNT);
if(last_pos != current_pos) {
last_pos = current_pos;
blink_on = true;
} else if (pom_second_start == 0) {
blink_on = !blink_on;
}
// Current solid
if (pom_visible) {
for(int i = POM_CURRENT_INDEX; i < current_pos; i++) {
hsv_matrix_set_color(i, current_hsv);
}
}
// Current blinking
if (blink_on) {
if (pom_visible) {
hsv_matrix_set_color(current_pos, current_hsv);
} else {
hsv_matrix_set_color(current_pos, hidden_hsv);
}
}
}
void count_pom(void) {
// Start ms counter
if(pom_second_start == 0)
pom_second_start = timer_read32();
// Check if second completed
if (timer_elapsed32(pom_second_start) > 1000) {
pom_second_start = 0;
pom_current_secs++;
}
// Check if pom completed
if (pom_current_secs >= POM_DURATION) {
poms_completed++;
current_pom_state = STOPPED;
pom_current_secs = 0;
pom_second_start = 0;
}
}
void rgb_matrix_indicators_user(void) {
if (g_suspend_state || disable_layer_color ||
rgb_matrix_get_flags() == LED_FLAG_NONE ||

@ -32,16 +32,4 @@ enum layout_names {
extern bool g_suspend_state;
bool disable_layer_color;
enum pom_state {
STOPPED,
RUNNING,
PAUSED
};
enum pom_state current_pom_state;
bool pom_visible;
short poms_completed;
short pom_current_secs;
uint32_t pom_second_start;
void send_alt_code(int);

@ -0,0 +1,86 @@
#include "keymap.h"
#include "pomodoro.h"
#include "lighting.h"
#define POM_CURRENT_INDEX 68
#define POM_LIGHT_COUNT 9
#define POM_COMPLETE_INDEX POM_CURRENT_INDEX + POM_LIGHT_COUNT + 1
#define POM_DURATION 1500 /* 25 * 60 */
void draw_pom(void) {
static bool blink_on;
static short last_pos;
const uint8_t complete_hsv[3] = {HSV_TEAL};
const uint8_t current_hsv[3] = {HSV_GOLDENROD};
const uint8_t hidden_hsv[3] = C_MODI;
// Clear row
if (pom_visible) {
if (current_pom_state != STOPPED) {
for(int i = POM_CURRENT_INDEX; i < POM_CURRENT_INDEX + POM_LIGHT_COUNT; i++)
hsv_matrix_set_color(i, (uint8_t[3]){0, 0, 0});
}
for(int i = POM_COMPLETE_INDEX; i < POM_COMPLETE_INDEX + 3; i++)
hsv_matrix_set_color(i, (uint8_t[3]){0, 0, 0});
}
// Draw completed
if (pom_visible) {
for(int i = POM_COMPLETE_INDEX; i < POM_COMPLETE_INDEX + poms_completed && i < POM_COMPLETE_INDEX + 3; i++ ) {
hsv_matrix_set_color(i, complete_hsv);
}
} else if (poms_completed > 0 && poms_completed <= 3) {
const short completed_position = POM_COMPLETE_INDEX + poms_completed - 1;
hsv_matrix_set_color(completed_position, hidden_hsv);
}
if (current_pom_state == STOPPED)
return;
const short current_pos = POM_CURRENT_INDEX + (short)((float)pom_current_secs / POM_DURATION * POM_LIGHT_COUNT);
if(last_pos != current_pos) {
last_pos = current_pos;
blink_on = true;
} else if (pom_second_start == 0) {
blink_on = !blink_on;
}
// Current solid
if (pom_visible) {
for(int i = POM_CURRENT_INDEX; i < current_pos; i++) {
hsv_matrix_set_color(i, current_hsv);
}
}
// Current blinking
if (blink_on) {
if (pom_visible) {
hsv_matrix_set_color(current_pos, current_hsv);
} else {
hsv_matrix_set_color(current_pos, hidden_hsv);
}
}
}
void count_pom(void) {
// Start ms counter
if(pom_second_start == 0)
pom_second_start = timer_read32();
// Check if second completed
if (timer_elapsed32(pom_second_start) > 1000) {
pom_second_start = 0;
pom_current_secs++;
}
// Check if pom completed
if (pom_current_secs >= POM_DURATION) {
poms_completed++;
current_pom_state = STOPPED;
pom_current_secs = 0;
pom_second_start = 0;
}
}

@ -0,0 +1,16 @@
#pragma once
enum pom_state {
STOPPED,
RUNNING,
PAUSED
};
enum pom_state current_pom_state;
bool pom_visible;
short poms_completed;
short pom_current_secs;
uint32_t pom_second_start;
void draw_pom(void);
void count_pom(void);

@ -14,4 +14,4 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
# COMBO_ENABLE # Key combo feature
# LEADER_ENABLE # Enable leader key chording
SRC += lighting_funcs.c
SRC += lighting_funcs.c pomodoro.c
Loading…
Cancel
Save