diff --git a/esp8266_deauther/esp8266_deauther.ino b/esp8266_deauther/esp8266_deauther.ino index 4e531cc..3223dfb 100644 --- a/esp8266_deauther/esp8266_deauther.ino +++ b/esp8266_deauther/esp8266_deauther.ino @@ -15,7 +15,7 @@ // Settings // -//#define USE_DISPLAY /* <-- uncomment that if you want to use the display */ +#define USE_DISPLAY /* <-- uncomment that if you want to use the display */ #define resetPin 4 /* <-- comment out or change if you need GPIO 4 for other purposes */ #define USE_LED16 /* <-- for the Pocket ESP8266 which has a LED on GPIO 16 to indicate if it's running */ @@ -27,11 +27,11 @@ //include the library you need #include "SSD1306.h" #include "SH1106.h" - - //create display(Adr, SDA-pin, SCL-pin) - SSD1306 display(0x3c, 5, 4); //GPIO 5 = D1, GPIO 4 = D2 - //SH1106 display(0x3c, 5, 4); + //create display(Adr, SDA-pin, SCL-pin) + //SSD1306 display(0x3c, 5, 4); //GPIO 5 = D1, GPIO 4 = D2 + SH1106 display(0x3c, 5, 4); + #include "screensaver.h" //button pins #define upBtn 12 //GPIO 12 = D6 #define downBtn 13 //GPIO 13 = D7 @@ -637,8 +637,16 @@ void loop() { display.clear(); display.display(); } + screensavertimer = 0; + lastactivity = millis(); + } else { + screensavertimer = millis() - lastactivity; + } + if(screensavertimer>saveeafter) { + drawScreenSaver(); + } else { + drawInterface(); } - drawInterface(); #endif } diff --git a/esp8266_deauther/screensaver.h b/esp8266_deauther/screensaver.h new file mode 100644 index 0000000..9bb2ce2 --- /dev/null +++ b/esp8266_deauther/screensaver.h @@ -0,0 +1,240 @@ +#ifdef USE_DISPLAY + +time_t lastactivity = millis(); +time_t saveeafter = 100000; // millesecs before screensaver start +time_t screensavertimer = 0; + + +float angleX, angleY, angleZ; +float lastAngleX, lastAngleY, lastAngleZ; + +#define DEBUG false + +const double halfC = M_PI / 180; + +// Overall scale and perspective distance +uint8_t sZ = 4, scale = 16, scaleMax = 16; +// screen center coordinates (calculated from screen dimensions) +uint8_t centerX = 64; +uint8_t centerY = 32; + +typedef struct { + double x; + double y; + double z; +} Coord3DSet; + +typedef struct { + double x; + double y; +} Coord2DSet; + +typedef struct { + uint16_t id1; + uint16_t id2; +} Lines; + + +/* https://codepen.io/ge1doot/pen/grWrLe */ + +static Coord3DSet CubePoints3DArray[21] = { + { 1, 1, 1 }, + { 1, 1, -1 }, + { 1, -1, 1 }, + { 1, -1, -1 }, + { -1, 1, 1 }, + { -1, 1, -1 }, + { -1, -1, 1 }, + { -1, -1, -1 }, + + { 1, 1, 0 }, + { 1, 0, 1 }, + { 0, 1, 1 }, + + { -1, 1, 0 }, + { -1, 0, 1 }, + { 0, -1, 1 }, + + { 1, -1, 0 }, + { 1, 0, -1 }, + { 0, 1, -1 }, + + { -1, -1, 0 }, + { -1, 0, -1 }, + { 0, -1, -1 }, + + {0, 0, 0} + +}; + +static Coord3DSet CubePoints2DArray[21] = { + { 0,0 }, + { 0,0 }, + { 0,0 }, + { 0,0 }, + { 0,0 }, + { 0,0 }, + { 0,0 }, + { 0,0 }, + + { 0,0 }, + { 0,0 }, + { 0,0 }, + { 0,0 }, + { 0,0 }, + { 0,0 }, + { 0,0 }, + { 0,0 }, + { 0,0 }, + + { 0,0 }, + { 0,0 }, + { 0,0 }, + + { 0,0 } +}; + +static Lines LinesArray[12] = { + { 0, 1 }, + { 0, 2 }, + { 0, 4 }, + { 1, 3 }, + { 1, 5 }, + { 2, 3 }, + { 2, 6 }, + { 3, 7 }, + { 4, 5 }, + { 4, 6 }, + { 5, 7 }, + { 6, 7 } +/* + { 1, 4 }, + { 2, 3 }, + { 1, 6 }, + { 2, 5 }, + { 2, 8 }, + { 6, 4 }, + { 4, 7 }, + { 3, 8 }, + { 1, 7 }, + { 3, 5 }, + { 5, 8 }, + { 7, 6 } + */ + +}; + +// used for sorting points by depth +uint16_t zsortedpoints[21] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; + +uint16_t totalpoints = sizeof(CubePoints3DArray) / sizeof(CubePoints3DArray[0]); +uint16_t totallines = sizeof(LinesArray) / sizeof(LinesArray[0]); + + +void vectorRotateXYZ(double angle, int axe) { + int8_t m1; // coords polarity + uint8_t i1, i2; // coords index + double t1, t2; + uint16_t i; + for( i=0; i nextradius) { + temp = zsortedpoints[i]; + zsortedpoints[i] = zsortedpoints[i + 1]; + zsortedpoints[i + 1] = temp; + swapped = true; + } + } + } while (swapped); +} + + +/* draw scaled spheres from background to foreground */ +void spherePlot() { + uint16_t i; + int radius, halfradius; + int transid; + for( i=0; i