Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/bitbank2/ss_oled
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbank2 committed Feb 4, 2020
2 parents cf1a563 + d596080 commit 50efab0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Instructions for use:<br>
Start by initializing the library. Either using hardware I2C, bit-banged I2C or SPI to talk to the display. For I2C, the
address of the display will be detected automatically (either 0x3c or 0x3d). The typical MCU only allows setting the I2C speed up to 400Khz, but the SSD1306 displays can handle a much faster signal. With the bit-bang code, you can usually specify a stable 800Khz clock and with Cortex-M0 targets, the hardware I2C can be told to be almost any speed, but the displays I've tested tend to stop working beyond 1.6Mhz. After initializing the display you can begin drawing text or graphics on it. The final parameter of all of the drawing functions is a render flag. When true, the graphics will be sent to the internal backing buffer (when available) and sent to the display. You optionally pass the library a backing buffer (if your MCU has enough RAM) with the oledSetBackBuffer() function. When the render flag is false, the graphics will only be drawn into the internal buffer. Once you're ready to send the pixels to the display, call oledDumpBuffer(NULL) and it will copy the internal buffer in its entirety to the display. The text drawing function now has a scroll offset parameter. This tells it how many pixels of the text to skip before drawing the text at the given destination coordinates. For example, if you pass a value of 20 for the scroll offset and are using an 8-pixel wide font (FONT_NORMAL), the first two and a half characters will not be drawn; the second half of the third and subsequent characters will be drawn starting at the x/y you specified. This allows you to create a scrolling text effect by repeatedly calling the oledWriteString() function with progressively larger scroll offset values to make the text scroll from right to left.<br>

If you find this code useful, please consider buying me a cup of coffee
If you find this code useful, please consider sending a donation.

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SR4F44J2UR8S4)

2 changes: 1 addition & 1 deletion linux/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ libss_oled.a: ss_oled.o
sudo cp libss_oled.a /usr/local/lib ;\
sudo cp ../src/ss_oled.h /usr/local/include

ss_oled.o: ss_oled.c
ss_oled.o: ss_oled.c ../src/ss_oled.h ../src/ss_oled.cpp
$(CC) $(CFLAGS) -D_LINUX_ ss_oled.c

clean:
Expand Down
20 changes: 13 additions & 7 deletions src/ss_oled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,12 @@ int rc;
rc = read(file_i2c, pBuf, iLen);
return (rc > 0);
}
int I2CRead(uint8_t addr, uint8_t *pBuf, int iLen)
{
int rc;
rc = read(file_i2c, pBuf, iLen);
return (rc > 0);
}
int I2CInit(int iSDAPin, int iSCLPin, int32_t iSpeed)
{
char filename[32];
Expand Down Expand Up @@ -634,7 +640,7 @@ static void oledCachedFlush(void)
bEnd = 1;
} /* oledCachedFlush() */

static void oledCachedWrite(byte *pData, byte bLen)
static void oledCachedWrite(uint8_t *pData, uint8_t bLen)
{

if (bEnd + bLen > MAX_CACHE) // need to flush it
Expand Down Expand Up @@ -1006,7 +1012,7 @@ unsigned char ucTemp[129];
//
// Write a block of flash memory to the display
//
void oledWriteFlashBlock(byte *s, int iLen)
void oledWriteFlashBlock(uint8_t *s, int iLen)
{
int j;
int iWidthMask = oled_x -1;
Expand All @@ -1032,7 +1038,7 @@ uint8_t ucTemp[128];
//
// Write a repeating byte to the display
//
void oledRepeatByte(byte b, int iLen)
void oledRepeatByte(uint8_t b, int iLen)
{
int j;
int iWidthMask = oled_x -1;
Expand Down Expand Up @@ -1063,7 +1069,7 @@ uint8_t ucTemp[128];
//
uint8_t * oledPlayAnimFrame(uint8_t *pAnimation, uint8_t *pCurrent, int iLen)
{
byte *s;
uint8_t *s;
int i, j;
unsigned char b, bCode;
int iBufferSize = (oled_x * oled_y)/8; // size in bytes of the display devce
Expand All @@ -1074,7 +1080,7 @@ int iWidthMask, iWidthShift;
if (pCurrent == NULL || pCurrent > pAnimation + iLen)
return NULL; // invalid starting point

s = (byte *)pCurrent; // start of animation data
s = (uint8_t *)pCurrent; // start of animation data
i = 0;
oledSetPosition(0,0,1);
while (i < iBufferSize) // run one frame
Expand Down Expand Up @@ -1261,7 +1267,7 @@ void oledDrawTile(const uint8_t *pTile, int x, int y, int iRotation, int bInvert
{
for (i=0; i<16; i+=8) // x
{
ucPixels = pgm_read_byte(pTile++);
ucPixels = pgm_read_byte((uint8_t*)pTile++);
ucMask = 0x80; // MSB is the first source pixel
for (k=0; k<8; k++)
{
Expand Down Expand Up @@ -1289,7 +1295,7 @@ void oledDrawTile(const uint8_t *pTile, int x, int y, int iRotation, int bInvert
{
for (i=0; i<16; i+=8) // x
{
ucPixels = pgm_read_byte(pTile++);
ucPixels = pgm_read_byte((uint8_t*)pTile++);
ucMask = 0x80; // MSB is the first source pixel
for (k=0; k<8; k++)
{
Expand Down

0 comments on commit 50efab0

Please sign in to comment.