Skip to content

Commit

Permalink
Merge branch 'master' into simplify_i2c_screen
Browse files Browse the repository at this point in the history
  • Loading branch information
WantClue authored Oct 9, 2024
2 parents 8597391 + 7589e6e commit d729a3a
Show file tree
Hide file tree
Showing 37 changed files with 539 additions and 212 deletions.
2 changes: 1 addition & 1 deletion components/asic/bm1366.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ static uint8_t _send_init(uint64_t frequency, uint16_t asic_count)

// unsigned char init137[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x14, 0x00, 0x00, 0x00, 0xFF, 0x08};
// _send_simple(init137, 11);
BM1366_set_job_difficulty_mask(BM1366_INITIAL_DIFFICULTY);
BM1366_set_job_difficulty_mask(BM1366_ASIC_DIFFICULTY);

unsigned char init138[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x54, 0x00, 0x00, 0x00, 0x03, 0x1D};
_send_simple(init138, 11);
Expand Down
2 changes: 1 addition & 1 deletion components/asic/bm1368.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ uint8_t BM1368_init(uint64_t frequency, uint16_t asic_count)
vTaskDelay(pdMS_TO_TICKS(500));
}

BM1368_set_job_difficulty_mask(BM1368_INITIAL_DIFFICULTY);
BM1368_set_job_difficulty_mask(BM1368_ASIC_DIFFICULTY);

do_frequency_ramp_up((float)frequency);

Expand Down
2 changes: 1 addition & 1 deletion components/asic/bm1370.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ static uint8_t _send_init(uint64_t frequency, uint16_t asic_count)
//set ticket mask
// unsigned char init11[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x14, 0x00, 0x00, 0x00, 0xFF, 0x08};
// _send_simple(init11, 11);
BM1370_set_job_difficulty_mask(BM1370_INITIAL_DIFFICULTY);
BM1370_set_job_difficulty_mask(BM1370_ASIC_DIFFICULTY);

//Analog Mux Control
unsigned char init12[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x54, 0x00, 0x00, 0x00, 0x03, 0x1D};
Expand Down
2 changes: 1 addition & 1 deletion components/asic/bm1397.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static uint8_t _send_init(uint64_t frequency, uint16_t asic_count)
unsigned char init4[9] = {0x00, CORE_REGISTER_CONTROL, 0x80, 0x00, 0x80, 0x74}; // init4 - init_4_?
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init4, 6, BM1937_SERIALTX_DEBUG);

BM1397_set_job_difficulty_mask(256);
BM1397_set_job_difficulty_mask(BM1397_ASIC_DIFFICULTY);

unsigned char init5[9] = {0x00, PLL3_PARAMETER, 0xC0, 0x70, 0x01, 0x11}; // init5 - pll3_parameter
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init5, 6, BM1937_SERIALTX_DEBUG);
Expand Down
2 changes: 1 addition & 1 deletion components/asic/include/bm1366.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define ASIC_BM1366_JOB_FREQUENCY_MS 2000

#define CRC5_MASK 0x1F
#define BM1366_INITIAL_DIFFICULTY 256
#define BM1366_ASIC_DIFFICULTY 256

#define BM1366_SERIALTX_DEBUG false
#define BM1366_SERIALRX_DEBUG false
Expand Down
2 changes: 1 addition & 1 deletion components/asic/include/bm1368.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define ASIC_BM1368_JOB_FREQUENCY_MS 500

#define CRC5_MASK 0x1F
#define BM1368_INITIAL_DIFFICULTY 256
#define BM1368_ASIC_DIFFICULTY 256

#define BM1368_SERIALTX_DEBUG false
#define BM1368_SERIALRX_DEBUG false
Expand Down
3 changes: 1 addition & 2 deletions components/asic/include/bm1370.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#define ASIC_BM1370_JOB_FREQUENCY_MS 500

#define CRC5_MASK 0x1F

#define BM1370_INITIAL_DIFFICULTY 256
#define BM1370_ASIC_DIFFICULTY 256

