Skip to content

Add examples + dependencies #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 4, 2023
Merged
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
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Arduino_GigaDisplayRGB
# Arduino_GigaDisplay

Minimal library for controlling the built-in RGB on the GIGA Display Shield via the IS31FL3197 driver (I2C).
40 changes: 40 additions & 0 deletions examples/basic/ArduinoLogoDrawing/ArduinoLogoDrawing
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
ArduinoLogoDrawing

created 17 Apr 2023
by Leonardo Cavagnis

Note: This example is also embedded in the Mbed Core:
https://github.com/arduino/ArduinoCore-mbed/blob/main/libraries/Arduino_H7_Video/
*/

#include "Arduino_H7_Video.h"
#include "ArduinoGraphics.h"

Arduino_H7_Video Display(800, 480, GigaDisplayShield);
//Arduino_H7_Video Display(1024, 768, USBCVideo);

void setup() {
Display.begin();

Display.beginDraw();
Display.background(255, 255, 255);
Display.clear();
Display.fill(0x008184);
Display.circle(Display.width()/2, Display.height()/2, 300);
Display.stroke(255, 255, 255);
Display.noFill();
for (int i=0; i<30; i++) {
Display.circle((Display.width()/2)-55+5, Display.height()/2, 110-i);
Display.circle((Display.width()/2)+55-5, Display.height()/2, 110-i);
}
Display.fill(255, 255, 255);
Display.rect((Display.width()/2)-55-16+5, (Display.height()/2)-5, 32, 10);
Display.fill(255, 255, 255);
Display.rect((Display.width()/2)+55-16-5, (Display.height()/2)-5, 32, 10);
Display.fill(255, 255, 255);
Display.rect((Display.width()/2)+55-5-5, (Display.height()/2)-16, 10, 32);
Display.endDraw();
}

void loop() { }
33 changes: 33 additions & 0 deletions examples/basic/SimpleText/SimpleText.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Simple Text

This example initializes the 800x480 display on the
GIGA Display Shield, and writes "Hello World" at
specific coordinates.

The circuit:
- GIGA R1 WiFi
- GIGA Display Shield

Created 4 sept 2023
by Karl Söderby

This example code is in the public domain.
*/

#include "Arduino_H7_Video.h"
#include "ArduinoGraphics.h"

Arduino_H7_Video Display(800, 480, GigaDisplayShield);

void setup() {
Display.begin();
Display.clear();
Display.beginDraw();
Display.textFont(Font_5x7);
Display.stroke(255, 255, 255);
Display.text("Hello world!", 50, 50);
Display.endDraw();
}

void loop() {}
98 changes: 98 additions & 0 deletions examples/camera/display_camera/display_camera.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@

#include "arducam_dvp.h"
#include "Arduino_H7_Video.h"
#include "dsi.h"
#include "SDRAM.h"

// This example only works with Greyscale cameras (due to the palette + resize&rotate algo)
#define ARDUCAM_CAMERA_HM01B0

#ifdef ARDUCAM_CAMERA_HM01B0
#include "Himax_HM01B0/himax.h"
HM01B0 himax;
Camera cam(himax);
#define IMAGE_MODE CAMERA_GRAYSCALE
#elif defined(ARDUCAM_CAMERA_HM0360)
#include "Himax_HM0360/hm0360.h"
HM0360 himax;
Camera cam(himax);
#define IMAGE_MODE CAMERA_GRAYSCALE
#elif defined(ARDUCAM_CAMERA_OV767X)
#include "OV7670/ov767x.h"
// OV7670 ov767x;
OV7675 ov767x;
Camera cam(ov767x);
#define IMAGE_MODE CAMERA_RGB565
#error "Unsupported camera (at the moment :) )"
#elif defined(ARDUCAM_CAMERA_GC2145)
#include "GC2145/gc2145.h"
GC2145 galaxyCore;
Camera cam(galaxyCore);
#define IMAGE_MODE CAMERA_RGB565
#error "Unsupported camera (at the moment :) )"
#endif

// The buffer used to capture the frame
FrameBuffer fb;
// The buffer used to rotate and resize the frame
FrameBuffer outfb;
// The buffer used to rotate and resize the frame
Arduino_H7_Video Display(800, 480, GigaDisplayShield);

void blinkLED(uint32_t count = 0xFFFFFFFF)
{
pinMode(LED_BUILTIN, OUTPUT);
while (count--) {
digitalWrite(LED_BUILTIN, LOW); // turn the LED on (HIGH is the voltage level)
delay(50); // wait for a second
digitalWrite(LED_BUILTIN, HIGH); // turn the LED off by making the voltage LOW
delay(50); // wait for a second
}
}

uint32_t palette[256];

void setup() {
// Init the cam QVGA, 30FPS
if (!cam.begin(CAMERA_R320x240, IMAGE_MODE, 30)) {
blinkLED();
}

// Setup the palette to convert 8 bit greyscale to 32bit greyscale
for (int i = 0; i < 256; i++) {
palette[i] = 0xFF000000 | (i << 16) | (i << 8) | i;
}

Display.begin();
dsi_configueCLUT((uint32_t*)palette);

outfb.setBuffer((uint8_t*)SDRAM.malloc(1024*1024));

// clear the display (gives a nice black background)
dsi_lcdClear(0);
dsi_drawCurrentFrameBuffer();
dsi_lcdClear(0);
dsi_drawCurrentFrameBuffer();
}

