From d115bee8e30481ae4c86ede2717694ffbefefa36 Mon Sep 17 00:00:00 2001 From: dewdude Date: Sun, 5 Jan 2020 13:19:32 -0500 Subject: [PATCH] 0.1.6 'rewrite' --- CHANGELOG | 5 +++ README.md | 1 + hifilogix.ino | 121 ++++++++++++-------------------------------------- 3 files changed, 35 insertions(+), 92 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0e39798..36dc1b4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ CHANGELOG: +Version 0.1.6: + + Software: + Removed a bunch of functions in favor of passing arguments to function. + Version 0.1.5: Hardware diff --git a/README.md b/README.md index 857d3b2..a64a7af 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Arduino Control for Your Vintage Stereo 01-Jan-2020: Added license, media, and proper README. 04-Jan-2020: Version 0.1.4 - Changed project name. Removed 1602 display code. Added 128x32 OLED code 05-Jan-2020: Version 0.1.5 - Fixed stupid mistake in hardware. Flipped logic of srEnable for new circuit. +05-Jan-2020: Version 0.1.6 - Lots of code clean-up, condensing, rewriting. ```` diff --git a/hifilogix.ino b/hifilogix.ino index 8b3cd35..5ff28f9 100644 --- a/hifilogix.ino +++ b/hifilogix.ino @@ -1,5 +1,5 @@ /* - HiFiLOGIX 0.1.5 + HiFiLOGIX 0.1.6 dewdude@gmail.com - 05-JAN-2020 @@ -10,9 +10,8 @@ U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0); -// const char *inputs[] = {"TAPE-2","TAPE-1","AUX","TUNER","PHONO-2","PHONO-1"}; -// int i = 0; + int latchPin = 11; int clockPin = 9; int dataPin = 12; @@ -26,20 +25,15 @@ decode_results ircode; void logo() { u8g2.clearBuffer(); - u8g2.setFont(u8g2_font_fewture_tr); - u8g2.drawStr(15,14,"HiFiLOGIX"); + u8g2.setFont(u8g2_font_fewture_tr); + u8g2.drawStr(15,14,"HiFiLOGIX"); u8g2.setFont(u8g2_font_freedoomr10_tu); - u8g2.drawStr(14,30,"DENON PMA-770"); - u8g2.sendBuffer(); + u8g2.drawStr(14,30,"DENON PMA-770"); + u8g2.sendBuffer(); u8g2.setFont(u8g2_font_logisoso28_tr); } - -/* void inputdisp() { - u8g2.clearBuffer(); - u8g2.drawStr(x,30,inputs[i]); - u8g2.sendBuffer(); - } -*/ + + void updateShiftRegister() { digitalWrite(latchPin, LOW); @@ -47,75 +41,18 @@ void updateShiftRegister() digitalWrite(latchPin, HIGH); } -void DontCrossTheStreams() +void DontCrossTheStreams(byte op, int x, const char* i) // Oh yeah, this much nicer than 8 seperate functions. { out = 0; updateShiftRegister(); + out = op; // No more bitset. This works better. + updateShiftRegister(); + u8g2.clearBuffer(); + u8g2.drawStr(x,30,i); + u8g2.sendBuffer(); // Don't cross the streams! } -void setTape2() -{ - DontCrossTheStreams(); - bitSet(out,6); - updateShiftRegister(); - u8g2.clearBuffer(); - u8g2.drawStr(10,30,"TAPE-2"); - u8g2.sendBuffer(); -} - -void setTape1() -{ - DontCrossTheStreams(); - bitSet(out,5); - updateShiftRegister(); - u8g2.clearBuffer(); - u8g2.drawStr(10,30,"TAPE-1"); - u8g2.sendBuffer(); -} - -void setAUX() -{ - DontCrossTheStreams(); - bitSet(out,4); - updateShiftRegister(); - u8g2.clearBuffer(); - u8g2.drawStr(32,30,"AUX"); - u8g2.sendBuffer(); -} - -void setTune() -{ - DontCrossTheStreams(); - bitSet(out,3); - updateShiftRegister(); - u8g2.clearBuffer(); - u8g2.drawStr(18,30,"TUNER"); - u8g2.sendBuffer(); -} - -void setPh1() -{ - DontCrossTheStreams(); - bitSet(out,2); - bitSet(out,1); - updateShiftRegister(); - u8g2.clearBuffer(); - u8g2.drawStr(1,30,"PHONO-2"); - u8g2.sendBuffer(); -} - -void setPh2() -{ - DontCrossTheStreams(); - bitSet(out,2); - bitSet(out,0); - updateShiftRegister(); - u8g2.clearBuffer(); - u8g2.drawStr(1,30,"PHONO-1"); - u8g2.sendBuffer(); -} - void setup() { pinMode(latchPin, OUTPUT); @@ -124,39 +61,39 @@ void setup() pinMode(srEnable, OUTPUT); u8g2.begin(); remote.enableIRIn(); - logo(); - delay(2000); - setAUX(); - digitalWrite(srEnable,HIGH); + logo(); // It's so pretty! + delay(2000); // It takes the Denon about 4.5 seconds to kick speakers on. + DontCrossTheStreams(16,32,"AUX"); // Someday this will not be static. + digitalWrite(srEnable,HIGH); // Now drives a logic inverter. } void loop() { int mx = analogRead(matrix); - if (mx > 100 && mx < 200) setTape2(); - if (mx > 500 && mx < 600) setTape1(); - if (mx > 900 && mx < 950) setAUX(); - if (mx > 1000) setTune(); - if (mx > 820 && mx < 899) setPh1(); + if (mx > 100 && mx < 200) DontCrossTheStreams(64,10,"TAPE-2"); // Byte value for outputs, X offset for display, text to display + 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)) { switch(ircode.value){ case 0xFF6897: - setTape2(); + DontCrossTheStreams(64,10,"TAPE-2"); // Same thing except for remote input. break; case 0xFF9867: - setTape1(); + DontCrossTheStreams(32,10,"TAPE-1"); break; case 0xFFB04F: - setAUX(); + DontCrossTheStreams(16,32,"AUX"); break; case 0xFF30CF: - setTune(); + DontCrossTheStreams(8,18,"TUNER"); break; case 0xFF18E7: - setPh1(); + DontCrossTheStreams(6,1,"PHONO-2"); break; case 0xFF7A85: - setPh2(); + DontCrossTheStreams(5,1,"PHONO-1"); break; } remote.resume();