"Const unsigned char" Problem

I get error. I want to make that showing logo and their value for every crypto. Please help me.

/*******************************************************************
    A project to display crypto currency prices using an ESP8266

    Main Hardware:
    - NodeMCU Development Board (Any ESP8266 dev board will work)
    - OLED I2C Display (SH1106)

    Written by Brian Lough
    https://www.youtube.com/channel/UCezJOfu7OtqGzd5xrP3q6WA
 *******************************************************************/

// ----------------------------
// Standard Libraries - Already Installed if you have ESP8266 set up
// ----------------------------

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <Wire.h>

// ----------------------------
// Additional Libraries - each one of these will need to be installed.
// ----------------------------

#include <CoinMarketCapApi.h>
// For Integrating with the CoinMarketCap.com API
// Available on the library manager (Search for "CoinMarket")
// https://github.com/witnessmenow/arduino-coinmarketcap-api

#include "SH1106.h"
// The driver for the OLED display
// Available on the library manager (Search for "oled ssd1306")
// https://github.com/squix78/esp8266-oled-ssd1306

#include <ArduinoJson.h>
// !! NOTE !!: When installing this select an older version than V6 from the drop down
// Required by the CoinMarketCapApi Library for parsing the response
// Available on the library manager (Search for "arduino json")
// https://github.com/squix78/esp8266-oled-ssd1306


// ----------------------------
// Configurations - Update these
// ----------------------------

char ssid[] = "WiFiNetworkName";       // your network SSID (name)
char password[] = "password";  // your network key

// Pins based on your wiring
#define SCL_PIN D5
#define SDA_PIN D3
#define upLED 13
#define downLED 12
#define LOGO_GENISLIK 48
#define LOGO_YUKSEKLIK 48
// CoinMarketCap's limit is "no more than 10 per minute"
// Make sure to factor in if you are requesting more than one coin.
// We'll request a new value just before we change the screen so it's the most up to date
unsigned long screenChangeDelay = 10000; // Every 10 seconds

// Have tested up to 10, can probably do more
#define MAX_HOLDINGS 10

#define CURRENCY "eur" //See CoinMarketCap.com for currency options (usd, gbp etc)
#define CURRENCY_SYMBOL "E" // Euro doesn't seem to work, $ and £ do

// You also need to add your crypto currecnies in the setup function

// ----------------------------
// End of area you need to change
// ----------------------------


WiFiClientSecure client;
CoinMarketCapApi api(client);

SH1106 display(0x3c, SDA_PIN, SCL_PIN);

unsigned long screenChangeDue;

struct Holding {
  String tickerId;
  float amount;
  bool inUse;
const unsigned char logo [288];
  CMCTickerResponse lastResponse;
};

Holding holdings[MAX_HOLDINGS];

int currentIndex = -1;
String ipAddressString;

void addNewHolding(String tickerId, const unsigned char logo [288], float amount = 0) {
  int index = getNextFreeHoldingIndex();
  if (index > -1) {
    holdings[index].tickerId = tickerId;
    holdings[index].amount = amount;
    holdings[index].inUse = true;
    holdings[index].logo = logo;
  }
}

