Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cool project - any suggestions to get vcom value? #1

Closed
kimmobrunfeldt opened this issue Nov 21, 2022 · 4 comments
Closed

Cool project - any suggestions to get vcom value? #1

kimmobrunfeldt opened this issue Nov 21, 2022 · 4 comments

Comments

@kimmobrunfeldt
Copy link

kimmobrunfeldt commented Nov 21, 2022

Hi! I've been playing with the usb based controlling using https://sr.ht/~martijnbraam/it8951/ C code as the basis. I wasn't able to get the current vcom value using this code. Have you successfully queried the vcom value? The USB programming pdf sheet had an example command:

unsigned char get_vcom_cmd[16] = {
  0xfe, // Customer command.
  0x00,
  0x00,
  0x00,
  0x00,
  0x00,
  0xa3,  // PMIC (Power Management Integrated Circuits) command.
  0x00,
  0x00,
  0x00,   // Do Set VCom? (0 – no, 1 – yes)
  0x00,
  0x00,
  0x00,
  0x00,
  0x00,
  0x00,
};

but it didn't describe the return shape or length in bytes.

As a reference, Waveshare has a GPIO based C code example.

@adzialocha
Copy link
Owner

adzialocha commented Nov 22, 2022

Hey @kimmobrunfeldt! 👋

I just made an experiment and could retreive the data with the command you've mentioned. The result you're receiving is a "word" (that is two bytes, or 16 bit).

The VCOM value of my display is -1.58, which is represented as 1580 (decimal) or 062c (hex). When I run the 0xa3 command I receive 062c 👍 - this is the code I've used:

let data = [
    CUSTOMER_CMD, // 0xfe
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    PMIC_CONTROL_CMD, // 0xa3
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
];

// https://github.com/adzialocha/it8951-video/blob/main/src/usb.rs#L47
let result: u16 = self
    .connection
    .read_command(&data, bincode::options().with_big_endian())?;

println!("{:x}", result); // 062c

@kimmobrunfeldt
Copy link
Author

@adzialocha ok awesome, thanks for testing!
Then it seems like my C code might have an issue with reading data.

@kimmobrunfeldt
Copy link
Author

Finally figured it out with the help of your example code. I didn't spot the "FROM" vs "TO" difference before, now with correct communication direction it works: kimmobrunfeldt/eink-weather-display@84b60bf

@adzialocha
Copy link
Owner

Super ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants