Skip to content

Commit

Permalink
add missing lor_get_intensity function body
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryptkeeper committed Sep 1, 2024
1 parent 5cce892 commit df6f1fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tinylor.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,9 @@ size_t lor_write(unsigned char* b, const size_t bs, const lor_req_s* r,
}
return h;
}

lor_intensity lor_get_intensity(const unsigned char b) {
// scale b from (0,255) to (240,1) which is the LOR intensity range
static const lor_intensity ceiling = 240;
return ceiling - (lor_intensity) ((1.0f - ((float) b / 255.0f)) * 239);
}
6 changes: 6 additions & 0 deletions tinylor.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,12 @@ size_t lor_write(unsigned char* b, const size_t bs, const lor_req_s* r,
return h;
}

lor_intensity lor_get_intensity(const unsigned char b) {
// scale b from (0,255) to (240,1) which is the LOR intensity range
static const lor_intensity ceiling = 240;
return ceiling - (lor_intensity) ((1.0f - ((float) b / 255.0f)) * 239);
}

#endif// TINYLOR_IMPL_ONCE
#endif// TINYLOR_IMPL
#endif// TINYLOR_SINGLEFILE_H

0 comments on commit df6f1fb

Please sign in to comment.