void setup() {

  Serial.begin(115200);
  pinMode(upLED, OUTPUT);                                                     //Define the LED pin outputs
  pinMode(downLED, OUTPUT);
  // ----------------------------
  // Holdings - Add your currencies here
  // ----------------------------
  // Go to the currencies coinmarketcap.com page
  // and take the tickerId from the URL (use bitcoin or ethereum as an example)
  
  addNewHolding("bitcoin",  { 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff,
      0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x7f,
      0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80,
      0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xfe, 0x3f, 0xff, 0xe0, 0x0f, 0xff, 0xfe, 0x73,
      0xff, 0xf0, 0x0f, 0xff, 0xfc, 0x63, 0xff, 0xf0, 0x1f, 0xff, 0x0c, 0x63, 0xff, 0xf8, 0x1f, 0xff,
      0x00, 0x63, 0xff, 0xfc, 0x3f, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x3f, 0xff, 0xe0, 0x01, 0xff, 0xfc,
      0x7f, 0xff, 0xe0, 0x80, 0x7f, 0xfe, 0x7f, 0xff, 0xe0, 0xf0, 0x3f, 0xfe, 0x7f, 0xff, 0xe1, 0xf8,
      0x3f, 0xfe, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff,
      0xc1, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x7f, 0xff,
      0xff, 0xff, 0x82, 0x00, 0xff, 0xff, 0xff, 0xff, 0x83, 0xc0, 0x7f, 0xff, 0xff, 0xff, 0x87, 0xf0,
      0x3f, 0xff, 0xff, 0xff, 0x07, 0xf8, 0x3f, 0xff, 0xff, 0xfb, 0x07, 0xf8, 0x3f, 0xff, 0x7f, 0xf8,
      0x07, 0xf0, 0x3f, 0xfe, 0x7f, 0xf0, 0x03, 0xf0, 0x3f, 0xfe, 0x7f, 0xf8, 0x00, 0x00, 0x7f, 0xfe,
      0x3f, 0xff, 0x80, 0x00, 0x7f, 0xfc, 0x3f, 0xff, 0x88, 0x00, 0xff, 0xfc, 0x3f, 0xff, 0x9c, 0x43,
      0xff, 0xfc, 0x1f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff,
      0xf8, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xfd, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0,
      0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff,
      0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x07,
      0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00
    });
  addNewHolding("dogecoin",  { 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff,
      0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x7f,
      0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80,
      0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xfe, 0x3f, 0xff, 0xe0, 0x0f, 0xff, 0xfe, 0x73,
      0xff, 0xf0, 0x0f, 0xff, 0xfc, 0x63, 0xff, 0xf0, 0x1f, 0xff, 0x0c, 0x63, 0xff, 0xf8, 0x1f, 0xff,
      0x00, 0x63, 0xff, 0xfc, 0x3f, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x3f, 0xff, 0xe0, 0x01, 0xff, 0xfc,
      0x7f, 0xff, 0xe0, 0x80, 0x7f, 0xfe, 0x7f, 0xff, 0xe0, 0xf0, 0x3f, 0xfe, 0x7f, 0xff, 0xe1, 0xf8,
      0x3f, 0xfe, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff,
      0xc1, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x7f, 0xff,
      0xff, 0xff, 0x82, 0x00, 0xff, 0xff, 0xff, 0xff, 0x83, 0xc0, 0x7f, 0xff, 0xff, 0xff, 0x87, 0xf0,
      0x3f, 0xff, 0xff, 0xff, 0x07, 0xf8, 0x3f, 0xff, 0xff, 0xfb, 0x07, 0xf8, 0x3f, 0xff, 0x7f, 0xf8,
      0x07, 0xf0, 0x3f, 0xfe, 0x7f, 0xf0, 0x03, 0xf0, 0x3f, 0xfe, 0x7f, 0xf8, 0x00, 0x00, 0x7f, 0xfe,
      0x3f, 0xff, 0x80, 0x00, 0x7f, 0xfc, 0x3f, 0xff, 0x88, 0x00, 0xff, 0xfc, 0x3f, 0xff, 0x9c, 0x43,
      0xff, 0xfc, 0x1f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff,
      0xf8, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xfd, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0,
      0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff,
      0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x07,
      0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00
    });
  addNewHolding("ethereum",  { 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff,
      0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x7f,
      0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80,
      0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xfe, 0x3f, 0xff, 0xe0, 0x0f, 0xff, 0xfe, 0x73,
      0xff, 0xf0, 0x0f, 0xff, 0xfc, 0x63, 0xff, 0xf0, 0x1f, 0xff, 0x0c, 0x63, 0xff, 0xf8, 0x1f, 0xff,
      0x00, 0x63, 0xff, 0xfc, 0x3f, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x3f, 0xff, 0xe0, 0x01, 0xff, 0xfc,
      0x7f, 0xff, 0xe0, 0x80, 0x7f, 0xfe, 0x7f, 0xff, 0xe0, 0xf0, 0x3f, 0xfe, 0x7f, 0xff, 0xe1, 0xf8,
      0x3f, 0xfe, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff,
      0xc1, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x7f, 0xff,
      0xff, 0xff, 0x82, 0x00, 0xff, 0xff, 0xff, 0xff, 0x83, 0xc0, 0x7f, 0xff, 0xff, 0xff, 0x87, 0xf0,
      0x3f, 0xff, 0xff, 0xff, 0x07, 0xf8, 0x3f, 0xff, 0xff, 0xfb, 0x07, 0xf8, 0x3f, 0xff, 0x7f, 0xf8,
      0x07, 0xf0, 0x3f, 0xfe, 0x7f, 0xf0, 0x03, 0xf0, 0x3f, 0xfe, 0x7f, 0xf8, 0x00, 0x00, 0x7f, 0xfe,
      0x3f, 0xff, 0x80, 0x00, 0x7f, 0xfc, 0x3f, 0xff, 0x88, 0x00, 0xff, 0xfc, 0x3f, 0xff, 0x9c, 0x43,
      0xff, 0xfc, 0x1f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff,
      0xf8, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xfd, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0,
      0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff,
      0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x07,
      0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00
    });

  // ----------------------------
  // Everything below can be thinkered with if you want but should work as is!
  // ----------------------------

  // Initialising the display
  display.init();
  display.setTextAlignment(TEXT_ALIGN_CENTER);
  display.setFont(ArialMT_Plain_16);
  display.drawString(64, 0, F("HODL Display"));
  display.setFont(ArialMT_Plain_10);
  display.drawString(64, 18, F("By Brian Lough"));
  display.display();
  

  // Set WiFi to station mode and disconnect from an AP if it was Previously
  // connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  // Attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();
  Serial.println(ip);
  ipAddressString = ip.toString();
}

int getNextFreeHoldingIndex() {
  for (int i = 0; i < MAX_HOLDINGS; i++) {
    if (!holdings[i].inUse) {
      return i;
    }
  }

  return -1;
}

int getNextIndex() {
  for (int i = currentIndex + 1; i < MAX_HOLDINGS; i++) {
    if (holdings[i].inUse) {
      return i;
    }
  }

  for (int j = 0; j <= currentIndex; j++) {
    if (holdings[j].inUse) {
      return j;
    }
  }

  return -1;
}

