forked from qmk/qmk_firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Joel Challis <[email protected]>
- Loading branch information
1 parent
16b528d
commit 3436d70
Showing
17 changed files
with
3,185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2023 Dasky (@daskygit) | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#pragma once | ||
|
||
#define DEBUG_MATRIX_SCAN_RATE // only want api | ||
|
||
#define SPI_DRIVER SPID0 | ||
#define SPI_SCK_PIN GP18 | ||
#define SPI_MOSI_PIN GP19 | ||
#define SPI_MISO_PIN GP16 | ||
|
||
#define DISPLAY_RST GP15 | ||
#define DISPLAY_CS GP21 | ||
#define DISPLAY_DC GP20 | ||
|
||
#define QUANTUM_PAINTER_SUPPORTS_256_PALETTE true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// Copyright 2023 Dasky (@daskygit) | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#include "display.h" | ||
#include "graphics/splash.qgf.h" | ||
#include "graphics/reverb.qgf.h" | ||
#include "graphics/robotomono20.qff.h" | ||
#include <stdio.h> | ||
#include <math.h> | ||
|
||
static painter_image_handle_t reverb_logo; | ||
static deferred_token display_task_token; | ||
static uint32_t key_pressed_count = 0; | ||
|
||
static uint8_t reverb_surface_fb[SURFACE_REQUIRED_BUFFER_BYTE_SIZE(240, 240, 16)]; | ||
|
||
painter_device_t reverb_surface; | ||
painter_device_t reverb_display; | ||
painter_font_handle_t roboto_font; | ||
|
||
uint32_t display_task_callback(uint32_t trigger_time, void *cb_arg) { | ||
display_task_kb(); | ||
return 100; | ||
} | ||
|
||
void display_init_kb(void) { | ||
reverb_display = qp_gc9a01_make_spi_device(240, 240, DISPLAY_CS, DISPLAY_DC, DISPLAY_RST, 2, 0); // always init display | ||
qp_init(reverb_display, QP_ROTATION_0); | ||
roboto_font = qp_load_font_mem(font_robotomono20); | ||
reverb_surface = qp_make_rgb565_surface(240, 240, reverb_surface_fb); | ||
qp_init(reverb_surface, QP_ROTATION_0); | ||
if (!display_init_user()) { | ||
return; | ||
} | ||
painter_image_handle_t splash_image; | ||
splash_image = qp_load_image_mem(gfx_splash); | ||
reverb_logo = qp_load_image_mem(gfx_reverb); | ||
qp_drawimage(reverb_display, 0, 0, splash_image); | ||
qp_flush(reverb_display); | ||
qp_close_image(splash_image); | ||
display_task_token = defer_exec(2000, display_task_callback, NULL); | ||
} | ||
|
||
__attribute__((weak)) bool display_init_user(void) { | ||
return true; | ||
} | ||
|
||
void display_task_kb(void) { | ||
if (!display_task_user()) { | ||
return; | ||
} | ||
static bool first_draw = true; | ||
static uint32_t last_timer = 0; | ||
static uint32_t last_wpm = UINT32_MAX; | ||
static uint32_t last_scan_rate = 0; | ||
static uint32_t last_key_pressed_count = UINT32_MAX; | ||
static uint8_t last_hue = 0; | ||
static uint8_t last_sat = 0; | ||
static uint8_t last_val = 0; | ||
bool rgb_redraw = false; | ||
|
||
if (first_draw) { | ||
qp_rect(reverb_display, 0, 0, 239, 239, 0, 0, 0, true); | ||
first_draw = false; | ||
} | ||
|
||
char buffer[64] = {0}; | ||
|
||
if (last_hue != rgb_matrix_get_hue() || last_sat != rgb_matrix_get_sat() || last_val != rgb_matrix_get_val()) { | ||
last_hue = rgb_matrix_get_hue(); | ||
last_sat = rgb_matrix_get_sat(); | ||
last_val = rgb_matrix_get_val(); | ||
qp_drawimage_recolor(reverb_surface, 60, 40, reverb_logo, rgb_matrix_get_hue(), rgb_matrix_get_sat(), MAX(rgb_matrix_get_val(), 128), 0, 0, 0); | ||
rgb_redraw = true; | ||
} | ||
|
||
if (rgb_redraw || last_scan_rate != get_matrix_scan_rate()) { | ||
snprintf(buffer, sizeof(buffer), "Scan Rate %ld", get_matrix_scan_rate()); | ||
int16_t width = qp_textwidth(roboto_font, buffer); | ||
qp_line(reverb_surface, 17, 101, 220, 101, rgb_matrix_get_hue(), rgb_matrix_get_sat(), MAX(rgb_matrix_get_val(), 128)); | ||
qp_rect(reverb_surface, 16, 125 - roboto_font->line_height, 221, 125, 0, 0, 0, true); | ||
qp_drawtext_recolor(reverb_surface, (120 - (width / 2)), (125 - roboto_font->line_height), roboto_font, buffer, rgb_matrix_get_hue(), rgb_matrix_get_sat(), MAX(rgb_matrix_get_val(), 128), 0, 0, 0); | ||
qp_line(reverb_surface, 16, 126, 221, 126, rgb_matrix_get_hue(), rgb_matrix_get_sat(), MAX(rgb_matrix_get_val(), 128)); | ||
last_scan_rate = get_matrix_scan_rate(); | ||
} | ||
if (rgb_redraw || last_key_pressed_count != key_pressed_count) { | ||
snprintf(buffer, sizeof(buffer), "Keys Pressed"); | ||
int16_t width = qp_textwidth(roboto_font, buffer); | ||
qp_rect(reverb_surface, 30, 150 - roboto_font->line_height, 209, 150, 0, 0, 0, true); | ||
qp_drawtext_recolor(reverb_surface, (120 - (width / 2)), (150 - roboto_font->line_height), roboto_font, buffer, rgb_matrix_get_hue(), rgb_matrix_get_sat(), MAX(rgb_matrix_get_val(), 128), 0, 0, 0); | ||
snprintf(buffer, sizeof(buffer), "%ld", key_pressed_count); | ||
width = qp_textwidth(roboto_font, buffer); | ||
qp_rect(reverb_surface, 30, 172 - roboto_font->line_height, 173, 172, 0, 0, 0, true); | ||
qp_drawtext_recolor(reverb_surface, (120 - (width / 2)), (172 - roboto_font->line_height), roboto_font, buffer, rgb_matrix_get_hue(), rgb_matrix_get_sat(), MAX(rgb_matrix_get_val(), 128), 0, 0, 0); | ||
qp_line(reverb_surface, 30, 173, 209, 173, rgb_matrix_get_hue(), rgb_matrix_get_sat(), MAX(rgb_matrix_get_val(), 128)); | ||
last_key_pressed_count = key_pressed_count; | ||
} | ||
if (rgb_redraw || last_wpm != get_current_wpm()) { | ||
snprintf(buffer, sizeof(buffer), "WPM %d", get_current_wpm()); | ||
int16_t width = qp_textwidth(roboto_font, buffer); | ||
qp_rect(reverb_surface, 56, 200 - roboto_font->line_height, 184, 200, 0, 0, 0, true); | ||
qp_drawtext_recolor(reverb_surface, (120 - (width / 2)), (200 - roboto_font->line_height), roboto_font, buffer, rgb_matrix_get_hue(), rgb_matrix_get_sat(), MAX(rgb_matrix_get_val(), 128), 0, 0, 0); | ||
qp_line(reverb_surface, 56, 201, 184, 201, rgb_matrix_get_hue(), rgb_matrix_get_sat(), MAX(rgb_matrix_get_val(), 128)); | ||
last_wpm = get_current_wpm(); | ||
} | ||
|
||
if (rgb_redraw || timer_elapsed(last_timer) >= 1000) { | ||
static uint8_t seconds = 0; | ||
static uint8_t x = 0; | ||
static uint8_t y = 0; | ||
if (x && y) { | ||
qp_circle(reverb_surface, x, y, 4, 0, 0, 0, true); | ||
} | ||
double radians = 0.10471975511966 * seconds; | ||
x = (110 * cos(radians)) + 119; | ||
y = (110 * sin(radians)) + 119; | ||
qp_circle(reverb_surface, x, y, 4, rgb_matrix_get_hue(), rgb_matrix_get_sat(), MAX(rgb_matrix_get_val(), 128), true); | ||
qp_circle(reverb_surface, 119, 119, 105, rgb_matrix_get_hue(), rgb_matrix_get_sat(), MAX(rgb_matrix_get_val(), 128), false); | ||
if (seconds == 59) { | ||
seconds = 0; | ||
} else if (timer_elapsed(last_timer) >= 1000) { | ||
last_timer = timer_read32(); | ||
seconds++; | ||
} | ||
} | ||
|
||
qp_surface_draw(reverb_surface, reverb_display, 0, 0, rgb_redraw); | ||
} | ||
|
||
__attribute__((weak)) bool display_task_user(void) { | ||
return true; | ||
} | ||
|
||
void display_key_counter(void) { | ||
if (key_pressed_count == UINT32_MAX) { | ||
key_pressed_count = 0; | ||
} | ||
key_pressed_count++; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2023 Dasky (@daskygit) | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#pragma once | ||
|
||
#include "qp.h" | ||
#include "qp_surface.h" | ||
|
||
extern painter_device_t reverb_surface; | ||
extern painter_device_t reverb_display; | ||
extern painter_font_handle_t roboto_font; | ||
|
||
void display_key_counter(void); | ||
void display_init_kb(void); | ||
bool display_init_user(void); | ||
void display_task_kb(void); | ||
bool display_task_user(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2023 QMK -- generated source code only, image retains original copyright | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
// This file was auto-generated by `qmk painter-convert-graphics -i reverb.png -f mono2` | ||
|
||
#include <qp.h> | ||
|
||
const uint32_t gfx_reverb_length = 736; | ||
|
||
// clang-format off | ||
const uint8_t gfx_reverb[736] = { | ||
0x00, 0xFF, 0x12, 0x00, 0x00, 0x51, 0x47, 0x46, 0x01, 0xE0, 0x02, 0x00, 0x00, 0x1F, 0xFD, 0xFF, | ||
0xFF, 0x78, 0x00, 0x32, 0x00, 0x01, 0x00, 0x01, 0xFE, 0x04, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | ||
0x02, 0xFD, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xE8, 0x03, 0x05, 0xFA, 0xB0, 0x02, 0x00, | ||
0x3C, 0x00, 0x8F, 0xF8, 0xFF, 0xC7, 0xFF, 0x3F, 0x30, 0x80, 0x83, 0xFF, 0x0F, 0xFF, 0xCF, 0xF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F0, 0x0F, 0x02, 0x3F, 0x83, 0xE0, 0x1F, 0xF8, | ||
0x07, 0x02, 0x3F, 0x86, 0x00, 0xE0, 0xFF, 0xFD, 0x03, 0xF0, 0x0F, 0x02, 0x3F, 0x83, 0xF0, 0x1F, | ||
0xF8, 0x07, 0x02, 0x3F, 0x93, 0x00, 0xE0, 0xFF, 0xFD, 0x03, 0xF0, 0x0F, 0x3F, 0x3E, 0xF8, 0x1F, | ||
0xF8, 0x07, 0x3E, 0xFE, 0xFF, 0xEF, 0xFF, 0xFD, 0xFF, 0x02, 0x0F, 0x8C, 0x3E, 0xFE, 0xFF, 0x0F, | ||
0xF8, 0x07, 0x3E, 0xFE, 0xFF, 0xEF, 0xFF, 0xFD, 0xFF, 0x02, 0x0F, 0x8C, 0x3E, 0xFC, 0xFF, 0x0F, | ||
0xF8, 0x07, 0x3E, 0xFC, 0xFF, 0xCF, 0xFF, 0xFC, 0xFF, 0x02, 0x0F, 0x8C, 0x3C, 0xFC, 0xFF, 0x07, | ||
0xF8, 0x07, 0x3C, 0xFC, 0xFF, 0xCF, 0xFF, 0xFC, 0xFF, 0x02, 0x0F, 0x8C, 0x3C, 0xF8, 0xFF, 0x03, | ||
0xF8, 0x07, 0x3C, 0xF8, 0xFF, 0xCF, 0xFF, 0xFC, 0xFF, 0x02, 0x0F, 0x8C, 0x38, 0xF8, 0xFF, 0x01, | ||
0xF8, 0x07, 0x38, 0xF8, 0xFF, 0xCF, 0xFF, 0xFC, 0xFF, 0x02, 0x0F, 0x91, 0x38, 0xF8, 0x7F, 0x00, | ||
0xF0, 0x07, 0x38, 0xF0, 0xFF, 0xCF, 0x7F, 0xFC, 0xFF, 0x0F, 0x0E, 0x30, 0xF0, 0x0F, 0x2E, 0x00, | ||
}; | ||
// clang-format on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2023 QMK -- generated source code only, image retains original copyright | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
// This file was auto-generated by `qmk painter-convert-graphics -i reverb.png -f mono2` | ||
|
||
#pragma once | ||
|
||
#include <qp.h> | ||
|
||
extern const uint32_t gfx_reverb_length; | ||
extern const uint8_t gfx_reverb[736]; |
Oops, something went wrong.