modm API documentation
modm::Sh1106< I2cMaster, Height > Class Template Referenceabstract

#include <modm/driver/display/sh1106.hpp>

Inheritance diagram for modm::Sh1106< I2cMaster, Height >:
modm::ssd1306< I2cMaster, Height > modm::MonochromeGraphicDisplayVertical< 128, Height > modm::I2cDevice< I2cMaster, 3, ssd1306::Ssd1306_I2cWriteTransaction > modm::ssd1306_register modm::MonochromeGraphicDisplay< Width, Height, Width, Height/8 > modm::NestedResumable< 10+1 > modm::GraphicDisplay modm::IOStream

Public Types

enum  DisplayMode : uint8_t { Normal = NormalDisplay, Inverted = InvertedDisplay }
 
enum  ScrollDirection : uint8_t { Right = HorizontalScrollRight, Left = HorizontalScrollLeft }
 
enum  ScrollStep : uint8_t {
  Frames2 = 0b111, Frames3 = 0b100, Frames4 = 0b101, Frames5 = 0b000,
  Frames25 = 0b110, Frames64 = 0b001, Frames128 = 0b010, Frames256 = 0b011
}
 

Public Member Functions

 Sh1106 (uint8_t address=0x3C)
 
 Ssd1306 (uint8_t address=0x3C)
 
IOStreamascii ()
 set the output mode to ASCII style for integer types
 
void attachConfigurationHandler (I2c::ConfigurationHandler handler)
 
IOStreambin ()
 set the output mode to binary style for integer types
 
void clear () final
 
void clearPixel (int16_t x, int16_t y) final
 
void clearPixel (glcd::Point p)
 
modm::ResumableResult< bool > configureScroll (uint8_t origin, uint8_t size, ScrollDirection direction, ScrollStep steps)
 
modm::ResumableResult< bool > disableScroll ()
 
void drawCircle (glcd::Point center, uint16_t radius)
 
void drawEllipse (glcd::Point center, int16_t rx, int16_t ry)
 
void drawImage (glcd::Point start, modm::accessor::Flash< uint8_t > image)
 
void drawImageRaw (glcd::Point start, uint16_t width, uint16_t height, modm::accessor::Flash< uint8_t > data) final
 
void drawLine (glcd::Point start, glcd::Point end)
 
void drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2)
 
void drawRectangle (glcd::Point start, uint16_t width, uint16_t height)
 
void drawRectangle (int16_t x, int16_t y, uint16_t width, uint16_t height)
 
void drawRoundedRectangle (glcd::Point start, uint16_t width, uint16_t height, uint16_t radius)
 
modm::ResumableResult< bool > enableScroll ()
 
IOStreamendl ()
 
virtual void fillCircle (glcd::Point center, uint16_t radius)
 
void fillRectangle (glcd::Point start, uint16_t width, uint16_t height)
 
void fillRectangle (int16_t x, int16_t y, uint16_t width, uint16_t height)
 
IOStreamflush ()
 
IOStreamget (char &c)
 Reads one character and returns it if available. Otherwise, returns IOStream::eof.
 
IOStreamget (char *s, size_t n)
 
template<size_t N>
IOStreamget (char (&s)[N])
 
std::size_t getBufferHeight () const final
 
std::size_t getBufferWidth () const final
 
glcd::Point getCursor () const
 
uint8_t getFontHeight () const
 
uint16_t getHeight () const final
 
bool getPixel (int16_t x, int16_t y) const final
 
uint16_t getStringWidth (const char *s) const
 
uint16_t getWidth () const final
 
IOStreamhex ()
 set the output mode to hexadecimal style for integer types
 
modm::ResumableResult< bool > initialize ()
 initializes for 3V3 with charge-pump asynchronously
 
bool initializeBlocking ()
 initializes for 3V3 with charge-pump
 
bool isWritable ()
 
IOStreamoperator<< (const bool &v)
 
IOStreamoperator<< (const char &v)
 
IOStreamoperator<< (const uint8_t &v)
 
