├── .travis.yml
├── README.md
├── aREST_UI.h
├── examples
├── ESP8266
│ └── ESP8266.ino
├── WiFi_CC3000
│ └── WiFi_CC3000.ino
└── WildFire
│ └── WildFire.ino
├── library.json
└── library.properties
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: c
2 | before_install:
3 | - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16"
4 | - sleep 3
5 | - export DISPLAY=:1.0
6 | - wget http://downloads.arduino.cc/arduino-1.6.5-linux64.tar.xz
7 | - tar xf arduino-1.6.5-linux64.tar.xz
8 | - sudo mv arduino-1.6.5 /usr/local/share/arduino
9 | - sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino
10 | install:
11 | - ln -s $PWD /usr/local/share/arduino/libraries/aREST_UI
12 | - arduino --install-library "Adafruit CC3000 Library"
13 | - arduino --install-library "CC3000 MDNS"
14 | - arduino --install-library "aREST"
15 | script:
16 | - arduino --verify --board arduino:avr:mega:cpu=atmega2560 $PWD/examples/WiFi_CC3000/WiFi_CC3000.ino
17 | notifications:
18 | email:
19 | on_success: change
20 | on_failure: change
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # aREST_UI [](https://travis-ci.org/marcoschwartz/aREST_UI)
2 |
3 | Version 1.1.1
4 |
5 | ## Overview
6 |
7 | aREST UI is an embedded UI for the aREST framework. Currently works with the Arduino Mega & Arduino Due with the CC3000 WiFi chip, the WiFi shield, and the Ethernet shield. It works as well with the Arduino Zero with the WiFi 101 shield, and with the Arduino MKR1000 board.
8 |
9 | It also works with the ESP8266 WiFi chip.
10 |
11 | If you want to know more about aREST, go over to [http://arest.io/](http://arest.io/).
12 |
13 | ## Contents
14 |
15 | - aREST_UI.h: the library file.
16 | - examples: several examples using the aREST UI library
17 |
18 | ## Requirements
19 |
20 | To use the library with Arduino boards you will need the latest version of the Arduino IDE:
21 |
22 | - [Arduino IDE 1.6.5](http://arduino.cc/en/main/software)
23 |
24 | You will also need the aREST library:
25 |
26 | - [aREST](https://github.com/marcoschwartz/aREST)
27 |
28 | ### For WiFi using the CC3000 chip
29 |
30 | - [Adafruit CC3000 Library](https://github.com/adafruit/Adafruit_CC3000_Library)
31 | - [Adafruit MDNS Library](https://github.com/adafruit/CC3000_MDNS)
32 | - MDNS support in your operating system:
33 | - For OS X it is supported through Bonjour, you don't have anything to install.
34 | - For Linux, you need to install [Avahi](http://avahi.org/).
35 | - For Windows, you need to install [Bonjour](http://www.apple.com/support/bonjour/).
36 |
37 | ## Setup
38 |
39 | To install the library, simply clone this repository in the /libraries folder of your Arduino folder.
40 |
41 | ## Quick test (WiFi)
42 |
43 | 1. Connect a LED & resistor to pin number 6 of your Arduino Mega board
44 | 2. Open the WiFi_CC3000 example sketch and modify the WiFi SSID and password
45 | 3. Upload the sketch to the board
46 | 4. Go to a web browser and type `http://arduino.local`
47 | 5. Click on the 'On' button and the LED should turn on
48 |
49 | ## Quick test (WildFire)
50 |
51 | 1. Connect a LED & resistor to pin number 6 of your WildFire board
52 | 2. Open the WildFire example sketch and modify the WiFi SSID and password
53 | 3. Upload the sketch to the board
54 | 4. Go to a web browser and type `http://wildfire.local`
55 | 5. Click on the 'On' button and the LED should turn on
56 |
57 | ## API documentation
58 |
59 | ### Create aREST UI instance
60 |
61 | You can simply create an instance of aREST UI with the following command:
62 |
63 | `aREST_UI ui = aREST_UI();`
64 |
65 | ### Title
66 |
67 | If you don't want to run with the default title, set your own for the UI.
68 |
69 | `ui.title("Your title");`
70 |
71 | ### Button
72 |
73 | Buttons are used to control the state of a digital output pin. The command creates two button inside the interface, one 'On' button, and one 'Off' button. For example, the following command creates a pair of buttons to control pin number 6:
74 |
75 | `ui.button(6)`
76 |
77 | ### Slider
78 |
79 | The slider command creates a slider to control a pin via PWM. For example, it can be used to control the intensity of a LED connected to this pin. The following command creates a pair of buttons to control pin number 6:
80 |
81 | `ui.slider(6)`;
82 |
83 | ### Label
84 |
85 | Labels are used to display the value of variables inside the interface. Before you can use this command, you need to create the corresponding variable first. The following command declares a variable called temperature:
86 |
87 | `ui.variable("temperature",&temperature);`
88 |
89 | After that, you can use the following command to create the corresponding label inside the interface:
90 |
91 | `ui.label("temperature")`;
92 |
--------------------------------------------------------------------------------
/aREST_UI.h:
--------------------------------------------------------------------------------
1 | /*
2 | aREST UI for Arduino & the ESP8266
3 | See the README file for more details.
4 |
5 | Written in 2015 by Marco Schwartz under a GPL license.
6 | Version 1.1.1
7 |
8 | Changelog:
9 |
10 | Version 1.1.1: Fixed bug with NodeMCU boards
11 | Version 1.1.0: Added support for functions
12 | Version 1.0.1: Initial release with buttons only
13 | */
14 |
15 | #ifndef aRest_ui_h
16 | #define aRest_ui_h
17 |
18 | // Include Arduino header
19 | #include "Arduino.h"
20 |
21 | // Using ESP8266 ?
22 | #if defined(ESP8266)
23 | #include "stdlib_noniso.h"
24 | #endif
25 |
26 | class aREST_UI: public aREST {
27 |
28 | public:
29 |
30 | aREST_UI() {
31 |
32 | }
33 |
34 | // Get title
35 | void title(String the_title) {
36 | ui_title = the_title;
37 | }
38 |
39 | // Create button
40 | void button(int pin){
41 |
42 | // Set pin as output
43 | #if defined(ARDUINO_ESP8266_NODEMCU) || defined(ARDUINO_ESP8266_WEMOS_D1MINI)
44 | pinMode(esp_12_pin_map(pin), OUTPUT);
45 | #else
46 | pinMode(pin, OUTPUT);
47 | #endif
48 |
49 | // Set in button array
50 | buttons[buttons_index] = pin;
51 | buttons_index++;
52 |
53 | }
54 |
55 | // Create function control
56 | void callFunction(char * functionName, char * type){
57 |
58 | // Set in callFunction array
59 | callFunctionNames[functions_index] = functionName;
60 | callFunctionTypes[functions_index] = type;
61 | functions_index++;
62 |
63 | }
64 |
65 | // Create slider
66 | void slider(int pin) {
67 |
68 | // Set pin as output
69 | #if defined(ARDUINO_ESP8266_NODEMCU) || defined(ARDUINO_ESP8266_WEMOS_D1MINI)
70 | pinMode(esp_12_pin_map(pin), OUTPUT);
71 | #else
72 | pinMode(pin, OUTPUT);
73 | #endif
74 |
75 | // Set in button array
76 | sliders[sliders_index] = pin;
77 | sliders_index++;
78 |
79 | }
80 |
81 | // Create label
82 | void label(char * label_name){
83 |
84 | int_labels_names[int_labels_index] = label_name;
85 | int_labels_index++;
86 |
87 | }
88 |
89 | // Handle connection
90 | virtual void root_answer() {
91 |
92 | // Answer
93 | addToBuffer("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n");
94 | addToBuffer("