Skip to content

Commit 4bbf7f8

Browse files
committed
queue external commands, LEDMatrix display
1 parent 93c8cd6 commit 4bbf7f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+911
-402
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ jobs:
5959
- board: CYD
6060
keyboard: NO_KEYBOARD
6161
fqbn: "esp32:esp32:esp32:FlashMode=qio,FlashSize=4M,PartitionScheme=huge_app,LoopCore=0,DebugLevel=info"
62+
- board: LEDMATRIX
63+
keyboard: BLE_KEYBOARD
64+
fqbn: "esp32:esp32:esp32s3:CDCOnBoot=cdc,FlashSize=8M,PSRAM=enabled,PartitionScheme=default_8MB"
6265

6366
steps:
6467
- name: Checkout Code

Makefile

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,50 @@
22
#BOARD := T_HMI
33
#BOARD := T_DISPLAY_S3
44
#BOARD := WAVESHARE
5-
BOARD := CYD
5+
#BOARD := CYD
6+
BOARD := LEDMATRIX
67

78
# choose keyboard
8-
#KEYBOARD := BLE_KEYBOARD
9+
KEYBOARD := BLE_KEYBOARD
910
#KEYBOARD := WEB_KEYBOARD
10-
KEYBOARD := NO_KEYBOARD
11+
#KEYBOARD := NO_KEYBOARD
1112

12-
ifeq ($(BOARD),CYD)
13-
ifneq ($(KEYBOARD),NO_KEYBOARD)
13+
ifeq ($(BOARD), CYD)
14+
ifneq ($(KEYBOARD), NO_KEYBOARD)
1415
$(error FEHLER: If BOARD is set to CYD, KEYBOARD MUST have the value NO_KEYBOARD. (current: $(KEYBOARD)))
1516
endif
1617
endif
1718

1819
UNAME_S := $(shell uname -s)
1920

2021
# choose port
21-
ifeq ($(UNAME_S),Linux)
22-
ifeq ($(BOARD),CYD)
22+
ifeq ($(UNAME_S), Linux)
23+
ifeq ($(BOARD), CYD)
2324
PORT := /dev/ttyUSB0
2425
else
2526
PORT := /dev/ttyACM0
2627
endif
27-
else ifeq ($(UNAME_S),Darwin)
28+
else ifeq ($(UNAME_S), Darwin)
2829
PORT := /dev/tty.usbmodem1101
2930
endif
3031

3132
ALLBOARDS := T_HMI T_DISPLAY_S3 WAVESHARE
3233
ALLKEYBOARDS := BLE_KEYBOARD WEB_KEYBOARD
3334

35+
BUILD_EXTRA_FLAGS := -DBOARD_$(BOARD) -DUSE_$(KEYBOARD) -DESP32
36+
3437
ifeq ($(BOARD), WAVESHARE)
3538
FQBN := esp32:esp32:esp32s3:CDCOnBoot=cdc,DFUOnBoot=dfu,FlashSize=16M,JTAGAdapter=builtin,PartitionScheme=app3M_fat9M_16MB,PSRAM=opi,DebugLevel=info
39+
BUILD_EXTRA_FLAGS += -DBOARD_HAS_PSRAM
40+
else ifeq ($(BOARD), LEDMATRIX)
41+
FQBN := esp32:esp32:esp32s3:CDCOnBoot=cdc,FlashSize=8M,PSRAM=enabled,PartitionScheme=default_8MB
42+
BUILD_EXTRA_FLAGS += -DBOARD_HAS_PSRAM
3643
else
3744
ifeq ($(BOARD),CYD)
3845
FQBN := esp32:esp32:esp32:FlashMode=qio,FlashSize=4M,PartitionScheme=huge_app,LoopCore=0,DebugLevel=info
3946
else
4047
FQBN := esp32:esp32:esp32s3:CDCOnBoot=cdc,DFUOnBoot=dfu,FlashSize=16M,JTAGAdapter=builtin,PartitionScheme=huge_app,PSRAM=opi,DebugLevel=info
48+
BUILD_EXTRA_FLAGS += -DBOARD_HAS_PSRAM
4149
endif
4250
endif
4351