void displayHolding(int index) {

  CMCTickerResponse response = holdings[index].lastResponse;

  display.clear();

  display.setTextAlignment(TEXT_ALIGN_CENTER);
  display.setFont(ArialMT_Plain_16);
  display.drawString(64, 0, response.symbol);
  display.setFont(ArialMT_Plain_24);
  double price = response.price_currency;
  if (price == 0) {
    price = response.price_usd;
  }
  display.drawString(64, 20, formatCurrency(price));
  display.setFont(ArialMT_Plain_16);
//  display.setTextAlignment(TEXT_ALIGN_CENTER);
//  display.drawString(64, 48, " 1h:" + String(response.percent_change_1h) + "%");
    logoCizdir(logo);
  display.setTextAlignment(TEXT_ALIGN_CENTER);
  display.drawString(64, 48, "24h: " + String(response.percent_change_24h) + "%");

  display.display();
  if (response.percent_change_24h > 0)                                                                         //If price has increased from yesterday
  {
    digitalWrite(upLED, HIGH);
    digitalWrite(downLED, LOW);
  } 
  else                                                                                  //If price has decreased from yesterday
  {
    digitalWrite(downLED, HIGH);
    digitalWrite(upLED, LOW);
  }
}
void logoCizdir(const unsigned char logo []) {
  display.drawBitmap(0,
                     (display.height() + (display.height() / 4) - LOGO_YUKSEKLIK) / 2,
                     logo, LOGO_GENISLIK, LOGO_YUKSEKLIK, 1);
  display.display();
}
void displayMessage(String message){
  display.clear();
  display.setFont(ArialMT_Plain_10);
  display.setTextAlignment(TEXT_ALIGN_LEFT);
  display.drawStringMaxWidth(0, 0, 128, message);
  display.display();
}

String formatCurrency(float price) {
  String formattedCurrency = CURRENCY_SYMBOL;
  int pointsAfterDecimal = 6;
  if (price > 100) {
    pointsAfterDecimal = 2;
  } else if (price > 1) {
    pointsAfterDecimal = 4;
  }
  formattedCurrency.concat(String(price, pointsAfterDecimal));
  return formattedCurrency;
}

bool loadDataForHolding(int index) {
  int nextIndex = getNextIndex();
  if (nextIndex > -1 ) {
    holdings[index].lastResponse = api.GetTickerInfo(holdings[index].tickerId, CURRENCY);
    return holdings[index].lastResponse.error == "";
  }

  return false;
}

void loop() {

  unsigned long timeNow = millis();
  if ((timeNow > screenChangeDue))  {
    currentIndex = getNextIndex();
    if (currentIndex > -1) {
      if (loadDataForHolding(currentIndex)) {
        displayHolding(currentIndex);
      } else {
        displayMessage(F("Error loading data."));
      }
    } else {
      displayMessage(F("No funds to display. Edit the setup to add them"));
    }
    screenChangeDue = timeNow + screenChangeDelay;
  }
}

My Fault Code:

