Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ install: the repository root is the site (GitHub Pages serves `main` as is).
| `src/main.js` | Entry point: wires controls to actions, keyboard shortcuts, start-up |
| `src/state.js` | The shared state object `S` and display-unit helpers |
| `src/config.js` | Constants, storage keys, peak colours (read from CSS tokens), `MOCK` |
| `src/version.js` | The version number; the only place it is written in the code |
| `src/acquisition.js` | Connect, acquire, live loop, exposure, dark |
| `src/spectrum.js` | Frame → display unit, peak detection, render scheduling (one render per frame) |
| `src/export.js` | CSV and PNG export |
Expand Down Expand Up @@ -84,9 +85,21 @@ pass callbacks (as `initPlot(handlers)` does) when a lower module must reach a h

- **Never push to `main`.** GitHub Pages publishes `main` as is, so every change reaches it through a pull
request that the maintainer merges.
- **One change per branch, one branch per pull request,** branched from the current `main` and named by kind:
`feat/…`, `fix/…`, `docs/…`, `refactor/…`, `test/…`.
- **Work locally, open a pull request when the work is complete.** Branch from the current `main`, named by
kind (`feat/…`, `fix/…`, `docs/…`, `refactor/…`, `test/…`, `release/…`), commit as you go and check the result
locally. Push and open the pull request once the feature, fix or release is finished; small related edits go
into it rather than into pull requests of their own.
- **Keep pull requests independent,** so they can be merged in any order or left out. Do not build one on an
unmerged branch; when two changes truly depend on each other, say so in both descriptions.
- The description says what changed, why, and how it was tested: `npm test`, the `?mock` checks, and whether
a real instrument was used (and which). Driver changes are not merged before a test on hardware.

## Releases

Versions follow semantic versioning: a fix raises the patch number, a new feature the minor number.

1. On a `release/x.y.z` branch, set the version in `src/version.js`, `package.json` and the README's version
line, and add the `## x.y.z — date` entry at the top of `CHANGELOG.md`; `tests/test_version.mjs` fails
until all four agree.
2. After the pull request is merged, tag the merge commit `vx.y.z` and publish a GitHub release whose notes
are the changelog entry.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Changelog

## 2.1.0 — 2026-11-26

### Instruments
- Instruments are recognised by their USB IDs from a table of per-model profiles. Besides the HDX, the STS,
QE Pro, Spark and Ventana open as experimental models; older Ocean models and the Ocean ST/SR/HR series are
recognised but not operated.
- For an instrument Spektra cannot operate, a report built from the USB descriptors alone, with a pre-filled
GitHub issue; for an unknown device that may speak OBP, optional read-only requests.
- Read-only `?diag` page for the instrument's spectrum messages.

### Phones
- Android Chrome over a USB-C (OTG) adapter, tested with an HDX; iOS remains unsupported (no WebUSB).
- Compact landscape layout: one-line top bar, processing steps as a strip on the left, the peaks panel as a
drawer, full-screen toggle and a prompt to turn the phone sideways.
- Touch gestures on the plot: pan, pinch-zoom, tap to select a peak, double tap to reset.

### Fixes
- The wavelength coefficients are read twice and checked, so a repeated USB reply can no longer shift them
(the axis was stretched to about 2 × 10⁶ nm).
- X-axis labels no longer overlap when zoomed in or on narrow screens.
- Connect shows "Connecting…" and cannot be pressed twice while the instrument opens.
- Instrument error 12 is reported with its correct meaning; errors 13, 100–104 and 255 added.
- Interface text names "the spectrometer" wherever any model can be meant.

### Documentation
- `docs/PROTOCOL.md`: how Spektra communicates with the instrument.
- `docs/TROUBLESHOOTING.md`: common connection problems and their fixes (contributed by Haseem Ajaz).
- README: the project's aims, supported instruments and a call for test reports.
- `AGENTS.md` and `CONTRIBUTING.md` for contributors; issue forms, a pull request template and tests run on
every pull request.

## 2.0.0 — 2026-11-25

