Skip to content

Commit 9e3dd03

Browse files
committed
version 2
1 parent 499b4b6 commit 9e3dd03

6 files changed

Lines changed: 275 additions & 248 deletions

File tree

.gitignore

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,2 @@
11
# CLion
22
.idea/
3-
4-
# CMake & Make
5-
CMakeCache.txt
6-
CMakeFiles/
7-
Makefile
8-
cmake-build-debug/
9-
cmake_install.cmake
10-
.cmake/
11-
12-
# CTest
13-
Testing/
14-
15-
# Ninja
16-
build.ninja
17-
18-
# Output
19-
build.h
20-
libtinyfseq.a

CMakeLists.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.

README.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,33 @@
11
# libtinyfseq
22

3-
A tiny library (~125 LOC) for decoding FSEQ (.fseq) v2.0+ sequence files developed and popularized by
3+
A single-file library (~150 LOC) for decoding FSEQ (.fseq) v2.0+ sequence files developed and popularized by
44
the [fpp](https://github.com/FalconChristmas/fpp) and [xLights](https://github.com/smeighan/xLights) programs.
55
Additional documentation for the file format is available
66
at [Cryptkeeper/fseq-file-format](https://github.com/Cryptkeeper/fseq-file-format).
77

8-
## Installation
8+
A short example of including libtinyfseq and decoding a file header is available in [`example.c`](example.c).
99

10-
You may either install the library, or use `tinyfseq.h` & `tinyfseq.c` directly as a single-file library. libtinyfseq uses [CMake](https://cmake.org/) for building and packaging the library.
10+
## Installation
1111

12-
- Generate Makefiles using `cmake .`
13-
- Compile the library using `make`
14-
- Optionally install the headers and compiled archive using `make install`
15-
- Include in your project using `#include <tinyfseq/tinyfseq.h>`
12+
- Download and copy `tinyfseq.h` into your project locally, or to your toolchain's include paths
13+
- `#include "tinyfseq.h"` as expected (you may need to modify the path).
14+
- Define `TINYFSEQ_IMPLEMENTATION` in a SINGLE C/C++ source code
15+
file ([more information on using single-file libraries](https://github.com/nothings/stb#how-do-i-use-these-libraries))
1616

17-
If optionally installed, `install_manifest.txt` will be created, containing the installed file paths for easy removal.
17+
## Library Configuration
1818

19-
## Build Configuration
19+
Prior to including `tinyfseq.h`, two definition based options are available:
2020

21-
For devices with limited memory, a `TF_INCLUDE_ERR_STRINGS` setting is included in [CMakeLists.txt](CMakeLists.txt)
22-
to disable the inclusion of error strings in the build. Calls to `tf_err_str` will instead return `"NULL"` (as a string). You may also `#define TF_STRIP_ERR_STRINGS` prior to including `tinyfseq.h` to disable error strings without using CMake.
21+
1. `TINYFSEQ_MEMCPY` allows you to override the selected `memcpy` function with whatever is best for your platform (
22+
currently a basic freestanding implementation, `tf_memcpy_impl`)
23+
2. `TINYFSEQ_STRIP_ERR_STRINGS` replaces all literal strings returned by `tf_err_str` with `"NULL"` (as a string) to
24+
reduce the compiled binary size
2325

2426
## Compatibility
2527

28+
- libtinyfseq uses `stdint.h` for fixed-size int types
2629
- libtinyfseq only supports FSEQ versions v2.x versions, with the schema initially released in 2018. Older v1.x files
2730
can be upgraded using the [xLights](https://github.com/smeighan/xLights) program.
28-
- To minimize dependencies, libtinyfseq does not support compressed FSEQ files as they may use both
29-
[zstd](https://github.com/facebook/zstd) and [zlib](https://www.zlib.net)
30-
compression. Compressed FSEQ files can be pre-decompressed using the [xLights](https://github.com/smeighan/xLights)
31-
program, or you may decompress the data buffer yourself using an additional library before passing it to
32-
libtinyfseq.
33-
- libtinyfseq assumes data buffers are in little endian byte order.
3431

3532
## Usage
3633

example.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#include <assert.h>
2+
#include <stdio.h>
3+
4+
// define TINYFSEQ_IMPLEMENTATION to include inline function implementations
5+
// otherwise only include "libtinyfseq.h"
6+
// (in the style of stb headers: https://github.com/nothings/stb#how-do-i-use-these-libraries)
7+
#define TINYFSEQ_IMPLEMENTATION
8+
#include "tinyfseq.h"
9+
10+
static uint8_t FILE_DATA[] = {
11+
'P',
12+
'S',
13+
'E',
14+
'Q',
15+
0,// channelDataOffset
16+
0,
17+
0,// minorVersion
18+
2,// majorVersion
19+
0,// variableDataOffset
20+
0,
21+
0,// channelCount
22+
0,
23+
0,
24+
0,
25+
0,// frameCount
26+
0,
27+
0,
28+
0,
29+
0, // frameStepTimeMillis
30+
0, // -
31+
0, // compressionType
32+
0, // -
33+
0, // channelRangeCount
34+
0, // -
35+
'I',// sequenceUid
36+
'L',
37+
'O',
38+
'V',
39+
'E',
40+
'Y',
41+
'O',
42+
'U',
43+
};
44+
45+
int main() {
46+
printf("using tinyfseq v%s\n", TINYFSEQ_VERSION);
47+
48+
struct tf_file_header_t header;
49+
50+
// read the "embedded" file, FILE_DATA
51+
enum tf_err_t err;
52+
if ((err = tf_read_file_header(FILE_DATA, sizeof(FILE_DATA), &header, NULL))) {
53+
return err;
54+
}
55+
56+
// sequenceUid is an uint64_t that normally stores a timestamp
57+
// instead it carries an 8-byte string message
58+
// this assert call validates the decoded header prior to printing the char values
59+
assert(header.sequenceUid == 6147230170719669321);
60+
61+
int bit_idx;
62+
for (bit_idx = 0; bit_idx < 64; bit_idx += 8) {
63+
uint64_t bit_mask = ((uint64_t) 0xFFu) << bit_idx;
64+
printf("%c", (uint8_t) ((header.sequenceUid & bit_mask) >> bit_idx));
65+
}
66+
67+
printf("\n");
68+
69+
return 0;
70+
}

tinyfseq.c

Lines changed: 0 additions & 157 deletions
This file was deleted.

0 commit comments

Comments
 (0)