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.
[QP] Add support for OLED, variable framebuffer bpp (qmk#19997)
Co-authored-by: Pablo Martínez <58857054+elpekenin@users.noreply.github.com> Co-authored-by: Dasky <32983009+daskygit@users.noreply.github.com> Fixup delta frame coordinates after qmk#20296.
- Loading branch information
Showing
51 changed files
with
1,610 additions
and
497 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
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
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,34 @@ | ||
// Copyright 2023 Nick Brassel (@tzarc) | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#ifdef QUANTUM_PAINTER_DUMMY_COMMS_ENABLE | ||
|
||
# include "qp_comms_dummy.h" | ||
|
||
static bool dummy_comms_init(painter_device_t device) { | ||
// No-op. | ||
return true; | ||
} | ||
|
||
static bool dummy_comms_start(painter_device_t device) { | ||
// No-op. | ||
return true; | ||
} | ||
|
||
static void dummy_comms_stop(painter_device_t device) { | ||
// No-op. | ||
} | ||
|
||
uint32_t dummy_comms_send(painter_device_t device, const void *data, uint32_t byte_count) { | ||
// No-op. | ||
return byte_count; | ||
} | ||
|
||
painter_comms_vtable_t dummy_comms_vtable = { | ||
// These are all effective no-op's because they're not actually needed. | ||
.comms_init = dummy_comms_init, | ||
.comms_start = dummy_comms_start, | ||
.comms_stop = dummy_comms_stop, | ||
.comms_send = dummy_comms_send}; | ||
|
||
#endif // QUANTUM_PAINTER_DUMMY_COMMS_ENABLE |
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 Nick Brassel (@tzarc) | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
#pragma once | ||
|
||
#ifdef QUANTUM_PAINTER_DUMMY_COMMS_ENABLE | ||
|
||
# include "qp_internal.h" | ||
|
||
extern painter_comms_vtable_t dummy_comms_vtable; | ||
|
||
#endif // QUANTUM_PAINTER_DUMMY_COMMS_ENABLE |
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,94 @@ | ||
// Copyright 2022 Nick Brassel (@tzarc) | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#ifdef QUANTUM_PAINTER_I2C_ENABLE | ||
|
||
# include "i2c_master.h" | ||
# include "qp_comms_i2c.h" | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Helpers | ||
|
||
static uint32_t qp_comms_i2c_send_raw(painter_device_t device, const void *data, uint32_t byte_count) { | ||
painter_driver_t * driver = (painter_driver_t *)device; | ||
qp_comms_i2c_config_t *comms_config = (qp_comms_i2c_config_t *)driver->comms_config; | ||
i2c_status_t res = i2c_transmit(comms_config->chip_address << 1, data, byte_count, I2C_TIMEOUT); | ||
if (res < 0) { | ||
return 0; | ||
} | ||
return byte_count; | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Base I2C support | ||
|
||
bool qp_comms_i2c_init(painter_device_t device) { | ||
i2c_init(); | ||
return true; | ||
} | ||
|
||
bool qp_comms_i2c_start(painter_device_t device) { | ||
painter_driver_t * driver = (painter_driver_t *)device; | ||
qp_comms_i2c_config_t *comms_config = (qp_comms_i2c_config_t *)driver->comms_config; | ||
return i2c_start(comms_config->chip_address << 1) == I2C_STATUS_SUCCESS; | ||
} | ||
|
||
uint32_t qp_comms_i2c_send_data(painter_device_t device, const void *data, uint32_t byte_count) { | ||
return qp_comms_i2c_send_raw(device, data, byte_count); | ||
} | ||
|
||
void qp_comms_i2c_stop(painter_device_t device) { | ||
i2c_stop(); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Command+Data I2C support | ||
|
||
static const uint8_t cmd_byte = 0x00; | ||
static const uint8_t data_byte = 0x40; | ||
|
||
void qp_comms_i2c_cmddata_send_command(painter_device_t device, uint8_t cmd) { | ||
uint8_t buf[2] = {cmd_byte, cmd}; | ||
qp_comms_i2c_send_raw(device, &buf, 2); | ||
} | ||
|
||
uint32_t qp_comms_i2c_cmddata_send_data(painter_device_t device, const void *data, uint32_t byte_count) { | ||
uint8_t buf[1 + byte_count]; | ||
buf[0] = data_byte; | ||
memcpy(&buf[1], data, byte_count); | ||
if (qp_comms_i2c_send_raw(device, buf, sizeof(buf)) != sizeof(buf)) { | ||
return 0; | ||
} | ||
return byte_count; | ||
} | ||
|
||
void qp_comms_i2c_bulk_command_sequence(painter_device_t device, const uint8_t *sequence, size_t sequence_len) { | ||
uint8_t buf[32]; | ||
for (size_t i = 0; i < sequence_len;) { | ||
uint8_t command = sequence[i]; | ||
uint8_t delay = sequence[i + 1]; | ||
uint8_t num_bytes = sequence[i + 2]; | ||
buf[0] = cmd_byte; | ||
buf[1] = command; | ||
memcpy(&buf[2], &sequence[i + 3], num_bytes); | ||
qp_comms_i2c_send_raw(device, buf, num_bytes + 2); | ||
if (delay > 0) { | ||
wait_ms(delay); | ||
} | ||
i += (3 + num_bytes); | ||
} | ||
} | ||
|
||
const painter_comms_with_command_vtable_t i2c_comms_cmddata_vtable = { | ||
.base = | ||
{ | ||
.comms_init = qp_comms_i2c_init, | ||
.comms_start = qp_comms_i2c_start, | ||
.comms_send = qp_comms_i2c_cmddata_send_data, | ||
.comms_stop = qp_comms_i2c_stop, | ||
}, | ||
.send_command = qp_comms_i2c_cmddata_send_command, | ||
.bulk_command_sequence = qp_comms_i2c_bulk_command_sequence, | ||
}; | ||
|
||
#endif // QUANTUM_PAINTER_I2C_ENABLE |
Oops, something went wrong.