@@ -49,7 +57,7 @@ HEADERFILES := $(shell find src -name '*.h')
4957

5058
TARGET := build-$(BOARD)-$(KEYBOARD)/T-HMI-C64.ino.elf
5159

52-
CLI_COMPILE := compile --warnings all --fqbn $(FQBN) --build-property "build.extra_flags=-DBOARD_$(BOARD) -DUSE_$(KEYBOARD) -DESP32" --build-path build-$(BOARD)-$(KEYBOARD) T-HMI-C64.ino
60+
CLI_COMPILE := compile --warnings all --fqbn $(FQBN) --build-property "build.extra_flags=$(BUILD_EXTRA_FLAGS)" --build-path build-$(BOARD)-$(KEYBOARD) T-HMI-C64.ino
5361

5462
# -DESP32 is needed for ESP_Async_WebServer, Async_TCP
5563
$(TARGET): T-HMI-C64.ino $(SOURCEFILES) $(HEADERFILES)
@@ -69,6 +77,8 @@ compileAll:
6977
done
7078
echo "\nCompiling for Board: CYD"; \
7179
$(MAKE) clean compile BOARD=CYD KEYBOARD=NO_KEYBOARD || exit $$?; \
80+
echo "\nCompiling for LEDMatrix"; \
81+
$(MAKE) clean compile BOARD=LEDMATRIX KEYBOARD=BLE_KEYBOARD || exit $$?; \
7282

7383
# first you have to get the docker image:
7484
# podman pull docker.io/retroelec42/arduino-cli-thmic64:latest
@@ -94,11 +104,14 @@ install: check_install
94104
arduino-cli config set network.connection_timeout 600s
95105
arduino-cli core update-index
96106
arduino-cli core install esp32:esp32@3.2.0
97-
arduino-cli lib install ArduinoJson
107+
arduino-cli lib install ArduinoJson # used to read config file
98108
arduino-cli config set library.enable_unsafe_install true
99-
arduino-cli lib install --git-url https://github.com/ESP32Async/AsyncTCP.git
100-
arduino-cli lib install --git-url https://github.com/ESP32Async/ESPAsyncWebServer.git
101-
arduino-cli lib install --git-url https://github.com/devyte/ESPAsyncDNSServer.git
109+
arduino-cli lib install --git-url https://github.com/ESP32Async/AsyncTCP.git # used for web keyboard
110+
arduino-cli lib install --git-url https://github.com/ESP32Async/ESPAsyncWebServer.git # used for web keyboard
111+
arduino-cli lib install --git-url https://github.com/devyte/ESPAsyncDNSServer.git # used for web keyboard
112+
arduino-cli lib install --git-url https://github.com/mrcodetastic/ESP32-HUB75-MatrixPanel-DMA.git # used for LED matrix panel
113+
arduino-cli lib install --git-url https://github.com/adafruit/Adafruit-GFX-Library.git # used for LED matrix panel
114+
arduino-cli lib install --git-url https://github.com/adafruit/Adafruit_BusIO # used for LED matrix panel
102115

103116
check_install:
104117
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]

README.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# C64 Emulator for ESP32-S3 (and ESP32) with "Android BLE keyboard" or "Web keyboard" (Lilygo T-HMI, Lilygo T-Display S3 AMOLED, Waveshare ESP32-S3-LCD-2.8, CYD)
1+
# C64 Emulator for ESP32-S3 (and ESP32) with "Android BLE keyboard" or "Web keyboard"
22

