Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
| `class` [`ModulinoMovement`](#modulinomovement) | Handles the functionality of Modulino Movement,interfacing with the IMU sensor to get acceleration readings. |
| `class` [`ModulinoThermo`](#modulinothermo) | Handles the functionality of Modulino Thermo, managing temperature sensors to provide real-time temperature and humidity readings. |
| `class` [`ModulinoDistance`](#modulinodistance) | Handles the functionality of Modulino Distance, enabling distance measurement using ToF (Time-of-Flight) sensors for precise range detection. |
| `class` [`ModulinoDisplay`](#modulinodisplay) | Handles the functionality of Modulino Display, managing OLED screen output for text and graphics display. |

### ModulinoClass

Expand Down Expand Up @@ -167,6 +168,16 @@ Represents a Modulino Distance module.
Returns the distance measured by the sensor in millimeters.
The measured distance in millimeters if available, `NAN` if the distance reading is invalid.

---

### ModulinoDisplay

Represents a Modulino Display module.

#### Methods

Refer to the [ArduinoGraphics](https://github.com/arduino-libraries/ArduinoGraphics) class methods for specific drawing operations such as shapes, text, colors, and pixel manipulation.

## Constants

- **`ModulinoColor RED`**
Expand Down
15 changes: 15 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The **Modulino** library supports the following hardware modules:
- **Motion (`ModulinoMovement`)**: Interface with the LSM6DSOX IMU sensor to get acceleration values.
- **Temperature & Humidity (`ModulinoThermo`)**: Get temperature and humidity readings from the HS300x sensor.
- **Distance (`ModulinoDistance`)**: Measures distance using a Time-of-Flight (ToF) sensor (VL53L0x).
- **Display (`ModulinoDisplay`)**: Control a 128x64 OLED display for visual output.

## Library Initialization

Expand Down Expand Up @@ -116,6 +117,20 @@ distance.begin();
float distanceValue = distance.get();
```

### ModulinoDisplay
Controls a 128x64 OLED display for visual output. You can draw text, shapes, and images on the screen using the [ArduinoGraphics](https://github.com/arduino-libraries/ArduinoGraphics) functions.

```cpp
ModulinoDisplay display;
display.begin();
display.beginDraw();
display.background(0, 0, 0);
display.stroke(255, 255, 255);
display.textFont(Font_5x7);
display.text("Hello Modulino!", 10, 10);
display.endDraw();
```

## Example Usage

Here’s an example of how to use some Modulino in a program:
Expand Down
27 changes: 27 additions & 0 deletions examples/Modulino_Display/Display_Basic/Display_Basic.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <Arduino_Modulino.h>

ModulinoDisplay display;

void setup() {
Serial.begin(115200);
Modulino.begin();

if (!display.begin()) {
Serial.println("Display not found!");
while (1);
}

display.beginDraw();
display.background(0, 0, 0);
display.stroke(255, 255, 255);
display.textFont(Font_5x7);

display.text("Hello Modulino!", 10, 10);
display.noFill();
display.circle(64, 40, 15);

display.endDraw();
}

void loop() {
}
34 changes: 34 additions & 0 deletions src/Modulino.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <Arduino_HS300x.h>
#include "Arduino_LTR381RGB.h"
#include "Arduino.h"
#include "Arduino_ST7315.h"
//#include <SE05X.h> // need to provide a way to change Wire object

#ifndef ARDUINO_API_VERSION
Expand Down Expand Up @@ -1062,4 +1063,37 @@ class ModulinoLatchRelay : public Module {
uint8_t match[1] = { 0x04 }; // same as fw main.c
};

class ModulinoDisplay : public ArduinoGraphics, public Module {
public:
ModulinoDisplay(ModulinoHubPort* hubPort = nullptr)
: ArduinoGraphics(128, 64),
Module(0xFF, "DISPLAY", hubPort) {}

int begin() { // override of ArduinoGraphics::begin (we can't use Module::begin here because conflict of return type)
if (hubPort != nullptr) hubPort->select();

_display = new Arduino_ST7315_Driver(128, 64, (TwoWire*)getWire(), 0x3D);
initialized = _display->begin();
__increaseI2CPriority();

if (hubPort != nullptr) hubPort->clear();
return initialized;
}

operator bool() {
return (initialized != 0);
}

void beginDraw() override {}
void endDraw() override { if(initialized) _display->update(); }

void set(int x, int y, uint8_t r, uint8_t g, uint8_t b) override {
bool on = (r | g | b) > 127; // RGB threshold to decide pixel on/off (at least one color > 50%/127)
if(initialized) _display->set(x, y, on);
}
private:
Arduino_ST7315_Driver* _display = nullptr;
int initialized = 0;
};

#endif
Loading