#include "WiFi.h"
#include "esp_now.h"
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const uint8_t kalp[] PROGMEM = {
// 'kalp', 35x35px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60,
0x01, 0xc0, 0x00, 0x03, 0xfc, 0x07, 0xf0, 0x00, 0x07, 0xff, 0x0f, 0xfc, 0x00, 0x0f, 0xff, 0x3f,
0xfe, 0x00, 0x0f, 0xff, 0xff, 0xfe, 0x00, 0x1f, 0xff, 0xff, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff,
0x00, 0x1f, 0xfb, 0xfb, 0xff, 0x00, 0x1f, 0xf3, 0xf9, 0xff, 0x00, 0x1f, 0xf3, 0xf9, 0xff, 0x00,
0x0f, 0xf1, 0xb1, 0xfe, 0x00, 0x0f, 0xf5, 0x94, 0xfe, 0x00, 0x07, 0xe5, 0x96, 0xfc, 0x00, 0x00,
0x0d, 0x86, 0x00, 0x00, 0x01, 0xfc, 0x2f, 0xf0, 0x00, 0x00, 0xfe, 0x7f, 0xe0, 0x00, 0x00, 0x7e,
0x7f, 0xc0, 0x00, 0x00, 0x3e, 0x7f, 0x80, 0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, 0x00, 0x0f, 0xfe,
0x00, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00,
0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
typedef struct struct_message {
int nabiz;
int spo;
int nabiziki;
int spoiki;
} struct_message;
struct_message myData;
void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
memcpy(&myData, incomingData, sizeof(myData));
//neopixelWrite(RGBLED, 100, 0, 0); // Burada neopixel kontrolü yapılıyor
display.clearDisplay();
//display.drawBitmap(50, 15, kalp, 35, 35, 1);
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(10, 10);
display.print(myData.nabiz);
display.setTextSize(2);
display.setCursor(10, 40);
display.print(myData.spo);
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(45, 10);
display.print(myData.nabiziki);
display.setTextSize(2);
display.setCursor(45, 40);
display.print(myData.spoiki);
display.display();
Serial.println("Nabiz2 ");
Serial.print(myData.nabiz);
Serial.print("spo2 ");
Serial.print(myData.spo);
Serial.print(" ");
Serial.print("Nabiz2 ");
Serial.print(myData.nabiziki);
Serial.print("spo2 ");
Serial.print(myData.spoiki);
}
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
WiFi.mode(WIFI_STA);
// OLED ekranı başlatma
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 ekranı başlatılamadı"));
for(;;);
}
if (esp_now_init() != ESP_OK) {
Serial.println("ESP-NOW başlatılamadı");
return;
}
esp_now_register_recv_cb(OnDataRecv);
}
void loop() {
// main loop kodu buraya gelebilir
}