SimpleCrypto:88:30: error: use of deleted function 'Holding::Holding()'
   88 | Holding holdings[MAX_HOLDINGS];
      |                              ^
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino:80:8: note: 'Holding::Holding()' is implicitly deleted because the default definition would be ill-formed:
   80 | struct Holding {
      |        ^~~~~~~
SimpleCrypto:80:8: error: uninitialized const member in 'struct Holding'
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino:84:21: note: 'const unsigned char Holding::logo [288]' should be initialized
   84 | const unsigned char logo [288];
      |                     ^~~~
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino: In function 'void addNewHolding(String, const unsigned char*, float)':
SimpleCrypto:99:26: error: assignment of read-only member 'Holding::logo'
   99 |     holdings[index].logo = logo;
      |     ~~~~~~~~~~~~~~~~~~~~~^~~~~~
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino: In function 'void setup()':
SimpleCrypto:132:6: error: cannot convert '<brace-enclosed initializer list>' to 'const unsigned char*'
  132 |     });
      |      ^
      |      |
      |      <brace-enclosed initializer list>
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino:93:57: note:   initializing argument 2 of 'void addNewHolding(String, const unsigned char*, float)'
   93 | void addNewHolding(String tickerId, const unsigned char logo [288], float amount = 0) {
      |                                     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
SimpleCrypto:151:6: error: cannot convert '<brace-enclosed initializer list>' to 'const unsigned char*'
  151 |     });
      |      ^
      |      |
      |      <brace-enclosed initializer list>
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino:93:57: note:   initializing argument 2 of 'void addNewHolding(String, const unsigned char*, float)'
   93 | void addNewHolding(String tickerId, const unsigned char logo [288], float amount = 0) {
      |                                     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
SimpleCrypto:170:6: error: cannot convert '<brace-enclosed initializer list>' to 'const unsigned char*'
  170 |     });
      |      ^
      |      |
      |      <brace-enclosed initializer list>
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino:93:57: note:   initializing argument 2 of 'void addNewHolding(String, const unsigned char*, float)'
   93 | void addNewHolding(String tickerId, const unsigned char logo [288], float amount = 0) {
      |                                     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino: In function 'void displayHolding(int)':
SimpleCrypto:252:16: error: 'logo' was not declared in this scope; did you mean 'logl'?
  252 |     logoCizdir(logo);
      |                ^~~~
      |                logl
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino: In function 'void logoCizdir(const unsigned char*)':
SimpleCrypto:269:11: error: 'SH1106' {aka 'class SH1106Wire'} has no member named 'drawBitmap'
  269 |   display.drawBitmap(0,
      |           ^~~~~~~~~~
exit status 1
use of deleted function 'Holding::Holding()'

don't declare it const if you want to modify it later on.... :slight_smile:

you can't assign an array this way holdings[index].logo = logo;. You have to copy each value into the destination or use memcpy()

2 Likes

Bro my LEDs didn't work why? when I tested with an external supply, they worked.

//mucitpilot kripto para takip uygulaması
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecureBearSSL.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <ArduinoJson.h> //5 nolu sürümü yükleyin 6 ile çalışmaz

// Ağ adı ve şifresini girin
#define WIFI_SSID "ATA CUMHURIYETI"
#define WIFI_PASS "19982002"

// setup zamanı (sn)
#define SETUP_TIME 4

// Ekran yenileme zamanı (sn)
#define UPDATE_TIME 5

// Kripto para için kullanılacak para birimi: eur / usd / gbp olabilir.
#define CURRENCY_CODE "usd"
// para birimi veya sembol, tested: harfler veya $ işareti olabilir.
#define CURRENCY_SYM '$'
#define upLED 12
#define downLED 13
#define blue 15
//Https yani güvenli bağlantı için sitelere ait gerekli parmak izi bilgileri
//bir sitenin fingerprintini bulmak için https://www.grc.com/fingerprints.htm  adresini kullanabiliriz.
// Fingerprint ---> api.cryptonator.com - 6 Şubat 2022'ye kadar geçerli
const uint8_t fingerprint_crypto[20] = {0x10, 0x76, 0x19, 0x6B, 0xE9, 0xE5, 0x87, 0x5A, 0x26, 0x12, 0x15, 0xDE, 0x9F, 0x7D, 0x3B, 0x92, 0x9A, 0x7F, 0x30, 0x13};

// OLED Ekran tanımlamaları
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// Coin'lere ait logoların ebatı 48x48 piksel olmalı
//http://javl.github.io/image2cpp/ sitesini kullanarak monokrom bitmap'leriniz için gerekli kodu üretebilirsiniz.
#define LOGO_GENISLIK 48
#define LOGO_YUKSEKLIK 48

// Coinlerimize ait bilgileri saklamak için bir veri tipi bloğu oluşturuyoruz.
struct asset {
  String assetName;
  String url;
  const unsigned char logo [288];
};

// Kullanacağımız tüm coin'ler için bilgileri oluşturmamız gerekli
// Yeni bir COIN eklemek isterseniz:
//  1: Aşağıdaki örneklerden birini kopyalayıp yapıştırın
//  2: Kripto ismini güncelleyin
//  3: api.cryptonator.com sitesinden o coin için gerekli linki alın
//  4: http://javl.github.io/image2cpp/ sitesini kullanarak o coin için 48x48'lik bir simge olşturun
asset assets[] = {
  // Doge coin bilgileri
  { "Doge",
    "https://api.cryptonator.com/api/ticker/doge-" + String(CURRENCY_CODE),
    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00,
      0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x07, 0x00, 0x00, 0x01, 0xa0, 0x00, 0x0f, 0x00, 0x00, 0x01,
      0x80, 0x00, 0x1f, 0x00, 0x00, 0x01, 0x98, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x80, 0x00, 0x7e, 0x00,
      0x00, 0x01, 0x83, 0xe1, 0xf8, 0x00, 0x00, 0x01, 0x83, 0xe1, 0xf8, 0x00, 0x00, 0x01, 0x3f, 0xfd,
      0xd8, 0x00, 0x00, 0x07, 0xff, 0xfe, 0x10, 0x00, 0x00, 0x1f, 0xe7, 0xff, 0x90, 0x00, 0x00, 0x7f,
      0xe7, 0xff, 0x80, 0x00, 0x01, 0xff, 0xdf, 0xff, 0xf0, 0x00, 0x03, 0xff, 0xdf, 0xff, 0xff, 0x00,
      0x03, 0xff, 0xdf, 0xff, 0xff, 0x80, 0x07, 0xc7, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xc7, 0xff, 0xff,
      0xff, 0xc0, 0x07, 0xe7, 0xff, 0xff, 0xff, 0xc0, 0x0f, 0xcf, 0xfd, 0x1f, 0xff, 0xc0, 0x0f, 0xff,
      0xfe, 0x0f, 0xff, 0xe0, 0x0f, 0xff, 0xfa, 0x1f, 0xff, 0xe0, 0x1f, 0xff, 0xfe, 0x7f, 0xff, 0xe0,
      0x1f, 0xdf, 0xff, 0xff, 0xff, 0xe0, 0x1e, 0x07, 0xff, 0xff, 0xff, 0xe0, 0x1e, 0x01, 0xff, 0xff,
      0xff, 0xe0, 0x1e, 0x01, 0xff, 0xff, 0xff, 0xe0, 0x1e, 0x01, 0xff, 0xff, 0xff, 0xe0, 0x1e, 0x0f,
      0xff, 0xff, 0xff, 0xe0, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xe0,
      0x0f, 0x9f, 0xff, 0xff, 0xff, 0xe0, 0x0e, 0x07, 0xff, 0xff, 0xff, 0xe0, 0x0f, 0xc0, 0x1f, 0xff,
      0xff, 0xc0, 0x0f, 0xc0, 0x1f, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff,
      0xff, 0xff, 0xff, 0x80, 0x03, 0xff, 0xff, 0xff, 0xff, 0x80, 0x01, 0xff, 0xff, 0xff, 0xff, 0x00,
      0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x1f, 0xff, 0xff,
      0xf0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x01,
      0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    }
  },
  // BTC ayarları
  { "BTC",
    "https://api.cryptonator.com/api/ticker/btc-" + String(CURRENCY_CODE),
    { 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff,
      0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x7f,
      0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80,
      0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xfe, 0x3f, 0xff, 0xe0, 0x0f, 0xff, 0xfe, 0x73,
      0xff, 0xf0, 0x0f, 0xff, 0xfc, 0x63, 0xff, 0xf0, 0x1f, 0xff, 0x0c, 0x63, 0xff, 0xf8, 0x1f, 0xff,
      0x00, 0x63, 0xff, 0xfc, 0x3f, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x3f, 0xff, 0xe0, 0x01, 0xff, 0xfc,
      0x7f, 0xff, 0xe0, 0x80, 0x7f, 0xfe, 0x7f, 0xff, 0xe0, 0xf0, 0x3f, 0xfe, 0x7f, 0xff, 0xe1, 0xf8,
      0x3f, 0xfe, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff,
      0xc1, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x7f, 0xff,
      0xff, 0xff, 0x82, 0x00, 0xff, 0xff, 0xff, 0xff, 0x83, 0xc0, 0x7f, 0xff, 0xff, 0xff, 0x87, 0xf0,
      0x3f, 0xff, 0xff, 0xff, 0x07, 0xf8, 0x3f, 0xff, 0xff, 0xfb, 0x07, 0xf8, 0x3f, 0xff, 0x7f, 0xf8,
      0x07, 0xf0, 0x3f, 0xfe, 0x7f, 0xf0, 0x03, 0xf0, 0x3f, 0xfe, 0x7f, 0xf8, 0x00, 0x00, 0x7f, 0xfe,
      0x3f, 0xff, 0x80, 0x00, 0x7f, 0xfc, 0x3f, 0xff, 0x88, 0x00, 0xff, 0xfc, 0x3f, 0xff, 0x9c, 0x43,
      0xff, 0xfc, 0x1f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff,
      0xf8, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xfd, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0,
      0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff,
      0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x07,
      0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00
    }
  },
  // ETH ayarları
  { "ETH",
    "https://api.cryptonator.com/api/ticker/eth-" + String(CURRENCY_CODE),
    { 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff,
      0xc0, 0x00, 0x00, 0x0f, 0xfe, 0xff, 0xf0, 0x00, 0x00, 0x1f, 0xfc, 0x7f, 0xfc, 0x00, 0x00, 0x7f,
      0xfc, 0x7f, 0xfe, 0x00, 0x00, 0xff, 0xf8, 0x3f, 0xff, 0x00, 0x01, 0xff, 0xf0, 0x1f, 0xff, 0x80,
      0x03, 0xff, 0xf0, 0x1f, 0xff, 0xc0, 0x07, 0xff, 0xe0, 0x0f, 0xff, 0xe0, 0x07, 0xff, 0xe0, 0x07,
      0xff, 0xf0, 0x0f, 0xff, 0xc0, 0x07, 0xff, 0xf0, 0x1f, 0xff, 0x80, 0x03, 0xff, 0xf8, 0x1f, 0xff,
      0x80, 0x03, 0xff, 0xf8, 0x3f, 0xff, 0x00, 0x01, 0xff, 0xfc, 0x3f, 0xff, 0x00, 0x00, 0xff, 0xfc,
      0x7f, 0xfe, 0x00, 0x00, 0xff, 0xfe, 0x7f, 0xfc, 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfc, 0x00, 0x00,
      0x7f, 0xfe, 0x7f, 0xf8, 0x00, 0x00, 0x3f, 0xfe, 0xff, 0xf8, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0,
      0x00, 0x00, 0x1f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x0f, 0xff,
      0xff, 0xe0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfe, 0x00, 0x00,
      0x7f, 0xff, 0x7f, 0xe7, 0x00, 0x01, 0xcf, 0xff, 0x7f, 0xf3, 0xc0, 0x07, 0x9f, 0xff, 0x7f, 0xf8,
      0xf0, 0x0e, 0x3f, 0xfe, 0x7f, 0xf8, 0x38, 0x3c, 0x3f, 0xfe, 0x7f, 0xfc, 0x1e, 0xf0, 0x7f, 0xfe,
      0x3f, 0xfe, 0x07, 0xc0, 0xff, 0xfe, 0x3f, 0xff, 0x03, 0x80, 0xff, 0xfc, 0x1f, 0xff, 0x00, 0x01,
      0xff, 0xfc, 0x1f, 0xff, 0x80, 0x03, 0xff, 0xf8, 0x0f, 0xff, 0xc0, 0x07, 0xff, 0xf0, 0x0f, 0xff,
      0xc0, 0x07, 0xff, 0xf0, 0x07, 0xff, 0xe0, 0x0f, 0xff, 0xe0, 0x03, 0xff, 0xf0, 0x1f, 0xff, 0xc0,
      0x01, 0xff, 0xf0, 0x1f, 0xff, 0xc0, 0x00, 0xff, 0xf8, 0x3f, 0xff, 0x00, 0x00, 0x7f, 0xfc, 0x7f,
      0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x7f, 0xfc, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x07,
      0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00
    }
  },
  // XLM ayarları
  { "Stellar",
    "https://api.cryptonator.com/api/ticker/xlm-" + String(CURRENCY_CODE),
    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00,
      0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xc0, 0x03, 0x00, 0x0f, 0xfc, 0x3f, 0xf0, 0x0f,
      0x00, 0x1f, 0xc0, 0x03, 0xc0, 0x3f, 0x00, 0x3f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x7c, 0x00, 0x00,
      0x03, 0xfc, 0x00, 0xf8, 0x00, 0x00, 0x0f, 0xf0, 0x01, 0xf0, 0x00, 0x00, 0x3f, 0xe0, 0x01, 0xe0,
      0x00, 0x00, 0xff, 0x80, 0x03, 0xc0, 0x00, 0x03, 0xfe, 0x01, 0x03, 0xc0, 0x00, 0x07, 0xf8, 0x07,
      0x07, 0x80, 0x00, 0x3f, 0xe0, 0x1f, 0x07, 0x80, 0x00, 0x7f, 0x80, 0x7f, 0x0f, 0x00, 0x01, 0xfe,
      0x01, 0xfe, 0x0f, 0x00, 0x07, 0xf8, 0x07, 0xf8, 0x0f, 0x00, 0x1f, 0xe0, 0x1f, 0xf8, 0x0f, 0x00,
      0x7f, 0x80, 0x7f, 0xf0, 0x0e, 0x01, 0xfe, 0x01, 0xfe, 0x70, 0x0e, 0x07, 0xf8, 0x07, 0xf8, 0x70,
      0x0e, 0x1f, 0xe0, 0x1f, 0xe0, 0x70, 0x0e, 0x7f, 0x80, 0x7f, 0x80, 0x70, 0x0f, 0xfe, 0x01, 0xfe,
      0x00, 0xf0, 0x1f, 0xf8, 0x07, 0xf8, 0x00, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0, 0x00, 0xf0, 0x7f, 0x80,
      0x7f, 0x80, 0x00, 0xf0, 0xfe, 0x01, 0xfe, 0x00, 0x01, 0xe0, 0xf8, 0x07, 0xfc, 0x00, 0x01, 0xe0,
      0xe0, 0x1f, 0xe0, 0x00, 0x03, 0xc0, 0x80, 0x7f, 0xc0, 0x00, 0x03, 0xc0, 0x01, 0xff, 0x00, 0x00,
      0x07, 0x80, 0x07, 0xfc, 0x00, 0x00, 0x0f, 0x80, 0x0f, 0xf0, 0x00, 0x00, 0x1f, 0x00, 0x3f, 0xc0,
      0x00, 0x00, 0x3e, 0x00, 0xff, 0x00, 0x00, 0x00, 0xfc, 0x00, 0xfc, 0x03, 0xc0, 0x03, 0xf8, 0x00,
      0xf0, 0x0f, 0xfc, 0x3f, 0xf0, 0x00, 0xc0, 0x03, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0xff, 0xff,
      0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    }
  },
  // ADA ayarları
  { "Cardano",
    "https://api.cryptonator.com/api/ticker/ada-" + String(CURRENCY_CODE),
    { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
      0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x07, 0x03, 0x81, 0xc0, 0x00,
      0x00, 0x07, 0x03, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x30, 0x08, 0x00, 0x00, 0x0c, 0x00, 0xfc, 0x3e, 0x00, 0x60, 0x0c, 0x00,
      0xfc, 0x7f, 0x00, 0x20, 0x00, 0x31, 0xfe, 0x7f, 0x08, 0x00, 0x00, 0x79, 0xfe, 0x7f, 0x1c, 0x00,
      0x00, 0x79, 0xfe, 0x7f, 0x1c, 0x00, 0x00, 0x30, 0xfc, 0x7f, 0x1c, 0x00, 0x00, 0x00, 0x78, 0x3e,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x1f,
      0x80, 0x03, 0xf0, 0x00, 0x00, 0x1f, 0xc0, 0x03, 0xf8, 0x60, 0x46, 0x1f, 0xc0, 0x03, 0xf8, 0xe2,
      0xce, 0x1f, 0xc0, 0x03, 0xf8, 0x62, 0x04, 0x1f, 0xc0, 0x03, 0xf8, 0x00, 0x00, 0x0f, 0x80, 0x03,
      0xf0, 0x00, 0x00, 0x07, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x7c, 0x3e, 0x00, 0x00, 0x00, 0x30, 0xfc, 0x7f, 0x1c, 0x00, 0x00, 0x79, 0xfe, 0x7f, 0x1c, 0x00,
      0x00, 0x71, 0xfe, 0x7f, 0x1c, 0x00, 0x00, 0x01, 0xfe, 0x7f, 0x00, 0x00, 0x0c, 0x00, 0xfc, 0x7f,
      0x00, 0x60, 0x0c, 0x00, 0x7c, 0x3e, 0x00, 0x60, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x03, 0x03, 0xc0, 0xc0, 0x00,
      0x00, 0x03, 0x03, 0x80, 0xc0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
      0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    }
  }


};

