Skip to content

Commit a59c622

Browse files
committed
Add examples
1 parent 6003178 commit a59c622

File tree

20 files changed

+1371
-16
lines changed

20 files changed

+1371
-16
lines changed

.DS_Store

6 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Arduino_GigaDisplayRGB
1+
# Arduino_GigaDisplay
22

33
Minimal library for controlling the built-in RGB on the GIGA Display Shield via the IS31FL3197 driver (I2C).
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
ArduinoLogoDrawing
3+
4+
created 17 Apr 2023
5+
by Leonardo Cavagnis
6+
7+
Note: This example is also embedded in the Mbed Core:
8+
https://github.com/arduino/ArduinoCore-mbed/blob/main/libraries/Arduino_H7_Video/
9+
*/
10+
11+
#include "Arduino_H7_Video.h"
12+
#include "ArduinoGraphics.h"
13+
14+
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
15+
//Arduino_H7_Video Display(1024, 768, USBCVideo);
16+
17+
void setup() {
18+
Display.begin();
19+
20+
Display.beginDraw();
21+
Display.background(255, 255, 255);
22+
Display.clear();
23+
Display.fill(0x008184);
24+
Display.circle(Display.width()/2, Display.height()/2, 300);
25+
Display.stroke(255, 255, 255);
26+
Display.noFill();
27+
for (int i=0; i<30; i++) {
28+
Display.circle((Display.width()/2)-55+5, Display.height()/2, 110-i);
29+
Display.circle((Display.width()/2)+55-5, Display.height()/2, 110-i);
30+
}
31+
Display.fill(255, 255, 255);
32+
Display.rect((Display.width()/2)-55-16+5, (Display.height()/2)-5, 32, 10);
33+
Display.fill(255, 255, 255);
34+
Display.rect((Display.width()/2)+55-16-5, (Display.height()/2)-5, 32, 10);
35+
Display.fill(255, 255, 255);
36+
Display.rect((Display.width()/2)+55-5-5, (Display.height()/2)-16, 10, 32);
37+
Display.endDraw();
38+
}
39+
40+
void loop() { }
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Simple Text
3+
4+
This example initializes the 800x480 display on the
5+
GIGA Display Shield, and writes "Hello World" at
6+
specific coordinates.
7+
8+
The circuit:
9+
- GIGA R1 WiFi
10+
- GIGA Display Shield
11+
12+
Created 4 sept 2023
13+
by Karl Söderby
14+
15+
This example code is in the public domain.
16+
*/
17+
18+
#include "Arduino_H7_Video.h"
19+
#include "ArduinoGraphics.h"
20+
21+
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
22+
23+
void setup() {
24+
Display.begin();
25+
Display.clear();
26+
Display.beginDraw();
27+
Display.textFont(Font_5x7);
28+
Display.stroke(255, 255, 255);
29+
Display.text("Hello world!", 50, 50);
30+
Display.endDraw();
31+
}
32+
33+
void loop() {}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
#include "arducam_dvp.h"
3+
#include "Arduino_H7_Video.h"
4+
#include "dsi.h"
5+
#include "SDRAM.h"
6+
7+
// This example only works with Greyscale cameras (due to the palette + resize&rotate algo)
8+
#define ARDUCAM_CAMERA_HM01B0
9+
10+
#ifdef ARDUCAM_CAMERA_HM01B0
11+
#include "Himax_HM01B0/himax.h"
12+
HM01B0 himax;
13+
Camera cam(himax);
14+
#define IMAGE_MODE CAMERA_GRAYSCALE
15+
#elif defined(ARDUCAM_CAMERA_HM0360)
16+
#include "Himax_HM0360/hm0360.h"
17+
HM0360 himax;
18+
Camera cam(himax);
19+
#define IMAGE_MODE CAMERA_GRAYSCALE
20+
#elif defined(ARDUCAM_CAMERA_OV767X)
21+
#include "OV7670/ov767x.h"
22+
// OV7670 ov767x;
23+
OV7675 ov767x;
24+
Camera cam(ov767x);
25+
#define IMAGE_MODE CAMERA_RGB565
26+
#error "Unsupported camera (at the moment :) )"
27+
#elif defined(ARDUCAM_CAMERA_GC2145)
28+
#include "GC2145/gc2145.h"
29+
GC2145 galaxyCore;
30+
Camera cam(galaxyCore);
31+
#define IMAGE_MODE CAMERA_RGB565
32+
#error "Unsupported camera (at the moment :) )"
33+
#endif
34+
35+
// The buffer used to capture the frame
36+
FrameBuffer fb;
37+
// The buffer used to rotate and resize the frame
38+
FrameBuffer outfb;
39+
// The buffer used to rotate and resize the frame
40+
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
41+
42+
void blinkLED(uint32_t count = 0xFFFFFFFF)
43+
{
44+
pinMode(LED_BUILTIN, OUTPUT);
45+
while (count--) {
46+
digitalWrite(LED_BUILTIN, LOW); // turn the LED on (HIGH is the voltage level)
47+
delay(50); // wait for a second
48+
digitalWrite(LED_BUILTIN, HIGH); // turn the LED off by making the voltage LOW
49+
delay(50); // wait for a second
50+
}
51+
}
52+
53+
uint32_t palette[256];
54+
55+
void setup() {
56+
// Init the cam QVGA, 30FPS
57+
if (!cam.begin(CAMERA_R320x240, IMAGE_MODE, 30)) {
58+
blinkLED();
59+
}
60+
61+
// Setup the palette to convert 8 bit greyscale to 32bit greyscale
62+
for (int i = 0; i < 256; i++) {
63+
palette[i] = 0xFF000000 | (i << 16) | (i << 8) | i;
64+
}
65+
66+
Display.begin();
67+
dsi_configueCLUT((uint32_t*)palette);
68+
69+
outfb.setBuffer((uint8_t*)SDRAM.malloc(1024*1024));
70+
71+
// clear the display (gives a nice black background)
72+
dsi_lcdClear(0);
73+
dsi_drawCurrentFrameBuffer();
74+
dsi_lcdClear(0);
75+
dsi_drawCurrentFrameBuffer();
76+
}
77+
78+
void loop() {
79+
80+
// Grab frame and write to another framebuffer
81+
if (cam.grabFrame(fb, 3000) == 0) {
82+
83+
// double the resolution and transpose (rotate by 90 degrees) in the same step
84+
// this only works if the camera feed is 320x240 and the area where we want to display is 640x480
85+
for (int i = 0; i < 320; i++) {
86+
for (int j = 0; j < 240; j++) {
87+
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480] = ((uint8_t*)fb.getBuffer())[i + j * 320];
88+
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2) * 480 + 1] = ((uint8_t*)fb.getBuffer())[i + j * 320];
89+
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480] = ((uint8_t*)fb.getBuffer())[i + j * 320];
90+
((uint8_t*)outfb.getBuffer())[j * 2 + (i * 2 + 1) * 480 + 1] = ((uint8_t*)fb.getBuffer())[i + j * 320];
91+
}
92+
}
93+
dsi_lcdDrawImage((void*)outfb.getBuffer(), (void*)dsi_getCurrentFrameBuffer(), 480, 640, DMA2D_INPUT_L8);
94+
dsi_drawCurrentFrameBuffer();
95+
} else {
96+
blinkLED(20);
97+
}
98+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
Arduino BMI270 - Simple Accelerometer
3+
4+
This example reads the acceleration values from the BMI270
5+
sensor and continuously prints them to the Serial Monitor
6+
or Serial Plotter.
7+
8+
The circuit:
9+
- GIGA R1 WiFi
10+
- GIGA Display Shield
11+
12+
created 10 Jul 2019
13+
by Riccardo Rizzo
14+
15+
modified 4 sept 2023
16+
by Karl Söderby
17+
18+
Note: this example originates from the following library:
19+
https://github.com/arduino-libraries/Arduino_BMI270_BMM150
20+
21+
This example code is in the public domain.
22+
*/
23+
24+
#include "Arduino_BMI270_BMM150.h"
25+
BoschSensorClass imu(Wire1);
26+
27+
void setup() {
28+
Serial.begin(9600);
29+
while (!Serial);
30+
Serial.println("Started");
31+
32+
if (!imu.begin()) {
33+
Serial.println("Failed to initialize imu!");
34+
while (1);
35+
}
36+
37+
Serial.print("Accelerometer sample rate = ");
38+
Serial.print(imu.accelerationSampleRate());
39+
Serial.println(" Hz");
40+
Serial.println();
41+
Serial.println("Acceleration in G's");
42+
Serial.println("X\tY\tZ");
43+
}
44+
45+
void loop() {
46+
float x, y, z;
47+
48+
if (imu.accelerationAvailable()) {
49+
imu.readAcceleration(x, y, z);
50+
51+
Serial.print(x);
52+
Serial.print('\t');
53+
Serial.print(y);
54+
Serial.print('\t');
55+
Serial.println(z);
56+
}
57+
}

