/* HiFiLOGIX 0.1.8 dewdude@gmail.com - 08-JAN-2019 */ #include #include #include #include "logo.h" // XBMP data for logo. U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); const char *inputs[] = {"TAPE-2","TAPE-1","AUX","TUNER","PHONO-2","PHONO-1"}; int latchPin = 11; int clockPin = 9; int dataPin = 12; int IRin = 7; int blanking = 5; int matrix = A0; IRrecv remote(IRin); decode_results ircode; void DontCrossTheStreams(byte op, int x, int i) // There's something I forgot to tell you. {// Don't cross the streams. // It would be bad. digitalWrite(latchPin, LOW); // What do you mean, bad? shiftOut(dataPin, clockPin, LSBFIRST, op); // Imagine all life as you know it digitalWrite(latchPin, HIGH); // stopping instaneously and every u8g2.clearBuffer(); // molecule in your body exploding u8g2.drawStr(x,30,inputs[i]); // At the speed of light. u8g2.sendBuffer(); // Total protonic reversal. // That's bad. // Important safety tip, thanks Egon. } void setup() { pinMode(latchPin, OUTPUT); pinMode(dataPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(blanking, OUTPUT); u8g2.begin(); remote.enableIRIn(); u8g2.firstPage(); // Logo is now bitmapped and since I only call it do { // once, it doesn't need it's own function. u8g2.drawXBMP(14,4,hifilogix_width,hifilogix_height,hifilogix_bits); } while ( u8g2.nextPage() ); delay(2000); // It takes the Denon about 4.5 seconds to kick speakers on. u8g2.setFont(u8g2_font_logisoso28_tr); // Moved here since logo is bitmap. DontCrossTheStreams(16,32,2); // THIS IS NO LONGER STATIC IN THE BETA! (yay.) digitalWrite(blanking,HIGH); // Now drives a logic inverter. } void loop() { int mx = analogRead(matrix); byte icode = 0; // I changed how I handed the inputs. if (remote.decode(&ircode)) { icode = ircode.value; remote.resume(); } // I don't know if it improves things, but I sure like how much smaller this section is. if ((mx > 100 && mx < 200) || (icode == 0x97)) DontCrossTheStreams(64,10,0); // The code I originally used to figure out my if ((mx > 500 && mx < 600) || (icode == 0x67)) DontCrossTheStreams(32,10,1); // remote codes returned 3 bytes in hex. I can't if ((mx > 900 && mx < 950) || (icode == 0x4F)) DontCrossTheStreams(16,32,2); // remember what that code was, but I only need if ((mx > 1000) || (icode == 0xCF)) DontCrossTheStreams(8,18,3); // the last bit with the remote I'm using. if ((mx > 820 && mx < 899) || (icode == 0xE7)) DontCrossTheStreams(6,1,4); // I'm working on making the bare-bones utility I if ((mx > 700 && mx < 800) || (icode == 0x85)) DontCrossTheStreams(5,1,5); // wrote a bit more user-friendly. delay(200); }