33
A C64 emulator developed for the [Lilygo T-HMI](https://lilygo.cc/products/t-hmi?srsltid=AfmBOorPecASXq7SyOqsX45fdQunicyf2Bg8MDc_GLFPwDzk0vfWwCg7) development board, featuring an ESP32-S3 chip, a 2.8-inch touch LCD, and an SD card slot.
44
The emulator was later expanded to support the
55
[Lilygo T-Display S3 AMOLED](https://lilygo.cc/products/t-display-s3-amoled?srsltid=AfmBOoq3R6k7Wx7UcW6C1HozzFvwgN2AkHtXgrbJKdD2U9mv75vTSvJI), the [ESP32-S3-LCD-2.8 from Waveshare](https://www.waveshare.com/product/esp32-s3-touch-lcd-2.8.htm)
66
and the [ESP32 CYD board](https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display).
7+
The emulator is also running on an ESP32-S3-WROOM with a 64x64 LED matrix panel.
78

89
Keyboard input is implemented via a custom Android app or via a web interface.
910
The Android app communicates with the emulator via Bluetooth Low Energy (BLE).
@@ -20,10 +21,8 @@ Contact: retroelec42@gmail.com
2021

2122
## News
2223

24+
- Support for LED matrix panel
2325
- Support for CYD board
24-
- "Joystick-only” operation
25-
- Enclosure for the Waveshare Board by uliuc@gmx.net
26-
- Web keyboard by uliuc@gmx.net
2726

2827
## Hardware
2928

@@ -130,6 +129,44 @@ Joystick connections:
130129

131130
Switch voltage to 3.3V on the Arduino joystick module.
132131

132+
### ESP32-S3-WROOM with a 64x64 LED matrix panel
133+
134+
The following pins of a standard ESP32-S3-WROOM module are connected to a 64x64 LED matrix panel as follows:
135+
136+
| Wroom pin | HUB75 pin |
137+
| --------- | --------- |
138+
| 4 | R1 |
139+
| 5 | B1 |
140+
| 6 | R2 |
141+
| 7 | B2 |
142+
| 15 | CH_A |
143+
| 16 | CH_C |
144+
| 41 | CLK |
145+
| 39 | OE |
146+
| 17 | G1 |
147+
| GND | GND |
148+
| 18 | G2 |
149+
| 8 | CH_E |
150+
| 3 | CH_B |
151+
| 46 | CH_D |
152+
| 40 | LAT |
153+
| GND | GND |
154+
155+
Because the resolution of the LED matrix display is too small, either only a section is displayed or it is "scaled".
156+
The following modes are available:
157+
158+
- pixel area follows sprite (slow)
159+
- pixel area follows sprite (fast)
160+
- scale mode "merge x pixels"
161+
- scale mode "extract each x. pixel"
162+
163+
The modes can be changed using the BLE keyboard, DIV screen, SPECIAL1 button.
164+
For the "pixel area follows sprite" modes the sprite to be followed can be determined using the BLE keyboard, DIV screen, SPECIAL2 button.
165+
166+
<img src="doc/ledmatrix_miner_area.png" alt="ledmatrix_miner_area" width="800"/>
167+
<img src="doc/ledmatrix_loderun_area.png" alt="ledmatrix_loderun_area" width="800"/>
168+
<img src="doc/ledmatrix_frogger_scaled.png" alt="ledmatrix_frogger_scaled" width="800"/>
169+
133170
</details>
134171

135172
## Installation

THMIC64KB/app/build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ plugins {
33
}
44

55
android {
6-
compileSdk 32
6+
compileSdk 36
77

88
defaultConfig {
99
applicationId "org.retroelec.thmic64kb"
10-
minSdk 26
11-
targetSdk 32
10+
minSdk 33
11+
targetSdk 33
1212
versionCode 1
1313
versionName "1.0"
1414

@@ -29,6 +29,7 @@ android {
2929
sourceCompatibility JavaVersion.VERSION_1_8
3030
targetCompatibility JavaVersion.VERSION_1_8
3131
}
32+
namespace 'org.retroelec.thmic64kb'
3233
}
3334

3435
dependencies {
@@ -37,6 +38,6 @@ dependencies {
3738
implementation 'com.google.android.material:material:1.3.0'
3839
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
3940
testImplementation 'junit:junit:4.+'
40-
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
41-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
41+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
42+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
4243
}

THMIC64KB/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="org.retroelec.thmic64kb">
4-
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
54
<uses-permission android:name="android.permission.BLUETOOTH" />
65
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
76
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
@@ -12,7 +11,7 @@
1211

1312
<application
1413
android:name=".MyApplication"
15-
android:allowBackup="true"
14+
android:allowBackup="false"
1615
android:icon="@mipmap/thmic64kb"
1716
android:label="THMIC64KB"
1817
android:roundIcon="@mipmap/thmic64kb_round"

THMIC64KB/app/src/main/java/org/retroelec/thmic64kb/Config.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,7 @@ public class Config {
5656
public static final byte SETVOLUME = 33;
5757
public static final byte ATTACHD64 = 37;
5858
public static final byte DETACHD64 = 38;
59+
public static final byte PAUSE = 40;
60+
public static final byte SPECIAL1 = 43;
61+
public static final byte SPECIAL2 = 44;
5962
}

THMIC64KB/app/src/main/java/org/retroelec/thmic64kb/DivActivity.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
public class DivActivity extends AppCompatActivity implements SettingsObserver, NotificationObserver {
3232
private Switch toggleDeactivateTempSwitch;
3333
private Switch toggleSendRawKeyCodes;
34-
private Switch toggleDebug;
34+
// private Switch toggleDebug;
3535
private Switch togglePerf;
3636
private Switch toggleDetectReleaseKey;
3737
private Slider volumeSlider;
@@ -204,14 +204,13 @@ public void updateSettings() {
204204
runOnUiThread(() -> {
205205
toggleDeactivateTempSwitch.setChecked(settings.isDeactivateTemp());
206206
toggleSendRawKeyCodes.setChecked(settings.isSendRawKeyCodes());
207-
toggleDebug.setChecked(settings.isDebug());
207+
// toggleDebug.setChecked(settings.isDebug());
208208
togglePerf.setChecked(settings.isPerf());
209209
toggleDetectReleaseKey.setChecked(settings.isDetectReleaseKey());
210210
volumeSlider.setValue(settings.getVolume() * 100 / 255);
211211
if (settings.isd64attached()) {
212212
keyattach.setBackgroundColor(Config.KEYBGDCOLORD64ATTACHED);
213-
}
214-
else {
213+
} else {
215214
keyattach.setBackgroundColor(Config.KEYBGDCOLORACTION);
216215
}
217216
});
@@ -288,8 +287,8 @@ protected void onCreate(Bundle savedInstanceState) {
288287
toggleSendRawKeyCodes = findViewById(R.id.toggleSendRawKeyCodes);
289288
toggleSendRawKeyCodes.setOnClickListener(v -> bleUtils.send(new byte[]{Config.SENDRAWKEYS, (byte) 0x00, (byte) 0x80}, false));
290289

291-
toggleDebug = findViewById(R.id.toggleDebug);
292-
toggleDebug.setOnClickListener(v -> bleUtils.send(new byte[]{Config.SWITCHDEBUG, (byte) 0x00, (byte) 0x80}, false));
290+
// toggleDebug = findViewById(R.id.toggleDebug);
291+
// toggleDebug.setOnClickListener(v -> bleUtils.send(new byte[]{Config.SWITCHDEBUG, (byte) 0x00, (byte) 0x80}, false));
293292

294293
togglePerf = findViewById(R.id.togglePerf);
295294
togglePerf.setOnClickListener(v -> bleUtils.send(new byte[]{Config.SWITCHPERF, (byte) 0x00, (byte) 0x80}, false));
@@ -337,17 +336,19 @@ protected void onCreate(Bundle savedInstanceState) {
337336
final Button send = findViewById(R.id.send);
338337
send.setOnClickListener(view -> openFilePicker());
339338

340-
final Button keystatus = findViewById(R.id.keystatus);
341-
keystatus.setOnClickListener(view -> {
342-
Intent i = new Intent(this, StatusActivity.class);
343-
startActivity(i);
344-
});
345-
346-
final Button keymemory = findViewById(R.id.keymemory);
347-
keymemory.setOnClickListener(view -> {
348-
Intent i = new Intent(this, MemoryActivity.class);
349-
startActivity(i);
350-
});
339+
final Button keyspecial1 = findViewById(R.id.keyspecial1);
340+
keyspecial1.setOnTouchListener(bleUtils.createButtonTouchListener(keyspecial1, new byte[]{Config.SPECIAL1, (byte) 0x00, (byte) 0x80}, Config.KEYSELECTEDCOLORACTION, Config.KEYBGDCOLORACTION, true));
341+
// keyspecial1.setOnClickListener(view -> {
342+
// Intent i = new Intent(this, StatusActivity.class);
343+
// startActivity(i);
344+
// });
345+
346+
final Button keyspecial2 = findViewById(R.id.keyspecial2);
347+
keyspecial2.setOnTouchListener(bleUtils.createButtonTouchListener(keyspecial2, new byte[]{Config.SPECIAL2, (byte) 0x00, (byte) 0x80}, Config.KEYSELECTEDCOLORACTION, Config.KEYBGDCOLORACTION, true));
348+
// keyspecial2.setOnClickListener(view -> {
349+
// Intent i = new Intent(this, MemoryActivity.class);
350+
// startActivity(i);
351+
// });
351352

352353
final Button keysave = findViewById(R.id.keysave);
353354
keysave.setOnTouchListener(bleUtils.createButtonTouchListener(keysave, new byte[]{Config.SAVE, (byte) 0x00, (byte) 0x80}, Config.KEYSELECTEDCOLORACTION, Config.KEYBGDCOLORACTION, true));

THMIC64KB/app/src/main/res/layout/div.xml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
android:layout_height="wrap_content"
2424
android:text="Commando hack" />
2525

26-
<Switch
26+
<!--Switch
2727
android:id="@+id/toggleDebug"
2828
android:layout_width="wrap_content"
2929
android:layout_height="wrap_content"
30-
android:text="Monitor CPU" />
30+
android:text="Monitor CPU" /-->
3131

3232
<Switch
3333
android:id="@+id/togglePerf"
@@ -82,26 +82,29 @@
8282
android:layout_height="wrap_content"
8383
android:layout_marginEnd="10dp"
8484
android:layout_weight="1"
85+
android:backgroundTint="#cc7777"
8586
android:text="SENDPRG"
8687
android:theme="@style/ButtonTheme" />
8788

8889
<Button
89-
android:id="@+id/keystatus"
90+
android:id="@+id/keyspecial1"
9091
android:layout_width="0dp"
9192
android:layout_height="wrap_content"
9293
android:layout_marginStart="10dp"
9394
android:layout_marginEnd="10dp"
9495
android:layout_weight="1"
95-
android:text="STATUS"
96+
android:backgroundTint="#cc7777"
97+
android:text="SPECIAL1"
9698
android:theme="@style/ButtonTheme" />
9799

98100
<Button
99-
android:id="@+id/keymemory"
101+
android:id="@+id/keyspecial2"
100102
android:layout_width="0dp"
101103
android:layout_height="wrap_content"
102104
android:layout_marginStart="10dp"
103105
android:layout_weight="1"
104-
android:text="MEMORY"
106+
android:backgroundTint="#cc7777"
107+
android:text="SPECIAL2"
105108
android:theme="@style/ButtonTheme" />
106109

107110
<TextView

THMIC64KB/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
mavenCentral()
66
}
77
dependencies {
8-
classpath "com.android.tools.build:gradle:7.0.4"
8+
classpath 'com.android.tools.build:gradle:8.13.2'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files
@@ -14,4 +14,4 @@ buildscript {
1414

1515
task clean(type: Delete) {
1616
delete rootProject.buildDir
17-
}
17+
}

THMIC64KB/gradle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
1616
# https://developer.android.com/topic/libraries/support-library/androidx-rn
1717
android.useAndroidX=true
1818
# Automatically convert third-party libraries to use AndroidX
19-
android.enableJetifier=true
19+
android.enableJetifier=true
20+
android.defaults.buildfeatures.buildconfig=true
21+
android.nonTransitiveRClass=false
22+
android.nonFinalResIds=false

0 commit comments

Comments
 (0)