Spektra 2.0 replaces the earlier desktop program (1.x, Python and Qt) with a browser application:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ protocol. It is tested on the HDX; support for other models is being added and n
instruments](#supported-instruments)). No software has to be installed, and the same page works on Windows,
macOS, Linux, ChromeOS and Android devices.

Application: <https://berameric.github.io/spektra/> · Version 2.0.0 ([changelog](CHANGELOG.md)) ·
Application: <https://berameric.github.io/spektra/> · Version 2.1.0 ([changelog](CHANGELOG.md)) ·
[MIT licence](LICENSE)

![Spektra on a computer: live spectrum with detected peaks and the peak table (simulated data)](assets/screenshot.png)
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ <h2>Peaks</h2><span class="count" id="peakCount">0</span>
<span class="mono chain-sum" id="chainSum"></span>
<span class="vr"></span>
<a class="foot-link foot-small" href="https://nano-optoelectronics.istanbul.edu.tr/en/_" target="_blank" rel="noopener" title="Nano Optoelectronics Laboratories, Istanbul University">Nano Optoelectronics Lab · IU</a>
<a class="foot-link" href="https://github.com/berameric/spektra/blob/main/CHANGELOG.md" target="_blank" rel="noopener" title="What is new in this version">v2.0.0</a>
<a class="foot-link" href="https://github.com/berameric/spektra/blob/main/CHANGELOG.md" target="_blank" rel="noopener" title="What is new in this version" id="versionLink">v</a>
<a class="foot-link" href="https://github.com/berameric/spektra" target="_blank" rel="noopener" title="Spektra on GitHub"><svg class="i"><use href="#i-github"/></svg>GitHub</a>
</footer>

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "spektra",
"version": "2.0.0",
"version": "2.1.0",
"private": true,
"license": "MIT",
"description": "Browser acquisition and peak analysis for the Ocean Insight HDX spectrometer",
"description": "Browser acquisition and peak analysis for Ocean Insight spectrometers",
"type": "module",
"scripts": {
"test": "node tests/test_web_analysis.mjs && node tests/test_web_usb.mjs",
"test": "node tests/test_web_analysis.mjs && node tests/test_web_usb.mjs && node tests/test_version.mjs",
"start": "node scripts/serve.mjs",
"dev": "node scripts/serve.mjs"
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { checkEnvironment, initEnvironment } from "./ui/environment.js";
import { toast } from "./ui/notify.js";
import { initPlot, redrawPlot, resetView, zoomToPeak, zoomToSelection } from "./ui/plot.js";
import { $, clamp, store } from "./util.js";
import { VERSION } from "./version.js";

store.remove("hdx.rois.v1"); // saved regions of an earlier version
store.remove("hdx.theme"); // the light theme was removed
Expand Down Expand Up @@ -60,6 +61,7 @@ $("peaksCopy").addEventListener("click", async () => {
$("detectScope").addEventListener("click", (e) => { if (e.target.closest('[data-act="clear-sel"]')) clearSelection(); });
initEnvironment();
watchDevice();
$("versionLink").textContent = `v${VERSION}`;

// ---------------------------------------------------------------- top bar
$("connectBtn").addEventListener("click", connect);
Expand Down
3 changes: 2 additions & 1 deletion src/ui/diag.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { DIAG } from "../config.js";
import { S } from "../state.js";
import { $ } from "../util.js";
import { VERSION } from "../version.js";
import { toast } from "./notify.js";

const MESSAGES = [0x00101000, 0x00101100];
Expand Down Expand Up @@ -79,7 +80,7 @@ async function run() {
for (let round = 0; round < 2; round++) for (const t of MESSAGES) caps.push(await capture(t));
const [a1, b1, a2, b2] = caps;
report = {
spektra: "2.0.0", time: new Date().toISOString(), model: S.dev.model, serial: S.dev.serialNumber,
spektra: VERSION, time: new Date().toISOString(), model: S.dev.model, serial: S.dev.serialNumber,
integrationMs: S.intMs, captures: caps.map(({ px, ...rest }) => rest),
sameMessageRepeat: compare(a1, a2), otherMessageRepeat: compare(b1, b2), between: compare(a1, b1),
};
Expand Down
3 changes: 2 additions & 1 deletion src/ui/unsupported.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { OBP2, OOI, PROTOCOL_NAMES } from "../device/profiles.js";
import { describeDevice, probeObp } from "../device/probe.js";
import { $ } from "../util.js";
import { VERSION } from "../version.js";
import { toast } from "./notify.js";

const ISSUES = "https://github.com/berameric/spektra/issues/new";
Expand Down Expand Up @@ -53,7 +54,7 @@ export function showUnsupported(device, profile) {
if (!$("unsupDlg")) build();
current = {
device, profile,
report: { spektra: "2.0.0", time: new Date().toISOString(), browser: navigator.userAgent, device: describeDevice(device) },
report: { spektra: VERSION, time: new Date().toISOString(), browser: navigator.userAgent, device: describeDevice(device) },
};
const known = profile && profile.protocol !== undefined;
$("unsupTitle").textContent = known ? `${profile.model} is not supported yet` : "This instrument is not supported yet";
Expand Down
2 changes: 2 additions & 0 deletions src/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// The Spektra version, shown in the footer and written into reports. Release steps: AGENTS.md.
export const VERSION = "2.1.0";
13 changes: 13 additions & 0 deletions tests/test_version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Node test: the version in src/version.js matches package.json, the README and the latest CHANGELOG entry,
// so a release cannot leave one of them behind: node tests/test_version.mjs
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { VERSION } from "../src/version.js";

const read = (path) => readFileSync(new URL(`../${path}`, import.meta.url), "utf8");

assert.equal(JSON.parse(read("package.json")).version, VERSION, "package.json");
assert.ok(read("README.md").includes(`Version ${VERSION} (`), "README.md version line");
assert.equal(read("CHANGELOG.md").match(/^## (\S+)/m)?.[1], VERSION, "CHANGELOG.md: the first entry is the current version");

console.log(`OK: version ${VERSION} is the same everywhere.`);
Loading