2019-09-02 11:41:24 +00:00
|
|
|
#include "display.h"
|
|
|
|
#include "gpio.h"
|
2019-10-22 19:54:33 +00:00
|
|
|
#include "spi_mode.h"
|
2019-09-19 14:41:32 +00:00
|
|
|
#include "stmlib/system/system_clock.h"
|
2020-02-23 10:15:27 +00:00
|
|
|
#include <U8g2lib.h>
|
2019-09-07 19:47:43 +00:00
|
|
|
#include <stm32f37x_conf.h>
|
|
|
|
#include <u8g2.h>
|
2019-09-02 11:41:24 +00:00
|
|
|
|
2019-09-19 14:41:32 +00:00
|
|
|
using namespace stmlib;
|
2019-09-02 11:41:24 +00:00
|
|
|
|
2020-02-23 10:15:27 +00:00
|
|
|
static uint8_t* default_buf;
|
|
|
|
static uint8_t second_buf[1024];
|
|
|
|
static uint8_t* output_buf;
|
2019-09-19 14:41:32 +00:00
|
|
|
|
2020-02-23 10:15:27 +00:00
|
|
|
|
|
|
|
class U8G2_SH1106_128x64_NONAME_F_SPI : public U8G2 {
|
|
|
|
public:
|
|
|
|
U8G2_SH1106_128x64_NONAME_F_SPI()
|
|
|
|
: U8G2()
|
|
|
|
{
|
2020-02-25 20:48:04 +00:00
|
|
|
u8g2_Setup_sh1106_128x64_noname_f(&this->u8g2, U8G2_R0, u8x8_byte_4wire_stm32_spi, u8x8_stm32_gpio_and_delay);
|
2020-02-23 10:15:27 +00:00
|
|
|
output_buf = default_buf = this->u8g2.tile_buf_ptr;
|
|
|
|
/*u8g2_InitDisplay(&u8g2_);
|
|
|
|
u8g2_SetContrast(&u8g2_, 255);
|
|
|
|
u8g2_SetPowerSave(&u8g2_, 0);*/
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
U8G2_SH1106_128x64_NONAME_F_SPI u8g2_;
|
|
|
|
|
|
|
|
U8G2* Display::u8g2()
|
2019-09-02 11:41:24 +00:00
|
|
|
{
|
2019-10-22 19:54:33 +00:00
|
|
|
return &u8g2_;
|
2019-09-19 14:41:32 +00:00
|
|
|
}
|
2019-09-02 11:41:24 +00:00
|
|
|
|
2019-09-19 14:41:32 +00:00
|
|
|
void Display::InitGLib()
|
2019-09-02 11:41:24 +00:00
|
|
|
{
|
2020-02-23 10:15:27 +00:00
|
|
|
u8g2_.begin();
|
2019-09-02 11:41:24 +00:00
|
|
|
}
|
2019-09-19 15:55:48 +00:00
|
|
|
|
|
|
|
void Display::Flush()
|
|
|
|
{
|
2020-02-23 10:15:27 +00:00
|
|
|
uint8_t* cache = u8g2_.getU8g2()->tile_buf_ptr;
|
|
|
|
u8g2_.getU8g2()->tile_buf_ptr = output_buf;
|
|
|
|
u8g2_.sendBuffer();
|
|
|
|
u8g2_.getU8g2()->tile_buf_ptr = cache;
|
2019-09-19 15:55:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Display::Swap()
|
|
|
|
{
|
2020-02-23 10:15:27 +00:00
|
|
|
output_buf = u8g2_.getU8g2()->tile_buf_ptr;
|
2019-10-22 19:54:33 +00:00
|
|
|
if (output_buf == default_buf)
|
2020-02-23 10:15:27 +00:00
|
|
|
u8g2_.getU8g2()->tile_buf_ptr = second_buf;
|
2019-10-22 19:54:33 +00:00
|
|
|
else
|
2020-02-23 10:15:27 +00:00
|
|
|
u8g2_.getU8g2()->tile_buf_ptr = default_buf;
|
2019-09-19 15:55:48 +00:00
|
|
|
}
|