-
Notifications
You must be signed in to change notification settings - Fork 8
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
♻️ (MagicCard): Add language byte to MagicCard #1048
♻️ (MagicCard): Add language byte to MagicCard #1048
Conversation
File comparision analysis report🔖 Info
Click to show memory sections
📝 SummaryClick to show summary
🗺️ Map files diff outputClick to show diff list
|
File comparision analysis report🔖 Info
Click to show memory sections
📝 SummaryClick to show summary
🗺️ Map files diff outputClick to show diff list
|
Codecov Report
@@ Coverage Diff @@
## develop #1048 +/- ##
========================================
Coverage 95.99% 95.99%
========================================
Files 133 133
Lines 3171 3173 +2
========================================
+ Hits 3044 3046 +2
Misses 127 127
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
libs/RFIDKit/include/MagicCard.h
Outdated
@@ -30,6 +30,8 @@ struct MagicCard { | |||
return both; | |||
} | |||
|
|||
[[nodiscard]] constexpr auto getLanguage() const -> uint8_t { return _tag.data.at(language_byte_index); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not asking for a change, but after re-reading the whole code, having at getXXX
feels a bit verbose. It's just a simple struct, card.id()
or card.language()
would be good enough.
to keep in mind for a future refactor ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it more readable and using Language inside MagicCard's architecture, use uint16_t _id
& Language _language
as variables instead of rfid::Tag _tag
.
libs/RFIDKit/include/MagicCard.h
Outdated
@@ -30,6 +30,8 @@ struct MagicCard { | |||
return both; | |||
} | |||
|
|||
[[nodiscard]] constexpr auto getLanguage() const -> uint8_t { return _tag.data.at(language_byte_index); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of returning a byte (0x01, 0x02, ...) I think it is better to wrap it into an Enum to understand what is happening on use
enum class TagLanguage{
None = 00,
fr_FR = 01,
en_US = 02
}
if (card.getLanguage() == TagLanguage::fr_FR) {
_videokit.displayImage("/fs/home/img/system/robot-misc-choose_activity-fr_FR.jpg");
} else if (card.getLanguage() == TagLanguage::en_US){
_videokit.displayImage("/fs/home/img/system/robot-misc-choose_activity-en_US.jpg");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going further, we can have a python dictionary like or struct as Color.h
in ActivityKit to get language tag from the byte in order to directly set the right tag in the path
_videokit.displayImage({image_system_folder} + {id_converted_name} + '-' + {tag_language} + ".jpg");
We can abord this when we will simplify use of videokit by dropping the folder and extension, {image_system_folder} and ".jpg" in the above case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @YannLocatelli
Just a small note: I would call the enum just Language
and keep in struct MagicCard
to access/use it via MagicCard::Language
e9fda6c
to
89d51ff
Compare
89d51ff
to
4097645
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's look pretty good!
Except applying suggestion of @ladislas by setting Language in MagicCard struct, everything is good to me 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last change :)
libs/RFIDKit/include/MagicCard.h
Outdated
enum class Language | ||
{ | ||
fr_FR = 1, | ||
en_US = 2 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this inside struct MagicCard
?
4097645
to
46e154b
Compare
46e154b
to
1a77f51
Compare
Kudos, SonarCloud Quality Gate passed! |
No description provided.