//||||||||||||||| Starfinder |||||||||||||||
// Libraries
#include <SPI.h> // Serial Peripheral Interface. <<https://docs.arduino.cc/learn/communication/spi>>
#include <Wire.h> // Communication with I2C/TWI devices. <<https://www.arduino.cc/reference/en/language/functions/communication/wire/>>
#include <Adafruit_GFX.h> // Adafruit SPI TFT Displays. <<http://adafruit.github.io/Adafruit-GFX-Library/html/index.html>>
#include <Adafruit_SSD1306.h> // Arduino library for monochrome OLEDs based on SSD1306 drivers. <<https://adafruit.github.io/Adafruit_SSD1306/html/index.html>>
#include <IRremote.h> // This library enables you to send and receive using infra-red signals on an Arduino. <<https://arduino-irremote.github.io/Arduino-IRremote/index.html>>
// Definitions
#define SCREEN_WIDTH 128 // OLED display - width, in pixels
#define SCREEN_HEIGHT 64 // OLED display - height, in pixels
#define OLED_RESET -1 // OLED display - reset pin # (or -1 if sharing Arduino reset pin)
#define PIN_RECEIVER 2 // IR receiver - pin in use, where a demodulating IR receiver is connected.
// Declarations
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); // OLED display - constructor for I2C-interfaced SSD1306 displays.
IRrecv receiver(PIN_RECEIVER); // IR receiver - instantiate the IRrecv class.
decode_results button;
// Menu
#define n_menu 4 // Numero de menus
int menu_num = 1;
int menu_sub = 1;
void keyboard ();
void one_menu ();
void two_menu ();
void three_menu ();
void four_menu ();
// IR Remote control
byte zero = 0xFF6897;
byte one = 0xFF30CF;
byte two = 0xFF18E7;
byte three = 0xFF7A85;
byte four = 0xFF10EF;
byte five = 0xFF38C7;
byte six = 0xFF5AA5;
byte seven = 0xFF42BD;
byte eight = 0xFF4AB5;
byte nine = 0xFF52AD;
byte down = 0xFF9867 ;
byte up = 0xFF02FD;
byte left = 0xFFE01F;
byte right = 144;
byte enter = 0xFFA857;
byte asterisk = 0xFFC23D;
byte hash = 0xFF22DD;
void setup() {
Serial.begin(9600); // Serial - Sets the data rate in bits per second (baud) for serial data transmission.
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // OLED display - Allocate RAM for image buffer, initialize peripherals and pins.
display.clearDisplay(); // OLED display - Clear contents of display buffer (set all pixels to off).
receiver.enableIRIn(); // IR receiver - Alias for start().
}
void loop() {
keyboard ();
switch(menu_num){
case 1: one_menu();
break;
case 2: two_menu();
break;
case 3: three_menu();
break;
case 4: four_menu();
break;
}
}
void keyboard (){
if(( receiver.decode() == 0xFF906F ) && ( menu_sub == 1 )){
delay(150);
if( menu_num > 0 ) menu_num += 1 ;
}
if(( receiver.decode() == left ) && ( menu_sub == 1 )){
delay(150);
if( menu_num <= n_menu ) menu_num -= 1 ;
}
if(( receiver.decode() ) == enter ){
delay(150);
if( menu_num <= 2 ) menu_sub += 1 ;
}
if(( receiver.decode() ) == asterisk ){
delay(150);
if( menu_num > 0 ) menu_num -= 1 ;
}
}
void one_menu (){
switch (menu_sub){
case 1:
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("menu 1 \n");
display.print("sub menu 1 \n");
display.display();
break;
case 2:
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("menu 1 \n");
display.print("sub menu 2 \n");
display.display();
break;
}
}
void two_menu (){
switch (menu_sub){
case 1:
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("menu 2 \n");
display.print("sub menu 1 \n");
display.display();
break;
case 2:
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("menu 2 \n");
display.print("sub menu 2 \n");
display.display();
break;
}
}
void three_menu (){
switch (menu_sub){
case 1:
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("menu 3 \n");
display.print("sub menu 1 \n");
display.display();
break;
case 2:
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("menu 3 \n");
display.print("sub menu 2 \n");
display.display();
break;
}
}
void four_menu (){
switch (menu_sub){
case 1:
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("menu 4 \n");
display.print("sub menu 1 \n");
display.display();
break;
case 2:
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("menu 4 \n");
display.print("sub menu 2 \n");
display.display();
break;
}
}
/*||||||||||||||| Comments |||||||||||||||
Display ratio (7:5) (26.6 mm : 19 mm) (128px : 64px)0.96 inch
Logo font <<https://www.dafont.com/pt/star-jedi.font>>
if(receiver.decode(&button)){
Serial.print("valor: ");
Serial.println(button.value,HEX);
switch(){
case 0xFF6897: // "0"
break;
case 0xFF30CF: // "1"
break;
case 0xFF18E7: // "2"
break;
case 0xFF7A85: // "3"
break;
case 0xFF10EF: // "4"
break;
case 0xFF38C7: // "5"
break;
case 0xFF5AA5: // "6"
break;
case 0xFF42BD: // "7"
break;
case 0xFF4AB5: // "8"
break;
case 0xFF52AD: // "9"
break;
case 0xFF9867: // "Down"
break;
case 0xFF02FD: // "Up"
break;
case 0xFFE01F: // "Left"
break;
case 0xFF906F: // "Right"
break;
case 0xFFA857: // "Enter"
break;
case 0xFF22DD: // "*"
break;
case 0xFFB04F: // "#"
break;
}
receiver.resume();
}
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("Ola makers! \n");
display.display();
*/