Board#
-
class EVOX1#
Manages the EVOX1 controller, handling display, battery, I2C, buttons, and RGB functions.
This class implements a singleton pattern to ensure only one instance is created.
Initialisation & Setup
I2C Control Functions#
-
void EVOX1::selectI2CChannel(I2CChannel channel)#
Selects an I2C channel on the multiplexer.
- Parameters:
channel – The I2C channel to select.
-
int EVOX1::scanI2CChannel(I2CChannel channel, uint8_t *addresses, int maxAddresses)#
Scans for I2C devices on a specific channel.
- Parameters:
channel – The I2C channel to scan.
addresses – Pointer to store detected device addresses.
maxAddresses – Maximum number of addresses that can be stored.
- Returns:
The number of devices found.
I2C Scanner Example#
1#include <Evo.h>
2
3EVOX1 evo;
4
5void setup()
6{
7 evo.begin();
8 Serial.begin(115200);
9 while (!Serial) // Waits for serial to be connected
10 ;
11 Serial.println("I2C Scanner");
12 delay(1000);
13 Serial.println("0x70 is the address of the multiplexor. It will show up on every I2C port.");
14
15 int maxAddresses = 5;
16 int numAddress = 0;
17 uint8_t i2CAddress[maxAddresses];
18 for (int i = 0; i < 8; i++)
19 {
20 numAddress = evo.scanI2CChannel((I2CChannel)i, i2CAddress, maxAddresses);
21 if (numAddress != 0)
22 {
23 Serial.printf("%d addresse(s) found on I2C%d:", numAddress, i + 1);
24 for (int j = 0; j < numAddress; j++)
25 {
26 Serial.printf(" 0x%x", i2CAddress[j]);
27 }
28 Serial.println();
29 }
30 }
31}
Output
0x70 is the address of the multiplexor. It will show up on every I2C port.
2 addresse(s) found on I2C1: 0x29 0x70
2 addresse(s) found on I2C2: 0x29 0x70
1 addresse(s) found on I2C3: 0x70
1 addresse(s) found on I2C4: 0x70
1 addresse(s) found on I2C5: 0x70
1 addresse(s) found on I2C6: 0x70
1 addresse(s) found on I2C7: 0x70
3 addresse(s) found on I2C8: 0x29 0x3c 0x70
Note
The output will vary depending on the connected devices and their addresses.
Battery Control Functions#
-
float EVOX1::getTopBattery()#
Gets the voltage of the top battery.
- Returns:
The voltage of the top battery in volts.
-
float EVOX1::getBottomBattery()#
Gets the voltage of the bottom battery.
- Returns:
The voltage of the bottom battery in volts.
-
float EVOX1::getBattery()#
Gets the combined battery voltage.
- Returns:
The total battery voltage in volts.
Note
Battery values are returned in volts. Make sure to scale appropriately if using raw ADCs elsewhere.
Battery Example#
1#include <Evo.h>
2
3EVOX1 evo;
4
5void setup() {
6 Serial.begin(115200);
7 evo.begin();
8 Serial.println("EVOX1 evo Initialised");
9}
10
11void loop() {
12 Serial.print("Top Battery: ");
13 Serial.print(evo.getTopBattery());
14 Serial.print(" V, Bottom Battery: ");
15 Serial.print(evo.getBottomBattery());
16 Serial.println(" V");
17 delay(1000);
18}
Display Control Functions#
-
void EVOX1::flipDisplayOrientation(bool flip = true)#
Flips the orientation of the display.
- Parameters:
flip – true to flip, false to not flip.
Writing to Display
-
void EVOX1::writeToDisplay(int value, int x, int y, bool clear = false, bool draw = false)#
Writes an integer to the display at a specific position.
- Parameters:
value – The integer value to display.
x – X-coordinate position (0-128).
y – Y-coordinate position (0-64).
clear – Whether to clear the screen before drawing.
draw – Whether to immediately draw the screen.
-
void EVOX1::writeToDisplay(double f, int x, int y, bool clear = false, bool draw = false)#
Writes a floating-point number to the display at a specific position.
- Parameters:
f – The floating-point number to display.
x – X-coordinate position (0-128).
y – Y-coordinate position (0-64).
clear – Whether to clear the screen before drawing.
draw – Whether to immediately draw the screen.
-
void EVOX1::writeToDisplay(const char *c, int x, int y, bool clear = false, bool draw = false)#
Writes a string to the display at a specific position.
- Parameters:
c – The string to display.
x – X-coordinate position (0-128).
y – Y-coordinate position (0-64).
clear – Whether to clear the screen before drawing.
draw – Whether to immediately draw the screen.
Note
These overloaded functions write data to the display at specific coordinates (x, y). You can write integers, floating-point values, or C-style strings. The optional clear parameter clears the display before writing, and the optional draw parameter immediately renders the display buffer.
Writing Line to Display
Note
These methods write a value to a specified line on the display. Overloads accept integers, floating point numbers, or C-style strings.
Tip
For centered or multiline display, calculate position before calling these methods.
-
void EVOX1::setFontSize(uint8_t size)#
Sets the font size for the display.
- Parameters:
size – The font size.
Display Example#
Here is an example of how to use the EVOX1 display functions
1#include <Evo.h>
2
3EVOX1 evo;
4
5void setup() {
6 evo.begin(); // Initialize EVOX1
7
8 evo.clearDisplay(); // Clear the display
9 evo.writeToDisplay("Hello, EVOX1!", 0, 0, true, true); // Write to display
10 evo.drawDisplay(); // Render the display buffer
11}
LED & Buzzer Control Functions#
-
void EVOX1::setRGB(int r, int g, int b)#
Sets the color of the RGB LED.
- Parameters:
r – Red intensity (0-255).
g – Green intensity (0-255).
b – Blue intensity (0-255).
Tip
Use colors to indicate system states — e.g., red = error, green = ready.
-
void EVOX1::playTone(uint frequency, int duration = -1, bool blocking = true)#
Plays a tone on the buzzer.
See also
stopTone()
Note
If duration is -1, you must call stopTone() to stop the tone.
- Parameters:
frequency – The frequency of the tone in Hz.
duration – The duration of the tone in milliseconds. If -1, plays indefinitely until stopped.
blocking – If true, the program waits for the tone to complete playing. Default is true.
Warning
playTone is blocking — it will delay program execution.
LED & Buzzer Example#
1#include <Evo.h>
2
3EVOX1 evo;
4
5void setup() {
6evo.begin(); // initialises the Evo-X1 peripherals
7
8evo.clearDisplay(); // clears the display buffer
9evo.writeLineToDisplay("Press Button", 0, false, true); // writes the program name to the display
10
11evo.waitForBump(100); // waits for the button to be pressed
12evo.playTone(NOTE_G4, 300); // plays the buzzer for 300ms
13}
14
15void loop() {
16// cycling through red green and blue colors using the RGB led
17evo.setRGB(20, 0, 0);
18delay(1000);
19evo.setRGB(0, 20, 0);
20delay(1000);
21evo.setRGB(0, 0, 20);
22delay(1000);
23}