examples/imu/gyroscope/gyroscope.ino

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Arduino BMI270 - Simple Gyroscope
3+
4+
This example reads the gyroscope values from the BMI270
5+
sensor and continuously prints them to the Serial Monitor
6+
or Serial Plotter.
7+
8+
The circuit:
9+
- GIGA R1 WiFi
10+
- GIGA Display Shield
11+
12+
created 10 Jul 2019
13+
by Riccardo Rizzo
14+
15+
modified 4 sept 2023
16+
by Karl Söderby
17+
18+
Note: this example originates from the following library:
19+
https://github.com/arduino-libraries/Arduino_BMI270_BMM150
20+
21+
This example code is in the public domain.
22+
*/
23+
24+
#include "Arduino_BMI270_BMM150.h"
25+
BoschSensorClass imu(Wire1);
26+
27+
void setup() {
28+
Serial.begin(9600);
29+
while (!Serial);
30+
Serial.println("Started");
31+
32+
if (!imu.begin()) {
33+
Serial.println("Failed to initialize imu!");
34+
while (1);
35+
}
36+
Serial.print("Gyroscope sample rate = ");
37+
Serial.print(imu.gyroscopeSampleRate());
38+
Serial.println(" Hz");
39+
Serial.println();
40+
Serial.println("Gyroscope in degrees/second");
41+
Serial.println("X\tY\tZ");
42+
}
43+
44+
void loop() {
45+
float x, y, z;
46+
47+
if (imu.gyroscopeAvailable()) {
48+
imu.readGyroscope(x, y, z);
49+
50+
Serial.print(x);
51+
Serial.print('\t');
52+
Serial.print(y);
53+
Serial.print('\t');
54+
Serial.println(z);
55+
}
56+
}

