Skip to content

Commit

Permalink
[P165] Add more code from letscontrolit#5091
Browse files Browse the repository at this point in the history
  • Loading branch information
tonhuisman committed Sep 1, 2024
1 parent 4dd4c6b commit a237603
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/src/PluginStructs/P073_data_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ void P073_font_selector(const __FlashStringHelper *id, int16_t value) {

# endif // ifdef P073_EXTRA_FONTS

/**
* This function reverts the 7 databits/segmentbits so TM1637 and 74HC595 displays work with fonts designed for MAX7219.
* Dot/colon bit is still bit 8
*/
uint8_t P073_revert7bits(uint8_t character) {
uint8_t newCharacter = character & 0x80; // Keep dot-bit if passed in

for (int b = 0; b < 7; ++b) {
if (character & (0x01 << b)) {
newCharacter |= (0x40 >> b);
}
}
return newCharacter;
}
// FIXME End of part to merge from PR #5091

void P073_data_struct::init(struct EventStruct *event)
Expand Down
1 change: 1 addition & 0 deletions src/src/PluginStructs/P073_data_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ void P073_display_output_selector(const __FlashStringHelper *id,
void P073_font_selector(const __FlashStringHelper *id,
int16_t value);
# endif // ifdef P073_EXTRA_FONTS
uint8_t P073_revert7bits(uint8_t character);
// FIXME End of part to merge from PR #5091

struct P073_data_struct : public PluginTaskData_base {
Expand Down

0 comments on commit a237603

Please sign in to comment.