def cmdSetColAddr(colStart, colEnd): """ Setup column start and end address for horizontal/vertical mode """ if (colStart < 0) or (colStart > 127): raise ValueError("Column Start only valid from 0 to 127") if (colEnd < 0) or (colEnd > 127): raise ValueError("Column End only valid from 0 to 127") if (colStart > colEnd): raise ValueError("Column End must be greater then Column Start") sendCmd(0x21, colStart, colEnd)
def cmdSetPageAddr(pageStart, pageEnd): """ Setup page start and end address for horizontal/vertical mode """ if (pageStart < 0) or (pageStart > 7): raise ValueError("Page Start only valid from 0 to 7") if (pageEnd < 0) or (pageEnd > 7): raise ValueError("Page End only valid from 0 to 7") if (pageStart > pageEnd): raise ValueError("Page End must be greater then Page Start") sendCmd(0x22, pageStart, pageEnd)
def cmdSetContrast(contrast): """ Set display contrast 0-255 """ if contrast > 255: raise ValueError('Paramteres from 0 to 255 excepted!') sendCmd(0x81, contrast)
def cmdSetMuxRatio(muxRatio): """ Set MUX ratio to N+1 MUX, values from 16 to 63 allowed """ if (muxRatio < 15) or (muxRatio > 63): raise ValueError("Mux Ratio from 16 to 63 supported!") sendCmd(0xA8, muxRatio)
def cmdRemapCol(bRemap): """ Remap segments to either start from 0 or from 127 """ if bRemap: sendCmd(0xA1) else: sendCmd(0xA0)
def cmdSetStartRow(startRow): """ Set Display RAM start row from 0-63 """ if (startRow < 0) or (startRow > 63): raise ValueError("Start Row from 0 to 63 supported!") sendCmd(0x40 | startRow)
def cmdChargePumpDisable(): """ Disable charge pump for the display """ sendCmd(0x8D, 0x10)
def cmdChargePumpEnable(): """ Enable charge pump for the display """ sendCmd(0x8D, 0x14)
def cmdSetCurPage(page): """ Set Page Start Address, Current Line if in Page Mode """ if (page < 0) or (page > 7): raise ValueError("Pages from 0 to 7 supported!") sendCmd(0xB0 | page)
def cmdSetAddrMode(addrMode): """ Set display address mode """ if addrMode == ADDR_MODE_HOR or ADDR_MODE_VER or ADDR_MODE_PAGE: sendCmd(0x20, addrMode) else: raise ValueError("Undefined address mode!")
def cmdDisplayInverse(bInverse): """ Inverse display """ if bInverse: sendCmd(0xA7) else: sendCmd(0xA6)
def cmdDisplayAllOn(bOn): """ Turn all pixels On """ if bOn: sendCmd(0xA5) else: sendCmd(0xA4)
def cmdDisplayOFF(): """ Turn display off """ sendCmd(0xAE)
def cmdDisplayON(): """ Turn display on """ sendCmd(0xAF)
def cmdRemapRow(bRemap): """ Remap COM Output scan direction """ if bRemap: sendCmd(0xC8) else: sendCmd(0xC0)
def cmdSetRowOffset(offset): """ Set vertical shift by COM from 0 to 63 """ if (offset < 0) or (offset > 63): raise ValueError("Offset from 0 to 63 supported!") sendCmd(0xD3, offset)
def cmdSetCurCol(col): """ Set Column Start Address, Current column in Page Mode """ if (col < 0) or (col > 127): raise ValueError("Columns from 0 to 127 supported!") sendCmd(col & 0x0F) # lower nibble with cmd 0x00 sendCmd(((col >> 4) & 0x0F) | 0x10) # higher nibble with cmd 0x01