examples/lvgl/bar_lvgl/bar_lvgl.ino

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include "Arduino_H7_Video.h"
2+
#include "Arduino_GigaDisplayTouch.h"
3+
4+
#include "lvgl.h"
5+
6+
Arduino_H7_Video Display(800, 480, GigaDisplayShield); /* Arduino_H7_Video Display(1024, 768, USBCVideo); */
7+
Arduino_GigaDisplayTouch TouchDetector;
8+
9+
static void set_slider_val(void * bar, int32_t val) {
10+
lv_bar_set_value((lv_obj_t *)bar, val, LV_ANIM_ON);
11+
}
12+
13+
void setup() {
14+
Display.begin();
15+
TouchDetector.begin();
16+
17+
lv_obj_t * screen = lv_obj_create(lv_scr_act());
18+
lv_obj_set_size(screen, Display.width(), Display.height());
19+
20+
static lv_coord_t col_dsc[] = { 500, LV_GRID_TEMPLATE_LAST};
21+
static lv_coord_t row_dsc[] = { 400, LV_GRID_TEMPLATE_LAST};
22+
23+
lv_obj_t * grid = lv_obj_create(lv_scr_act());
24+
25+
lv_obj_set_grid_dsc_array(grid, col_dsc, row_dsc);
26+
27+
lv_obj_set_size(grid, Display.width(), Display.height());
28+
29+
lv_obj_center(grid);
30+
31+
lv_obj_t * label;
32+
lv_obj_t * obj;
33+
34+
obj = lv_obj_create(grid);
35+
lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 0, 1,
36+
LV_GRID_ALIGN_STRETCH, 0, 1);
37+
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
38+
39+
lv_obj_t * bar = lv_bar_create(obj);
40+
lv_obj_set_size(bar, 200, 20);
41+
lv_obj_center(bar);
42+
lv_bar_set_value(bar, 70, LV_ANIM_OFF);
43+
44+
lv_anim_t a;
45+
lv_anim_init(&a);
46+
lv_anim_set_exec_cb(&a, set_slider_val);
47+
lv_anim_set_time(&a, 3000);
48+
lv_anim_set_playback_time(&a, 3000);
49+
lv_anim_set_var(&a, bar);
50+
lv_anim_set_values(&a, 0, 100);
51+
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
52+
lv_anim_start(&a);
53+
54+
}
55+
56+
void loop() {
57+
lv_timer_handler();
58+
}

0 commit comments

Comments
 (0)