#define BM1370_SERIALTX_DEBUG true
#define BM1370_SERIALRX_DEBUG false
Expand Down
2 changes: 1 addition & 1 deletion components/asic/include/bm1397.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define ASIC_BM1397_JOB_FREQUENCY_MS 20 //not currently used

#define CRC5_MASK 0x1F
#define BM1397_INITIAL_DIFFICULTY 256
#define BM1397_ASIC_DIFFICULTY 256

#define BM1937_SERIALTX_DEBUG false
#define BM1937_SERIALRX_DEBUG false
Expand Down
2 changes: 2 additions & 0 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ SRCS
"TPS546.c"
"vcore.c"
"work_queue.c"
"nvs_device.c"
"./http_server/http_server.c"
"./self_test/self_test.c"
"./tasks/stratum_task.c"
Expand All @@ -27,6 +28,7 @@ INCLUDE_DIRS
"."
"tasks"
"http_server"
"self_test"
"../components/asic/include"
"../components/connect/include"
"../components/dns_server/include"
Expand Down
2 changes: 1 addition & 1 deletion main/global_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ typedef struct
uint16_t voltage_domain;
AsicFunctions ASIC_functions;
double asic_job_frequency_ms;
uint32_t initial_ASIC_difficulty;
uint32_t ASIC_difficulty;

work_queue stratum_queue;
work_queue ASIC_jobs_queue;
Expand Down
5 changes: 5 additions & 0 deletions main/http_server/axe-os/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './components/home/home.component';
import { LogsComponent } from './components/logs/logs.component';
import { SettingsComponent } from './components/settings/settings.component';
import { NetworkComponent } from './components/network/network.component';
import { SwarmComponent } from './components/swarm/swarm.component';
import { AppLayoutComponent } from './layout/app.layout.component';

