Compare commits
11 Commits
6a04694180
...
7844102336
Author | SHA1 | Date | |
---|---|---|---|
|
7844102336 | ||
|
2028613c4c | ||
|
14f4efce72 | ||
|
a94f3ff151 | ||
|
30075fb015 | ||
|
df06ff17eb | ||
|
a05f666031 | ||
|
93cc2a1a88 | ||
|
de10ecad99 | ||
|
4df5d3615e | ||
|
fb36c60738 |
@ -3,7 +3,6 @@
|
|||||||
#ifdef T_DISPLAY
|
#ifdef T_DISPLAY
|
||||||
|
|
||||||
#include <TFT_eSPI.h>
|
#include <TFT_eSPI.h>
|
||||||
#include "media/images_320_170.h"
|
|
||||||
#include "media/myFonts.h"
|
#include "media/myFonts.h"
|
||||||
#include "media/Free_Fonts.h"
|
#include "media/Free_Fonts.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
@ -11,6 +10,12 @@
|
|||||||
#include "OpenFontRender.h"
|
#include "OpenFontRender.h"
|
||||||
#include "rotation.h"
|
#include "rotation.h"
|
||||||
|
|
||||||
|
#ifdef NERD_NOS
|
||||||
|
#include "media/images_NOS_320_170.h"
|
||||||
|
#else
|
||||||
|
#include "media/images_320_170.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define WIDTH 340
|
#define WIDTH 340
|
||||||
#define HEIGHT 170
|
#define HEIGHT 170
|
||||||
|
|
||||||
@ -83,9 +88,9 @@ void tDisplay_MinerScreen(unsigned long mElapsed)
|
|||||||
// Total hashes
|
// Total hashes
|
||||||
render.setFontSize(18);
|
render.setFontSize(18);
|
||||||
render.rdrawString(data.totalMHashes.c_str(), 268, 138, TFT_BLACK);
|
render.rdrawString(data.totalMHashes.c_str(), 268, 138, TFT_BLACK);
|
||||||
// Block templates
|
// ASIC temp
|
||||||
render.setFontSize(18);
|
render.setFontSize(18);
|
||||||
render.drawString(data.templates.c_str(), 186, 20, 0xDEDB);
|
render.drawString(data.currentTemperature.c_str(), 186, 20, 0xDEDB);
|
||||||
// Best diff
|
// Best diff
|
||||||
render.drawString(data.bestDiff.c_str(), 186, 48, 0xDEDB);
|
render.drawString(data.bestDiff.c_str(), 186, 48, 0xDEDB);
|
||||||
// 32Bit shares
|
// 32Bit shares
|
||||||
|
@ -48,6 +48,8 @@ typedef struct __attribute__((__packed__))
|
|||||||
|
|
||||||
static const char *TAG = "bm1397Module";
|
static const char *TAG = "bm1397Module";
|
||||||
|
|
||||||
|
static const uint8_t chip_id[] = {0xAA, 0x55, 0x13, 0x97, 0x18, 0x00};
|
||||||
|
|
||||||
uint32_t increment_bitmask(const uint32_t value, const uint32_t mask);
|
uint32_t increment_bitmask(const uint32_t value, const uint32_t mask);
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
@ -204,9 +206,8 @@ static uint8_t _send_init(uint64_t frequency, uint16_t asic_count)
|
|||||||
|
|
||||||
int chip_counter = 0;
|
int chip_counter = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
int received = SERIAL_rx(buf, 11, 1000);
|
int received = SERIAL_rx(buf, 9, 1000);
|
||||||
if (received > 0) {
|
if (received > 0 && !memcmp(chip_id, buf, sizeof(chip_id))) {
|
||||||
//ESP_LOG_BUFFER_HEX(TAG, asic_response_buffer, received);
|
|
||||||
chip_counter++;
|
chip_counter++;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -361,24 +362,23 @@ bool BM1397_receive_work(uint16_t timeout, asic_result *result)
|
|||||||
{
|
{
|
||||||
uint8_t *rcv_buf = (uint8_t*) result;
|
uint8_t *rcv_buf = (uint8_t*) result;
|
||||||
|
|
||||||
// wait for a response, wait time is pretty arbitrary
|
// non blocking read
|
||||||
int received = SERIAL_rx(rcv_buf, 9, timeout);
|
int received = SERIAL_rx_non_blocking(rcv_buf, 9);
|
||||||
|
|
||||||
if (received < 0)
|
if (received < 0)
|
||||||
{
|
{
|
||||||
Serial.println("Error in serial RX");
|
Serial.println("Error in serial RX");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (received == 0)
|
else if (!received)
|
||||||
{
|
{
|
||||||
// Didn't find a solution, restart and try again
|
// we have not received any data
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (received != 9 || rcv_buf[0] != 0xAA || rcv_buf[1] != 0x55)
|
if (received != 9 || rcv_buf[0] != 0xAA || rcv_buf[1] != 0x55)
|
||||||
{
|
{
|
||||||
Serial.println("Serial RX invalid. Resetting receive buffer ...");
|
Serial.println("Serial RX invalid. Resetting receive buffer ...");
|
||||||
//ESP_LOG_BUFFER_HEX(TAG, asic_response_buffer, received);
|
|
||||||
SERIAL_clear_buffer();
|
SERIAL_clear_buffer();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
3410
src/drivers/nerd-nos/nos_images/nos_clock.bin
Normal file
3410
src/drivers/nerd-nos/nos_images/nos_clock.bin
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/drivers/nerd-nos/nos_images/nos_clock.png
Normal file
BIN
src/drivers/nerd-nos/nos_images/nos_clock.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
3410
src/drivers/nerd-nos/nos_images/nos_globalHash.bin
Normal file
3410
src/drivers/nerd-nos/nos_images/nos_globalHash.bin
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/drivers/nerd-nos/nos_images/nos_globalHash.png
Normal file
BIN
src/drivers/nerd-nos/nos_images/nos_globalHash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
3410
src/drivers/nerd-nos/nos_images/nos_hashscreen.bin
Normal file
3410
src/drivers/nerd-nos/nos_images/nos_hashscreen.bin
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/drivers/nerd-nos/nos_images/nos_hashscreen.png
Normal file
BIN
src/drivers/nerd-nos/nos_images/nos_hashscreen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
3410
src/drivers/nerd-nos/nos_images/nos_initScreen.bin
Normal file
3410
src/drivers/nerd-nos/nos_images/nos_initScreen.bin
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/drivers/nerd-nos/nos_images/nos_initScreen.png
Normal file
BIN
src/drivers/nerd-nos/nos_images/nos_initScreen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 58 KiB |
3410
src/drivers/nerd-nos/nos_images/nos_priceScreen.bin
Normal file
3410
src/drivers/nerd-nos/nos_images/nos_priceScreen.bin
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/drivers/nerd-nos/nos_images/nos_priceScreen.png
Normal file
BIN
src/drivers/nerd-nos/nos_images/nos_priceScreen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
@ -57,6 +57,28 @@ size_t SERIAL_check_for_data() {
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief waits for a serial response from the device
|
||||||
|
/// @param buf buffer to read data into
|
||||||
|
/// @param buf number of ms to wait before timing out
|
||||||
|
/// @return number of bytes read, or -1 on error
|
||||||
|
int16_t SERIAL_rx_non_blocking(uint8_t *buf, uint16_t size) {
|
||||||
|
// check how much data we have
|
||||||
|
size_t available = SERIAL_check_for_data();
|
||||||
|
|
||||||
|
// no data available, return 0
|
||||||
|
if (!available) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for incomplete data
|
||||||
|
if (available && available < size) {
|
||||||
|
Serial.printf("not returning incomplete data ... %d vs %d\n", (int) available, (int) size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// timeout 0 means non_blocking read
|
||||||
|
return SERIAL_rx(buf, size, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// @brief waits for a serial response from the device
|
/// @brief waits for a serial response from the device
|
||||||
/// @param buf buffer to read data into
|
/// @param buf buffer to read data into
|
||||||
@ -64,13 +86,6 @@ size_t SERIAL_check_for_data() {
|
|||||||
/// @return number of bytes read, or -1 on error
|
/// @return number of bytes read, or -1 on error
|
||||||
int16_t SERIAL_rx(uint8_t *buf, uint16_t size, uint16_t timeout_ms)
|
int16_t SERIAL_rx(uint8_t *buf, uint16_t size, uint16_t timeout_ms)
|
||||||
{
|
{
|
||||||
// don't return incomplete data
|
|
||||||
size_t available = SERIAL_check_for_data();
|
|
||||||
if (available && available < size) {
|
|
||||||
Serial.printf("not returning parts of data ... %d vs %d\n", (int) available, (int) size);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t bytes_read = uart_read_bytes(UART_NUM_1, buf, size, timeout_ms / portTICK_PERIOD_MS);
|
int16_t bytes_read = uart_read_bytes(UART_NUM_1, buf, size, timeout_ms / portTICK_PERIOD_MS);
|
||||||
// if (bytes_read > 0) {
|
// if (bytes_read > 0) {
|
||||||
// printf("rx: ");
|
// printf("rx: ");
|
||||||
@ -83,21 +98,6 @@ int16_t SERIAL_rx(uint8_t *buf, uint16_t size, uint16_t timeout_ms)
|
|||||||
return bytes_read;
|
return bytes_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SERIAL_debug_rx(void)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
uint8_t buf[CHUNK_SIZE];
|
|
||||||
|
|
||||||
ret = SERIAL_rx(buf, 100, 20);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "unable to read data\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(buf, 0, 1024);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SERIAL_clear_buffer(void)
|
void SERIAL_clear_buffer(void)
|
||||||
{
|
{
|
||||||
uart_flush(UART_NUM_1);
|
uart_flush(UART_NUM_1);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
int SERIAL_send(uint8_t *, int, bool);
|
int SERIAL_send(uint8_t *, int, bool);
|
||||||
void SERIAL_init(void);
|
void SERIAL_init(void);
|
||||||
void SERIAL_debug_rx(void);
|
|
||||||
int16_t SERIAL_rx(uint8_t *, uint16_t, uint16_t);
|
int16_t SERIAL_rx(uint8_t *, uint16_t, uint16_t);
|
||||||
|
int16_t SERIAL_rx_non_blocking(uint8_t *buf, uint16_t size);
|
||||||
void SERIAL_clear_buffer(void);
|
void SERIAL_clear_buffer(void);
|
||||||
void SERIAL_set_baud(int baud);
|
void SERIAL_set_baud(int baud);
|
||||||
|
|
||||||
|
23844
src/media/images_NOS_320_170.h
Normal file
23844
src/media/images_NOS_320_170.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,8 @@ extern pthread_mutex_t job_mutex;
|
|||||||
extern double best_diff;
|
extern double best_diff;
|
||||||
extern unsigned long mLastTXtoPool;
|
extern unsigned long mLastTXtoPool;
|
||||||
|
|
||||||
|
extern uint32_t shares;
|
||||||
|
extern uint32_t valids;
|
||||||
|
|
||||||
// we can have 32 different job ids
|
// we can have 32 different job ids
|
||||||
#define ASIC_JOB_COUNT 32
|
#define ASIC_JOB_COUNT 32
|
||||||
@ -98,6 +100,9 @@ static void calculate_hashrate(history_t *history, uint32_t diff) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
history->newest++;
|
history->newest++;
|
||||||
|
|
||||||
|
// Increment the global shares counter
|
||||||
|
shares++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// triggers the job creation
|
// triggers the job creation
|
||||||
@ -150,6 +155,12 @@ void runASIC(void * task_id) {
|
|||||||
uint32_t current_difficulty = 0;
|
uint32_t current_difficulty = 0;
|
||||||
|
|
||||||
while (mMiner.inRun) {
|
while (mMiner.inRun) {
|
||||||
|
// wait for the timer to start a new job
|
||||||
|
// also yields the CPU
|
||||||
|
pthread_mutex_lock(&job_interval_mutex);
|
||||||
|
pthread_cond_wait(&job_interval_cond, &job_interval_mutex);
|
||||||
|
pthread_mutex_unlock(&job_interval_mutex);
|
||||||
|
|
||||||
// Temperature check
|
// Temperature check
|
||||||
unsigned long currentTime = millis();
|
unsigned long currentTime = millis();
|
||||||
if (currentTime - lastTempCheck > TEMP_CHECK_INTERVAL) {
|
if (currentTime - lastTempCheck > TEMP_CHECK_INTERVAL) {
|
||||||
@ -172,12 +183,6 @@ void runASIC(void * task_id) {
|
|||||||
lastTempCheck = currentTime;
|
lastTempCheck = currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for the timer to start a new job
|
|
||||||
// also yields the CPU
|
|
||||||
pthread_mutex_lock(&job_interval_mutex);
|
|
||||||
pthread_cond_wait(&job_interval_cond, &job_interval_mutex);
|
|
||||||
pthread_mutex_unlock(&job_interval_mutex);
|
|
||||||
|
|
||||||
// increment extranonce2
|
// increment extranonce2
|
||||||
extranonce_2++;
|
extranonce_2++;
|
||||||
|
|
||||||
@ -191,13 +196,15 @@ void runASIC(void * task_id) {
|
|||||||
// make sure that another task doesn't mess with the data while
|
// make sure that another task doesn't mess with the data while
|
||||||
// we are using it
|
// we are using it
|
||||||
pthread_mutex_lock(&job_mutex);
|
pthread_mutex_lock(&job_mutex);
|
||||||
if (current_difficulty != mMiner.poolDifficulty) {
|
nerdnos_create_job(&mWorker, &mJob, &asic_jobs[asic_job_id], extranonce_2, mMiner.poolDifficulty);
|
||||||
current_difficulty = mMiner.poolDifficulty;
|
pthread_mutex_unlock(&job_mutex);
|
||||||
|
|
||||||
|
// don't send difficulty while the job mutex is locked
|
||||||
|
if (current_difficulty != asic_jobs[asic_job_id].pool_diff) {
|
||||||
|
current_difficulty = asic_jobs[asic_job_id].pool_diff;
|
||||||
nerdnos_set_asic_difficulty(current_difficulty);
|
nerdnos_set_asic_difficulty(current_difficulty);
|
||||||
Serial.printf("Set difficulty to %lu\n", current_difficulty);
|
Serial.printf("Set difficulty to %lu\n", current_difficulty);
|
||||||
}
|
}
|
||||||
nerdnos_create_job(&mWorker, &mJob, &asic_jobs[asic_job_id], extranonce_2, current_difficulty);
|
|
||||||
pthread_mutex_unlock(&job_mutex);
|
|
||||||
|
|
||||||
// send the job and
|
// send the job and
|
||||||
nerdnos_send_work(&asic_jobs[asic_job_id], asic_job_id);
|
nerdnos_send_work(&asic_jobs[asic_job_id], asic_job_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user