Skip to content

Commit

Permalink
Some modif from André Knörig
Browse files Browse the repository at this point in the history
- reset pin was hard-coded to pin 8
- setFont, setPenSize, setTextAppearance didn't work
- renamed OLED_SEND_ADD_USER_BMP_CHAR to CMD_ADD_USER_BMP_CHAR for consistence
- added replaceColor command
  • Loading branch information
Charles R committed Jan 23, 2013
1 parent 8f83f7a commit df95c8f
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions Oled4d.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum OLED4D_CMD {

CMD_DETECT_BAUDRATE = 0x55,

OLED4D_SEND_ADD_USER_BMP_CHAR = 'A',
CMD_ADD_USER_BMP_CHAR = 'A',
CMD_SET_BG_COLOR = 'B',
CMD_PLACE_TEXT_BUTTON = 'b',
CMD_DRAW_CIRCLE = 'C',
Expand All @@ -64,6 +64,7 @@ enum OLED4D_CMD {
CMD_DRAW_TRIANGLE = 'G',
CMD_DRAW_POLYGON = 'g',
CMD_DISPLAY_IMAGE = 'I',
CMD_REPLACE_COLOR = 'k',
CMD_DRAW_LINE = 'L',
CMD_OPAQUE_TRANSPARENT_TXT = 'O',
CMD_PUT_PIXEL = 'P',
Expand Down Expand Up @@ -211,6 +212,7 @@ class Oled4d

void drawPolygon(char, char *, OLED4D_COLOR);
char displayImage(char, char, char, char, OLED4D_COLORMODE, char *);
void replaceColor(char, char, char, char, OLED4D_COLOR, OLED4D_COLOR);

// User bitmap
void addBmpChar(char, char[]);
Expand Down Expand Up @@ -248,7 +250,7 @@ Oled4d<T>::Oled4d(HardwareSerial &serial, unsigned char reset_pin) :
_reset_pin(reset_pin)
{
_last_status_code = 0;
pinMode(8, OUTPUT);
pinMode(reset_pin, OUTPUT);
};

template <class T>
Expand All @@ -257,7 +259,7 @@ Oled4d<T>::Oled4d(NewSoftSerial &serial, unsigned char reset_pin) :
_reset_pin(reset_pin)
{
_last_status_code = 0;
pinMode(8, OUTPUT);
pinMode(reset_pin, OUTPUT);
};

template <class T>
Expand Down Expand Up @@ -367,7 +369,7 @@ void Oled4d<T>::getInfo(bool output, Oled4d_info &info)
template <class T>
void Oled4d<T>::setFont(OLED4D_FONT font)
{
command(CMD_FONT, font);
OLED4D_SEND_I(CMD_FONT, font);
}

template <class T>
Expand All @@ -387,7 +389,7 @@ void Oled4d<T>::drawString(char str, char column, char row, OLED4D_COLOR color)
template <class T>
void Oled4d<T>::setTextAppearance(OLED4D_TEXTAPPEARANCE appearance)
{
command(CMD_OPAQUE_TRANSPARENT_TXT, appearance);
OLED4D_SEND_I(CMD_OPAQUE_TRANSPARENT_TXT, appearance);
}

template <class T>
Expand Down Expand Up @@ -469,7 +471,7 @@ char Oled4d<T>::displayImage(char x, char y, char width, char height, OLED4D_COL
template <class T>
void Oled4d<T>::setPenSize(OLED4D_PENSIZE pensize)
{
command(CMD_SET_PEN_SIZE, pensize);
OLED4D_SEND_I(CMD_SET_PEN_SIZE, pensize);
}

template <class T>
Expand Down Expand Up @@ -515,7 +517,7 @@ void Oled4d<T>::addBmpChar(char index, char bitmap[])
args[c + 1] = bitmap[c];
}

OLED4D_SEND_A(OLED4D_SEND_ADD_USER_BMP_CHAR, args);
OLED4D_SEND_A(CMD_ADD_USER_BMP_CHAR, args);
}

// Display bitmap char from index
Expand Down Expand Up @@ -592,4 +594,11 @@ void Oled4d<T>::displayImgFromSD(char x, char y, char width, char height, OLED4D
OLED4D_SEND_A(CMD_EXTENDED_COMMAND, args);
}

template <class T>
void Oled4d<T>::replaceColor(char x1, char y1, char x2, char y2, OLED4D_COLOR old_color, OLED4D_COLOR new_color)
{
char args[] = { x1, y1, x2, y2, SPLIT(old_color), SPLIT(new_color) };
OLED4D_SEND_A(CMD_REPLACE_COLOR, args);
}

#endif

0 comments on commit df95c8f

Please sign in to comment.