#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <splash.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// 'Link-Off', 25x12px
const unsigned char epd_bitmap_Link_Off [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x3f, 0xe3, 0xfe, 0x00, 0x7f, 0xe3, 0xff, 0x00, 0xf8, 0x00, 0x0f, 0x80,
0xf0, 0x00, 0x07, 0x80, 0xe0, 0x00, 0x03, 0x80, 0xe0, 0x00, 0x03, 0x80, 0xf0, 0x00, 0x07, 0x80,
0xf8, 0x00, 0x0f, 0x80, 0x7f, 0xe3, 0xff, 0x00, 0x3f, 0xe3, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'Link-On', 25x12px
const unsigned char epd_bitmap_Link_On [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x3f, 0xe3, 0xfe, 0x00, 0x7f, 0xe3, 0xff, 0x00, 0xf8, 0x00, 0x0f, 0x80,
0xf0, 0x1c, 0x07, 0x80, 0xe1, 0xff, 0xc3, 0x80, 0xe1, 0xff, 0xc3, 0x80, 0xf0, 0x1c, 0x07, 0x80,
0xf8, 0x00, 0x0f, 0x80, 0x7f, 0xe3, 0xff, 0x00, 0x3f, 0xe3, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 128)
const int epd_bitmap_allArray_LEN = 2;
const unsigned char* epd_bitmap_allArray[2] = {
epd_bitmap_Link_Off,
epd_bitmap_Link_On
};
uint8_t ncanalRF[3] = {0x15, 0x33, 0x60};
void setup() {
// put your setup code here, to run once:
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 ha fallat"));
for(;;); // Es quedarà aquí per sempre, fins que funcioni
}
display.display();
delay(500);
display.setTextSize(1); // escala de texy 2X
display.setTextColor(SSD1306_WHITE);
display.clearDisplay();
display.drawPixel(10, 10, SSD1306_WHITE);
display.setCursor(20, 0);
display.println(F("Display OK !!"));
display.display();
}
bool RFconnectat = 0;
long temps = 0, tmpAct, tmpEspera = 1000;
String cap, inf1, inf2; // variables per rebre missatges
void loop() {
if(millis() > tmpAct + tmpEspera){
tmpAct = millis();
display.clearDisplay();
display.drawRoundRect(0,0,125,12,2,1);
display.setCursor(5, 3); // Per la y-> (128pix -(nºcaracter x 6))/2
char tt[5]; sprintf(tt,"%04ld RF: Ch:%X",temps,ncanalRF[1]);
display.println(tt);
(!RFconnectat) ? display.drawBitmap(52,0,epd_bitmap_Link_Off,25,12,1) :display.drawBitmap(52,0,epd_bitmap_Link_On,25,12,1);
display.display();
temps++;
}
}