// Yükseliş / Düşüş Trend Okları 45x26piksel
#define OK_GENISLIK 45
#define OK_YUKSEKLIK 26

// Bitmap olarak Yükseliş Oku
const unsigned char stonks [] PROGMEM = {
  0x00, 0x00, 0x00, 0x07, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x03, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x01,
  0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00,
  0x00, 0x00, 0x3f, 0xf8, 0x00, 0x03, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x03, 0x80, 0x00, 0x3f, 0xf8,
  0x00, 0x07, 0xc0, 0x00, 0x7f, 0xf8, 0x00, 0x0f, 0xe0, 0x00, 0xff, 0xf8, 0x00, 0x1f, 0xf0, 0x01,
  0xfd, 0xf8, 0x00, 0x1f, 0xf8, 0x03, 0xf8, 0xf8, 0x00, 0x3f, 0xfc, 0x07, 0xf0, 0x78, 0x00, 0x7c,
  0xfe, 0x0f, 0xf0, 0x38, 0x00, 0xf8, 0xff, 0x1f, 0xe0, 0x18, 0x00, 0xf0, 0x7f, 0xbf, 0xc0, 0x08,
  0x01, 0xe0, 0x3f, 0xff, 0x80, 0x00, 0x03, 0xc0, 0x1f, 0xff, 0x00, 0x00, 0x07, 0x00, 0x0f, 0xfe,
  0x00, 0x00, 0x06, 0x00, 0x07, 0xfc, 0x00, 0x00, 0x0c, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x18, 0x00,
  0x01, 0xf0, 0x00, 0x00, 0x30, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x20, 0x00, 0x00, 0x40, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

// Bitmap olarak Düşüş Oku
const unsigned char notstonks [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
  0x00, 0x20, 0x00, 0x00, 0x38, 0x00, 0x00, 0x60, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xc0, 0x00, 0x00,
  0xfe, 0x00, 0x01, 0x80, 0x00, 0x01, 0xff, 0x00, 0x03, 0x00, 0x00, 0x03, 0xff, 0x80, 0x07, 0x00,
  0x00, 0x07, 0xff, 0xc0, 0x1e, 0x00, 0x00, 0x0f, 0xff, 0xe0, 0x3c, 0x00, 0x80, 0x1f, 0xef, 0xf0,
  0x78, 0x00, 0xc0, 0x3f, 0xc7, 0xf8, 0xf8, 0x00, 0xe0, 0x7f, 0x83, 0xf9, 0xf0, 0x00, 0xf0, 0x7f,
  0x01, 0xff, 0xe0, 0x00, 0xf8, 0xfe, 0x00, 0xff, 0xc0, 0x00, 0xfd, 0xfc, 0x00, 0x7f, 0xc0, 0x00,
  0xff, 0xf8, 0x00, 0x3f, 0x80, 0x00, 0xff, 0xf0, 0x00, 0x1f, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x0e,
  0x00, 0x00, 0xff, 0xc0, 0x00, 0x06, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0,
  0x00, 0x00, 0x00, 0x00, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00,
  0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00
};

// Hangi coin'in gösterileceğini tutacağımız değişken
int currentAsset = 0; //dizinin kaçıncı elemanı
// Dizide kaç tane eleman olduğu bilgisini tutacak değişken
const int maxAssets = sizeof(assets) / sizeof(assets[0]);

void setup() {

  Serial.begin(115200);
pinMode(upLED, OUTPUT);                                                     //Define the LED pin outputs
pinMode(downLED, OUTPUT);
pinMode(blue, OUTPUT);
  // OLED ekranı başlatıyoruz ve herhangi bir hata varsa uyarıyoruz
  if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("HATA: OLED ekran başlatılamadı"));
    while (1); //sürekli burada döner koda devam etmez
  }

  // Önce ekranı temizliyoruz
  display.clearDisplay();
  // Metin rengini beyaz yapıyoruz ki arka plan koyu yazılar açık renk olsun
  display.setTextColor(SSD1306_WHITE);
  // Bağlantı mesajı için text boyutunu en küçüğe ayarladık
  display.setTextSize(1);

  // Wifi'ye bağlanırken gereken zaman için bekletiyoruz
  for (uint8_t t = SETUP_TIME; t > 0; t--) {
    // Bağlanma durumunu serial'a yazdıralım
    Serial.printf("[SETUP] Bekleyin %d...\n", t);
    Serial.flush();
    // OLED ekrana da yazdıralım
    display.clearDisplay();
    display.setCursor(0, display.height() / 4);
    display.print(F("Basliyor bekleyin . . . "));
    display.print(t);
    display.display();
    delay(1000);
  }

  // Kodun geri kalan kısmı için font boyutunu 2 olarak kullanalım
  display.setTextSize(2);

  // Ağa bağlanalım
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASS);
}

