You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
2.9 KiB
Arduino

5 years ago
/*
HiFiLOGIX 0.1.4
5 years ago
dewdude@gmail.com - 04-JAN-2020
5 years ago
*/
#include <Wire.h>
#include <U8g2lib.h>
#include <IRremote.h>
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0);
5 years ago
// const char *inputs[] = {"TAPE-2","TAPE-1","AUX","TUNER","PHONO-2","PHONO-1"};
// int i = 0;
5 years ago
int latchPin = 11;
int clockPin = 9;
int dataPin = 12;
int IRin = 7;
int srEnable = 5;
5 years ago
int matrix = A0;
byte out = 0;
int mx = 0;
IRrecv remote(IRin);
decode_results ircode;
void logo() {
u8g2.clearBuffer();
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.setFont(u8g2_font_logisoso28_tr);
}
/* void inputdisp() {
u8g2.clearBuffer();
u8g2.drawStr(x,30,inputs[i]);
u8g2.sendBuffer();
}
*/
5 years ago
void updateShiftRegister()
{
digitalWrite(latchPin, LOW);
5 years ago
shiftOut(dataPin, clockPin, LSBFIRST, out);
digitalWrite(latchPin, HIGH);
}
void DontCrossTheStreams()
5 years ago
{
out = 0;
updateShiftRegister();
// Don't cross the streams!
}
void setTape2()
{
DontCrossTheStreams();
bitSet(out,6);
5 years ago
updateShiftRegister();
u8g2.clearBuffer();
u8g2.drawStr(10,30,"TAPE-2");
u8g2.sendBuffer();
5 years ago
}
5 years ago
void setTape1()
{
DontCrossTheStreams();
bitSet(out,5);
5 years ago
updateShiftRegister();
u8g2.clearBuffer();
u8g2.drawStr(10,30,"TAPE-1");
u8g2.sendBuffer();
5 years ago
}
5 years ago
void setAUX()
{
DontCrossTheStreams();
bitSet(out,4);
5 years ago
updateShiftRegister();
u8g2.clearBuffer();
u8g2.drawStr(32,30,"AUX");
u8g2.sendBuffer();
5 years ago
}
5 years ago
void setTune()
{
DontCrossTheStreams();
bitSet(out,3);
5 years ago
updateShiftRegister();
u8g2.clearBuffer();
u8g2.drawStr(18,30,"TUNER");
u8g2.sendBuffer();
5 years ago
}
5 years ago
void setPh1()
{
DontCrossTheStreams();
bitSet(out,2);
bitSet(out,1);
5 years ago
updateShiftRegister();
u8g2.clearBuffer();
u8g2.drawStr(1,30,"PHONO-2");
u8g2.sendBuffer();
5 years ago
}
void setPh2()
{
DontCrossTheStreams();
bitSet(out,2);
bitSet(out,0);
updateShiftRegister();
u8g2.clearBuffer();
u8g2.drawStr(1,30,"PHONO-1");
u8g2.sendBuffer();
}
5 years ago
void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(srEnable, OUTPUT);
u8g2.begin();
remote.enableIRIn();
logo();
delay(2000);
setAUX();
digitalWrite(srEnable,LOW);
5 years ago
}
void loop() {
5 years ago
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 (remote.decode(&ircode)) {
switch(ircode.value){
case 0xFF6897:
setTape2();
break;
case 0xFF9867:
setTape1();
break;
case 0xFFB04F:
setAUX();
break;
case 0xFF30CF:
setTune();
break;
case 0xFF18E7:
setPh1();
break;
case 0xFF7A85:
setPh2();
break;
}
remote.resume();
}
5 years ago
delay(200);
}