├── src ├── Font16.h ├── Font32rle.h ├── Font64rle.h ├── Font72rle.h ├── Font7srle.h ├── Language.h ├── ServoControl.h ├── Action.h ├── evive.cpp ├── Examples.h ├── SlideSwitch.h ├── ServoControl.cpp ├── Dac_MCP4725.h ├── EvivePins.h ├── Plot.h ├── Potentiometer.h ├── main.cpp ├── SerialMonitor.h ├── Potentiometer.cpp ├── main.h ├── Button.h ├── AddUserDefinedFunctions.h ├── ServoTimers.h ├── Configuration.h ├── Ade7912_Adc.h ├── TftMonitor.h ├── Screen.h ├── SlideSwitch.cpp ├── MPR121_Touch.h ├── Navkey.h ├── Plot.cpp ├── TFT_User_Setup.h ├── keywords.txt ├── Action.cpp ├── MPR121_Touch.cpp ├── Rtc_Pcf8563.h ├── ReadMe.md ├── SerialMonitor.cpp └── Stepper.h ├── examples ├── eviveFirmwareExtended │ ├── Font16.h │ ├── Font32rle.h │ ├── Font64rle.h │ ├── Font72rle.h │ ├── Font7srle.h │ ├── Language.h │ ├── ServoControl.h │ ├── Action.h │ ├── evive.cpp │ ├── Examples.h │ ├── eviveFirmwareExtended.ino │ ├── SlideSwitch.h │ ├── ServoControl.cpp │ ├── Dac_MCP4725.h │ ├── EvivePins.h │ ├── Plot.h │ ├── Potentiometer.h │ ├── main.cpp │ ├── ReadMe.md │ ├── SerialMonitor.h │ ├── Potentiometer.cpp │ ├── main.h │ ├── Button.h │ ├── AddUserDefinedFunctions.h │ ├── ServoTimers.h │ ├── Configuration.h │ ├── Ade7912_Adc.h │ ├── TftMonitor.h │ ├── Screen.h │ ├── SlideSwitch.cpp │ ├── MPR121_Touch.h │ ├── Navkey.h │ ├── Plot.cpp │ ├── keywords.txt │ ├── TFT_User_Setup.h │ ├── Action.cpp │ ├── MPR121_Touch.cpp │ ├── SerialMonitor.cpp │ └── Stepper.h ├── Easy │ ├── SerialReceive │ │ └── SerialReceive.ino │ ├── SlideSwitch │ │ └── SlideSwitch.ino │ ├── Fading │ │ └── Fading.ino │ ├── AnalogDataRead │ │ └── AnalogDataRead.ino │ └── Button │ │ └── Button.ino ├── Intermediate │ ├── Buzzer │ │ ├── Frequencies │ │ │ └── Frequencies.ino │ │ └── buzzerTest │ │ │ └── buzzerTest.ino │ ├── TFT │ │ ├── HelloWorld │ │ │ └── HelloWorld.ino │ │ ├── TextSize │ │ │ └── TextSize.ino │ │ ├── digitalButton │ │ │ └── digitalButton.ino │ │ ├── Shapes │ │ │ └── Shapes.ino │ │ └── Colors │ │ │ └── Colors.ino │ ├── Touch │ │ ├── State │ │ │ └── State.ino │ │ └── ColorMixer │ │ │ └── ColorMixer.ino │ ├── TFT_Monitor │ │ └── TFT_Monitor.ino │ ├── Motor │ │ ├── MotorAndPotentiometer │ │ │ └── MotorAndPotentiometer.ino │ │ └── Motor │ │ │ └── Motor.ino │ ├── Servo │ │ ├── PotentiometerServo │ │ │ └── PotentiometerServo.ino │ │ └── Sweep │ │ │ └── Sweep.ino │ ├── Relay │ │ └── Relay.ino │ ├── Bluetooth │ │ ├── BluetoothSwitch │ │ │ └── BluetoothSwitch.ino │ │ └── BluetoothSetup │ │ │ └── BluetoothSetup.ino │ └── RTC │ │ └── SetandReadTime │ │ └── SetandReadTime.ino ├── eviveFirmware │ └── eviveFirmware.ino ├── Communication │ └── Serial3Communication │ │ └── Serial3Communication.ino └── BlinkWithFirmware │ └── BlinkWithFirmware.ino └── library.properties /src/Font16.h: -------------------------------------------------------------------------------- 1 | #include "Font16.c" 2 | 3 | #define nr_chrs_f16 96 4 | #define chr_hgt_f16 16 5 | #define data_size_f16 8 6 | #define firstchr_f16 32 7 | 8 | extern const unsigned char widtbl_f16[96]; 9 | extern const unsigned char* const chrtbl_f16[96]; 10 | -------------------------------------------------------------------------------- /src/Font32rle.h: -------------------------------------------------------------------------------- 1 | #include "Font32rle.c" 2 | 3 | #define nr_chrs_f32 96 4 | #define chr_hgt_f32 26 5 | #define data_size_f32 8 6 | #define firstchr_f32 32 7 | 8 | extern const unsigned char widtbl_f32[96]; 9 | extern const unsigned char* const chrtbl_f32[96]; 10 | -------------------------------------------------------------------------------- /src/Font64rle.h: -------------------------------------------------------------------------------- 1 | #include "Font64rle.c" 2 | 3 | #define nr_chrs_f64 96 4 | #define chr_hgt_f64 48 5 | #define data_size_f64 8 6 | #define firstchr_f64 32 7 | 8 | extern const unsigned char widtbl_f64[96]; 9 | extern const unsigned char* const chrtbl_f64[96]; 10 | -------------------------------------------------------------------------------- /src/Font72rle.h: -------------------------------------------------------------------------------- 1 | #include "Font72rle.c" 2 | 3 | #define nr_chrs_f72 96 4 | #define chr_hgt_f72 75 5 | #define data_size_f72 8 6 | #define firstchr_f72 32 7 | 8 | extern const unsigned char widtbl_f72[96]; 9 | extern const unsigned char* const chrtbl_f72[96]; 10 | -------------------------------------------------------------------------------- /src/Font7srle.h: -------------------------------------------------------------------------------- 1 | #include "Font7srle.c" 2 | 3 | #define nr_chrs_f7s 96 4 | #define chr_hgt_f7s 48 5 | #define data_size_f7s 8 6 | #define firstchr_f7s 32 7 | 8 | extern const unsigned char widtbl_f7s[96]; 9 | extern const unsigned char* const chrtbl_f7s[96]; 10 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Font16.h: -------------------------------------------------------------------------------- 1 | #include "Font16.c" 2 | 3 | #define nr_chrs_f16 96 4 | #define chr_hgt_f16 16 5 | #define data_size_f16 8 6 | #define firstchr_f16 32 7 | 8 | extern const unsigned char widtbl_f16[96]; 9 | extern const unsigned char* const chrtbl_f16[96]; 10 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Font32rle.h: -------------------------------------------------------------------------------- 1 | #include "Font32rle.c" 2 | 3 | #define nr_chrs_f32 96 4 | #define chr_hgt_f32 26 5 | #define data_size_f32 8 6 | #define firstchr_f32 32 7 | 8 | extern const unsigned char widtbl_f32[96]; 9 | extern const unsigned char* const chrtbl_f32[96]; 10 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Font64rle.h: -------------------------------------------------------------------------------- 1 | #include "Font64rle.c" 2 | 3 | #define nr_chrs_f64 96 4 | #define chr_hgt_f64 48 5 | #define data_size_f64 8 6 | #define firstchr_f64 32 7 | 8 | extern const unsigned char widtbl_f64[96]; 9 | extern const unsigned char* const chrtbl_f64[96]; 10 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Font72rle.h: -------------------------------------------------------------------------------- 1 | #include "Font72rle.c" 2 | 3 | #define nr_chrs_f72 96 4 | #define chr_hgt_f72 75 5 | #define data_size_f72 8 6 | #define firstchr_f72 32 7 | 8 | extern const unsigned char widtbl_f72[96]; 9 | extern const unsigned char* const chrtbl_f72[96]; 10 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Font7srle.h: -------------------------------------------------------------------------------- 1 | #include "Font7srle.c" 2 | 3 | #define nr_chrs_f7s 96 4 | #define chr_hgt_f7s 48 5 | #define data_size_f7s 8 6 | #define firstchr_f7s 32 7 | 8 | extern const unsigned char widtbl_f7s[96]; 9 | extern const unsigned char* const chrtbl_f7s[96]; 10 | -------------------------------------------------------------------------------- /src/Language.h: -------------------------------------------------------------------------------- 1 | #ifndef LANGUAGE_H 2 | #define LANGUAGE_H 3 | 4 | #define LANGUAGE_CONCAT(M) #M 5 | #define GENERATE_LANGUAGE_INCLUDE(M) LANGUAGE_CONCAT(language_##M.h) 6 | 7 | //Languages supported: 8 | //En: English 9 | 10 | #ifndef LANGUAGE_INCLUDE 11 | #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) 12 | #endif 13 | 14 | #ifndef SOURCE_CODE_URL 15 | #define SOURCE_CODE_URL http://github.com/evivetoolkit/ 16 | #endif 17 | 18 | //Serial console message list comes here: 19 | #include "Language_en.h" 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Language.h: -------------------------------------------------------------------------------- 1 | #ifndef LANGUAGE_H 2 | #define LANGUAGE_H 3 | 4 | #define LANGUAGE_CONCAT(M) #M 5 | #define GENERATE_LANGUAGE_INCLUDE(M) LANGUAGE_CONCAT(language_##M.h) 6 | 7 | //Languages supported: 8 | //En: English 9 | 10 | #ifndef LANGUAGE_INCLUDE 11 | #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) 12 | #endif 13 | 14 | #ifndef SOURCE_CODE_URL 15 | #define SOURCE_CODE_URL http://github.com/evivetoolkit/ 16 | #endif 17 | 18 | //Serial console message list comes here: 19 | #include "Language_en.h" 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=evive 2 | version=2.0.1 3 | author=STEMpedia 4 | maintainer=STEMpedia 5 | sentence=This ia a arduino libray for using evive. 6 | paragraph=This is a arduino library for using evive. evive is a open source embedded platform used for making and debugging various electronics related projects. It come with a preloaded firmware that provides a wide range of features like motor control, servo control, oscilloscope, function generator, pin state monitor and many more. 7 | category=Device Control 8 | url=https://github.com/evivetoolkit/evive-Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /src/ServoControl.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVO_CONTROL_H 2 | #define SERVO_CONTROL_H 3 | 4 | #include "evive.h" 5 | 6 | //No varible can be assigned any value here as variables are actually declared in motor.cpp 7 | //Using extern, variables can be used in other libraries without declaration. 8 | extern bool _SERVO1_EN; 9 | extern bool _SERVO2_EN; 10 | extern Servo _servo1, _servo2; 11 | 12 | void controlServo(); //auto motor control from pots and slide switches 13 | void addServo1(); 14 | void addServo2(); 15 | void addServo12(); 16 | int prevValueServo1(); 17 | int prevValueServo2(); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/ServoControl.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVO_CONTROL_H 2 | #define SERVO_CONTROL_H 3 | 4 | #include "evive.h" 5 | 6 | //No varible can be assigned any value here as variables are actually declared in motor.cpp 7 | //Using extern, variables can be used in other libraries without declaration. 8 | extern bool _SERVO1_EN; 9 | extern bool _SERVO2_EN; 10 | extern Servo _servo1, _servo2; 11 | 12 | void controlServo(); //auto motor control from pots and slide switches 13 | void addServo1(); 14 | void addServo2(); 15 | void addServo12(); 16 | int prevValueServo1(); 17 | int prevValueServo2(); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/Action.h: -------------------------------------------------------------------------------- 1 | #ifndef ACTION_H 2 | #define ACTION_H 3 | #include "evive.h" 4 | 5 | typedef void (*actionFunc)(); // Function pointer to action functions. 6 | extern actionFunc actionFuncList[7]; 7 | extern uint8_t actionFuncListNum; 8 | 9 | void actionAdd(actionFunc, bool); 10 | void actionAdd(actionFunc); 11 | void actionRemove(actionFunc); //Remove action (function) from action function list using the name of the function 12 | void actionRemove(uint8_t); //Remove action (function) from action function list using number in array 13 | void actionRemoveAll(); //Remove all action (function) from action function list 14 | void action(); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Action.h: -------------------------------------------------------------------------------- 1 | #ifndef ACTION_H 2 | #define ACTION_H 3 | #include "evive.h" 4 | 5 | typedef void (*actionFunc)(); // Function pointer to action functions. 6 | extern actionFunc actionFuncList[7]; 7 | extern uint8_t actionFuncListNum; 8 | 9 | void actionAdd(actionFunc, bool); 10 | void actionAdd(actionFunc); 11 | void actionRemove(actionFunc); //Remove action (function) from action function list using the name of the function 12 | void actionRemove(uint8_t); //Remove action (function) from action function list using number in array 13 | void actionRemoveAll(); //Remove all action (function) from action function list 14 | void action(); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /examples/Easy/SerialReceive/SerialReceive.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Serial LED 3 | In this example control LED marked as M1 using Serial Communication 4 | 5 | Open the serial monitor in Arduino IDE and send 'H' to turn on LED and 'L' to turn it off. 6 | By Nihar Shah, Agilo Research 7 | On 29 December 2017 8 | 9 | Explore more on: https://thestempedia.com/tutorials/serial-communication/ 10 | 11 | */ 12 | #include 13 | void setup() { 14 | Serial.begin (115200); // start Serial Communication at 115200 15 | pinMode(LED28, OUTPUT); 16 | } 17 | char incomingData; 18 | void loop() { 19 | while (Serial.available()) 20 | { 21 | incomingData = Serial.read(); 22 | } 23 | if (incomingData == 'H') 24 | digitalWrite(LED28, HIGH); 25 | if (incomingData == 'L') 26 | digitalWrite(LED28, LOW); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /examples/Intermediate/Buzzer/Frequencies/Frequencies.ino: -------------------------------------------------------------------------------- 1 | /* 2 | evive buzzer test code 3 | 4 | The evive's tone() command will play notes of a given frequency. 5 | 6 | Created by Pankaj Verma. 7 | This code is in public domain. 8 | 9 | Explore more : https://thestempedia.com/tutorials/piezo-buzzer/ 10 | */ 11 | const int buzzerPin = 46; 12 | int baseFrequency = 262; 13 | int maxFrequency = 1030; 14 | void setup() { 15 | // put your setup code here, to run once: 16 | pinMode (buzzerPin, OUTPUT); 17 | for (baseFrequency = 62 ; baseFrequency < maxFrequency; baseFrequency += 100) 18 | { 19 | tone(buzzerPin, baseFrequency, 1000); //this function plays sound of given frequency on buzzer. 20 | delay(1000); 21 | } 22 | } 23 | 24 | void loop() { 25 | 26 | // put your main code here, to run repeatedly: 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/evive.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * evive.cpp 3 | * Created on: April 16, 2016 4 | * Author: dhrups 5 | * Last update: May 10, 2016 6 | * Version: 1.0 7 | */ 8 | #include "evive.h" 9 | 10 | int freeRam () 11 | { 12 | extern int __heap_start, *__brkval; 13 | int v; 14 | return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 15 | } 16 | void eviveFirmware(void) 17 | { 18 | exitmenu = 1; 19 | Serial.begin(115200); 20 | tft_init(INITR_BLACKTAB); 21 | while (1) 22 | { 23 | tft_update(); //Updates the TFT on any action in menu 24 | action(); //Runs the function in array actionFuncList. All functions/user defined programs are added in action FuncList array upon selection. 25 | if (exitmenu == 0) 26 | break; 27 | } 28 | tft.fillScreen(ST7735_BLACK); 29 | tft.drawBitmap(45, 29, evive_logo, 71, 71, ST7735_BLUE); 30 | } -------------------------------------------------------------------------------- /src/Examples.h: -------------------------------------------------------------------------------- 1 | #ifndef example_H 2 | #define example_H 3 | 4 | //IMPORTANT: uncomment the required Example(s). Then in Examples.cpp, go to the corresponding "setup" and "loop" functions to write the program (definition). 5 | #define EXAMPLE_1 "Blink Analog Input" 6 | //#define EXAMPLE_2 "NA" 7 | #define EXAMPLE_3 "TFT Display (Pot1)" 8 | #define EXAMPLE_4 "Probe V Sense" 9 | #define EXAMPLE_5 "TFT Serial Monitor (Pot1)" 10 | 11 | 12 | #include "evive.h" 13 | 14 | #ifdef EXAMPLE_1 15 | void loop_example_1(); 16 | #endif 17 | #ifdef EXAMPLE_2 18 | void loop_example_2(); 19 | #endif 20 | #ifdef EXAMPLE_3 21 | void loop_example_3(); 22 | #endif 23 | #ifdef EXAMPLE_4 24 | void loop_example_4(); 25 | #endif 26 | #ifdef EXAMPLE_5 27 | void loop_example_5(); 28 | #endif 29 | 30 | void add_example(uint8_t); 31 | void remove_other_example(uint8_t); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /examples/Intermediate/TFT/HelloWorld/HelloWorld.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Using TFT Display 3 | 4 | This code shows how to use TFT display attached on evive. 5 | Explore more on:https://thestempedia.com/tutorials/tft-hello/ 6 | */ 7 | 8 | #include 9 | void setup() { 10 | tft_init(INITR_BLACKTAB); // this is used to initialize TFT display 11 | tft.setRotation(1); // this rotates screen by 90 degree 12 | tft.fillScreen(ST7735_BLACK); // this filles display with black colour 13 | tft.setCursor(0,10); // this sets cursor to write on (0,10) location 14 | tft.setTextColor(ST7735_WHITE); 15 | tft.println("Hello World!"); //print function 16 | tft.println(""); 17 | tft.print("My name is evive and this is my first TFT display code."); 18 | 19 | // put your setup code here, to run once: 20 | } 21 | 22 | void loop() { 23 | // put your main code here, to run repeatedly: 24 | 25 | } 26 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/evive.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * evive.cpp 3 | * Created on: April 16, 2016 4 | * Author: dhrups 5 | * Last update: May 10, 2016 6 | * Version: 1.0 7 | */ 8 | #include "evive.h" 9 | 10 | int freeRam () 11 | { 12 | extern int __heap_start, *__brkval; 13 | int v; 14 | return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 15 | } 16 | void eviveFirmware(void) 17 | { 18 | exitmenu = 1; 19 | Serial.begin(115200); 20 | tft_init(INITR_BLACKTAB); 21 | while (1) 22 | { 23 | tft_update(); //Updates the TFT on any action in menu 24 | action(); //Runs the function in array actionFuncList. All functions/user defined programs are added in action FuncList array upon selection. 25 | if (exitmenu == 0) 26 | break; 27 | } 28 | tft.fillScreen(ST7735_BLACK); 29 | tft.drawBitmap(45, 29, evive_logo, 71, 71, ST7735_BLUE); 30 | } -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Examples.h: -------------------------------------------------------------------------------- 1 | #ifndef example_H 2 | #define example_H 3 | 4 | //IMPORTANT: uncomment the required Example(s). Then in Examples.cpp, go to the corresponding "setup" and "loop" functions to write the program (definition). 5 | #define EXAMPLE_1 "Blink Analog Input" 6 | //#define EXAMPLE_2 "NA" 7 | #define EXAMPLE_3 "TFT Display (Pot1)" 8 | #define EXAMPLE_4 "Probe V Sense" 9 | #define EXAMPLE_5 "TFT Serial Monitor (Pot1)" 10 | 11 | 12 | #include "evive.h" 13 | 14 | #ifdef EXAMPLE_1 15 | void loop_example_1(); 16 | #endif 17 | #ifdef EXAMPLE_2 18 | void loop_example_2(); 19 | #endif 20 | #ifdef EXAMPLE_3 21 | void loop_example_3(); 22 | #endif 23 | #ifdef EXAMPLE_4 24 | void loop_example_4(); 25 | #endif 26 | #ifdef EXAMPLE_5 27 | void loop_example_5(); 28 | #endif 29 | 30 | void add_example(uint8_t); 31 | void remove_other_example(uint8_t); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /examples/Intermediate/Touch/State/State.ino: -------------------------------------------------------------------------------- 1 | /* 2 | evive Touch TFT Display 3 | 4 | This code detects if someone have touched banana attached to channel 1 5 | of Touch inputs and display the state on TFT Screen. 6 | 7 | Explore more on:https://thestempedia.com/tutorials/arduino-ide-touch-input/ 8 | 9 | */ 10 | 11 | #include 12 | void setup() { 13 | // put your setup code here, to run once: 14 | tft_init(INITR_GREENTAB); // initialize a ST7735S chip, black tab 15 | tft.fillScreen(ST7735_BLACK); 16 | touchPins.begin(0x5A); 17 | } 18 | 19 | void loop() { 20 | tft.drawRoundRect(20, 30, 120, 68, 10, ST7735_WHITE); 21 | tft.setTextColor(ST7735_WHITE); 22 | tft.setTextSize(2); 23 | tft.setCursor(50, 40); 24 | tft.println("STATE"); 25 | if (touchPins.isTouched(1)) 26 | tft.fillRoundRect(40, 65, 80, 25, 5, ST7735_GREEN); 27 | else 28 | tft.fillRoundRect(40, 65, 80, 25, 5, ST7735_RED); 29 | } 30 | -------------------------------------------------------------------------------- /examples/Intermediate/TFT/TextSize/TextSize.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Using TFT Display to change text size. 3 | 4 | Created by Nihar Shah. 5 | This code is in Public domain. 6 | 7 | Explore more on : https://thestempedia.com/tutorials/tft-text-manipulation/ 8 | */ 9 | #include 10 | void setup() { 11 | Serial.begin(9600); 12 | tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab 13 | tft.setRotation(1); 14 | Serial.println("Initialized"); 15 | tft.fillScreen(ST7735_BLACK); 16 | } 17 | 18 | void loop() { 19 | tft.fillScreen(ST7735_BLACK); 20 | tft.setTextColor(ST7735_WHITE); 21 | tft.setCursor(0,0); 22 | 23 | tft.setTextSize(1); 24 | tft.println("S1"); 25 | delay(1000); 26 | 27 | tft.setTextSize(2); 28 | tft.println("S2"); 29 | delay(1000); 30 | 31 | tft.setTextSize(3); 32 | tft.println("S3"); 33 | delay(1000); 34 | 35 | tft.setTextSize(4); 36 | tft.println("S4"); 37 | delay(1000); 38 | 39 | tft.setTextSize(5); 40 | tft.println("S5"); 41 | delay(1000); 42 | } 43 | -------------------------------------------------------------------------------- /examples/Intermediate/TFT_Monitor/TFT_Monitor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This example shows how to plot any variable on evive TFT display. 3 | 4 | Explore more on: https://thestempedia.com/tutorials/tft-monitor/ 5 | Created by Dhrupal Shah. 6 | 7 | This code is in public domain. 8 | 9 | */ 10 | 11 | #include //include evive library 12 | 13 | TftMonitor tft_Monitor; // Initialize a class object 14 | 15 | void setup(){ 16 | tft_init(INITR_BLACKTAB); //Use either INITR_BLACKTAB or INITR_GREENTAB. Initialize TFT screen in library screen.cpp 17 | tft_Monitor.begin(); // Begins tftMonitor 18 | pinMode(A9,INPUT); // Set pin as input mode (POT1 = A9) 19 | } 20 | 21 | // the loop function runs continuously when you select the user defined function 22 | void loop(){ 23 | tft.setTextColor(ST7735_WHITE,ST7735_BLACK); 24 | tft_Monitor.print("Pot 1 value: "); 25 | tft_Monitor.println(analogRead(A9)); // Pot1 Value is printed on TFT Monitor 26 | delay(50); 27 | } 28 | -------------------------------------------------------------------------------- /examples/Intermediate/Motor/MotorAndPotentiometer/MotorAndPotentiometer.ino: -------------------------------------------------------------------------------- 1 | /* This example demonstrates how to use motor with Potentiometer 2 | attached in evive 3 | 4 | For Motor 1: Direction digital pins are MOTOR1_D1 and MOTOR1_D2, and PWM pin is digital pin MOTOR1_EN 5 | For Motor 2: Direction digital pins are MOTOR2_D1 and MOTOR2_D2, and PWM pin is digital pin MOTOR2_EN 6 | 7 | Created by Nihar Shah. 8 | This code is in public domain. 9 | Explore more at :https://thestempedia.com/tutorials/dc-motor-driving/ 10 | 11 | */ 12 | 13 | #include 14 | 15 | Motor Motor1 = Motor(MOTOR1_D1, MOTOR1_D2, MOTOR1_EN); // defines motor 1 16 | 17 | int potData=0; 18 | void setup() { 19 | // put your setup code here, to run once: 20 | 21 | } 22 | 23 | void loop() { 24 | potData=analogRead(POT1); // reads pot data between 0 to 1023. 25 | potData = map(potData,0,1023,0,255); //motor input range is 0 to 255 hence mapping potentiometer value in this range. 26 | Motor1.moveMotor(potData); // writes motor according to potentiometer value. 27 | } 28 | -------------------------------------------------------------------------------- /examples/eviveFirmware/eviveFirmware.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Version 2.0.1 3 | * This firmware is developed for evive [https://thestempedia.com]. 4 | * This is licensed under GNU GPL V3 [http://www.gnu.org/licenses/gpl.txt]. 5 | * Written by Dhrupal R Shah for evive platform, Agilo Research. 6 | * Last update: 2018, August 3 , by Mimansa Maheshwari, Agilo Research. 7 | 8 | * Copyright (c) 2018 Agilo Research. All rights reserved. 9 | * 10 | * Getting started with evive: https://thestempedia.com 11 | * 12 | * NOTE: Works with Arduino IDE 1.6.6 or later [https://www.arduino.cc/en/Main/Software] 13 | */ 14 | 15 | #include 16 | 17 | void setup(){ 18 | Serial.begin(BAUDRATE); //Default BAUD Rate: 250000, edit the macro in configuration.h 19 | tft_init(INITR_BLACKTAB); //Use either INITR_BLACKTAB or INITR_GREENTAB. Initialize TFT screen in library screen.cpp 20 | } 21 | 22 | void loop(){ 23 | tft_update(); //Updates the TFT on any action in menu 24 | action(); //Runs the function in array actionFuncList. All functions/user defined programs are added in action FuncList array upon selection. 25 | } 26 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/eviveFirmwareExtended.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Version 2.0.1 3 | * This firmware is developed for evive [https://thestempedia.com]. 4 | * This is licensed under GNU GPL V3 [http://www.gnu.org/licenses/gpl.txt]. 5 | * Written by Dhrupal R Shah for evive platform, Agilo Research. 6 | * Last update: 2018, August 2, by Mimansa Maheshwari 7 | 8 | * Copyright (c) 2018 Agilo Research. All rights reserved. 9 | * 10 | * Getting started with evive: https://thestempedia.com 11 | * 12 | * NOTE: Works with Arduino IDE 1.6.6 or later [https://www.arduino.cc/en/Main/Software] 13 | */ 14 | 15 | #include "evive.h" 16 | 17 | void setup(){ 18 | Serial.begin(BAUDRATE); //Default BAUD Rate: 250000, edit the macro in configuration.h 19 | tft_init(INITR_BLACKTAB); //Use either INITR_BLACKTAB or INITR_GREENTAB. Initialize TFT screen in library screen.cpp 20 | } 21 | 22 | void loop(){ 23 | tft_update(); //Updates the TFT on any action in menu 24 | action(); //Runs the function in array actionFuncList. All functions/user defined programs are added in action FuncList array upon selection. 25 | } 26 | -------------------------------------------------------------------------------- /examples/Intermediate/Servo/PotentiometerServo/PotentiometerServo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | evive servo example 3 | This example demonstrates how to use servo motor on evive. 4 | For this servo is rotated as per movement of POT1 on evive. 5 | One can also use POT2 of evive for same purpose. 6 | 7 | To control servo 1(S1) use SERVO1_ATTACH. 8 | To control servo 2(S2) use SERVO2_ATTACH. 9 | 10 | 11 | This code is in public domain. 12 | 13 | Explore more on : https://thestempedia.com/tutorials/servo/ 14 | 15 | */ 16 | #include 17 | Servo myservo; // create servo object to control a servo 18 | int angle=0; 19 | void setup() { 20 | myservo.attach(SERVO1_ATTACH); // attaches the servo on pin S1 to the servo object 21 | } 22 | 23 | void loop() { 24 | angle = analogRead(POT1); // reads the value of the potentiometer (value between 0 and 1023) 25 | angle = map(angle, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180) 26 | myservo.write(angle); // sets the servo position according to the scaled value 27 | delay(15); // waits for the servo to get there 28 | } 29 | -------------------------------------------------------------------------------- /examples/Intermediate/Motor/Motor/Motor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | evive motor control through motor library 3 | 4 | For Motor 1: Direction digital pins are MOTOR1_D1 and MOTOR1_D2, and PWM pin is digital pin MOTOR1_EN 5 | For Motor 2: Direction digital pins are MOTOR2_D1 and MOTOR2_D2, and PWM pin is digital pin MOTOR2_EN 6 | 7 | This code demonstrates how to use motor library to start motor, stop motor, control its direction of rotation and speed.. 8 | Here a dc motor is plugged in channel M1 on evive. And that motor is rotated clockwise and anti-clockwise at constant pwm. 9 | Created by Nihar Shah. 10 | This code is in public domain. 11 | Explore more: https://thestempedia.com/tutorials/dc-motor-driving/ 12 | */ 13 | 14 | #include 15 | Motor Motor1 = Motor(MOTOR1_D1, MOTOR1_D2, MOTOR1_EN); 16 | 17 | void setup() { 18 | // put your setup code here, to run once: 19 | 20 | } 21 | 22 | void loop() { 23 | 24 | //Rotate motor in CW direction with PWM 200 25 | Motor1.moveMotor(200); 26 | delay(1000); 27 | 28 | // Stop Motor 29 | Motor1.freeMotor(); 30 | delay(1000); 31 | 32 | // Rotate motor in CCW direction with PWM -200 33 | Motor1.moveMotor(-200); 34 | delay(1000); 35 | 36 | // Stop Motor 37 | Motor1.freeMotor(); 38 | delay(1000); 39 | } 40 | -------------------------------------------------------------------------------- /examples/Intermediate/Servo/Sweep/Sweep.ino: -------------------------------------------------------------------------------- 1 | /* Sweep 2 | 3 | 4 | This example runs servo from 0 to 180 degree and reverse i.e from 180 to 0 degree. 5 | To control servo 1(S1) use SERVO1_ATTACH. 6 | To control servo 2(S2) use SERVO2_ATTACH. 7 | 8 | This code is in public domain. 9 | 10 | Explore more on : https://thestempedia.com/tutorials/servo/ 11 | 12 | */ 13 | 14 | #include 15 | Servo servo; // create servo object to control a servo 16 | // twelve servo objects can be created on most boards 17 | 18 | int degree = 0; // variable to store the servo position 19 | 20 | void setup() { 21 | servo.attach(SERVO1_ATTACH); // attaches the servo on pin S1 to the servo object 22 | } 23 | 24 | void loop() { 25 | for (degree = 0; degree <= 180; degree += 1) { // goes from 0 degrees to 180 degrees 26 | // in steps of 1 degree 27 | servo.write(degree); // tell servo to go to degree in variable 'degree' 28 | delay(15); // waits 15ms for the servo to reach the position 29 | } 30 | for (degree = 180; degree >= 0; degree -= 1) { // goes from 180 degrees to 0 degrees 31 | servo.write(degree); // tell servo to go to degree in variable 'degree' 32 | delay(15); // waits 15ms for the servo to reach the position 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /examples/Intermediate/TFT/digitalButton/digitalButton.ino: -------------------------------------------------------------------------------- 1 | /* 2 | evive Digital Read TFT Display 3 | 4 | This code demonstrates how to display digital state on TFT Screen. 5 | Explore more on :https://thestempedia.com/tutorials/evive-digital-input-2/ 6 | 7 | */ 8 | #include 9 | boolean state = false; 10 | void setup() { 11 | Serial.begin(9600); 12 | tft_init(INITR_GREENTAB); // initialize a ST7735S chip, green tab 13 | Serial.println("Initialized"); 14 | tft.fillScreen(ST7735_BLACK); // fill with black colour 15 | pinMode(TACTILESW1, INPUT); // set as input 16 | } 17 | 18 | void loop() { 19 | tft.drawRoundRect(20, 30, 120, 68, 10, ST7735_WHITE); // Draw rectangle 20 | tft.setTextColor(ST7735_WHITE); // set white colour 21 | tft.setTextSize(2); // size 2 22 | tft.setCursor(50, 40); // set cursor at 50,40 23 | tft.println("STATE"); // print state 24 | state = digitalRead(TACTILESW1); // check state 25 | if (state == true) { // if true set green colour 26 | tft.fillRoundRect(40, 65, 80, 25, 5, ST7735_GREEN); 27 | } 28 | else { 29 | tft.fillRoundRect(40, 65, 80, 25, 5, ST7735_RED); // if false set red rectangle 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/Intermediate/Relay/Relay.ino: -------------------------------------------------------------------------------- 1 | /* 2 | High power circuit switching 3 | 4 | Turns on and off a AC bulb connected on relay 5 | with help of SlideSwitch 1 on evive. 6 | 7 | Depeding upon which SlideSwitch and which part of Slide switch 8 | is to be used keywords for pins connected to slide switch are: 9 | SLIDESW1_D1 Slide Switch 1 (Up direction pin 40) 10 | SLIDESW1_D2 Slide Switch 1 (Down direction pin 41) 11 | SLIDESW2_D1 Slide Switch 2 (UP direction pin 42) 12 | SLIDESW2_D2 Slide Switch 2 (Down direction pin 43) 13 | 14 | Explore more on: https://thestempedia.com/tutorials/interfacing-relay-with-evive/ 15 | 16 | */ 17 | #include 18 | #define relay 2 19 | int state = 0; // variable for reading the pushbutton status 20 | void setup() { 21 | // put your setup code here, to run once: 22 | // initialize the relay pin as an output: 23 | pinMode(relay, OUTPUT); 24 | // initialize the pushbutton pin as an input: 25 | pinMode(SLIDESW1_D1, INPUT); 26 | 27 | } 28 | 29 | void loop() { 30 | // read the state of the pushbutton value: 31 | state = digitalRead(SLIDESW1_D1); 32 | 33 | // check if the pushbutton is pressed. 34 | // if it is, the state is HIGH: 35 | if (state == HIGH) { 36 | // turn relay on: 37 | digitalWrite(relay, LOW); 38 | } else { 39 | // turn relay off: 40 | digitalWrite(relay, HIGH); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/Communication/Serial3Communication/Serial3Communication.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This example is used to communicate with peripherals connected to Serial3 Port. 3 | Messages/Data read from Serial Port 3 will be sent to Serial Port 0 (connected to USB) and vice-versa. 4 | 5 | Just simply change BAUD rate to desired and open Serial Monitor in Arduino IDE 6 | 7 | Note: Make sure that Both NL and CR is selected at bottom of Serial monitor with proper baud 8 | 9 | Made by Nihar Shah. 10 | On 12 October 2017. 11 | 12 | Explore more on: https://thestempedia.com/tutorials/serial-communication/ 13 | */ 14 | 15 | void setup() { 16 | Serial.begin(250000); // Start Serial 0 (USB) at BAUD rate 250000 17 | Serial3.begin(115200); // Start Serial 3 at BAUD here as per the module 18 | delay(50); 19 | Serial3.print("AT\r\n"); // AT to check whether device is connected or not? Typically Replies with OK 20 | } 21 | 22 | void loop() { 23 | 24 | while (Serial.available()) //Checks wether any data is recieved on Serial (USB) (Serial Port 0) 25 | { 26 | Serial3.write(Serial.read()); //Reads the data from Serial Port 0 and send/write it to Serial Port 3 27 | } 28 | 29 | while (Serial3.available()) //Checks wether any data is recieved on Serial Port 3 30 | { 31 | Serial.write(Serial3.read()); //Reads the data from Serial Port 3 and send/write it to Serial Port 0 32 | } 33 | delay(100); 34 | } 35 | -------------------------------------------------------------------------------- /src/SlideSwitch.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------* 2 | * slideSwitch.cpp 3 | * 4 | * Created on: May 23, 2016 5 | * Author: dhrups 6 | *----------------------------------------------------------------------*/ 7 | #ifndef SLIDE_SWITCH_H 8 | #define SLIDE_SWITCH_H 9 | 10 | #include "evive.h" 11 | 12 | class SlideSwitch 13 | { 14 | public: 15 | SlideSwitch(); 16 | SlideSwitch(uint8_t pin1, uint8_t _pin2); 17 | SlideSwitch(uint8_t pin1, uint8_t _pin2, bool puEnable, bool invert); 18 | bool readPin1(); 19 | bool readPin2(); 20 | 21 | private: 22 | uint8_t _pin1; //arduino pin number 23 | uint8_t _pin2; //arduino pin number 24 | bool _puEnable; //internal pullup resistor enabled 25 | bool _invert; //if 0, interpret high state as pressed, else interpret low state as pressed 26 | bool _state1; //current button state 27 | bool _state2; //current button state 28 | // uint8_t _lastState; //previous button state 29 | // uint8_t _changed; //state changed since last read 30 | // uint32_t _time; //time of current state (all times are in ms) 31 | // uint32_t _lastChange; //time of last state change 32 | // uint32_t _dbTime; //debounce time 33 | }; 34 | 35 | extern SlideSwitch slideSw1, slideSw2; 36 | #endif 37 | -------------------------------------------------------------------------------- /examples/Easy/SlideSwitch/SlideSwitch.ino: -------------------------------------------------------------------------------- 1 | /* 2 | evive Slide Switch 3 | 4 | This code demonstrates how to use slide switch in Aruino IDE and display state on TFT Screen. 5 | 6 | Created by Pankaj Kumar Verma, Agilo Research 7 | On 13 Mar, 2017 8 | 9 | Explore more on: https://thestempedia.com/tutorials/slide-switch/ 10 | */ 11 | 12 | 13 | #include 14 | int buttonState1 = 0; // variable for reading the pushbutton pin 1 status 15 | int buttonState2 = 0; // variable for reading the pushbutton pin 2 status 16 | 17 | void setup() { 18 | pinMode(SLIDESW1_D1, INPUT); // initialize the first slideswitch pins as an input: 19 | pinMode(SLIDESW1_D2, INPUT); 20 | pinMode(LED28, OUTPUT); 21 | pinMode(LED29, OUTPUT); 22 | } 23 | 24 | void loop() { 25 | // read the state of the pushbutton value: 26 | buttonState1 = digitalRead(SLIDESW1_D1); 27 | buttonState2 = digitalRead(SLIDESW1_D2); 28 | // check if the slideswitch is in state 1. 29 | // if it is, the buttonState1 is HIGH: 30 | if (buttonState1 == HIGH) { 31 | digitalWrite(LED28, HIGH); 32 | digitalWrite(LED29, LOW); 33 | } 34 | // check if the slideswitch is in state 2. 35 | // if it is, the buttonState2 is HIGH: 36 | else if (buttonState2 == HIGH) { 37 | digitalWrite(LED29, HIGH); 38 | digitalWrite(LED28, LOW); 39 | } 40 | else { // if it is in middle state. 41 | digitalWrite(LED28, LOW); 42 | digitalWrite(LED29, LOW); 43 | } 44 | delay(100); 45 | } 46 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/SlideSwitch.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------* 2 | * slideSwitch.cpp 3 | * 4 | * Created on: May 23, 2016 5 | * Author: dhrups 6 | *----------------------------------------------------------------------*/ 7 | #ifndef SLIDE_SWITCH_H 8 | #define SLIDE_SWITCH_H 9 | 10 | #include "evive.h" 11 | 12 | class SlideSwitch 13 | { 14 | public: 15 | SlideSwitch(); 16 | SlideSwitch(uint8_t pin1, uint8_t _pin2); 17 | SlideSwitch(uint8_t pin1, uint8_t _pin2, bool puEnable, bool invert); 18 | bool readPin1(); 19 | bool readPin2(); 20 | 21 | private: 22 | uint8_t _pin1; //arduino pin number 23 | uint8_t _pin2; //arduino pin number 24 | bool _puEnable; //internal pullup resistor enabled 25 | bool _invert; //if 0, interpret high state as pressed, else interpret low state as pressed 26 | bool _state1; //current button state 27 | bool _state2; //current button state 28 | // uint8_t _lastState; //previous button state 29 | // uint8_t _changed; //state changed since last read 30 | // uint32_t _time; //time of current state (all times are in ms) 31 | // uint32_t _lastChange; //time of last state change 32 | // uint32_t _dbTime; //debounce time 33 | }; 34 | 35 | extern SlideSwitch slideSw1, slideSw2; 36 | #endif 37 | -------------------------------------------------------------------------------- /examples/Easy/Fading/Fading.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Fading 3 | 4 | This example shows how to fade an on-board LED 5 | using the analogWrite() function. 6 | 7 | The analogWrite() function uses PWM, so if 8 | you want to change the pin you're using, be 9 | sure to use another PWM capable pin. On evive 10 | the PWM pins are digital pin 2 to 13. 11 | 12 | This example code is in the public domain. 13 | 14 | made on 9 Sept 2017 15 | by Nihar Shah. 16 | 17 | Explore more about PWM on : https://thestempedia.com/tutorials/evive-analog-output-pwm/ 18 | */ 19 | 20 | #include 21 | 22 | #define led 13 // the PWM pin the LED is attached to 23 | int brightness = 0; // how bright the LED is 24 | int fadeAmount = 5; // how many points to fade the LED by 25 | 26 | // the setup routine runs once when you press reset: 27 | void setup() { 28 | pinMode(led, OUTPUT); // declare LED to be an output: 29 | } 30 | 31 | // the loop routine runs over and over again forever: 32 | void loop() { 33 | analogWrite(led, brightness); // set the brightness of pin 9: 34 | 35 | // change the brightness for next time through the loop: 36 | brightness = brightness + fadeAmount; 37 | 38 | // reverse the direction of the fading at the ends of the fade: 39 | if (brightness == 0 || brightness == 255) { 40 | fadeAmount = -fadeAmount ; 41 | } 42 | 43 | delay(50); // wait for 50 milliseconds to see the dimming effect 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/ServoControl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * servoControl.cpp 3 | * 4 | * Created on: May 6, 2016 5 | * Author: dhrups 6 | */ 7 | #include "ServoControl.h" 8 | 9 | bool _SERVO1_EN = 0; 10 | bool _SERVO2_EN = 0; 11 | Servo _servo1, _servo2; 12 | int prevAngleServo1, prevAngleServo2; 13 | unsigned long lastServoMoveTime = 0; 14 | 15 | void controlServo(){ 16 | //Serial.println("ServoCtrl"); 17 | if((millis() - lastServoMoveTime) > MIN_TIME2){ 18 | if(_SERVO1_EN) 19 | { prevAngleServo1 = _servo1.read(); 20 | _servo1.write(int(map(pot1.getValue(),0, 1023, 0, 180))); 21 | //Serial.println(_servo1.read()); 22 | } 23 | if(_SERVO2_EN) 24 | { prevAngleServo2 = _servo2.read(); 25 | _servo2.write(int(map(pot2.getValue(),0, 1023, 0, 180))); 26 | } 27 | lastServoMoveTime = millis(); 28 | } 29 | } 30 | 31 | int prevValueServo1(){ 32 | return prevAngleServo1; 33 | } 34 | 35 | int prevValueServo2(){ 36 | return prevAngleServo2; 37 | } 38 | 39 | void addServo1(){ 40 | _MOTOR1_EN = 0; 41 | _SERVO1_EN = 1; 42 | _STEPPER_EN = 0; 43 | _servo1.attach(SERVO1_ATTACH); 44 | actionAdd(controlServo, 1); 45 | prevAngleServo1 = _servo1.read(); 46 | prevAngleServo2 = _servo2.read(); 47 | } 48 | 49 | void addServo2(){ 50 | _MOTOR2_EN = 0; 51 | _SERVO2_EN = 1; 52 | _STEPPER_EN = 0; 53 | _servo2.attach(SERVO2_ATTACH); 54 | actionAdd(controlServo, 1); 55 | prevAngleServo1 = _servo1.read(); 56 | prevAngleServo2 = _servo2.read(); 57 | } 58 | 59 | void addServo12(){ 60 | addServo1(); 61 | addServo2(); 62 | } 63 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/ServoControl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * servoControl.cpp 3 | * 4 | * Created on: May 6, 2016 5 | * Author: dhrups 6 | */ 7 | #include "ServoControl.h" 8 | 9 | bool _SERVO1_EN = 0; 10 | bool _SERVO2_EN = 0; 11 | Servo _servo1, _servo2; 12 | int prevAngleServo1, prevAngleServo2; 13 | unsigned long lastServoMoveTime = 0; 14 | 15 | void controlServo(){ 16 | //Serial.println("ServoCtrl"); 17 | if((millis() - lastServoMoveTime) > MIN_TIME2){ 18 | if(_SERVO1_EN) 19 | { prevAngleServo1 = _servo1.read(); 20 | _servo1.write(int(map(pot1.getValue(),0, 1023, 0, 180))); 21 | //Serial.println(_servo1.read()); 22 | } 23 | if(_SERVO2_EN) 24 | { prevAngleServo2 = _servo2.read(); 25 | _servo2.write(int(map(pot2.getValue(),0, 1023, 0, 180))); 26 | } 27 | lastServoMoveTime = millis(); 28 | } 29 | } 30 | 31 | int prevValueServo1(){ 32 | return prevAngleServo1; 33 | } 34 | 35 | int prevValueServo2(){ 36 | return prevAngleServo2; 37 | } 38 | 39 | void addServo1(){ 40 | _MOTOR1_EN = 0; 41 | _SERVO1_EN = 1; 42 | _STEPPER_EN = 0; 43 | _servo1.attach(SERVO1_ATTACH); 44 | actionAdd(controlServo, 1); 45 | prevAngleServo1 = _servo1.read(); 46 | prevAngleServo2 = _servo2.read(); 47 | } 48 | 49 | void addServo2(){ 50 | _MOTOR2_EN = 0; 51 | _SERVO2_EN = 1; 52 | _STEPPER_EN = 0; 53 | _servo2.attach(SERVO2_ATTACH); 54 | actionAdd(controlServo, 1); 55 | prevAngleServo1 = _servo1.read(); 56 | prevAngleServo2 = _servo2.read(); 57 | } 58 | 59 | void addServo12(){ 60 | addServo1(); 61 | addServo2(); 62 | } 63 | -------------------------------------------------------------------------------- /examples/Easy/AnalogDataRead/AnalogDataRead.ino: -------------------------------------------------------------------------------- 1 | /* Analog Data Read 2 | * Read analog data of Potentiometer 1 (A9) on evive and publish it Tft screen. 3 | * 4 | * Explore more on: https://thestempedia.com/tutorials/evive-analog-input/ 5 | */ 6 | 7 | #include //include evive library 8 | 9 | void setup() { 10 | tft.init(INITR_BLACKTAB); 11 | tft.setRotation(1); 12 | tft.fillScreen(ST7735_BLACK); 13 | pinMode(POT1,INPUT); //Set pin as input mode (POT1 = A9) 14 | } 15 | 16 | int potData; //variable to store analog reading of potentiometer 1 17 | 18 | void loop() { 19 | //print text "Analog Read Value:" on tft screen 20 | tft.drawRoundRect(20, 30, 120, 68, 10, ST7735_WHITE); 21 | tft.setTextColor(ST7735_WHITE); 22 | tft.setTextSize(1); 23 | tft.setCursor(25, 40); 24 | tft.println("Analog Read Value: "); 25 | //read analog data of potentiometer on Pin A9 26 | potData = analogRead(POT1); 27 | tft.setTextColor(ST7735_WHITE, ST7735_BLACK); 28 | tft.setTextSize(2); 29 | tft.setCursor(55, 70); 30 | //To prevent overwrite problem the analogvalues are printed in the following manner 31 | if(potData < 10) 32 | { 33 | tft.print(potData); 34 | tft.print(" "); //3 spaces 35 | } 36 | else if(potData < 100) 37 | { 38 | tft.print(potData); 39 | tft.print(" "); //2 spaces 40 | } 41 | else if(potData < 1000) 42 | { 43 | tft.print(potData); 44 | tft.print(" "); //1 spaces 45 | } 46 | else 47 | { 48 | tft.print(potData); 49 | } 50 | delay(100); //delay of 100 milli seconds in each loop 51 | } 52 | 53 | -------------------------------------------------------------------------------- /examples/Intermediate/Bluetooth/BluetoothSwitch/BluetoothSwitch.ino: -------------------------------------------------------------------------------- 1 | /* 2 | evive Bluetooth 3 | 4 | An example of using the evive to receive data from any Bluetooth enabled device. In 5 | this case, the evive turns on an LED when it receives the character 6 | 'H', and turns off the LED when it receives the character 'L'. 7 | 8 | The data can be sent from any Bluetooth enabled device. For example for mobile device you 9 | can find "Serial Bluetooth Terminal" in respective App Store. 10 | 11 | Created by Nihar Shah. 12 | This code is in public domain. 13 | 14 | To explore more : https://thestempedia.com/tutorials/bluetooth-switching/ 15 | */ 16 | #include 17 | int incomingByte; // a variable to read incoming serial data into 18 | 19 | void setup() { 20 | // initialize serial communication: 21 | Serial3.begin(115200); 22 | Serial.begin(250000); 23 | // initialize the LED pin as an output: 24 | pinMode(LED_BUILTIN, OUTPUT); 25 | } 26 | 27 | void loop() { 28 | // see if there's incoming serial data: 29 | if (Serial3.available() > 0) { 30 | // read the oldest byte in the serial buffer: 31 | incomingByte = Serial3.read(); 32 | Serial.print("Data Received: "); 33 | Serial.write(incomingByte); //writes received data on Serial monitor 34 | Serial.println(); 35 | // if it's a capital H (ASCII 72), turn on the LED: 36 | if (incomingByte == 'H') { 37 | digitalWrite(LED_BUILTIN, HIGH); 38 | } 39 | // if it's an L (ASCII 76) turn off the LED: 40 | if (incomingByte == 'L') { 41 | digitalWrite(LED_BUILTIN, LOW); 42 | } 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/Dac_MCP4725.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /*! 3 | @file Adafruit_MCP4725.h 4 | @author K. Townsend (Adafruit Industries) 5 | @license BSD (see license.txt) 6 | 7 | Adafruit invests time and resources providing this open source code, 8 | please support Adafruit and open-source hardware by purchasing 9 | products from Adafruit! 10 | 11 | @section HISTORY 12 | 13 | v1.0 - First release 14 | Edited by: Dhrupal R Shah 15 | http://evive.cc 16 | Date: 2016/08/01 17 | */ 18 | /**************************************************************************/ 19 | #ifndef DAC_MCP4725_H 20 | #define DAC_MCP4725_H 21 | //#ifndef MCP4725_ADDR 22 | #define MCP4725_ADDR 0x62 23 | //#endif 24 | 25 | #include "evive.h" 26 | 27 | #define MCP4726_CMD_WRITEDAC (0x40) // Writes data to the DAC 28 | #define MCP4726_CMD_WRITEDACEEPROM (0x60) // Writes data to the DAC and the EEPROM (persisting the assigned value after reset) 29 | 30 | class dac_MCP4725{ 31 | public: 32 | dac_MCP4725(); 33 | void begin(uint8_t a); 34 | void setVoltage( uint16_t output, bool writeEEPROM ); 35 | 36 | private: 37 | uint8_t _i2caddr; 38 | }; 39 | 40 | ////////////////Modified Library//////////////// 41 | extern dac_MCP4725 dac; 42 | 43 | extern uint16_t increment, oldIncrement; 44 | extern float amplitude, oldAmplitude; 45 | 46 | void setFrequencyAmplitude(); 47 | void generateSineWave(); 48 | void generateSquareWave(); 49 | void generateTraingularWave(); 50 | void generateSawtoothWaveUp(); 51 | void generateSawtoothWaveDown(); 52 | void generateAnalogOutput(); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Dac_MCP4725.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /*! 3 | @file Adafruit_MCP4725.h 4 | @author K. Townsend (Adafruit Industries) 5 | @license BSD (see license.txt) 6 | 7 | Adafruit invests time and resources providing this open source code, 8 | please support Adafruit and open-source hardware by purchasing 9 | products from Adafruit! 10 | 11 | @section HISTORY 12 | 13 | v1.0 - First release 14 | Edited by: Dhrupal R Shah 15 | http://evive.cc 16 | Date: 2016/08/01 17 | */ 18 | /**************************************************************************/ 19 | #ifndef DAC_MCP4725_H 20 | #define DAC_MCP4725_H 21 | //#ifndef MCP4725_ADDR 22 | #define MCP4725_ADDR 0x62 23 | //#endif 24 | 25 | #include "evive.h" 26 | 27 | #define MCP4726_CMD_WRITEDAC (0x40) // Writes data to the DAC 28 | #define MCP4726_CMD_WRITEDACEEPROM (0x60) // Writes data to the DAC and the EEPROM (persisting the assigned value after reset) 29 | 30 | class dac_MCP4725{ 31 | public: 32 | dac_MCP4725(); 33 | void begin(uint8_t a); 34 | void setVoltage( uint16_t output, bool writeEEPROM ); 35 | 36 | private: 37 | uint8_t _i2caddr; 38 | }; 39 | 40 | ////////////////Modified Library//////////////// 41 | extern dac_MCP4725 dac; 42 | 43 | extern uint16_t increment, oldIncrement; 44 | extern float amplitude, oldAmplitude; 45 | 46 | void setFrequencyAmplitude(); 47 | void generateSineWave(); 48 | void generateSquareWave(); 49 | void generateTraingularWave(); 50 | void generateSawtoothWaveUp(); 51 | void generateSawtoothWaveDown(); 52 | void generateAnalogOutput(); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/EvivePins.h: -------------------------------------------------------------------------------- 1 | /*All the Pin configuration of evive. 2 | *Developed by Dhrupal R Shah for the evive platform https://evive.cc 3 | *Last editted : 20180208 4 | *Last editted by: Dhrupal R. Shah 5 | *Explore more: https://evive.cc/wp-content/uploads/2017/04/eviveSchematicPinOutDiagram_A4.pdf 6 | */ 7 | 8 | #ifndef EVIVEPINS_H 9 | #define EVIVEPINS_H 10 | 11 | #define TFT_RST 47 12 | #define TFT_CS 48 13 | #define TFT_DC 49 14 | #define SPI_MISO 50 15 | #define SPI_MOSI 51 16 | #define SPI_SCK 52 17 | #define SD_CS 34 18 | #define ADC_CS 35 19 | #define ADC_DREADY 32 20 | #define MOTOR1_D1 28 21 | #define LED28 28 22 | #define MOTOR1_D2 29 23 | #define LED29 29 24 | #define MOTOR1_EN 44 // PWM 25 | #define MOTOR2_D1 30 26 | #define LED30 30 27 | #define MOTOR2_D2 31 28 | #define LED31 31 29 | #define MOTOR2_EN 45 // PWM 30 | #define STEPPER_D1 28 31 | #define STEPPER_D2 29 32 | #define STEPPER_D3 30 33 | #define STEPPER_D4 31 34 | #define SERVO1_ATTACH 44 35 | #define SERVO2_ATTACH 45 36 | #define TACTILESW1 38 37 | #define TACTILESW2 39 38 | #define SLIDESW1_D1 40 39 | #define SLIDESW1_D2 41 40 | #define SLIDESW2_D1 42 41 | #define SLIDESW2_D2 43 42 | #define POT1 A9 43 | #define POT2 A10 44 | #define LEVELSHIFTER_DIR 33 45 | #define VINSUPPLYLEVEL A6 46 | #define VARSUPPLYLEVEL A7 47 | #define BATSUPPLYLEVEL A8 48 | #define NAVKEY_MOVE A11 49 | #define NAVKEY_PRESS 19 50 | #define LED13 13 51 | #define TIMER 46 52 | #define BUZZER 46 53 | #define IO3V3_PIN1 36 54 | #define IO3V3_PIN2 37 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/EvivePins.h: -------------------------------------------------------------------------------- 1 | /*All the Pin configuration of evive. 2 | *Developed by Dhrupal R Shah for the evive platform https://evive.cc 3 | *Last editted : 20180208 4 | *Last editted by: Dhrupal R. Shah 5 | *Explore more: https://evive.cc/wp-content/uploads/2017/04/eviveSchematicPinOutDiagram_A4.pdf 6 | */ 7 | 8 | #ifndef EVIVEPINS_H 9 | #define EVIVEPINS_H 10 | 11 | #define TFT_RST 47 12 | #define TFT_CS 48 13 | #define TFT_DC 49 14 | #define SPI_MISO 50 15 | #define SPI_MOSI 51 16 | #define SPI_SCK 52 17 | #define SD_CS 34 18 | #define ADC_CS 35 19 | #define ADC_DREADY 32 20 | #define MOTOR1_D1 28 21 | #define LED28 28 22 | #define MOTOR1_D2 29 23 | #define LED29 29 24 | #define MOTOR1_EN 44 // PWM 25 | #define MOTOR2_D1 30 26 | #define LED30 30 27 | #define MOTOR2_D2 31 28 | #define LED31 31 29 | #define MOTOR2_EN 45 // PWM 30 | #define STEPPER_D1 28 31 | #define STEPPER_D2 29 32 | #define STEPPER_D3 30 33 | #define STEPPER_D4 31 34 | #define SERVO1_ATTACH 44 35 | #define SERVO2_ATTACH 45 36 | #define TACTILESW1 38 37 | #define TACTILESW2 39 38 | #define SLIDESW1_D1 40 39 | #define SLIDESW1_D2 41 40 | #define SLIDESW2_D1 42 41 | #define SLIDESW2_D2 43 42 | #define POT1 A9 43 | #define POT2 A10 44 | #define LEVELSHIFTER_DIR 33 45 | #define VINSUPPLYLEVEL A6 46 | #define VARSUPPLYLEVEL A7 47 | #define BATSUPPLYLEVEL A8 48 | #define NAVKEY_MOVE A11 49 | #define NAVKEY_PRESS 19 50 | #define LED13 13 51 | #define TIMER 46 52 | #define BUZZER 46 53 | #define IO3V3_PIN1 36 54 | #define IO3V3_PIN2 37 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /examples/BlinkWithFirmware/BlinkWithFirmware.ino: -------------------------------------------------------------------------------- 1 | /* Here we are blinking bi-color LED "M1" of evive connected on Pin 28 and 29. 2 | * Unlike basic blinking code that uses delay for blink action here blinking 3 | * is achieved by switching between firmware and code of glowing LED. 4 | * Library of evive is included in code which makes this task possible. 5 | * Intially LED glows in two colours namely red and green now as the 6 | * navKey is center pressed we navigate to firmware and the uploaded code 7 | * stops running hence led stops changing color for a while till we exit from the firmware 8 | * by using Exit from the menu. As we exit firmware the code to glow led in 9 | * two colours starts again.In this code status bar is also shown for 10 | * information related to battery level and variable voltage value. 11 | * 12 | * Created by Nihar Shah. 13 | * This code is in public domain. 14 | * Explore more at https://thestempedia.com/tutorials/blink-with-firmware-on-evive 15 | */ 16 | 17 | #include // Include evive library 18 | 19 | void setup() { 20 | pinMode(LED28, OUTPUT); // Set pin as output mode (LED28 = Pin 28) 21 | pinMode(LED29, OUTPUT); // Set pin as output mode (LED29 = Pin 29) 22 | drawStatusBar(); // shows variable voltage value (VVR) and battery level 23 | } 24 | 25 | void loop() { 26 | //By center pressing navigation key evive Firmware opens. 27 | drawStatusBar(); // shows variable voltage value (VVR) and battery level 28 | digitalWrite(LED28, HIGH); // glows led in green 29 | digitalWrite(LED29, LOW); 30 | delay(1000); // wait for a second 31 | digitalWrite(LED29, HIGH); // glows led in red 32 | digitalWrite(LED28, LOW); 33 | delay(1000); // wait for a second 34 | } 35 | -------------------------------------------------------------------------------- /src/Plot.h: -------------------------------------------------------------------------------- 1 | /*Plot.h is a library for plotting any variable on TFT ST7735 (in evive) 2 | 3 | Copyright (C) 2018, Agilo Research 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see 30 | 31 | //#include "TFT_ST7735.h" 32 | //#include // Core graphics library 33 | //#include 34 | 35 | //#include 36 | #include "evive.h" 37 | //#include "screenImplementation.h" 38 | 39 | class Plotter 40 | { 41 | public: 42 | int value; 43 | 44 | public: 45 | Plotter(); 46 | void begin(int range); 47 | void draw(int value); 48 | 49 | private: 50 | void ClearAndDrawDot(int i); 51 | void DrawGrid(int i); 52 | void setRange(int range); 53 | 54 | 55 | private: 56 | int i; 57 | //TFT_ST7735 tft; 58 | int values[2][160]; 59 | int range; 60 | int factor; 61 | 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /examples/Easy/Button/Button.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Control an LED on Pin 13 with Button 3 | 4 | Turns ON and OFF a On-Board light emitting diode(LED) 5 | when pressing pushbutton on evive. 6 | 7 | 8 | Modified 9 Sep 2017 9 | by Nihar Shah. 10 | 11 | Explore more on: https://thestempedia.com/tutorials/evive-digital-input-2/ 12 | 13 | 14 | */ 15 | 16 | #include // include evive library 17 | 18 | //Following are called Macros. They are just nicknames. And for Tactile switches on evive nicknames are already avialable. 19 | #define led 13 // Wherever led will be used in sketch, it will be replaced with 13 20 | 21 | //Use macro TACTILESW1 for tactile switch 1. 22 | //Use macro TACTILESW2 for tactile switch 2. 23 | 24 | 25 | //There are different types of variables like integer (..-1,0,1,2..), boolean (1 OR 0), 26 | //character (a, b,...!,@..), float (-1.12,...0..., 100.21..), etc. 27 | //Explore more here: https://thestempedia.com/tutorials/arduino-variable/ 28 | //Bool can either take 1 (High or True) OR 0 (Low or False). A Push button can be either be High or Low. 29 | bool state = 0; // variable for reading the pushbutton status 30 | 31 | void setup() { 32 | // initialize the LED pin as an output: 33 | pinMode(led, OUTPUT); //Initialize LED pin as output (led = 13) 34 | pinMode(TACTILESW1, INPUT); // initialize the pushbutton pin as an input 35 | } 36 | 37 | void loop() { 38 | // read the state of the pushbutton value: 39 | state = digitalRead(TACTILESW1); 40 | // check if the pushbutton is pressed. 41 | // if it is, the buttonState is HIGH: 42 | if (state == HIGH) { 43 | digitalWrite(led, HIGH); // turn LED on: 44 | } 45 | else { 46 | digitalWrite(led, LOW); // turn LED off: 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/Intermediate/TFT/Shapes/Shapes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Using TFT Display to draw shapes 3 | 4 | This code shows how to use TFT display attached on evive for drawing different shapes. 5 | Explore more on : https://thestempedia.com/tutorials/tft-graphics/ 6 | */ 7 | 8 | #include 9 | void setup() { 10 | tft_init(INITR_BLACKTAB); // this is used to initialize TFT display 11 | tft.fillScreen(ST7735_BLACK); // this filles display with black colour 12 | } 13 | void loop() { 14 | // Drawing Lines 15 | tft.drawLine(10, 10, 150, 118, ST7735_BLUE); 16 | tft.drawLine(10, 118, 150, 10, ST7735_BLUE); 17 | delay(1000); 18 | tft.fillScreen(ST7735_BLACK); 19 | 20 | // Drawing Fast Verticle Lines 21 | for (int i = 10; i < 151; i = i + 10) 22 | { 23 | tft.drawFastVLine(i, 1, 128, ST7735_BLUE); 24 | } 25 | 26 | // Drawing Fast Horizontal Lines 27 | for (int i = 10; i < 121; i = i + 10) 28 | { 29 | tft.drawFastHLine(1, i, 160, ST7735_BLUE); 30 | } 31 | delay(1000); 32 | tft.fillScreen(ST7735_BLACK); 33 | 34 | // Draw Rectangle 35 | tft.drawRect(10, 10, 140, 108, ST7735_WHITE); 36 | tft.fillRect(20, 20, 120, 88, ST7735_BLUE); 37 | delay(1000); 38 | tft.fillScreen(ST7735_BLACK); 39 | 40 | // Draw Round Rectangle 41 | tft.drawRoundRect(10, 10, 140, 108, 10, ST7735_WHITE); 42 | tft.fillRoundRect(20, 20, 120, 88, 4, ST7735_BLUE); 43 | delay(1000); 44 | tft.fillScreen(ST7735_BLACK); 45 | 46 | // Draw Circle 47 | tft.drawCircle(80, 64, 60, ST7735_WHITE); 48 | tft.fillCircle(80, 64, 50, ST7735_BLUE); 49 | delay(1000); 50 | tft.fillScreen(ST7735_BLACK); 51 | 52 | // Draw Triangle 53 | tft.drawTriangle(80, 10, 10, 118, 150, 118, ST7735_WHITE); 54 | tft.fillTriangle(80, 30, 30, 108, 130, 108, ST7735_BLUE); 55 | delay(1000); 56 | tft.fillScreen(ST7735_BLACK); 57 | } 58 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Plot.h: -------------------------------------------------------------------------------- 1 | /*Plot.h is a library for plotting any variable on TFT ST7735 (in evive) 2 | 3 | Copyright (C) 2018, Agilo Research 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see 30 | 31 | //#include "TFT_ST7735.h" 32 | //#include // Core graphics library 33 | //#include 34 | 35 | //#include 36 | #include "evive.h" 37 | //#include "screenImplementation.h" 38 | 39 | class Plotter 40 | { 41 | public: 42 | int value; 43 | 44 | public: 45 | Plotter(); 46 | void begin(int range); 47 | void draw(int value); 48 | 49 | private: 50 | void ClearAndDrawDot(int i); 51 | void DrawGrid(int i); 52 | void setRange(int range); 53 | 54 | 55 | private: 56 | int i; 57 | //TFT_ST7735 tft; 58 | int values[2][160]; 59 | int range; 60 | int factor; 61 | 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /examples/Intermediate/Touch/ColorMixer/ColorMixer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Colour Mixer 3 | 4 | In this program three touch pins are assigned names R,G and B signifying red ,green and blue color. 5 | Depending upon the number of pins touched and which pins are touched corresponding colors are displayed on screen. 6 | For example touching red displays Red bar on screen similarly if both red and green are touched yellow is displayed 7 | on screen. 8 | 9 | Made by Nihar Shah, Agilo Research. 10 | On 31 Dec, 2017 11 | Explore more on:https://thestempedia.com/tutorials/arduino-ide-touch-input/ 12 | */ 13 | #define red 1 14 | #define green 2 15 | #define blue 3 16 | #include 17 | void setup() { 18 | tft_init(INITR_GREENTAB); // initialize a ST7735S chip, black tab 19 | tft.fillScreen(ST7735_BLACK); // clear screen 20 | touchPins.begin(0x5A); 21 | 22 | // start touch 23 | } 24 | bool r, g, b; 25 | void loop() { 26 | r = touchPins.isTouched(red); // check red is touched or not? 27 | g = touchPins.isTouched(green); // check green is touched or not? 28 | b = touchPins.isTouched(blue); // check blue is touched or not? 29 | //enter all the combinations 30 | if (r & g & b) 31 | tft.fillRoundRect(20, 30, 120, 68, 10, ST7735_WHITE); 32 | else if (r & g) 33 | tft.fillRoundRect(20, 30, 120, 68, 10, ST7735_YELLOW); 34 | else if (r & b) 35 | tft.fillRoundRect(20, 30, 120, 68, 10, ST7735_MAGENTA); 36 | else if (g & b) 37 | tft.fillRoundRect(20, 30, 120, 68, 10, ST7735_CYAN); 38 | else if (r) 39 | tft.fillRoundRect(20, 30, 120, 68, 10, ST7735_RED); 40 | else if (g) 41 | tft.fillRoundRect(20, 30, 120, 68, 10, ST7735_GREEN); 42 | else if (b) 43 | tft.fillRoundRect(20, 30, 120, 68, 10, ST7735_BLUE); 44 | else 45 | tft.fillRoundRect(20, 30, 120, 68, 10, ST7735_BLACK); 46 | } 47 | -------------------------------------------------------------------------------- /src/Potentiometer.h: -------------------------------------------------------------------------------- 1 | /* 2 | || 3 | || @file Potentiometer.h 4 | || @version 1.2 5 | || @author Alexander Brevig 6 | || @contact alexanderbrevig@gmail.com 7 | || 8 | || @description 9 | || | Provide an easy way of making/using potentiometerss 10 | || # 11 | || 12 | || @license 13 | || | This library is free software; you can redistribute it and/or 14 | || | modify it under the terms of the GNU Lesser General Public 15 | || | License as published by the Free Software Foundation; version 16 | || | 2.1 of the License. 17 | || | 18 | || | This library is distributed in the hope that it will be useful, 19 | || | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | || | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | || | Lesser General Public License for more details. 22 | || | 23 | || | You should have received a copy of the GNU Lesser General Public 24 | || | License along with this library; if not, write to the Free Software 25 | || | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | || # 27 | || 28 | */ 29 | 30 | #ifndef POTENTIOMETER_H 31 | #define POTENTIOMETER_H 32 | 33 | #include "evive.h" 34 | 35 | class Potentiometer { 36 | public: 37 | Potentiometer(byte potPin); 38 | Potentiometer(byte potPin, uint8_t sectors); //Maximum 255 Sectors 39 | uint16_t getValue(); 40 | uint16_t hadValue(); 41 | uint8_t getSector(); 42 | void setSectors(uint8_t sectors); //Maximum 255 Sectors 43 | private: 44 | byte _pin; 45 | uint16_t _value; 46 | uint8_t _sectors; 47 | }; 48 | 49 | extern Potentiometer pot1, pot2; 50 | #endif 51 | 52 | /* 53 | || @changelog 54 | || | 1.2.1 2011-12-11 - TVHeadedRobots : Modified includes to add Arduino 1.0 compatibility 55 | || | 1.2 2009-07-21 - Alexander Brevig : Changed Lisence 56 | || | 1.0 2009-04-13 - Alexander Brevig : Initial Release 57 | || # 58 | */ 59 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Potentiometer.h: -------------------------------------------------------------------------------- 1 | /* 2 | || 3 | || @file Potentiometer.h 4 | || @version 1.2 5 | || @author Alexander Brevig 6 | || @contact alexanderbrevig@gmail.com 7 | || 8 | || @description 9 | || | Provide an easy way of making/using potentiometerss 10 | || # 11 | || 12 | || @license 13 | || | This library is free software; you can redistribute it and/or 14 | || | modify it under the terms of the GNU Lesser General Public 15 | || | License as published by the Free Software Foundation; version 16 | || | 2.1 of the License. 17 | || | 18 | || | This library is distributed in the hope that it will be useful, 19 | || | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | || | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | || | Lesser General Public License for more details. 22 | || | 23 | || | You should have received a copy of the GNU Lesser General Public 24 | || | License along with this library; if not, write to the Free Software 25 | || | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | || # 27 | || 28 | */ 29 | 30 | #ifndef POTENTIOMETER_H 31 | #define POTENTIOMETER_H 32 | 33 | #include "evive.h" 34 | 35 | class Potentiometer { 36 | public: 37 | Potentiometer(byte potPin); 38 | Potentiometer(byte potPin, uint8_t sectors); //Maximum 255 Sectors 39 | uint16_t getValue(); 40 | uint16_t hadValue(); 41 | uint8_t getSector(); 42 | void setSectors(uint8_t sectors); //Maximum 255 Sectors 43 | private: 44 | byte _pin; 45 | uint16_t _value; 46 | uint8_t _sectors; 47 | }; 48 | 49 | extern Potentiometer pot1, pot2; 50 | #endif 51 | 52 | /* 53 | || @changelog 54 | || | 1.2.1 2011-12-11 - TVHeadedRobots : Modified includes to add Arduino 1.0 compatibility 55 | || | 1.2 2009-07-21 - Alexander Brevig : Changed Lisence 56 | || | 1.0 2009-04-13 - Alexander Brevig : Initial Release 57 | || # 58 | */ 59 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | main.cpp - Main loop for Arduino sketches 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "main.h" 21 | ////Declared weak in Arduino.h to allow user redefinitions. 22 | // int atexit(void (* /*func*/ )()) { return 0; } 23 | 24 | ////Weak empty variant initialization function. 25 | ////May be redefined by variant files. 26 | // void initVariant() __attribute__((weak)); 27 | // void initVariant() { } 28 | // void setupUSB() __attribute__((weak)); 29 | // void setupUSB() { } 30 | 31 | //void backToMenu (); 32 | volatile bool _flag_evive_menu; 33 | 34 | void backToMenu (void) 35 | { 36 | _flag_evive_menu = 1; 37 | } 38 | 39 | int main(void) 40 | { 41 | init(); 42 | 43 | initVariant(); 44 | 45 | #if defined(USBCON) 46 | USBDevice.attach(); 47 | #endif 48 | 49 | setup(); 50 | attachInterrupt(digitalPinToInterrupt(19), backToMenu, RISING); 51 | for (;;) { 52 | //unsigned long _ti = pulseInLong(19,HIGH); 53 | if (_flag_evive_menu) 54 | { 55 | eviveFirmware(); 56 | setup(); 57 | } 58 | _flag_evive_menu =0; 59 | 60 | loop(); 61 | 62 | if (serialEventRun) serialEventRun(); 63 | 64 | } 65 | 66 | return 0; 67 | } -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | main.cpp - Main loop for Arduino sketches 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "main.h" 21 | ////Declared weak in Arduino.h to allow user redefinitions. 22 | // int atexit(void (* /*func*/ )()) { return 0; } 23 | 24 | ////Weak empty variant initialization function. 25 | ////May be redefined by variant files. 26 | // void initVariant() __attribute__((weak)); 27 | // void initVariant() { } 28 | // void setupUSB() __attribute__((weak)); 29 | // void setupUSB() { } 30 | 31 | //void backToMenu (); 32 | volatile bool _flag_evive_menu; 33 | 34 | void backToMenu (void) 35 | { 36 | _flag_evive_menu = 1; 37 | } 38 | 39 | int main(void) 40 | { 41 | init(); 42 | 43 | initVariant(); 44 | 45 | #if defined(USBCON) 46 | USBDevice.attach(); 47 | #endif 48 | 49 | setup(); 50 | attachInterrupt(digitalPinToInterrupt(19), backToMenu, RISING); 51 | for (;;) { 52 | //unsigned long _ti = pulseInLong(19,HIGH); 53 | if (_flag_evive_menu) 54 | { 55 | menuPress = 1; 56 | eviveFirmware(); 57 | setup(); 58 | } 59 | _flag_evive_menu =0; 60 | 61 | loop(); 62 | 63 | if (serialEventRun) serialEventRun(); 64 | 65 | } 66 | 67 | return 0; 68 | } -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/ReadMe.md: -------------------------------------------------------------------------------- 1 | evive 2 | This firmware is developed for evive [https://evive.cc] It enables the menu based visual interface for Arduino programs. 3 | 4 | -Planned updates: 5 | 2) Try to implement ADE7912 in library mode from functions (Take care of evive oscilloscope 6 | 7 | eviveFirmware 1.1.0 8 | -Major Changes 9 | 10 | 1) In place of full developer mode with all the libraries, functions of inbuilt functionalities accessible to the user all the time, a library sturcture is implemented. 11 | 2) Examples are added in library of evive 12 | 3) Exit Menu functionality introduced to start the user to run his/her own code defined in the loop of Arduino sketch. 13 | 4) Removed evive.ino from the main destination folder. It has been added in eviveFirmwareExtended folder. 14 | 5) Added Plot libraries in beta testing mode 15 | 6) Added main.h to control evive firmware from center button of joystick. just include main.h and upload blank sketch and press center button. you can also use evive functions and code normally. 16 | 7) Tft Monitor is now working. 17 | 8) Converted Navkey functions to library 18 | 9) isTouched Located Properly 19 | 20 | -Minor Changes 21 | 1) Updated documentation of many libaries 22 | 2) Documented examples 23 | 24 | eviveFirmware 1.0.4 25 | 1) Updated Motor Library to reduce memory usage by changing variables as per required sizes. 26 | 2) Added an Examples library "Examples.h". It includes some examples of using TFT display, presicion sensing using ADE7912 IC, TFTSerial Library etc. But if All examples are selected, than it leads to mulfunctioning of Oscilloscope functioning. 27 | This is disabled by default, but by enabling a macro " 28 | 3) Added init(TAB) function in TFT library to adjust color based on RED TAB or GREEN TAB screen. 29 | 30 | eviveFirmware 1.0.3 20170729 31 | 1) Added TFTSerial Library to enable the user to print any data on TFT screen anywhere in the firmware or user defined functions. 32 | 2) Changed variable "lcd" to "tft" -------------------------------------------------------------------------------- /src/SerialMonitor.h: -------------------------------------------------------------------------------- 1 | /*Serial Monitor library reads data from the selected serial ports in menu and displays on TFT screen. 2 | Menu gives the user a choice to select the baud rate and displays it on the TFT. It can read from multiple 3 | serial ports simultaneously. In the function tft_implementation_serial_monitor [in screenImplementation.h], 4 | serial ports are checked for any new/available data while the class object serialObject takes care of printing the 5 | data on screen corresponding to the selected serial port(s). 6 | 7 | Copyright (C) 2018, Agilo Research 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see 11 | Rtc_Pcf8563 rtc; 12 | String weekDay[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; 13 | void setup() { 14 | tft.init(INITR_BLACKTAB); 15 | tft.setRotation(1); 16 | tft.fillScreen(ST7735_BLACK); 17 | 18 | //Draw round rectangle border on evive screen 19 | tft.drawRoundRect(2, 2, 156, 123, 10, ST7735_BLUE); 20 | 21 | //Print evive logo on screen 22 | tft.drawBitmap(45, 20, evive_logo, 71, 71, ST7735_BLUE); 23 | 24 | //clears all registers 25 | rtc.initClock(); //initialize clock 26 | /* set a date to start with. 27 | day, weekday, month, century, year */ 28 | rtc.setDate(28, 6, 7, 0, 18); // century 0 for 2000 and 1 for 1999. 29 | /*set time in hr, min, sec format*/ 30 | rtc.setTime(19, 15, 40); 31 | 32 | } 33 | 34 | void loop() { 35 | //Get Date from RTC and print it on evive Screen 36 | tft.setCursor(7, 7); 37 | tft.setTextSize(1); 38 | tft.setTextColor(ST7735_WHITE, ST7735_BLACK); 39 | tft.print(rtc.formatDate(0x01)); //0x01 for dd-mm-yyyy, 0x02 for yyyy-mm-dd ,0x04 for mm/dd/yyyy format 40 | 41 | //Get weekDay from RTC and print it on evive Screen 42 | tft.setCursor(135, 7); 43 | tft.setTextSize(1); 44 | tft.setTextColor(ST7735_WHITE, ST7735_BLACK); 45 | tft.print(weekDay[rtc.getWeekday()]); 46 | 47 | //Get Time from RTC and print it on evive Screen 48 | tft.setTextColor(ST7735_WHITE, ST7735_BLACK); 49 | tft.setTextSize(2); 50 | tft.setCursor(33, 100); 51 | tft.print(rtc.formatTime(0x01)); //0x01 for Hours:minutes:seconds , 0x02 for Hours:Minutes 52 | } 53 | -------------------------------------------------------------------------------- /src/Potentiometer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | || @changelog 3 | || | 1.0 2009-04-13 - Alexander Brevig : Initial Release 4 | || | 2.0 2016-05-22 - https://evive.cc Dhrupal R Shah, Agilo Research support@evive.cc 5 | || # 6 | 7 | || @file Potentiometer.cpp 8 | || @version 1.2 9 | || @author Alexander Brevig 10 | || @contact alexanderbrevig@gmail.com 11 | || 12 | || @description 13 | || | Provide an easy way of making/using potentiometers 14 | || # 15 | || 16 | || @license 17 | || | This library is free software; you can redistribute it and/or 18 | || | modify it under the terms of the GNU Lesser General Public 19 | || | License as published by the Free Software Foundation; version 20 | || | 2.1 of the License. 21 | || | 22 | || | This library is distributed in the hope that it will be useful, 23 | || | but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | || | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 25 | || | Lesser General Public License for more details. 26 | || | 27 | || | You should have received a copy of the GNU Lesser General Public 28 | || | License along with this library; if not, write to the Free Software 29 | || | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 30 | || # 31 | || 32 | */ 33 | 34 | #include "Potentiometer.h" 35 | 36 | Potentiometer::Potentiometer(byte potPin){ 37 | _pin=potPin; 38 | setSectors(6); 39 | _value = analogRead(_pin); 40 | } 41 | 42 | Potentiometer::Potentiometer(byte potPin, uint8_t sectors){ 43 | _pin=potPin; 44 | setSectors(sectors); 45 | } 46 | 47 | uint16_t Potentiometer::getValue(){ 48 | return (_value = analogRead(_pin)); 49 | } 50 | 51 | uint16_t Potentiometer::hadValue(){ 52 | return _value; 53 | } 54 | 55 | uint8_t Potentiometer::getSector(){ 56 | return analogRead(_pin)/(1024/_sectors); 57 | } 58 | 59 | void Potentiometer::setSectors(uint8_t newSectors){ 60 | if (newSectors<1024 && newSectors>0){ 61 | _sectors=newSectors; 62 | }else if (newSectors<0){ 63 | _sectors=0; 64 | }else{ 65 | _sectors=255; 66 | } 67 | } 68 | 69 | Potentiometer pot1(9,6), pot2(10,6); 70 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/SerialMonitor.h: -------------------------------------------------------------------------------- 1 | /*Serial Monitor library reads data from the selected serial ports in menu and displays on TFT screen. 2 | Menu gives the user a choice to select the baud rate and displays it on the TFT. It can read from multiple 3 | serial ports simultaneously. In the function tft_implementation_serial_monitor [in screenImplementation.h], 4 | serial ports are checked for any new/available data while the class object serialObject takes care of printing the 5 | data on screen corresponding to the selected serial port(s). 6 | 7 | Copyright (C) 2018, Agilo Research 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see 0){ 61 | _sectors=newSectors; 62 | }else if (newSectors<0){ 63 | _sectors=0; 64 | }else{ 65 | _sectors=255; 66 | } 67 | } 68 | 69 | Potentiometer pot1(9,6), pot2(10,6); 70 | -------------------------------------------------------------------------------- /src/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | main.cpp - Main loop for Arduino sketches 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | #ifndef MAIN_H 20 | #define MAIN_H 21 | 22 | #include 23 | #include "evive.h" 24 | // Declared weak in Arduino.h to allow user redefinitions. 25 | int atexit(void (* /*func*/ )()) { return 0; } 26 | 27 | // Weak empty variant initialization function. 28 | // May be redefined by variant files. 29 | void initVariant() __attribute__((weak)); 30 | void initVariant() { } 31 | void setupUSB() __attribute__((weak)); 32 | void setupUSB() { } 33 | 34 | void backToMenu (); 35 | //volatile bool _flag_evive_menu; 36 | 37 | int main(void); 38 | /* int main(void) 39 | { 40 | init(); 41 | 42 | initVariant(); 43 | 44 | #if defined(USBCON) 45 | USBDevice.attach(); 46 | #endif 47 | 48 | setup(); 49 | attachInterrupt(digitalPinToInterrupt(19), backToMenu, RISING); 50 | for (;;) { 51 | //unsigned long _ti = pulseInLong(19,HIGH); 52 | if (_flag_evive_menu) 53 | { 54 | eviveFirmware(); 55 | setup(); 56 | } 57 | _flag_evive_menu =0; 58 | 59 | loop(); 60 | 61 | if (serialEventRun) serialEventRun(); 62 | 63 | } 64 | 65 | return 0; 66 | } 67 | */ 68 | 69 | //#ifndef BACK_TO_MENU 70 | //#define BACK_TO_MENU 71 | /* void backToMenu (void) 72 | { 73 | _flag_evive_menu = 1; 74 | } */ 75 | //#endif 76 | 77 | #endif -------------------------------------------------------------------------------- /src/Button.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------* 2 | * Arduino Button Library v1.0 * 3 | * Jack Christensen Mar 2012 * 4 | * * 5 | * This work is licensed under the Creative Commons Attribution- * 6 | * ShareAlike 3.0 Unported License. To view a copy of this license, * 7 | * visit http://creativecommons.org/licenses/by-sa/3.0/ or send a * 8 | * letter to Creative Commons, 171 Second Street, Suite 300, * 9 | * San Francisco, California, 94105, USA. * 10 | *----------------------------------------------------------------------*/ 11 | #ifndef BUTTON_H 12 | #define BUTTON_H 13 | 14 | #include "evive.h" 15 | //#if ARDUINO >= 100 16 | //#include 17 | //#else 18 | //#include 19 | //#endif 20 | class Button 21 | { 22 | public: 23 | Button(uint8_t pin); 24 | Button(uint8_t pin, uint32_t dbTime); 25 | Button(uint8_t pin, uint8_t puEnable, uint8_t invert, uint32_t dbTime); 26 | uint8_t read(); 27 | uint8_t isPressed(); 28 | uint8_t isReleased(); 29 | uint8_t wasPressed(); 30 | uint8_t wasReleased(); 31 | uint8_t pressedFor(uint32_t ms); 32 | uint8_t releasedFor(uint32_t ms); 33 | uint32_t lastChange(); 34 | 35 | private: 36 | uint8_t _pin; //arduino pin number 37 | uint8_t _puEnable; //internal pullup resistor enabled 38 | uint8_t _invert; //if 0, interpret high state as pressed, else interpret low state as pressed 39 | uint8_t _state; //current button state 40 | uint8_t _lastState; //previous button state 41 | uint8_t _changed; //state changed since last read 42 | uint32_t _time; //time of current state (all times are in ms) 43 | uint32_t _lastChange; //time of last state change 44 | uint32_t _dbTime; //debounce time 45 | }; 46 | 47 | extern Button tactileSw1, tactileSw2; 48 | #endif 49 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | main.cpp - Main loop for Arduino sketches 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | #ifndef MAIN_H 20 | #define MAIN_H 21 | 22 | #include 23 | #include "evive.h" 24 | // Declared weak in Arduino.h to allow user redefinitions. 25 | int atexit(void (* /*func*/ )()) { return 0; } 26 | 27 | // Weak empty variant initialization function. 28 | // May be redefined by variant files. 29 | void initVariant() __attribute__((weak)); 30 | void initVariant() { } 31 | void setupUSB() __attribute__((weak)); 32 | void setupUSB() { } 33 | 34 | void backToMenu (); 35 | //volatile bool _flag_evive_menu; 36 | 37 | int main(void); 38 | /* int main(void) 39 | { 40 | init(); 41 | 42 | initVariant(); 43 | 44 | #if defined(USBCON) 45 | USBDevice.attach(); 46 | #endif 47 | 48 | setup(); 49 | attachInterrupt(digitalPinToInterrupt(19), backToMenu, RISING); 50 | for (;;) { 51 | //unsigned long _ti = pulseInLong(19,HIGH); 52 | if (_flag_evive_menu) 53 | { 54 | eviveFirmware(); 55 | setup(); 56 | } 57 | _flag_evive_menu =0; 58 | 59 | loop(); 60 | 61 | if (serialEventRun) serialEventRun(); 62 | 63 | } 64 | 65 | return 0; 66 | } 67 | */ 68 | 69 | //#ifndef BACK_TO_MENU 70 | //#define BACK_TO_MENU 71 | /* void backToMenu (void) 72 | { 73 | _flag_evive_menu = 1; 74 | } */ 75 | //#endif 76 | 77 | #endif -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Button.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------* 2 | * Arduino Button Library v1.0 * 3 | * Jack Christensen Mar 2012 * 4 | * * 5 | * This work is licensed under the Creative Commons Attribution- * 6 | * ShareAlike 3.0 Unported License. To view a copy of this license, * 7 | * visit http://creativecommons.org/licenses/by-sa/3.0/ or send a * 8 | * letter to Creative Commons, 171 Second Street, Suite 300, * 9 | * San Francisco, California, 94105, USA. * 10 | *----------------------------------------------------------------------*/ 11 | #ifndef BUTTON_H 12 | #define BUTTON_H 13 | 14 | #include "evive.h" 15 | //#if ARDUINO >= 100 16 | //#include 17 | //#else 18 | //#include 19 | //#endif 20 | class Button 21 | { 22 | public: 23 | Button(uint8_t pin); 24 | Button(uint8_t pin, uint32_t dbTime); 25 | Button(uint8_t pin, uint8_t puEnable, uint8_t invert, uint32_t dbTime); 26 | uint8_t read(); 27 | uint8_t isPressed(); 28 | uint8_t isReleased(); 29 | uint8_t wasPressed(); 30 | uint8_t wasReleased(); 31 | uint8_t pressedFor(uint32_t ms); 32 | uint8_t releasedFor(uint32_t ms); 33 | uint32_t lastChange(); 34 | 35 | private: 36 | uint8_t _pin; //arduino pin number 37 | uint8_t _puEnable; //internal pullup resistor enabled 38 | uint8_t _invert; //if 0, interpret high state as pressed, else interpret low state as pressed 39 | uint8_t _state; //current button state 40 | uint8_t _lastState; //previous button state 41 | uint8_t _changed; //state changed since last read 42 | uint32_t _time; //time of current state (all times are in ms) 43 | uint32_t _lastChange; //time of last state change 44 | uint32_t _dbTime; //debounce time 45 | }; 46 | 47 | extern Button tactileSw1, tactileSw2; 48 | #endif 49 | -------------------------------------------------------------------------------- /examples/Intermediate/TFT/Colors/Colors.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This Program demonstrates various colours on TFT display 4 | made for evive platform. 5 | 6 | Created by Nihar Shah. 7 | 8 | This code is in public domain. 9 | 10 | Explore more on : https://thestempedia.com/tutorials/tft-text-manipulation/ 11 | */ 12 | #include 13 | void setup() { 14 | Serial.begin(250000); 15 | tft.init(INITR_BLACKTAB); 16 | tft.setRotation(1); 17 | Serial.println("Initialized"); 18 | tft.fillScreen(ST7735_BLACK); 19 | } 20 | 21 | void loop() { 22 | tft.setTextColor(ST7735_WHITE); 23 | tft.setTextSize(1); 24 | tft.setCursor(0, 10); 25 | tft.println("Hello World"); 26 | tft.println(""); 27 | tft.println("My name is evive and this is TFT display in white colour."); 28 | delay(2000); 29 | tft.fillScreen(ST7735_BLACK); 30 | 31 | tft.setTextColor(ST7735_RED); 32 | tft.setTextSize(1); 33 | tft.setCursor(0, 10); 34 | tft.println("Hello World"); 35 | tft.println(""); 36 | tft.println("My name is evive and this is TFT display in red colour."); 37 | delay(2000); 38 | tft.fillScreen(ST7735_BLACK); 39 | 40 | tft.setTextColor(ST7735_BLUE); 41 | tft.setTextSize(1); 42 | tft.setCursor(0, 10); 43 | tft.println("Hello World"); 44 | tft.println(""); 45 | tft.println("My name is evive and this is TFT display in blue colour."); 46 | delay(2000); 47 | tft.fillScreen(ST7735_BLACK); 48 | 49 | tft.setTextColor(ST7735_YELLOW); 50 | tft.setTextSize(1); 51 | tft.setCursor(0, 10); 52 | tft.println("Hello World"); 53 | tft.println(""); 54 | tft.println("My name is evive and this is TFT display in yellow colour."); 55 | delay(2000); 56 | tft.fillScreen(ST7735_BLACK); 57 | 58 | tft.setTextColor(ST7735_GREEN); 59 | tft.setTextSize(1); 60 | tft.setCursor(0, 10); 61 | tft.println("Hello World"); 62 | tft.println(""); 63 | tft.println("My name is evive and this is TFT display in green colour."); 64 | delay(2000); 65 | tft.fillScreen(ST7735_BLACK); 66 | 67 | tft.setTextColor(ST7735_MAGENTA); 68 | tft.setTextSize(1); 69 | tft.setCursor(0, 10); 70 | tft.println("Hello World"); 71 | tft.println(""); 72 | tft.println("My name is evive and this is TFT display in Magenta colour."); 73 | delay(2000); 74 | tft.fillScreen(ST7735_BLACK); 75 | } 76 | -------------------------------------------------------------------------------- /src/AddUserDefinedFunctions.h: -------------------------------------------------------------------------------- 1 | /*AddUserDefinedFunctions.cpp defines the User Defined Functions to be 2 | displayed on the evive's menu based visual interface. 3 | Copyright (C) 2018, Agilo Research 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see " 28 | 2) Write the corresponding code in AddUserDefinedFunctions.cpp as follows: 29 | -setup (runs one time) 30 | -loop (runs continuosly) 31 | */ 32 | 33 | #ifndef addUserDefinedFunctions_H 34 | #define addUserDefinedFunctions_H 35 | 36 | //IMPORTANT: uncomment the required user defined function(s) and give desired name below. Then in AddUserDefinedFunctions.cpp, go to the corresponding "setup" and "loop" functions to write the program (defination). 37 | #define USER_DEFINED_FUNCTION_1 "Eg: Blink" 38 | #define USER_DEFINED_FUNCTION_2 "Eg: Blink Analog Input" 39 | #define USER_DEFINED_FUNCTION_3 "User Def fun name 3" 40 | //#define USER_DEFINED_FUNCTION_4 "User Def fun name 4" 41 | //#define USER_DEFINED_FUNCTION_5 "User Def fun name 5" 42 | 43 | #include "evive.h" 44 | 45 | void loop_user_def_fun_1(); 46 | void loop_user_def_fun_2(); 47 | void loop_user_def_fun_3(); 48 | void loop_user_def_fun_4(); 49 | void loop_user_def_fun_5(); 50 | 51 | void add_user_def_fun(uint8_t); 52 | void remove_other_user_def_fun(uint8_t); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/AddUserDefinedFunctions.h: -------------------------------------------------------------------------------- 1 | /*AddUserDefinedFunctions.cpp defines the User Defined Functions to be 2 | displayed on the evive's menu based visual interface. 3 | Copyright (C) 2018, Agilo Research 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see " 28 | 2) Write the corresponding code in AddUserDefinedFunctions.cpp as follows: 29 | -setup (runs one time) 30 | -loop (runs continuosly) 31 | */ 32 | 33 | #ifndef addUserDefinedFunctions_H 34 | #define addUserDefinedFunctions_H 35 | 36 | //IMPORTANT: uncomment the required user defined function(s) and give desired name below. Then in AddUserDefinedFunctions.cpp, go to the corresponding "setup" and "loop" functions to write the program (defination). 37 | #define USER_DEFINED_FUNCTION_1 "Eg: Blink" 38 | #define USER_DEFINED_FUNCTION_2 "Eg: Blink Analog Input" 39 | #define USER_DEFINED_FUNCTION_3 "User Def fun name 3" 40 | //#define USER_DEFINED_FUNCTION_4 "User Def fun name 4" 41 | //#define USER_DEFINED_FUNCTION_5 "User Def fun name 5" 42 | 43 | #include "evive.h" 44 | 45 | void loop_user_def_fun_1(); 46 | void loop_user_def_fun_2(); 47 | void loop_user_def_fun_3(); 48 | void loop_user_def_fun_4(); 49 | void loop_user_def_fun_5(); 50 | 51 | void add_user_def_fun(uint8_t); 52 | void remove_other_user_def_fun(uint8_t); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/ServoTimers.h: -------------------------------------------------------------------------------- 1 | /* 2 | Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 3 | Copyright (c) 2009 Michael Margolis. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /* 21 | * Defines for 16 bit timers used with Servo library 22 | * 23 | * If _useTimerX is defined then TimerX is a 16 bit timer on the current board 24 | * timer16_Sequence_t enumerates the sequence that the timers should be allocated 25 | * _Nbr_16timers indicates how many 16 bit timers are available. 26 | */ 27 | 28 | /** 29 | * AVR Only definitions 30 | * -------------------- 31 | */ 32 | 33 | // Say which 16 bit timers can be used and in what order 34 | #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 35 | #define _useTimer1 36 | #define _useTimer5 37 | #define _useTimer3 38 | #define _useTimer4 39 | typedef enum { _timer1, _timer5, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t; 40 | 41 | #elif defined(__AVR_ATmega32U4__) 42 | #define _useTimer1 43 | typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t; 44 | 45 | #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) 46 | #define _useTimer3 47 | #define _useTimer1 48 | typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t; 49 | 50 | #elif defined(__AVR_ATmega128__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega2561__) 51 | #define _useTimer3 52 | #define _useTimer1 53 | typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t; 54 | 55 | #else // everything else 56 | #define _useTimer1 57 | typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t; 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/ServoTimers.h: -------------------------------------------------------------------------------- 1 | /* 2 | Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 3 | Copyright (c) 2009 Michael Margolis. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /* 21 | * Defines for 16 bit timers used with Servo library 22 | * 23 | * If _useTimerX is defined then TimerX is a 16 bit timer on the current board 24 | * timer16_Sequence_t enumerates the sequence that the timers should be allocated 25 | * _Nbr_16timers indicates how many 16 bit timers are available. 26 | */ 27 | 28 | /** 29 | * AVR Only definitions 30 | * -------------------- 31 | */ 32 | 33 | // Say which 16 bit timers can be used and in what order 34 | #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 35 | #define _useTimer1 36 | #define _useTimer5 37 | #define _useTimer3 38 | #define _useTimer4 39 | typedef enum { _timer1, _timer5, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t; 40 | 41 | #elif defined(__AVR_ATmega32U4__) 42 | #define _useTimer1 43 | typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t; 44 | 45 | #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) 46 | #define _useTimer3 47 | #define _useTimer1 48 | typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t; 49 | 50 | #elif defined(__AVR_ATmega128__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega2561__) 51 | #define _useTimer3 52 | #define _useTimer1 53 | typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t; 54 | 55 | #else // everything else 56 | #define _useTimer1 57 | typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t; 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /src/Configuration.h: -------------------------------------------------------------------------------- 1 | /*All the configuration for including/excluding evive features. (Pin Configuration are defined in "EvivePins.h".) 2 | *Developed by Dhrupal R Shah for the evive platform https://evive.cc . 3 | *Last editted : 20180208 4 | *Last editted by: Dhrupal R Shah 5 | * 6 | *Note: Work in progress to make it modular and reudce features as per user needs 7 | */ 8 | 9 | #ifndef CONFIGURATION_H 10 | #define CONFIGURATION_H 11 | 12 | /* DEBUG MODE: comment this line to disable debugging messages over serial console*/ 13 | //#define __DEBUG__ 14 | 15 | #define SENSING 16 | 17 | #define SCREEN 18 | 19 | //Uncomment/Comment the INCLUDE_EXAMPLES to exclued/include examples in menu 20 | #ifndef INCLUDE_EXAMPLES 21 | #define INCLUDE_EXAMPLES 22 | #endif 23 | 24 | #define BAUDRATE 250000 25 | #define SERIAL_TIME_OUT 10 26 | 27 | //////////macros//////////////// 28 | // Macros to support option testing 29 | #define _CAT(a, ...) a ## __VA_ARGS__ 30 | #define SWITCH _ENABLED_0 0 31 | #define SWITCH_ENABLED_1 1 32 | #define SWITCH_ENABLED_ 1 33 | #define ENABLED(b) _CAT(SWITCH_ENABLED_, b) 34 | #define DISABLED(b) (!_CAT(SWITCH_ENABLED_, b)) 35 | 36 | //Min time between simultaneous process 37 | #define MIN_TIME1 100 38 | #define MIN_TIME1_5 150 39 | #define MIN_TIME2 200 40 | //#define MIN_TIME3 300 41 | #define MIN_TIME5 500 42 | 43 | // Macros for bit masks 44 | #define BIT(b) (1<<(b)) 45 | #define TEST(n,b) (((n)&BIT(b))!=0) 46 | #define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b)) 47 | 48 | // Macros for maths shortcuts 49 | //#define RADIANS(d) ((d)*M_PI/180.0) 50 | //#define DEGREES(r) ((r)*180.0/M_PI) 51 | // 52 | //#define COUNT(a) (sizeof(a)/sizeof(*a)) 53 | 54 | // Define various ADC prescaler (Used to speed up ADC read action) 55 | //const unsigned char PS_16 = (1 << ADPS2); 56 | const unsigned char PS_32 = (1 << ADPS2) | (1 << ADPS0); 57 | //const unsigned char PS_64 = (1 << ADPS2) | (1 << ADPS1); 58 | const unsigned char PS_128 = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); 59 | 60 | //TFT and Menu related macros 61 | #ifndef ROW_HEIGHT 62 | #define ROW_HEIGHT 10 63 | #endif 64 | #ifndef CHAR_HEIGHT 65 | #define CHAR_HEIGHT 8 66 | #endif 67 | #ifndef CHAR_WIDTH 68 | #define CHAR_WIDTH 6 69 | #endif 70 | #ifndef LEFT_MARGIN 71 | #define LEFT_MARGIN 2 72 | #endif 73 | #ifndef RIGHT_MARGIN 74 | #define RIGHT_MARGIN 2 75 | #endif 76 | #ifndef TOP_MARGIN 77 | #define TOP_MARGIN 14 78 | #endif 79 | #ifndef BOTTOM_MARGIN 80 | #define BOTTOM_MARGIN 2 81 | #endif 82 | #ifndef TFT_HEIGHT 83 | #define TFT_HEIGHT 128 84 | #endif 85 | #ifndef TFT_WIDTH 86 | #define TFT_WIDTH 160 87 | #endif 88 | #ifndef TFT_WIDTH_BY_2 89 | #define TFT_WIDTH_BY_2 80 90 | #endif 91 | 92 | #endif 93 | 94 | -------------------------------------------------------------------------------- /src/Ade7912_Adc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adc_Ade7912.cpp is the library with functions to use sensing probes in evive, namely Probe V and Probe I/V 3 | * evive has 24bit presision sensing ADC: ADE7912 4 | * 5 | * Created on: May 27, 2016 6 | * Author: Dhrupal R Shah 7 | * Sensing with ADE7912 8 | * Library based on codes of Art of Circuits 9 | * Edited by evive team, https://evive.cc Agilo Research 10 | * or Dhrupal R Shah and Akshat Agarwal 11 | * Edited on 20170102 12 | * Contact: support@evive.cc 13 | * Target Board: evive 14 | * Copyright (C) 2018, Agilo Research 15 | * 16 | * How to use: 17 | * Read well documented tutorial on how to use evive sensing here: 18 | * Function List: 19 | * 1) ade791x_init() : initialize the ADE7912 IC to communicate over SPI communication with microcontroller ATmega2560 20 | * 2) long ade791x_read_v1() : returns the voltage sensed between the Probe V and COM (or on the Graph port between the Right Pin and Center Pin (COM)) 21 | * 3) long ade791x_read_vim() : returns the voltage sensed between the Probe I/V and COM (or on the Graph port between the Left Pin and Center Pin (COM)) 22 | * 4) long ade791x_read_im(): NOTE: Put the JP2 Jumper of I or V (Blue) on the I side for sensing current. This function returns the current sensed 23 | * between the Probe I/V and COM (or on the Graph port between the Right Pin and Center Pin (COM)) 24 | * 25 | * Note: Converting to class-library format was tried, but 1 channel of evive oscillocope functioning was not correct. 26 | * NOTE: Screen Implementation for mini oscilloscope feature is done in SCREEN_IMPLEMENTATION_H 27 | */ 28 | 29 | #ifndef ADC_ADE7912_H_ 30 | #define ADC_ADE7912_H_ 31 | 32 | #include "evive.h" 33 | 34 | #ifndef ADE7911X_REG_IWV 35 | #define ADE791X_REG_IWV 0x00 /* Instantaneous value of Current I. */ 36 | #define ADE791X_REG_V1WV 0x01 /* Instantaneous value of Voltage V1 */ 37 | #define ADE791X_REG_V2WV 0x02 /* Instantaneous value of Voltage V2 */ 38 | //For V1WV 5,320,000 reading = 34.5V (Multiplier = 0.006485) mV 39 | #define ADE791X_MUL_V1WV 0.006485 40 | //For V2WV 5,320,000Num reading = 6.3315V (Multiplier = 0.0011901) mV 41 | #define ADE791X_MUL_VIMWV 0.0011901 42 | //For IWV 5,320,000 reading = 3.15A (Multiplier = 0.0005921) mA 43 | #define ADE791X_MUL_IWV 0.0005921 44 | #define ADE791X_OFFSET_V1WV 363378 //387161; //Adjust 45 | #define ADE791X_OFFSET_VIMWV 369226 //Adjust 46 | #define ADE791X_OFFSET_IWV 355000 //369226; //Adjust 47 | #endif 48 | 49 | void ade791x_init(void); 50 | long ade791x_read_v1(void); 51 | long ade791x_read_vim(void); 52 | long ade791x_read_im(void); 53 | 54 | #endif /* ADC_ADE7912_H_ */ 55 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Configuration.h: -------------------------------------------------------------------------------- 1 | /*All the configuration for including/excluding evive features. (Pin Configuration are defined in "EvivePins.h".) 2 | *Developed by Dhrupal R Shah for the evive platform https://evive.cc . 3 | *Last editted : 20180208 4 | *Last editted by: Dhrupal R Shah 5 | * 6 | *Note: Work in progress to make it modular and reudce features as per user needs 7 | */ 8 | 9 | #ifndef CONFIGURATION_H 10 | #define CONFIGURATION_H 11 | 12 | /* DEBUG MODE: comment this line to disable debugging messages over serial console*/ 13 | //#define __DEBUG__ 14 | 15 | #define SENSING 16 | 17 | #define SCREEN 18 | 19 | //Uncomment/Comment the INCLUDE_EXAMPLES to exclued/include examples in menu 20 | #ifndef INCLUDE_EXAMPLES 21 | #define INCLUDE_EXAMPLES 22 | #endif 23 | 24 | #define BAUDRATE 250000 25 | #define SERIAL_TIME_OUT 10 26 | 27 | //////////macros//////////////// 28 | // Macros to support option testing 29 | #define _CAT(a, ...) a ## __VA_ARGS__ 30 | #define SWITCH _ENABLED_0 0 31 | #define SWITCH_ENABLED_1 1 32 | #define SWITCH_ENABLED_ 1 33 | #define ENABLED(b) _CAT(SWITCH_ENABLED_, b) 34 | #define DISABLED(b) (!_CAT(SWITCH_ENABLED_, b)) 35 | 36 | //Min time between simultaneous process 37 | #define MIN_TIME1 100 38 | #define MIN_TIME1_5 150 39 | #define MIN_TIME2 200 40 | //#define MIN_TIME3 300 41 | #define MIN_TIME5 500 42 | 43 | // Macros for bit masks 44 | #define BIT(b) (1<<(b)) 45 | #define TEST(n,b) (((n)&BIT(b))!=0) 46 | #define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b)) 47 | 48 | // Macros for maths shortcuts 49 | //#define RADIANS(d) ((d)*M_PI/180.0) 50 | //#define DEGREES(r) ((r)*180.0/M_PI) 51 | // 52 | //#define COUNT(a) (sizeof(a)/sizeof(*a)) 53 | 54 | // Define various ADC prescaler (Used to speed up ADC read action) 55 | //const unsigned char PS_16 = (1 << ADPS2); 56 | const unsigned char PS_32 = (1 << ADPS2) | (1 << ADPS0); 57 | //const unsigned char PS_64 = (1 << ADPS2) | (1 << ADPS1); 58 | const unsigned char PS_128 = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); 59 | 60 | //TFT and Menu related macros 61 | #ifndef ROW_HEIGHT 62 | #define ROW_HEIGHT 10 63 | #endif 64 | #ifndef CHAR_HEIGHT 65 | #define CHAR_HEIGHT 8 66 | #endif 67 | #ifndef CHAR_WIDTH 68 | #define CHAR_WIDTH 6 69 | #endif 70 | #ifndef LEFT_MARGIN 71 | #define LEFT_MARGIN 2 72 | #endif 73 | #ifndef RIGHT_MARGIN 74 | #define RIGHT_MARGIN 2 75 | #endif 76 | #ifndef TOP_MARGIN 77 | #define TOP_MARGIN 14 78 | #endif 79 | #ifndef BOTTOM_MARGIN 80 | #define BOTTOM_MARGIN 2 81 | #endif 82 | #ifndef TFT_HEIGHT 83 | #define TFT_HEIGHT 128 84 | #endif 85 | #ifndef TFT_WIDTH 86 | #define TFT_WIDTH 160 87 | #endif 88 | #ifndef TFT_WIDTH_BY_2 89 | #define TFT_WIDTH_BY_2 80 90 | #endif 91 | 92 | #endif 93 | 94 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Ade7912_Adc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adc_Ade7912.cpp is the library with functions to use sensing probes in evive, namely Probe V and Probe I/V 3 | * evive has 24bit presision sensing ADC: ADE7912 4 | * 5 | * Created on: May 27, 2016 6 | * Author: Dhrupal R Shah 7 | * Sensing with ADE7912 8 | * Library based on codes of Art of Circuits 9 | * Edited by evive team, https://evive.cc Agilo Research 10 | * or Dhrupal R Shah and Akshat Agarwal 11 | * Edited on 20170102 12 | * Contact: support@evive.cc 13 | * Target Board: evive 14 | * Copyright (C) 2018, Agilo Research 15 | * 16 | * How to use: 17 | * Read well documented tutorial on how to use evive sensing here: 18 | * Function List: 19 | * 1) ade791x_init() : initialize the ADE7912 IC to communicate over SPI communication with microcontroller ATmega2560 20 | * 2) long ade791x_read_v1() : returns the voltage sensed between the Probe V and COM (or on the Graph port between the Right Pin and Center Pin (COM)) 21 | * 3) long ade791x_read_vim() : returns the voltage sensed between the Probe I/V and COM (or on the Graph port between the Left Pin and Center Pin (COM)) 22 | * 4) long ade791x_read_im(): NOTE: Put the JP2 Jumper of I or V (Blue) on the I side for sensing current. This function returns the current sensed 23 | * between the Probe I/V and COM (or on the Graph port between the Right Pin and Center Pin (COM)) 24 | * 25 | * Note: Converting to class-library format was tried, but 1 channel of evive oscillocope functioning was not correct. 26 | * NOTE: Screen Implementation for mini oscilloscope feature is done in SCREEN_IMPLEMENTATION_H 27 | */ 28 | 29 | #ifndef ADC_ADE7912_H_ 30 | #define ADC_ADE7912_H_ 31 | 32 | #include "evive.h" 33 | 34 | #ifndef ADE7911X_REG_IWV 35 | #define ADE791X_REG_IWV 0x00 /* Instantaneous value of Current I. */ 36 | #define ADE791X_REG_V1WV 0x01 /* Instantaneous value of Voltage V1 */ 37 | #define ADE791X_REG_V2WV 0x02 /* Instantaneous value of Voltage V2 */ 38 | //For V1WV 5,320,000 reading = 34.5V (Multiplier = 0.006485) mV 39 | #define ADE791X_MUL_V1WV 0.006485 40 | //For V2WV 5,320,000Num reading = 6.3315V (Multiplier = 0.0011901) mV 41 | #define ADE791X_MUL_VIMWV 0.0011901 42 | //For IWV 5,320,000 reading = 3.15A (Multiplier = 0.0005921) mA 43 | #define ADE791X_MUL_IWV 0.0005921 44 | #define ADE791X_OFFSET_V1WV 363378 //387161; //Adjust 45 | #define ADE791X_OFFSET_VIMWV 369226 //Adjust 46 | #define ADE791X_OFFSET_IWV 355000 //369226; //Adjust 47 | #endif 48 | 49 | void ade791x_init(void); 50 | long ade791x_read_v1(void); 51 | long ade791x_read_vim(void); 52 | long ade791x_read_im(void); 53 | 54 | #endif /* ADC_ADE7912_H_ */ 55 | -------------------------------------------------------------------------------- /src/TftMonitor.h: -------------------------------------------------------------------------------- 1 | /*TftMonitor library implements similar view of serial monitor of Arduino desktop IDE 2 | *on evive TFT display. 3 | * 4 | *Last editted on 01.08.2017 by Harsh Chittora an Dhrupal R. Shah 5 | *Added support for double and float 6 | *Improved Text wrap for int 7 | * 8 | *How to use: 9 | *1) Declare a class object with any name, say tftMonitor, as: TftMonitor tftMonitor; 10 | *2) Now you can use the tftMonitor as Serial object: tftMonitor.print(123) 11 | * 12 | *Note: Work in progress. 13 | */ 14 | 15 | #ifndef TFTSERIAL_H 16 | #define TFTSERIAL_H 17 | 18 | //#include 19 | //#include "TFT_ST7735.h" 20 | 21 | #include "evive.h" 22 | 23 | extern TFT_ST7735 tft;// = TFT_ST7735(); 24 | 25 | class TftMonitor{ 26 | private: 27 | String s; //string to be printed 28 | public: 29 | //TftMonitor(); //internally creates the class for tft. 30 | void begin(); //innitialises the tft 31 | 32 | 33 | //the print and println functions work same as the serial print and println 34 | void print(int i); 35 | void print(char c); 36 | void print(String s); 37 | //void print(double, int = 2); //upto arg2 number of decimals 38 | void print(double d); 39 | void print(float f); 40 | //void print(int, int = DEC); //Print in HEX/DEC/OCT 41 | 42 | //void println(); 43 | void println(char c); 44 | // void println(int i); 45 | void println(String s); 46 | void println(void); 47 | void println(double d); 48 | void println(float f); 49 | void println(int i, int = DEC); 50 | // size_t print(const __FlashStringHelper *); 51 | // size_t print(const String &); 52 | // size_t print(const char[]); 53 | // size_t print(char); 54 | // size_t print(unsigned char, int = DEC); 55 | // size_t print(int, int = DEC); 56 | // size_t print(unsigned int, int = DEC); 57 | // size_t print(long, int = DEC); 58 | // size_t print(unsigned long, int = DEC); 59 | // size_t print(double, int = 2); 60 | // size_t print(const Printable&); 61 | 62 | // size_t println(const __FlashStringHelper *); 63 | // size_t println(const String &s); 64 | // size_t println(const char[]); 65 | // size_t println(char); 66 | // size_t println(unsigned char, int = DEC); 67 | // size_t println(int, int = DEC); 68 | // size_t println(unsigned int, int = DEC); 69 | // size_t println(long, int = DEC); 70 | // size_t println(unsigned long, int = DEC); 71 | // size_t println(double, int = 2); 72 | // size_t println(const Printable&); 73 | // size_t println(void); 74 | 75 | private: 76 | //TFT_ST7735 tft; 77 | uint8_t next_line; //keep a track of the next line on tft. 78 | uint8_t next_col; //keep a track of the next column on tft. 79 | 80 | 81 | 82 | 83 | }; 84 | 85 | //extern TftMonitor tftMonitor; 86 | #endif 87 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/TftMonitor.h: -------------------------------------------------------------------------------- 1 | /*TftMonitor library implements similar view of serial monitor of Arduino desktop IDE 2 | *on evive TFT display. 3 | * 4 | *Last editted on 01.08.2017 by Harsh Chittora an Dhrupal R. Shah 5 | *Added support for double and float 6 | *Improved Text wrap for int 7 | * 8 | *How to use: 9 | *1) Declare a class object with any name, say tftMonitor, as: TftMonitor tftMonitor; 10 | *2) Now you can use the tftMonitor as Serial object: tftMonitor.print(123) 11 | * 12 | *Note: Work in progress. 13 | */ 14 | 15 | #ifndef TFTSERIAL_H 16 | #define TFTSERIAL_H 17 | 18 | //#include 19 | //#include "TFT_ST7735.h" 20 | 21 | #include "evive.h" 22 | 23 | extern TFT_ST7735 tft;// = TFT_ST7735(); 24 | 25 | class TftMonitor{ 26 | private: 27 | String s; //string to be printed 28 | public: 29 | //TftMonitor(); //internally creates the class for tft. 30 | void begin(); //innitialises the tft 31 | 32 | 33 | //the print and println functions work same as the serial print and println 34 | void print(int i); 35 | void print(char c); 36 | void print(String s); 37 | //void print(double, int = 2); //upto arg2 number of decimals 38 | void print(double d); 39 | void print(float f); 40 | //void print(int, int = DEC); //Print in HEX/DEC/OCT 41 | 42 | //void println(); 43 | void println(char c); 44 | // void println(int i); 45 | void println(String s); 46 | void println(void); 47 | void println(double d); 48 | void println(float f); 49 | void println(int i, int = DEC); 50 | // size_t print(const __FlashStringHelper *); 51 | // size_t print(const String &); 52 | // size_t print(const char[]); 53 | // size_t print(char); 54 | // size_t print(unsigned char, int = DEC); 55 | // size_t print(int, int = DEC); 56 | // size_t print(unsigned int, int = DEC); 57 | // size_t print(long, int = DEC); 58 | // size_t print(unsigned long, int = DEC); 59 | // size_t print(double, int = 2); 60 | // size_t print(const Printable&); 61 | 62 | // size_t println(const __FlashStringHelper *); 63 | // size_t println(const String &s); 64 | // size_t println(const char[]); 65 | // size_t println(char); 66 | // size_t println(unsigned char, int = DEC); 67 | // size_t println(int, int = DEC); 68 | // size_t println(unsigned int, int = DEC); 69 | // size_t println(long, int = DEC); 70 | // size_t println(unsigned long, int = DEC); 71 | // size_t println(double, int = 2); 72 | // size_t println(const Printable&); 73 | // size_t println(void); 74 | 75 | private: 76 | //TFT_ST7735 tft; 77 | uint8_t next_line; //keep a track of the next line on tft. 78 | uint8_t next_col; //keep a track of the next column on tft. 79 | 80 | 81 | 82 | 83 | }; 84 | 85 | //extern TftMonitor tftMonitor; 86 | #endif 87 | -------------------------------------------------------------------------------- /src/Screen.h: -------------------------------------------------------------------------------- 1 | /*Screen.h handles the functioning of menu based visual interface for 2 | evive/Arduino based platforms. 3 | Copyright (C) 2018, Agilo Research 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see 24 | bool response = 0; 25 | String response_data = ""; 26 | void setup() { 27 | // initialize Serial3 communication of bluetooth which is on Serial3 3: 28 | // bluetooth setup is done at 38400 baud with New line and Carriage Return 29 | Serial3.begin(38400); //Baud for communication in ATmode 30 | Serial.begin(250000); 31 | // initialize the LED pin as an output: 32 | pinMode(LED_BUILTIN, OUTPUT); 33 | while (!(response)) 34 | { 35 | Serial3.print("AT+ADDR\r\n"); 36 | response_data = Serial3.readString(); 37 | if (response_data != '\0') 38 | { 39 | Serial.println("AT+ADDR"); 40 | Serial.println(response_data); 41 | response++; 42 | } 43 | } 44 | response = 0; 45 | while (!(response)) 46 | { 47 | Serial3.print("AT+UART=115200,0,0\r\n"); 48 | response_data = Serial3.readString(); 49 | if (response_data == "OK\r\n") 50 | { 51 | Serial.println("AT+UART=115200,0,0"); 52 | Serial.println(response_data); 53 | response++; 54 | } 55 | } 56 | response = 0; 57 | while (!(response)) 58 | { 59 | Serial3.print("AT+NAME=evive\r\n"); 60 | response_data = Serial3.readString(); 61 | if (response_data == "OK\r\n") 62 | { 63 | Serial.println("AT+NAME=evive"); 64 | Serial.println(response_data); 65 | response++; 66 | } 67 | } 68 | response = 0; 69 | while (!(response)) 70 | { 71 | Serial3.print("AT+PSWD=\"0000\"\r\n"); 72 | response_data = Serial3.readString(); 73 | if (response_data == "OK\r\n") 74 | { 75 | Serial.println("AT+PSWD=\"0000\""); 76 | Serial.println(response_data); 77 | response++; 78 | } 79 | } 80 | response = 0; 81 | //To initialize pairing mode of HC-05 82 | Serial3.print("AT+INIT\r\n"); //when HC-05 responds to this command sucessfully the led on HC-05 starts blinking in speed suggesting that bluetooth is in pairing mode. 83 | Serial.println("AT+INIT"); 84 | digitalWrite(LED_BUILTIN, HIGH); 85 | } 86 | 87 | void loop() { 88 | 89 | // put your main code here, to run repeatedly: 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/MPR121_Touch.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the MPR121 12-Channel Capacitive Sensor 3 | 4 | Designed specifically to work with the MPR121 breakout from Adafruit 5 | ----> https://www.adafruit.com/products/1982 6 | 7 | These sensors use I2C to communicate, 2+ pins are required to 8 | interface 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | BSD license, all text above must be included in any redistribution 15 | ****************************************************/ 16 | 17 | #ifndef ADAFRUIT_MPR121_H 18 | #define ADAFRUIT_MPR121_H 19 | 20 | #if (ARDUINO >= 100) 21 | #include "Arduino.h" 22 | #else 23 | #include "WProgram.h" 24 | #endif 25 | #include 26 | 27 | // The default I2C address 28 | #define MPR121_I2CADDR_DEFAULT 0x5A 29 | 30 | #define MPR121_TOUCHSTATUS_L 0x00 31 | #define MPR121_TOUCHSTATUS_H 0x01 32 | #define MPR121_FILTDATA_0L 0x04 33 | #define MPR121_FILTDATA_0H 0x05 34 | #define MPR121_BASELINE_0 0x1E 35 | #define MPR121_MHDR 0x2B 36 | #define MPR121_NHDR 0x2C 37 | #define MPR121_NCLR 0x2D 38 | #define MPR121_FDLR 0x2E 39 | #define MPR121_MHDF 0x2F 40 | #define MPR121_NHDF 0x30 41 | #define MPR121_NCLF 0x31 42 | #define MPR121_FDLF 0x32 43 | #define MPR121_NHDT 0x33 44 | #define MPR121_NCLT 0x34 45 | #define MPR121_FDLT 0x35 46 | 47 | #define MPR121_TOUCHTH_0 0x41 48 | #define MPR121_RELEASETH_0 0x42 49 | #define MPR121_DEBOUNCE 0x5B 50 | #define MPR121_CONFIG1 0x5C 51 | #define MPR121_CONFIG2 0x5D 52 | #define MPR121_CHARGECURR_0 0x5F 53 | #define MPR121_CHARGETIME_1 0x6C 54 | #define MPR121_ECR 0x5E 55 | #define MPR121_AUTOCONFIG0 0x7B 56 | #define MPR121_AUTOCONFIG1 0x7C 57 | #define MPR121_UPLIMIT 0x7D 58 | #define MPR121_LOWLIMIT 0x7E 59 | #define MPR121_TARGETLIMIT 0x7F 60 | 61 | #define MPR121_GPIODIR 0x76 62 | #define MPR121_GPIOEN 0x77 63 | #define MPR121_GPIOSET 0x78 64 | #define MPR121_GPIOCLR 0x79 65 | #define MPR121_GPIOTOGGLE 0x7A 66 | 67 | 68 | 69 | #define MPR121_SOFTRESET 0x80 70 | 71 | //.. thru to 0x1C/0x1D 72 | class Adafruit_MPR121 { 73 | public: 74 | // Hardware I2C 75 | Adafruit_MPR121(void); 76 | 77 | boolean begin(uint8_t i2caddr = MPR121_I2CADDR_DEFAULT); 78 | boolean isTouched(uint8_t touchpin); 79 | uint16_t filteredData(uint8_t t); 80 | uint16_t baselineData(uint8_t t); 81 | 82 | uint8_t readRegister8(uint8_t reg); 83 | uint16_t readRegister16(uint8_t reg); 84 | void writeRegister(uint8_t reg, uint8_t value); 85 | uint16_t touched(void); 86 | // Add deprecated attribute so that the compiler shows a warning 87 | __attribute__((deprecated)) void setThreshholds(uint8_t touch, uint8_t release); 88 | void setThresholds(uint8_t touch, uint8_t release); 89 | 90 | private: 91 | int8_t _i2caddr; 92 | }; 93 | 94 | // You can have up to 4 on one i2c bus but one is enough for testing! 95 | extern Adafruit_MPR121 touchPins; 96 | 97 | #endif // ADAFRUIT_MPR121_H 98 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/MPR121_Touch.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the MPR121 12-Channel Capacitive Sensor 3 | 4 | Designed specifically to work with the MPR121 breakout from Adafruit 5 | ----> https://www.adafruit.com/products/1982 6 | 7 | These sensors use I2C to communicate, 2+ pins are required to 8 | interface 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | BSD license, all text above must be included in any redistribution 15 | ****************************************************/ 16 | 17 | #ifndef ADAFRUIT_MPR121_H 18 | #define ADAFRUIT_MPR121_H 19 | 20 | #if (ARDUINO >= 100) 21 | #include "Arduino.h" 22 | #else 23 | #include "WProgram.h" 24 | #endif 25 | #include 26 | 27 | // The default I2C address 28 | #define MPR121_I2CADDR_DEFAULT 0x5A 29 | 30 | #define MPR121_TOUCHSTATUS_L 0x00 31 | #define MPR121_TOUCHSTATUS_H 0x01 32 | #define MPR121_FILTDATA_0L 0x04 33 | #define MPR121_FILTDATA_0H 0x05 34 | #define MPR121_BASELINE_0 0x1E 35 | #define MPR121_MHDR 0x2B 36 | #define MPR121_NHDR 0x2C 37 | #define MPR121_NCLR 0x2D 38 | #define MPR121_FDLR 0x2E 39 | #define MPR121_MHDF 0x2F 40 | #define MPR121_NHDF 0x30 41 | #define MPR121_NCLF 0x31 42 | #define MPR121_FDLF 0x32 43 | #define MPR121_NHDT 0x33 44 | #define MPR121_NCLT 0x34 45 | #define MPR121_FDLT 0x35 46 | 47 | #define MPR121_TOUCHTH_0 0x41 48 | #define MPR121_RELEASETH_0 0x42 49 | #define MPR121_DEBOUNCE 0x5B 50 | #define MPR121_CONFIG1 0x5C 51 | #define MPR121_CONFIG2 0x5D 52 | #define MPR121_CHARGECURR_0 0x5F 53 | #define MPR121_CHARGETIME_1 0x6C 54 | #define MPR121_ECR 0x5E 55 | #define MPR121_AUTOCONFIG0 0x7B 56 | #define MPR121_AUTOCONFIG1 0x7C 57 | #define MPR121_UPLIMIT 0x7D 58 | #define MPR121_LOWLIMIT 0x7E 59 | #define MPR121_TARGETLIMIT 0x7F 60 | 61 | #define MPR121_GPIODIR 0x76 62 | #define MPR121_GPIOEN 0x77 63 | #define MPR121_GPIOSET 0x78 64 | #define MPR121_GPIOCLR 0x79 65 | #define MPR121_GPIOTOGGLE 0x7A 66 | 67 | 68 | 69 | #define MPR121_SOFTRESET 0x80 70 | 71 | //.. thru to 0x1C/0x1D 72 | class Adafruit_MPR121 { 73 | public: 74 | // Hardware I2C 75 | Adafruit_MPR121(void); 76 | 77 | boolean begin(uint8_t i2caddr = MPR121_I2CADDR_DEFAULT); 78 | boolean isTouched(uint8_t touchpin); 79 | uint16_t filteredData(uint8_t t); 80 | uint16_t baselineData(uint8_t t); 81 | 82 | uint8_t readRegister8(uint8_t reg); 83 | uint16_t readRegister16(uint8_t reg); 84 | void writeRegister(uint8_t reg, uint8_t value); 85 | uint16_t touched(void); 86 | // Add deprecated attribute so that the compiler shows a warning 87 | __attribute__((deprecated)) void setThreshholds(uint8_t touch, uint8_t release); 88 | void setThresholds(uint8_t touch, uint8_t release); 89 | 90 | private: 91 | int8_t _i2caddr; 92 | }; 93 | 94 | // You can have up to 4 on one i2c bus but one is enough for testing! 95 | extern Adafruit_MPR121 touchPins; 96 | 97 | #endif // ADAFRUIT_MPR121_H 98 | -------------------------------------------------------------------------------- /src/Navkey.h: -------------------------------------------------------------------------------- 1 | /*Navkey.cpp contains function for joystick/5way navigation key to update 2 | global variables menuPress and menuMove (this are accesible to the user). 3 | It also include enabling/disenabling interrupt on center press of navkey (Pin 19) 4 | 5 | Copyright (C) 2018, Agilo Research 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see =SAMPLES) 105 | i=0; 106 | } 107 | 108 | void Plotter :: setRange(int range) 109 | { 110 | factor=range/60; 111 | } 112 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Plot.cpp: -------------------------------------------------------------------------------- 1 | /*Plot.cpp is a library for plotting any variable on TFT ST7735 (in evive) 2 | 3 | Copyright (C) 2018, Agilo Research 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see =SAMPLES) 105 | i=0; 106 | } 107 | 108 | void Plotter :: setRange(int range) 109 | { 110 | factor=range/60; 111 | } 112 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For evive 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | evive KEYWORD1 10 | tft KEYWORD1 11 | touchPins KEYWORD1 12 | 13 | 14 | ####################################### 15 | # Methods and Functions (KEYWORD2) 16 | ####################################### 17 | BAUDRATE KEYWORD2 18 | INITR_GREENTAB KEYWORD2 19 | INITR_REDTAB KEYWORD2 20 | INITR_GREENTAB2 KEYWORD2 21 | INITR_BLACKTAB KEYWORD2 22 | INITB KEYWORD2 23 | ST7735_BLACK KEYWORD2 24 | ST7735_NAVY KEYWORD2 25 | ST7735_DARKGREEN KEYWORD2 26 | ST7735_DARKCYAN KEYWORD2 27 | ST7735_MAROON KEYWORD2 28 | ST7735_PURPLE KEYWORD2 29 | ST7735_OLIVE KEYWORD2 30 | ST7735_LIGHTGREY KEYWORD2 31 | ST7735_DARKGREY KEYWORD2 32 | ST7735_BLUE KEYWORD2 33 | ST7735_GREEN KEYWORD2 34 | ST7735_CYAN KEYWORD2 35 | ST7735_RED KEYWORD2 36 | ST7735_MAGENTA KEYWORD2 37 | ST7735_YELLOW KEYWORD2 38 | ST7735_WHITE KEYWORD2 39 | ST7735_ORANGE KEYWORD2 40 | ST7735_GREENYELLOW KEYWORD2 41 | ST7735_PINK KEYWORD2 42 | drawPixel KEYWORD2 43 | drawChar KEYWORD2 44 | setAddrWindow KEYWORD2 45 | pushColor KEYWORD2 46 | pushColor KEYWORD2 47 | pushColors KEYWORD2 48 | pushColors KEYWORD2 49 | fillScreen KEYWORD2 50 | drawLine KEYWORD2 51 | drawFastVLine KEYWORD2 52 | drawFastHLine KEYWORD2 53 | drawRect KEYWORD2 54 | fillRect KEYWORD2 55 | drawRoundRect KEYWORD2 56 | fillRoundRect KEYWORD2 57 | setRotation KEYWORD2 58 | invertDisplay KEYWORD2 59 | drawCircle KEYWORD2 60 | drawCircleHelper KEYWORD2 61 | fillCircle KEYWORD2 62 | fillCircleHelper KEYWORD2 63 | drawEllipse KEYWORD2 64 | fillEllipse KEYWORD2 65 | drawTriangle KEYWORD2 66 | fillTriangle KEYWORD2 67 | drawBitmap KEYWORD2 68 | setTextColor KEYWORD2 69 | setTextColor KEYWORD2 70 | setTextSize KEYWORD2 71 | setTextFont KEYWORD2 72 | setTextWrap KEYWORD2 73 | setTextDatum KEYWORD2 74 | setTextPadding KEYWORD2 75 | tft_init KEYWORD2 76 | tft_update KEYWORD2 77 | action KEYWORD2 78 | drawStatusBar KEYWORD2 79 | eviveFirmware KEYWORD2 80 | isTouched KEYWORD2 81 | 82 | 83 | ################################ 84 | PINS 85 | ################################ 86 | TFT_RST LITERAL1 87 | TFT_CS LITERAL1 88 | TFT_DC LITERAL1 89 | SPI_MISO LITERAL1 90 | SPI_MOSI LITERAL1 91 | SPI_SCK LITERAL1 92 | SD_CS LITERAL1 93 | ADC_CS LITERAL1 94 | ADC_DREADY LITERAL1 95 | MOTOR1_D1 LITERAL1 96 | LED28 LITERAL1 97 | MOTOR1_D2 LITERAL1 98 | LED29 LITERAL1 99 | MOTOR1_EN LITERAL1 100 | MOTOR2_D1 LITERAL1 101 | LED30 LITERAL1 102 | MOTOR2_D2 LITERAL1 103 | LED31 LITERAL1 104 | MOTOR2_EN LITERAL1 105 | STEPPER_D1 LITERAL1 106 | STEPPER_D2 LITERAL1 107 | STEPPER_D3 LITERAL1 108 | STEPPER_D4 LITERAL1 109 | SERVO1_ATTACH LITERAL1 110 | SERVO2_ATTACH LITERAL1 111 | TACTILESW1 LITERAL1 112 | TACTILESW2 LITERAL1 113 | SLIDESW1_D1 LITERAL1 114 | SLIDESW1_D2 LITERAL1 115 | SLIDESW2_D1 LITERAL1 116 | SLIDESW2_D2 LITERAL1 117 | POT1 LITERAL1 118 | POT2 LITERAL1 119 | LEVELSHIFTER_DIR LITERAL1 120 | VINSUPPLYLEVEL LITERAL1 121 | VARSUPPLYLEVEL LITERAL1 122 | BATSUPPLYLEVEL LITERAL1 123 | NAVKEY_MOVE LITERAL1 124 | NAVKEY_PRESS LITERAL1 125 | LED13 LITERAL1 126 | TIMER LITERAL1 127 | BUZZER LITERAL1 128 | IO3V3_PIN1 LITERAL1 129 | IO3V3_PIN2 LITERAL1 -------------------------------------------------------------------------------- /examples/Intermediate/Buzzer/buzzerTest/buzzerTest.ino: -------------------------------------------------------------------------------- 1 | /* 2 | evive buzzer test code 3 | The Arduino's tone() command will play notes of a given frequency. 4 | We'll provide a function that takes in note characters (a-g), 5 | and returns the corresponding frequency from this table: 6 | 7 | note frequency 8 | c 262 Hz 9 | d 294 Hz 10 | e 330 Hz 11 | f 349 Hz 12 | g 392 Hz 13 | a 440 Hz 14 | b 494 Hz 15 | C 523 Hz 16 | Explore more: https://thestempedia.com/tutorials/piezo-buzzer/ 17 | */ 18 | 19 | const int buzzerPin = 46; 20 | 21 | // We'll set up an array with the notes we want to play 22 | // change these values to make different songs! 23 | 24 | // Length must equal the total number of notes and spaces 25 | 26 | const int songLength = 18; 27 | 28 | // Notes is an array of text characters corresponding to the notes 29 | // in your song. A space represents a rest (no tone) 30 | 31 | char notes[] = "abcCdef cdfdg gf "; // a space represents a rest 32 | 33 | // Beats is an array of values for each note and rest. 34 | // A "1" represents a quarter-note, 2 a half-note, etc. 35 | // Don't forget that the rests (spaces) need a length as well. 36 | 37 | int beats[] = {1, 1, 1, 1, 1, 1, 4, 4, 2, 1, 1, 1, 1, 1, 1, 4, 4, 2}; 38 | 39 | // The tempo is how fast to play the song. 40 | // To make the song play faster, decrease this value. 41 | 42 | int tempo = 113; 43 | #include 44 | void setup() 45 | { 46 | pinMode(buzzerPin, OUTPUT); 47 | } 48 | void loop() 49 | { 50 | int i, duration; 51 | 52 | for (i = 0; i < songLength; i++) // step through the song arrays 53 | { 54 | duration = beats[i] * tempo; // length of note/rest in ms 55 | 56 | if (notes[i] == ' ') // is this a rest? 57 | { 58 | delay(duration); // then pause for a moment 59 | } 60 | else // otherwise, play the note 61 | { 62 | tone(buzzerPin, frequency(notes[i]), duration); 63 | delay(duration); // wait for tone to finish 64 | } 65 | delay(tempo / 10); // brief pause between notes 66 | } 67 | 68 | // We only want to play the song once, so we'll pause forever: 69 | while (true) {} 70 | // If you'd like your song to play over and over, 71 | // remove the above statement 72 | } 73 | int frequency(char note) 74 | { 75 | // This function takes a note character (a-g), and returns the 76 | // corresponding frequency in Hz for the tone() function. 77 | 78 | int i; 79 | const int numNotes = 8; // number of notes we're storing 80 | 81 | // The following arrays hold the note characters and their 82 | // corresponding frequencies. The last "C" note is uppercase 83 | // to separate it from the first lowercase "c". If you want to 84 | // add more notes, you'll need to use unique characters. 85 | 86 | // For the "char" (character) type, we put single characters 87 | // in single quotes. 88 | 89 | char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' }; 90 | int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523}; 91 | 92 | // Now we'll search through the letters in the array, and if 93 | // we find it, we'll return the frequency for that note. 94 | 95 | for (i = 0; i < numNotes; i++) // Step through the notes 96 | { 97 | if (names[i] == note) // Is this the one? 98 | { 99 | return (frequencies[i]); // Yes! Return the frequency 100 | } 101 | } 102 | return (0); // We looked through everything and didn't find it, 103 | // but we still need to return a value, so return 0. 104 | } 105 | 106 | 107 | -------------------------------------------------------------------------------- /src/TFT_User_Setup.h: -------------------------------------------------------------------------------- 1 | // USER DEFINED SETTINGS V16 2 | // Set fonts to be loaded, pins used and SPI control method 3 | 4 | // Define the type of display from the colour of the tab on the screen protector 5 | // Comment out all but one of these options 6 | 7 | //#define TAB_COLOUR INITB 8 | //#define TAB_COLOUR INITR_GREENTAB 9 | //#define TAB_COLOUR INITR_REDTAB 10 | #define TAB_COLOUR INITR_BLACKTAB 11 | //#define TAB_COLOUR INITR_GREENTAB2 12 | 13 | // ################################################################################## 14 | // 15 | // Define the pins that are used to interface with the display here 16 | // 17 | // ################################################################################## 18 | 19 | // We must use hardware SPI 20 | // FYI Mega SCK is pin 52, MOSI is 51, UNO/NanoPro micro etc SCK is pin 13 and MOSI is 11 21 | // Leonardo Pro micro SCK is pin 15 and MOSI is 16 22 | 23 | // ###### EDIT THE PIN NUMBERS IN THE 3 LINES FOLLOWING TO SUIT YOUR SETUP ###### 24 | 25 | #define TFT_CS 48 // Chip select control pin 26 | #define TFT_DC 49 // Data Command control pin 27 | #define TFT_RST 47 // Reset pin (could connect to Arduino RESET pin) 28 | 29 | 30 | // ################################################################################## 31 | // 32 | // Define the fonts that are to be used here 33 | // 34 | // ################################################################################## 35 | 36 | // Comment out the #defines below with // to stop that font being loaded 37 | // As supplied font 8 is disabled by commenting out 38 | // 39 | // If all fonts are loaded the extra FLASH space required is about 17000 bytes... 40 | // To save FLASH space only enable the fonts you need! 41 | 42 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 43 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 44 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 45 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 46 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 47 | //#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 48 | 49 | 50 | // ################################################################################## 51 | // 52 | // Define whether we want to use delays or SPIF flag to control SPI transactions 53 | // 54 | // ################################################################################## 55 | 56 | // If we define F_AS_T here then delays are used between SPI transactions 57 | // to speed up rendering, comment out to "wait" for the SPIF flag instead 58 | // Commenting out the line stops use of FastPin for control lines 59 | 60 | // BUG AWAITING FIX - DO NOT COMMENT OUT IN THIS VERSION 61 | #define F_AS_T 62 | 63 | 64 | // ################################################################################## 65 | // 66 | // Other speed up options 67 | // 68 | // ################################################################################## 69 | 70 | // Uncomment the following #define to invoke a 20% faster drawLine() function 71 | // This speeds up other funtions such as triangle outline drawing too 72 | // Code size penalty is about 72 bytes 73 | 74 | #define FAST_LINE 75 | 76 | // Comment out the following #define to stop boundary checking and clipping 77 | // for fillRectangle()and fastH/V lines. This speeds up other funtions such as text 78 | // rendering where size>1. Sketch then must not draw graphics/text outside screen 79 | // boundary. Code saving for no bounds check (i.e. commented out) is 316 bytes 80 | 81 | //#define CLIP_CHECK 82 | 83 | // Comment out the following #define if "SPI Transactions" do not need to be 84 | // supported. Tranaction support is required if other SPI devices use interrupts. 85 | // When commented out the code size will be ~700 bytes smaller and sketches will 86 | // run slightly faster, so leave it commented out unless you need it! 87 | // Transaction support is needed to work with SD libraru but not needed with TFT_SdFat 88 | 89 | // #define SUPPORT_TRANSACTIONS 90 | 91 | -------------------------------------------------------------------------------- /src/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For evive 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | evive KEYWORD1 10 | tft KEYWORD1 11 | touchPins KEYWORD1 12 | Rtc_Pcf8563 KEYWORD1 13 | 14 | ####################################### 15 | # Methods and Functions (KEYWORD2) 16 | ####################################### 17 | BAUDRATE KEYWORD2 18 | INITR_GREENTAB KEYWORD2 19 | INITR_REDTAB KEYWORD2 20 | INITR_GREENTAB2 KEYWORD2 21 | INITR_BLACKTAB KEYWORD2 22 | INITB KEYWORD2 23 | ST7735_BLACK KEYWORD2 24 | ST7735_NAVY KEYWORD2 25 | ST7735_DARKGREEN KEYWORD2 26 | ST7735_DARKCYAN KEYWORD2 27 | ST7735_MAROON KEYWORD2 28 | ST7735_PURPLE KEYWORD2 29 | ST7735_OLIVE KEYWORD2 30 | ST7735_LIGHTGREY KEYWORD2 31 | ST7735_DARKGREY KEYWORD2 32 | ST7735_BLUE KEYWORD2 33 | ST7735_GREEN KEYWORD2 34 | ST7735_CYAN KEYWORD2 35 | ST7735_RED KEYWORD2 36 | ST7735_MAGENTA KEYWORD2 37 | ST7735_YELLOW KEYWORD2 38 | ST7735_WHITE KEYWORD2 39 | ST7735_ORANGE KEYWORD2 40 | ST7735_GREENYELLOW KEYWORD2 41 | ST7735_PINK KEYWORD2 42 | drawPixel KEYWORD2 43 | drawChar KEYWORD2 44 | setAddrWindow KEYWORD2 45 | pushColor KEYWORD2 46 | pushColor KEYWORD2 47 | pushColors KEYWORD2 48 | pushColors KEYWORD2 49 | fillScreen KEYWORD2 50 | drawLine KEYWORD2 51 | drawFastVLine KEYWORD2 52 | drawFastHLine KEYWORD2 53 | drawRect KEYWORD2 54 | fillRect KEYWORD2 55 | drawRoundRect KEYWORD2 56 | fillRoundRect KEYWORD2 57 | setRotation KEYWORD2 58 | invertDisplay KEYWORD2 59 | drawCircle KEYWORD2 60 | drawCircleHelper KEYWORD2 61 | fillCircle KEYWORD2 62 | fillCircleHelper KEYWORD2 63 | drawEllipse KEYWORD2 64 | fillEllipse KEYWORD2 65 | drawTriangle KEYWORD2 66 | fillTriangle KEYWORD2 67 | drawBitmap KEYWORD2 68 | setTextColor KEYWORD2 69 | setTextColor KEYWORD2 70 | setTextSize KEYWORD2 71 | setTextFont KEYWORD2 72 | setTextWrap KEYWORD2 73 | setTextDatum KEYWORD2 74 | setTextPadding KEYWORD2 75 | tft_init KEYWORD2 76 | tft_update KEYWORD2 77 | action KEYWORD2 78 | drawStatusBar KEYWORD2 79 | eviveFirmware KEYWORD2 80 | isTouched KEYWORD2 81 | initClock KEYWORD2 82 | clearStatus KEYWORD2 83 | getDate KEYWORD2 84 | setDate KEYWORD2 85 | getTime KEYWORD2 86 | setTime KEYWORD2 87 | setAlarm KEYWORD2 88 | clearAlarm KEYWORD2 89 | getStatus1 KEYWORD2 90 | getStatus2 KEYWORD2 91 | getSecond KEYWORD2 92 | getMinute KEYWORD2 93 | getHour KEYWORD2 94 | getDay KEYWORD2 95 | getWeekDay KEYWORD2 96 | getMonth KEYWORD2 97 | getYear KEYWORD2 98 | formatTime KEYWORD2 99 | formatDate KEYWORD2 100 | alarmEnabled KEYWORD2 101 | alarmActive KEYWORD2 102 | enableAlarm KEYWORD2 103 | resetAlarm KEYWORD2 104 | setSquareWave KEYWORD2 105 | clearSquareWave KEYWORD2 106 | getAlarmMinute KEYWORD2 107 | getAlarmHour KEYWORD2 108 | getAlarmDay KEYWORD2 109 | getAlarmWeekday KEYWORD2 110 | version KEYWORD2 111 | 112 | 113 | 114 | ################################ 115 | PINS 116 | ################################ 117 | TFT_RST LITERAL1 118 | TFT_CS LITERAL1 119 | TFT_DC LITERAL1 120 | SPI_MISO LITERAL1 121 | SPI_MOSI LITERAL1 122 | SPI_SCK LITERAL1 123 | SD_CS LITERAL1 124 | ADC_CS LITERAL1 125 | ADC_DREADY LITERAL1 126 | MOTOR1_D1 LITERAL1 127 | LED28 LITERAL1 128 | MOTOR1_D2 LITERAL1 129 | LED29 LITERAL1 130 | MOTOR1_EN LITERAL1 131 | MOTOR2_D1 LITERAL1 132 | LED30 LITERAL1 133 | MOTOR2_D2 LITERAL1 134 | LED31 LITERAL1 135 | MOTOR2_EN LITERAL1 136 | STEPPER_D1 LITERAL1 137 | STEPPER_D2 LITERAL1 138 | STEPPER_D3 LITERAL1 139 | STEPPER_D4 LITERAL1 140 | SERVO1_ATTACH LITERAL1 141 | SERVO2_ATTACH LITERAL1 142 | TACTILESW1 LITERAL1 143 | TACTILESW2 LITERAL1 144 | SLIDESW1_D1 LITERAL1 145 | SLIDESW1_D2 LITERAL1 146 | SLIDESW2_D1 LITERAL1 147 | SLIDESW2_D2 LITERAL1 148 | POT1 LITERAL1 149 | POT2 LITERAL1 150 | LEVELSHIFTER_DIR LITERAL1 151 | VINSUPPLYLEVEL LITERAL1 152 | VARSUPPLYLEVEL LITERAL1 153 | BATSUPPLYLEVEL LITERAL1 154 | NAVKEY_MOVE LITERAL1 155 | NAVKEY_PRESS LITERAL1 156 | LED13 LITERAL1 157 | TIMER LITERAL1 158 | BUZZER LITERAL1 159 | IO3V3_PIN1 LITERAL1 160 | IO3V3_PIN2 LITERAL1 -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/TFT_User_Setup.h: -------------------------------------------------------------------------------- 1 | // USER DEFINED SETTINGS V16 2 | // Set fonts to be loaded, pins used and SPI control method 3 | 4 | // Define the type of display from the colour of the tab on the screen protector 5 | // Comment out all but one of these options 6 | 7 | //#define TAB_COLOUR INITB 8 | //#define TAB_COLOUR INITR_GREENTAB 9 | //#define TAB_COLOUR INITR_REDTAB 10 | #define TAB_COLOUR INITR_BLACKTAB 11 | //#define TAB_COLOUR INITR_GREENTAB2 12 | 13 | // ################################################################################## 14 | // 15 | // Define the pins that are used to interface with the display here 16 | // 17 | // ################################################################################## 18 | 19 | // We must use hardware SPI 20 | // FYI Mega SCK is pin 52, MOSI is 51, UNO/NanoPro micro etc SCK is pin 13 and MOSI is 11 21 | // Leonardo Pro micro SCK is pin 15 and MOSI is 16 22 | 23 | // ###### EDIT THE PIN NUMBERS IN THE 3 LINES FOLLOWING TO SUIT YOUR SETUP ###### 24 | 25 | #define TFT_CS 48 // Chip select control pin 26 | #define TFT_DC 49 // Data Command control pin 27 | #define TFT_RST 47 // Reset pin (could connect to Arduino RESET pin) 28 | 29 | 30 | // ################################################################################## 31 | // 32 | // Define the fonts that are to be used here 33 | // 34 | // ################################################################################## 35 | 36 | // Comment out the #defines below with // to stop that font being loaded 37 | // As supplied font 8 is disabled by commenting out 38 | // 39 | // If all fonts are loaded the extra FLASH space required is about 17000 bytes... 40 | // To save FLASH space only enable the fonts you need! 41 | 42 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 43 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 44 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 45 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 46 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 47 | //#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 48 | 49 | 50 | // ################################################################################## 51 | // 52 | // Define whether we want to use delays or SPIF flag to control SPI transactions 53 | // 54 | // ################################################################################## 55 | 56 | // If we define F_AS_T here then delays are used between SPI transactions 57 | // to speed up rendering, comment out to "wait" for the SPIF flag instead 58 | // Commenting out the line stops use of FastPin for control lines 59 | 60 | // BUG AWAITING FIX - DO NOT COMMENT OUT IN THIS VERSION 61 | #define F_AS_T 62 | 63 | 64 | // ################################################################################## 65 | // 66 | // Other speed up options 67 | // 68 | // ################################################################################## 69 | 70 | // Uncomment the following #define to invoke a 20% faster drawLine() function 71 | // This speeds up other funtions such as triangle outline drawing too 72 | // Code size penalty is about 72 bytes 73 | 74 | #define FAST_LINE 75 | 76 | // Comment out the following #define to stop boundary checking and clipping 77 | // for fillRectangle()and fastH/V lines. This speeds up other funtions such as text 78 | // rendering where size>1. Sketch then must not draw graphics/text outside screen 79 | // boundary. Code saving for no bounds check (i.e. commented out) is 316 bytes 80 | 81 | //#define CLIP_CHECK 82 | 83 | // Comment out the following #define if "SPI Transactions" do not need to be 84 | // supported. Tranaction support is required if other SPI devices use interrupts. 85 | // When commented out the code size will be ~700 bytes smaller and sketches will 86 | // run slightly faster, so leave it commented out unless you need it! 87 | // Transaction support is needed to work with SD libraru but not needed with TFT_SdFat 88 | 89 | // #define SUPPORT_TRANSACTIONS 90 | 91 | -------------------------------------------------------------------------------- /src/Action.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * action.cpp 3 | * Action library is a framework to add multiple functions in Arduino 4 | * loop via callback functions of menu (including user defined programs) 5 | * and running multiple function in background. An array actionFuncList 6 | * stores the pointer of function(s) to be executed in Arduino loop everytime. 7 | * actionFuncList is a pointer to a function. 8 | * 9 | * This is licensed under GNU GPL V3 [http://www.gnu.org/licenses/gpl.txt]. 10 | * Written by Dhrupal R Shah for evive platform, Agilo Research. 11 | * Contact: support@evive.cc 12 | * Copyright (c) 2017 Agilo Research. All rights reserved. 13 | * 14 | * This program is free software: you can redistribute it and/or modify 15 | * it under the terms of the GNU General Public License as published by 16 | * the Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | * GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License 25 | * along with this program. If not, see https://www.adafruit.com/products/1982 6 | 7 | These sensors use I2C to communicate, 2+ pins are required to 8 | interface 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | BSD license, all text above must be included in any redistribution 15 | ****************************************************/ 16 | 17 | #include "MPR121_Touch.h" 18 | 19 | Adafruit_MPR121::Adafruit_MPR121() { 20 | } 21 | 22 | boolean Adafruit_MPR121::begin(uint8_t i2caddr) { 23 | Wire.begin(); 24 | 25 | _i2caddr = i2caddr; 26 | 27 | // soft reset 28 | writeRegister(MPR121_SOFTRESET, 0x63); 29 | delay(1); 30 | for (uint8_t i=0; i<0x7F; i++) { 31 | // Serial.print("$"); Serial.print(i, HEX); 32 | // Serial.print(": 0x"); Serial.println(readRegister8(i)); 33 | } 34 | 35 | 36 | writeRegister(MPR121_ECR, 0x0); 37 | 38 | uint8_t c = readRegister8(MPR121_CONFIG2); 39 | 40 | if (c != 0x24) return false; 41 | 42 | 43 | setThreshholds(12, 6); 44 | writeRegister(MPR121_MHDR, 0x01); 45 | writeRegister(MPR121_NHDR, 0x01); 46 | writeRegister(MPR121_NCLR, 0x0E); 47 | writeRegister(MPR121_FDLR, 0x00); 48 | 49 | writeRegister(MPR121_MHDF, 0x01); 50 | writeRegister(MPR121_NHDF, 0x05); 51 | writeRegister(MPR121_NCLF, 0x01); 52 | writeRegister(MPR121_FDLF, 0x00); 53 | 54 | writeRegister(MPR121_NHDT, 0x00); 55 | writeRegister(MPR121_NCLT, 0x00); 56 | writeRegister(MPR121_FDLT, 0x00); 57 | 58 | writeRegister(MPR121_DEBOUNCE, 0); 59 | writeRegister(MPR121_CONFIG1, 0x10); // default, 16uA charge current 60 | writeRegister(MPR121_CONFIG2, 0x20); // 0.5uS encoding, 1ms period 61 | 62 | // writeRegister(MPR121_AUTOCONFIG0, 0x8F); 63 | 64 | // writeRegister(MPR121_UPLIMIT, 150); 65 | // writeRegister(MPR121_TARGETLIMIT, 100); // should be ~400 (100 shifted) 66 | // writeRegister(MPR121_LOWLIMIT, 50); 67 | // enable all electrodes 68 | writeRegister(MPR121_ECR, 0x8F); // start with first 5 bits of baseline tracking 69 | 70 | return true; 71 | } 72 | 73 | void Adafruit_MPR121::setThreshholds(uint8_t touch, uint8_t release) { 74 | 75 | setThresholds(touch, release); 76 | } 77 | 78 | void Adafruit_MPR121::setThresholds(uint8_t touch, uint8_t release) { 79 | for (uint8_t i=0; i<12; i++) { 80 | writeRegister(MPR121_TOUCHTH_0 + 2*i, touch); 81 | writeRegister(MPR121_RELEASETH_0 + 2*i, release); 82 | } 83 | } 84 | 85 | uint16_t Adafruit_MPR121::filteredData(uint8_t t) { 86 | if (t > 12) return 0; 87 | return readRegister16(MPR121_FILTDATA_0L + t*2); 88 | } 89 | 90 | uint16_t Adafruit_MPR121::baselineData(uint8_t t) { 91 | if (t > 12) return 0; 92 | uint16_t bl = readRegister8(MPR121_BASELINE_0 + t); 93 | return (bl << 2); 94 | } 95 | 96 | uint16_t Adafruit_MPR121::touched(void) { 97 | uint16_t t = readRegister16(MPR121_TOUCHSTATUS_L); 98 | return t & 0x0FFF; 99 | } 100 | 101 | /*********************************************************************/ 102 | 103 | 104 | uint8_t Adafruit_MPR121::readRegister8(uint8_t reg) { 105 | Wire.beginTransmission(_i2caddr); 106 | Wire.write(reg); 107 | Wire.endTransmission(false); 108 | while (Wire.requestFrom(_i2caddr, 1) != 1); 109 | return ( Wire.read()); 110 | } 111 | 112 | uint16_t Adafruit_MPR121::readRegister16(uint8_t reg) { 113 | Wire.beginTransmission(_i2caddr); 114 | Wire.write(reg); 115 | Wire.endTransmission(false); 116 | while (Wire.requestFrom(_i2caddr, 2) != 2); 117 | uint16_t v = Wire.read(); 118 | v |= ((uint16_t) Wire.read()) << 8; 119 | return v; 120 | } 121 | 122 | /**************************************************************************/ 123 | /*! 124 | @brief Writes 8-bits to the specified destination register 125 | */ 126 | /**************************************************************************/ 127 | void Adafruit_MPR121::writeRegister(uint8_t reg, uint8_t value) { 128 | Wire.beginTransmission(_i2caddr); 129 | Wire.write((uint8_t)reg); 130 | Wire.write((uint8_t)(value)); 131 | Wire.endTransmission(); 132 | } 133 | Adafruit_MPR121 touchPins = Adafruit_MPR121(); 134 | 135 | boolean Adafruit_MPR121::isTouched(uint8_t touchpin) 136 | { 137 | return touchPins.touched()& _BV(touchpin-1) ; 138 | } 139 | 140 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/MPR121_Touch.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the MPR121 I2C 12-chan Capacitive Sensor 3 | 4 | Designed specifically to work with the MPR121 sensor from Adafruit 5 | ----> https://www.adafruit.com/products/1982 6 | 7 | These sensors use I2C to communicate, 2+ pins are required to 8 | interface 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | BSD license, all text above must be included in any redistribution 15 | ****************************************************/ 16 | 17 | #include "MPR121_Touch.h" 18 | 19 | Adafruit_MPR121::Adafruit_MPR121() { 20 | } 21 | 22 | boolean Adafruit_MPR121::begin(uint8_t i2caddr) { 23 | Wire.begin(); 24 | 25 | _i2caddr = i2caddr; 26 | 27 | // soft reset 28 | writeRegister(MPR121_SOFTRESET, 0x63); 29 | delay(1); 30 | for (uint8_t i=0; i<0x7F; i++) { 31 | // Serial.print("$"); Serial.print(i, HEX); 32 | // Serial.print(": 0x"); Serial.println(readRegister8(i)); 33 | } 34 | 35 | 36 | writeRegister(MPR121_ECR, 0x0); 37 | 38 | uint8_t c = readRegister8(MPR121_CONFIG2); 39 | 40 | if (c != 0x24) return false; 41 | 42 | 43 | setThreshholds(12, 6); 44 | writeRegister(MPR121_MHDR, 0x01); 45 | writeRegister(MPR121_NHDR, 0x01); 46 | writeRegister(MPR121_NCLR, 0x0E); 47 | writeRegister(MPR121_FDLR, 0x00); 48 | 49 | writeRegister(MPR121_MHDF, 0x01); 50 | writeRegister(MPR121_NHDF, 0x05); 51 | writeRegister(MPR121_NCLF, 0x01); 52 | writeRegister(MPR121_FDLF, 0x00); 53 | 54 | writeRegister(MPR121_NHDT, 0x00); 55 | writeRegister(MPR121_NCLT, 0x00); 56 | writeRegister(MPR121_FDLT, 0x00); 57 | 58 | writeRegister(MPR121_DEBOUNCE, 0); 59 | writeRegister(MPR121_CONFIG1, 0x10); // default, 16uA charge current 60 | writeRegister(MPR121_CONFIG2, 0x20); // 0.5uS encoding, 1ms period 61 | 62 | // writeRegister(MPR121_AUTOCONFIG0, 0x8F); 63 | 64 | // writeRegister(MPR121_UPLIMIT, 150); 65 | // writeRegister(MPR121_TARGETLIMIT, 100); // should be ~400 (100 shifted) 66 | // writeRegister(MPR121_LOWLIMIT, 50); 67 | // enable all electrodes 68 | writeRegister(MPR121_ECR, 0x8F); // start with first 5 bits of baseline tracking 69 | 70 | return true; 71 | } 72 | 73 | void Adafruit_MPR121::setThreshholds(uint8_t touch, uint8_t release) { 74 | 75 | setThresholds(touch, release); 76 | } 77 | 78 | void Adafruit_MPR121::setThresholds(uint8_t touch, uint8_t release) { 79 | for (uint8_t i=0; i<12; i++) { 80 | writeRegister(MPR121_TOUCHTH_0 + 2*i, touch); 81 | writeRegister(MPR121_RELEASETH_0 + 2*i, release); 82 | } 83 | } 84 | 85 | uint16_t Adafruit_MPR121::filteredData(uint8_t t) { 86 | if (t > 12) return 0; 87 | return readRegister16(MPR121_FILTDATA_0L + t*2); 88 | } 89 | 90 | uint16_t Adafruit_MPR121::baselineData(uint8_t t) { 91 | if (t > 12) return 0; 92 | uint16_t bl = readRegister8(MPR121_BASELINE_0 + t); 93 | return (bl << 2); 94 | } 95 | 96 | uint16_t Adafruit_MPR121::touched(void) { 97 | uint16_t t = readRegister16(MPR121_TOUCHSTATUS_L); 98 | return t & 0x0FFF; 99 | } 100 | 101 | /*********************************************************************/ 102 | 103 | 104 | uint8_t Adafruit_MPR121::readRegister8(uint8_t reg) { 105 | Wire.beginTransmission(_i2caddr); 106 | Wire.write(reg); 107 | Wire.endTransmission(false); 108 | while (Wire.requestFrom(_i2caddr, 1) != 1); 109 | return ( Wire.read()); 110 | } 111 | 112 | uint16_t Adafruit_MPR121::readRegister16(uint8_t reg) { 113 | Wire.beginTransmission(_i2caddr); 114 | Wire.write(reg); 115 | Wire.endTransmission(false); 116 | while (Wire.requestFrom(_i2caddr, 2) != 2); 117 | uint16_t v = Wire.read(); 118 | v |= ((uint16_t) Wire.read()) << 8; 119 | return v; 120 | } 121 | 122 | /**************************************************************************/ 123 | /*! 124 | @brief Writes 8-bits to the specified destination register 125 | */ 126 | /**************************************************************************/ 127 | void Adafruit_MPR121::writeRegister(uint8_t reg, uint8_t value) { 128 | Wire.beginTransmission(_i2caddr); 129 | Wire.write((uint8_t)reg); 130 | Wire.write((uint8_t)(value)); 131 | Wire.endTransmission(); 132 | } 133 | Adafruit_MPR121 touchPins = Adafruit_MPR121(); 134 | 135 | boolean Adafruit_MPR121::isTouched(uint8_t touchpin) 136 | { 137 | return touchPins.touched()& _BV(touchpin-1) ; 138 | } 139 | 140 | -------------------------------------------------------------------------------- /src/Rtc_Pcf8563.h: -------------------------------------------------------------------------------- 1 | /***** 2 | * NAME 3 | * External Real Time Clock support routines 4 | * AUTHOR 5 | * Joe Robertson, jmr 6 | * orbitalair@bellsouth.net 7 | * http://orbitalair.wikispaces.com/Arduino 8 | * CREATION DATE 9 | * 1/2/10, init - built off of pic rtc code 10 | * NOTES 11 | * HISTORY 12 | * 1/2/10 ported to arduino compiler, jmr 13 | * 2/14/10 added 3 world date formats, jmr 14 | * 28/02/2012 A. Pasotti 15 | * fixed a bug in RTCC_ALARM_AF, 16 | * added a few (not really useful) methods 17 | * 12/26/12 added version method to be able to track builds. jmr 18 | * fix for arduino 1.0.1. Wire. 19 | * TODO 20 | * 21 | ****** 22 | * Robodoc embedded documentation. 23 | * http://www.xs4all.nl/~rfsber/Robo/robodoc.html 24 | */ 25 | 26 | #ifndef Rtc_Pcf8563_H 27 | #define Rtc_Pcf8563_H 28 | 29 | #include "Arduino.h" 30 | #include "Wire.h" 31 | 32 | #define RTCC_VERSION "Pcf8563 v1.0.1" 33 | 34 | /* the read and write values for pcf8563 rtcc */ 35 | /* these are adjusted for arduino */ 36 | #define RTCC_R 0xa3 37 | #define RTCC_W 0xa2 38 | 39 | #define RTCC_SEC 1 40 | #define RTCC_MIN 2 41 | #define RTCC_HR 3 42 | #define RTCC_DAY 4 43 | #define RTCC_WEEKDAY 5 44 | #define RTCC_MONTH 6 45 | #define RTCC_YEAR 7 46 | #define RTCC_CENTURY 8 47 | 48 | /* register addresses in the rtc */ 49 | #define RTCC_STAT1_ADDR 0x0 50 | #define RTCC_STAT2_ADDR 0x01 51 | #define RTCC_SEC_ADDR 0x02 52 | #define RTCC_MIN_ADDR 0x03 53 | #define RTCC_HR_ADDR 0x04 54 | #define RTCC_DAY_ADDR 0x05 55 | #define RTCC_WEEKDAY_ADDR 0x06 56 | #define RTCC_MONTH_ADDR 0x07 57 | #define RTCC_YEAR_ADDR 0x08 58 | #define RTCC_ALRM_MIN_ADDR 0x09 59 | #define RTCC_SQW_ADDR 0x0D 60 | 61 | /* setting the alarm flag to 0 enables the alarm. 62 | * set it to 1 to disable the alarm for that value. 63 | */ 64 | #define RTCC_ALARM 0x80 65 | #define RTCC_ALARM_AIE 0x02 66 | #define RTCC_ALARM_AF 0x08 // 0x08 : not 0x04!!!! 67 | /* optional val for no alarm setting */ 68 | #define RTCC_NO_ALARM 99 69 | 70 | #define RTCC_CENTURY_MASK 0x80 71 | 72 | /* date format flags */ 73 | #define RTCC_DATE_WORLD 0x01 74 | #define RTCC_DATE_ASIA 0x02 75 | #define RTCC_DATE_US 0x04 76 | /* time format flags */ 77 | #define RTCC_TIME_HMS 0x01 78 | #define RTCC_TIME_HM 0x02 79 | 80 | /* square wave contants */ 81 | #define SQW_DISABLE B00000000 82 | #define SQW_32KHZ B10000000 83 | #define SQW_1024HZ B10000001 84 | #define SQW_32HZ B10000010 85 | #define SQW_1HZ B10000011 86 | 87 | 88 | /* arduino class */ 89 | class Rtc_Pcf8563 { 90 | public: 91 | Rtc_Pcf8563(); 92 | 93 | void initClock(); /* zero out all values, disable all alarms */ 94 | void clearStatus(); /* set both status bytes to zero */ 95 | 96 | void getDate(); /* get date vals to local vars */ 97 | void setDate(byte day, byte weekday, byte month, byte century, byte year); 98 | void getTime(); /* get time vars + 2 status bytes to local vars */ 99 | void getAlarm(); 100 | void setTime(byte sec, byte minute, byte hour); 101 | byte readStatus2(); 102 | boolean alarmEnabled(); 103 | boolean alarmActive(); 104 | 105 | void enableAlarm(); /* activate alarm flag and interrupt */ 106 | void setAlarm(byte min, byte hour, byte day, byte weekday); /* set alarm vals, 99=ignore */ 107 | void clearAlarm(); /* clear alarm flag and interrupt */ 108 | void resetAlarm(); /* clear alarm flag but leave interrupt unchanged */ 109 | void setSquareWave(byte frequency); 110 | void clearSquareWave(); 111 | 112 | byte getSecond(); 113 | byte getMinute(); 114 | byte getHour(); 115 | byte getDay(); 116 | byte getMonth(); 117 | byte getYear(); 118 | byte getWeekday(); 119 | byte getStatus1(); 120 | byte getStatus2(); 121 | 122 | byte getAlarmMinute(); 123 | byte getAlarmHour(); 124 | byte getAlarmDay(); 125 | byte getAlarmWeekday(); 126 | 127 | /*get a output string, these call getTime/getDate for latest vals */ 128 | char *formatTime(byte style=RTCC_TIME_HMS); 129 | /* date supports 3 styles as listed in the wikipedia page about world date/time. */ 130 | char *formatDate(byte style=RTCC_DATE_US); 131 | 132 | char *version(); 133 | 134 | private: 135 | /* methods */ 136 | byte decToBcd(byte value); 137 | byte bcdToDec(byte value); 138 | /* time variables */ 139 | byte hour; 140 | byte minute; 141 | byte sec; 142 | byte day; 143 | byte weekday; 144 | byte month; 145 | byte year; 146 | /* alarm */ 147 | byte alarm_hour; 148 | byte alarm_minute; 149 | byte alarm_weekday; 150 | byte alarm_day; 151 | /* support */ 152 | byte status1; 153 | byte status2; 154 | byte century; 155 | 156 | char strOut[9]; 157 | char strDate[11]; 158 | 159 | int Rtcc_Addr; 160 | }; 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /src/ReadMe.md: -------------------------------------------------------------------------------- 1 | # evive Firmware version 1.0.0 2 | This firmware is developed for evive. It enables the menu based visual interface for Arduino programs. A brief description of firmware menu options is stated below: 3 | 4 | 1) Control Menu: evive includes hardware interaction and plug & play interface, which can be used to control many basic utilities like controlling motors, servos, stepper, relays, solenoid valves for pneumatics using tactile switches slide switches and potentiometers. Also the user can use the inbuilt hardware (switches and potentiometers) to change/define the states of Digital I/O Pins or PWM output. Switches and potentiometers are internally connected to Arduino MEGA pins as control inputs and motor drivers are connected for output at plug & play interface. The state or values are displayed on screen 5 | 6 | 2) Sensing: evive can be used as a voltmeter or an ammeter. It uses a very accurate 24-bit dual channel ADC IC for sensing from Analog Devices (ADE7912). There are two channels for data acquisition namely Probe I/V and Probe V. The Probe I/V can be used to sense currents or voltage as per the Jumper selection. The current sensing has accuracy of 3mA with range of -3A to +3A, while in voltage mode, the accuracy is of 3mV with range of -5V to +5V. The Probe V can be used for higher voltage sensing in range of -30V to +30V with accuracy of 10mV. 7 | 8 | 3) Serial Monitor: Serial Monitor appears in one of the menu item of evive. It asks the user to select the serial and also allows users to set the baud rate at which they want to open the serial port. It then, reads and displays the data coming from the selected serial at specified baud rate by the user. With Serial Monitor it is also possible to display the multiple serial data displaying simultaneously on the screen of evive. Different Serial data are displayed in different colors i.e. Serial 1 with White ;Serial 2 with Magenta ; Serial 3 with Blue. It is an essential tool for debug. 9 | 10 | 4) Mini Oscilloscope: Visualize voltage and currents on evive using either banana jacks or jumper wires. Is has lots of function like scaling voltage level, time scaling to see the reading in better way, trigger to start the measurement at some set value, scanning modes like single or continuous, offset, save readings to SD card and send data to computer. It uses a very accurate 24-bit dual channel ADC IC for sensing from Analog Devices (ADE7912). There are two channels for data acquisition namely Probe I/V and Probe V. The Probe I/V can be used to sense currents or voltage as per the Jumper selection. The maximum sensing frequency is about 1kHz. The current sensing has accuracy of 3mA with range of -3A to +3A, while in voltage mode, the accuracy is of 3mV with range of -5V to +5V. The Probe V can be used for higher voltage sensing in range of -30V to +30V with accuracy of 10mV. Have a look at: https://www.youtube.com/watch?v=KHnaoqdOgPY&index=5&list=PLKsEDqUnyShrW8RfqVAjHGHCjeYfb7TwI 11 | 12 | 5) Arduino Pin State Monitor: Pin State monitor is included in the evive menu. It shows the state of all the digital and analog pins of evive. It shows output as high(1) or low(0) for digital pins and analog value for analog pins. The pins are displayed in tabular form on the evive screen. There are 40 digital pins in evive and 16 analog pins. Different colors are used to show the pin no. and its respective output. 13 | 14 | 6) Beta Function Generator: evive has a built-in 12-bit DAC using IC MCP4725 (IIC Address 0x60 or 0x62). It is controlled using IIC (or I2C) commands using Arduino MEGA with output range of 0 to 5V. Many inbuilt function to generate waves like sine, square, triangular or saw-tooth shapes are provided with option to control amplitude between 0 to 5V and frequency upto few hundred hertz. It’s limited to 8.5Hz ~ 500Hz. The user can set the desired output voltage and the desired frequency using potentiometer knobs. 15 | 16 | 7) Touch: evive has 12 touch inputs. Just plug a wire from the outputs to any conducting surface, and get a touch-sensitive surface! 17 | 18 | 8) User Defined Programs: Generally, while using Arduino one face problem of uploading different codes again and again as he changes some part of codes. Using evive’s user defined function submenu, the user can store different Arduino programs at once. He can switch to different program while navigating inside the menu. Here is how to do it: https://www.youtube.com/watch?v=c5ne1dfeFOQ 19 | 20 | 9)Examples: There are some example codes in example menu that can be used directly from the firmware of evive. Name of these examples are: 21 | Blink Analog Input 22 | TFT display (POT1) 23 | Probe V Sense 24 | TFT Serial Monitor (pot 1) 25 | 26 | 10) Exit Menu: While using evive Frimware as library, Exit Menu needs to be selected to enter the custom program along with evive Menu. 27 | 28 | When evive is used for custom programming at that time also it is possible to navigate back to firmware by center pressing navigate key of evive. At this time the custom code that was previously running on evive stops and firmware runs on evive. But for this to happen custom code made should have evive.h library included. As soon as one exits firmware from menu, their custom code again starts running on evive. 29 | -------------------------------------------------------------------------------- /src/SerialMonitor.cpp: -------------------------------------------------------------------------------- 1 | /*Serial Monitor library reads data from the selected serial ports in menu and displays on TFT screen. 2 | Menu gives the user a choice to select the baud rate and displays it on the TFT. It can read from multiple 3 | serial ports simultaneously. In the function tft_implementation_serial_monitor [in screenImplementation.h], 4 | serial ports are checked for any new/available data while the class object serialObject takes care of printing the 5 | data on screen corresponding to the selected serial port(s). 6 | 7 | Copyright (C) 2018, Agilo Research 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see 0) { 63 | msg = Serial.readString(); 64 | linesMsg = linesCount(msg.length()); 65 | if (lineNumCurrent + linesMsg > 16) { 66 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * (16-lineNumCurrent) + CHAR_HEIGHT, ST7735_BLACK); 67 | tft.fillRect(0, 3 * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 68 | tft.setCursor(0, CHAR_HEIGHT * 3); 69 | tft.print(F("> ")); 70 | tft.print(msg); 71 | lineNumCurrent = 3; 72 | } 73 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 74 | tft.setTextColor(ST7735_WHITE); 75 | tft.setCursor(0, CHAR_HEIGHT * lineNumCurrent); 76 | tft.print(F("> ")); 77 | tft.print(msg); 78 | lineNumCurrent = lineNumCurrent + linesMsg; 79 | msg = ""; 80 | } 81 | } 82 | 83 | void SerialMonitor::serial2PrintMsg() { 84 | if (Serial2.available() > 0) { 85 | msg2 = Serial2.readString(); 86 | linesMsg = linesCount(msg2.length()); 87 | if (lineNumCurrent + linesMsg > 16) { 88 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * (16-lineNumCurrent) + CHAR_HEIGHT, ST7735_BLACK); 89 | tft.fillRect(0, 3 * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 90 | tft.setCursor(0, CHAR_HEIGHT * 3); 91 | tft.print(F("> ")); 92 | tft.print(msg2); 93 | lineNumCurrent = 3; 94 | } 95 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 96 | tft.setTextColor(ST7735_MAGENTA); 97 | tft.setCursor(0, CHAR_HEIGHT * lineNumCurrent); 98 | tft.print(F("> ")); 99 | tft.print(msg2); 100 | lineNumCurrent = lineNumCurrent + linesMsg; 101 | msg2 = ""; 102 | } 103 | } 104 | 105 | void SerialMonitor::serial3PrintMsg() { 106 | if (Serial3.available() > 0) { 107 | msg3 = Serial3.readString(); 108 | linesMsg = linesCount(msg3.length()); 109 | if (lineNumCurrent + linesMsg > 16) { 110 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * (16-lineNumCurrent) + CHAR_HEIGHT, ST7735_BLACK); 111 | tft.fillRect(0, 3 * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 112 | tft.setCursor(0, CHAR_HEIGHT * 3); 113 | tft.print(F("> ")); 114 | tft.print(msg3); 115 | lineNumCurrent = 3; 116 | } 117 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 118 | tft.setCursor(0, CHAR_HEIGHT * lineNumCurrent); 119 | tft.print(F("> ")); 120 | tft.print(msg3); 121 | lineNumCurrent = lineNumCurrent + linesMsg; 122 | msg3 = ""; 123 | } 124 | } 125 | 126 | uint8_t SerialMonitor::linesCount(int lengthMsg) { 127 | if(lengthMsg>=390) return 16; 128 | return (uint8_t(1+lengthMsg/25)); 129 | } 130 | 131 | SerialMonitor serialObject; 132 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/SerialMonitor.cpp: -------------------------------------------------------------------------------- 1 | /*Serial Monitor library reads data from the selected serial ports in menu and displays on TFT screen. 2 | Menu gives the user a choice to select the baud rate and displays it on the TFT. It can read from multiple 3 | serial ports simultaneously. In the function tft_implementation_serial_monitor [in screenImplementation.h], 4 | serial ports are checked for any new/available data while the class object serialObject takes care of printing the 5 | data on screen corresponding to the selected serial port(s). 6 | 7 | Copyright (C) 2018, Agilo Research 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see 0) { 63 | msg = Serial.readString(); 64 | linesMsg = linesCount(msg.length()); 65 | if (lineNumCurrent + linesMsg > 16) { 66 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * (16-lineNumCurrent) + CHAR_HEIGHT, ST7735_BLACK); 67 | tft.fillRect(0, 3 * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 68 | tft.setCursor(0, CHAR_HEIGHT * 3); 69 | tft.print(F("> ")); 70 | tft.print(msg); 71 | lineNumCurrent = 3; 72 | } 73 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 74 | tft.setTextColor(ST7735_WHITE); 75 | tft.setCursor(0, CHAR_HEIGHT * lineNumCurrent); 76 | tft.print(F("> ")); 77 | tft.print(msg); 78 | lineNumCurrent = lineNumCurrent + linesMsg; 79 | msg = ""; 80 | } 81 | } 82 | 83 | void SerialMonitor::serial2PrintMsg() { 84 | if (Serial2.available() > 0) { 85 | msg2 = Serial2.readString(); 86 | linesMsg = linesCount(msg2.length()); 87 | if (lineNumCurrent + linesMsg > 16) { 88 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * (16-lineNumCurrent) + CHAR_HEIGHT, ST7735_BLACK); 89 | tft.fillRect(0, 3 * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 90 | tft.setCursor(0, CHAR_HEIGHT * 3); 91 | tft.print(F("> ")); 92 | tft.print(msg2); 93 | lineNumCurrent = 3; 94 | } 95 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 96 | tft.setTextColor(ST7735_MAGENTA); 97 | tft.setCursor(0, CHAR_HEIGHT * lineNumCurrent); 98 | tft.print(F("> ")); 99 | tft.print(msg2); 100 | lineNumCurrent = lineNumCurrent + linesMsg; 101 | msg2 = ""; 102 | } 103 | } 104 | 105 | void SerialMonitor::serial3PrintMsg() { 106 | if (Serial3.available() > 0) { 107 | msg3 = Serial3.readString(); 108 | linesMsg = linesCount(msg3.length()); 109 | if (lineNumCurrent + linesMsg > 16) { 110 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * (16-lineNumCurrent) + CHAR_HEIGHT, ST7735_BLACK); 111 | tft.fillRect(0, 3 * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 112 | tft.setCursor(0, CHAR_HEIGHT * 3); 113 | tft.print(F("> ")); 114 | tft.print(msg3); 115 | lineNumCurrent = 3; 116 | } 117 | tft.fillRect(0, lineNumCurrent * CHAR_HEIGHT, TFT_WIDTH, CHAR_HEIGHT * linesMsg + CHAR_HEIGHT, ST7735_BLACK); 118 | tft.setCursor(0, CHAR_HEIGHT * lineNumCurrent); 119 | tft.print(F("> ")); 120 | tft.print(msg3); 121 | lineNumCurrent = lineNumCurrent + linesMsg; 122 | msg3 = ""; 123 | } 124 | } 125 | 126 | uint8_t SerialMonitor::linesCount(int lengthMsg) { 127 | if(lengthMsg>=390) return 16; 128 | return (uint8_t(1+lengthMsg/25)); 129 | } 130 | 131 | SerialMonitor serialObject; 132 | -------------------------------------------------------------------------------- /src/Stepper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Stepper.h - Stepper library for Wiring/Arduino - Version 1.1.0 3 | * 4 | * Original library (0.1) by Tom Igoe. 5 | * Two-wire modifications (0.2) by Sebastian Gassner 6 | * Combination version (0.3) by Tom Igoe and David Mellis 7 | * Bug fix for four-wire (0.4) by Tom Igoe, bug fix from Noah Shibley 8 | * High-speed stepping mod by Eugene Kozlenko 9 | * Timer rollover fix by Eugene Kozlenko 10 | * Five phase five wire (1.1.0) by Ryan Orendorff 11 | * 12 | * This library is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU Lesser General Public 14 | * License as published by the Free Software Foundation; either 15 | * version 2.1 of the License, or (at your option) any later version. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 | * 26 | * 27 | * Drives a unipolar, bipolar, or five phase stepper motor. 28 | * 29 | * When wiring multiple stepper motors to a microcontroller, you quickly run 30 | * out of output pins, with each motor requiring 4 connections. 31 | * 32 | * By making use of the fact that at any time two of the four motor coils are 33 | * the inverse of the other two, the number of control connections can be 34 | * reduced from 4 to 2 for the unipolar and bipolar motors. 35 | * 36 | * A slightly modified circuit around a Darlington transistor array or an 37 | * L293 H-bridge connects to only 2 microcontroler pins, inverts the signals 38 | * received, and delivers the 4 (2 plus 2 inverted ones) output signals 39 | * required for driving a stepper motor. Similarly the Arduino motor shields 40 | * 2 direction pins may be used. 41 | * 42 | * The sequence of control signals for 5 phase, 5 control wires is as follows: 43 | * 44 | * Step C0 C1 C2 C3 C4 45 | * 1 0 1 1 0 1 46 | * 2 0 1 0 0 1 47 | * 3 0 1 0 1 1 48 | * 4 0 1 0 1 0 49 | * 5 1 1 0 1 0 50 | * 6 1 0 0 1 0 51 | * 7 1 0 1 1 0 52 | * 8 1 0 1 0 0 53 | * 9 1 0 1 0 1 54 | * 10 0 0 1 0 1 55 | * 56 | * The sequence of control signals for 4 control wires is as follows: 57 | * 58 | * Step C0 C1 C2 C3 59 | * 1 1 0 1 0 60 | * 2 0 1 1 0 61 | * 3 0 1 0 1 62 | * 4 1 0 0 1 63 | * 64 | * The sequence of controls signals for 2 control wires is as follows 65 | * (columns C1 and C2 from above): 66 | * 67 | * Step C0 C1 68 | * 1 0 1 69 | * 2 1 1 70 | * 3 1 0 71 | * 4 0 0 72 | * 73 | * The circuits can be found at 74 | * 75 | * http://www.arduino.cc/en/Tutorial/Stepper 76 | */ 77 | 78 | // ensure this library description is only included once 79 | #ifndef STEPPER_H 80 | #define STEPPER_H 81 | #include "evive.h" 82 | 83 | const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution 84 | // for your motor 85 | 86 | // library interface description 87 | class Stepper { 88 | public: 89 | // constructors: 90 | Stepper(); 91 | Stepper(uint16_t number_of_steps, uint8_t motor_pin_1, uint8_t motor_pin_2); 92 | Stepper(uint16_t number_of_steps, uint8_t motor_pin_1, uint8_t motor_pin_2, 93 | uint8_t motor_pin_3, uint8_t motor_pin_4); 94 | Stepper(uint16_t number_of_steps, uint8_t motor_pin_1, uint8_t motor_pin_2, 95 | uint8_t motor_pin_3, uint8_t motor_pin_4, 96 | uint8_t motor_pin_5); 97 | 98 | //attach stepper 99 | void attachStepper(uint16_t number_of_steps, uint8_t motor_pin_1, uint8_t motor_pin_2, 100 | uint8_t motor_pin_3, uint8_t motor_pin_4); 101 | // speed setter method: 102 | void setSpeed(long whatSpeed); 103 | 104 | // mover method: 105 | void step(int number_of_steps); 106 | 107 | int version(void); 108 | 109 | private: 110 | void stepMotor(int this_step); 111 | 112 | int direction; // Direction of rotation 113 | unsigned long step_delay; // delay between steps, in ms, based on speed 114 | int number_of_steps; // total number of steps this motor can take 115 | uint8_t pin_count; // how many pins are in use. 116 | int step_number; // which step the motor is on 117 | 118 | // motor pin numbers: 119 | int motor_pin_1; 120 | int motor_pin_2; 121 | int motor_pin_3; 122 | int motor_pin_4; 123 | int motor_pin_5; // Only 5 phase motor 124 | 125 | unsigned long last_step_time; // time stamp in us of when the last step was taken 126 | }; 127 | 128 | //No varible can be assigned any value here as variables are actually declared in motor.cpp 129 | //Using extern, variables can be used in other libraries without declaration. 130 | extern bool _STEPPER_EN; 131 | extern Stepper stepper; 132 | 133 | void controlStepper(); 134 | void addStepper(); 135 | 136 | #endif 137 | -------------------------------------------------------------------------------- /examples/eviveFirmwareExtended/Stepper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Stepper.h - Stepper library for Wiring/Arduino - Version 1.1.0 3 | * 4 | * Original library (0.1) by Tom Igoe. 5 | * Two-wire modifications (0.2) by Sebastian Gassner 6 | * Combination version (0.3) by Tom Igoe and David Mellis 7 | * Bug fix for four-wire (0.4) by Tom Igoe, bug fix from Noah Shibley 8 | * High-speed stepping mod by Eugene Kozlenko 9 | * Timer rollover fix by Eugene Kozlenko 10 | * Five phase five wire (1.1.0) by Ryan Orendorff 11 | * 12 | * This library is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU Lesser General Public 14 | * License as published by the Free Software Foundation; either 15 | * version 2.1 of the License, or (at your option) any later version. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 | * 26 | * 27 | * Drives a unipolar, bipolar, or five phase stepper motor. 28 | * 29 | * When wiring multiple stepper motors to a microcontroller, you quickly run 30 | * out of output pins, with each motor requiring 4 connections. 31 | * 32 | * By making use of the fact that at any time two of the four motor coils are 33 | * the inverse of the other two, the number of control connections can be 34 | * reduced from 4 to 2 for the unipolar and bipolar motors. 35 | * 36 | * A slightly modified circuit around a Darlington transistor array or an 37 | * L293 H-bridge connects to only 2 microcontroler pins, inverts the signals 38 | * received, and delivers the 4 (2 plus 2 inverted ones) output signals 39 | * required for driving a stepper motor. Similarly the Arduino motor shields 40 | * 2 direction pins may be used. 41 | * 42 | * The sequence of control signals for 5 phase, 5 control wires is as follows: 43 | * 44 | * Step C0 C1 C2 C3 C4 45 | * 1 0 1 1 0 1 46 | * 2 0 1 0 0 1 47 | * 3 0 1 0 1 1 48 | * 4 0 1 0 1 0 49 | * 5 1 1 0 1 0 50 | * 6 1 0 0 1 0 51 | * 7 1 0 1 1 0 52 | * 8 1 0 1 0 0 53 | * 9 1 0 1 0 1 54 | * 10 0 0 1 0 1 55 | * 56 | * The sequence of control signals for 4 control wires is as follows: 57 | * 58 | * Step C0 C1 C2 C3 59 | * 1 1 0 1 0 60 | * 2 0 1 1 0 61 | * 3 0 1 0 1 62 | * 4 1 0 0 1 63 | * 64 | * The sequence of controls signals for 2 control wires is as follows 65 | * (columns C1 and C2 from above): 66 | * 67 | * Step C0 C1 68 | * 1 0 1 69 | * 2 1 1 70 | * 3 1 0 71 | * 4 0 0 72 | * 73 | * The circuits can be found at 74 | * 75 | * http://www.arduino.cc/en/Tutorial/Stepper 76 | */ 77 | 78 | // ensure this library description is only included once 79 | #ifndef STEPPER_H 80 | #define STEPPER_H 81 | #include "evive.h" 82 | 83 | const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution 84 | // for your motor 85 | 86 | // library interface description 87 | class Stepper { 88 | public: 89 | // constructors: 90 | Stepper(); 91 | Stepper(uint16_t number_of_steps, uint8_t motor_pin_1, uint8_t motor_pin_2); 92 | Stepper(uint16_t number_of_steps, uint8_t motor_pin_1, uint8_t motor_pin_2, 93 | uint8_t motor_pin_3, uint8_t motor_pin_4); 94 | Stepper(uint16_t number_of_steps, uint8_t motor_pin_1, uint8_t motor_pin_2, 95 | uint8_t motor_pin_3, uint8_t motor_pin_4, 96 | uint8_t motor_pin_5); 97 | 98 | //attach stepper 99 | void attachStepper(uint16_t number_of_steps, uint8_t motor_pin_1, uint8_t motor_pin_2, 100 | uint8_t motor_pin_3, uint8_t motor_pin_4); 101 | // speed setter method: 102 | void setSpeed(long whatSpeed); 103 | 104 | // mover method: 105 | void step(int number_of_steps); 106 | 107 | int version(void); 108 | 109 | private: 110 | void stepMotor(int this_step); 111 | 112 | int direction; // Direction of rotation 113 | unsigned long step_delay; // delay between steps, in ms, based on speed 114 | int number_of_steps; // total number of steps this motor can take 115 | uint8_t pin_count; // how many pins are in use. 116 | int step_number; // which step the motor is on 117 | 118 | // motor pin numbers: 119 | int motor_pin_1; 120 | int motor_pin_2; 121 | int motor_pin_3; 122 | int motor_pin_4; 123 | int motor_pin_5; // Only 5 phase motor 124 | 125 | unsigned long last_step_time; // time stamp in us of when the last step was taken 126 | }; 127 | 128 | //No varible can be assigned any value here as variables are actually declared in motor.cpp 129 | //Using extern, variables can be used in other libraries without declaration. 130 | extern bool _STEPPER_EN; 131 | extern Stepper stepper; 132 | 133 | void controlStepper(); 134 | void addStepper(); 135 | 136 | #endif 137 | --------------------------------------------------------------------------------