void loop() {
  // Ağa bağlanılana kadar bekliyoruz
  if ((WiFi.status() == WL_CONNECTED)) {

    // fingerprinti ayarlıyoruz
    uint8_t fingerprint[20];
    // C dilinde bir dizi diğer diziye memcopy ile atanabilir.
    memcpy(fingerprint, fingerprint_crypto, 20);

    // Bir Https istemcisi başlatalım //bu kısım olmadan SSL sertifikalı sitelerden veri çekemeyiz.
    std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
    client->setFingerprint(fingerprint);
    HTTPClient https;

    // API'ya bağlantı kuralım
    Serial.print("HTTPS başlatılıyor...\n");
    if (https.begin(*client, assets[currentAsset].url)) {  // HTTPS

      // Bağlantıyı başlatalım ve GET header'ını gönderelim.
      Serial.print("HTTPS GET...\n");
      int httpCode = https.GET();

      // bir hata olmuşsa httpCode değeri negatif dönecektir.
      if (httpCode > 0) {
        // Sunucudan gelen cevabı işlemeliyiz.
        Serial.printf("HTTPS GET... code: %d\n", httpCode);

        // HTTP iletişi geçerli ise gelen veriyi alıp işleyelim
        if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
          // API'den aldığımız veri bloğunu bir String'e atıyoruz.
          String payload = https.getString();
          // Coin'in değerini, değer değişimini alıyor ve bunlardan da %değişimi hesaplıyoruz
          float price;
          float change;
          String nick = "";

          Serial.println("Güncel veriler alındı");
          const size_t capacity = JSON_OBJECT_SIZE(4) + JSON_OBJECT_SIZE(5) + 150;
          DynamicJsonBuffer jsonBuffer(capacity);
          JsonObject& root = jsonBuffer.parseObject(payload);

          if (!root.success()) {
            Serial.println(F("Parsing başarısız!"));
            return;
          }

          Serial.println(F("Cevap:"));
          Serial.println(root["ticker"]["price"].as<char*>());
          price = root["ticker"]["price"];
          nick = root["ticker"]["base"].as<char*>();
          change = root["ticker"]["change"];

          //price = payload.substring(payload.indexOf("price") + 8, payload.indexOf("volume") - 3).toFloat();
          //change = payload.substring(payload.indexOf("change") + 9, payload.indexOf("timestamp") - 4).toFloat();
          //nick = payload.substring(payload.indexOf("base") + 7, payload.indexOf("target") - 3);

          float changePercent = change / price * 100;

          // Aldığımız veri bloğunu serial ekrana yazdıralım (kontrol için)
          Serial.println(assets[currentAsset].assetName);
          Serial.println(payload);


          // Bilgileri OLED ekrana yazdıralım
          display.clearDisplay();
          logoCizdir(assets[currentAsset].logo);//logoyu çizdir
          okCizdir(change);//pozitif ise artan ok negatif ise düşen oku çizdirecek
          degerYazdir(price);//değeri yazdır
          degisimiYazdir(changePercent);//değişim yüzdesini yazdır
          display.setTextSize(1);
          isminiYazdir(nick);//değeri yazdır
          display.setTextSize(2);
          // Bir sonraki coin'i göstermek için
          currentAsset++;//sayacı bir arttırdık
          if (currentAsset >= maxAssets) { //sona geldiysek başa çevirdik
            currentAsset = 0;
          }
        }
      }
      else { //negatif bir cevap kodu dönmüşse
        // Serial ekran ve OLED ekran kullanılarak hata bildirimi yapıyoruz.
        Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str());
        display.clearDisplay();
        display.setTextSize(1);
        display.setCursor(0, display.height() / 4);
        display.println(F("HTTPS GET hatasi"));
        display.print(F("Birkaç saniye içinde yeniden denenecek"));
        display.setTextSize(2);
      }

      // https bağlantısını işimiz bitince sonlandırmalıyız.
      https.end();
    }
    else {
      // API ile bağlantı sağlanamamışsa
      Serial.println("API'ya bağlanılamıyor");
      display.clearDisplay();
      display.setTextSize(1);
      display.setCursor(0, display.height() / 4);
      display.println(F("Baglanti Hatasi"));
      display.print(F("Tekrar Denenecek"));
      display.setTextSize(2);
    }
  }

  Serial.print("Bir sonraki döngü için bekleyin...\n\n");
  delay(UPDATE_TIME * 1000);
}

