Skip to content

Commit 3e0f385

Browse files
authored
Merge pull request #4 from amrikarisma/feature/webserver
Feature/webserver
2 parents ed1c16c + d49b443 commit 3e0f385

11 files changed

Lines changed: 1474 additions & 119 deletions

ALL_COMMANDS.md

Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
# Mazduino Dashboard - All Commands Reference
2+
3+
## 📋 **Serial Commands Summary**
4+
5+
### 🎮 **Simulator Commands** (Mode: Simulator)
6+
```
7+
0 = OFF (use real data)
8+
1 = RPM SWEEP (0-6000 RPM)
9+
2 = ENGINE IDLE (800-900 RPM)
10+
3 = DRIVING (1500-4000 RPM)
11+
4 = REDLINE (5500-6000 RPM)
12+
h = Show simulator help
13+
```
14+
15+
### 🔧 **Debug Commands** (Mode: Debug)
16+
```
17+
d = Toggle debug mode ON/OFF
18+
i = Show system information
19+
```
20+
21+
### 🌐 **Web Server Commands** (Mode: WiFi Access Point)
22+
```
23+
Network: MAZDUINO_Display (password: 12345678)
24+
IP: 192.168.4.1
25+
Auto-starts: 15 seconds after boot
26+
Auto-shuts: 1 minute no connections
27+
28+
Web Interface Features:
29+
- Real-time status updates
30+
- Display mode toggle (ECU Data/Trigger Error)
31+
- Communication mode selection (CAN/Serial)
32+
- Debug mode toggle
33+
- Simulator mode controls (0-4)
34+
- OTA firmware update
35+
- System information display
36+
```
37+
38+
### 📊 **All Available Commands**
39+
```
40+
=== SIMULATOR COMMANDS ===
41+
0 = Turn OFF simulator
42+
1 = RPM sweep mode
43+
2 = Engine idle mode
44+
3 = Driving mode
45+
4 = Redline mode
46+
h = Simulator help menu
47+
48+
=== DEBUG COMMANDS ===
49+
d = Toggle debug display
50+
i = System info dump
51+
52+
=== WEB INTERFACE COMMANDS ===
53+
/debug - Toggle debug mode
54+
/simulator - Control simulator modes
55+
/status - Get real-time status (JSON)
56+
/toggle - Toggle display configuration
57+
/setMode - Change communication mode
58+
59+
=== HELP COMMANDS ===
60+
h = Simulator help
61+
i = System information
62+
```
63+
64+
## 🎯 **Visual Indicators**
65+
66+
### On Display
67+
```
68+
[CAN/SER] [DEBUG INFO] [SIM]
69+
Top-left Top-center Top-right
70+
71+
CAN = Green text (CAN Bus mode)
72+
SER = Orange text (Serial mode)
73+
DEBUG = Cyan text (CPU/FPS/Heap info)
74+
SIM = Yellow text (Simulator active)
75+
```
76+
77+
### On Web Interface
78+
```
79+
Communication Mode:
80+
- CAN Bus: Green indicator
81+
- Serial: Orange indicator
82+
83+
Real-time Status:
84+
- Updates every second
85+
- Shows current mode, debug status, simulator mode
86+
- Memory usage and uptime
87+
```
88+
89+
## 🚀 **Quick Start Guide**
90+
91+
### 1. **Upload & Monitor:**
92+
```bash
93+
# Upload firmware
94+
/Users/amri/Library/Python/3.12/bin/pio run -t upload
95+
96+
# Monitor serial
97+
/Users/amri/Library/Python/3.12/bin/pio device monitor --baud 115200
98+
```
99+
100+
### 2. **Expected Startup:**
101+
```
102+
=== MAZDUINO DASHBOARD STARTING ===
103+
Communication mode: CAN
104+
CAN mode aktif.
105+
=== MAZDUINO SIMULATOR INITIALIZED ===
106+
Available modes: 0,1,2,3,4,h
107+
=== DEBUG MODE AVAILABLE ===
108+
Send 'd' to toggle debug mode
109+
Send 'i' for system info
110+
```
111+
112+
### 3. **Test Commands:**
113+
```
114+
# Enable debug mode
115+
d
116+
117+
# Expected output:
118+
[DEBUG] Debug mode ON
119+
=== DEBUG MODE ENABLED ===
120+
CPU Usage and FPS will be displayed
121+
Serial debug prints enabled
122+
Send 'd' again to disable
123+
124+
# Check system info
125+
i
126+
127+
# Expected output:
128+
=== SYSTEM INFO ===
129+
Free Heap: 291840 bytes
130+
Min Free Heap: 285632 bytes
131+
CPU Freq: 240 MHz
132+
Flash Size: 4194304 bytes
133+
Chip Model: ESP32
134+
Chip Revision: 1
135+
Uptime: 45 seconds
136+
```
137+
138+
### 4. **Visual Confirmation:**
139+
**Debug Mode ON:**
140+
- Pojok kiri atas: `CPU:15.2% FPS:12.3 Heap:285KB DBG`
141+
- Pojok kanan atas: `SIM` (jika simulator aktif)
142+
143+
**Debug Mode OFF:**
144+
- Area debug bersih
145+
- Hanya `SIM` indicator jika simulator aktif
146+
147+
## 🎯 **Use Cases**
148+
149+
### **Development & Testing:**
150+
```
151+
1. Enable debug: 'd'
152+
2. Start simulator: '1' (RPM sweep)
153+
3. Monitor performance
154+
4. Check system info: 'i'
155+
5. Disable debug: 'd'
156+
```
157+
158+
### **Performance Monitoring:**
159+
```
160+
1. Enable debug: 'd'
161+
2. Monitor CPU usage, FPS, memory
162+
3. Test different modes: '1','2','3','4'
163+
4. Check system stability
164+
```
165+
166+
### **Troubleshooting:**
167+
```
168+
1. Check system info: 'i'
169+
2. Enable debug: 'd'
170+
3. Monitor metrics in real-time
171+
4. Check for memory leaks
172+
5. Verify performance
173+
```
174+
175+
## 📊 **Expected Performance**
176+
177+
### **Normal Operation:**
178+
- **CPU Usage**: 10-30%
179+
- **FPS**: 8-15 FPS
180+
- **Free Heap**: >250KB
181+
- **Loop Time**: <100ms
182+
183+
### **With Debug Mode:**
184+
- **CPU Usage**: +5-10% overhead
185+
- **FPS**: Minimal impact
186+
- **Free Heap**: -5KB for debug variables
187+
- **Loop Time**: +10-20ms
188+
189+
### **With Simulator:**
190+
- **CPU Usage**: +10-20% (depends on mode)
191+
- **FPS**: Minimal impact
192+
- **Free Heap**: -10KB for simulator data
193+
- **Loop Time**: +20-30ms
194+
195+
## 🔧 **Configuration**
196+
197+
### **Enable/Disable Features:**
198+
Edit `src/Config.h`:
199+
```cpp
200+
#define ENABLE_SIMULATOR 1 // 1=ON, 0=OFF
201+
#define ENABLE_DEBUG_MODE 1 // 1=ON, 0=OFF
202+
```
203+
204+
### **Debug Update Rates:**
205+
Edit `src/main.cpp`:
206+
```cpp
207+
// CPU & FPS update: 1000ms (1 second)
208+
// Serial debug print: 2000ms (2 seconds)
209+
```
210+
211+
## ✅ **Success Criteria**
212+
213+
### **Startup Test:**
214+
- [x] Simulator initializes with modes 0,1,2,3,4,h
215+
- [x] Debug mode available with 'd','i' commands
216+
- [x] Visual indicators work (SIM, DBG)
217+
- [x] Serial commands respond properly
218+
219+
### **Simulator Test:**
220+
- [x] Mode 1: RPM sweep 0→6000→0
221+
- [x] Mode 2: Idle ~850 RPM
222+
- [x] Mode 3: Driving 1500-4000 RPM
223+
- [x] Mode 4: Redline 5750-5940 RPM
224+
- [x] Mode 0: OFF, back to real data
225+
226+
### **Debug Test:**
227+
- [x] 'd' toggles debug display ON/OFF
228+
- [x] CPU usage shows reasonable values
229+
- [x] FPS updates continuously
230+
- [x] Memory info is accurate
231+
- [x] System info command 'i' works
232+
233+
### **Performance Test:**
234+
- [x] CPU usage <50% in normal operation
235+
- [x] FPS >5 for smooth display
236+
- [x] Memory >200KB free
237+
- [x] No crashes or hangs
238+
- [x] Responsive to commands
239+
240+
## 🎉 **Complete Feature Set**
241+
242+
### **Implemented Features:**
243+
1. **Modular Code Structure** - Clean separation of concerns
244+
2. **CAN Bus Support** - Real ECU data communication
245+
3. **Simulator Mode** - 5 realistic test modes
246+
4. **Debug Mode** - Performance monitoring
247+
5. **Visual Indicators** - SIM, DBG status
248+
6. **Serial Commands** - Interactive control
249+
7. **RPM Bar Display** - Smooth animation
250+
8. **Sensor Monitoring** - AFR, TPS, MAP, etc.
251+
9. **Backlight Control** - Auto-adjust based on RPM
252+
10. **Memory Management** - Heap monitoring
253+
11. **FPS Monitoring** - Display performance
254+
12. **CPU Usage** - System load monitoring
255+
13. **System Info** - Hardware details
256+
14. **Error Handling** - Graceful degradation
257+
15. **Configuration** - Compile-time options
258+
259+
**Mazduino Dashboard sekarang lengkap dengan semua fitur debug dan monitoring! 🚀**
260+
261+
### **Final Commands:**
262+
- **Simulator**: `0`,`1`,`2`,`3`,`4`,`h`
263+
- **Debug**: `d`,`i`
264+
- **Visual**: SIM indicator, DBG display
265+
- **Performance**: CPU, FPS, Memory monitoring

src/CANHandler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ void setupCAN() {
1717
CAN0.watchFor(0x3E0); // CLT, IAT
1818
CAN0.watchFor(0x3E4); // Indicator
1919

20+
isCANMode = true; // Set communication mode indicator
2021
Serial.println("CAN mode aktif.");
2122
}
2223

@@ -34,6 +35,8 @@ void handleCANCommunication() {
3435
lastRefresh = millis();
3536
unsigned long currentTime = millis();
3637

38+
isCANMode = true; // We're in CAN mode when this function is called
39+
3740
if (CAN0.available()) {
3841
CAN_FRAME can_message;
3942
if (CAN0.read(can_message)) {

src/DataTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern uint16_t spr_width;
2626
// Communication variables
2727
extern int commMode;
2828
extern bool sent, received;
29+
extern bool isCANMode; // true for CAN, false for Serial
2930

3031
// WiFi variables
3132
extern bool wifiActive;

0 commit comments

Comments
 (0)