Moved code into submodules

This commit is contained in:
Andrea Cavalli 2018-09-04 12:12:41 +02:00
parent bda1752c53
commit 899ca234ce
598 changed files with 3117 additions and 3917 deletions

View File

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.243909357">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.243909357" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.243909357" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.243909357." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.230974560" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.230974560.1020516125" name=""/>
<builder id="org.eclipse.cdt.build.core.settings.default.builder.1750223979" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.1329659482" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.164361898" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.91955504" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.587173658" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.752272386" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.808639665" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1739537780" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="PICalculator.null.699279890" name="PICalculator"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="0.243909357">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/PICalculator"/>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
<buildTargets>
<target name="TestJNI.h" path="src/main/jni" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>TestJNI.h</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="all" path="src/main/jni" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="src/main/jni" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="windows" path="src/main/jni" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>picalculatornative.dll</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
</buildTargets>
</storageModule>
</cproject>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="warppi-calculator" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
</component>
</project>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -1,27 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>PICalculator</name> <name>WarpPI</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name> <name>org.eclipse.m2e.core.maven2Builder</name>
<arguments> <arguments>
@ -30,6 +13,5 @@
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View File

@ -1,9 +1,2 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding//src/jar-specific/java=UTF-8 encoding/<project>=UTF-8
encoding//src/main/java=UTF-8
encoding//src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesis.java=UTF-8
encoding//src/main/java/it/cavallium/warppi/math/MathematicalSymbols.java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/main/rules=UTF-8
encoding//src/teavm-specific/java=UTF-8
encoding//src/test/java=UTF-8

View File

@ -1,9 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter

View File

@ -1,60 +0,0 @@
cleanup.add_default_serial_version_id=false
cleanup.add_generated_serial_version_id=true
cleanup.add_missing_annotations=true
cleanup.add_missing_deprecated_annotations=true
cleanup.add_missing_methods=true
cleanup.add_missing_nls_tags=false
cleanup.add_missing_override_annotations=true
cleanup.add_missing_override_annotations_interface_methods=true
cleanup.add_serial_version_id=true
cleanup.always_use_blocks=true
cleanup.always_use_parentheses_in_expressions=true
cleanup.always_use_this_for_non_static_field_access=false
cleanup.always_use_this_for_non_static_method_access=false
cleanup.convert_functional_interfaces=true
cleanup.convert_to_enhanced_for_loop=true
cleanup.correct_indentation=true
cleanup.format_source_code=true
cleanup.format_source_code_changes_only=false
cleanup.insert_inferred_type_arguments=false
cleanup.make_local_variable_final=true
cleanup.make_parameters_final=false
cleanup.make_private_fields_final=true
cleanup.make_type_abstract_if_missing_method=false
cleanup.make_variable_declarations_final=true
cleanup.never_use_blocks=false
cleanup.never_use_parentheses_in_expressions=false
cleanup.organize_imports=false
cleanup.qualify_static_field_accesses_with_declaring_class=false
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
cleanup.qualify_static_member_accesses_with_declaring_class=true
cleanup.qualify_static_method_accesses_with_declaring_class=false
cleanup.remove_private_constructors=true
cleanup.remove_redundant_type_arguments=true
cleanup.remove_trailing_whitespaces=false
cleanup.remove_trailing_whitespaces_all=true
cleanup.remove_trailing_whitespaces_ignore_empty=false
cleanup.remove_unnecessary_casts=true
cleanup.remove_unnecessary_nls_tags=true
cleanup.remove_unused_imports=true
cleanup.remove_unused_local_variables=false
cleanup.remove_unused_private_fields=true
cleanup.remove_unused_private_members=false
cleanup.remove_unused_private_methods=true
cleanup.remove_unused_private_types=true
cleanup.sort_members=false
cleanup.sort_members_all=false
cleanup.use_anonymous_class_creation=false
cleanup.use_blocks=true
cleanup.use_blocks_only_for_return_and_throw=false
cleanup.use_lambda=true
cleanup.use_parentheses_in_expressions=false
cleanup.use_this_for_non_static_field_access=true
cleanup.use_this_for_non_static_field_access_only_if_necessary=true
cleanup.use_this_for_non_static_method_access=true
cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup_profile=_Drake's Cleanup
cleanup_settings_version=2
eclipse.preferences.version=1
formatter_settings_version=12

View File

@ -1,4 +1,4 @@
activeProfiles=jarprofile activeProfiles=
eclipse.preferences.version=1 eclipse.preferences.version=1
resolveWorkspaceProjects=true resolveWorkspaceProjects=true
version=1 version=1

View File

@ -1,15 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> <classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes> <attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
@ -17,28 +28,5 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="veryverylongandparticularpath/abcd" kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/rules">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="veryverylongandparticularpath/abcd" kind="src" output="target/classes" path="src/jar-specific/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

1
core/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target/

23
core/.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>warppi-core</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding/<project>=UTF-8

View File

@ -0,0 +1,6 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

59
core/pom.xml Normal file
View File

