├── .gitattributes ├── .gitignore ├── Lights.ino └── SerialMonitor.ino /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /Lights.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef __AVR__ 3 | #include 4 | #endif 5 | 6 | #define PIN 6 7 | 8 | // Parameter 1 = number of pixels in strip 9 | // Parameter 2 = Arduino pin number (most are valid) 10 | // Parameter 3 = pixel type flags, add together as needed: 11 | // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 12 | // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 13 | // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 14 | // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 15 | Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800); 16 | 17 | // IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across 18 | // pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input 19 | // and minimize distance between Arduino and first pixel. Avoid connecting 20 | // on a live circuit...if you must, connect GND first. 21 | 22 | const int pinLigths = 2; 23 | 24 | void setup() { 25 | digitalWrite(pinLigths, 0); 26 | pinMode(pinLigths, INPUT); 27 | digitalWrite(pinLigths, 0); 28 | // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket 29 | #if defined (__AVR_ATtiny85__) 30 | if (F_CPU == 16000000) clock_prescale_set(clock_div_1); 31 | #endif 32 | // End of trinket special code 33 | 34 | strip.begin(); 35 | strip.show(); // Initialize all pixels to 'off' 36 | } 37 | 38 | void loop() { 39 | int val = digitalRead(pinLigths); 40 | if ( val > 0 ){ 41 | // Some example procedures showing how to display to the pixels: 42 | // colorWipe(strip.Color(255, 0, 0), 50); // Red 43 | //colorWipe(strip.Color(0, 255, 0), 50); // Green 44 | //colorWipe(strip.Color(0, 0, 255), 50); // Blue 45 | // Send a theater pixel chase in... 46 | theaterChase(strip.Color(127, 127, 127), 50); // White 47 | /*theaterChase(strip.Color(127, 0, 0), 50); // Red 48 | theaterChase(strip.Color(0, 0, 127), 50); // Blue 49 | 50 | rainbow(20); 51 | rainbowCycle(20); 52 | theaterChaseRainbow(50);*/ 53 | } else { 54 | colorWipe(strip.Color(0,0,0), 10); 55 | } 56 | } 57 | 58 | // Fill the dots one after the other with a color 59 | void colorWipe(uint32_t c, uint8_t wait) { 60 | for(uint16_t i=0; i 2 | #include 3 | #include 4 | #include 5 | 6 | //#define USE_TEENSY_KEYBOARD 7 | #include "HID-Project.h" 8 | 9 | // OLED setup 10 | #define OLED_RESET 12 11 | SSD1306 display(OLED_RESET); 12 | int oledDraw = 0; 13 | int oledOverride = 0; 14 | 15 | // Neopixel setup 16 | #define PIN 5 17 | Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800); 18 | 19 | // Debpunce timers for buttons 20 | long lastDebounceTime = 0; 21 | long debounceDelay = 3000; 22 | 23 | // Inverted timers for oled 24 | long invertDelay = 300000; 25 | long lastInvertTime = 0; 26 | int invertedStatus = 0; 27 | 28 | // media buttons 29 | const int pinButton = A0; 30 | 31 | //extra butons 32 | const int sButton = A1; 33 | 34 | //tray button 35 | const int tButton = A2; 36 | 37 | // vars for serial input 38 | String inputString = ""; 39 | boolean stringComplete = false; 40 | 41 | // initial neopixel status 42 | int lightStatus = 0; 43 | int lightOverride = 0; 44 | int loginStatus = 1; 45 | void setup() { 46 | /* NEO PIXEL SETUP */ 47 | strip.begin(); 48 | strip.show(); 49 | 50 | /* PIN SETUP */ 51 | pinMode(pinButton, INPUT); 52 | pinMode(sButton, INPUT); 53 | 54 | 55 | // Tray button 56 | pinMode(tButton, INPUT); 57 | 58 | 59 | /* OLED SETUP */ 60 | display.begin(SSD1306_SWITCHCAPVCC, 0x3c); 61 | display.clearDisplay(); 62 | display.setTextColor(WHITE); 63 | oledDrawBackground(); 64 | 65 | 66 | /* Media keys setup */ 67 | Consumer.begin(); 68 | /* Teensy for mod shortcuts */ 69 | //TeensyKeyboard.begin(); 70 | /* Keyboard FTW */ 71 | Keyboard.begin(); 72 | 73 | 74 | /* Serial setup */ 75 | Serial.begin(9600); 76 | inputString.reserve(200); 77 | 78 | } 79 | 80 | void loop() { 81 | 82 | 83 | if (lastInvertTime < 1 ){ 84 | lastInvertTime = millis(); 85 | } 86 | 87 | serialEvent(); 88 | 89 | /* OLED DRAW STATS */ 90 | if (stringComplete) { 91 | display.setTextSize(1); 92 | display.fillRect(25, 0, 64, 39, BLACK); 93 | display.setCursor(25,0); 94 | int cpuStringStart = inputString.indexOf("C"); 95 | int cpuStringLimit = inputString.indexOf("|"); 96 | String cpuString = inputString.substring(cpuStringStart+1, cpuStringLimit); 97 | display.println(cpuString); 98 | display.setCursor(25,10); 99 | int gpuStringStart = inputString.indexOf("G", cpuStringLimit); 100 | int gpuStringLimit = inputString.indexOf("|", gpuStringStart); 101 | String gpuString = inputString.substring(gpuStringStart+1 ,gpuStringLimit); 102 | display.println(gpuString); 103 | display.setCursor(25,20); 104 | int ramStringStart = inputString.indexOf("R", gpuStringLimit); 105 | int ramStringLimit = inputString.indexOf("|", ramStringStart); 106 | String ramString = inputString.substring(ramStringStart+1 ,ramStringLimit); 107 | display.println(ramString); 108 | display.fillRect(0, 42, 128, 22, BLACK); 109 | display.setCursor(0,42); 110 | int songStringStart = inputString.indexOf("S", ramStringLimit); 111 | int songStringLimit = inputString.indexOf("|", songStringStart); 112 | String songString = inputString.substring(songStringStart+1, songStringLimit); 113 | display.println(songString); 114 | display.display(); 115 | inputString = ""; 116 | stringComplete = false; 117 | } 118 | 119 | 120 | /* MEDIA EVENTS */ 121 | int c = analogRead(pinButton); 122 | if ( c > 50 ) { 123 | display.fillRect(94, 0, 34, 36, BLACK); 124 | if( c >= 510){ 125 | Consumer.write(MEDIA_PREVIOUS); 126 | //PREV 127 | display.fillTriangle(94, 19 ,124, 4,124, 34, WHITE); 128 | display.fillRect(94, 4, 4, 30, WHITE); 129 | } else if (c >= 60 && c <= 65){ 130 | Consumer.write(MEDIA_PLAY_PAUSE); 131 | //PLAY 132 | display.fillTriangle(94, 34 ,94, 4,124, 19, WHITE); 133 | } else if ( c >= 89 && c <= 95 ){ 134 | Consumer.write(MEDIA_NEXT); 135 | //NEXT 136 | display.fillTriangle(94, 34 ,94, 4,124, 19, WHITE); 137 | display.fillRect(121, 4, 4, 30, WHITE); 138 | } else if ( c >= 116 && c <= 120 ){ 139 | Consumer.write(MEDIA_VOLUME_MUTE); 140 | //MUTE 141 | display.fillRect(94, 4, 30, 30, WHITE); 142 | } else if ( c >= 140 && c <= 145 ){ 143 | Consumer.write(MEDIA_VOLUME_DOWN); 144 | //VOL DOWN 145 | display.fillRect(94, 15, 30, 8, WHITE); 146 | } else if ( c >= 165 && c <= 170 ){ 147 | Consumer.write(MEDIA_VOLUME_UP); 148 | //VOL UP 149 | display.fillRect(94, 15, 30, 8, WHITE); 150 | display.fillRect(105, 4, 8, 30, WHITE); 151 | }; 152 | if ( oledDraw == 1 ){ 153 | display.display(); 154 | } 155 | delay(50); 156 | lastDebounceTime = millis(); 157 | } 158 | /* CLEAR MEDIA SQUARE */ 159 | if ((millis() - lastDebounceTime) > debounceDelay) { 160 | clearMedia(); 161 | } 162 | /* SCREEN INVERT */ 163 | if ((millis() - lastInvertTime) > invertDelay && oledDraw == 1) { 164 | lastInvertTime = millis(); 165 | inverter(); 166 | } 167 | 168 | 169 | int s = analogRead(sButton); 170 | if ( s > 25 ){ 171 | if ( s >= 28 && s <= 50 ){ 172 | if ( oledOverride == 0 ){ 173 | oledOverride = 1; 174 | } else if ( oledOverride == 1 ){ 175 | oledOverride = 0; 176 | } 177 | if ( oledDraw == 1 ){ 178 | antiBurn(); 179 | } else if ( oledDraw == 0 ){ 180 | oledDrawBackground(); 181 | } 182 | } 183 | if ( s >= 60 && s <= 70 ){ 184 | if ( lightOverride == 0 ){ 185 | lightOverride = 1; 186 | } else if ( lightOverride == 1 ){ 187 | lightOverride = 0; 188 | } 189 | if( lightStatus==0 && lightOverride == 1 ){ 190 | lightStatus = 1; 191 | colorWipe(strip.Color(0,255,0), 0); 192 | } else if ( lightStatus == 1 && lightOverride == 1 ){ 193 | lightStatus = 0; 194 | colorWipe(strip.Color(0,0,0), 0); 195 | } 196 | } 197 | delay(50); 198 | } 199 | 200 | /* TRAY BUTTON */ 201 | int t = analogRead(tButton); 202 | 203 | if ( t>5 && loginStatus == 1){ 204 | loginStatus = 0; 205 | Keyboard.press(KEY_LEFT_GUI); 206 | Keyboard.press('l'); 207 | Keyboard.releaseAll(); 208 | delay(300); 209 | } else if ( t<5 && loginStatus == 0){ 210 | loginStatus = 1; 211 | Keyboard.write(KEY_ESC); 212 | delay(2000); 213 | Keyboard.println("PASSWORD HERE"); 214 | delay(300); 215 | } 216 | 217 | /* Leds off */ 218 | if ( t>5 && lightOverride == 0 ){ 219 | lightStatus = 0; 220 | colorWipe(strip.Color(0,0,0), 0); 221 | } else if ( t<5 && lightStatus == 0 && lightOverride == 0 ){ 222 | lightStatus = 1; 223 | colorWipe(strip.Color(0,255,0), 5); 224 | } 225 | /* oled off */ 226 | if ( t>5 && oledDraw == 1 ){ 227 | antiBurn(); 228 | } else if ( t<5 && oledDraw == 0 && oledOverride == 0 ){ 229 | oledDrawBackground(); 230 | } 231 | 232 | } 233 | void writeCommand(String printCommand){ 234 | display.setTextSize(3); 235 | display.clearDisplay(); 236 | display.setCursor(0,0); 237 | display.println(printCommand); 238 | display.display(); 239 | } 240 | void antiBurn(){ 241 | display.invertDisplay(0); 242 | display.fillRect(0, 0, 128, 64, BLACK); 243 | display.display(); 244 | oledDraw = 0; 245 | } 246 | void clearMedia(){ 247 | display.fillRect(94, 0, 34, 36, BLACK); 248 | display.display(); 249 | } 250 | void oledDrawBackground(){ 251 | display.setCursor(0,0); 252 | display.println("CPU:"); 253 | display.setCursor(0,10); 254 | display.println("GPU:"); 255 | display.setCursor(0,20); 256 | display.println("RAM:"); 257 | display.setCursor(0,30); 258 | //display.println("NET:"); 259 | display.drawFastVLine(90, 0, 40, WHITE); 260 | display.drawFastHLine(0, 40, 128, WHITE); 261 | display.display(); 262 | oledDraw = 1; 263 | } 264 | void inverter(){ 265 | if ( invertedStatus == 1 ){ 266 | invertedStatus = 0; 267 | } else { 268 | invertedStatus = 1; 269 | }; 270 | display.invertDisplay(invertedStatus); 271 | display.display(); 272 | } 273 | void serialEvent() { 274 | while (Serial.available()) { 275 | char inChar = (char)Serial.read(); 276 | inputString += inChar; 277 | if (inChar == '|') { 278 | stringComplete = true; 279 | } 280 | } 281 | } 282 | 283 | 284 | 285 | // Fill the dots one after the other with a color 286 | void colorWipe(uint32_t c, uint8_t wait) { 287 | for(uint16_t i=0; i