Skip to content

Commit ac0303a

Browse files
committed
updated tests
1 parent 6c508fb commit ac0303a

11 files changed

Lines changed: 178 additions & 14 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ idf_component_register(
1414
INCLUDE_DIRS "src"
1515
)
1616

17+
# Warn strongly but avoid -Werror for consumers (toolchain churn / IDF flags).
1718
target_compile_options(${COMPONENT_LIB} PRIVATE
1819
-Wall
1920
-Wextra
2021
-Wshadow
2122
-Wconversion
22-
-Werror
2323
)

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,24 @@ Documentation tables live under **`compare/`** (`LIBRARIES.md` for platforms/rep
120120

121121
### PlatformIO
122122

123-
Use `library.json` at the repo root: add this folder as a local library or publish following [PlatformIO library format](https://docs.platformio.org/en/latest/manifests/library-json/index.html). Headers resolve from `src/` (`#include "qf_math.h"` for C, `#include "qf_math.hpp"` for C++).
123+
- **Manifest:** [`library.json`](library.json) (registry: [deftio/qf_math](https://registry.platformio.org/libraries/deftio/qf_math)).
124+
- **`lib_deps`:** `deftio/qf_math` or `https://github.com/deftio/qf_math.git`
125+
- **Lean subset** (smaller ROM, no `log10` / `pow10` / waves / ADSR): add to the env `build_flags = -DQF_MATH_LEAN`
126+
- **`export` exclude** in the manifest trims compare/tests/docs from the PIO-installed copy; clones via **git URL** still get the full repo (including **`examples/`**).
127+
- Sanity check locally: `pio pkg pack .` must succeed before publishing.
128+
129+
### Arduino Library Manager / Arduino IDE
130+
131+
- **Manifest:** [`library.properties`](library.properties) beside `library.json` (Arduino 2.x discovers `src/` layout).
132+
- Install from ZIP of the repo or symlink the folder under `Arduino/libraries/`; include `#include <qf_math.h>` (Arduino adds library `src/` to the include path).
124133

125134
### Espressif ESP-IDF
126135

127-
`idf_component.yml` registers the component for the ESP-IDF Component Manager. `CMakeLists.txt` wraps `idf_component_register` for `src/qf_math.c` with include path `src/`.
136+
- **Component Manager:** [`idf_component.yml`](idf_component.yml) + [`CMakeLists.txt`](CMakeLists.txt). Component tarball excludes bulky trees (`examples/`, `compare/`, …); **`src/`**, root **`CMakeLists.txt`**, **`LICENSE.txt`**, and **`README.md`** remain usable.
137+
- **Consumer projects:** `#include "qf_math.h"`; optional **`QF_MATH_LEAN`** via `target_compile_definitions` on your target or **`idf.py menuconfig`/CMake extra flags**.
138+
- **Warnings:** component build uses `-Wall -Wextra -Wshadow -Wconversion` **without** `-Werror` so toolchain/IDF updates are less likely to break downstream apps.
128139

129-
Add as a dependency (path or git URL) per Espressif docs; then `#include "qf_math.h"` from application components.
140+
Add as a dependency (path or git URL) per Espressif docs.
130141

131142
---
132143

agents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Guidance for automated coding agents editing this repository.
3636
## Manifests
3737

3838
- `library.json` — PlatformIO; keep `src/` as include dir.
39-
- `idf_component.yml` + root `CMakeLists.txt` — ESP-IDF component wiring only; fatal-error if configured standalone without `ESP_PLATFORM`.
39+
- `idf_component.yml` + root `CMakeLists.txt` — ESP-IDF component wiring only; fatal-error if configured standalone without `ESP_PLATFORM`. Published component uses strong warnings but not `-Werror` on the component target.
4040

4141
## Markdown policy
4242

docs/INTEGRATION.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ Headers resolve from `src/`:
7373
#include "qf_math.hpp" // C++ wrapper (optional)
7474
```
7575

76+
Lean subset (omit `log10`, `pow10`, waves, ADSR):
77+
78+
```ini
79+
build_flags =
80+
-DQF_MATH_LEAN
81+
```
82+
83+
Arduino IDE installs also see [`library.properties`](../library.properties) (`src/` layout).
84+
85+
Publish check (optional): [`pio pkg pack`](https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_pack.html) in the repo root must succeed.
86+
7687
---
7788

7889
## ESP-IDF component
@@ -103,7 +114,7 @@ components/
103114
idf_component.yml
104115
```
105116
106-
The `CMakeLists.txt` calls `idf_component_register()` to wire `src/qf_math.c` with include path `src/`.
117+
The root `CMakeLists.txt` registers `src/qf_math.c` with include path `src/`. Compile flags use `-Wall`/`-Wextra`/`-Wshadow`/`-Wconversion` **without** `-Werror`, so downstream apps are less likely to break on toolchain or IDF churn.
107118
108119
Then include from any application component:
109120

idf_component.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
version: "1.0.0"
22
description: >-
33
Quick Float Math — approximate float32 routines (trig, log/exp, sqrt/hypot,
4-
waveform helpers, ADSR) for Espressif ESP-IDF and other embedded targets.
4+
waveform helpers, ADSR) for Espressif ESP-IDF. One C99 TU, no heap.
5+
6+
url: https://github.com/deftio/qf_math
7+
repository: https://github.com/deftio/qf_math.git
8+
issues: https://github.com/deftio/qf_math/issues
9+
documentation: "https://github.com/deftio/qf_math#documentation"
10+
511
license: BSD-2-Clause
12+
13+
tags:
14+
- math
15+
- float
16+
- dsp
17+
618
dependencies: {}
19+
20+
# Keep uploaded component blobs small — only compile-time bits are guaranteed.
21+
files:
22+
exclude:
23+
- ".git/**"
24+
- ".github/**"
25+
- "docker/**"
26+
- "examples/**"
27+
- "pages/**"
28+
- "tools/**"
29+
- "compare/**"
30+
- "docs/**"
31+
- "build/**"
32+
- "test/**"

library.json

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
"name": "qf_math",
33
"version": "1.0.0",
44
"description": "Fast approximate IEEE float32 math for embedded C99 (trig, log/exp, sqrt/hypot, waves, ADSR). Small flash footprint, no heap.",
5+
"homepage": "https://github.com/deftio/qf_math",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/deftio/qf_math.git"
9+
},
510
"keywords": [
611
"math",
712
"float",
@@ -12,7 +17,13 @@
1217
"sqrt",
1318
"dsp",
1419
"audio",
15-
"c99"
20+
"c99",
21+
"esp32",
22+
"esp-idf",
23+
"arduino",
24+
"riscv",
25+
"pico",
26+
"arm"
1627
],
1728
"authors": [
1829
{
@@ -25,6 +36,23 @@
2536
"frameworks": "*",
2637
"platforms": "*",
2738
"headers": "qf_math.h",
39+
"export": {
40+
"exclude": [
41+
".claude",
42+
".github",
43+
".git",
44+
"build",
45+
"compare",
46+
"docker",
47+
"pages",
48+
"test",
49+
"tools",
50+
"docs",
51+
"*.gcov",
52+
"*.gcda",
53+
"*.gcno"
54+
]
55+
},
2856
"build": {
2957
"includeDir": "src",
3058
"flags": ["-std=c99"],

library.properties

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=qf_math
2+
version=1.0.0
3+
author=M. A. Chatterjee
4+
maintainer=deftio@deftio.com
5+
sentence=Quick Float Math — approximate IEEE float32 routines for embedded C/C++.
6+
paragraph=Trig, log/exp, sqrt/hypot, waves, floating-point ADSR. Single C translation unit (C99); optional C++ header. Tiny ROM, no heap. BSD-2-Clause. See sibling fr_math for pure fixed-point.
7+
category=Signal Input/Output
8+
url=https://github.com/deftio/qf_math
9+
architectures=*
10+
includes=qf_math.h

llms.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Single-file style library in `src/qf_math.c` + `src/qf_math.h`. Approximate trig
2727

2828
## Integration manifests
2929

30-
- PlatformIO: `library.json`
31-
- ESP-IDF: `idf_component.yml`, `CMakeLists.txt` (component registration only)
30+
- PlatformIO: `library.json` (`pio pkg pack .` validates before publish); Arduino-compatible `library.properties`
31+
- ESP-IDF: `idf_component.yml` (URLs, tags, tarball excludes), `CMakeLists.txt` (component registration, no `-Werror` on consumers)
3232

3333
## Agent notes
3434

src/qf_math.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,8 @@ qf qf_pow2(qf x)
711711
uint32_t pb = vp.u;
712712
uint32_t exp_p = (pb >> 23) & 0xFFu;
713713

714-
/* p should be finite normal (~2^[-1/2,1/2]) — if not, use multiply path */
715-
if (exp_p == 0 || exp_p >= 255 || (pb & 0x7FFFFFFFu) == 0)
716-
return p * make_pow2i(n);
717-
714+
/* Fast path: add n to IEEE exponent if the result stays in normal range.
715+
* Defensive: also catches subnormal / inf / zero p (exp_p==0 or >=255). */
718716
int32_t ne = (int32_t)exp_p + n;
719717
if (ne < 1 || ne > 254)
720718
return p * make_pow2i(n);
@@ -1010,4 +1008,8 @@ qf qf_cov_reduce_to_twopi(qf r)
10101008
{
10111009
return reduce_to_twopi(r);
10121010
}
1011+
qf qf_cov_make_pow2i(int32_t n) { return make_pow2i(n); }
1012+
int32_t qf_cov_ifloor(qf x) { return qf_ifloor(x); }
1013+
qf qf_cov_exp2_frac_01(qf f) { return qf_exp2_frac_01(f); }
1014+
qf qf_cov_asin_pos_kernel(qf ax) { return qf_asin_pos_kernel(ax); }
10131015
#endif

src/qf_math.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ qf qf_adsr_step(qf_adsr_t *env);
303303
/* Built only when compiling tests/coverage (see Makefile `CFLAGS_TEST`). */
304304
#if defined(QF_MATH_COVERAGE)
305305
qf qf_cov_reduce_to_twopi(qf rad);
306+
qf qf_cov_make_pow2i(int32_t n);
307+
int32_t qf_cov_ifloor(qf x);
308+
qf qf_cov_exp2_frac_01(qf f);
309+
qf qf_cov_asin_pos_kernel(qf ax);
306310
#endif
307311

308312
#ifdef __cplusplus

0 commit comments

Comments
 (0)