Skip to content

Commit

Permalink
Calculate rate from signature and display it in broadcast screen
Browse files Browse the repository at this point in the history
  • Loading branch information
isuretpolos committed Jul 7, 2023
1 parent 14081e4 commit cf23ffb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,22 @@ public void controlEvent(ControlEvent theEvent) {
}
}

public String generateRate(String input) {
// Convert user input to a string and remove any whitespace
String inputStr = input.trim();

// Calculate the radionic rate as a numerical value
double rate = 0;
for (char c : inputStr.toCharArray()) {
rate += (int) c;
}
rate = Math.sqrt(rate);

// Format the radionic rate as a string and return it
String rateStr = String.format("%.2f", rate);
return rateStr;
}

private void prepareExitHandler() {

Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.isuret.polos.AetherOnePi.processing2.elements;

import controlP5.Textfield;
import de.isuret.polos.AetherOnePi.processing2.AetherOneConstants;
import de.isuret.polos.AetherOnePi.processing2.AetherOneUI;
import de.isuret.polos.AetherOnePi.processing2.events.MouseClickObserver;

Expand All @@ -13,9 +15,12 @@ public BroadcastScreen(AetherOneUI p) {

@Override
public void draw() {
// p.noStroke();
// p.fill(198, 220, 255, 50f);
// p.rect(40,120,1205,410);
p.fill(255);

String signature = ((Textfield) p.getGuiElements().getCp5().get(AetherOneConstants.SIGNATURE)).getText();
if (signature.length() > 0) {
p.text("Rate: " + p.generateRate(signature), 900, 90);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import controlP5.CColor;
import controlP5.ControlP5;
import controlP5.Textfield;
import de.isuret.polos.AetherOnePi.domain.AnalysisResult;
import de.isuret.polos.AetherOnePi.domain.Rate;
import de.isuret.polos.AetherOnePi.domain.RateObject;
import de.isuret.polos.AetherOnePi.domain.Settings;
import de.isuret.polos.AetherOnePi.processing2.AetherOneConstants;
import de.isuret.polos.AetherOnePi.processing2.AetherOneUI;
import de.isuret.polos.AetherOnePi.utils.AetherOnePiProcessingConfiguration;
import processing.core.PFont;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public void controlEvent(ControlEvent theEvent) {
return;
}

if ("BROADCAST NOW".equals(name)) {
if (AetherOneConstants.BROADCAST_NOW.equals(name)) {
broadcastNow();
return;
}
Expand Down

0 comments on commit cf23ffb

Please sign in to comment.