Bonjour à tous,
J'utilise ce type d'écran sans capacité tactile (without touch) avec squarline studio.
Jusqu'à là ça fonctionne bien, affichage mouvement de ce que je veux faire parfait...
j'ai voulu y ajouté un module ads1115, je l'ai branché sur un autre ESP32 ça fonctionne parfaitement.
Donc j'ai implémenté ce petit module sur mon écran (gpio 21-22 scl-sda) ainsi que dans la prog et du coup j'ai plus rien qui fonctionne sauf l'écran qui s'allume 1s et se coupe 2s...
J'ai testé de débranche le ads1115 mais c'est pareil.
Les bibliothèques sont :
pour l'affichage lvgl et arduino gfx
pour l'ads1115 Adafruit_ADS1X15 et wire
#include <lvgl.h>
#include "ui.h"
#include <Wire.h>
#include <Arduino_GFX_Library.h>
#include <Adafruit_ADS1X15.h>
#define GFX_BL 27
Arduino_DataBus *bus = new Arduino_ESP32SPI(2 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, GFX_NOT_DEFINED /* MISO */);//JUANE
Arduino_GFX *gfx = new Arduino_ST7789(bus, -1 /* RST */, 1 /* rotation */, true /* IPS */);//JAUNE
const int PIN_SIGNAL_1 = 35;//JAUNE
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
/* Change to your screen resolution */
static uint32_t screenWidth;
static uint32_t screenHeight;
static lv_disp_draw_buf_t draw_buf;
static lv_color_t *disp_draw_buf;
static lv_disp_drv_t disp_drv;
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);
#if (LV_COLOR_16_SWAP != 0)
gfx->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#else
gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#endif
lv_disp_flush_ready(disp);
}
unsigned long tr = 0;
volatile long comptageImpuls = 0;
long timeRef = 0;
long delai = 250;
long timeRef1 = 0;
long delai1 = 1000;
volatile signed angle = -256;
volatile signed oldangle = -256;
volatile signed newangle = -256;
long signed temp = 0.00;
long signed temp2 = 0.00;
Adafruit_ADS1115 ads; /* Verifier adresse*/
void IRAM_ATTR fonction_ISR() {
comptageImpuls = comptageImpuls + 1;
}
void setup()
{
pinMode(PIN_SIGNAL_1, INPUT_PULLUP);
attachInterrupt(PIN_SIGNAL_1, fonction_ISR, FALLING);
Wire.begin();
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
gfx->begin();
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
lv_init();
screenWidth = gfx->width();
screenHeight = gfx->height();
#ifdef ESP32
disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * 32, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
#else
disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * 32);
#endif
if (!disp_draw_buf)
{
}
else
{
lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * 32);
/* Initialize the display */
lv_disp_drv_init(&disp_drv);
/* Change the following line to your display resolution */
disp_drv.hor_res = screenWidth;
disp_drv.ver_res = screenHeight;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register(&disp_drv);
/* Initialize the (dummy) input device driver */
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
lv_indev_drv_register(&indev_drv);
ui_init();
}
ledcSetup(0,50,8);
ledcAttachPin(GFX_BL, 0);
}
void loop()
{
lv_timer_handler(); /* let the GUI do its work */
delay(5);
if (millis() >= timeRef + delai) {
tr = (comptageImpuls / 2) * 240;
angle = map(tr, 0, 8000, 0, 2370);
comptageImpuls = 0;
timeRef = millis();
}
if (millis() >= timeRef1 + delai1) {
int16_t adc0, adc1, adc2, adc3;
adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
temp2 = map(adc1,32767, 0, -10, 110);
temp = map(adc0,30912, 9502, -30, 50);
char buff[7];
char buff2[7];
sprintf(buff, "%d °C", temp);
sprintf(buff2, "%d °C", temp2);
lv_label_set_text(ui_ext, buff);
lv_label_set_text(ui_tmot, buff2);
if(adc0 > 1000){
ledcWrite(0, 200);
}else{
ledcWrite(0, 70);
}
timeRef1 = millis();
}
incremente();
}
void incremente(){
if (angle < oldangle - 10){
newangle = oldangle - 20;
oldangle = newangle;
}
if (angle > oldangle + 10){
newangle = oldangle + 20;
oldangle = newangle;
}
if(newangle < -256){ newangle = -256;}
if(newangle > 2000){ newangle = 2000;}
lv_img_set_angle(ui_needle, newangle);
}
je ne trouve rien nul part ou alors j'ai pas bien cherché.
Avez-vous une idée?