User manual
137 138
return(x1);
}
// Linien Zeichnen
void disp_line_lcd(int x0, int y0, int x1, int y1, unsigned short col) {
// disp_setpixel(x+b1,y+i,color);
int dx, dy, sx, sy, err, e2;
dx = (x1 - x0);
if (dx < 0) dx = -dx;
dy = (y1 - y0);
if (dy < 0) dy = -dy;
if (x0 < x1) {
sx = 1;
} else {
sx = -1;
}
if (y0 < y1) {
sy = 1;
} else {
sy = -1;
}
//
err = dx - dy;
do {
disp_setpixel(x0, y0, col);
if ((x0 == x1) && (y0 == y1)) return;
e2 = 2 * err;
if (e2 > -dy) {
err = err - dy;
x0 = x0 + sx;
}
if (e2 < dx) {
err = err + dx;
y0 = y0 + sy;
}
} while (1==1);
}
// Rechteck Zeichnen
void disp_rect_lcd(int x1, int y1, int x2, int y2, unsigned short col) {
// disp_setpixel(x+b1,y+i,color);
disp_line_lcd(x1, y1, x2, y1, col);
disp_line_lcd(x1, y2, x2, y2, col);
disp_line_lcd(x1, y1, x1, y2, col);
disp_line_lcd(x2, y1, x2, y2, col);
}
// lled rechteck zeichnen optionaler rahmen
//
void disp_lledrect_lcd(int x1, int y1, int x2, int y2, unsigned short col) {
// disp_setpixel(x+b1,y+i,color);
// schnelles ll
//
// x1,y1 und x2,y2 swappen ggf.
unsigned short *dest; // zielpointer lcdbuffer mit 8 bytes per row !! (little
endian codiert)
int x, y;
if (x1 > x2) {
x = x1;
x1 = x2;
x2 = x;
}
if (y1 > y2) {
y = y1;
y1 = y2;
y2 = y;
}
if (x1 < 0) x1 = 0; // CLIP
if (x1 >= LCDWIDTH) x1 = LCDWIDTH - 1; // CLIP
if (y1< 0) y1 = 0;
if (y1 >= LCDHEIGHT) y1 = LCDHEIGHT - 1; // CLIP;
// ACHTUNG rechnen row
if (x2 < 0) x2 = 0; // CLIP
if (x2 >= LCDWIDTH) x2 = LCDWIDTH - 1; // CLIP
if (y2< 0) y2 = 0;
if (y2 >= LCDHEIGHT) y2 = LCDHEIGHT - 1; // CLIP;
// noch nicht ganz efzient fuer sonderfaelle
// koennte man in bytes zusammenfassen wenn eine ganze row betroffen ist
// also startzeile, n*zeilen 8bit endzeilen z.b.
// bzw drei masken berechnen dafuer...
//
for (y = y1; y<= y2; y++) {
for (x = 0; x<=(x2 - x1); x++) {
disp_setpixel(x, y, col);
}
}
}
// -------------------------END OLED ----------------------------------------------
void setup() {
Wire.begin(); // I2C Init
i2c_oled_initall(i2coledssd); // OLED Init
}
void loop() { // in der Schleife
// 64x48 Pixel OLED
static int phase=0; // Scrolleffekt hier statisch speichern
disp_buffer_clear(COLOR_BLACK); // Virtuellen Buffer loeschen BLACK = dunkel
disp_line_lcd (0,24,63,24, COLOR_WHITE); // x0,y0,x1,y1 Linie in Mitte
for (int i=0; i<63;i++) { // nun fuer alle 64 Spalten (x) des Displays










