Skip to content

Commit

Permalink
Fix wander of vertical offset
Browse files Browse the repository at this point in the history
  • Loading branch information
antiprism committed Mar 31, 2021
1 parent b769f1e commit bb55927
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/ArduiPi_OLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@ void ArduiPi_OLED::close(void)
bcm2835_close();
}

void ArduiPi_OLED::reset_offset()
{
sendCommand(SSD1306_Set_Display_Offset, 0x00); // no offset
}

void ArduiPi_OLED::begin(void)
{
uint8_t multiplex;
Expand Down
6 changes: 3 additions & 3 deletions src/ArduiPi_OLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ class ArduiPi_OLED : public Adafruit_GFX {
// I2C Init
boolean init_i2c(int8_t RST, uint8_t OLED_TYPE, int8_t i2c_addr, int i2c_bus);

boolean
oled_is_spi_proto(uint8_t OLED_TYPE); /* to know protocol before /init */
boolean select_oled(uint8_t OLED_TYPE, int8_t i2c_addr = 0);
boolean oled_is_spi_proto(uint8_t OLED_TYPE); /* to know protocol before /init */
boolean select_oled(uint8_t OLED_TYPE, int8_t i2c_addr=0) ;
void reset_offset();

void begin(void);
void close(void);
Expand Down
16 changes: 9 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,16 +553,18 @@ int start_idle_loop(ArduiPi_OLED &display, FILE *fifo_file,

// Update display if necessary
if (timer.finished() || num_bars_read) {
display.clearDisplay();
pthread_mutex_lock(&disp_info_lock);
display.invertDisplay(get_invert(opts.invert));
draw_display(display, disp_info);
pthread_mutex_unlock(&disp_info_lock);
display.display();
display.clearDisplay();
pthread_mutex_lock(&disp_info_lock);
display.invertDisplay(get_invert(opts.invert));
draw_display(display, disp_info);
pthread_mutex_unlock(&disp_info_lock);
display.display();
}

if (timer.finished())
if (timer.finished()) {
display.reset_offset();
timer.set_timer(update_sec); // Reset the timer
}
}

return 0;
Expand Down

1 comment on commit bb55927

@antiprism
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closes #3

Please sign in to comment.