// OLED ekrana logoları yazdırmak için kullandığımız prosedür
void logoCizdir(const unsigned char logo []) {
  display.drawBitmap(0,
                     (display.height() + (display.height() / 4) - LOGO_YUKSEKLIK) / 2,
                     logo, LOGO_GENISLIK, LOGO_YUKSEKLIK, 1);
  display.display();
}

// Yukarı / Aşağı Trend Oklarını yazdıran prosedür
void okCizdir(float change) {//değişimin değerine bakıp aşağı / yukarı oka karar vereceğiz
  if (change >= 0) {
    display.drawBitmap(display.width() - OK_GENISLIK, display.height() - OK_YUKSEKLIK, stonks, OK_GENISLIK, OK_YUKSEKLIK, 1);
    
  }
  else {
    display.drawBitmap(display.width() - OK_GENISLIK, display.height() - OK_YUKSEKLIK, notstonks, OK_GENISLIK, OK_YUKSEKLIK, 1);
  }
  display.display();
}

// OLED ekrana coin değerini yazdırdığımız prosedür
void degerYazdir(float price) {
  char priceBuf[20];
  // Kullanılan para birimi sembolü
  char currencySymbol = '$';
  currencySymbol = CURRENCY_SYM;
  // Değer metnini şekillendirelim
  if (price < 10) {
    sprintf(priceBuf, "%c%.5f", currencySymbol, price);
  }
  else {
    sprintf(priceBuf, "%c%.3f", currencySymbol, price);
  }
  // Ekranı ortalamak için metin boyutu bilgisine ihtiyacımız var
  int16_t x1, y1;
  uint16_t w, h;
  display.getTextBounds(priceBuf, 0, 0, &x1, &y1, &w, &h);
  // Cursor'u ekranı ortalayacak pozisyona alıyoruz.
  display.setCursor((display.width() - w) / 2, 0);
  // ekrana yazdıralım.
  display.print(priceBuf);
  display.display();
}


