diff --git a/SConstruct b/SConstruct index 3aa0c4577d..cdab6220ba 100644 --- a/SConstruct +++ b/SConstruct @@ -174,6 +174,7 @@ env = Environment( "#phonelibs/linux/include", "#phonelibs/snpe/include", "#phonelibs/nanovg", + "#phonelibs/qrcode", "#selfdrive/boardd", "#selfdrive/common", "#selfdrive/camerad", diff --git a/selfdrive/ui/qt/widgets/QrCode.cc b/phonelibs/qrcode/QrCode.cc similarity index 98% rename from selfdrive/ui/qt/widgets/QrCode.cc rename to phonelibs/qrcode/QrCode.cc index d248b2d8e0..b9de86215e 100644 --- a/selfdrive/ui/qt/widgets/QrCode.cc +++ b/phonelibs/qrcode/QrCode.cc @@ -349,7 +349,7 @@ QrCode::QrCode(int ver, Ecc ecl, const vector &dataCodewords, int msk) applyMask(i); // Undoes the mask due to XOR } } - if (msk < 0 || msk > 7)//lgtm [cpp/constant-comparison] + if (msk < 0 || msk > 7) throw std::logic_error("Assertion error"); this->mask = msk; applyMask(msk); // Apply the final choice of mask @@ -635,12 +635,12 @@ long QrCode::getPenaltyScore() const { } else { finderPenaltyAddHistory(runX, runHistory); if (!runColor) - result += finderPenaltyCountPatterns(runHistory) * PENALTY_N3;//lgtm [cpp/integer-multiplication-cast-to-long] + result += finderPenaltyCountPatterns(runHistory) * PENALTY_N3; runColor = module(x, y); runX = 1; } } - result += finderPenaltyTerminateAndCount(runColor, runX, runHistory) * PENALTY_N3;//lgtm [cpp/integer-multiplication-cast-to-long] + result += finderPenaltyTerminateAndCount(runColor, runX, runHistory) * PENALTY_N3; } // Adjacent modules in column having same color, and finder-like patterns for (int x = 0; x < size; x++) { @@ -657,12 +657,12 @@ long QrCode::getPenaltyScore() const { } else { finderPenaltyAddHistory(runY, runHistory); if (!runColor) - result += finderPenaltyCountPatterns(runHistory) * PENALTY_N3;//lgtm [cpp/integer-multiplication-cast-to-long] + result += finderPenaltyCountPatterns(runHistory) * PENALTY_N3; runColor = module(x, y); runY = 1; } } - result += finderPenaltyTerminateAndCount(runColor, runY, runHistory) * PENALTY_N3;//lgtm [cpp/integer-multiplication-cast-to-long] + result += finderPenaltyTerminateAndCount(runColor, runY, runHistory) * PENALTY_N3; } // 2*2 blocks of modules having same color diff --git a/selfdrive/ui/qt/widgets/QrCode.hpp b/phonelibs/qrcode/QrCode.hpp similarity index 100% rename from selfdrive/ui/qt/widgets/QrCode.hpp rename to phonelibs/qrcode/QrCode.hpp diff --git a/release/files_common b/release/files_common index 21f96f861c..fe12037f8f 100644 --- a/release/files_common +++ b/release/files_common @@ -441,6 +441,9 @@ phonelibs/json11/json11.hpp phonelibs/qpoases/** +phonelibs/qrcode/*.cc +phonelibs/qrcode/*.hpp + phonelibs/libyuv/include/** phonelibs/libyuv/lib/** diff --git a/selfdrive/ui/SConscript b/selfdrive/ui/SConscript index 1c532837bb..a19fe1ee41 100644 --- a/selfdrive/ui/SConscript +++ b/selfdrive/ui/SConscript @@ -19,7 +19,7 @@ else: widgets = qt_env.Library("qt_widgets", ["qt/qt_window.cc", "qt/qt_sound.cc", "qt/widgets/keyboard.cc", "qt/widgets/input_field.cc", "qt/widgets/drive_stats.cc", - "qt/offroad/wifi.cc", "qt/offroad/wifiManager.cc", "qt/widgets/toggle.cc", "qt/widgets/offroad_alerts.cc", "qt/widgets/setup.cc", "qt/widgets/QrCode.cc"], + "qt/offroad/wifi.cc", "qt/offroad/wifiManager.cc", "qt/widgets/toggle.cc", "qt/widgets/offroad_alerts.cc", "qt/widgets/setup.cc"], LIBS=qt_libs) qt_libs.append(widgets) @@ -29,8 +29,7 @@ else: del qt_libs[qt_libs.index('OpenCL')] qt_env['FRAMEWORKS'] += ['OpenCL'] - qt_src = ["qt/ui.cc", "qt/window.cc", "qt/home.cc", "qt/api.cc", "qt/offroad/settings.cc", "qt/offroad/onboarding.cc"] + src - + qt_src = ["qt/ui.cc", "qt/window.cc", "qt/home.cc", "qt/api.cc", "qt/offroad/settings.cc", "qt/offroad/onboarding.cc", "#phonelibs/qrcode/QrCode.cc"] + src qt_env.Program("_ui", qt_src, LIBS=qt_libs) # spinner and text window