Skip to content

Commit

Permalink
Merge branch 'skot:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SatsForFreedom authored Sep 8, 2023
2 parents f9ad1eb + 712c670 commit d8d5a8b
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
BasedOnStyle: LLVM
UseTab: false
IndentWidth: 4
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 132
DerivePointerAlignment: false
PointerAlignment: Middle
AllowShortFunctionsOnASingleLine: None
BreakBeforeBraces: Custom
BraceWrapping:
AfterEnum: true
AfterStruct: true
AfterFunction: true
AfterNamespace: true
AfterUnion: true
AfterExternBlock: true
SplitEmptyFunction: false
SpaceAfterCStyleCast: true
8 changes: 4 additions & 4 deletions components/bm1397/include/common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef COMMON_H_
#define COMMON_H_

#include <stdint.h>

typedef struct __attribute__((__packed__))
{
uint8_t job_id;
Expand All @@ -13,8 +15,7 @@ static unsigned char _reverse_bits(unsigned char num)
unsigned char reversed = 0;
int i;

for (i = 0; i < 8; i++)
{
for (i = 0; i < 8; i++) {
reversed <<= 1; // Left shift the reversed variable by 1
reversed |= num & 1; // Use bitwise OR to set the rightmost bit of reversed to the current bit of num
num >>= 1; // Right shift num by 1 to get the next bit
Expand All @@ -27,8 +28,7 @@ static int _largest_power_of_two(int num)
{
int power = 0;

while (num > 1)
{
while (num > 1) {
num = num >> 1;
power++;
}
Expand Down
2 changes: 1 addition & 1 deletion main/http_server/axe-os/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ yarn-error.log

# Visual Studio Code
.vscode/*
!.vscode/settings.json
# !.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
Expand Down
4 changes: 3 additions & 1 deletion main/http_server/axe-os/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { HeaderComponent } from './components/header/header.component';
import { HomeComponent } from './components/home/home.component';
import { LoadingComponent } from './components/loading/loading.component';
import { ANSIPipe } from './pipes/ansi.pipe';
import { DateAgoPipe } from './pipes/date-ago.pipe';

const components = [
AppComponent,
Expand All @@ -25,7 +26,8 @@ const components = [
EditComponent,
HomeComponent,
LoadingComponent,
ANSIPipe
ANSIPipe,
DateAgoPipe
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ <h2>Edit</h2>

</form>
</ng-container>
<div>You must restart this device after saving for changes to take effect.</div>
<div class="mt-2">
<button (click)="updateSystem()" class="btn btn-primary mr-2">Save</button>
<button [routerLink]="['/']" class="btn btn-secondary">Cancel</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ <h2>Overview</h2>
<td>{{info.ASICModel}}</td>
</tr>
<tr>
<td>Uptime (seconds):</td>
<td>{{info.uptimeSeconds}}</td>
<td>Uptime:</td>
<td>{{info.uptimeSeconds | dateAgo}}</td>

</tr>
<tr>
Expand Down
8 changes: 8 additions & 0 deletions main/http_server/axe-os/src/app/pipes/date-ago.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { DateAgoPipe } from './date-ago.pipe';

describe('DateAgoPipe', () => {
it('create an instance', () => {
const pipe = new DateAgoPipe();
expect(pipe).toBeTruthy();
});
});
38 changes: 38 additions & 0 deletions main/http_server/axe-os/src/app/pipes/date-ago.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'dateAgo',
pure: true
})
export class DateAgoPipe implements PipeTransform {

transform(value: any, args?: any): any {
if (value) {
value = new Date().getTime() - value * 1000;
const seconds = Math.floor((+new Date() - +new Date(value)) / 1000);
if (seconds < 29) // less than 30 seconds ago will show as 'Just now'
return 'Just now';
const intervals: { [key: string]: number } = {
'year': 31536000,
'month': 2592000,
'week': 604800,
'day': 86400,
'hour': 3600,
'minute': 60,
'second': 1
};
let counter;
for (const i in intervals) {
counter = Math.floor(seconds / intervals[i]);
if (counter > 0)
if (counter === 1) {
return counter + ' ' + i + ''; // singular (1 day ago)
} else {
return counter + ' ' + i + 's'; // plural (2 days ago)
}
}
}
return value;
}

}

0 comments on commit d8d5a8b

Please sign in to comment.