Skip to content

Commit

Permalink
Yarns: the LED display driver used for the bootloader no longer suppo…
Browse files Browse the repository at this point in the history
…rts scrolling/flashing, and shift register loop unrolling, saving about 300 bytes
  • Loading branch information
Olivier Gillet committed Feb 8, 2017
1 parent 779901b commit 1b03704
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions yarns/drivers/display.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ void Display::Scroll() {
}

void Display::RefreshSlow() {
#ifdef APPLICATION
if (scrolling_) {
if (scrolling_pre_delay_timer_) {
--scrolling_pre_delay_timer_;
Expand Down Expand Up @@ -112,8 +113,14 @@ void Display::RefreshSlow() {
: 15 - (fading_counter_ >> 12);
}
actual_brightness_ = brightness >> 1;

blink_counter_ = (blink_counter_ + 1) % (kBlinkMask * 2);

#else

displayed_buffer_ = short_buffer_;
actual_brightness_ = 3;

#endif // APPLICATION
}

void Display::RefreshFast() {
Expand All @@ -132,8 +139,12 @@ void Display::RefreshFast() {

void Display::Print(const char* short_buffer, const char* long_buffer) {
strncpy(short_buffer_, short_buffer, kDisplayWidth);

#ifdef APPLICATION
strncpy(long_buffer_, long_buffer, kScrollBufferSize);
long_buffer_size_ = strlen(long_buffer_);
#endif // APPLICATION

scrolling_ = false;
}

Expand All @@ -149,7 +160,8 @@ void Display::Print(const char* short_buffer, const char* long_buffer) {

void Display::Shift14SegmentsWord(uint16_t data) {
GPIOB->BRR = kPinEnable;
for (uint16_t i = 0; i < 2; ++i) {
for (int i = 0; i < 2; ++i) {
#ifdef APPLICATION
SHIFT_BIT
SHIFT_BIT
SHIFT_BIT
Expand All @@ -158,6 +170,11 @@ void Display::Shift14SegmentsWord(uint16_t data) {
SHIFT_BIT
SHIFT_BIT
SHIFT_BIT
#else
for (int j = 0; j < 8; ++j) {
SHIFT_BIT
}
#endif // APPLICATION
}
GPIOB->BSRR = kPinEnable;
}
Expand Down

0 comments on commit 1b03704

Please sign in to comment.