IOStreamoperator<< (const int16_t &v)
 
IOStreamoperator<< (const uint16_t &v)
 
IOStreamoperator<< (const int32_t &v)
 
IOStreamoperator<< (const uint32_t &v)
 
IOStreamoperator<< (const char *s)
 
IOStreamoperator<< (const void *p)
 write the hex value of a pointer
 
template<class Ret , class... Args>
IOStreamoperator<< (Ret (*pointer)(Args...))
 Write the hex value of any function pointer.
 
IOStreamoperator<< (IOStream &(*format)(IOStream &))
 
modm::ResumableResult< bool > ping ()
 
bool pingBlocking ()
 Pings the display.
 
modm::ResumableResult< bool > read (uint8_t *buffer, std::size_t size)
 Starts a write transaction and waits until finished.
 
void setAddress (uint8_t address)
 
modm::ResumableResult< bool > setContrast (uint8_t contrast=0xCE)
 
void setCursor (glcd::Point position)
 
void setCursor (int16_t x, int16_t y)
 
void setCursorX (int16_t x)
 
void setCursorY (int16_t y)
 
modm::ResumableResult< bool > setDisplayMode (DisplayMode mode=DisplayMode::Normal)
 
void setFont (const uint8_t *newFont)
 
void setFont (const modm::accessor::Flash< uint8_t > *font)
 
modm::ResumableResult< bool > setOrientation (glcd::Orientation orientation)
 
void setPixel (int16_t x, int16_t y) final
 
void setPixel (glcd::Point p)
 
void update () override
 Update the display with the content of the RAM buffer.
 
virtual void update () = 0
 
void write (char c)
 
modm::ResumableResult< bool > write (const uint8_t *buffer, std::size_t size)
 Starts a write transaction and waits until finished.
 
virtual modm::ResumableResult< bool > writeDisplay ()
 
modm::ResumableResult< bool > writeRead (const uint8_t *writeBuffer, std::size_t writeSize, uint8_t *readBuffer, std::size_t readSize)
 Starts a write-read transaction and waits until finished.
 

Static Public Member Functions

static uint8_t getFontHeight (const modm::accessor::Flash< uint8_t > *font)
 
static uint16_t getStringWidth (const char *s, const modm::accessor::Flash< uint8_t > *font)
 

Static Public Attributes

static constexpr char eof = -1
 

Protected Types

enum  AdressingCommands : uint8_t {
  MemoryMode = 0x20, ColumnAddress = 0x21, PageAddress = 0x22, PageStartAddress = 0xB0,
  LowerColumnStartAddress = 0x00, HigherColumnStartAddress = 0x10
}
 
enum  ChargePump : uint8_t { DISABLE = 0x00, V7_5 = 0x14, V8_5 = 0x94, V9 = 0x95 }
 
enum  FundamentalCommands : uint8_t {
  ContrastControl = 0x81, EntireDisplayResumeToRam = 0xA4, EntireDisplayIgnoreRam = 0xA5, NormalDisplay = 0xA6,
  InvertedDisplay = 0xA7, DisplayOff = 0xAE, DisplayOn = 0xAF
}
 
enum  HardwareConfigCommands : uint8_t {
  DisplayStartLine = 0x40, SegmentRemap0 = 0xA0, SegmentRemap127 = 0xA1, MultiplexRatio = 0xA8,
  ComOutputScanDirectionIncrement = 0xC0, ComOutputScanDirectionDecrement = 0xC8, DisplayOffset = 0xD3, ComPinsOrder = 0xDA
}
 
enum  MemoryMode : uint8_t { HORIZONTAL = 0, VERTICAL = 1, PAGE = 2 }
 
enum  ScrollingCommands : uint8_t {
  HorizontalScrollRight = 0x26, HorizontalScrollLeft = 0x27, VerticalAndHorizontalScrollRight = 0x29, VerticalAndHorizontalScrollLeft = 0x2A,
  VerticalScrollArea = 0xA3, DisableScroll = 0x2E, EnableScroll = 0x2F
}
 
