Forum: PC Hard- und Software Fehler beim Kompilieren


von ich (Gast)


Lesenswert?

Hallo,

ich bekomme in PlatformIO folgenden Fehler beim Kompilieren:
1
.pio\build\d1_mini\src\main.cpp.o: In function `lcdml_menu_display_h()':
2
main.cpp:(.text._Z20lcdml_menu_display_hv+0x0): multiple definition of `lcdml_menu_display_h()'
3
.pio\build\d1_mini\src\display_utils.cpp.o:display_utils.cpp:(.text._Z20lcdml_menu_display_hv+0x0): first defined here
4
5
6
.pio\build\d1_mini\src\main.cpp.o: In function `lcdml_menu_clear_h()':
7
main.cpp:(.text._Z18lcdml_menu_clear_hv+0x0): multiple definition of `lcdml_menu_clear_h()'
8
.pio\build\d1_mini\src\display_utils.cpp.o:display_utils.cpp:(.text._Z18lcdml_menu_clear_hv+0x0): first defined here
9
10
11
.pio\build\d1_mini\src\main.cpp.o: In function `lcdml_menu_control_h()':
12
main.cpp:(.text._Z20lcdml_menu_control_hv+0x0): multiple definition of `lcdml_menu_control_h()'
13
.pio\build\d1_mini\src\display_utils.cpp.o:display_utils.cpp:(.text._Z20lcdml_menu_control_hv+0x0): first defined here
14
.pio\build\d1_mini\src\main.cpp.o:(.bss.lcd+0x0): multiple definition of `lcd'
15
.pio\build\d1_mini\src\display_utils.cpp.o:(.bss.lcd+0x0): first defined here
16
.pio\build\d1_mini\src\main.cpp.o:(.bss.LCDML_1+0x0): multiple definition of `LCDML_1'
17
.pio\build\d1_mini\src\display_utils.cpp.o:(.bss.LCDML_1+0x0): first defined here
18
.pio\build\d1_mini\src\main.cpp.o:(.bss.LCDML+0x0): multiple definition of `LCDML'
19
.pio\build\d1_mini\src\display_utils.cpp.o:(.bss.LCDML+0x0): first defined here

CPU: ESP8266

display.h
1
#ifndef DISPLAY_H
2
#define DISPLAY_H
3
4
#include <Arduino.h>
5
#include "config.h"
6
#include <LCDMenuLib2.h> //  https://github.com/ich423/LCDMenuLib2.git 
7
#include <Wire.h>
8
#include <LiquidCrystal_I2C.h>
9
10
extern void(*ptr_lcdml_menu_display)();
11
extern void(* ptr_lcdml_menu_clear)();
12
extern void(* ptr_lcdml_menu_control)();
13
14
void lcdml_menu_display_h() {
15
    //lcdml_menu_display();
16
}
17
18
void lcdml_menu_clear_h() {
19
    //lcdml_menu_display();
20
}
21
22
void lcdml_menu_control_h() {
23
    //lcdml_menu_display();
24
}
25
26
LiquidCrystal_I2C lcd(0x27, _LCDML_DISP_cols, _LCDML_DISP_rows);
27
LCDMenuLib2_menu LCDML_1(255, 0, 0, NULL, NULL); // root menu element (do not change)
28
LCDMenuLib2 LCDML(LCDML_1, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display_h, lcdml_menu_clear_h, lcdml_menu_control_h);
29
30
class displayUtils {
31
  public:
32
    displayUtils();
33
    
34
};
35
36
#endif

display_utils.cpp (gekürzt)
1
#include <Arduino.h>
2
#include "display.h"
3
#include <LiquidCrystal_I2C.h>
4
#include <LCDMenuLib2.h> //https://github.com/Jomelo/LCDMenuLib2
5
6
7
displayUtils::displayUtils(){
8
}
9
10
// =====================================================================
11
//
12
// Output function
13
//
14
// =====================================================================
15
16
void lcdml_menu_control()
17
{
18
  // If something must init, put in in the setup condition
19
  if(LCDML.BT_setup()) {
20
    // runs only once
21
  }
22
/*
23
  // check if new serial input is available
24
  if (Serial.available()) {
25
    // read one char from input buffer,
26
   switch (Serial.read())
27
    {
28
      case _LCDML_CONTROL_serial_enter:  LCDML.BT_enter(); break;
29
      case _LCDML_CONTROL_serial_up:     LCDML.BT_up();    break;
30
      case _LCDML_CONTROL_serial_down:   LCDML.BT_down();  break;
31
      case _LCDML_CONTROL_serial_left:   LCDML.BT_left();  break;
32
      case _LCDML_CONTROL_serial_right:  LCDML.BT_right(); break;
33
      case _LCDML_CONTROL_serial_quit:   LCDML.BT_quit();  break;
34
      default: break;
35
    }
36
  }*/
37
}
38
39
/* ******************************************************************** */
40
void lcdml_menu_clear()
41
/* ******************************************************************** */
42
{
43
  lcd.clear();
44
  lcd.setCursor(0, 0);
45
}
46
47
/* ******************************************************************** */
48
void lcdml_menu_display()
49
/* ******************************************************************** */
50
{
51
  // update content
52
  // ***************
53
  if (LCDML.DISP_checkMenuUpdate()) {
54
    // clear menu
55
    // ***************
56
    LCDML.DISP_clear();
57
58
    // declaration of some variables
59
    // ***************
60
    // content variable
61
    char content_text[_LCDML_DISP_cols];  // save the content text of every menu element
62
    // menu element object
63
    LCDMenuLib2_menu *tmp;
64
    // some limit values
65
    uint8_t i = LCDML.MENU_getScroll();
66
    uint8_t maxi = _LCDML_DISP_rows + i;
67
    uint8_t n = 0;
68
69
    }
70
  }
71
72
73
  if(LCDML.DISP_checkMenuCursorUpdate())
74
  {
75
    // init vars
76
    uint8_t n_max             = (LCDML.MENU_getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.MENU_getChilds());
77
    uint8_t scrollbar_min     = 0;
78
    uint8_t scrollbar_max     = LCDML.MENU_getChilds();
79
    uint8_t scrollbar_cur_pos = LCDML.MENU_getCursorPosAbs();
80
    uint8_t scroll_pos        = ((1.*n_max * _LCDML_DISP_rows) / (scrollbar_max - 1) * scrollbar_cur_pos);
81
82
    }
83
84
    // display scrollbar
85
    if (_LCDML_DISP_cfg_scrollbar == 1) {
86
      if (scrollbar_max > n_max) {
87
        //set scroll position
88
        if (scrollbar_cur_pos == scrollbar_min) {
89
          // min pos
90
          lcd.setCursor((_LCDML_DISP_cols - 1), 0);
91
          lcd.write((uint8_t)1);
92
        } else if (scrollbar_cur_pos == (scrollbar_max - 1)) {
93
          // max pos
94
          lcd.setCursor((_LCDML_DISP_cols - 1), (n_max - 1));
95
          lcd.write((uint8_t)4);
96
        } else {
97
          // between
98
          lcd.setCursor((_LCDML_DISP_cols - 1), scroll_pos / n_max);
99
          lcd.write((uint8_t)(scroll_pos % n_max) + 1);
100
        }
101
      }
102
    }
103
  }
104
}
105
106
void(* ptr_lcdml_menu_display)() = &lcdml_menu_display;
107
void(* ptr_lcdml_menu_clear)() = &lcdml_menu_clear;
108
void(* ptr_lcdml_menu_control)() = &lcdml_menu_control;

von Jürgen W. (Firma: MED-EL GmbH) (wissenwasserj)


Lesenswert?

Du definierst oben eine Funktion 'lcdml_menu_control_h' und gibst in der 
Funktion 'LCDML' ebendiese Funktion als Datentyp für ein Argument an.
Kann so nicht laufen.

von Jörg W. (dl8dtl) (Moderator) Benutzerseite


Lesenswert?

ich schrieb:

> void lcdml_menu_display_h() {
>     //lcdml_menu_display();
> }

Komplette Funktionsdefinitionen (statt nur Deklarationen) gehören nicht 
in ein Headerfile.

(Ausnahme: "static inline".)

> LiquidCrystal_I2C lcd(0x27, _LCDML_DISP_cols, _LCDML_DISP_rows);

Was soll das denn in einem Headerfile?

Das ist ja weder Definition noch Deklaration, sondern ein 
Funktionsaufruf?!

Der hat dort rein gar nichts zu suchen. Pack sowas an den Anfang von 
main().

> void(* ptr_lcdml_menu_display)() = &lcdml_menu_display;
> void(* ptr_lcdml_menu_clear)() = &lcdml_menu_clear;
> void(* ptr_lcdml_menu_control)() = &lcdml_menu_control;

Globale Variablendefinitionen schreibt man üblicherweise an den Anfang 
einer Datei, nicht ans Ende.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.