Finished the basic functions for the lcd like print pixel, chat, test, line, rectangle, circle, now need to clean ssd1306_i2c

master
kerem yollu 2 years ago
parent d1a570b8df
commit 3e98c7ce71

@ -266,3 +266,82 @@ void lcd_oled_draw_line(uint16_t x, uint16_t y, uint16_t angle, uint16_t lenght,
break;
}
}
void lcd_oled_draw_circle(uint16_t x, uint16_t y, uint16_t radius, uint8_t fill, uint8_t color)
{
uint8_t i = 0;
int16_t x_cicle, y_circle, d = 0;
if(fill == 0)
{
x_cicle = 0;
y_circle = radius;
d = 3 - 2 * radius;
lcd_oled_draw_circle_bresenham(x, y, x_cicle, y_circle, color);
while (y_circle >= x_cicle)
{
x_cicle++;
if (d > 0)
{
y_circle--;
d = d + 4 * (x_cicle - y_circle) + 10;
}
else
d = d + 4 * x_cicle + 6;
lcd_oled_draw_circle_bresenham(x, y, x_cicle, y_circle, color);
}
}
else // To be optimized
{
for(i=radius; i > 0; i--)
{
x_cicle = 0;
y_circle = i;
d = 3 - 2 * i;
lcd_oled_draw_circle_bresenham(x, y, x_cicle, y_circle, color);
while (y_circle >= x_cicle)
{
x_cicle++;
if (d > 0)
{
y_circle--;
d = d + 4 * (x_cicle - y_circle) + 10;
}
else
d = d + 4 * x_cicle + 6;
lcd_oled_draw_circle_bresenham(x, y, x_cicle, y_circle, color);
}
}
}
}
void lcd_oled_draw_circle_bresenham(int16_t xc, int16_t yc, uint8_t x, uint8_t y, uint8_t color)
{
lcd_oled_draw_pixel(xc+x, yc+y, color);
lcd_oled_draw_pixel(xc-x, yc+y, color);
lcd_oled_draw_pixel(xc+x, yc-y, color);
lcd_oled_draw_pixel(xc-x, yc-y, color);
lcd_oled_draw_pixel(xc+y, yc+x, color);
lcd_oled_draw_pixel(xc-y, yc+x, color);
lcd_oled_draw_pixel(xc+y, yc-x, color);
lcd_oled_draw_pixel(xc-y, yc-x, color);
}
void lcd_oled_draw_rectangle(uint16_t x, uint16_t y, uint16_t length, uint16_t width, uint8_t fill, uint8_t color)
{
uint16_t i = 0;
if(fill == EMPTY)
{
lcd_oled_draw_line(x, y, 0, length, color);
lcd_oled_draw_line(x, y+width-1, 0, length, color);
lcd_oled_draw_line(x, y, 270, width, color);
lcd_oled_draw_line(x+length-1, y, 270, width, color);
}
else
{
for(i=0 ; i < width; i++)
{
lcd_oled_draw_line(x, y+i, 0, length, color);
}
}
}

@ -29,6 +29,8 @@ void lcd_oled_init(spi_t *spi_dev, pinNo_t pinNo, uint8_t address);
#error "Please Define The communication Methode in ked/drivers/lcd_oled/lcd_oled.h"
#endif
void lcd_oled_enable();
void lcd_oled_disable();
@ -42,8 +44,9 @@ void lcd_oled_wake();
void lcd_oled_draw_pixel(uint16_t x, uint16_t y, uint8_t color);
void lcd_oled_draw_line(uint16_t x, uint16_t y, uint16_t angle, uint16_t lenght, uint8_t color);
void lcd_oled_draw_rectangle(uint16_t x, uint16_t y, uint16_t lenght, uint16_t width, uint8_t fill, uint8_t color);
void lcd_oled_draw_rectangle(uint16_t x, uint16_t y, uint16_t length, uint16_t width, uint8_t fill, uint8_t color);
void lcd_oled_draw_circle(uint16_t x, uint16_t y, uint16_t radius, uint8_t fill, uint8_t color);
void lcd_oled_draw_circle_bresenham(int16_t xc, int16_t yc, uint8_t x, uint8_t y, uint8_t color);
void lcd_oled_scroll_right(uint16_t start, uint16_t stop);
void lcd_oled_scroll_left(uint16_t start, uint16_t stop);

@ -52,6 +52,7 @@ int main(int argc, char *argv[])
registerToRead = 0x02;
registerToRead = 0x06;
i2cData = 0xAA;
uint8_t text[30]="KED Wellcomes You";
i2c_check_device(&i2c_1, &slaveAddress);
@ -71,12 +72,11 @@ int main(int argc, char *argv[])
lcd_oled_init(&i2c_1 , SSD1306_I2C_ADDRESS);
lcd_oled_display(); //Adafruit logo is visible
delayMs(1000);
lcd_oled_clear();
uint8_t text[30]="KED Wellcomes You";
lcd_oled_print_text(0,5,text,18,WHITE);
delayMs(500);
lcd_oled_clear();
lcd_oled_print_text(0,5,text,18,WHITE);
lcd_oled_draw_line(64, 32, 0, 10, WHITE);
lcd_oled_draw_line(64, 32, 45, 10, WHITE);
lcd_oled_draw_line(64, 32, 90, 10, WHITE);
@ -84,10 +84,19 @@ int main(int argc, char *argv[])
lcd_oled_draw_line(64, 32, 180, 10, WHITE);
lcd_oled_draw_line(64, 32, 225, 10, WHITE);
lcd_oled_draw_line(64, 32, 270, 10, WHITE);
lcd_oled_draw_line(64, 32, 315, 10, WHITE);
lcd_oled_draw_line(64, 32, 315, 10, WHITE);
lcd_oled_draw_circle(64, 32, 15, EMPTY, WHITE);
lcd_oled_draw_circle(10, 30, 10, FILLED, WHITE);
lcd_oled_draw_rectangle(10, 50, 10, 10, EMPTY, WHITE);
lcd_oled_draw_rectangle(30, 50, 10, 10, FILLED, WHITE);
lcd_oled_display(&i2c_1);
print_Usart(usart2, "\n\r");
print_Usart(usart2, "All Is Working fine ");
print_Usart(usart2, "\n\r");

Loading…
Cancel
Save