// //How to draw points and figures on an OLED Screen.
// //First include this libs
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "PinDefinitionsAndMore.h"
#include <IRremote.hpp> // include the library
// Define the params of the OLED
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define RESET_Pin -1
//# define Remote_Pin 13
#define LED 14
Adafruit_SSD1306 OLED(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, RESET_Pin); //Attach the OLED
//IRrecv remote(Remote_Pin); // Attach the remote
decode_results results; // Store the decoded data in the variable called results
void setup() {
// put your setup code here, to run once:
// We setup the OLED
Serial.begin(115200);
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // Start the receiver
//remote.enableIRIn(); // enable the remote
OLED.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Set the address of the OLED at 0x3C
OLED.clearDisplay(); // Clear everything before the code
pinMode(LED, OUTPUT);
// oled.begin(128, 64, sizeof(tiny4koled_init_128x64br), tiny4koled_init_128x64br);
OLED.clearDisplay();
OLED.setTextSize(2);
OLED.setTextColor(WHITE);
OLED.setCursor(15, 10);
// Display static text
OLED.println("Welcome!");
OLED.display();
}
void loop() {
// put your main code here, to run repeatedly:
if (IrReceiver.decode()) {
if((IrReceiver.decodedIRData.decodedRawData, HEX)==0x5DA2FF00){
OLED.display();
OLED.clearDisplay();
Serial.println(results.value);
}
if((IrReceiver.decodedIRData.decodedRawData)==0x1DE2FF00){
digitalWrite(LED, HIGH);
// Draw a single white pixel at (x, y)
int x =64; int y = 32;
OLED.clearDisplay();
OLED.drawPixel(x, y, WHITE);
OLED.display();
}
if((IrReceiver.decodedIRData.decodedRawData)==0x9768FF00){
digitalWrite(LED, HIGH);
// Draw a single white Line at (x1, y1) and (x2, y2)
int x1 =0; int y1 = 50; int x2 =100; int y2 =1;
OLED.clearDisplay();
OLED.drawLine(x1, y1, x2, y2, WHITE);
OLED.display();
}
// Draw rectangle
if((IrReceiver.decodedIRData.decodedRawData)==0xCF30FF00){
OLED.clearDisplay();
OLED.drawRect(20, 20, 40, 20, WHITE);
OLED.display();
}
// Draw fillrectangle
if((IrReceiver.decodedIRData.decodedRawData)==0xE718FF00){
OLED.clearDisplay();
OLED.fillRect(20, 20, 40, 20, WHITE);
OLED.display();
}
// Draw roundrectangle
if((IrReceiver.decodedIRData.decodedRawData)==0x857AFF00){
OLED.clearDisplay();
OLED.drawRoundRect(20, 20, 40, 20, 5, WHITE);
OLED.display();
}
if((IrReceiver.decodedIRData.decodedRawData)==0xEF10FF00){
OLED.clearDisplay();
OLED.fillRoundRect(20, 20, 50, 20, 5, WHITE);
OLED.display();
}
if((IrReceiver.decodedIRData.decodedRawData)==0xC738FF00){
OLED.clearDisplay();
OLED.drawCircle(64, 32, 20, WHITE);
OLED.display();
}
if((IrReceiver.decodedIRData.decodedRawData)==0xA55AFF00){
OLED.clearDisplay();
OLED.fillCircle(64, 32, 20, WHITE);
OLED.display();
}
if((IrReceiver.decodedIRData.decodedRawData)==0xBD42FF00){
OLED.clearDisplay();
OLED.drawTriangle(64, 10, 30, 40, 100, 40, WHITE);
OLED.display();
}
if((IrReceiver.decodedIRData.decodedRawData)==0xB54AFF00){
OLED.clearDisplay();
OLED.fillTriangle(64, 20, 30, 50, 100, 50, WHITE);
OLED.display();
}
if((IrReceiver.decodedIRData.decodedRawData)==0x5DA2FF00){ // - button to turn OFF the LED
digitalWrite(LED, LOW);
}
IrReceiver.resume(); // Enable receiving of the next value
}
}
// // Menu 0x1DE2FF00
// //0 0x9768FF00
// // 1 0xCF30FF00
// // 2 0xE718FF00
// // \3 0x857AFF00
// //4 0xEF10FF00
// /// 5 0xC738FF00
// /// 6 0xA55AFF00
// // 7 > 0xBD42FF00
// // 8 > 0xB54AFF00
// // 9 > 0xAD52FF00
// // Previous > 0x1FE0FF00
// // Next > 0x6F90FF00
// // Play > 0x57A8FF00
// power : 0x5DA2FF00
// Test : 0xDD22FF00
// Plus + : 0xFD02FF00
// Return : 0x3DC2FF00
//Netx: 0x6F90FF00
// Minus : 0x6798FF00
// C : 0x4FB0FF00
// /*
// // The Foward Button
// if(results.value==0X23FCB924){
// for(int i =0; i<10; i++){
// if(digitalRead( Relay_Pin[i])==0){
// digitalWrite( Relay_Pin[i+1], HIGH);
// OLED.clearDisplay();
// OLED.setTextSize(2);
// OLED.setTextColor(WHITE);
// OLED.setCursor(15, 15);
// OLED.println("All ON!");
// OLED.display();
// }
// else if(digitalRead( Relay_Pin[i])==1){
// digitalWrite( Relay_Pin[i+1], LOW);
// OLED.clearDisplay();
// OLED.setTextSize(2);
// OLED.setTextColor(WHITE);
// OLED.setCursor(15, 15);
// OLED.println("All OFF!");
// OLED.display();
// }
// }
// }
// */
// // Backwrd button
// /* if(results.value==0X710E7FC0){
// for(int i =0; i<10; i++){
// if(digitalRead( Relay_Pin[i])==0){
// digitalWrite( Relay_Pin[i-1], HIGH);
// OLED.clearDisplay();
// OLED.setTextSize(2);
// OLED.setTextColor(WHITE);
// OLED.setCursor(15, 15);
// OLED.println("All ON!");
// OLED.display();
// }
// else if(digitalRead( Relay_Pin[i])==1){
// digitalWrite( Relay_Pin[i-1], LOW);
// OLED.clearDisplay();
// OLED.setTextSize(2);
// OLED.setTextColor(WHITE);
// OLED.setCursor(15, 15);
// OLED.println("All OFF!");
// OLED.display();
// }
// }
// }
// */
// }
/*
* SimpleReceiver.cpp
*
* Demonstrates receiving NEC IR codes with IRremote
*
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
*
************************************************************************************
* MIT License
*
* Copyright (c) 2020-2023 Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
************************************************************************************
*/
/*
* Specify which protocol(s) should be used for decoding.
* If no protocol is defined, all protocols (except Bang&Olufsen) are active.
* This must be done before the #include <IRremote.hpp>
*/
//#define DECODE_DENON // Includes Sharp
//#define DECODE_JVC
//#define DECODE_KASEIKYO
//#define DECODE_PANASONIC // alias for DECODE_KASEIKYO
//#define DECODE_LG
//#define DECODE_NEC // Includes Apple and Onkyo
//#define DECODE_SAMSUNG
//#define DECODE_SONY
//#define DECODE_RC5
//#define DECODE_RC6
//#define DECODE_BOSEWAVE
//#define DECODE_LEGO_PF
//#define DECODE_MAGIQUEST
//#define DECODE_WHYNTER
//#define DECODE_FAST
//#define DECODE_DISTANCE_WIDTH // Universal decoder for pulse distance width protocols
//#define DECODE_HASH // special decoder for all protocols
//#define DECODE_BEO // This protocol must always be enabled manually, i.e. it is NOT enabled if no protocol is defined. It prevents decoding of SONY!
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
//#define RAW_BUFFER_LENGTH 180 // Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
// #include <Arduino.h>
// /*
// * This include defines the actual pin number for pins like IR_RECEIVE_PIN, IR_SEND_PIN for many different boards and architectures
// */
// void setup() {
// Serial.begin(115200);
// // Just to know which program is running on my Arduino
// Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
// // Start the receiver and if not 3. parameter specified, take LED_BUILTIN pin from the internal boards definition as default feedback LED
// Serial.print(F("Ready to receive IR signals of protocols: "));
// printActiveIRProtocols(&Serial);
// Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
// }
// void loop() {
// /*
// * Check if received data is available and if yes, try to decode it.
// * Decoded result is in the IrReceiver.decodedIRData structure.
// *
// * E.g. command is in IrReceiver.decodedIRData.command
// * address is in command is in IrReceiver.decodedIRData.address
// * and up to 32 bit raw data in IrReceiver.decodedIRData.decodedRawData
// */
// if (IrReceiver.decode()) {
// /*
// * Print a short summary of received data
// */
// IrReceiver.printIRResultShort(&Serial);
// IrReceiver.printIRSendUsage(&Serial);
// if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
// Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
// // We have an unknown protocol here, print more info
// IrReceiver.printIRResultRawFormatted(&Serial, true);
// }
// Serial.println();
// /*
// * !!!Important!!! Enable receiving of the next value,
// * since receiving has stopped after the end of the current received data packet.
// */
// IrReceiver.resume(); // Enable receiving of the next value
// /*
// * Finally, check the received data and perform actions according to the received command
// */
// if (IrReceiver.decodedIRData.command == 0x10) {
// // do something
// } else if (IrReceiver.decodedIRData.command == 0x11) {
// // do something else
// }
// }
// }