Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.

Commit 04adf9f

Browse files
committed
First commit
1 parent 7b648d5 commit 04adf9f

File tree

19 files changed

+1080
-0
lines changed

19 files changed

+1080
-0
lines changed

.gitignore

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
2+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3+
4+
# User-specific stuff
5+
.idea/**/workspace.xml
6+
.idea/**/tasks.xml
7+
.idea/**/usage.statistics.xml
8+
.idea/**/dictionaries
9+
.idea/**/shelf
10+
11+
# Generated files
12+
.idea/**/contentModel.xml
13+
14+
# Sensitive or high-churn files
15+
.idea/**/dataSources/
16+
.idea/**/dataSources.ids
17+
.idea/**/dataSources.local.xml
18+
.idea/**/sqlDataSources.xml
19+
.idea/**/dynamic.xml
20+
.idea/**/uiDesigner.xml
21+
.idea/**/dbnavigator.xml
22+
23+
# Gradle
24+
.idea/**/gradle.xml
25+
.idea/**/libraries
26+
27+
# Gradle and Maven with auto-import
28+
# When using Gradle or Maven with auto-import, you should exclude module files,
29+
# since they will be recreated, and may cause churn. Uncomment if using
30+
# auto-import.
31+
# .idea/artifacts
32+
# .idea/compiler.xml
33+
# .idea/jarRepositories.xml
34+
# .idea/modules.xml
35+
# .idea/*.iml
36+
# .idea/modules
37+
.idea/
38+
*.iml
39+
*.ipr
40+
41+
# CMake
42+
cmake-build-*/
43+
44+
# Mongo Explorer plugin
45+
.idea/**/mongoSettings.xml
46+
47+
# File-based project format
48+
*.iws
49+
50+
# IntelliJ
51+
out/
52+
53+
# mpeltonen/sbt-idea plugin
54+
.idea_modules/
55+
56+
# JIRA plugin
57+
atlassian-ide-plugin.xml
58+
59+
# Cursive Clojure plugin
60+
.idea/replstate.xml
61+
62+
# Crashlytics plugin (for Android Studio and IntelliJ)
63+
com_crashlytics_export_strings.xml
64+
crashlytics.properties
65+
crashlytics-build.properties
66+
fabric.properties
67+
68+
# Editor-based Rest Client
69+
.idea/httpRequests
70+
71+
# Android studio 3.1+ serialized cache file
72+
.idea/caches/build_file_checksums.ser
73+
74+
target/

