Skip to content

Commit

Permalink
simplify, no longer uses frozen
Browse files Browse the repository at this point in the history
  • Loading branch information
Habbie committed Nov 9, 2024
1 parent cc04ab1 commit 5ebf11e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 37 deletions.
5 changes: 0 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ project(
default_options: ['warning_level=3', 'cpp_std=c++20'],
)

add_global_arguments('-fconstexpr-ops-limit=5000000000', language : 'cpp')

version_file = vcs_tag(input: 'src/version.cpp.in', output: 'version.cpp')

cpp = meson.get_compiler('cpp')
Expand Down Expand Up @@ -163,8 +161,6 @@ if get_option('front-lvgl').enabled()
endif
quickjs_proj = cmake.subproject('quickjs', options: quickjs_options)
quickjs_dep = quickjs_proj.dependency('qjs')

frozen_dep = dependency('frozen')
endif

incdir = include_directories('./src/')
Expand Down Expand Up @@ -267,7 +263,6 @@ if get_option('front-lvgl').enabled()
libatomic,
date_dep,
quickjs_dep,
frozen_dep,
],
include_directories: incdir,
cpp_args: [
Expand Down
12 changes: 10 additions & 2 deletions scripts/mdimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,19 @@

outfile.write(f"""#include "mdimap.hpp"
constexpr frozen::unordered_map<frozen::string, frozen::string, {len(icons)}> voorkant::mdi::name2id = {{
static std::map<std::string, std::string> map_name2id = {{
""")


for k, v in icons.items():
outfile.write(f' {{{k}, "{v}"}},\n')

outfile.write("};\n")
outfile.write("""
};
// making _name a ref is tempting but currently some code tries to pass simple static "foo" (char array) in
std::string voorkant::mdi::name2id(std::string _name) {
return map_name2id.at(_name);
}
\n""")
4 changes: 2 additions & 2 deletions src/front-lvgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ void uithread(int _argc, char* _argv[])

lv_obj_t* left_btn = lv_button_create(bottom_row);
lv_obj_t* left_btn_txt = lv_label_create(left_btn);
lv_label_set_text(left_btn_txt, voorkant::mdi::name2id.at("waze").data());
lv_label_set_text(left_btn_txt, voorkant::mdi::name2id("waze").data());
lv_obj_add_event_cb(left_btn, btnLeftPress, LV_EVENT_CLICKED, NULL);
lv_obj_add_style(left_btn, &voorkant::lvgl::mdistyle, 0);

UILogBox logbox(bottom_row, &voorkant::lvgl::b612style);

lv_obj_t* right_btn = lv_button_create(bottom_row);
lv_obj_t* right_btn_txt = lv_label_create(right_btn);
lv_label_set_text(right_btn_txt, voorkant::mdi::name2id.at("arrow-right").data());
lv_label_set_text(right_btn_txt, voorkant::mdi::name2id("arrow-right").data());
lv_obj_add_style(right_btn_txt, &voorkant::lvgl::mdistyle, 0);

lv_obj_add_event_cb(right_btn, btnRightPress, LV_EVENT_CLICKED, NULL);
Expand Down
9 changes: 0 additions & 9 deletions src/mdimap.cpp

This file was deleted.

11 changes: 7 additions & 4 deletions src/mdimap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

#include <cstdint> // FIXME: this works around a bug in frozen? (likely fixed in 1.2.0, we're using 1.1.1 here)

#include <frozen/unordered_map.h>
#include <frozen/string.h>
// #include <frozen/unordered_map.h>
// #include <frozen/string.h>
#include <map>
#include <string>

namespace voorkant
{
namespace mdi
{
// FIXME: 7447 is a constant until we update the MDI submodule
extern const frozen::unordered_map<frozen::string, frozen::string, 7447> name2id;
// extern const frozen::unordered_map<frozen::string, frozen::string, 7447> name2id;
std::string name2id(std::string _name);
}
}
}
3 changes: 1 addition & 2 deletions src/uicomponents/uirgblight.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "uirgblight.hpp"
#include "frozen/unordered_map.h"
#include "logger.hpp"
#include "uicomponents/UIComponents.hpp"
#include "mdimap.hpp"
Expand Down Expand Up @@ -264,7 +263,7 @@ UIRGBLight::UIRGBLight(std::shared_ptr<HAEntity> _entity, lv_obj_t* _parent) :
lv_obj_set_flex_align(btns, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_remove_flag(btns, LV_OBJ_FLAG_SCROLLABLE);

btnOnOff = createImageButton(voorkant::mdi::name2id.at("power-standby").data(), UIRGBLight::btnOnOffCB, LV_EVENT_VALUE_CHANGED, true);
btnOnOff = createImageButton(voorkant::mdi::name2id("power-standby").data(), UIRGBLight::btnOnOffCB, LV_EVENT_VALUE_CHANGED, true);

if (showBrightness) {
btnBrightness = createImageButton(&G_BRIGHTNESS24, UIRGBLight::btnBrightnessCB, LV_EVENT_CLICKED);
Expand Down
13 changes: 0 additions & 13 deletions subprojects/frozen.wrap

This file was deleted.

0 comments on commit 5ebf11e

Please sign in to comment.