summaryrefslogtreecommitdiffstats
path: root/keyboards/tzarc/djinn
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2022-06-20 14:20:56 +1000
committerGitHub <noreply@github.com>2022-06-20 14:20:56 +1000
commitaa06893b58ac3ed88e796968d237f60f4c156875 (patch)
treead4b3a637b7bba88de772dd50150262d2992603e /keyboards/tzarc/djinn
parentad2e85361128a2252798a7bb4c1cbc0bcd58e8ab (diff)
Add Djinn. (#17382)
* Add Djinn. * Review comments. * Further cleanup.
Diffstat (limited to 'keyboards/tzarc/djinn')
-rw-r--r--keyboards/tzarc/djinn/config.h74
-rw-r--r--keyboards/tzarc/djinn/djinn.c199
-rw-r--r--keyboards/tzarc/djinn/djinn.h32
-rw-r--r--keyboards/tzarc/djinn/djinn_portscan_matrix.c117
-rw-r--r--keyboards/tzarc/djinn/djinn_split_sync.c58
-rw-r--r--keyboards/tzarc/djinn/djinn_usbpd.c28
-rw-r--r--keyboards/tzarc/djinn/graphics/djinn.qgf.c246
-rw-r--r--keyboards/tzarc/djinn/graphics/djinn.qgf.h11
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-caps-OFF.qgf.c31
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-caps-OFF.qgf.h11
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-caps-ON.qgf.c32
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-caps-ON.qgf.h11
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-num-OFF.qgf.c31
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-num-OFF.qgf.h11
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-num-ON.qgf.c32
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-num-ON.qgf.h11
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-scrl-OFF.qgf.c32
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-scrl-OFF.qgf.h11
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-scrl-ON.qgf.c32
-rw-r--r--keyboards/tzarc/djinn/graphics/lock-scrl-ON.qgf.h11
-rw-r--r--keyboards/tzarc/djinn/graphics/theme_djinn_default.c307
-rw-r--r--keyboards/tzarc/djinn/graphics/theme_djinn_default.h19
-rw-r--r--keyboards/tzarc/djinn/graphics/thintel15.qff.c74
-rw-r--r--keyboards/tzarc/djinn/graphics/thintel15.qff.h11
-rw-r--r--keyboards/tzarc/djinn/halconf.h14
-rw-r--r--keyboards/tzarc/djinn/info.json140
-rw-r--r--keyboards/tzarc/djinn/keymaps/default/config.h60
-rw-r--r--keyboards/tzarc/djinn/keymaps/default/keymap.c107
-rw-r--r--keyboards/tzarc/djinn/keymaps/default/rules.mk15
-rw-r--r--keyboards/tzarc/djinn/mcuconf.h30
-rw-r--r--keyboards/tzarc/djinn/readme.md27
-rw-r--r--keyboards/tzarc/djinn/rev1/config.h35
-rw-r--r--keyboards/tzarc/djinn/rev1/info.json98
-rw-r--r--keyboards/tzarc/djinn/rev1/rev1.c3
-rw-r--r--keyboards/tzarc/djinn/rev1/rev1.h3
-rw-r--r--keyboards/tzarc/djinn/rev1/rules.mk1
-rw-r--r--keyboards/tzarc/djinn/rev2/config.h47
-rw-r--r--keyboards/tzarc/djinn/rev2/info.json100
-rw-r--r--keyboards/tzarc/djinn/rev2/rev2.c3
-rw-r--r--keyboards/tzarc/djinn/rev2/rev2.h3
-rw-r--r--keyboards/tzarc/djinn/rev2/rules.mk1
-rw-r--r--keyboards/tzarc/djinn/rules.mk23
42 files changed, 2142 insertions, 0 deletions
diff --git a/keyboards/tzarc/djinn/config.h b/keyboards/tzarc/djinn/config.h
new file mode 100644
index 0000000000..005784b98d
--- /dev/null
+++ b/keyboards/tzarc/djinn/config.h
@@ -0,0 +1,74 @@
+// Copyright 2018-2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+#include "config_common.h"
+
+// Encoders -- right-side is reversed
+#define ENCODERS_PAD_A \
+ { C14 }
+#define ENCODERS_PAD_B \
+ { C15 }
+#define ENCODERS_PAD_A_RIGHT \
+ { C15 }
+#define ENCODERS_PAD_B_RIGHT \
+ { C14 }
+
+#ifndef ENCODER_RESOLUTION
+# define ENCODER_RESOLUTION 2
+#endif // ENCODER_RESOLUTION
+
+// Bootloader
+#define STM32_BOOTLOADER_DUAL_BANK TRUE
+#define STM32_BOOTLOADER_DUAL_BANK_GPIO B7
+
+// Peripheral power control pins
+#define LCD_POWER_ENABLE_PIN A6
+
+// Split configuration
+#define SPLIT_TRANSACTION_IDS_KB RPC_ID_SYNC_STATE_KB
+#define SPLIT_TRANSPORT_MIRROR
+#define SPLIT_LAYER_STATE_ENABLE
+#define SPLIT_LED_STATE_ENABLE
+#define SPLIT_MODS_ENABLE
+#define SPLIT_WPM_ENABLE
+
+// SPI Configuration
+#define SPI_DRIVER SPID3
+#define SPI_SCK_PIN C10
+#define SPI_SCK_PAL_MODE 6
+#define SPI_MOSI_PIN C12
+#define SPI_MOSI_PAL_MODE 6
+#define SPI_MISO_PIN C11
+#define SPI_MISO_PAL_MODE 6
+
+// LCD Configuration
+#define LCD_RST_PIN B3
+#define LCD_CS_PIN D2
+#define LCD_DC_PIN A15
+#ifndef LCD_ACTIVITY_TIMEOUT
+# define LCD_ACTIVITY_TIMEOUT 30000
+#endif // LCD_ACTIVITY_TIMEOUT
+
+// Backlight driver (to control LCD backlight)
+#define BACKLIGHT_LEVELS 4
+#define BACKLIGHT_PWM_DRIVER PWMD17
+#define BACKLIGHT_PWM_CHANNEL 1
+#define BACKLIGHT_PAL_MODE 1
+
+// RGB configuration
+#define RGB_DI_PIN B2
+#define WS2812_EXTERNAL_PULLUP
+#define WS2812_PWM_DRIVER PWMD20
+#define WS2812_PWM_CHANNEL 1
+#define WS2812_PWM_PAL_MODE 3
+#define WS2812_DMA_STREAM STM32_DMA1_STREAM1
+#define WS2812_DMA_CHANNEL 1
+#define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM20_UP
+
+// Audio configuration
+#define AUDIO_PIN A5
+#define AUDIO_PIN_ALT A4
+#define AUDIO_PIN_ALT_AS_NEGATIVE
+#ifndef STARTUP_SONG
+# define STARTUP_SONG SONG(STARTUP_SOUND)
+#endif // STARTUP_SONG
diff --git a/keyboards/tzarc/djinn/djinn.c b/keyboards/tzarc/djinn/djinn.c
new file mode 100644
index 0000000000..41155a6584
--- /dev/null
+++ b/keyboards/tzarc/djinn/djinn.c
@@ -0,0 +1,199 @@
+// Copyright 2018-2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <string.h>
+#include "quantum.h"
+#include <hal_pal.h>
+#include "djinn.h"
+#include "serial.h"
+#include "split_util.h"
+#include "qp.h"
+
+painter_device_t lcd;
+
+// clang-format off
+#ifdef SWAP_HANDS_ENABLE
+const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
+ { { 6, 6 }, { 5, 6 }, { 4, 6 }, { 3, 6 }, { 2, 6 }, { 1, 6 }, { 0, 6 } },
+ { { 6, 7 }, { 5, 7 }, { 4, 7 }, { 3, 7 }, { 2, 7 }, { 1, 7 }, { 0, 7 } },
+ { { 6, 8 }, { 5, 8 }, { 4, 8 }, { 3, 8 }, { 2, 8 }, { 1, 8 }, { 0, 8 } },
+ { { 6, 9 }, { 5, 9 }, { 4, 9 }, { 3, 9 }, { 2, 9 }, { 1, 9 }, { 0, 9 } },
+ { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 6, 10 }, { 5, 10 }, { 4, 10 }, { 3, 10 } },
+ { { 0, 0 }, { 6, 11 }, { 5, 11 }, { 4, 11 }, { 3, 11 }, { 2, 11 }, { 1, 11 } },
+
+ { { 6, 0 }, { 5, 0 }, { 4, 0 }, { 3, 0 }, { 2, 0 }, { 1, 0 }, { 0, 0 } },
+ { { 6, 1 }, { 5, 1 }, { 4, 1 }, { 3, 1 }, { 2, 1 }, { 1, 1 }, { 0, 1 } },
+ { { 6, 2 }, { 5, 2 }, { 4, 2 }, { 3, 2 }, { 2, 2 }, { 1, 2 }, { 0, 2 } },
+ { { 6, 3 }, { 5, 3 }, { 4, 3 }, { 3, 3 }, { 2, 3 }, { 1, 3 }, { 0, 3 } },
+ { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 6, 4 }, { 5, 4 }, { 4, 4 }, { 3, 4 } },
+ { { 0, 0 }, { 6, 5 }, { 5, 5 }, { 4, 5 }, { 3, 5 }, { 2, 5 }, { 1, 5 } },
+};
+# ifdef ENCODER_MAP_ENABLE
+const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS] = { 1, 0 };
+# endif // ENCODER_MAP_ENABLE
+#endif // SWAP_HANDS_ENABLE
+// clang-format on
+
+void board_init(void) {
+ usbpd_init();
+}
+
+//----------------------------------------------------------
+// Initialisation
+
+void keyboard_post_init_kb(void) {
+ // Register keyboard state sync split transaction
+ transaction_register_rpc(RPC_ID_SYNC_STATE_KB, kb_state_sync_slave);
+
+ // Reset the initial shared data value between master and slave
+ memset(&kb_state, 0, sizeof(kb_state));
+
+ // Turn off increased current limits
+ setPinOutput(RGB_CURR_1500mA_OK_PIN);
+ writePinLow(RGB_CURR_1500mA_OK_PIN);
+ setPinOutput(RGB_CURR_3000mA_OK_PIN);
+ writePinLow(RGB_CURR_3000mA_OK_PIN);
+
+ // Turn on the RGB
+ setPinOutput(RGB_POWER_ENABLE_PIN);
+ writePinHigh(RGB_POWER_ENABLE_PIN);
+
+#ifdef EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN
+ setPinOutput(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN);
+ writePinHigh(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN);
+#endif // EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN
+
+ // Turn on the LCD
+ setPinOutput(LCD_POWER_ENABLE_PIN);
+ writePinHigh(LCD_POWER_ENABLE_PIN);
+
+ // Let the LCD get some power...
+ wait_ms(150);
+
+ // Initialise the LCD
+ lcd = qp_ili9341_make_spi_device(320, 240, LCD_CS_PIN, LCD_DC_PIN, LCD_RST_PIN, 4, 3);
+ qp_init(lcd, QP_ROTATION_0);
+
+ // Turn on the LCD and clear the display
+ kb_state.lcd_power = 1;
+ qp_power(lcd, true);
+ qp_rect(lcd, 0, 0, 239, 319, HSV_BLACK, true);
+
+ // Turn on the LCD backlight
+ backlight_enable();
+ backlight_level(BACKLIGHT_LEVELS);
+
+ // Allow for user post-init
+ keyboard_post_init_user();
+}
+
+//----------------------------------------------------------
+// RGB brightness scaling dependent on USBPD state
+
+#if defined(RGB_MATRIX_ENABLE)
+RGB rgb_matrix_hsv_to_rgb(HSV hsv) {
+ float scale;
+ switch (kb_state.current_setting) {
+ default:
+ case USBPD_500MA:
+ scale = 0.35f;
+ break;
+ case USBPD_1500MA:
+ scale = 0.75f;
+ break;
+ case USBPD_3000MA:
+ scale = 1.0f;
+ break;
+ }
+
+ hsv.v = (uint8_t)(hsv.v * scale);
+ return hsv_to_rgb(hsv);
+}
+#endif
+
+//----------------------------------------------------------
+// UI Placeholder, implemented in themes
+
+__attribute__((weak)) void draw_ui_user(void) {}
+
+//----------------------------------------------------------
+// Housekeeping
+
+void housekeeping_task_kb(void) {
+ // Update kb_state so we can send to slave
+ kb_state_update();
+
+ // Data sync from master to slave
+ kb_state_sync();
+
+ // Work out if we've changed our current limit, update the limiter circuit switches
+ static uint8_t current_setting = USBPD_500MA;
+ if (current_setting != kb_state.current_setting) {
+ current_setting = kb_state.current_setting;
+ switch (current_setting) {
+ default:
+ case USBPD_500MA:
+ writePinLow(RGB_CURR_1500mA_OK_PIN);
+ writePinLow(RGB_CURR_3000mA_OK_PIN);
+ break;
+ case USBPD_1500MA:
+ writePinHigh(RGB_CURR_1500mA_OK_PIN);
+ writePinLow(RGB_CURR_3000mA_OK_PIN);
+ break;
+ case USBPD_3000MA:
+ writePinHigh(RGB_CURR_1500mA_OK_PIN);
+ writePinHigh(RGB_CURR_3000mA_OK_PIN);
+ break;
+ }
+
+ // If we've changed the current limit, toggle rgb off and on if it was on, to force a brightness update on all LEDs
+ if (is_keyboard_master() && rgb_matrix_is_enabled()) {
+ rgb_matrix_disable_noeeprom();
+ rgb_matrix_enable_noeeprom();
+ }
+ }
+
+ // Turn on/off the LCD
+ static bool lcd_on = false;
+ if (lcd_on != (bool)kb_state.lcd_power) {
+ lcd_on = (bool)kb_state.lcd_power;
+ qp_power(lcd, lcd_on);
+ }
+
+ // Enable/disable RGB
+ if (lcd_on) {
+ // Turn on RGB
+ writePinHigh(RGB_POWER_ENABLE_PIN);
+ // Modify the RGB state if different to the LCD state
+ if (rgb_matrix_is_enabled() != lcd_on) {
+ // Wait for a small amount of time to allow the RGB capacitors to charge, before enabling RGB output
+ wait_ms(10);
+ // Enable RGB
+ rgb_matrix_enable_noeeprom();
+ }
+ } else {
+ // Turn off RGB
+ writePinLow(RGB_POWER_ENABLE_PIN);
+ // Disable the PWM output for the RGB
+ if (rgb_matrix_is_enabled() != lcd_on) {
+ rgb_matrix_disable_noeeprom();
+ }
+ }
+
+ // Match the backlight to the LCD state
+ if (is_keyboard_master() && is_backlight_enabled() != lcd_on) {
+ if (lcd_on)
+ backlight_enable();
+ else
+ backlight_disable();
+ }
+
+ // Draw the UI
+ if (kb_state.lcd_power) {
+ draw_ui_user();
+ }
+
+ // Go into low-scan interrupt-based mode if we haven't had any matrix activity in the last 250 milliseconds
+ if (last_input_activity_elapsed() > 250) {
+ matrix_wait_for_interrupt();
+ }
+} \ No newline at end of file
diff --git a/keyboards/tzarc/djinn/djinn.h b/keyboards/tzarc/djinn/djinn.h
new file mode 100644
index 0000000000..ff6b555e8e
--- /dev/null
+++ b/keyboards/tzarc/djinn/djinn.h
@@ -0,0 +1,32 @@
+// Copyright 2018-2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+#include "quantum.h"
+#include "qp.h"
+
+//----------------------------------------------------------
+// General stuff
+
+extern painter_device_t lcd;
+
+void matrix_wait_for_interrupt(void);
+
+void usbpd_update(void);
+const char* usbpd_str(usbpd_allowance_t allowance);
+
+//----------------------------------------------------------
+// Runtime data sync -- keyboard
+
+#pragma pack(push)
+#pragma pack(1)
+typedef struct kb_runtime_config {
+ unsigned lcd_power : 1;
+ usbpd_allowance_t current_setting : 2;
+} kb_runtime_config;
+#pragma pack(pop)
+
+extern kb_runtime_config kb_state;
+
+void kb_state_update(void);
+void kb_state_sync(void);
+void kb_state_sync_slave(uint8_t m2s_size, const void* m2s_buffer, uint8_t s2m_size, void* s2m_buffer);
diff --git a/keyboards/tzarc/djinn/djinn_portscan_matrix.c b/keyboards/tzarc/djinn/djinn_portscan_matrix.c
new file mode 100644
index 0000000000..f0ae9721f9
--- /dev/null
+++ b/keyboards/tzarc/djinn/djinn_portscan_matrix.c
@@ -0,0 +1,117 @@
+// Copyright 2018-2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include "quantum.h"
+#include <hal_pal.h>
+#include "djinn.h"
+
+#define GPIOB_BITMASK (1 << 13 | 1 << 14 | 1 << 15) // B13, B14, B15
+#define GPIOB_OFFSET 13
+#define GPIOB_COUNT 3
+#define GPIOC_BITMASK (1 << 6 | 1 << 7 | 1 << 8) // C6, C7, C8
+#define GPIOC_OFFSET 6
+
+// Pin definitions
+static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
+static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
+
+void matrix_wait_for_pin(pin_t pin, uint8_t target_state) {
+ rtcnt_t start = chSysGetRealtimeCounterX();
+ rtcnt_t end = start + 5000;
+ while (chSysIsCounterWithinX(chSysGetRealtimeCounterX(), start, end)) {
+ if (readPin(pin) == target_state) {
+ break;
+ }
+ }
+}
+
+void matrix_wait_for_port(stm32_gpio_t *port, uint32_t target_bitmask) {
+ rtcnt_t start = chSysGetRealtimeCounterX();
+ rtcnt_t end = start + 5000;
+ while (chSysIsCounterWithinX(chSysGetRealtimeCounterX(), start, end)) {
+ if ((palReadPort(port) & target_bitmask) == target_bitmask) {
+ break;
+ }
+ }
+}
+
+void matrix_init_custom(void) {
+ for (int i = 0; i < MATRIX_ROWS; ++i) {
+ setPinInputHigh(row_pins[i]);
+ }
+ for (int i = 0; i < MATRIX_COLS; ++i) {
+ setPinInputHigh(col_pins[i]);
+ }
+}
+
+bool matrix_scan_custom(matrix_row_t current_matrix[]) {
+ static matrix_row_t temp_matrix[MATRIX_ROWS] = {0};
+
+ for (int current_col = 0; current_col < MATRIX_COLS; ++current_col) {
+ // Keep track of the pin we're working with
+ pin_t curr_col_pin = col_pins[current_col];
+
+ // Setup the output column pin
+ setPinOutput(curr_col_pin);
+ writePinLow(curr_col_pin);
+ matrix_wait_for_pin(curr_col_pin, 0);
+
+ // Read the row ports
+ uint32_t gpio_b = palReadPort(GPIOB);
+ uint32_t gpio_c = palReadPort(GPIOC);
+
+ // Unselect the row pin
+ setPinInputHigh(curr_col_pin);
+
+ // Construct the packed bitmask for the pins
+ uint32_t readback = ~(((gpio_b & GPIOB_BITMASK) >> GPIOB_OFFSET) | (((gpio_c & GPIOC_BITMASK) >> GPIOC_OFFSET) << GPIOB_COUNT));
+
+ // Inject values into the matrix
+ for (int i = 0; i < MATRIX_ROWS; ++i) {
+ if (readback & (1 << i)) {
+ temp_matrix[i] |= (1ul << current_col);
+ } else {
+ temp_matrix[i] &= ~(1ul << current_col);
+ }
+ }
+
+ // Wait for readback of the unselected column to go high
+ matrix_wait_for_pin(curr_col_pin, 1);
+
+ // Wait for readback of each port to go high -- unselecting the row would have been completed
+ matrix_wait_for_port(GPIOB, GPIOB_BITMASK);
+ matrix_wait_for_port(GPIOC, GPIOC_BITMASK);
+ }
+
+ // Check if we've changed, return the last-read data
+ bool changed = memcmp(current_matrix, temp_matrix, sizeof(temp_matrix)) != 0;
+ if (changed) {
+ memcpy(current_matrix, temp_matrix, sizeof(temp_matrix));
+ }
+ return changed;
+}
+
+void matrix_wait_for_interrupt(void) {
+ // Set up row/col pins and attach callback
+ for (int i = 0; i < sizeof(col_pins) / sizeof(pin_t); ++i) {
+ setPinOutput(col_pins[i]);
+ writePinLow(col_pins[i]);
+ }
+ for (int i = 0; i < sizeof(row_pins) / sizeof(pin_t); ++i) {
+ setPinInputHigh(row_pins[i]);
+ palEnableLineEvent(row_pins[i], PAL_EVENT_MODE_BOTH_EDGES);
+ }
+
+ // Wait for an interrupt
+ __WFI();
+
+ // Now that the interrupt has woken us up, reset all the row/col pins back to defaults
+ for (int i = 0; i < sizeof(row_pins) / sizeof(pin_t); ++i) {
+ palDisableLineEvent(row_pins[i]);
+ writePinHigh(row_pins[i]);
+ setPinInputHigh(row_pins[i]);
+ }
+ for (int i = 0; i < sizeof(col_pins) / sizeof(pin_t); ++i) {
+ writePinHigh(col_pins[i]);
+ setPinInputHigh(col_pins[i]);
+ }
+} \ No newline at end of file
diff --git a/keyboards/tzarc/djinn/djinn_split_sync.c b/keyboards/tzarc/djinn/djinn_split_sync.c
new file mode 100644
index 0000000000..3c7a58d155
--- /dev/null
+++ b/keyboards/tzarc/djinn/djinn_split_sync.c
@@ -0,0 +1,58 @@
+// Copyright 2018-2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <string.h>
+#include "quantum.h"
+#include "transactions.h"
+#include "split_util.h"
+#include "djinn.h"
+
+kb_runtime_config kb_state;
+uint32_t last_slave_sync_time = 0;
+
+void kb_state_update(void) {
+ if (is_keyboard_master()) {
+ // Modify allowed current limits
+ usbpd_update();
+
+ // Turn off the LCD if there's been no matrix activity
+ kb_state.lcd_power = (last_input_activity_elapsed() < LCD_ACTIVITY_TIMEOUT) ? 1 : 0;
+ }
+}
+
+void kb_state_sync(void) {
+ if (!is_transport_connected()) return;
+
+ if (is_keyboard_master()) {
+ // Keep track of the last state, so that we can tell if we need to propagate to slave
+ static kb_runtime_config last_kb_state;
+ static uint32_t last_sync;
+ bool needs_sync = false;
+
+ // Check if the state values are different
+ if (memcmp(&kb_state, &last_kb_state, sizeof(kb_runtime_config))) {
+ needs_sync = true;
+ memcpy(&last_kb_state, &kb_state, sizeof(kb_runtime_config));
+ }
+
+ // Send to slave every 500ms regardless of state change
+ if (timer_elapsed32(last_sync) > 500) {
+ needs_sync = true;
+ }
+
+ // Perform the sync if requested
+ if (needs_sync) {
+ if (transaction_rpc_send(RPC_ID_SYNC_STATE_KB, sizeof(kb_runtime_config), &kb_state)) {
+ last_sync = timer_read32();
+ } else {
+ dprint("Failed to perform data transaction\n");
+ }
+ }
+ }
+}
+
+void kb_state_sync_slave(uint8_t m2s_size, const void* m2s_buffer, uint8_t s2m_size, void* s2m_buffer) {
+ if (m2s_size == sizeof(kb_runtime_config)) {
+ memcpy(&kb_state, m2s_buffer, sizeof(kb_runtime_config));
+ last_slave_sync_time = timer_read32();
+ }
+}
diff --git a/keyboards/tzarc/djinn/djinn_usbpd.c b/keyboards/tzarc/djinn/djinn_usbpd.c
new file mode 100644
index 0000000000..b0bf166b7c
--- /dev/null
+++ b/keyboards/tzarc/djinn/djinn_usbpd.c
@@ -0,0 +1,28 @@
+// Copyright 2018-2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <string.h>
+#include "quantum.h"
+#include "djinn.h"
+
+const char* usbpd_str(usbpd_allowance_t allowance) {
+ switch (allowance) {
+ default:
+ case USBPD_500MA:
+ return "500mA";
+ case USBPD_1500MA:
+ return "1500mA";
+ case USBPD_3000MA:
+ return "3000mA";
+ }
+}
+
+void usbpd_update(void) {
+ static uint32_t last_read = 0;
+ if (timer_elapsed32(last_read) > 250) {
+ usbpd_allowance_t allowance = usbpd_get_allowance();
+ if (kb_state.current_setting != allowance) {
+ dprintf("Transitioning UCPD1 %s -> %s\n", usbpd_str(kb_state.current_setting), usbpd_str(allowance));
+ kb_state.current_setting = allowance;
+ }
+ }
+} \ No newline at end of file
diff --git a/keyboards/tzarc/djinn/graphics/djinn.qgf.c b/keyboards/tzarc/djinn/graphics/djinn.qgf.c
new file mode 100644
index 0000000000..0acdf6ebb5
--- /dev/null
+++ b/keyboards/tzarc/djinn/graphics/djinn.qgf.c
@@ -0,0 +1,246 @@
+// Copyright 2022 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 djinn.png -f mono4`
+
+#include <qp.h>
+
+const uint32_t gfx_djinn_length = 3724;
+
+// clang-format off
+const uint8_t gfx_djinn[3724] = {
+ 0x00, 0xFF, 0x12, 0x00, 0x00, 0x51, 0x47, 0x46, 0x01, 0x8C, 0x0E, 0x00, 0x00, 0x73, 0xF1, 0xFF,
+ 0xFF, 0x66, 0x00, 0x20, 0x01, 0x01, 0x00, 0x01, 0xFE, 0x04, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x02, 0xFD, 0x06, 0x00, 0x00, 0x01, 0x00, 0x01, 0xFF, 0xE8, 0x03, 0x05, 0xFA, 0x5C, 0x0E, 0x00,
+ 0x58, 0x00, 0x80, 0x90, 0x19, 0x00, 0x80, 0x2D, 0x18, 0x00, 0x81, 0xE0, 0x07, 0x18, 0x00, 0x81,
+ 0xFE, 0x01, 0x17, 0x00, 0x81, 0xF4, 0x2F, 0x17, 0x00, 0x82, 0x80, 0xFF, 0x07, 0x17, 0x00, 0x82,
+ 0xFD, 0xFF, 0x01, 0x16, 0x00, 0x82, 0xE0, 0xFF, 0x2F, 0x16, 0x00, 0x80, 0x80, 0x02, 0xFF, 0x80,
+ 0x03, 0x15, 0x00, 0x84, 0x40, 0xFE, 0xFF, 0x7F, 0x14, 0x15, 0x00, 0x80, 0xF9, 0x02, 0xFF, 0x81,
+ 0x4B, 0x1A, 0x14, 0x00, 0x80, 0xE4, 0x03, 0xFF, 0x81, 0xE0, 0x06, 0x13, 0x00, 0x80, 0xD0, 0x03,
+ 0xFF, 0x82, 0x0F, 0xBE, 0x01, 0x12, 0x00, 0x80, 0x80, 0x04, 0xFF, 0x81, 0xE0, 0x6F, 0x13, 0x00,
+ 0x80, 0xFE, 0x03, 0xFF, 0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0xF4, 0xFF, 0x0D, 0x00, 0x81, 0xFD, 0x0B, 0x09, 0x00, 0x81, 0xFE, 0x0B, 0x0C, 0x00, 0x81,
+ 0xD0, 0xBF, 0x09, 0x00, 0x81, 0xE0, 0xBF, 0x0D, 0x00, 0x81, 0xF9, 0x07, 0x09, 0x00, 0x81, 0xFD,
+ 0x07, 0x0C, 0x00, 0x81, 0x80, 0x7F, 0x09, 0x00, 0x81, 0xD0, 0x7F, 0x0D, 0x00, 0x81, 0xF8, 0x07,
+ 0x09, 0x00, 0x81, 0xF9, 0x03, 0x0C, 0x00, 0x81, 0x40, 0x7F, 0x09, 0x00, 0x81, 0x90, 0x2F, 0x0D,
+ 0x00, 0x81, 0xE0, 0x07, 0x09, 0x00, 0x81, 0xF8, 0x02, 0x0D, 0x00, 0x80, 0x7D, 0x09, 0x00, 0x81,
+ 0x80, 0x1F, 0x0D, 0x00, 0x81, 0x80, 0x07, 0x09, 0x00, 0x80, 0xB8, 0x0E, 0x00, 0x80, 0x74, 0x09,
+ 0x00, 0x81, 0x80, 0x0B, 0x0E, 0x00, 0x80, 0x0A, 0x03, 0x00, 0x80, 0x04, 0x05, 0x00, 0x80, 0x78,
+ 0x0E, 0x00, 0x80, 0x90, 0x03, 0x00, 0x83, 0xA4, 0x00, 0x80, 0x06, 0x02, 0x00, 0x81, 0x80, 0x02,
+ 0x0E, 0x00, 0x87, 0x04, 0x00, 0x40, 0xE9, 0x0B, 0x00, 0xF8, 0x5A, 0x02, 0x00, 0x80, 0x14, 0x10,
+ 0x00, 0x86, 0x40, 0xFA, 0xBF, 0x00, 0x40, 0xFF, 0x6B, 0x12, 0x00, 0x87, 0x90, 0xFE, 0xFF, 0x07,
+ 0x00, 0xE0, 0xFF, 0xAF, 0x11, 0x00, 0x80, 0x80, 0x02, 0xFF, 0x80, 0x1F, 0x02, 0x00, 0x82, 0xF9,
+ 0xFF, 0x2F, 0x11, 0x00, 0x82, 0xFE, 0xFF, 0x6F, 0x03, 0x00, 0x82, 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