* Update Display.cpp

I THINK I FIGURED OUT WHAT IM DOING

* Add files via upload

* Update esp32_marauder.ino

* Update MenuFunctions.cpp

* Update MenuFunctions.h

* Update MenuFunctions.cpp

* Update README.md

* Update README.md

* Update MenuFunctions.cpp

* Update MenuFunctions.h

* Update MenuFunctions.h

* Add files via upload

* Update esp32_marauder.ino

* Update README.md

* Update Display.cpp

moved the float "wd", as the draw function would continously change it, which resulted in those weird effects when trying to draw different thicknesses

* Update MenuFunctions.cpp

* Update Display.cpp

made it so the drawing code doesnt need to draw every pixel individually and made it so it can handle higher thiccnesses... at all. it did not handly thicknesses above 2 with any kind of grace

* Update Display.cpp

removed unneccessary variable changes, just realized i kept making certain variables be a certain value over and over

* Fix screen change battery percentage

* restore TFT touch data

Co-authored-by: Just Call Me Koko <25190487+justcallmekoko@users.noreply.github.com>
This commit is contained in:
Joshinken
2020-07-21 23:45:20 +02:00
committed by GitHub
parent bbc10e4452
commit 7a5134bb86
6 changed files with 834 additions and 624 deletions

View File

@@ -465,7 +465,6 @@ void Display::drawJpeg(const char *filename, int xpos, int ypos) {
uint16_t xlast;
uint16_t ylast;
uint32_t AH;
float wd = 3;
void Display::drawStylus()
{
uint16_t x = 0, y = 0; // To store the touch coordinates
@@ -477,26 +476,35 @@ void Display::drawStylus()
if (pressed) {
// tft.fillCircle(x, y, 2, TFT_WHITE);
if ( xlast > 0 && ylast > 0 ) {
int dx = abs(x - xlast), sx = xlast < x ? 1 : -1;
int dy = abs(y - ylast), sy = ylast < y ? 1 : -1;
int err = dx - dy, e2, x2, y2; /* error value e_xy */
float ed = dx + dy == 0 ? 1 : sqrt((float)dx * dx + (float)dy * dy);
for (wd = (wd + 1) / 2; ; ) { /* pixel loop */
tft.drawPixel(xlast, ylast, TFT_WHITE);
e2 = err; x2 = xlast;
if (2 * e2 >= -dx) { /* x step */
for (e2 += dy, y2 = ylast; e2 < ed * wd && (y != y2 || dx > dy); e2 += dx)
tft.drawPixel(xlast, y2 += sy, TFT_WHITE);
if (xlast == x) break;
e2 = err; err -= dy; xlast += sx;
}
if (2 * e2 <= dy) { /* y step */
for (e2 = dx - e2; e2 < ed * wd && (x != x2 || dx < dy); e2 += dy)
tft.drawPixel(x2 += sx, ylast, TFT_WHITE);
if (ylast == y) break;
err += dx; ylast += sy;
}
uint16_t the_color = TFT_WHITE;
uint16_t wd = 1;
int xlast2;
int ylast2;
int x2;
int y2;
int n;
int n2 = -wd;
xlast2 = xlast - wd;
x2 = x - wd;
for (n = -wd; n <= wd; n++) {
ylast2 = ylast + n;
y2 = y + n;
tft.drawLine(xlast2, ylast2, x2, y2, the_color);
}
for (n2 = -wd; n2 <= wd; n2++) {
xlast2 = xlast + n2;
x2 = x + n2;
tft.drawLine(xlast2, ylast2, x2, y2, the_color);
}
for (n = wd; n >= -wd; n--) {
ylast2 = ylast + n;
y2 = y + n;
tft.drawLine(xlast2, ylast2, x2, y2, the_color);
}
for (n2 = wd; n2 >= -wd; n2--) {
xlast2 = xlast + n2;
x2 = x + n2;
tft.drawLine(xlast2, ylast2, x2, y2, the_color);
}
// tft.drawLine(xlast, ylast, x, y, TFT_WHITE);
}