// Değerdeki oransal değişimi yazdırdığımız prosedür
void degisimiYazdir(float change) {
  display.setCursor(LOGO_GENISLIK + 10, display.height() / 4 + 2);
  // Pozitif değişimler için + işareti ekleyelim.
  if (change >= 0) {
    display.print(F("+"));
  }
  // değişim yüzdesi 10'dan az ise bir hane ondalık ekleyelim
  if (abs(change) < 10) {
    display.print(change, 1);
  }
  else {
    display.print(change, 0);
  }
  display.print(F("%"));
  display.display();
}
void leds(float change) {
  if (change > 0) {
digitalWrite(upLED, HIGH);
digitalWrite(downLED, LOW);
digitalWrite(blue, LOW);
}
else if (change < 0) {
 digitalWrite(downLED, HIGH);
 digitalWrite(upLED, LOW);
 digitalWrite(blue, LOW);
}
else {
 digitalWrite(downLED, LOW);
 digitalWrite(upLED, LOW);
 digitalWrite(blue, HIGH);
}
  }

// COIN kısaltmasını yazdırdığımız prosedür
void isminiYazdir(String nick) {
  display.setCursor(LOGO_GENISLIK + 5, display.height() / 4 * 3);
  // Pozitif değişimler için + işareti ekleyelim.
  display.print(nick);
  display.display();
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.