Skip to content

Commit

Permalink
pre selected frequency and voltage
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-wilson committed Oct 1, 2023
1 parent 75c70a3 commit 10caab2
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,76 @@ <h2>Settings</h2>
<label>Stratum User: </label>
<input formControlName="stratumUser" type="text">
</div>
<div class="form-group">
<label>Frequency </label>
<input formControlName="frequency" type="number">
</div>
<div class="form-group">
<label>Core Voltage</label>
<input formControlName="coreVoltage" type="number">
</div>

<ng-container *ngIf="!devToolsOpen && ASICModel == eASICModel.BM1366">

<div class="form-group">
<label>Frequency </label>
<select formControlName="frequency">
<option value="400">400</option>
<option value="425">425</option>
<option value="450">450</option>
<option value="475">475</option>
<option value="485">485 (default)</option>
<option value="500">500</option>
<option value="525">525</option>
<option value="550">550</option>
<option value="575">575</option>
</select>
</div>

<div class="form-group">
<label>Core Voltage </label>
<select formControlName="coreVoltage">
<option value="1100">1100</option>
<option value="1150">1150</option>
<option value="1200">1200 (default)</option>
<option value="1250">1250</option>
<option value="1300">1300</option>
</select>
</div>
</ng-container>

<ng-container *ngIf="!devToolsOpen && ASICModel == eASICModel.BM1397">

<div class="form-group">
<label>Frequency </label>
<select formControlName="frequency">
<option value="400">400</option>
<option value="425">425 (default)</option>
<option value="450">450</option>
<option value="475">475</option>
<option value="485">485</option>
<option value="500">500</option>
<option value="525">525</option>
<option value="550">550</option>
<option value="575">575</option>
</select>
</div>

<div class="form-group">
<label>Core Voltage </label>
<select formControlName="coreVoltage">
<option value="1300">1300</option>
<option value="1350">1350</option>
<option value="1400">1400 (default)</option>
<option value="1450">1450</option>
<option value="1500">1500</option>
</select>
</div>
</ng-container>

<ng-container *ngIf="devToolsOpen === true">
<div class="form-group">
<label>Frequency </label>
<input formControlName="frequency" type="number">
</div>

<div class="form-group">
<label>Core Voltage</label>
<input formControlName="coreVoltage" type="number">
</div>
</ng-container>


</form>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
input {
min-width: 500px
min-width: 250px;
max-width: 90%;
}

select {
min-width: 268px;
max-width: 90%;
}

.restart {
margin-bottom: 1.5rem;

}

@media only screen and (min-width:900px) {

input {
min-width: 500px
}

select {
min-width: 518px
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ToastrService } from 'ngx-toastr';
import { LoadingService } from 'src/app/services/loading.service';
import { SystemService } from 'src/app/services/system.service';
import { eASICModel } from 'src/models/enum/eASICModel';

@Component({
selector: 'app-edit',
Expand All @@ -17,16 +18,26 @@ export class EditComponent {
public firmwareUpdateProgress: number | null = null;
public websiteUpdateProgress: number | null = null;


public devToolsOpen: boolean = false;
public eASICModel = eASICModel;
public ASICModel!: eASICModel;

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

window.addEventListener('resize', this.checkDevTools);
this.checkDevTools();

this.systemService.getInfo()
.pipe(this.loadingService.lockUIUntilComplete())
.subscribe(info => {
this.ASICModel = info.ASICModel;
this.form = this.fb.group({
stratumURL: [info.stratumURL, [Validators.required]],
stratumPort: [info.stratumPort, [Validators.required]],
Expand All @@ -38,9 +49,26 @@ export class EditComponent {
});
});
}
private checkDevTools = () => {
if (
window.outerWidth - window.innerWidth > 160 ||
window.outerHeight - window.innerHeight > 160
) {
this.devToolsOpen = true;
} else {
this.devToolsOpen = false;
}
};

public updateSystem() {
this.systemService.updateSystem(this.form.value)

const form = this.form.value;

form.frequency = parseInt(form.frequency);
form.coreVoltage = parseInt(form.coreVoltage);


this.systemService.updateSystem(form)
.pipe(this.loadingService.lockUIUntilComplete())
.subscribe({
next: () => {
Expand Down Expand Up @@ -124,4 +152,9 @@ export class EditComponent {
});
this.toastr.success('Success!', 'Bitaxe restarted');
}





}
43 changes: 22 additions & 21 deletions main/http_server/axe-os/src/app/services/system.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HttpClient, HttpEvent } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { delay, Observable, of } from 'rxjs';
import { eASICModel } from 'src/models/enum/eASICModel';
import { ISystemInfo } from 'src/models/ISystemInfo';

import { environment } from '../../environments/environment';
Expand All @@ -20,27 +21,27 @@ export class SystemService {
} else {
return of(
{
"power": 11.670000076293945,
"voltage": 5208.75,
"current": 2237.5,
"fanSpeed": 82,
"temp": 60,
"hashRate": 0,
"bestDiff": "0",
"freeHeap": 200504,
"coreVoltage": 1188,
"ssid": "skimadtrees-secure",
"wifiPass": "password",
"wifiStatus": "Connected!",
"sharesAccepted": 1,
"sharesRejected": 0,
"uptimeSeconds": 38,
"ASICModel": "BM1366",
"stratumURL": "192.168.1.242",
"stratumPort": 3333,
"stratumUser": "bc1q99n3pu025yyu0jlywpmwzalyhm36tg5u37w20d.bitaxe-U1",
"frequency": 485,
"version": "2.0",
power: 11.670000076293945,
voltage: 5208.75,
current: 2237.5,
fanSpeed: 82,
temp: 60,
hashRate: 0,
bestDiff: "0",
freeHeap: 200504,
coreVoltage: 1200,
ssid: "default",
wifiPass: "password",
wifiStatus: "Connected!",
sharesAccepted: 1,
sharesRejected: 0,
uptimeSeconds: 38,
ASICModel: eASICModel.BM1366,
stratumURL: "192.168.1.242",
stratumPort: 3333,
stratumUser: "bc1q99n3pu025yyu0jlywpmwzalyhm36tg5u37w20d.bitaxe-U1",
frequency: 485,
version: "2.0",
}
).pipe(delay(1000));
}
Expand Down
4 changes: 3 additions & 1 deletion main/http_server/axe-os/src/models/ISystemInfo.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { eASICModel } from './enum/eASICModel';

export interface ISystemInfo {

power: number,
Expand All @@ -15,7 +17,7 @@ export interface ISystemInfo {
sharesAccepted: number,
sharesRejected: number,
uptimeSeconds: number,
ASICModel: string,
ASICModel: eASICModel,
stratumURL: string,
stratumPort: number,
stratumUser: string,
Expand Down
4 changes: 4 additions & 0 deletions main/http_server/axe-os/src/models/enum/eASICModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum eASICModel {
BM1366 = 'BM1366',
BM1397 = 'BM1397'
}
3 changes: 2 additions & 1 deletion main/http_server/axe-os/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ button {

}

input {
input,
select {

font-size: 1rem;
color: rgba(255, 255, 255, 0.87);
Expand Down

0 comments on commit 10caab2

Please sign in to comment.