Hello All,
I want to display the values read from analog ports on the original GIGA display shield, but it seems that the display is interfering with the analogRead() function, and the display flickers. I also tried to use Arduino_advancedAnalog library, but it would not compile. The error is related to the pins description. I took a look at the schematics but could not spot any shared pin between the display and analog ports. My code is as follows:
#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;
char buffer[20];
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();
}
void loop() {
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);
label = lv_label_create(obj);
lv_label_set_text(label, "Hello World!");
lv_obj_align_to(label, bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
int i=0;
while(1){
i++;
delay(100);
lv_bar_set_value(bar, i, LV_ANIM_OFF);
sprintf(buffer, "%d", analogRead(2));
lv_label_set_text(label, buffer);
if(i==100)
i=0;
lv_timer_handler();
}
}