|  |  | @ -1,17 +1,17 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | /*
 |  |  |  | /*
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   HiFiLOGIX 0.1.6 |  |  |  |   HiFiLOGIX 0.1.7 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   dewdude@gmail.com - 05-JAN-2020 |  |  |  |   dewdude@gmail.com - 06-JAN-2019 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |    |  |  |  |    | 
			
		
	
		
		
			
				
					
					|  |  |  |  */ |  |  |  |  */ | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <Wire.h> |  |  |  | #include <Wire.h> | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <U8g2lib.h> |  |  |  | #include <U8g2lib.h> | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <IRremote.h> |  |  |  | #include <IRremote.h> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | #include "logo.h" // XBMP data for logo. | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0);  |  |  |  | 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 latchPin = 11; | 
			
		
	
		
		
			
				
					
					|  |  |  | int clockPin = 9; |  |  |  | int clockPin = 9; | 
			
		
	
		
		
			
				
					
					|  |  |  | int dataPin = 12; |  |  |  | int dataPin = 12; | 
			
		
	
	
		
		
			
				
					|  |  | @ -19,19 +19,16 @@ int IRin = 7; | 
			
		
	
		
		
			
				
					
					|  |  |  | int srEnable = 5; |  |  |  | int srEnable = 5; | 
			
		
	
		
		
			
				
					
					|  |  |  | int matrix = A0; |  |  |  | int matrix = A0; | 
			
		
	
		
		
			
				
					
					|  |  |  | byte out = 0; |  |  |  | byte out = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  | int mx = 0; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | IRrecv remote(IRin); |  |  |  | IRrecv remote(IRin); | 
			
		
	
		
		
			
				
					
					|  |  |  | decode_results ircode; |  |  |  | decode_results ircode; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  void logo() { |  |  |  | void logo() // Logo is now bitmapped. Saves a good bit of space this way.
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   u8g2.clearBuffer(); |  |  |  | {  | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   u8g2.setFont(u8g2_font_fewture_tr);   |  |  |  |   u8g2.firstPage(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   u8g2.drawStr(15,14,"HiFiLOGIX");   |  |  |  |     do { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   u8g2.setFont(u8g2_font_freedoomr10_tu); |  |  |  |     u8g2.drawXBMP(14,4,hifilogix_width,hifilogix_height,hifilogix_bits); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   u8g2.drawStr(14,30,"DENON PMA-770");  |  |  |  |     } while ( u8g2.nextPage() ); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   u8g2.sendBuffer();          |  |  |  | } // I also borrowed this from an example. I'll figure out how it works later.
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   u8g2.setFont(u8g2_font_logisoso28_tr); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |  } |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void updateShiftRegister() |  |  |  | void updateShiftRegister() | 
			
		
	
	
		
		
			
				
					|  |  | @ -41,14 +38,14 @@ void updateShiftRegister() | 
			
		
	
		
		
			
				
					
					|  |  |  |    digitalWrite(latchPin, HIGH); |  |  |  |    digitalWrite(latchPin, HIGH); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void DontCrossTheStreams(byte op, int x, const char* i) // Oh yeah, this much nicer than 8 seperate functions.
 |  |  |  | void DontCrossTheStreams(byte op, int x, int i) // Oh yeah, this much nicer than 8 seperate functions.
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  |     out = 0; |  |  |  |     out = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |     updateShiftRegister(); |  |  |  |     updateShiftRegister(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     out = op; // No more bitset. This works better.
 |  |  |  |     out = op; // No more bitset. This works better.
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     updateShiftRegister(); |  |  |  |     updateShiftRegister(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     u8g2.clearBuffer(); |  |  |  |     u8g2.clearBuffer(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     u8g2.drawStr(x,30,i); |  |  |  |     u8g2.drawStr(x,30,inputs[i]); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     u8g2.sendBuffer(); |  |  |  |     u8g2.sendBuffer(); | 
			
		
	
		
		
			
				
					
					|  |  |  | // Don't cross the streams!
 |  |  |  | // Don't cross the streams!
 | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | @ -63,40 +60,25 @@ void setup() | 
			
		
	
		
		
			
				
					
					|  |  |  |   remote.enableIRIn(); |  |  |  |   remote.enableIRIn(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   logo(); // It's so pretty!
 |  |  |  |   logo(); // It's so pretty!
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   delay(2000); // It takes the Denon about 4.5 seconds to kick speakers on.
 |  |  |  |   delay(2000); // It takes the Denon about 4.5 seconds to kick speakers on.
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   DontCrossTheStreams(16,32,"AUX"); // Someday this will not be static.
 |  |  |  |   u8g2.setFont(u8g2_font_logisoso28_tr); // Moved here since logo is bitmap.
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   DontCrossTheStreams(16,32,2); // Someday this will not be static.
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   digitalWrite(srEnable,HIGH); // Now drives a logic inverter.
 |  |  |  |   digitalWrite(srEnable,HIGH); // Now drives a logic inverter.
 | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void loop() { |  |  |  | void loop() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | int mx = analogRead(matrix); |  |  |  | int mx = analogRead(matrix); | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (mx > 100 && mx < 200) DontCrossTheStreams(64,10,"TAPE-2"); // Byte value for outputs, X offset for display, text to display
 |  |  |  | byte icode = 0; // I changed how I handed the inputs.
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   if (mx > 500 && mx < 600) DontCrossTheStreams(32,10,"TAPE-1"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (mx > 900 && mx < 950) DontCrossTheStreams(16,32,"AUX"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (mx > 1000) DontCrossTheStreams(8,18,"TUNER"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (mx > 820 && mx < 899) DontCrossTheStreams(6,1,"PHONO-2"); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | if (remote.decode(&ircode)) { |  |  |  | if (remote.decode(&ircode)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     switch(ircode.value){ |  |  |  |     icode = ircode.value; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |       case 0xFF6897: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         DontCrossTheStreams(64,10,"TAPE-2"); // Same thing except for remote input.
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         break; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       case 0xFF9867: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         DontCrossTheStreams(32,10,"TAPE-1"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         break; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       case 0xFFB04F: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         DontCrossTheStreams(16,32,"AUX"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         break; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       case 0xFF30CF: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         DontCrossTheStreams(8,18,"TUNER"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         break; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       case 0xFF18E7: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         DontCrossTheStreams(6,1,"PHONO-2"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         break; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       case 0xFF7A85: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         DontCrossTheStreams(5,1,"PHONO-1"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         break; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     remote.resume();     |  |  |  |     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); |  |  |  | delay(200); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } |