Skip to content

Commit

Permalink
[Painter] Begin initial add of layer map rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna committed Aug 6, 2024
1 parent 2502657 commit a3a10f4
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
3 changes: 3 additions & 0 deletions users/drashna/display/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ char qp_keylog_str[QP_KEYLOGGER_LENGTH] = {0};
#ifdef KEYLOGGER_ENABLE
bool keylogger_has_changed = true;
#endif
#ifdef LAYER_MAP_ENABLE
__attribute__((unused)) bool layer_map_has_updated = true;
#endif

// clang-format off
const char PROGMEM code_to_name[256] = {
Expand Down
1 change: 1 addition & 0 deletions users/drashna/display/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "progmem.h"

extern bool keylogger_has_changed;
extern bool layer_map_has_updated;
extern const char PROGMEM code_to_name[256];

bool process_record_display_driver(uint16_t keycode, keyrecord_t* record);
Expand Down
33 changes: 33 additions & 0 deletions users/drashna/display/painter/ili9341_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#ifdef RTC_ENABLE
# include "features/rtc/rtc.h"
#endif
#ifdef LAYER_MAP_ENABLE
# include "features/layer_map.h"
#endif

#include <math.h>
#include <stdio.h>
Expand Down Expand Up @@ -698,6 +701,36 @@ __attribute__((weak)) void ili9341_draw_user(void) {
qp_rect(ili9341_display, xpos, ypos, max_rtc_xpos, ypos + font_oled->line_height, 0, 0, 0, true);
}
#endif // RTC_ENABLE

// Layer Map render
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifdef LAYER_MAP_ENABLE
ypos -= (font_oled->line_height + 4) * LAYER_MAP_ROWS;
if (hue_redraw || layer_map_has_updated) {
uint16_t temp_ypos = ypos;
for (uint8_t y = 0; y < LAYER_MAP_ROWS; y++) {
xpos = 25;
for (uint8_t x = 0; x < LAYER_MAP_COLS; x++) {
uint16_t keycode = extract_basic_keycode(layer_map[y][x], NULL, false);
char code = 0;
if (keycode > 0xFF) {
keycode = KC_SPC;
}
if (keycode < ARRAY_SIZE(code_to_name)) {
code = pgm_read_byte(&code_to_name[keycode]);
}
snprintf(buf, sizeof(buf), "%c", code);
xpos += qp_drawtext_recolor(ili9341_display, xpos, temp_ypos, font_oled, buf, curr_hue, 255, 255, 0,
0, peek_matrix_layer_map(y, x) ? 255 : 0) +
5;
}
temp_ypos += font_oled->line_height + 4;
}
layer_map_has_updated = false;
}

#endif
}
qp_flush(ili9341_display);
}
8 changes: 7 additions & 1 deletion users/drashna/features/layer_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
volatile uint16_t layer_map[LAYER_MAP_ROWS][LAYER_MAP_COLS] = {0};
static bool layer_map_set = false;
extern bool peek_matrix(uint8_t row_index, uint8_t col_index, bool read_raw);
#ifdef CUSTOM_QUANTUM_PAINTER_ENABLE
extern bool layer_map_has_updated;
#endif

void set_layer_map(void) {
layer_map_set = true;
Expand Down Expand Up @@ -41,6 +44,9 @@ void populate_layer_map(void) {
}
// xprintf("\n");
}
#ifdef CUSTOM_QUANTUM_PAINTER_ENABLE
layer_map_has_updated = true;
#endif
}

bool peek_matrix_layer_map(uint8_t row, uint8_t col) {
Expand All @@ -50,7 +56,7 @@ bool peek_matrix_layer_map(uint8_t row, uint8_t col) {
}
return peek_matrix(layer_remap[row][col].row, layer_remap[row][col].col, false);
#else
if (row = > KEYLOC_DIP_SWITCH_OFF) {
if (row >= KEYLOC_DIP_SWITCH_OFF) {
return false;
}
return peek_matrix(row, col, false);
Expand Down

0 comments on commit a3a10f4

Please sign in to comment.