Initial Commit

This commit is contained in:
Tyler Perkins 2022-03-29 19:26:41 -04:00
commit 9778291b3d
9 changed files with 5823 additions and 0 deletions

21
CODES.txt Normal file
View File

@ -0,0 +1,21 @@
CODES
====
The following are recoded codes for the Z606 sound system. It is using NEC
encoding
Button | Address | Command
-----------------------------
Power | 0x7484 | 0xFF
Mute | 0x7080 | 0xB9
2.1/5.1 | 0x7080 | 0xEC
VOL- | 0x7080 | 0xC8
CHANNEL | 0x7080 | 0xC1
VOL+ | 0x7080 | 0xC7
AUX | 0x7080 | 0xB4
BLE | 0x7080 | 0xBA
RCA | 0x7080 | 0xF9
BACK | 0x7080 | 0xAE
PLAY/P | 0x7282 | 0xA8
FORWARD | 0x7080 | 0xAF

21
README.md Normal file
View File

@ -0,0 +1,21 @@
Remote
======
This is a programable remote control that uses an ATMega328P and mechanical
switches to create a more pleasent remote control experience
Features/TODO
-------------
- Programmable controls
- Mechanical keys
- Several "virtual" remotes
Design
======
Pinout
------
The IR led attaches to Pin 13

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

1182
remote/LowPower.cpp Normal file

File diff suppressed because it is too large Load Diff

173
remote/LowPower.h Normal file
View File

@ -0,0 +1,173 @@
#ifndef LowPower_h
#define LowPower_h
#include "Arduino.h"
enum period_t
{
SLEEP_15MS,
SLEEP_30MS,
SLEEP_60MS,
SLEEP_120MS,
SLEEP_250MS,
SLEEP_500MS,
SLEEP_1S,
SLEEP_2S,
SLEEP_4S,
SLEEP_8S,
SLEEP_FOREVER
};
enum bod_t
{
BOD_OFF,
BOD_ON
};
enum adc_t
{
ADC_OFF,
ADC_ON
};
enum timer5_t
{
TIMER5_OFF,
TIMER5_ON
};
enum timer4_t
{
TIMER4_OFF,
TIMER4_ON
};
enum timer3_t
{
TIMER3_OFF,
TIMER3_ON
};
enum timer2_t
{
TIMER2_OFF,
TIMER2_ON
};
enum timer1_t
{
TIMER1_OFF,
TIMER1_ON
};
enum timer0_t
{
TIMER0_OFF,
TIMER0_ON
};
enum spi_t
{
SPI_OFF,
SPI_ON
};
enum usart0_t
{
USART0_OFF,
USART0_ON
};
enum usart1_t
{
USART1_OFF,
USART1_ON
};
enum usart2_t
{
USART2_OFF,
USART2_ON
};
enum usart3_t
{
USART3_OFF,
USART3_ON
};
enum twi_t
{
TWI_OFF,
TWI_ON
};
enum usb_t
{
USB_OFF,
USB_ON
};
enum idle_t
{
IDLE_0,
IDLE_1,
IDLE_2
};
class LowPowerClass
{
public:
#if defined (__AVR__)
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega88__)
void idle(period_t period, adc_t adc, timer2_t timer2,
timer1_t timer1, timer0_t timer0, spi_t spi,
usart0_t usart0, twi_t twi);
#elif defined __AVR_ATmega644P__ || defined (__AVR_ATmega1284P__)
void idle(period_t period, adc_t adc, timer2_t timer2,
timer1_t timer1, timer0_t timer0, spi_t spi,
usart1_t usart1, usart0_t usart0, twi_t twi);
#elif defined __AVR_ATmega2560__
void idle(period_t period, adc_t adc, timer5_t timer5,
timer4_t timer4, timer3_t timer3, timer2_t timer2,
timer1_t timer1, timer0_t timer0, spi_t spi,
usart3_t usart3, usart2_t usart2, usart1_t usart1,
usart0_t usart0, twi_t twi);
#elif defined __AVR_ATmega256RFR2__
void idle(period_t period, adc_t adc, timer5_t timer5,
timer4_t timer4, timer3_t timer3, timer2_t timer2,
timer1_t timer1, timer0_t timer0, spi_t spi,
usart1_t usart1,
usart0_t usart0, twi_t twi);
#elif defined __AVR_ATmega32U4__
void idle(period_t period, adc_t adc, timer4_t timer4,
timer3_t timer3, timer1_t timer1, timer0_t timer0,
spi_t spi, usart1_t usart1, twi_t twi, usb_t usb);
#else
#error "Please ensure chosen MCU is either 88, 168, 168P, 328P, 32U4, 2560 or 256RFR2."
#endif
void adcNoiseReduction(period_t period, adc_t adc, timer2_t timer2) __attribute__((optimize("-O1")));
void powerDown(period_t period, adc_t adc, bod_t bod) __attribute__((optimize("-O1")));
void powerSave(period_t period, adc_t adc, bod_t bod, timer2_t timer2) __attribute__((optimize("-O1")));
void powerStandby(period_t period, adc_t adc, bod_t bod) __attribute__((optimize("-O1")));
void powerExtStandby(period_t period, adc_t adc, bod_t bod, timer2_t timer2) __attribute__((optimize("-O1")));
#elif defined (__arm__)
#if defined (__SAMD21G18A__)
void idle(idle_t idleMode);
void standby();
#else
#error "Please ensure chosen MCU is ATSAMD21G18A."
#endif
#else
#error "Processor architecture is not supported."
#endif
};
extern LowPowerClass LowPower;
#endif

22
remote/Makefile Normal file
View File

@ -0,0 +1,22 @@
###############################################################################
# Tyler Perkins
# 27-3-22
# Arduino remote controller
#
# Target board and cpu
# Default Arduino pro mini@5V
FQBN = arduino:avr:pro
CPU = :cpu=16MHzatmega328
# Serial port for Programmer
PORT = /dev/ttyUSB0
# path to the ino file
TARGET = ./remote.ino
compile: $(TARGET)
arduino-cli compile -b $(FQBN)$(CPU) $(TARGET)
upload: compile
sudo arduino-cli upload -b $(FQBN) -p /dev/ttyUSB0 $(TARGET)

50
remote/remote.ino Normal file
View File

@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////
// Tyler Perkins
// 2-1-22
// Remote Entry point
//
#include <IRremote.h>
#include "LowPower.h"
// IR library
IRsend irsend;
void setup() {
//set input pins
//interrupt
pinMode(2, INPUT);
//buttons
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
//pinMode(13, OUTPUT);
//attachInterrupt(digitalPinToInterrupt(2),readInput, RISING);
irsend.begin(3, ENABLE_LED_FEEDBACK);
}
void loop() {
attachInterrupt(digitalPinToInterrupt(2),readInput, RISING);
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
detachInterrupt(digitalPinToInterrupt(2));
}
void readInput(){
if(digitalRead(10) == HIGH){
//vol +
irsend.sendNEC(0x7080, 0xC7, 1);
} else if(digitalRead(11) == HIGH){
//vol -
irsend.sendNEC(0x7080, 0xC8, 1);
} else if(digitalRead(9) == HIGH){
// 2.1/5.1
irsend.sendNEC(0x7080, 0xEC, 1);
}
delay(25);
}

File diff suppressed because it is too large Load Diff