void loop() {

// Grab frame and write to another framebuffer
if (cam.grabFrame(fb, 3000) == 0) {

// double the resolution and transpose (rotate by 90 degrees) in the same step
// this only works if the camera feed is 320x240 and the area where we want to display is 640x480
for (int i = 0; i < 320; i++) {
for (int j = 0; j < 240; j++) {
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480] = ((uint8_t*)fb.getBuffer())[i + j * 320];
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480 + 1] = ((uint8_t*)fb.getBuffer())[i + j * 320];
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480] = ((uint8_t*)fb.getBuffer())[i + j * 320];
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480 + 1] = ((uint8_t*)fb.getBuffer())[i + j * 320];
}
}
dsi_lcdDrawImage((void*)outfb.getBuffer(), (void*)dsi_getCurrentFrameBuffer(), 480, 640, DMA2D_INPUT_L8);
dsi_drawCurrentFrameBuffer();
} else {
blinkLED(20);
}
}
57 changes: 57 additions & 0 deletions examples/imu/accelerometer/accelerometer.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Arduino BMI270 - Simple Accelerometer

This example reads the acceleration values from the BMI270
sensor and continuously prints them to the Serial Monitor
or Serial Plotter.

The circuit:
- GIGA R1 WiFi
- GIGA Display Shield

created 10 Jul 2019
by Riccardo Rizzo

modified 4 sept 2023
by Karl Söderby

Note: this example originates from the following library:
https://github.com/arduino-libraries/Arduino_BMI270_BMM150

This example code is in the public domain.
*/

#include "Arduino_BMI270_BMM150.h"
BoschSensorClass imu(Wire1);

void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("Started");

if (!imu.begin()) {
Serial.println("Failed to initialize imu!");
while (1);
}

Serial.print("Accelerometer sample rate = ");
Serial.print(imu.accelerationSampleRate());
Serial.println(" Hz");
Serial.println();
Serial.println("Acceleration in G's");
Serial.println("X\tY\tZ");
}

void loop() {
float x, y, z;

if (imu.accelerationAvailable()) {
imu.readAcceleration(x, y, z);

Serial.print(x);
Serial.print('\t');
Serial.print(y);
Serial.print('\t');
Serial.println(z);
}
}
56 changes: 56 additions & 0 deletions examples/imu/gyroscope/gyroscope.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
Arduino BMI270 - Simple Gyroscope

This example reads the gyroscope values from the BMI270
sensor and continuously prints them to the Serial Monitor
or Serial Plotter.

The circuit:
- GIGA R1 WiFi
- GIGA Display Shield

created 10 Jul 2019
by Riccardo Rizzo

modified 4 sept 2023
by Karl Söderby

Note: this example originates from the following library:
https://github.com/arduino-libraries/Arduino_BMI270_BMM150

This example code is in the public domain.
*/

#include "Arduino_BMI270_BMM150.h"
BoschSensorClass imu(Wire1);

void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("Started");

if (!imu.begin()) {
Serial.println("Failed to initialize imu!");
while (1);
}
Serial.print("Gyroscope sample rate = ");
Serial.print(imu.gyroscopeSampleRate());
Serial.println(" Hz");
Serial.println();
Serial.println("Gyroscope in degrees/second");
Serial.println("X\tY\tZ");
}

void loop() {
float x, y, z;

if (imu.gyroscopeAvailable()) {
imu.readGyroscope(x, y, z);

Serial.print(x);
Serial.print('\t');
Serial.print(y);
Serial.print('\t');
Serial.println(z);
}
}
58 changes: 58 additions & 0 deletions examples/lvgl/bar_lvgl/bar_lvgl.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "Arduino_H7_Video.h"
#include "Arduino_GigaDisplayTouch.h"

#include "lvgl.h"

Arduino_H7_Video Display(800, 480, GigaDisplayShield); /* Arduino_H7_Video Display(1024, 768, USBCVideo); */
Arduino_GigaDisplayTouch TouchDetector;

static void set_slider_val(void * bar, int32_t val) {
lv_bar_set_value((lv_obj_t *)bar, val, LV_ANIM_ON);
}

void setup() {
Display.begin();
TouchDetector.begin();

lv_obj_t * screen = lv_obj_create(lv_scr_act());
lv_obj_set_size(screen, Display.width(), Display.height());

static lv_coord_t col_dsc[] = { 500, LV_GRID_TEMPLATE_LAST};
static lv_coord_t row_dsc[] = { 400, LV_GRID_TEMPLATE_LAST};

lv_obj_t * grid = lv_obj_create(lv_scr_act());

lv_obj_set_grid_dsc_array(grid, col_dsc, row_dsc);

lv_obj_set_size(grid, Display.width(), Display.height());

lv_obj_center(grid);

lv_obj_t * label;
lv_obj_t * obj;

obj = lv_obj_create(grid);
lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 0, 1,
LV_GRID_ALIGN_STRETCH, 0, 1);
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);

lv_obj_t * bar = lv_bar_create(obj);
lv_obj_set_size(bar, 200, 20);
lv_obj_center(bar);
lv_bar_set_value(bar, 70, LV_ANIM_OFF);

lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_exec_cb(&a, set_slider_val);
lv_anim_set_time(&a, 3000);
lv_anim_set_playback_time(&a, 3000);
lv_anim_set_var(&a, bar);
lv_anim_set_values(&a, 0, 100);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);

}

void loop() {
lv_timer_handler();
}
Loading