Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added haptic engine
added text to speech for bluetooth scale connection
added sort of images
added indicator that machines are connected
  • Loading branch information
graphefruit committed May 16, 2024
1 parent 5f98a15 commit f3d26a2
Show file tree
Hide file tree
Showing 27 changed files with 556 additions and 40 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"cordova-plugin-ionic-webview": "^5.0.1",
"cordova-plugin-screen-orientation": "github:apache/cordova-plugin-screen-orientation",
"cordova-plugin-splashscreen": "^6.0.1",
"cordova-plugin-vibration": "^3.1.1",
"cordova-plugin-x-socialsharing": "^6.0.4",
"cordova-sqlite-storage": "^5.1.0",
"elliptic": ">=6.5.4",
Expand Down Expand Up @@ -233,7 +234,8 @@
"ACCESS_BACKGROUND_LOCATION": "false",
"BLUETOOTH_RESTORE_STATE": "false"
},
"cordova-plugin-screen-orientation": {}
"cordova-plugin-screen-orientation": {},
"cordova-plugin-vibration": {}
},
"platforms": [
"android",
Expand Down
22 changes: 22 additions & 0 deletions src/app/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,19 @@ ion-tab-button.tab-selected {
position: absolute;
top: 0;
right: 10px;
background: rgba(255, 255, 255, 0.8);
}
.position-absolute-button-sort-left {
position: absolute;
top: 0px;
left: 0px;
background: rgba(255, 255, 255, 0.8);
}
.position-absolute-button-sort-right {
position: absolute;
top: 0;
left: 70px;
background: rgba(255, 255, 255, 0.8);
}


Expand Down Expand Up @@ -1035,3 +1048,12 @@ loading-popover {
}
}
}

ion-chip.machine-connected {
background-color: rgba(5, 199, 147,0.4);
}
ion-chip.machine-disconnected {

background-color: rgba(204, 51, 17,0.4);

}
22 changes: 22 additions & 0 deletions src/app/brew/brew-add/brew-add.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@
</ion-button>
</ion-buttons>
<ion-buttons slot="end">
<ng-container *ngIf='brewBrewing?.brewBrewingPreparationDeviceEl?.hasAPreparationDeviceSet()'>
<ng-container *ngIf='brewBrewing?.brewBrewingPreparationDeviceEl?.getDataPreparationDeviceType() === PreparationDeviceType.METICULOUS'>
<ion-chip outline='true' class='machine-connected' *ngIf='brewBrewing?.brewBrewingPreparationDeviceEl?.preparationDeviceConnected()'>
<ion-icon name="beanconqueror-meticulous-logo" size='large'></ion-icon>
<ion-icon style='margin-left: -10px;' color="dark" name="beanconqueror-wifi"></ion-icon>
</ion-chip>
<ion-chip outline='true' class='machine-disconnected' *ngIf='!brewBrewing?.brewBrewingPreparationDeviceEl?.preparationDeviceConnected()'>
<ion-icon name="beanconqueror-meticulous-logo" size='large'></ion-icon>
<ion-icon style='margin-left: -10px;' color="dark" name="beanconqueror-no-wifi"></ion-icon>
</ion-chip>
</ng-container>
<ng-container *ngIf='brewBrewing?.brewBrewingPreparationDeviceEl?.getDataPreparationDeviceType() === PreparationDeviceType.XENIA'>
<ion-chip outline='true' class='machine-connected' *ngIf='brewBrewing?.brewBrewingPreparationDeviceEl?.preparationDeviceConnected()'>
<ion-icon name="beanconqueror-xenia-logo" size='large'></ion-icon>
<ion-icon style='margin-left: -10px;' color="dark" name="beanconqueror-wifi"></ion-icon>
</ion-chip>
<ion-chip outline='true' class='machine-disconnected' *ngIf='!brewBrewing?.brewBrewingPreparationDeviceEl?.preparationDeviceConnected()'>
<ion-icon name="beanconqueror-xenia-logo" size='large'></ion-icon>
<ion-icon style='margin-left: -10px;' color="dark" name="beanconqueror-no-wifi"></ion-icon>
</ion-chip>
</ng-container>
</ng-container>
<ion-button (click)="tareScale()" *ngIf="smartScaleConnected() && smartScaleSupportsTaring()" class="big-icon-only" fill="clear" tappable>
<ion-icon name="beanconqueror-scale-tare" slot="icon-only"></ion-icon>
</ion-button>
Expand Down
14 changes: 12 additions & 2 deletions src/app/brew/brew-add/brew-add.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ import {
CoffeeBluetoothDevicesService,
CoffeeBluetoothServiceEvent,
} from '../../../services/coffeeBluetoothDevices/coffee-bluetooth-devices.service';
import { PreparationDeviceType } from '../../../classes/preparationDevice';
import { UIHelper } from '../../../services/uiHelper';
import { VisualizerService } from '../../../services/visualizerService/visualizer-service.service';
import { Subscription } from 'rxjs';
import { HapticService } from '../../../services/hapticService/haptic.service';
import { PreparationDeviceType } from '../../../classes/preparationDevice';