Expand All @@ -20,6 +21,10 @@ const routes: Routes = [
path: 'logs',
component: LogsComponent
},
{
path: 'network',
component: NetworkComponent
},
{
path: 'settings',
component: SettingsComponent
Expand Down
4 changes: 4 additions & 0 deletions main/http_server/axe-os/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import { ToastrModule } from 'ngx-toastr';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { EditComponent } from './components/edit/edit.component';
import { NetworkEditComponent } from './components/network-edit/network.edit.component';
import { HomeComponent } from './components/home/home.component';
import { LoadingComponent } from './components/loading/loading.component';
import { LogsComponent } from './components/logs/logs.component';
import { NetworkComponent } from './components/network/network.component';
import { SettingsComponent } from './components/settings/settings.component';
import { SwarmComponent } from './components/swarm/swarm.component';
import { AppLayoutModule } from './layout/app.layout.module';
Expand All @@ -26,8 +28,10 @@ import { MessageModule } from 'primeng/message';
const components = [
AppComponent,
EditComponent,
NetworkEditComponent,
HomeComponent,
LoadingComponent,
NetworkComponent,
SettingsComponent,
LogsComponent
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
<ng-container *ngIf="form != null">
<form [formGroup]="form">

<div class="field grid p-fluid">
<label htmlFor="hostname" class="col-12 mb-2 md:col-2 md:mb-0">Hostname:</label>
<div class="col-12 md:col-10">
<input pInputText id="hostname" type="text" formControlName="hostname" />
</div>
</div>
<div class="field grid p-fluid">
<label htmlFor="ssid" class="col-12 mb-2 md:col-2 md:mb-0">WiFi SSID:</label>
<div class="col-12 md:col-10">
<input pInputText id="ssid" type="text" formControlName="ssid" />
</div>
</div>
<div class="field grid p-fluid">
<label htmlFor="wifiPass" class="col-12 mb-2 md:col-2 md:mb-0">WiFi Password:</label>
<div class="col-12 md:col-10 p-input-icon-right">
<i *ngIf="form.get('wifiPass')?.dirty" class="pi"
[ngClass]="{'pi-eye': !showWifiPassword, 'pi-eye-slash': showWifiPassword}"
(click)="toggleWifiPasswordVisibility()" style="cursor: pointer;"></i>
<input pInputText id="wifiPass" formControlName="wifiPass"
[type]="showWifiPassword ? 'text' : 'password'"
placeholder="Enter WiFi password" />
</div>
</div>
<div class="field grid p-fluid">
<label htmlFor="stratumURL" class="col-12 mb-2 md:col-2 md:mb-0">Stratum URL:</label>
<div class="col-12 md:col-10">
Expand Down Expand Up @@ -81,8 +57,13 @@
</div>
<div class="field grid p-fluid">
<label htmlFor="fallbackStratumPassword" class="col-12 mb-2 md:col-2 md:mb-0">Fallback Stratum Password:</label>
<div class="col-12 md:col-10">
<input pInputText id="fallbackStratumPassword" formControlName="fallbackStratumPassword" type="password" />
<div class="col-12 md:col-10 p-input-icon-right">
<i *ngIf="form.get('fallbackStratumPassword')?.dirty" class="pi"
[ngClass]="{'pi-eye': !showFallbackStratumPassword, 'pi-eye-slash': showFallbackStratumPassword}"
(click)="toggleFallbackStratumPasswordVisibility()" style="cursor: pointer;"></i>
<input pInputText id="fallbackStratumPassword" formControlName="fallbackStratumPassword"
[type]="showFallbackStratumPassword ? 'text' : 'password'"
placeholder="Enter fallback stratum password" />
</div>
</div>

Expand Down Expand Up @@ -172,7 +153,6 @@

</ng-container>


<div class="col-12 md:col-4">
<div class="field-checkbox">
<p-checkbox name="flipscreen" formControlName="flipscreen" inputId="flipscreen"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ export class EditComponent implements OnInit {
stratumPassword: ['*****', [Validators.required]],
fallbackStratumUser: [info.fallbackStratumUser, [Validators.required]],
fallbackStratumPassword: ['password', [Validators.required]],
hostname: [info.hostname, [Validators.required]],
ssid: [info.ssid, [Validators.required]],
wifiPass: ['*****'],
coreVoltage: [info.coreVoltage, [Validators.required]],
frequency: [info.frequency, [Validators.required]],
autofanspeed: [info.autofanspeed == 1, [Validators.required]],
Expand Down Expand Up @@ -198,12 +195,6 @@ export class EditComponent implements OnInit {

const form = this.form.getRawValue();

// Allow an empty wifi password
form.wifiPass = form.wifiPass == null ? '' : form.wifiPass;

if (form.wifiPass === '*****') {
delete form.wifiPass;
}
if (form.stratumPassword === '*****') {
delete form.stratumPassword;
}
Expand Down Expand Up @@ -232,4 +223,9 @@ export class EditComponent implements OnInit {
this.showWifiPassword = !this.showWifiPassword;
}

showFallbackStratumPassword: boolean = false;
toggleFallbackStratumPasswordVisibility() {
this.showFallbackStratumPassword = !this.showFallbackStratumPassword;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,21 @@ <h4>Loading...</h4>
<div class="card">
<h5>Power</h5>
<div class="grid text-center">
<div class="col-4">
<div class="col-6 sm:col-4">
<p-knob [min]="3" [max]="maxPower" [readonly]="true" [(ngModel)]="info.power"
valueTemplate="{value}W"></p-knob>
Power
</div>

<div class="col-4">
<div class="col-6 sm:col-4">
<p-knob [min]="4.5" [max]="5.5" [readonly]="true" [(ngModel)]="info.voltage"
valueTemplate="{value}V"
[valueColor]="info.voltage < 4.8 ? '#ff0000' : 'var(--primary-color, Black)'"></p-knob>
Input Voltage
<span class="danger" *ngIf="info.voltage < 4.8">&nbsp; Danger: Low voltage</span>
</div>

<div class="col-4">
<div class="col-6 sm:col-4">
<p-knob [min]="0.9" [max]="1.8" [readonly]="true" [(ngModel)]="info.coreVoltage"
valueTemplate="{value}V"></p-knob>
ASIC Voltage Requested
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<ng-container *ngIf="form != null">
<form [formGroup]="form">

<div class="field grid p-fluid">
<label htmlFor="hostname" class="col-12 mb-2 md:col-2 md:mb-0">Hostname:</label>
<div class="col-12 md:col-10">
<input pInputText id="hostname" type="text" formControlName="hostname" />
</div>
</div>
<div class="field grid p-fluid">
<label htmlFor="ssid" class="col-12 mb-2 md:col-2 md:mb-0">WiFi SSID:</label>
<div class="col-12 md:col-10">
<input pInputText id="ssid" type="text" formControlName="ssid" />
</div>
</div>
<div class="field grid p-fluid">
<label htmlFor="wifiPass" class="col-12 mb-2 md:col-2 md:mb-0">WiFi Password:</label>
<div class="col-12 md:col-10 p-input-icon-right">
<i *ngIf="form.get('wifiPass')?.dirty" class="pi"
[ngClass]="{'pi-eye': !showWifiPassword, 'pi-eye-slash': showWifiPassword}"
(click)="toggleWifiPasswordVisibility()" style="cursor: pointer;"></i>
<input pInputText id="wifiPass" formControlName="wifiPass"
[type]="showWifiPassword ? 'text' : 'password'"
placeholder="Enter WiFi password" />
</div>
</div>

<div class="mt-2">
<button pButton [disabled]="form.invalid" (click)="updateSystem()"
class="btn btn-primary mr-2">Save</button>
<b style="line-height: 34px;">You must restart this device after saving for changes to take effect.</b>
</div>
</form>
</ng-container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pi {
right: 1rem;
font-size: 1.5rem;
top: 1rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { NetworkEditComponent } from './network.edit.component';

describe('NetworkEditComponent', () => {
let component: NetworkEditComponent;
let fixture: ComponentFixture<NetworkEditComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [NetworkEditComponent]
});
fixture = TestBed.createComponent(NetworkEditComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ToastrService } from 'ngx-toastr';
import { startWith } from 'rxjs';
import { LoadingService } from 'src/app/services/loading.service';
import { SystemService } from 'src/app/services/system.service';

@Component({
selector: 'app-network-edit',
templateUrl: './network.edit.component.html',
styleUrls: ['./network.edit.component.scss']
})
export class NetworkEditComponent implements OnInit {

public form!: FormGroup;

@Input() uri = '';

constructor(
private fb: FormBuilder,
private systemService: SystemService,
private toastr: ToastrService,
private toastrService: ToastrService,
private loadingService: LoadingService
) {

}
ngOnInit(): void {
this.systemService.getInfo(this.uri)
.pipe(this.loadingService.lockUIUntilComplete())
.subscribe(info => {
this.form = this.fb.group({
hostname: [info.hostname, [Validators.required]],
ssid: [info.ssid, [Validators.required]],
wifiPass: ['*****'],
});

});
}


public updateSystem() {

const form = this.form.getRawValue();

// Allow an empty wifi password
form.wifiPass = form.wifiPass == null ? '' : form.wifiPass;

if (form.wifiPass === '*****') {
delete form.wifiPass;
}

this.systemService.updateSystem(this.uri, form)
.pipe(this.loadingService.lockUIUntilComplete())
.subscribe({
next: () => {
this.toastr.success('Success!', 'Saved.');
},
error: (err: HttpErrorResponse) => {
this.toastr.error('Error.', `Could not save. ${err.message}`);
}
});
}

showWifiPassword: boolean = false;
toggleWifiPasswordVisibility() {
this.showWifiPassword = !this.showWifiPassword;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="card">
<h2>Network Configuration</h2>

<app-network-edit></app-network-edit>
</div>
Loading

0 comments on commit d729a3a

Please sign in to comment.