Skip to content

Commit 6a4fd66

Browse files
committed
newlibrary
1 parent 5b24b95 commit 6a4fd66

File tree

10 files changed

+2086
-1
lines changed

10 files changed

+2086
-1
lines changed

README.md

Lines changed: 255 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,255 @@
1-
# WebGUI
1+
# WebGUI Library for Arduino
2+
3+
[![Arduino](https://img.shields.io/badge/Arduino-Compatible-blue.svg)](https://www.arduino.cc/)
4+
[![ESP32](https://img.shields.io/badge/ESP32-Compatible-green.svg)](https://www.espressif.com/en/products/socs/esp32)
5+
[![License: LGPL v2.1](https://img.shields.io/badge/License-LGPL%20v2.1-blue.svg)](https://www.gnu.org/licenses/lgpl-2.1)
6+
7+
A simple and powerful web-based GUI library for Arduino that enables you to create beautiful control interfaces accessible through any web browser. Perfect for IoT projects, home automation, and remote device control.
8+
9+
## Features
10+
11+
- **Web-Based Interface**: Access your Arduino through any web browser - no app installation required
12+
- **Mobile-Friendly**: Responsive design works on phones, tablets, and computers
13+
- **Easy Controls**: Simple buttons and sliders with real-time updates
14+
- **WiFi Access Point**: Creates its own WiFi network for direct connection
15+
- **Customizable Themes**: Built-in themes and custom CSS support
16+
- **Real-Time Updates**: Instant feedback between web interface and Arduino
17+
- **Cross-Platform**: Works on multiple Arduino boards
18+
19+
## Compatible Hardware
20+
21+
- **Arduino UNO R4 WiFi**
22+
- **Arduino Nano 33 IoT**
23+
- **ESP32** (all variants)
24+
25+
## Installation
26+
27+
### Arduino IDE Library Manager (Recommended)
28+
1. Open Arduino IDE
29+
2. Go to **Sketch****Include Library****Manage Libraries**
30+
3. Search for "WebGUI"
31+
4. Click **Install**
32+
33+
### Manual Installation
34+
1. Download the latest release from [GitHub](https://github.com/npuckett/WebGUI)
35+
2. Extract the ZIP file
36+
3. Copy the `WebGUI` folder to your Arduino `libraries` directory
37+
4. Restart Arduino IDE
38+
39+
## Quick Start
40+
41+
```cpp
42+
#include <WebGUI.h>
43+
44+
// Create controls
45+
Button myButton("Click Me!", 20, 50);
46+
Slider mySlider("Brightness", 20, 100, 0, 255, 128);
47+
48+
void setup() {
49+
Serial.begin(115200);
50+
51+
// Start WiFi Access Point
52+
GUI.startAP("My-Arduino", "password123");
53+
54+
// Add controls to GUI
55+
GUI.addElement(&myButton);
56+
GUI.addElement(&mySlider);
57+
58+
// Start web server
59+
GUI.begin();
60+
61+
Serial.println("Connect to WiFi: My-Arduino");
62+
Serial.println("Visit: http://" + GUI.getIP());
63+
}
64+
65+
void loop() {
66+
GUI.update();
67+
68+
if (myButton.wasPressed()) {
69+
Serial.println("Button pressed!");
70+
}
71+
72+
int brightness = mySlider.getIntValue();
73+
// Use brightness value...
74+
}
75+
```
76+
77+
## API Reference
78+
79+
### WebGUI Class
80+
81+
#### Setup Methods
82+
```cpp
83+
GUI.startAP(ssid, password); // Create WiFi access point
84+
GUI.connectWiFi(ssid, password); // Connect to existing WiFi
85+
GUI.begin(); // Start web server
86+
GUI.update(); // Process web requests (call in loop)
87+
```
88+
89+
#### Configuration Methods
90+
```cpp
91+
GUI.setTitle("My Project"); // Set browser tab title
92+
GUI.setHeading("Control Panel"); // Set page heading
93+
GUI.setTheme(WEBGUI_DARK_THEME); // Apply color theme
94+
GUI.setCustomCSS("button { ... }"); // Add custom styling
95+
GUI.addElement(&myControl); // Add control to interface
96+
```
97+
98+
### Button Class
99+
100+
#### Constructor
101+
```cpp
102+
Button(label, x, y, width=100, height=40);
103+
```
104+
105+
#### Methods
106+
```cpp
107+
bool wasPressed(); // Check if button was clicked
108+
bool isPressed(); // Check current press state
109+
void setButtonStyle("primary"); // Set button style
110+
```
111+
112+
### Slider Class
113+
114+
#### Constructor
115+
```cpp
116+
Slider(label, x, y, minValue, maxValue, defaultValue, width=300);
117+
```
118+
119+
#### Methods
120+
```cpp
121+
int getIntValue(); // Get current value as integer
122+
float getFloatValue(); // Get current value as float
123+
void setValue(value); // Set slider value
124+
void setRange(min, max); // Change min/max values
125+
```
126+
127+
## Styling and Themes
128+
129+
### Built-in Themes
130+
```cpp
131+
GUI.setTheme(WEBGUI_DEFAULT_THEME); // Light theme
132+
GUI.setTheme(WEBGUI_DARK_THEME); // Dark theme
133+
```
134+
135+
### Custom CSS
136+
```cpp
137+
GUI.setCustomCSS(
138+
".webgui-button { "
139+
" background: linear-gradient(145deg, #ff6b6b, #ee5a52); "
140+
" border-radius: 20px; "
141+
"}"
142+
);
143+
```
144+
145+
## Layout Guidelines
146+
147+
### Button Positioning
148+
- Height: 30-40px recommended
149+
- Horizontal spacing: 20px minimum between buttons
150+
- Example: `Button("Btn1", 20, 50)`, `Button("Btn2", 140, 50)`
151+
152+
### Slider Positioning
153+
- Height: ~60px total (includes label and padding)
154+
- Vertical spacing: 70px recommended between sliders
155+
- Example: `Slider("S1", 20, 100, ...)`, `Slider("S2", 20, 170, ...)`
156+
157+
## Network Configuration
158+
159+
### Access Point Mode (Default)
160+
```cpp
161+
GUI.startAP("MyDevice", "mypassword");
162+
```
163+
- Creates its own WiFi network
164+
- No internet router required
165+
- Perfect for portable projects
166+
167+
### Station Mode (Connect to existing WiFi)
168+
```cpp
169+
GUI.connectWiFi("YourWiFi", "wifipassword");
170+
```
171+
- Connects to your home/office WiFi
172+
- Allows internet access alongside device control
173+
174+
## Usage Instructions
175+
176+
1. **Upload your sketch** to the Arduino
177+
2. **Connect to WiFi network** created by Arduino (or your home WiFi if using station mode)
178+
3. **Open web browser** and navigate to the IP address shown in Serial Monitor
179+
4. **Control your project** using the web interface!
180+
181+
## Advanced Examples
182+
183+
### Multiple Controls
184+
```cpp
185+
Button power("Power", 20, 50);
186+
Button reset("Reset", 140, 50);
187+
Slider speed("Speed", 20, 100, 0, 100, 50);
188+
Slider angle("Angle", 20, 170, 0, 180, 90);
189+
190+
void setup() {
191+
GUI.startAP("Robot-Control", "robot123");
192+
GUI.setTitle("Robot Controller");
193+
GUI.setHeading("My Robot Dashboard");
194+
195+
GUI.addElement(&power);
196+
GUI.addElement(&reset);
197+
GUI.addElement(&speed);
198+
GUI.addElement(&angle);
199+
200+
GUI.begin();
201+
}
202+
```
203+
204+
### Custom Styling
205+
```cpp
206+
void setup() {
207+
GUI.setCustomCSS(
208+
"body { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }"
209+
".webgui-button { box-shadow: 0 8px 16px rgba(0,0,0,0.3); }"
210+
".webgui-slider { accent-color: #ff6b6b; }"
211+
);
212+
}
213+
```
214+
215+
## Troubleshooting
216+
217+
### Common Issues
218+
219+
**Can't connect to WiFi network**
220+
- Check SSID and password in Serial Monitor output
221+
- Ensure device WiFi is enabled
222+
- Try restarting Arduino if network doesn't appear
223+
224+
**Web page doesn't load**
225+
- Verify IP address in Serial Monitor
226+
- Check that you're connected to Arduino's WiFi network
227+
- Try accessing `192.168.4.1` (default AP IP)
228+
229+
**Controls don't respond**
230+
- Ensure `GUI.update()` is called in `loop()`
231+
- Check Serial Monitor for error messages
232+
- Verify control positioning doesn't overlap
233+
234+
**Compilation errors**
235+
- Install required WiFi libraries (WiFiS3, WiFiNINA)
236+
- Select correct board in Arduino IDE
237+
- Update to latest Arduino IDE version
238+
239+
## License
240+
241+
This library is released under the GNU Lesser General Public License v2.1. See [LICENSE](LICENSE) for details.
242+
243+
## Contributing
244+
245+
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
246+
247+
## Support
248+
249+
- **Documentation**: [GitHub Wiki](https://github.com/npuckett/WebGUI/wiki)
250+
- **Issues**: [GitHub Issues](https://github.com/npuckett/WebGUI/issues)
251+
- **Examples**: See `examples/` folder in library
252+
253+
---
254+
255+
**Made with care for the Arduino community**

0 commit comments

Comments
 (0)