Bonjour,

je sollicite votre aide sur une erreur dont je ne connais pas la signification :
dans ce petit programme test dont le but est d'afficher une valeur à l'aide d'un KY-040 -"Rotary encoder module"
et d'en faire le choix entre 3,4 ou 5


lvalue required as left operand of assignment

elle se produit à la ligne :

NUMBER=5;
fonction : void initNBLetter()

merci par avance
pascal



Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
 
//**********************************///
// ESP32 TTGO Lora OLED V1
//*********************************////
 
#include "FS.h"
#include "SPIFFS.h"
#define FORMAT_SPIFFS_IF_FAILED true
#include <TFT_eSPI.h>
#include <SPI.h>
#include "Free_Fonts.h"
#include <AiEsp32RotaryEncoder.h>
 
#define NUMBER 0
#define TFT_WIDTH 135
#define TFT_HEIGHT 240
#define BUTTON_1 35
#define BUTTON_2 0
TFT_eSPI tft = TFT_eSPI(TFT_WIDTH, TFT_HEIGHT);
 
const char wordFile[] = "";
 
 
#define ROTARY_ENCODER_A_PIN 33
#define ROTARY_ENCODER_B_PIN 32
#define ROTARY_ENCODER_BUTTON_PIN 25
#define ROTARY_ENCODER_STEPS 4
AiEsp32RotaryEncoder rotaryEncoder = AiEsp32RotaryEncoder(ROTARY_ENCODER_A_PIN, ROTARY_ENCODER_B_PIN, ROTARY_ENCODER_BUTTON_PIN, -1, ROTARY_ENCODER_STEPS);
void IRAM_ATTR readEncoderISR()
{
rotaryEncoder.readEncoder_ISR();
}
 
void initTFT() {
  // Prepare the display
  tft.begin();
  tft.fillScreen (TFT_BLACK);
  tft.setRotation(0);
}
void initNBLetter()
{
tft.setTextDatum(TC_DATUM);
tft.setFreeFont(FSSB12);
int h = 20;
int d = 5;
char letter;
    while (not rotaryEncoder.isEncoderButtonClicked()) {
      if (rotaryEncoder.encoderChanged()) {
      letter = rotaryEncoder.readEncoder();
      // display letter
      tft.fillRect(0, TFT_HEIGHT - 63, TFT_WIDTH, 63, TFT_BLACK);
      int y = (h + 3 * d);
      int x = (h + d) + 3;
      tft.fillRect(x, y, h + d, h + d, TFT_ORANGE);
      tft.drawRect(x, y, h + d, h + d, TFT_BLUE);
      tft.setCursor(x + h / 4, y + h);
      tft.setTextColor(TFT_WHITE);
      tft.print(letter);
      }
    }
 
    if (letter == 51) { 
    NUMBER=3;
      const char wordFile[] = "fichier3.txt";
    }
     if (letter == 52) { 
      NUMBER=4;
      const char wordFile[] = "fichier4.txt";
    }
     if (letter == 53) { 
      NUMBER=5;                                         <========================
      const char wordFile[] = "fichier5.txt";
    }
}
 
  //*************************************************
// SETUP
//*************************************************
 
void setup ()
{
 
  //***********************************************
  rotaryEncoder.begin();
  rotaryEncoder.setup(readEncoderISR);
  rotaryEncoder.setBoundaries(51, 53, true);
  //***********************************************  
  Serial.begin (115200);
  initTFT();
  if (!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)) {
    Serial.println("Échec du montage du SPIFFS");
    return;
  }
  // valider le nb de lettres
  initNBLetter();
  File file = SPIFFS.open(wordFile);
  if (!file || file.isDirectory()) {
    Serial.printf("%s: Impossible d'ouvrir le fichier pour la lecture\n", wordFile);
    //  while (1);
  }
 
}
 
//*************************************************
// LOOP
//*************************************************
 
void loop() {
 
}