pom.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>it.sc2.iregon.aco</groupId>
8+
<artifactId>ArduinoCodeOptimizer</artifactId>
9+
<version>0.1</version>
10+
11+
<build>
12+
<plugins>
13+
<plugin>
14+
<artifactId>maven-compiler-plugin</artifactId>
15+
<configuration>
16+
<source>11</source>
17+
<target>11</target>
18+
</configuration>
19+
</plugin>
20+
</plugins>
21+
</build>
22+
23+
<dependencies>
24+
<dependency>
25+
<groupId>org.openjfx</groupId>
26+
<artifactId>javafx-controls</artifactId>
27+
<version>11</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.openjfx</groupId>
31+
<artifactId>javafx-fxml</artifactId>
32+
<version>11</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>com.jfoenix</groupId>
36+
<artifactId>jfoenix</artifactId>
37+
<version>9.0.9</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>commons-io</groupId>
41+
<artifactId>commons-io</artifactId>
42+
<version>2.6</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.reflections</groupId>
46+
<artifactId>reflections</artifactId>
47+
<version>0.9.11</version>
48+
</dependency>
49+
</dependencies>
50+
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package it.sc2.iregon.aco;
2+
3+
import it.sc2.iregon.aco.gui.Main;
4+
import javafx.application.Application;
5+
6+
public class Program {
7+
8+
public static void main(String[] args) {
9+
Application.launch(Main.class);
10+
}
11+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package it.sc2.iregon.aco.config;
2+
3+
import it.sc2.iregon.aco.config.structure.Pin;
4+
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
import java.util.Optional;
8+
9+
public class AtMega328Mapping implements Mapping {
10+
11+
private List<Pin> pins = new ArrayList<Pin>();
12+
13+
public AtMega328Mapping() {
14+
// Add all pins
15+
addPin("0", "2", "D", "0"); // RX
16+
addPin("1", "3", "D", "1"); // TX
17+
addPin("2", "4", "D", "2"); // D2
18+
addPin("3", "5", "D", "3"); // D3
19+
addPin("4", "6", "D", "4"); // D4
20+
addPin("5", "11", "D", "5"); // D5
21+
addPin("6", "12", "D", "6"); // D6
22+
addPin("7", "13", "D", "7"); // D7
23+
addPin("8", "14", "B", "0"); // D8
24+
addPin("9", "15", "B", "1"); // D9
25+
addPin("10", "16", "B", "2"); // D10
26+
addPin("11", "17", "B", "3"); // D11
27+
addPin("12", "18", "B", "4"); // D12
28+
addPin("13", "19", "B", "5"); // D13
29+
}
30+
31+
@Override
32+
public void addPin(String logicIndex, String chipIndex, String port, String portIndex) {
33+
pins.add(new Pin(logicIndex, chipIndex, port, portIndex));
34+
}
35+
36+
@Override
37+
public void removePin(String logicIndex) {
38+
for(Pin pin : pins) {
39+
if(pin.getLogicIndex().equals(logicIndex)) {
40+
pins.remove(pin);
41+
break;
42+
}
43+
}
44+
}
45+
46+
@Override
47+
public Optional<Pin> findPinByLogicalName(String logicIndex) {
48+
for(Pin pin : pins) {
49+
if(pin.getLogicIndex().equals(logicIndex)) {
50+
return Optional.of(pin);
51+
}
52+
}
53+
return Optional.empty();
54+
}
55+
56+
@Override
57+
public String getMapName() {
58+
return "ATmega8/168/328";
59+
}
60+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package it.sc2.iregon.aco.config;
2+
3+
import it.sc2.iregon.aco.config.structure.Pin;
4+
5+
import java.util.Optional;
6+
7+
public interface Mapping {
8+
void addPin(String logicIndex, String chipIndex, String port, String portIndex);
9+
void removePin(String logicIndex);
10+
Optional<Pin> findPinByLogicalName(String logicIndex);
11+
String getMapName();
12+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package it.sc2.iregon.aco.config;
2+
3+
import java.util.ArrayList;
4+
5+
public class MappingFactory {
6+
7+
ArrayList<Mapping> mappers = new ArrayList<>();
8+
9+
private static MappingFactory instance;
10+
11+
public static MappingFactory getInstance() {
12+
if(instance == null) instance = new MappingFactory();
13+
return instance;
14+
}
15+
16+
public MappingFactory() {
17+
mappers.add(new AtMega328Mapping());
18+
}
19+
20+
public ArrayList<Mapping> getAllMapping() {
21+
return mappers;
22+
}
23+
24+
/**
25+
* Get mapping of a chip
26+
* @param chip chip name <br>
27+
* Chip supported:
28+
* <ul>
29+
* <li>ATmega8/168/328</li>
30+
* </ul>
31+
* @return chip port mapping
32+
*/
33+
public Mapping getMapping(String chip) {
34+
return mappers.stream()
35+
.filter(mapping -> mapping.getMapName().equals(chip))
36+
.findFirst()
37+
.orElse(null);
38+
}
39+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package it.sc2.iregon.aco.config.structure;
2+
3+
public class Pin {
4+
private String logicIndex;
5+
private String chipIndex;
6+
private String port;
7+
private String portIndex;
8+
9+
public Pin(String logicIndex, String chipIndex, String port, String portIndex) {
10+
this.logicIndex = logicIndex;
11+
this.chipIndex = chipIndex;
12+
this.port = port;
13+
this.portIndex = portIndex;
14+
}
15+
16+
public String getLogicIndex() {
17+
return logicIndex;
18+
}
19+
20+
public String getChipIndex() {
21+
return chipIndex;
22+
}
23+
24+
public String getPort() {
25+
return port;
26+
}
27+
28+
public String getPortIndex() {
29+
return portIndex;
30+
}
31+
}

0 commit comments

Comments
 (0)