71 lines
1.2 KiB
C++
71 lines
1.2 KiB
C++
![]() |
#include <RCSwitch.h>
|
||
|
#include <Adafruit_GFX.h>
|
||
|
#include <Adafruit_TFTLCD.h>
|
||
|
|
||
|
#define BLACK 0x0000
|
||
|
#define WHITE 0xFFFF
|
||
|
|
||
|
#define LCD_CS A3
|
||
|
#define LCD_CD A2
|
||
|
#define LCD_WR A1
|
||
|
#define LCD_RD A0
|
||
|
#define LCD_RESET A4
|
||
|
|
||
|
RCSwitch mySwitch = RCSwitch();
|
||
|
|
||
|
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
|
||
|
|
||
|
|
||
|
uint8_t lines = 0;
|
||
|
|
||
|
void clearScreen() {
|
||
|
if (lines >= 15) {
|
||
|
tft.fillScreen(BLACK);
|
||
|
tft.setCursor(0, 0);
|
||
|
lines = 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void setup() {
|
||
|
Serial.begin(9600);
|
||
|
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
|
||
|
|
||
|
|
||
|
pinMode(5, OUTPUT);
|
||
|
digitalWrite(5, HIGH);
|
||
|
|
||
|
tft.begin();
|
||
|
tft.setRotation(1);
|
||
|
tft.setTextSize(2);
|
||
|
tft.fillScreen(BLACK);
|
||
|
|
||
|
clearScreen();
|
||
|
tft.println("Hello");
|
||
|
lines++;
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
if (mySwitch.available()) {
|
||
|
|
||
|
int value = mySwitch.getReceivedValue();
|
||
|
|
||
|
if (value == 0) {
|
||
|
clearScreen();
|
||
|
tft.println("Unknown encoding");
|
||
|
lines++;
|
||
|
} else {
|
||
|
clearScreen();
|
||
|
tft.print("Recv ");
|
||
|
tft.print( mySwitch.getReceivedValue() );
|
||
|
tft.print(" / ");
|
||
|
tft.print( mySwitch.getReceivedBitlength() );
|
||
|
tft.print(" ");
|
||
|
tft.print("Prot: ");
|
||
|
tft.println( mySwitch.getReceivedProtocol() );
|
||
|
lines++;
|
||
|
}
|
||
|
|
||
|
mySwitch.resetAvailable();
|
||
|
}
|
||
|
}
|