enum  TimingAndDrivingCommands : uint8_t {
  ChargePump = 0x8D, DisplayClockDivideRatio = 0xD5, PreChargePeriod = 0xD9, V_DeselectLevel = 0xDB,
  Nop = 0xE3
}
 
enum  Transfer : uint8_t { COMMAND_BURST = 0x00, DATA_BURST = 0x40, COMMAND = 0x80, DATA = 0xC0 }
 

Protected Member Functions

modm::ResumableResult< void > startWriteDisplay () override
 
modm::ResumableResult< void > initializeMemoryMode () override
 
void drawCircle4 (glcd::Point center, int16_t x, int16_t y)
 helper method for drawCircle() and drawEllipse()
 
void drawHorizontalLine (glcd::Point start, uint16_t length) final
 
void drawVerticalLine (glcd::Point start, uint16_t length) final
 
int8_t getResumableDepth () const
 
bool isResumableRunning () const
 
bool isTransactionRunning ()
 
modm::ResumableResult< bool > runTransaction ()
 Starts our own transaction and waits until finished.
 
bool startRead (uint8_t *buffer, std::size_t size)
 Configures the transaction with a read operation and starts it.
 
bool startTransaction ()
 Starts the transaction with our own transaction object.
 
bool startTransaction (modm::I2cTransaction *transaction)
 Starts the transaction with a separate transaction object.
 
bool startWrite (const uint8_t *buffer, std::size_t size)
 Configures the transaction with a write operation and starts it.
 
bool startWriteRead (const uint8_t *writeBuffer, std::size_t writeSize, uint8_t *readBuffer, std::size_t readSize)
 Configures the transaction with a write/read operation and starts it.
 
void stopResumable ()
 
bool wasTransactionSuccessful ()
 
void writeBin (uint8_t value)
 
modm::ResumableResult< bool > writeCommands (std::size_t length)
 
void writeHex (uint8_t value)
 
void writeInteger (int16_t value)
 
void writeInteger (uint16_t value)
 
void writeInteger (int32_t value)
 
void writeInteger (uint32_t value)
 
template<typename T >
void writeIntegerMode (const T v)
 
void writePointer (const void *value)
 

Protected Attributes

uint8_t buffer [BufferHeight][BufferWidth]
 
uint8_t commandBuffer [7]
 
glcd::Point cursor
 
modm::accessor::Flash< uint8_t > font
 
ssd1306::Ssd1306_I2cWriteTransaction transaction
 
bool transaction_success
 
Writer writer
 

Detailed Description

template<class I2cMaster, uint8_t Height = 64>
class modm::Sh1106< I2cMaster, Height >

SH1106 is said to be 'compatible' with SSD1306. However there's a relevant difference: SH1106 does only support MemoryMode::PAGE. This requires a little more extensive writeDisplay() routine. We have to alternate between setting Page-address and sending page-data instead of sending the whole buffer at once like is for SSD1306 in MemoryMode::HORIZONTAL / MemoryMode::VERTICAL

Member Function Documentation

void modm::I2cDevice< I2cMaster, 10 , ssd1306::Ssd1306_I2cWriteTransaction >::attachConfigurationHandler ( I2c::ConfigurationHandler  handler)
inheritedinline

Attaches a configuration handler, which is called before a transaction, whenever the configuration has to be changed.

void modm::MonochromeGraphicDisplay< Width, Height, BufferWidth, BufferHeight >::clear ( )
inheritedfinalvirtual

Set whole screen to backgroundColor

Implements modm::GraphicDisplay.

void modm::GraphicDisplay::clearPixel ( glcd::Point  p)
inheritedinline

Set a pixel to backgroundColor

Parameters
ppoint
void modm::MonochromeGraphicDisplayVertical< Width, Height >::clearPixel ( int16_t  x,
int16_t  y 
)
inheritedfinalvirtual

Set a pixel to backgroundColor

Parameters
xx-position
yy-position

Implements modm::GraphicDisplay.

void modm::GraphicDisplay::drawCircle ( glcd::Point  center,
uint16_t  radius 
)
inherited