@ -0,0 +1,59 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>it.cavallium</groupId>
<artifactId>warppi</artifactId>
<version>${project.version}</version>
</parent>
<artifactId>warppi-core</artifactId>
<packaging>bundle</packaging>
<name>WarpPI Calculator Core</name>
<description>WarpPI Calculator core project</description>
<dependencies>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>it.cavallium.warppi.*</Export-Package>
<Bundle-SymbolicName>warppi-core</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -3,8 +3,8 @@ package it.cavallium.warppi;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.boot.StartupArguments; import it.cavallium.warppi.boot.StartupArguments;
import it.cavallium.warppi.deps.DGpio; import it.cavallium.warppi.deps.Platform;
import it.cavallium.warppi.deps.DSystem; import it.cavallium.warppi.deps.Platform.ConsoleUtils;
import it.cavallium.warppi.device.HardwareDevice; import it.cavallium.warppi.device.HardwareDevice;
import it.cavallium.warppi.device.HardwareTouchDevice; import it.cavallium.warppi.device.HardwareTouchDevice;
import it.cavallium.warppi.device.InputManager; import it.cavallium.warppi.device.InputManager;
@ -18,17 +18,19 @@ import it.cavallium.warppi.gui.screens.Screen;
public class Engine { public class Engine {
public static final Engine INSTANCE = new Engine(); public static final Engine INSTANCE = new Engine();
private static Platform platform;
private static boolean running = false; private static boolean running = false;
private static BehaviorSubject<LoadingStatus> loadPhase = BehaviorSubject.create(); private static BehaviorSubject<LoadingStatus> loadPhase = BehaviorSubject.create();
private BehaviorSubject<Boolean> loaded = BehaviorSubject.create(false); private BehaviorSubject<Boolean> loaded = BehaviorSubject.create(false);
private Engine() { private Engine() {
} }
/** /**
* Start an instance of the calculator. * Start an instance of the calculator.
* *
* @param platform
* Platform implementation
* @param screen * @param screen
* Default screen to show at startup * Default screen to show at startup
* @param disp * @param disp
@ -40,24 +42,25 @@ public class Engine {
* @throws InterruptedException * @throws InterruptedException
* @throws IOException * @throws IOException
*/ */
public static void start(Screen screen, HardwareDisplay disp, HardwareTouchDevice touchdevice, HUD hud, public static void start(Platform platform, Screen screen, HardwareDisplay disp, HardwareTouchDevice touchdevice, HUD hud,
StartupArguments args) throws InterruptedException, IOException { StartupArguments args) throws InterruptedException, IOException {
if (running) { if (running) {
throw new RuntimeException("Already running!"); throw new RuntimeException("Already running!");
} else { } else {
running = true; running = true;
INSTANCE.startInstance(screen, disp, touchdevice, hud, args); INSTANCE.startInstance(platform, screen, disp, touchdevice, hud, args);
} }
} }
private void startInstance(Screen screen, HardwareDisplay disp, HardwareTouchDevice touchdevice, HUD hud, private void startInstance(final Platform platform, Screen screen, HardwareDisplay disp, HardwareTouchDevice touchdevice, HUD hud,
StartupArguments args) throws InterruptedException, IOException { StartupArguments args) throws InterruptedException, IOException {
ConsoleUtils.out.println("WarpPI Calculator"); Engine.platform = platform;
platform.getConsoleUtils().out().println("WarpPI Calculator");
initializeEnvironment(args); initializeEnvironment(args);
Thread currentThread = Thread.currentThread(); Thread currentThread = Thread.currentThread();
currentThread.setPriority(Thread.MAX_PRIORITY); currentThread.setPriority(Thread.MAX_PRIORITY);
PlatformUtils.setThreadName(currentThread, "Main thread"); Engine.getPlatform().setThreadName(currentThread, "Main thread");
DisplayManager dm = new DisplayManager(disp, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)"); DisplayManager dm = new DisplayManager(disp, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)");
Keyboard k = new Keyboard(); Keyboard k = new Keyboard();
@ -68,11 +71,11 @@ public class Engine {
} }
private void onShutdown() { private void onShutdown() {
ConsoleUtils.out.println(1, "Shutdown..."); Engine.platform.getConsoleUtils().out().println(1, "Shutdown...");
beforeShutdown(); beforeShutdown();
ConsoleUtils.out.println(1, ""); Engine.platform.getConsoleUtils().out().println(1, "");
ConsoleUtils.out.println(1, "Closed."); Engine.platform.getConsoleUtils().out().println(1, "Closed.");
DSystem.exit(0); Engine.getPlatform().exit(0);
} }
private void initializeEnvironment(StartupArguments args) throws IOException { private void initializeEnvironment(StartupArguments args) throws IOException {
@ -83,11 +86,11 @@ public class Engine {
if (args.isVerboseLoggingEnabled() || args.isDebugEnabled()) { if (args.isVerboseLoggingEnabled() || args.isDebugEnabled()) {
StaticVars.outputLevel = ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE; StaticVars.outputLevel = ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE;
} }
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, args); Engine.platform.getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, args);
checkDeviceType(); checkDeviceType();
if (Utils.isRunningOnRaspberry() && args.isRaspberryModeAllowed()) { if (Utils.isRunningOnRaspberry() && args.isRaspberryModeAllowed()) {
DGpio.wiringPiSetupPhys(); Engine.getPlatform().getGpio().wiringPiSetupPhys();
DGpio.pinMode(12, DGpio.PWM_OUTPUT); Engine.getPlatform().getGpio().pinMode(12, Engine.getPlatform().getGpio().valuePwmOutput());
} else { } else {
StaticVars.screenPos = new int[] { 0, 0 }; StaticVars.screenPos = new int[] { 0, 0 };
StaticVars.debugOn = true; StaticVars.debugOn = true;
@ -111,6 +114,10 @@ public class Engine {
return loadPhase; return loadPhase;
} }
public static Platform getPlatform() {
return platform;
}
public static class LoadingStatus { public static class LoadingStatus {
protected LoadingStatus() { protected LoadingStatus() {

View File

@ -1,6 +1,7 @@
package it.cavallium.warppi; package it.cavallium.warppi;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
@ -11,19 +12,19 @@ import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.nevec.rjm.BigDecimalMath; import org.nevec.rjm.BigDecimalMath;
import org.nevec.rjm.Rational; import org.nevec.rjm.Rational;
import it.cavallium.warppi.deps.DGpio;
import it.cavallium.warppi.deps.StorageUtils;
import it.cavallium.warppi.deps.nio.DFiles;
import it.cavallium.warppi.deps.nio.DPath;
import it.cavallium.warppi.deps.nio.DPaths;
import it.cavallium.warppi.device.HardwareDevice; import it.cavallium.warppi.device.HardwareDevice;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.Function;
import it.cavallium.warppi.math.FunctionOperator; import it.cavallium.warppi.math.FunctionOperator;
import it.cavallium.warppi.math.FunctionSingle; import it.cavallium.warppi.math.FunctionSingle;
@ -154,7 +155,7 @@ public class Utils {
return c; return c;
} }
public static boolean areThereOnlySettedUpFunctionsSumsEquationsAndSystems(ObjectArrayList<Function> fl) { public static boolean areThereOnlySettedUpFunctionsSumsEquationsAndSystems(List<Function> fl) {
for (int i = 0; i < fl.size(); i++) { for (int i = 0; i < fl.size(); i++) {
if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Subtraction || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Subtraction || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) {
if (fl.get(i) instanceof FunctionSingle) { if (fl.get(i) instanceof FunctionSingle) {
@ -173,8 +174,7 @@ public class Utils {
return true; return true;
} }
public static boolean areThereOnlySettedUpFunctionsSumsMultiplicationsEquationsAndSystems( public static boolean areThereOnlySettedUpFunctionsSumsMultiplicationsEquationsAndSystems(List<Function> fl) {
ObjectArrayList<Function> fl) {
for (int i = 0; i < fl.size(); i++) { for (int i = 0; i < fl.size(); i++) {
if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Multiplication || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Subtraction || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Multiplication || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Subtraction || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) {
if (fl.get(i) instanceof FunctionSingle) { if (fl.get(i) instanceof FunctionSingle) {
@ -193,7 +193,7 @@ public class Utils {
return true; return true;
} }
public static boolean areThereOnlySettedUpFunctionsEquationsAndSystems(ObjectArrayList<Function> fl) { public static boolean areThereOnlySettedUpFunctionsEquationsAndSystems(List<Function> fl) {
for (int i = 0; i < fl.size(); i++) { for (int i = 0; i < fl.size(); i++) {
if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) {
if (fl.get(i) instanceof FunctionSingle) { if (fl.get(i) instanceof FunctionSingle) {
@ -212,7 +212,7 @@ public class Utils {
return true; return true;
} }
public static boolean areThereOnlySettedUpFunctionsAndSystems(ObjectArrayList<Function> fl) { public static boolean areThereOnlySettedUpFunctionsAndSystems(List<Function> fl) {
for (int i = 0; i < fl.size(); i++) { for (int i = 0; i < fl.size(); i++) {
if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) {
if (fl.get(i) instanceof FunctionSingle) { if (fl.get(i) instanceof FunctionSingle) {
@ -231,7 +231,7 @@ public class Utils {
return true; return true;
} }
public static boolean areThereOnlyEmptySNFunctions(ObjectArrayList<Function> fl) { public static boolean areThereOnlyEmptySNFunctions(List<Function> fl) {
for (int i = 0; i < fl.size(); i++) { for (int i = 0; i < fl.size(); i++) {
if (fl.get(i) instanceof FunctionSingle) { if (fl.get(i) instanceof FunctionSingle) {
if (((FunctionSingle) fl.get(i)).getParameter() == null) { if (((FunctionSingle) fl.get(i)).getParameter() == null) {
@ -242,7 +242,7 @@ public class Utils {
return false; return false;
} }
public static boolean areThereOnlyEmptyNSNFunctions(ObjectArrayList<Function> fl) { public static boolean areThereOnlyEmptyNSNFunctions(List<Function> fl) {
for (int i = 0; i < fl.size(); i++) { for (int i = 0; i < fl.size(); i++) {
if (fl.get(i) instanceof FunctionOperator && !(fl.get(i) instanceof Sum) && !(fl.get(i) instanceof SumSubtraction) && !(fl.get(i) instanceof Subtraction) && !(fl.get(i) instanceof Multiplication) && !(fl.get(i) instanceof Division)) { if (fl.get(i) instanceof FunctionOperator && !(fl.get(i) instanceof Sum) && !(fl.get(i) instanceof SumSubtraction) && !(fl.get(i) instanceof Subtraction) && !(fl.get(i) instanceof Multiplication) && !(fl.get(i) instanceof Division)) {
if (((FunctionOperator) fl.get(i)).getParameter1() == null && ((FunctionOperator) fl.get(i)).getParameter2() == null) { if (((FunctionOperator) fl.get(i)).getParameter1() == null && ((FunctionOperator) fl.get(i)).getParameter2() == null) {
@ -253,7 +253,7 @@ public class Utils {
return false; return false;
} }
public static boolean areThereEmptyMultiplications(ObjectArrayList<Function> fl) { public static boolean areThereEmptyMultiplications(List<Function> fl) {
for (int i = 0; i < fl.size(); i++) { for (int i = 0; i < fl.size(); i++) {
if (fl.get(i) instanceof Multiplication || fl.get(i) instanceof Division) { if (fl.get(i) instanceof Multiplication || fl.get(i) instanceof Division) {
if (((FunctionOperator) fl.get(i)).getParameter1() == null && ((FunctionOperator) fl.get(i)).getParameter2() == null) { if (((FunctionOperator) fl.get(i)).getParameter1() == null && ((FunctionOperator) fl.get(i)).getParameter2() == null) {
@ -264,7 +264,7 @@ public class Utils {
return false; return false;
} }
public static boolean areThereEmptySums(ObjectArrayList<Function> fl) { public static boolean areThereEmptySums(List<Function> fl) {
for (int i = 0; i < fl.size(); i++) { for (int i = 0; i < fl.size(); i++) {
if (fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Subtraction) { if (fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Subtraction) {
if (((FunctionOperator) fl.get(i)).getParameter1() == null && ((FunctionOperator) fl.get(i)).getParameter2() == null) { if (((FunctionOperator) fl.get(i)).getParameter1() == null && ((FunctionOperator) fl.get(i)).getParameter2() == null) {
@ -275,7 +275,7 @@ public class Utils {
return false; return false;
} }
public static boolean areThereEmptySystems(ObjectArrayList<Function> fl) { public static boolean areThereEmptySystems(List<Function> fl) {
for (int i = 0; i < fl.size(); i++) { for (int i = 0; i < fl.size(); i++) {
if (fl.get(i) instanceof EquationsSystemPart) { if (fl.get(i) instanceof EquationsSystemPart) {
if (((EquationsSystemPart) fl.get(i)).getParameter() == null) { if (((EquationsSystemPart) fl.get(i)).getParameter() == null) {
@ -286,7 +286,7 @@ public class Utils {
return false; return false;
} }
public static boolean areThereOtherSettedUpFunctions(ObjectArrayList<Function> fl) { public static boolean areThereOtherSettedUpFunctions(List<Function> fl) {
for (int i = 0; i < fl.size(); i++) { for (int i = 0; i < fl.size(); i++) {
if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Expression || fl.get(i) instanceof FunctionSingle || fl.get(i) instanceof Multiplication || fl.get(i) instanceof Division)) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Expression || fl.get(i) instanceof FunctionSingle || fl.get(i) instanceof Multiplication || fl.get(i) instanceof Division)) {
if (fl.get(i) instanceof FunctionSingle) { if (fl.get(i) instanceof FunctionSingle) {
@ -369,7 +369,7 @@ public class Utils {
return BigDecimalMath.divideRound(new BigDecimal(r.numer()).setScale(Utils.scale, Utils.scaleMode), new BigDecimal(r.denom()).setScale(Utils.scale, Utils.scaleMode)); return BigDecimalMath.divideRound(new BigDecimal(r.numer()).setScale(Utils.scale, Utils.scaleMode), new BigDecimal(r.denom()).setScale(Utils.scale, Utils.scaleMode));
} }
public static boolean equalsVariables(ObjectArrayList<Variable> variables, ObjectArrayList<Variable> variables2) { public static boolean equalsVariables(List<Variable> variables, List<Variable> variables2) {
if (variables.size() != variables2.size()) { if (variables.size() != variables2.size()) {
return false; return false;
} else { } else {
@ -602,7 +602,7 @@ public class Utils {
if (displayName.endsWith("MemorySize")) { if (displayName.endsWith("MemorySize")) {
mb = true; mb = true;
} }
final ObjectArrayList<String> arr = new ObjectArrayList<>(); final List<String> arr = new ArrayList<>();
arr.add("getFreePhysicalMemorySize"); arr.add("getFreePhysicalMemorySize");
arr.add("getProcessCpuLoad"); arr.add("getProcessCpuLoad");
arr.add("getSystemCpuLoad"); arr.add("getSystemCpuLoad");
@ -631,17 +631,17 @@ public class Utils {
public static boolean isRunningOnRaspberry() { public static boolean isRunningOnRaspberry() {
return CacheUtils.get("isRunningOnRaspberry", 24 * 60 * 60 * 1000, () -> { return CacheUtils.get("isRunningOnRaspberry", 24 * 60 * 60 * 1000, () -> {
if (PlatformUtils.isJavascript) if (Engine.getPlatform().isJavascript())
return false; return false;
try { try {
// Check if it's a raspberry using pi4j // Check if it's a raspberry using pi4j
return DGpio.getBoardType() != DGpio.UnknownBoardType; return Engine.getPlatform().getGpio().getBoardType() != Engine.getPlatform().getGpio().valueUnknownBoardType();
} catch (final Exception e) { } catch (final Exception e) {
// Check if it's a raspberry using other methods // Check if it's a raspberry using other methods
if (PlatformUtils.osName.equals("Linux")) { if (Engine.getPlatform().getOsName().equals("Linux")) {
try { try {
final DPath osRelease = DPaths.get("/etc", "os-release"); final File osRelease = new File("/etc", "os-release");
return DFiles.readAllLines(osRelease).stream().map(String::toLowerCase).anyMatch(line -> line.contains("raspbian") && line.contains("name")); return FileUtils.readLines(osRelease, "UTF-8").stream().map(String::toLowerCase).anyMatch(line -> line.contains("raspbian") && line.contains("name"));
} catch (IOException readException) { } catch (IOException readException) {
return false; return false;
} }
@ -654,7 +654,7 @@ public class Utils {
} }
public static boolean isWindows() { public static boolean isWindows() {
return (PlatformUtils.osName.indexOf("win") >= 0); return (Engine.getPlatform().getOsName().indexOf("win") >= 0);
} }
public static <T> ObjectArrayList<T> newArrayList(T o) { public static <T> ObjectArrayList<T> newArrayList(T o) {
@ -665,13 +665,21 @@ public class Utils {
public static InputStream getResourceStreamSafe(String string) throws IOException, URISyntaxException { public static InputStream getResourceStreamSafe(String string) throws IOException, URISyntaxException {
try { try {
return StorageUtils.getResourceStream(string); return Engine.getPlatform().getStorageUtils().getResourceStream(string);
} catch (final Exception ex) { } catch (final Exception ex) {
return null; return null;
} }
} }
public static DPath getJarDirectory() { public static File getJarDirectory() {
return DPaths.get("").toAbsolutePath(); return new File("").getAbsoluteFile();
}
public static <T,U> U getOrDefault(Map<T, U> enginesList, T key, U object) {
if (enginesList.containsKey(key)) {
return enginesList.get(key);
} else {
return object;
}
} }
} }

View File

@ -2,10 +2,10 @@ package it.cavallium.warppi.boot;
import java.util.Arrays; import java.util.Arrays;
import it.cavallium.warppi.ConsoleUtils;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.Engine;
import it.cavallium.warppi.Engine.LoadingStatus; import it.cavallium.warppi.Engine.LoadingStatus;
import it.cavallium.warppi.Error; import it.cavallium.warppi.Error;
import it.cavallium.warppi.deps.Platform;
import it.cavallium.warppi.device.HardwareDevice; import it.cavallium.warppi.device.HardwareDevice;
import it.cavallium.warppi.device.PIHardwareDisplay; import it.cavallium.warppi.device.PIHardwareDisplay;
import it.cavallium.warppi.device.PIHardwareTouchDevice; import it.cavallium.warppi.device.PIHardwareTouchDevice;
@ -13,10 +13,11 @@ import it.cavallium.warppi.gui.CalculatorHUD;
import it.cavallium.warppi.gui.screens.LoadingScreen; import it.cavallium.warppi.gui.screens.LoadingScreen;
import it.cavallium.warppi.math.rules.RulesManager; import it.cavallium.warppi.math.rules.RulesManager;
public class WarpPI { public class Boot {
public static void main(String[] args) throws Exception {
Engine.start(new LoadingScreen(), new PIHardwareDisplay(), new PIHardwareTouchDevice(false, false, false), new CalculatorHUD(), parseStartupArguments(args)); public static void boot(Platform platform, String[] args) throws Exception {
Engine.INSTANCE.getLoadPhase().subscribe(WarpPI::loadCalculator); Engine.start(platform, new LoadingScreen(), new PIHardwareDisplay(), new PIHardwareTouchDevice(false, false, false), new CalculatorHUD(), parseStartupArguments(args));
Engine.INSTANCE.getLoadPhase().subscribe(Boot::loadCalculator);
} }
private static void loadCalculator(LoadingStatus loading) { private static void loadCalculator(LoadingStatus loading) {
@ -86,7 +87,7 @@ public class WarpPI {
args.setUncached(true); args.setUncached(true);
break; break;
default: default:
ConsoleUtils.out.println("Unrecognized argument " + arg); Engine.getPlatform().getConsoleUtils().out().println("Unrecognized argument " + arg);
break; break;
} }
} }

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.deps.jogamp; package it.cavallium.warppi.deps;
public class DJogamp { public interface DJogamp {
// //
// Unicode: Non printable controls: [0x00 - 0x1F] // Unicode: Non printable controls: [0x00 - 0x1F]

View File

@ -0,0 +1,159 @@
package it.cavallium.warppi.deps;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.Map;
import it.cavallium.warppi.Error;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Skin;
public interface Platform {
public ConsoleUtils getConsoleUtils();
public Gpio getGpio();
public StorageUtils getStorageUtils();
public PngUtils getPngUtils();
public void setThreadName(Thread t, String name);
public void setThreadDaemon(Thread t);
public void setThreadDaemon(Thread t, boolean value);
public void exit(int value);
public void gc();
public boolean isJavascript();
public String getOsName();
public void alphaChanged(boolean val);
public void shiftChanged(boolean val);
public Semaphore newSemaphore();
public Semaphore newSemaphore(int i);
public URLClassLoader newURLClassLoader(URL[] urls);
public Map<String, GraphicEngine> getEnginesList();
public GraphicEngine getEngine(String string) throws NullPointerException;
public void throwNewExceptionInInitializerError(String text);
public String[] stacktraceToString(Error e);
public void loadPlatformRules();
public void zip(String targetPath, String destinationFilePath, String password);
public void unzip(String targetZipFilePath, String destinationFolderPath, String password);
public boolean compile(String[] command, PrintWriter printWriter, PrintWriter errors);
public interface Gpio {
public int valueOutput();
public int valuePwmOutput();
public int valueInput();
public int valueHigh();
public int valueLow();
public Object valueUnknownBoardType();
public void wiringPiSetupPhys();
public void pinMode(int i, int type);
public void digitalWrite(int pin, int val);
public void digitalWrite(int pin, boolean val);
public void pwmWrite(int pin, int val);
public void delayMicroseconds(int t);
public int digitalRead(int pin);
public Object getBoardType();
}
public interface ConsoleUtils {
public static final int OUTPUTLEVEL_NODEBUG = 0;
public static final int OUTPUTLEVEL_DEBUG_MIN = 1;
public static final int OUTPUTLEVEL_DEBUG_VERBOSE = 4;
public AdvancedOutputStream out();
public interface AdvancedOutputStream {
public void println(Object str);
public void println(int level);
public void println(int level, Object str);
public void print(int level, String str);
public void println(int level, String prefix, String str);
public void println(int level, String... parts);
}
}
public interface StorageUtils {
int OpenOptionWrite = 0;
int OpenOptionCreate = 1;
public boolean exists(File f);
public File get(String path);
public File get(String... path);
@Deprecated()
public File getResource(String string) throws IOException, URISyntaxException;
public InputStream getResourceStream(String string) throws IOException, URISyntaxException;
public List<String> readAllLines(File file) throws IOException;
public String read(InputStream input) throws IOException;
public List<File> walk(File dir) throws IOException;
public File relativize(File rulesPath, File f);
public File resolve(File file, String string);
public File getParent(File f);
public void createDirectories(File dir) throws IOException;
public void write(File f, byte[] bytes, int... options) throws IOException;
public List<String> readAllLines(InputStream input) throws IOException;
public String getBasePath();
}
public interface Semaphore {
void release();
void acquire() throws InterruptedException;
}
public interface URLClassLoader {
public Class<?> loadClass(String name) throws ClassNotFoundException;
void close() throws IOException;
}
public interface PngUtils {
public PngReader load(InputStream resourceStream);
public interface PngReader {
int[] getImageMatrix();
int[] getSize();
}
}
}

View File

@ -1,5 +1,6 @@
package it.cavallium.warppi.device; package it.cavallium.warppi.device;
import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
@ -8,8 +9,6 @@ import java.io.ObjectOutputStream;
import java.util.UUID; import java.util.UUID;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.deps.nio.DFiles;
import it.cavallium.warppi.deps.nio.DPaths;
public class CacheFile { public class CacheFile {
private String path; private String path;
@ -21,9 +20,9 @@ public class CacheFile {
public CacheFile() { public CacheFile() {
do { do {
path = UUID.randomUUID().toString() + ".ser"; path = UUID.randomUUID().toString() + ".ser";
} while (DFiles.exists(DPaths.get(path))); } while (new File(path).exists());
try { try {
DFiles.createTempFile(StaticVars.calculatorNameLOWER, ""); File.createTempFile(StaticVars.calculatorNameLOWER, "");
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -80,8 +79,8 @@ public class CacheFile {
public void dispose() { public void dispose() {
closeStreams(); closeStreams();
try { try {
DFiles.deleteIfExists(DPaths.get(path)); new File(path).delete();
} catch (final IOException e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.device; package it.cavallium.warppi.device;
import it.cavallium.warppi.PlatformUtils; import it.cavallium.warppi.Engine;
import it.cavallium.warppi.gui.DisplayManager; import it.cavallium.warppi.gui.DisplayManager;
public class HardwareDevice { public class HardwareDevice {
@ -26,8 +26,8 @@ public class HardwareDevice {
displayManager.initialize(); displayManager.initialize();
inputManager.getKeyboard().startKeyboard(); inputManager.getKeyboard().startKeyboard();
Thread t = new Thread(r); Thread t = new Thread(r);
PlatformUtils.setDaemon(t, false); Engine.getPlatform().setThreadDaemon(t, false);
PlatformUtils.setThreadName(t, "Main thread (after setup)"); Engine.getPlatform().setThreadName(t, "Main thread (after setup)");
t.start(); t.start();
} }

View File

@ -2,11 +2,10 @@ package it.cavallium.warppi.device;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import it.cavallium.warppi.ConsoleUtils; import it.cavallium.warppi.Engine;
import it.cavallium.warppi.PlatformUtils;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.deps.DGpio; import it.cavallium.warppi.deps.DJogamp;
import it.cavallium.warppi.deps.jogamp.DJogamp; import it.cavallium.warppi.deps.Platform.ConsoleUtils;
import it.cavallium.warppi.device.chip.ParallelToSerial; import it.cavallium.warppi.device.chip.ParallelToSerial;
import it.cavallium.warppi.device.chip.SerialToParallel; import it.cavallium.warppi.device.chip.SerialToParallel;
import it.cavallium.warppi.event.Key; import it.cavallium.warppi.event.Key;
@ -58,19 +57,19 @@ public class Keyboard {
} }
} catch (final InterruptedException e) {} } catch (final InterruptedException e) {}
} else { } else {
DGpio.pinMode(CLK_INH_pin, DGpio.OUTPUT); Engine.getPlatform().getGpio().pinMode(CLK_INH_pin, Engine.getPlatform().getGpio().valueOutput());
DGpio.pinMode(RCK_pin, DGpio.OUTPUT); Engine.getPlatform().getGpio().pinMode(RCK_pin, Engine.getPlatform().getGpio().valueOutput());
DGpio.pinMode(SER_pin, DGpio.OUTPUT); Engine.getPlatform().getGpio().pinMode(SER_pin, Engine.getPlatform().getGpio().valueOutput());
DGpio.pinMode(SH_LD_pin, DGpio.OUTPUT); Engine.getPlatform().getGpio().pinMode(SH_LD_pin, Engine.getPlatform().getGpio().valueOutput());
DGpio.pinMode(SCK_and_CLK_pin, DGpio.OUTPUT); Engine.getPlatform().getGpio().pinMode(SCK_and_CLK_pin, Engine.getPlatform().getGpio().valueOutput());
DGpio.pinMode(QH_pin, DGpio.INPUT); Engine.getPlatform().getGpio().pinMode(QH_pin, Engine.getPlatform().getGpio().valueInput());
DGpio.digitalWrite(CLK_INH_pin, false); Engine.getPlatform().getGpio().digitalWrite(CLK_INH_pin, false);
DGpio.digitalWrite(RCK_pin, false); Engine.getPlatform().getGpio().digitalWrite(RCK_pin, false);
DGpio.digitalWrite(SER_pin, false); Engine.getPlatform().getGpio().digitalWrite(SER_pin, false);
DGpio.digitalWrite(SH_LD_pin, false); Engine.getPlatform().getGpio().digitalWrite(SH_LD_pin, false);
DGpio.digitalWrite(SCK_and_CLK_pin, false); Engine.getPlatform().getGpio().digitalWrite(SCK_and_CLK_pin, false);
DGpio.digitalWrite(QH_pin, false); Engine.getPlatform().getGpio().digitalWrite(QH_pin, false);
final SerialToParallel chip1 = new SerialToParallel(RCK_pin, SCK_and_CLK_pin /*SCK*/, SER_pin); final SerialToParallel chip1 = new SerialToParallel(RCK_pin, SCK_and_CLK_pin /*SCK*/, SER_pin);
final ParallelToSerial chip2 = new ParallelToSerial(SH_LD_pin, CLK_INH_pin, QH_pin, SCK_and_CLK_pin/*CLK*/); final ParallelToSerial chip2 = new ParallelToSerial(SH_LD_pin, CLK_INH_pin, QH_pin, SCK_and_CLK_pin/*CLK*/);
@ -101,9 +100,9 @@ public class Keyboard {
} }
} }
}); });
PlatformUtils.setThreadName(kt, "Keyboard thread"); Engine.getPlatform().setThreadName(kt, "Keyboard thread");
kt.setPriority(Thread.NORM_PRIORITY + 1); kt.setPriority(Thread.NORM_PRIORITY + 1);
PlatformUtils.setDaemon(kt); Engine.getPlatform().setThreadDaemon(kt);
kt.start(); kt.start();
} }
@ -761,12 +760,12 @@ public class Keyboard {
public static void stopKeyboard() { public static void stopKeyboard() {
if (StaticVars.debugOn == false) { if (StaticVars.debugOn == false) {
DGpio.digitalWrite(33, false); Engine.getPlatform().getGpio().digitalWrite(33, false);
DGpio.digitalWrite(35, false); Engine.getPlatform().getGpio().digitalWrite(35, false);
DGpio.digitalWrite(36, false); Engine.getPlatform().getGpio().digitalWrite(36, false);
DGpio.digitalWrite(37, false); Engine.getPlatform().getGpio().digitalWrite(37, false);
DGpio.digitalWrite(38, false); Engine.getPlatform().getGpio().digitalWrite(38, false);
DGpio.digitalWrite(40, false); Engine.getPlatform().getGpio().digitalWrite(40, false);
} }
} }
@ -809,7 +808,7 @@ public class Keyboard {
case ZOOM_MODE: case ZOOM_MODE:
float newZoom = (StaticVars.windowZoom.getLastValue() % 3) + 1; float newZoom = (StaticVars.windowZoom.getLastValue() % 3) + 1;
StaticVars.windowZoom.onNext(newZoom); StaticVars.windowZoom.onNext(newZoom);
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Keyboard", "Zoom: " + newZoom); Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Keyboard", "Zoom: " + newZoom);
// StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f; // StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f;
refresh = true; refresh = true;
case HISTORY_BACK: case HISTORY_BACK:
@ -827,22 +826,22 @@ public class Keyboard {
switch (k) { switch (k) {
case SHIFT: case SHIFT:
if (Keyboard.alpha) if (Keyboard.alpha)
PlatformUtils.alphaChanged(Keyboard.alpha = false); Engine.getPlatform().alphaChanged(Keyboard.alpha = false);
PlatformUtils.shiftChanged(Keyboard.shift = !Keyboard.shift); Engine.getPlatform().shiftChanged(Keyboard.shift = !Keyboard.shift);
refresh = true; refresh = true;
break; break;
case ALPHA: case ALPHA:
if (Keyboard.shift) if (Keyboard.shift)
PlatformUtils.shiftChanged(Keyboard.shift = false); Engine.getPlatform().shiftChanged(Keyboard.shift = false);
PlatformUtils.alphaChanged(Keyboard.alpha = !Keyboard.alpha); Engine.getPlatform().alphaChanged(Keyboard.alpha = !Keyboard.alpha);
refresh = true; refresh = true;
break; break;
default: default:
if (k != Key.NONE) { if (k != Key.NONE) {
if (Keyboard.shift) if (Keyboard.shift)
PlatformUtils.shiftChanged(Keyboard.shift = false); Engine.getPlatform().shiftChanged(Keyboard.shift = false);
if (Keyboard.alpha) if (Keyboard.alpha)
PlatformUtils.alphaChanged(Keyboard.alpha = false); Engine.getPlatform().alphaChanged(Keyboard.alpha = false);
} }
break; break;
} }
@ -850,7 +849,7 @@ public class Keyboard {
refreshRequest = true; refreshRequest = true;
} }
} else if (!done) { } else if (!done) {
ConsoleUtils.out.println(1, "Key " + k.toString() + " ignored."); Engine.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored.");
} }
} }
@ -876,7 +875,7 @@ public class Keyboard {
refreshRequest = true; refreshRequest = true;
} }
} else if (!done) { } else if (!done) {
ConsoleUtils.out.println(1, "Key " + k.toString() + " ignored."); Engine.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored.");
} }
} }

View File

@ -1,8 +1,7 @@
package it.cavallium.warppi.device; package it.cavallium.warppi.device;
import it.cavallium.warppi.ConsoleUtils; import it.cavallium.warppi.Engine;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.deps.DGpio;
import it.cavallium.warppi.gui.HardwareDisplay; import it.cavallium.warppi.gui.HardwareDisplay;
public class PIHardwareDisplay implements HardwareDisplay { public class PIHardwareDisplay implements HardwareDisplay {
@ -16,10 +15,10 @@ public class PIHardwareDisplay implements HardwareDisplay {
@Override @Override
public void setBrightness(double value) { public void setBrightness(double value) {
if (StaticVars.debugOn == false) { if (StaticVars.debugOn == false) {
DGpio.pwmWrite(12, (int) Math.ceil(value * 1024f)); Engine.getPlatform().getGpio().pwmWrite(12, (int) Math.ceil(value * 1024f));
// SoftPwm.softPwmWrite(12, (int)(Math.ceil(brightness*10))); // SoftPwm.softPwmWrite(12, (int)(Math.ceil(brightness*10)));
} else { } else {
ConsoleUtils.out.println(1, "Brightness: " + value); Engine.getPlatform().getConsoleUtils().out().println(1, "Brightness: " + value);
} }
} }

View File

@ -0,0 +1,35 @@
package it.cavallium.warppi.device.chip;
import it.cavallium.warppi.Engine;
public class ParallelToSerial {
private final int SH_LD;
private final int CLK_INH;
private final int QH;
private final int CLK;
public ParallelToSerial(int SH_LD_pin, int CLK_INH_pin, int QH_pin, int CLK_pin) {
SH_LD = SH_LD_pin;
CLK_INH = CLK_INH_pin;
QH = QH_pin;
CLK = CLK_pin;
}
public boolean[] read() {
final boolean[] data = new boolean[8];
Engine.getPlatform().getGpio().digitalWrite(CLK_INH, Engine.getPlatform().getGpio().valueHigh());
Engine.getPlatform().getGpio().digitalWrite(SH_LD, Engine.getPlatform().getGpio().valueLow());
Engine.getPlatform().getGpio().delayMicroseconds(1);
Engine.getPlatform().getGpio().digitalWrite(SH_LD, Engine.getPlatform().getGpio().valueHigh());
Engine.getPlatform().getGpio().digitalWrite(CLK_INH, Engine.getPlatform().getGpio().valueLow());
for (int i = 7; i >= 0; i--) {
Engine.getPlatform().getGpio().digitalWrite(CLK, Engine.getPlatform().getGpio().valueHigh());
Engine.getPlatform().getGpio().digitalWrite(CLK, Engine.getPlatform().getGpio().valueLow());
data[i] = Engine.getPlatform().getGpio().digitalRead(QH) == Engine.getPlatform().getGpio().valueHigh() ? true : false;
}
return data;
}
}

View File

@ -0,0 +1,31 @@
package it.cavallium.warppi.device.chip;
import it.cavallium.warppi.Engine;
public class SerialToParallel {
private final int RCK; //Storage register clock pin (latch pin)
private final int SCK; //Shift register clock pin
private final int SER; //Serial data input
public SerialToParallel(int RCK_pin, int SCK_pin, int SER_pin) {
RCK = RCK_pin;
SCK = SCK_pin;
SER = SER_pin;
}
public void write(boolean[] data) {
if (data.length != 8) {
return;
} else {
Engine.getPlatform().getGpio().digitalWrite(RCK, Engine.getPlatform().getGpio().valueLow());
for (int i = 7; i >= 0; i--) {
Engine.getPlatform().getGpio().digitalWrite(SCK, Engine.getPlatform().getGpio().valueLow());
Engine.getPlatform().getGpio().digitalWrite(SER, data[i]);
Engine.getPlatform().getGpio().digitalWrite(SCK, Engine.getPlatform().getGpio().valueHigh());
}
Engine.getPlatform().getGpio().digitalWrite(RCK, Engine.getPlatform().getGpio().valueHigh());
}
}
}

View File

@ -12,8 +12,8 @@ import java.util.logging.Logger;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import it.cavallium.warppi.ClassUtils; import it.cavallium.warppi.ClassUtils;
import it.cavallium.warppi.Engine;
import it.cavallium.warppi.Utils; import it.cavallium.warppi.Utils;
import it.cavallium.warppi.deps.DSystem;
/** /**
* *
@ -36,7 +36,7 @@ public class RAWFont {
loadFont("/font_" + name + ".rft"); loadFont("/font_" + name + ".rft");
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
DSystem.exit(1); Engine.getPlatform().exit(1);
} }
chars32 = new int[(maxBound - minBound) * charIntCount]; chars32 = new int[(maxBound - minBound) * charIntCount];
for (int charIndex = 0; charIndex < maxBound - minBound; charIndex++) { for (int charIndex = 0; charIndex < maxBound - minBound; charIndex++) {
@ -114,7 +114,7 @@ public class RAWFont {
} catch (final Exception ex) { } catch (final Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
System.out.println(string); System.out.println(string);
DSystem.exit(-1); Engine.getPlatform().exit(-1);
} }
} }
} else { } else {

View File

@ -3,7 +3,7 @@ package it.cavallium.warppi.flow;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import it.cavallium.warppi.PlatformUtils; import it.cavallium.warppi.Engine;
public class IntervalsManager { public class IntervalsManager {
private static List<ObservableInterval> intervals = new LinkedList<>(); private static List<ObservableInterval> intervals = new LinkedList<>();
@ -41,8 +41,8 @@ public class IntervalsManager {
e.printStackTrace(); e.printStackTrace();
} }
}); });
PlatformUtils.setDaemon(t); Engine.getPlatform().setThreadDaemon(t);
PlatformUtils.setThreadName(t, "Intervals Manager"); Engine.getPlatform().setThreadName(t, "Intervals Manager");
t.start(); t.start();
} }
} }

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.flow; package it.cavallium.warppi.flow;
import it.cavallium.warppi.PlatformUtils; import it.cavallium.warppi.Engine;
public class ObservableInterval extends Observable<Long> { public class ObservableInterval extends Observable<Long> {
private final long interval; private final long interval;
@ -50,7 +50,7 @@ public class ObservableInterval extends Observable<Long> {
} catch (InterruptedException e) {} } catch (InterruptedException e) {}
timeThread = null; timeThread = null;
}); });
PlatformUtils.setThreadName(timeThread, "ObservableTimer"); Engine.getPlatform().setThreadName(timeThread, "ObservableTimer");
timeThread.start(); timeThread.start();
running = true; running = true;
} }

View File

@ -1,6 +1,6 @@
package it.cavallium.warppi.gui; package it.cavallium.warppi.gui;
import it.cavallium.warppi.ConsoleUtils; import it.cavallium.warppi.Engine;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.Utils; import it.cavallium.warppi.Utils;
import it.cavallium.warppi.device.HardwareDevice; import it.cavallium.warppi.device.HardwareDevice;
@ -84,7 +84,7 @@ public class CalculatorHUD extends HUD {
if (brightness <= 10) { if (brightness <= 10) {
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16); renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16);
} else { } else {
ConsoleUtils.out.println(1, "Brightness error"); Engine.getPlatform().getConsoleUtils().out().println(1, "Brightness error");
} }
padding += 18 + 6; padding += 18 + 6;

View File

@ -6,12 +6,11 @@ import java.util.List;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import it.cavallium.warppi.ConsoleUtils; import it.cavallium.warppi.Engine;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.Utils; import it.cavallium.warppi.Utils;
import it.cavallium.warppi.deps.DEngine; import it.cavallium.warppi.deps.Platform.ConsoleUtils;
import it.cavallium.warppi.deps.DSemaphore; import it.cavallium.warppi.deps.Platform.Semaphore;
import it.cavallium.warppi.deps.DSystem;
import it.cavallium.warppi.device.Keyboard; import it.cavallium.warppi.device.Keyboard;
import it.cavallium.warppi.flow.Observable; import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
@ -44,7 +43,7 @@ public final class DisplayManager implements RenderingLoop {
private final HUD hud; private final HUD hud;
private final String initialTitle; private final String initialTitle;
private Screen initialScreen; private Screen initialScreen;
public DSemaphore screenChange = new DSemaphore(0); public Semaphore screenChange;
public String displayDebugString; public String displayDebugString;
public ObjectArrayList<GUIErrorMessage> errorMessages; public ObjectArrayList<GUIErrorMessage> errorMessages;
/** /**
@ -53,6 +52,7 @@ public final class DisplayManager implements RenderingLoop {
public boolean forceRefresh; public boolean forceRefresh;
public DisplayManager(HardwareDisplay monitor, HUD hud, Screen screen, String title) { public DisplayManager(HardwareDisplay monitor, HUD hud, Screen screen, String title) {
screenChange = Engine.getPlatform().newSemaphore();
engine = chooseGraphicEngine(); engine = chooseGraphicEngine();
supportsPauses = engine.doesRefreshPauses(); supportsPauses = engine.doesRefreshPauses();
@ -77,7 +77,7 @@ public final class DisplayManager implements RenderingLoop {
} }
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
DSystem.exit(0); Engine.getPlatform().exit(0);
} }
try { try {
@ -123,45 +123,45 @@ public final class DisplayManager implements RenderingLoop {
private GraphicEngine chooseGraphicEngine() { private GraphicEngine chooseGraphicEngine() {
GraphicEngine d; GraphicEngine d;
if (!StaticVars.debugOn) { if (!StaticVars.debugOn) {
d = DEngine.newFBEngine(); d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "framebuffer engine", null);
if (d != null && d.isSupported()) { if (d != null && d.isSupported()) {
ConsoleUtils.out.println(1, "Using FB Graphic Engine"); Engine.getPlatform().getConsoleUtils().out().println(1, "Using FB Graphic Engine");
return d; return d;
} }
} }
d = DEngine.newGPUEngine(); d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "GPU engine", null);
if (d != null && d.isSupported()) { if (d != null && d.isSupported()) {
ConsoleUtils.out.println(1, "Using GPU Graphic Engine"); Engine.getPlatform().getConsoleUtils().out().println(1, "Using GPU Graphic Engine");
return d; return d;
} }
d = DEngine.newCPUEngine(); d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "CPU engine", null);
if (d != null && d.isSupported()) { if (d != null && d.isSupported()) {
ConsoleUtils.out.println(1, "Using CPU Graphic Engine"); Engine.getPlatform().getConsoleUtils().out().println(1, "Using CPU Graphic Engine");
return d; return d;
} }
d = DEngine.newHeadless24bitEngine(); d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 24 bit engine", null);
if (d != null && d.isSupported()) { if (d != null && d.isSupported()) {
System.err.println("Using Headless 24 bit Engine! This is a problem! No other graphic engines are available."); System.err.println("Using Headless 24 bit Engine! This is a problem! No other graphic engines are available.");
return d; return d;
} }
d = DEngine.newHeadless256Engine(); d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 256 colors engine", null);
if (d != null && d.isSupported()) { if (d != null && d.isSupported()) {
System.err.println("Using Headless 256 Engine! This is a problem! No other graphic engines are available."); System.err.println("Using Headless 256 Engine! This is a problem! No other graphic engines are available.");
return d; return d;
} }
d = DEngine.newHeadless8Engine(); d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 8 colors engine", null);
if (d != null && d.isSupported()) { if (d != null && d.isSupported()) {
System.err.println("Using Headless basic Engine! This is a problem! No other graphic engines are available."); System.err.println("Using Headless basic Engine! This is a problem! No other graphic engines are available.");
return d; return d;
} }
d = DEngine.newHtmlEngine(); d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "HTML5 engine", null);
if (d != null && d.isSupported()) { if (d != null && d.isSupported()) {
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "Using Html Graphic Engine"); Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "Using Html Graphic Engine");
return d; return d;
} }
d = new NoGuiEngine(); d = new NoGuiEngine();
if (d != null && d.isSupported()) { if (d != null && d.isSupported()) {
ConsoleUtils.out.println(1, "Using NoGui Graphic Engine"); Engine.getPlatform().getConsoleUtils().out().println(1, "Using NoGui Graphic Engine");
return d; return d;
} }
throw new UnsupportedOperationException("No graphic engines available."); throw new UnsupportedOperationException("No graphic engines available.");
@ -193,7 +193,7 @@ public final class DisplayManager implements RenderingLoop {
} }
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
DSystem.exit(0); Engine.getPlatform().exit(0);
} }
} }
@ -218,7 +218,7 @@ public final class DisplayManager implements RenderingLoop {
} }
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
DSystem.exit(0); Engine.getPlatform().exit(0);
} }
} }
@ -385,7 +385,7 @@ public final class DisplayManager implements RenderingLoop {
screen.initialize(); screen.initialize();
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
DSystem.exit(0); Engine.getPlatform().exit(0);
} }
Observable<Long> workTimer = Observable.interval(tickDuration); Observable<Long> workTimer = Observable.interval(tickDuration);

Some files were not shown because too many files have changed in this diff Show More