Open clickworkorange opened 7 years ago
To put it another way, could you list the steps required to get the IVPort operational without referring to specific libraries (e.g. picamera.py, ivport.py). I understand it needs to be initialised over i2c, and that certain GPIO pins need to be set high/low, and possibly additional i2c commands sent during capture - but which i2c commands/registers/values, and which GPIO pins set how exactly?
Ah. The reason I couldn't locate the source code for iic.py
was just that I was looking in the wrong place; I expected it to be a third party library, but it's right here in the root of this project :) Having looked at it, it appears that the i2c initialisation command needed is:
address = 0x70
register = 0x00
value = 0x01
Though I am unsure what exactly the "value" means in this case; the iic.py file lists four possible:
iic_bus0 = (0x01)
iic_bus1 = (0x02)
iic_bus2 = (0x04)
iic_bus3 = (0x08)
Do these correspond to the four camera ports on the four port IVPort?
I think I can answer that myself now: you need to both switch the GPIO pin and send the channel selection over i2c. Only by pulling the chosen GPIO high and sending 0x02 to register 0x00 at address 0x70 do I get captures from camera 2. If I omit either step (GPIO / i2c) then the capture fails. Conversely, to switch back to camera 1 I need to set the GPIO low and send 0x01 to the same address and register. I would still like to hear IVMech confirm this though, and I'm curious about the timing too; which one of these steps should happen first?
These lines make things a lot clearer: https://github.com/ivmech/ivport-v2/blob/523314bdcb9166a5bd99383bb097f70d115729e1/ivport.py#L89-L94
I'm trying to get an IVPort v2 dual to work with Node-RED and need to use the default picamera library. So I've been trying to figure out exactly what changes you've made to it, and which of them must be present to get stock picamera to work. I'm specifically looking at the
iviic = IIC.IIC(addr=(0x70), bus_enable =(0x01))
andiviic.write_control_register((0x01))
It seems you define an i2c device with the first command though I expected this would be in the format address=, register=, value=. I'm unable to locate the repository for the IIC Python library and would like to know what exactly these two commands do?