Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for cimbar.js, cimbar_send #75

Merged
merged 4 commits into from
Jun 10, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use Config settings for cimbar_js defaults
  • Loading branch information
sz3 committed Jun 10, 2023
commit 1b09a7725ee7744d8a074368fcd7923c060a53a7
13 changes: 7 additions & 6 deletions src/lib/cimbar_js/cimbar_js.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */
#include "cimbar_js.h"

#include "cimb_translator/Config.h"
#include "encoder/SimpleEncoder.h"
#include "gui/window_glfw.h"
#include "util/byte_istream.h"
Expand All @@ -18,9 +19,9 @@ namespace {
uint8_t _encodeId = 0;

// settings
unsigned _ecc = 30;
unsigned _colorBits = 2;
int _compressionLevel = 6;
unsigned _ecc = cimbar::Config::ecc_bytes();
unsigned _colorBits = cimbar::Config::color_bits();
int _compressionLevel = cimbar::Config::compression_level();
}

extern "C" {
Expand Down Expand Up @@ -105,11 +106,11 @@ int configure(unsigned color_bits, unsigned ecc, int compression)
{
// defaults
if (color_bits > 3)
color_bits = 2;
color_bits = cimbar::Config::color_bits();
if (ecc < 0 or ecc >= 150)
ecc = 30;
ecc = cimbar::Config::ecc_bytes();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honor config defaults.

if (compression < 0 or compression > 22)
compression = 6;
compression = cimbar::Config::compression_level();

// check if we need to refresh the stream
bool refresh = (color_bits != _colorBits or ecc != _ecc or compression != _compressionLevel);
Expand Down