Fix connecting to node
This commit is contained in:
parent
1f7946c30e
commit
be937da6b9
@ -1,6 +0,0 @@
|
||||
#include "universal_pin.hpp"
|
||||
|
||||
class MCP23017_Pin : public UniversalPin
|
||||
{
|
||||
|
||||
};
|
@ -1,6 +0,0 @@
|
||||
#include "universal_pin.hpp"
|
||||
|
||||
class Native_Pin : public UniversalPin
|
||||
{
|
||||
|
||||
};
|
@ -1,6 +0,0 @@
|
||||
#include "universal_pin.hpp"
|
||||
|
||||
class PCF8575_Pin : public UniversalPin
|
||||
{
|
||||
|
||||
};
|
@ -1,5 +0,0 @@
|
||||
#include "universal_pin.hpp"
|
||||
|
||||
UniversalPin::UniversalPin(uint pinNumber) {
|
||||
this->pinNumber = pinNumber;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
class UniversalPin
|
||||
{
|
||||
public:
|
||||
UniversalPin(uint pinNumber);
|
||||
virtual void pinMode(uint8_t mode);
|
||||
virtual uint8_t digitalRead();
|
||||
virtual void digitalWrite(uint8_t value);
|
||||
protected:
|
||||
uint pinNumber;
|
||||
};
|
@ -75,7 +75,7 @@ void onApiStatus(AsyncWebServerRequest *request)
|
||||
StaticJsonDocument<512> root;
|
||||
root["currentScreen"] = String(getCurrentScreen());
|
||||
root["timerRunning"] = timerRunning;
|
||||
|
||||
root["numScreens"] = NUM_SCREENS;
|
||||
JsonArray data = root.createNestedArray("data");
|
||||
JsonArray rendered = root.createNestedArray("rendered");
|
||||
String epdContent[7];
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "tasks/button.hpp"
|
||||
#include "tasks/led_handler.hpp"
|
||||
|
||||
//WiFiClient wifiClientInsecure;
|
||||
WiFiClient wifiClientInsecure;
|
||||
WiFiClientSecure wifiClient;
|
||||
ESP32Time rtc(3600);
|
||||
|
||||
|
@ -25,8 +25,7 @@ void HalvingCountdownScreen::init()
|
||||
for (int i = 0; i < NUM_SCREENS; i++)
|
||||
{
|
||||
epdContentP[i] = HalvingCountdownScreen::psramBuffer + i * maxStringLength;
|
||||
// strcpy(epdContent[i], "x");
|
||||
strcpy(epdContentP[i], "x");
|
||||
strcpy(epdContentP[i], "");
|
||||
}
|
||||
initialized = true;
|
||||
setupBlockNotify();
|
||||
@ -48,18 +47,12 @@ void HalvingCountdownScreen::showScreen()
|
||||
|
||||
snprintf(HalvingCountdownScreen::epdContentP[0], maxStringLength, "BIT/COIN");
|
||||
snprintf(HalvingCountdownScreen::epdContentP[1], maxStringLength, "HALV/ING");
|
||||
snprintf(HalvingCountdownScreen::epdContentP[2], maxStringLength, "%d/YRS", years);
|
||||
snprintf(HalvingCountdownScreen::epdContentP[(NUM_SCREENS-5)], maxStringLength, "%d/YRS", years);
|
||||
|
||||
snprintf(HalvingCountdownScreen::epdContentP[3], maxStringLength, "%d/DAYS", days);
|
||||
snprintf(HalvingCountdownScreen::epdContentP[4], maxStringLength, "%d/HRS", hours);
|
||||
snprintf(HalvingCountdownScreen::epdContentP[5], maxStringLength, "%d/MINS", mins);
|
||||
snprintf(HalvingCountdownScreen::epdContentP[6], maxStringLength, "TO/GO");
|
||||
|
||||
// // strcpy(epdContent[2], sprintf(String(years) + "/YRS").c_str());
|
||||
// // snprintf(epdContent[2], sizeof(epdContent[2]), "%d/YRS", years);
|
||||
// // strcpy(epdContent[3], String(days) + "/DAYS");
|
||||
// // strcpy(epdContent[4], String(hours) + "/HRS");
|
||||
// // strcpy(epdContent[5], String(mins) + "/MINS");
|
||||
snprintf(HalvingCountdownScreen::epdContentP[(NUM_SCREENS-4)], maxStringLength, "%d/DAYS", days);
|
||||
snprintf(HalvingCountdownScreen::epdContentP[(NUM_SCREENS-3)], maxStringLength, "%d/HRS", hours);
|
||||
snprintf(HalvingCountdownScreen::epdContentP[(NUM_SCREENS-2)], maxStringLength, "%d/MINS", mins);
|
||||
snprintf(HalvingCountdownScreen::epdContentP[(NUM_SCREENS-1)], maxStringLength, "TO/GO");
|
||||
}
|
||||
|
||||
uint HalvingCountdownScreen::getNextHalvingBlockNr()
|
||||
|
@ -8,12 +8,13 @@ void TimeScreen::init() {
|
||||
}
|
||||
|
||||
void TimeScreen::showScreen() {
|
||||
// String(String(rtc.getDay()) + "/" + String(rtc.getMonth() + 1)).toCharArray(TimeScreen::dateString, 5);
|
||||
// rtc.getTime("%H:%M").toCharArray(TimeScreen::timeString, 5);
|
||||
|
||||
std::string timeString = rtc.getTime("%H:%M").c_str();
|
||||
timeString.insert(timeString.begin(), NUM_SCREENS - timeString.length(), ' ');
|
||||
TimeScreen::epdContent[0] = String(rtc.getDay()) + "/" + String(rtc.getMonth() + 1);
|
||||
char dateTmp[6];
|
||||
snprintf(dateTmp, 6, "%d/%d", rtc.getDay(), (rtc.getMonth() + 1));
|
||||
|
||||
TimeScreen::epdContent[0] = dateTmp;
|
||||
|
||||
for (uint i = 1; i < NUM_SCREENS; i++)
|
||||
{
|
||||
TimeScreen::epdContent[i] = timeString[i];
|
||||
|
@ -26,7 +26,7 @@
|
||||
typedef std::function<void()> EventCallback;
|
||||
typedef std::function<void(uint number)> EventCallbackWithNumber;
|
||||
|
||||
//extern WiFiClient wifiClientInsecure;
|
||||
extern WiFiClient wifiClientInsecure;
|
||||
extern WiFiClientSecure wifiClient;
|
||||
|
||||
extern ESP32Time rtc;
|
||||
|
@ -19,20 +19,23 @@ void checkBitcoinBlock(void *pvParameters)
|
||||
{
|
||||
uint blockHeight = preferences.getUInt("blockHeight", currentBlockHeight);
|
||||
|
||||
|
||||
useBitcoind = preferences.getBool("useNode", false) && wifiClient.connect(preferences.getString("rpcHost", BITCOIND_HOST).c_str(), preferences.getUInt("rpcPort", BITCOIND_PORT));
|
||||
useBitcoind = preferences.getBool("useNode", false) && wifiClientInsecure.connect(preferences.getString("rpcHost", BITCOIND_HOST).c_str(), preferences.getUInt("rpcPort", BITCOIND_PORT));
|
||||
if (useBitcoind)
|
||||
Serial.println(F("bitcoind node is reachable, using this for blocks."));
|
||||
else
|
||||
Serial.println(F("bitcoind node is not reachable, using mempool API instead."));
|
||||
|
||||
if (!useBitcoind)
|
||||
{
|
||||
IPAddress result;
|
||||
|
||||
int err = WiFi.hostByName(preferences.getString("mempoolInstance", DEFAULT_MEMPOOL_INSTANCE).c_str(), result);
|
||||
|
||||
if (err != 1) {
|
||||
if (err != 1)
|
||||
{
|
||||
flashTemporaryLights(255, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@ -79,7 +82,6 @@ void checkBitcoinBlock(void *pvParameters)
|
||||
Serial.print(F("Error in HTTP request to mempool API: "));
|
||||
Serial.print(httpCode);
|
||||
Serial.println(http->errorToString(httpCode));
|
||||
|
||||
}
|
||||
|
||||
http->end();
|
||||
|
@ -35,7 +35,7 @@ void minuteTask(void * parameter) {
|
||||
|
||||
void setupMinuteEvent()
|
||||
{
|
||||
xTaskCreate(minuteTask, "MinuteTask", 2048, NULL, 1, &minuteTaskHandle); // Create the FreeRTOS task
|
||||
xTaskCreate(minuteTask, "MinuteTask", 4096, NULL, 1, &minuteTaskHandle); // Create the FreeRTOS task
|
||||
}
|
||||
|
||||
void registerNewMinuteCallback(const EventCallback cb)
|
||||
|
Loading…
Reference in New Issue
Block a user