Skip to content

Commit

Permalink
Merge pull request #1262 from GameOneYT/patch-2
Browse files Browse the repository at this point in the history
Auto update hashrate
  • Loading branch information
revoxhere authored Jan 18, 2022
2 parents 3b3376a + 54e19e4 commit a3439ea
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion ESP8266_Code/ESP8266_Code.ino
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const char* USERNAME = "my_cool_username";
const char* RIG_IDENTIFIER = "Auto";
// Change false to true if using 160 MHz clock mode to not get the first share rejected
const bool USE_HIGHER_DIFF = false;
// Change false to true if you want to update hashrate in browser without reloading page
const bool WEB_HASH_UPDATER = false;

/* Do not change the lines below. These lines are static and dynamic variables
that will be used by the program for counters and measurements. */
Expand Down Expand Up @@ -114,7 +116,7 @@ const char WEBSITE[] PROGMEM = R"=====(
<div class="columns is-multiline">
<div class="column" style="min-width:15em">
<div class="title is-size-5 mb-0">
@@HASHRATE@@kH/s
<span id="hashratex">@@HASHRATE@@</span>kH/s
</div>
<div class="heading is-size-5">
Hashrate
Expand Down Expand Up @@ -207,6 +209,22 @@ const char WEBSITE[] PROGMEM = R"=====(
</div>
</div>
</div>
<script>
setInterval(function(){
getData();
}, 3000);
function getData() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("hashratex").innerHTML = this.responseText;
}
};
xhttp.open("GET", "hashrateread", true);
xhttp.send();
}
</script>
</section>
</body>
Expand All @@ -215,6 +233,11 @@ const char WEBSITE[] PROGMEM = R"=====(

ESP8266WebServer server(80);

void hashupdater(){ //update hashrate every 3 sec in browser without reloading page
server.send(200, "text/plane", String(hashrate / 1000));
Serial.println("Update hashrate on page");
};

void UpdateHostPort(String input) {
// Thanks @ricaun for the code
DynamicJsonDocument doc(256);
Expand Down Expand Up @@ -488,6 +511,7 @@ void setup() {
+ WiFi.localIP().toString()
+ ")");
server.on("/", dashboard);
if (WEB_HASH_UPDATER) server.on("/hashrateread", hashupdater);
server.begin();

blink(BLINK_SETUP_COMPLETE);
Expand Down

0 comments on commit a3439ea

Please sign in to comment.