Skip to content

Commit

Permalink
#393 Add NULL waveform + first test
Browse files Browse the repository at this point in the history
  • Loading branch information
martinberlin committed Jan 28, 2025
1 parent 0c8a4af commit 0f82037
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 30 deletions.
33 changes: 15 additions & 18 deletions examples/vcom-kickback/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,30 @@ int temperature = 25;
EpdRect dragon_area = { .x = 0, .y = 0, .width = dragon_width, .height = dragon_height };

void idf_loop() {
epd_fullclear(&hl, temperature);
epd_copy_to_framebuffer(dragon_area, dragon_data, epd_hl_get_framebuffer(&hl));
// Supposedly to measure VCOM the display needs to update
// all the time with a NULL waveform (That we don't know how it is)
// MODE_GC16 or MODE_DU ?
//vTaskDelay(pdMS_TO_TICKS(1));
//epd_fill_rect(epd_full_screen(), 0, epd_hl_get_framebuffer(&hl));
epd_hl_update_screen(&hl, MODE_DU, temperature);

tps_vcom_kickback_rdy();
vTaskDelay(20);
/*
epd_fill_rect(epd_full_screen(), 255, epd_hl_get_framebuffer(&hl));
epd_hl_update_screen(&hl, MODE_GC16, temperature);
vTaskDelay(100); */
}

void idf_setup() {
epd_init(&DEMO_BOARD, &ED097TC2, EPD_LUT_64K);
hl = epd_hl_init(EPD_BUILTIN_WAVEFORM);


hl = epd_hl_init(&epdiy_NULL);
tps_vcom_kickback();
tps_vcom_kickback_start();

while ( 1 ) {
idf_loop();
for (int a = 5; a>0; a--) {
idf_loop();
}
tps_vcom_kickback_start();

int isrdy = 1;
int kickback_volt = 0;
while (kickback_volt == 0) {
idf_loop();
isrdy++;
kickback_volt = tps_vcom_kickback_rdy();
}
printf("VCOM reading of %d mV. was ready in %d refreshes\n", kickback_volt, isrdy);

}

#ifndef ARDUINO_ARCH_ESP32
Expand Down
3 changes: 1 addition & 2 deletions src/board/epd_board_v7.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ static void epd_board_measure_vcom(epd_ctrl_state_t* state) {
while (!(pca9555_read_input(config_reg.port, 1) & CFG_PIN_PWRGOOD)) {
}
ESP_LOGI("epdiy", "Power rails enabled");
// Replace for vcom kick-back: We will not set VCOM in this mode
//tps_set_vcom(config_reg.port, vcom);

state->ep_sth = true;
mask = (const epd_ctrl_state_t){
.ep_sth = true,
Expand Down
29 changes: 19 additions & 10 deletions src/board/tps65185.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,34 +102,43 @@ void tps_vcom_kickback() {
printf("VCOM Kickback test\n");
// Pull the WAKEUP pin and the PWRUP pin high to enable all output rails.
// But do not set VCOM to any voltage!
epd_current_board()->measure_vcom(epd_ctrl_state());

// Set the HiZ bit in the VCOM2 register (BIT 5) 0x20
epd_current_board()->measure_vcom(epd_ctrl_state());
// Set the HiZ bit in the VCOM2 register (BIT 5) 0x20
// This puts the VCOM pin in a high-impedance state.
tps_write_register(I2C_NUM_0, 4, 0x20);
}
// PLUS
// BIT 3 & 4 Number of acquisitions that is averaged to a single kick-back V. measurement
tps_write_register(I2C_NUM_0, 4, 0x38);
vTaskDelay(1);

uint8_t int1reg = tps_read_register(I2C_NUM_0, TPS_REG_INT1);
uint8_t vcomreg = tps_read_register(I2C_NUM_0, TPS_REG_VCOM2);
printf("kickback INT1: %x VCOM: %x\n\n", int1reg, vcomreg);

}

/**
* @brief Start measurements
*/
void tps_vcom_kickback_start() {
uint8_t int1reg = tps_read_register(I2C_NUM_0, TPS_REG_INT1);
printf("kickstart INT1: %x\n\n", int1reg);
// Set the ACQ bit in the VCOM2 register to 1 (BIT 7)
tps_write_register(I2C_NUM_0, 4, 0x80);
tps_write_register(I2C_NUM_0, TPS_REG_VCOM2, 0xA0); // BIT 5 + 7
}

/**
* @brief ACQC (Acquisition Complete) bit in the INT1 register is set
* //lbs &= 0xFF;mbs &= 0x100 >> 8;
* @return mV 0 is not read!
*/
unsigned tps_vcom_kickback_rdy() {
// ACQC (Acquisition Complete) bit in the INT1 register is set?
if (tps_read_register(I2C_NUM_0, TPS_REG_INT1) == 0x02) {
uint8_t int1reg = tps_read_register(I2C_NUM_0, TPS_REG_INT1);

if (int1reg == 0x02) {
uint8_t lsb = tps_read_register(I2C_NUM_0, 3);
uint8_t msb = tps_read_register(I2C_NUM_0, 4);
int u16Value = (lsb | (msb << 8)) & 0x1ff;
printf("Kickback lsb:%d msb:%d result:%d\n\n", lsb, msb, u16Value);
return u16Value;
return u16Value *10;
} else {
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/builtin_waveforms.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
#include "waveforms/epdiy_ED097OC4.h"
#include "waveforms/epdiy_ED097TC2.h"
#include "waveforms/epdiy_ED133UT2.h"
#include "waveforms/epdiy_NULL.h"
1 change: 1 addition & 0 deletions src/epd_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ extern const EpdWaveform epdiy_ED097TC2;
extern const EpdWaveform epdiy_ED060XC3;
extern const EpdWaveform epdiy_ED060SCT;
extern const EpdWaveform epdiy_ED133UT2;
extern const EpdWaveform epdiy_NULL;

/// Font data stored PER GLYPH
typedef struct {
Expand Down
28 changes: 28 additions & 0 deletions src/waveforms/epdiy_NULL.h

Large diffs are not rendered by default.

0 comments on commit 0f82037

Please sign in to comment.