Draw a filled rectangle with rounded corners

Parameters
startUpper left corner
widthWidth of rectangle
heightHeight of rectangle
radiusRounding radius

Draw a circle

Uses the midpoint circle algorithm.

Parameters
centerCenter of the circle
radiusRadius of the circle
void modm::GraphicDisplay::drawEllipse ( glcd::Point  center,
int16_t  rx,
int16_t  ry 
)
inherited

Draw an ellipse.

Uses a variation of the midpoint algorithm. May be improved through simplification of the used formula.

Parameters
centerCenter of the ellipse
rxRadius in x-direction
ryRadius in y-direction
void modm::GraphicDisplay::drawImage ( glcd::Point  start,
modm::accessor::Flash< uint8_t >  image 
)
inherited

Draw an image.

The first byte in the image data specifies the with, the second byte the height. Afterwards the actual image data.

Parameters
startUpper left corner
imageImage data in Flash
See also
drawImage()
void modm::MonochromeGraphicDisplayVertical< Width, Height >::drawImageRaw ( glcd::Point  start,
uint16_t  width,
uint16_t  height,
modm::accessor::Flash< uint8_t >  data 
)
inheritedfinalvirtual

Draw an image.

Parameters
startUpper left corner
widthImage width
heightImage height
dataImage data in Flash without any size information.

Reimplemented from modm::GraphicDisplay.

void modm::GraphicDisplay::drawLine ( glcd::Point  start,
glcd::Point  end 
)
inheritedinline

Draw a line.

Uses the faster drawHorizontalLine() or drawVerticalLine() if possible, otherwise the line is rastered with the Bresenham line algorithm.

Parameters
startfirst point
endsecond point
void modm::GraphicDisplay::drawLine ( int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2 
)
inherited

Draw a line

Parameters
x1Start x-position
y1Start y-position
x2End x-position
y3End y-position
void modm::GraphicDisplay::drawRectangle ( glcd::Point  start,
uint16_t  width,
uint16_t  height 
)
inherited

Draw a rectangle.

Parameters
startUpper left corner
widthWidth of rectangle
heightHeight of rectangle
void modm::GraphicDisplay::drawRectangle ( int16_t  x,
int16_t  y,
uint16_t  width,
uint16_t  height 
)
inheritedinline

Draw a rectangle.

Parameters
xUpper left corner x-position
yUpper left corner y-position
widthWidth of rectangle
heightHeight of rectangle
void modm::GraphicDisplay::drawRoundedRectangle ( glcd::Point  start,
uint16_t  width,
uint16_t  height,
uint16_t  radius 
)
inherited

Draw a rectangle with rounded corners

Parameters
startUpper left corner
widthWidth of rectangle
heightHeight of rectangle
radiusRounding radius
void modm::GraphicDisplay::fillCircle ( glcd::Point  center,
uint16_t  radius 
)
inheritedvirtual

Draw a filled circle.

Parameters
centerCenter of the circle
radiusRadius of the circle

Reimplemented in modm::ili9341< Interface, Reset, Backlight, BufferSize >.

void modm::GraphicDisplay::fillRectangle ( glcd::Point  start,
uint16_t  width,
uint16_t  height 
)
inherited

Draw a filled rectangle.

Parameters
startUpper left corner
widthWidth of rectangle
heightHeight of rectangle
void modm::GraphicDisplay::fillRectangle ( int16_t  x,
int16_t  y,
uint16_t  width,
uint16_t  height 
)
inheritedinline

Draw a rectangle.

Parameters
xUpper left corner x-position
yUpper left corner y-position
widthWidth of rectangle
heightHeight of rectangle
IOStream & modm::IOStream::get ( char *  s,
size_t  n 
)
inherited

reads characters into NULL delimited c string in contrast to the standard implementation, this does not care about newline characters in the input

std::size_t modm::MonochromeGraphicDisplay< Width, Height, BufferWidth, BufferHeight >::getBufferHeight ( ) const
inheritedinlinefinalvirtual

