Skip to content

Commit

Permalink
Fix screen 1 breaking when share found
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-wilson committed Jan 7, 2024
1 parent 84c0611 commit 9eee3ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
11 changes: 5 additions & 6 deletions main/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,14 @@ static void _init_system(GlobalState * global_state, SystemModule * module)
netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
}

static void _update_hashrate(GlobalState * GLOBAL_STATE)
static void _update_hashrate(SystemModule * module, float power)
{
SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE;

if (module->screen_page != 0) {
return;
}

float efficiency = GLOBAL_STATE->POWER_MANAGEMENT_MODULE.power / (module->current_hashrate / 1000.0);
float efficiency = power / (module->current_hashrate / 1000.0);

OLED_clearLine(0);
memset(module->oled_buf, 0, 20);
Expand Down Expand Up @@ -230,7 +229,7 @@ static void _update_system_performance(GlobalState * GLOBAL_STATE)

if (OLED_status()) {

_update_hashrate(GLOBAL_STATE);
_update_hashrate(module, GLOBAL_STATE->POWER_MANAGEMENT_MODULE.power);
_update_shares(module);
_update_best_diff(module);

Expand Down Expand Up @@ -424,7 +423,7 @@ void SYSTEM_notify_new_ntime(SystemModule * module, uint32_t ntime)
settimeofday(&tv, NULL);
}

void SYSTEM_notify_found_nonce(SystemModule * module, double pool_diff, double found_diff, uint32_t nbits)
void SYSTEM_notify_found_nonce(SystemModule * module, double pool_diff, double found_diff, uint32_t nbits, float power)
{
// Calculate the time difference in seconds with sub-second precision

Expand Down Expand Up @@ -459,7 +458,7 @@ void SYSTEM_notify_found_nonce(SystemModule * module, double pool_diff, double f
module->current_hashrate = ((module->current_hashrate * 9) + rolling_rate) / 10;
}

_update_hashrate(module);
_update_hashrate(module, power);

// logArrayContents(historical_hashrate, HISTORY_LENGTH);
// logArrayContents(historical_hashrate_time_stamps, HISTORY_LENGTH);
Expand Down
12 changes: 6 additions & 6 deletions main/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ typedef struct
uint32_t lastClockSync;
} SystemModule;

void SYSTEM_task(void *parameters);
void SYSTEM_task(void * parameters);

void SYSTEM_notify_accepted_share(SystemModule *module);
void SYSTEM_notify_rejected_share(SystemModule *module);
void SYSTEM_notify_found_nonce(SystemModule *module, double pool_diff, double found_diff, uint32_t nbits);
void SYSTEM_notify_mining_started(SystemModule *module);
void SYSTEM_notify_new_ntime(SystemModule *module, uint32_t ntime);
void SYSTEM_notify_accepted_share(SystemModule * module);
void SYSTEM_notify_rejected_share(SystemModule * module);
void SYSTEM_notify_found_nonce(SystemModule * module, double pool_diff, double found_diff, uint32_t nbits, float power);
void SYSTEM_notify_mining_started(SystemModule * module);
void SYSTEM_notify_new_ntime(SystemModule * module, uint32_t ntime);

#endif /* SYSTEM_H_ */
4 changes: 3 additions & 1 deletion main/tasks/asic_result_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ void ASIC_result_task(void *pvParameters)
&GLOBAL_STATE->SYSTEM_MODULE,
GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->pool_diff,
nonce_diff,
GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->target);
GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->target,
GLOBAL_STATE->POWER_MANAGEMENT_MODULE.power
);

STRATUM_V1_submit_share(
GLOBAL_STATE->sock,
Expand Down

0 comments on commit 9eee3ae

Please sign in to comment.