Skip to content

Commit

Permalink
Update old docs
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Aug 10, 2024
1 parent 5c8afd4 commit dad83dc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
14 changes: 3 additions & 11 deletions docs/c.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
# Camlib C API

Camlib uses *no macros*, so it's easy to use camlib from any language that has a basic C FFI. It would be trivial to
write a binding for Rust.
Camlib read and writes all data in a single buffer. When incoming data is parsed, it's also parsed in this buffer.
This reduces the number of memory allocations needed for a single transaction (generally it will be zero), and simplifies memory management.

Camlib also uses a single-buffer design. This means that all data, whether it comes in or out, is read, written, packed, and unpacked in a *single multi-megabyte buffer*.
This is not done to reduce memory usage, but to decrease complexity and reduce the number of `malloc()` calls. It also helps prevent rogue memory leaks, which
is crucial for apps, which have a very low memory limit.

This means that functions processing or using this data *must* keep the operation mutex locked until processing is done, so long as
the caller isn't making the application thread-safe. In a single-threaded application, there is no need for it to be thread-safe.

Camlib was designed to run on a single thread, through a thread-safe server returning `bind` requests. This works well
in many applications, but I'm slowly working on making it thread-safe for more complicated appliations.
In a multithreaded application, this buffer must be protected by a mutex. See `ptp_mutex_` functions.

## `void ptp_init(struct PtpRuntime *r);`
Initializes a `struct PtpRuntime`. The struct is pretty small. This allocates the a large buffer to `r.data`.
Expand Down
1 change: 1 addition & 0 deletions docs/chdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

All functionality is switched from a code in the first parameter: https://github.com/petabyt/chdk/blob/23c1f3f04fa1c7d483083d403818972a739c6dfd/core/ptp.h#L33C1-L33C1

TODO: Document CHDK extensions
16 changes: 4 additions & 12 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,18 @@ for i = 0,TAKE_X_PICS,1 do
rc = ptp.takePicture()
if rc == ptp.IO_ERR then
setStatusText("IO Error taking picture")
uiToast("IO Error taking picture")
break
elseif rc == ptp.UNSUPPORTED then
setStatusText("Remote capture is unsupported")
uiToast("Remote capture is unsupported")
break
elseif rc then
setStatusText("Error: " + tostring(rc))
uiToast("Error: " + tostring(rc))
break
else
setStatusText("Took " .. tostring(i) .. "picture(s)")
uiToast("Took " .. tostring(i) .. "picture(s)")
end
msleep(MS_BETWEEN_PICS);
end
```

```
-- Basic UI script
win = ui.popup("Astro Mode")
if win.addButton("Take pic") then
rc = ptp.takePicture()
endif
```
1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ tools and apps for several different projects.
- [camlib source code on Github](https://github.com/petabyt/camlib)

## Current Applications
- [Cam, a better camera controller](https://cam.clutchlink.com/)
- [Fujihack Project](https://github.com/fujihack/fujihack/tree/master/ptp)
- [mlinstall, Installer for Magic Lantern](https://github.com/petabyt/mlinstall)
- [Fudge, alternative WiFi/Bluetooth app for Fujifilm cameras](https://github.com/petabyt/fudge)

0 comments on commit dad83dc

Please sign in to comment.