mirror of
https://github.com/Matiasus/SSD1306.git
synced 2024-10-03 18:18:46 -04:00
Fix conflicts
This commit is contained in:
commit
e0e3a7053e
129
lib/ssd1306.c
129
lib/ssd1306.c
@ -102,25 +102,26 @@
|
||||
const uint8_t INIT_SSD1306[] PROGMEM = {
|
||||
18, // number of initializers
|
||||
0, SSD1306_DISPLAY_OFF, // 0xAE = Set Display OFF
|
||||
1, SSD1306_SET_MUX_RATIO, 0x3F, // 0xA8
|
||||
1, SSD1306_SET_MUX_RATIO, 0x3F, // 0xA8 - 64MUX
|
||||
1, SSD1306_MEMORY_ADDR_MODE, 0x00, // 0x20 = Set Memory Addressing Mode
|
||||
// 0x00 - Horizontal Addressing Mode
|
||||
// 0x01 - Vertical Addressing Mode
|
||||
// 0x02 - Page Addressing Mode (RESET)
|
||||
2, SSD1306_SET_COLUMN_ADDR, START_COLUMN_ADDR, END_COLUMN_ADDR, // 0x21 = Set Column Address
|
||||
2, SSD1306_SET_PAGE_ADDR, START_PAGE_ADDR, END_PAGE_ADDR, // 0x22 = Set Page Address
|
||||
2, SSD1306_SET_COLUMN_ADDR, START_COLUMN_ADDR, END_COLUMN_ADDR, // 0x21 = Set Column Address, 0 - 127
|
||||
2, SSD1306_SET_PAGE_ADDR, START_PAGE_ADDR, END_PAGE_ADDR, // 0x22 = Set Page Address, 0 - 7
|
||||
0, SSD1306_SET_START_LINE, // 0x40
|
||||
1, SSD1306_DISPLAY_OFFSET, 0x00, // 0xD3
|
||||
0, SSD1306_SEG_REMAP_OP, // 0xA0 / remap 0xA1
|
||||
0, SSD1306_COM_SCAN_DIR_OP, // 0xC0 / remap 0xC8
|
||||
1, SSD1306_COM_PIN_CONF, 0x12, // 0xDA
|
||||
1, SSD1306_SET_CONTRAST, 0x7F, // 0x81
|
||||
1, SSD1306_COM_PIN_CONF, 0x12, // 0xDA, 0x12 - Disable COM Left/Right remap, Alternative COM pin configuration
|
||||
1, SSD1306_SET_CONTRAST, 0x7F, // 0x81, 0x7F - reset value (max 0xFF)
|
||||
0, SSD1306_DIS_ENT_DISP_ON, // 0xA4
|
||||
0, SSD1306_DIS_NORMAL, // 0xA6
|
||||
1, SSD1306_SET_OSC_FREQ, 0x80, // 0xD5
|
||||
1, SSD1306_SET_PRECHARGE, 0xc2, // 0xD9, 1st Period = higher value less blinking
|
||||
1, SSD1306_SET_OSC_FREQ, 0x80, // 0xD5, 0x80 => D=1; DCLK = Fosc / D <=> DCLK = Fosc
|
||||
1, SSD1306_SET_PRECHARGE, 0xc2, // 0xD9, higher value less blinking
|
||||
// 0xC2, 1st phase = 2 DCLK, 2nd phase = 13 DCLK
|
||||
1, SSD1306_VCOM_DESELECT, 0x20, // Set V COMH Deselect, reset value 0x22 = 0,77xUcc
|
||||
1, SSD1306_SET_CHAR_REG, 0x14, // 0x8D
|
||||
1, SSD1306_SET_CHAR_REG, 0x14, // 0x8D, Enable charge pump during display on
|
||||
0, SSD1306_DISPLAY_ON // 0xAF = Set Display ON
|
||||
};
|
||||
|
||||
@ -523,6 +524,14 @@ uint8_t SSD1306_DrawPixel (uint8_t x, uint8_t y)
|
||||
|
||||
page = y >> 3; // find page (y / 8)
|
||||
pixel = 1 << (y - (page << 3)); // which pixel (y % 8)
|
||||
<<<<<<< HEAD
|
||||
|
||||
// set position
|
||||
// -------------------------------------------------------------------------------------
|
||||
status = SSD1306_SetPosition (x, page); // update position
|
||||
if (SSD1306_SUCCESS != status) { // check status
|
||||
return status; // error
|
||||
=======
|
||||
|
||||
// set position
|
||||
// -------------------------------------------------------------------------------------
|
||||
@ -556,3 +565,107 @@ uint8_t SSD1306_DrawPixel (uint8_t x, uint8_t y)
|
||||
|
||||
return SSD1306_SUCCESS; // success
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc Draw line by Bresenham algoritm
|
||||
*
|
||||
* @param uint8_t x start position / 0 <= cols <= MAX_X-1
|
||||
* @param uint8_t x end position / 0 <= cols <= MAX_X-1
|
||||
* @param uint8_t y start position / 0 <= rows <= MAX_Y-1
|
||||
* @param uint8_t y end position / 0 <= rows <= MAX_Y-1
|
||||
*
|
||||
* @return uint8_t
|
||||
*/
|
||||
uint8_t SSD1306_DrawLine (uint8_t x1, uint8_t x2, uint8_t y1, uint8_t y2)
|
||||
{
|
||||
int16_t D; // determinant
|
||||
int16_t delta_x, delta_y; // deltas
|
||||
int16_t trace_x = 1, trace_y = 1; // steps
|
||||
|
||||
delta_x = x2 - x1; // delta x
|
||||
delta_y = y2 - y1; // delta y
|
||||
|
||||
// Vertical line
|
||||
// -------------------------------------------------------------------------------------
|
||||
if (delta_x == 0) {
|
||||
status = SSD1306_DrawLineVert (x1, y1, y2); // draw vertical line
|
||||
if (SSD1306_SUCCESS != status) { // check status
|
||||
return status; // error
|
||||
}
|
||||
return SSD1306_SUCCESS; // success return
|
||||
}
|
||||
// Horizontal line
|
||||
// -------------------------------------------------------------------------------------
|
||||
if (delta_y == 0) {
|
||||
status = SSD1306_DrawLineHorz (y1, x1, x2); // draw horizontal line
|
||||
if (SSD1306_SUCCESS != status) { // check status
|
||||
return status; // error
|
||||
}
|
||||
return SSD1306_SUCCESS; // success return
|
||||
}
|
||||
|
||||
if (delta_x < 0) { // check if x2 > x1
|
||||
delta_x = -delta_x; // negate delta x
|
||||
trace_x = -trace_x; // negate step x
|
||||
>>>>>>> origin/develop
|
||||
}
|
||||
|
||||
// TWI start & SLAW
|
||||
// -------------------------------------------------------------------------------------
|
||||
status = SSD1306_Send_StartAndSLAW (SSD1306_ADDR); // start & SLAW
|
||||
if (SSD1306_SUCCESS != status) { // check status
|
||||
return status; // error
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
// TWI control byte data stream
|
||||
// -------------------------------------------------------------------------------------
|
||||
status = TWI_MT_Send_Data (SSD1306_DATA_STREAM); // send data 0x40
|
||||
if (SSD1306_SUCCESS != status) { // check status
|
||||
return status; // error
|
||||
}
|
||||
// send clear byte to memory lcd
|
||||
// -------------------------------------------------------------------------------------
|
||||
status = TWI_MT_Send_Data (pixel); // send pixel
|
||||
if (SSD1306_SUCCESS != status) { // check status
|
||||
return status; // error
|
||||
}
|
||||
|
||||
// TWI stop
|
||||
// -------------------------------------------------------------------------------------
|
||||
TWI_Stop ();
|
||||
|
||||
return SSD1306_SUCCESS; // success
|
||||
=======
|
||||
// condition for m < 1 (dy < dx)
|
||||
// -------------------------------------------------------------------------------------
|
||||
if (delta_y < delta_x) { //
|
||||
D = (delta_y << 1) - delta_x; // calculate determinant
|
||||
SSD1306_DrawPixel (x1, y1); // draw first pixel
|
||||
while (x1 != x2) { // check if x1 equal x2
|
||||
x1 += trace_x; // update x1
|
||||
if (D >= 0) { // positive?
|
||||
y1 += trace_y; // update y1
|
||||
D -= 2*delta_x; // update determinant
|
||||
}
|
||||
D += 2*delta_y; // update deteminant
|
||||
SSD1306_DrawPixel (x1, y1); // draw next pixel
|
||||
}
|
||||
// condition for m >= 1 (dy >= dx)
|
||||
// -------------------------------------------------------------------------------------
|
||||
} else {
|
||||
D = delta_y - (delta_x << 1); // calculate determinant
|
||||
SSD1306_DrawPixel (x1, y1); // draw first pixel
|
||||
while (y1 != y2) { // check if y2 equal y1
|
||||
y1 += trace_y; // update y1
|
||||
if (D <= 0) { // positive?
|
||||
x1 += trace_x; // update y1
|
||||
D += 2*delta_y; // update determinant
|
||||
}
|
||||
D -= 2*delta_x; // update deteminant
|
||||
SSD1306_DrawPixel (x1, y1); // draw next pixel
|
||||
}
|
||||
}
|
||||
|
||||
return SSD1306_SUCCESS; // success return
|
||||
>>>>>>> origin/develop
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user