Skip to content

Commit

Permalink
Remove bitfile from uart daq args
Browse files Browse the repository at this point in the history
Add OK device to docs
Add todos for docs to new meta category
  • Loading branch information
sneakers-the-rat committed Oct 31, 2023
1 parent ed85bf4 commit e362b2c
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 8 deletions.
11 changes: 11 additions & 0 deletions docs/api/devices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Devices

Interfaces to external devices like miniscopes and DAQs

## OpalKelly

```{eval-rst}
.. autoclass:: miniscope_io.devices.opalkelly.okDev
:members:
:undoc-members:
```
1 change: 1 addition & 0 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:caption: API
data
devices
formats
io
sdcard
Expand Down
8 changes: 6 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
'sphinx.ext.napoleon',
'sphinx.ext.autodoc',
'sphinxcontrib.autodoc_pydantic',
'sphinx.ext.intersphinx'
'sphinx.ext.intersphinx',
'sphinx.ext.todo'
]

templates_path = ['_templates']
Expand Down Expand Up @@ -68,4 +69,7 @@
# autodoc
# Mock imports for packages we don't have yet - this one is
# for opal kelley stuff we need to figure out the licensing for
autodoc_mock_imports = ['routine']
autodoc_mock_imports = ['routine']

# todo
todo_include_todos = True
7 changes: 6 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ guide/index
:caption: Contents:
api/index
changelog
```

```{toctree}
:caption: Meta:
meta/index
```


Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions docs/meta/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Meta


```{toctree}
changelog
todo
```

4 changes: 4 additions & 0 deletions docs/meta/todo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# TODO

```{todolist}
```
10 changes: 10 additions & 0 deletions miniscope_io/devices/opalkelly.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@


class okDev(ok.okCFrontPanel):
"""
I/O and configuration for an (what kind of opal kelly device?)
.. todo::
Phil: document what this thing does, including how bitfiles work
and how they're generated/where they're located.
"""
def __init__(self, serial_id: str = ""):
super().__init__()
ret = self.OpenBySerial("")
Expand All @@ -17,6 +26,7 @@ def __init__(self, serial_id: str = ""):
print("Connected to {}".format(self.info.productName))

def uploadBit(self, bit_file: str):

ret = self.ConfigureFPGA(bit_file)
if ret == self.NoError:
print("Succesfully uploaded {}".format(bit_file))
Expand Down
19 changes: 14 additions & 5 deletions miniscope_io/uart_daq.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import time
from datetime import datetime
import warnings
from typing import Literal

import coloredlogs
import cv2
Expand Down Expand Up @@ -34,6 +35,14 @@


class uart_daq:
"""
A combined class for reading frames from a UART and FPGA source.
.. todo::
Phil/Takuya - docstrings for uart daq: what devices these correspond to, how to configure them, usage examples, tests
"""
def __init__(
self,
frame_width: int = 304,
Expand Down Expand Up @@ -121,7 +130,7 @@ def _uart_recv(self, serial_buffer_queue, comport: str, baudrate: int):
sys.exit(1)

def _fpga_recv(
self, serial_buffer_queue, bit_file, read_length=None, pre_first=True
self, serial_buffer_queue, read_length=None, pre_first=True
):
if not HAVE_OK:
raise RuntimeError('Couldnt import OpalKelly device. Check the docs for install instructions!')
Expand All @@ -147,7 +156,6 @@ def _fpga_recv(
coloredlogs.install(level=logging.INFO, logger=locallogs)
# set up fpga devices
dev = okDev()
dev.uploadBit(bit_file)
dev.setWire(0x00, 0b0010)
time.sleep(0.01)
dev.setWire(0x00, 0b0)
Expand Down Expand Up @@ -332,11 +340,10 @@ def _format_frame(self, frame_buffer_queue, imagearray):
# COM port should probably be automatically found but not sure yet how to distinguish with other devices.
def capture(
self,
source: str,
source: Literal['uart', 'fpga'],
comport: str = "COM3",
baudrate: int = 1200000,
mode: str = "DEBUG",
bit_file: str = "/Users/mbrosch/Downloads/USBInterface/USBInterface-6mhz-3v3-INVERSE.bit",
read_length: int = None,
):
logdirectories = [
Expand Down Expand Up @@ -388,10 +395,12 @@ def capture(
target=self._fpga_recv,
args=(
serial_buffer_queue,
bit_file,
read_length,
),
)
else:
raise ValueError(f'source can be one of uart or fpga. Got {source}')

p_buffer_to_frame = multiprocessing.Process(
target=self._buffer_to_frame,
args=(
Expand Down

0 comments on commit e362b2c

Please sign in to comment.