declare var Plotly;
declare var window;
Expand Down Expand Up @@ -91,7 +92,8 @@ export class BrewAddComponent implements OnInit {
private readonly bleManager: CoffeeBluetoothDevicesService,
private readonly uiHelper: UIHelper,
private readonly visualizerService: VisualizerService,
private readonly changeDetectorRef: ChangeDetectorRef
private readonly changeDetectorRef: ChangeDetectorRef,
private readonly hapticService: HapticService
) {
// Initialize to standard in drop down

Expand Down Expand Up @@ -209,6 +211,12 @@ export class BrewAddComponent implements OnInit {
const scale: BluetoothScale = this.bleManager.getScale();
if (scale) {
scale.tare();
if (
this.settings.haptic_feedback_active &&
this.settings.haptic_feedback_tare
) {
this.hapticService.vibrate();
}
}
}

Expand Down Expand Up @@ -452,4 +460,6 @@ export class BrewAddComponent implements OnInit {
this.bluetoothSubscription = undefined;
}
}

protected readonly PreparationDeviceType = PreparationDeviceType;
}
22 changes: 22 additions & 0 deletions src/app/brew/brew-edit/brew-edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@
</ion-button>
</ion-buttons>
<ion-buttons slot="end">
<ng-container *ngIf='brewBrewing?.brewBrewingPreparationDeviceEl?.hasAPreparationDeviceSet()'>
<ng-container *ngIf='brewBrewing?.brewBrewingPreparationDeviceEl?.getDataPreparationDeviceType() === PreparationDeviceType.METICULOUS'>
<ion-chip outline='true' class='machine-connected' *ngIf='brewBrewing?.brewBrewingPreparationDeviceEl?.preparationDeviceConnected()'>
<ion-icon name="beanconqueror-meticulous-logo" size='large'></ion-icon>
<ion-icon style='margin-left: -10px;' color="dark" name="beanconqueror-wifi"></ion-icon>
</ion-chip>
<ion-chip outline='true' class='machine-disconnected' *ngIf='!brewBrewing?.brewBrewingPreparationDeviceEl?.preparationDeviceConnected()'>
<ion-icon name="beanconqueror-meticulous-logo" size='large'></ion-icon>
<ion-icon style='margin-left: -10px;' color="dark" name="beanconqueror-no-wifi"></ion-icon>
</ion-chip>
</ng-container>
<ng-container *ngIf='brewBrewing?.brewBrewingPreparationDeviceEl?.getDataPreparationDeviceType() === PreparationDeviceType.XENIA'>
<ion-chip outline='true' class='machine-connected' *ngIf='brewBrewing?.brewBrewingPreparationDeviceEl?.preparationDeviceConnected()'>
<ion-icon name="beanconqueror-xenia-logo" size='large'></ion-icon>
<ion-icon style='margin-left: -10px;' color="dark" name="beanconqueror-wifi"></ion-icon>
</ion-chip>
<ion-chip outline='true' class='machine-disconnected' *ngIf='!brewBrewing?.brewBrewingPreparationDeviceEl?.preparationDeviceConnected()'>
<ion-icon name="beanconqueror-xenia-logo" size='large'></ion-icon>
<ion-icon style='margin-left: -10px;' color="dark" name="beanconqueror-no-wifi"></ion-icon>
</ion-chip>
</ng-container>
</ng-container>
<ion-button (click)="tareScale()" *ngIf="smartScaleConnected() && smartScaleSupportsTaring()" class="big-icon-only" fill="clear" tappable>
<ion-icon name="beanconqueror-scale-tare" slot="icon-only"></ion-icon>
</ion-button>
Expand Down
13 changes: 11 additions & 2 deletions src/app/brew/brew-edit/brew-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import { Settings } from '../../../classes/settings/settings';
import { SettingsPopoverBluetoothActionsComponent } from '../../settings/settings-popover-bluetooth-actions/settings-popover-bluetooth-actions.component';
import { BluetoothScale, SCALE_TIMER_COMMAND } from '../../../classes/devices';
import { CoffeeBluetoothDevicesService } from '../../../services/coffeeBluetoothDevices/coffee-bluetooth-devices.service';
import { PreparationDeviceType } from '../../../classes/preparationDevice';
import { UIAlert } from '../../../services/uiAlert';
import { VisualizerService } from '../../../services/visualizerService/visualizer-service.service';
import { HapticService } from '../../../services/hapticService/haptic.service';
import { PreparationDeviceType } from '../../../classes/preparationDevice';
declare var Plotly;
declare var window;
@Component({
Expand All @@ -36,6 +37,7 @@ export class BrewEditComponent implements OnInit {
public showFooter: boolean = true;
private initialBeanData: string = '';
private disableHardwareBack;
public readonly PreparationDeviceType = PreparationDeviceType;
constructor(
private readonly modalController: ModalController,
private readonly navParams: NavParams,
Expand All @@ -50,7 +52,8 @@ export class BrewEditComponent implements OnInit {
private readonly insomnia: Insomnia,
private readonly bleManager: CoffeeBluetoothDevicesService,
private readonly uiAlert: UIAlert,
private readonly visualizerService: VisualizerService
private readonly visualizerService: VisualizerService,
private readonly hapticService: HapticService
) {
this.settings = this.uiSettingsStorage.getSettings();
// Moved from ionViewDidEnter, because of Ionic issues with ion-range
Expand Down Expand Up @@ -155,6 +158,12 @@ export class BrewEditComponent implements OnInit {
const scale: BluetoothScale = this.bleManager.getScale();
if (scale) {
scale.tare();
if (
this.settings.haptic_feedback_active &&
this.settings.haptic_feedback_tare
) {
this.hapticService.vibrate();
}
}
}
public async updateBrew() {
Expand Down
91 changes: 91 additions & 0 deletions src/app/settings/settings.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,97 @@ <h2>{{"VISUALIZER.UPLOAD_AUTOMATIC" | translate}}</h2>
</ion-card-content>
</ion-card>

<ion-card class="margin-top-20">
<ion-card-content>
<ion-card-title>{{"PAGE_SETTINGS_TEXT_TO_SPEECH_SECTION" | translate}}</ion-card-title>
<ion-item lines='none'>
<p style="display: inline;">{{"EXPERIMENTAL_FEATURE_DISCLAIMER" | translate}}</p>
</ion-item>
<ion-item>
<ion-checkbox label-placement='start' (ngModelChange)="saveSettings();" [(ngModel)]="settings.text_to_speech_active">
<div class='ion-label'>{{"TEXT_TO_SPEECH.ACTIVATE" | translate}}</div>
</ion-checkbox>
</ion-item>
<ng-container *ngIf='settings.text_to_speech_active'>
<ion-item lines='none'>
<ion-label class="ion-margin-end">
<p>{{"TEXT_TO_SPEECH.PITCH" | translate}}</p>
</ion-label>
</ion-item>
<ion-item style="top:-10px;">
<ion-range [disabled]='isScrolling' style="padding-left:20px;padding-top:0;padding-bottom:0px;padding-right:0px;" min="0" snaps="true" max="2"
step="0.1" (ngModelChange)="saveSettings()" [(ngModel)]="settings.text_to_speech_pitch">
<div class='ion-label' slot="end">{{settings.text_to_speech_pitch | number : '.0-1'}}</div>
</ion-range>
</ion-item>
<ion-item lines='none'>
<ion-label class="ion-margin-end">
<p>{{"TEXT_TO_SPEECH.RATE" | translate}}</p>
</ion-label>
</ion-item>
<ion-item style="top:-10px;">
<ion-range [disabled]='isScrolling' style="padding-left:20px;padding-top:0;padding-bottom:0px;padding-right:0px;" min="0.1" snaps="true" max="10"
step="0.1" (ngModelChange)="saveSettings()" [(ngModel)]="settings.text_to_speech_rate">
<div class='ion-label' slot="end">{{settings.text_to_speech_rate | number : '.0-1'}}</div>
</ion-range>
</ion-item>
<ion-item lines='none'>
<ion-label class="ion-margin-end">
<p>{{"TEXT_TO_SPEECH.SPEAK_EVERY_MS" | translate}}</p>
</ion-label>
</ion-item>
<ion-item style="top:-10px;">
<ion-range [disabled]='isScrolling' style="padding-left:20px;padding-top:0;padding-bottom:0px;padding-right:0px;" min="250" snaps="true" max="1000"
step="50" (ngModelChange)="saveSettings()" [(ngModel)]="settings.text_to_speech_interval_rate">
<div class='ion-label' slot="end">{{settings.text_to_speech_interval_rate | number : '.0'}}</div>
</ion-range>
</ion-item>

<ion-item (click)="testSpeak()" tappable button>
<ion-label>
<h2>{{"TEXT_TO_SPEECH.TEST_SPEAK" | translate}}</h2>
<p>{{"TEXT_TO_SPEECH.FOLLOWING_NUMBERS_WILL_BE_TEST_SPOKEN" | translate}}: 182.5, 28, 1072, 1.2, 0.1, 203.5</p>
</ion-label>
<ion-icon name="chevron-forward-outline" slot="end"></ion-icon>
</ion-item>
</ng-container>
</ion-card-content>
</ion-card>

<ion-card class="margin-top-20">
<ion-card-content>
<ion-card-title>
{{"PAGE_SETTINGS_HAPTIC_FEEDBACK_SECTION" | translate}}
</ion-card-title>
<ion-item lines='none'>
<p style="display: inline;">{{"EXPERIMENTAL_FEATURE_DISCLAIMER" | translate}}</p>
</ion-item>
<ion-item>
<ion-checkbox label-placement='start' (ngModelChange)="saveSettings();" [(ngModel)]="settings.haptic_feedback_active">
<div class='ion-label'>{{"HAPTIC_FEEDBACK.ACTIVATE" | translate}}</div>
</ion-checkbox>
</ion-item>
<ng-container *ngIf='settings.haptic_feedback_active'>
<ion-item>
<ion-checkbox label-placement='start' (ngModelChange)="saveSettings();" [(ngModel)]="settings.haptic_feedback_brew_started">
<div class='ion-label'>{{"HAPTIC_FEEDBACK.BREW_STARTED" | translate}}</div>
</ion-checkbox>
</ion-item>
<ion-item>
<ion-checkbox label-placement='start' (ngModelChange)="saveSettings();" [(ngModel)]="settings.haptic_feedback_brew_stopped">
<div class='ion-label'>{{"HAPTIC_FEEDBACK.BREW_STOPPED" | translate}}</div>
</ion-checkbox>
</ion-item>

<ion-item>
<ion-checkbox label-placement='start' (ngModelChange)="saveSettings();" [(ngModel)]="settings.haptic_feedback_tare">
<div class='ion-label'>{{"HAPTIC_FEEDBACK.TARE" | translate}}</div>
</ion-checkbox>
</ion-item>
</ng-container>
</ion-card-content>
</ion-card>

</div>
<div *ngSwitchCase="'bluetoothscale'">
<ion-card>
Expand Down
18 changes: 17 additions & 1 deletion src/app/settings/settings.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import { VISUALIZER_SERVER_ENUM } from '../../enums/settings/visualizerServer';
import { VisualizerService } from '../../services/visualizerService/visualizer-service.service';
import { UIGraphStorage } from '../../services/uiGraphStorage.service';
import { Graph } from '../../classes/graph/graph';
import { TextToSpeechService } from '../../services/textToSpeech/text-to-speech.service';

declare var cordova: any;
declare var device: any;
Expand Down Expand Up @@ -160,7 +161,8 @@ export class SettingsPage implements OnInit {
private readonly eventQueue: EventQueueService,
private readonly uiFileHelper: UIFileHelper,
private readonly uiExportImportHelper: UIExportImportHelper,
private readonly visualizerService: VisualizerService
private readonly visualizerService: VisualizerService,
private readonly textToSpeech: TextToSpeechService
) {
this.__initializeSettings();
this.debounceLanguageFilter
Expand Down Expand Up @@ -822,6 +824,20 @@ export class SettingsPage implements OnInit {
}
}

public testSpeak() {
this.textToSpeech.readAndSetTTLSettings();
let speakTestCount: number = 0;
const testSpeakArray = ['182.5', '28', '1072', '1.2', '0.1', '203.5'];
const speakTestIntv = setInterval(() => {
this.textToSpeech.speak(testSpeakArray[speakTestCount]);

speakTestCount = speakTestCount + 1;
if (speakTestCount > 5) {
clearInterval(speakTestIntv);
}
}, this.settings.text_to_speech_interval_rate);
}

public async uploadBrewsToVisualizer() {
const brewEntries = this.uiBrewStorage.getAllEntries();
const uploadShots = brewEntries.filter(
Expand Down
13 changes: 13 additions & 0 deletions src/assets/custom-ion-icons/beanconqueror-meticulous-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/custom-ion-icons/beanconqueror-no-wifi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f3d26a2

Please sign in to comment.