Skip to content

Commit

Permalink
[poincare/preferences,apps/global_preferences] Reduce version size to…
Browse files Browse the repository at this point in the history
… 1 byte
  • Loading branch information
GabrielNumworks committed Apr 16, 2024
1 parent 11bc134 commit 0106727
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
21 changes: 13 additions & 8 deletions apps/global_preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class __attribute__((packed)) GlobalPreferences {
void setFont(KDFont::Size font) { m_font = font; }

private:
constexpr static int k_version = 0x20240401;
constexpr static uint8_t k_version = 0;

GlobalPreferences()
: m_version(k_version),
Expand All @@ -131,21 +131,26 @@ class __attribute__((packed)) GlobalPreferences {
"I18n::NumberOfCountries is not superior to 0");

#if __EMSCRIPTEN__
emscripten_align1_int m_version;
emscripten_align1_int m_brightnessLevel;
CODE_GUARD(global_preferences, 3643843895, //
uint8_t m_version; //
emscripten_align1_int m_brightnessLevel; //
I18n::Language m_language; //
I18n::Country m_country; //
bool m_showPopUp; //
KDFont::Size m_font;)
#else
int m_version;
int m_brightnessLevel;
#endif
CODE_GUARD(global_preferences, 3045158492, //
CODE_GUARD(global_preferences, 1861289878, //
uint8_t m_version; //
int m_brightnessLevel; //
I18n::Language m_language; //
I18n::Country m_country; //
bool m_showPopUp; //
KDFont::Size m_font;)
#endif
};

#if PLATFORM_DEVICE
static_assert(sizeof(GlobalPreferences) == 12,
static_assert(sizeof(GlobalPreferences) == 9,
"Class GlobalPreferences changed size");
#endif

Expand Down
13 changes: 4 additions & 9 deletions poincare/include/poincare/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,10 @@ class __attribute__((packed)) Preferences final {
}

private:
constexpr static int k_version = 0x20240401;
constexpr static uint8_t k_version = 0;

#if __EMSCRIPTEN__
emscripten_align1_int m_version;
#else
int m_version;
#endif

CODE_GUARD(poincare_preferences, 4027384180, //
CODE_GUARD(poincare_preferences, 524861357, //
uint8_t m_version;
CalculationPreferences m_calculationPreferences;
mutable ExamMode m_examMode;
/* This flag can only be asserted by writing it via DFU. When set,
Expand All @@ -194,7 +189,7 @@ class __attribute__((packed)) Preferences final {
};

#if PLATFORM_DEVICE
static_assert(sizeof(Preferences) == 14, "Class Preferences changed size");
static_assert(sizeof(Preferences) == 11, "Class Preferences changed size");
#endif

#if __EMSCRIPTEN__
Expand Down

0 comments on commit 0106727

Please sign in to comment.