Buffer-array size of second dimension

Implements modm::GraphicDisplay.

std::size_t modm::MonochromeGraphicDisplay< Width, Height, BufferWidth, BufferHeight >::getBufferWidth ( ) const
inheritedinlinefinalvirtual

Buffer-array size of first dimension

Implements modm::GraphicDisplay.

uint8_t modm::GraphicDisplay::getFontHeight ( ) const
inherited

Get the height of a character.

uint16_t modm::MonochromeGraphicDisplay< Width, Height, BufferWidth, BufferHeight >::getHeight ( ) const
inheritedinlinefinalvirtual

Number of pixel in vertical direction.

Implements modm::GraphicDisplay.

uint16_t modm::GraphicDisplay::getStringWidth ( const char *  s) const
inherited

Get the width of (null terminated) string.

uint16_t modm::MonochromeGraphicDisplay< Width, Height, BufferWidth, BufferHeight >::getWidth ( ) const
inheritedinlinefinalvirtual

Number of pixel in horizontal direction.

Implements modm::GraphicDisplay.

bool modm::I2cDevice< I2cMaster, 10 , ssd1306::Ssd1306_I2cWriteTransaction >::isTransactionRunning ( )
inheritedinlineprotected
Returns
true when transaction is busy.
template<class I2cMaster , uint8_t Height = 64>
bool modm::ssd1306< I2cMaster, Height >::isWritable ( )
inheritedinline

Use this method to synchronize writing to the displays buffer to avoid tearing.

Returns
true if the frame buffer is not being copied to the display
modm::ResumableResult<bool> modm::I2cDevice< I2cMaster, 10 , ssd1306::Ssd1306_I2cWriteTransaction >::ping ( )
inheritedinline
Return Values
truedevice responds to address
falseno device with address found
void modm::I2cDevice< I2cMaster, 10 , ssd1306::Ssd1306_I2cWriteTransaction >::setAddress ( uint8_t  address)
inheritedinline

Sets a new address of the slave device.

Parameters
addressthe slave address not yet shifted left (address < 128).
void modm::GraphicDisplay::setCursor ( glcd::Point  position)
inheritedinline

Set the cursor for text drawing.

Parameters
positionCursor position
void modm::GraphicDisplay::setCursor ( int16_t  x,
int16_t  y 
)
inheritedinline

Set the cursor for text drawing.

Parameters
xCursor x-position
yCursor y-position
void modm::GraphicDisplay::setCursorX ( int16_t  x)
inheritedinline

Set the cursor x-position for text drawing.

Parameters
xCursor x-position
void modm::GraphicDisplay::setCursorY ( int16_t  y)
inheritedinline

Set the cursor y-position for text drawing.

Parameters
yCursor y-position
void modm::GraphicDisplay::setFont ( const uint8_t *  newFont)
inheritedinline

Set a new font.

Default font is modm::font::FixedWidth5x8.

Parameters
newFontActive font
See also
modm::font
template<class I2cMaster , uint8_t Height = 64>
modm::ResumableResult<bool> modm::ssd1306< I2cMaster, Height >::setOrientation ( glcd::Orientation  orientation)
inherited
Parameters
orientationglcd::Orientation::Landscape0 or glcd::Orientation::Landscape180
void modm::GraphicDisplay::setPixel ( glcd::Point  p)
inheritedinline

Set a pixel to foregroundColor

Parameters
ppoint
void modm::MonochromeGraphicDisplayVertical< Width, Height >::setPixel ( int16_t  x,
int16_t  y 
)
inheritedfinalvirtual

Set a pixel to foregroundColor

Parameters
xx-position
yy-position

Implements modm::GraphicDisplay.

bool modm::I2cDevice< I2cMaster, 10 , ssd1306::Ssd1306_I2cWriteTransaction >::wasTransactionSuccessful ( )
inheritedinlineprotected
Returns
true when transaction did not return an error.
void modm::GraphicDisplay::write ( char  c)
inherited

Write a single character.


The documentation for this class was generated from the following file: