LOCODUINO

Parlons Arduino => Vos projets => Discussion démarrée par: Matou le avril 04, 2021, 08:05:00 pm

Titre: Une alimentation analogique de base et une proposition de structure de classes
Posté par: Matou le avril 04, 2021, 08:05:00 pm
Bonjour,

Je suis débutant en Arduino avec une vie professionnelle -terminée- en informatique (pas en électronique).
Pour commencer, je me suis lancé dans la réalisation d'une alimentation analogique pilotée par un Uno.
J'ai écrit une structure de classes pour les entrées-sorties dans le but de simplifier les boucles loop (et setup).
Une classe mère virtuelle pure EntreeSortie impose trois méthodes à toutes ses dérivées : print_config(), setup() et update().
La classe EntreesSorties (au pluriel) n'est qu'une liste chaînée d'EntreeSortie et ses méthodes ne servcent qu'à appeller la méthode correspondante de chacun
des objets de la liste.
La méthode print_config() permet d'afficher la configuration de chaque objet de la liste. Cela sert à avoir un affichage de l'usage des broches par un programme.
Il est pratique de l'invoquer au démarrage du programme. L'usage me dira si c'est réellement utile ou pas...
Les méthodes setup() et update() sont plus classiques. Avec cette structure, le programme principal devient plus simple.
Je joins les documentations et programmes dans leur état actuel. N'hésitez pas à les utiliser si vous pensez que cela peut vous servir.

Mon alimentation fonctionne actuellement en montage "volant sur table", je l'utilise pour faire rouler une locomotive sur un bout de voie de 2 mètres et demi de long. C'est encore très embrionaire, mais il faut un -second- début à tout.
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: Dominique le avril 05, 2021, 09:34:24 am
Bonjour,

C’est très intéressant pour faire rouler des trains analogiques.

J’ai vu les classes, mais, sauf erreur, je n’ai pas trouvé le programme complet qui les utilise.

Bon week-end.
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: bobyAndCo le avril 05, 2021, 10:50:10 am
Oui, il manque un main ou un .ino ???
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: Matou le avril 05, 2021, 12:04:30 pm
Effectivement, le programme principal n'est ni un cpp, ni un h, j'avais zappé cela. Je répare mon oubli et je mets aussi le schéma en format PDF, car tout le monde n'a pas Kicad.
Et je demande humblement à être excusé.
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: bobyAndCo le avril 05, 2021, 03:21:13 pm
J'ai pas mal d'erreurs de complilation !!!

Arduino : 1.8.13 (Mac OS X), Carte : "Arduino Uno"
/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/christophe/Library/Arduino15/packages -hardware /Users/christophe/Documents/Arduino/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/christophe/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/christophe/Documents/Arduino/libraries -fqbn=arduino:avr:uno -ide-version=10813 -build-path /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676 -warnings=default -build-cache /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_cache_675639 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -verbose /Users/christophe/Downloads/Alimentation_CC (1)/Alim_analogique/Alim_analogique.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/christophe/Library/Arduino15/packages -hardware /Users/christophe/Documents/Arduino/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/christophe/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/christophe/Documents/Arduino/libraries -fqbn=arduino:avr:uno -ide-version=10813 -build-path /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676 -warnings=default -build-cache /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_cache_675639 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -verbose /Users/christophe/Downloads/Alimentation_CC (1)/Alim_analogique/Alim_analogique.ino
Using board 'uno' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
Using core 'arduino' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
Detecting libraries used...
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/Alim_analogique.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for LinkedList.h: [LinkedList@1.2.3]
ResolveLibrary(LinkedList.h)
  -> candidates: [LinkedList@1.2.3]
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/Alim_analogique.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE

Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: bobyAndCo le avril 05, 2021, 03:23:31 pm
Suite car dépasse la taille :

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/EntreeAnalog.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/EntreeDiscretisee.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/EntreeNumerique.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/EntreeSortie.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/EntreesSorties.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/InterpoLin.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/LCD_MG.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/Led_MG_256.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/Led_MG_256_Cligno.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/Led_MG_Bin.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -

Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: Matou le avril 05, 2021, 03:23:40 pm
J'ai l'impression qu'il faut ajouter la librairie LinkedList. Effectivement, je l'avais fait, sans la mettre d
ans mes sources.
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: bobyAndCo le avril 05, 2021, 03:24:55 pm
I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/LiquidCrystal.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/MoteurCC_L298N.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/Servo_MG.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for Servo.h: [ESP32_Arduino_Servo_Library@1.0.1 ServoESP32@1.0.3 Servo@1.1.6 Servo@1.1.7]
ResolveLibrary(Servo.h)
  -> candidates: [ESP32_Arduino_Servo_Library@1.0.1 ServoESP32@1.0.3 Servo@1.1.6 Servo@1.1.7]
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList -I/Users/christophe/Documents/Arduino/libraries/Servo/src /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/Servo_MG.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList -I/Users/christophe/Documents/Arduino/libraries/Servo/src /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/VMA323.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList -I/Users/christophe/Documents/Arduino/libraries/Servo/src /Users/christophe/Documents/Arduino/libraries/Servo/src/avr/Servo.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList -I/Users/christophe/Documents/Arduino/libraries/Servo/src /Users/christophe/Documents/Arduino/libraries/Servo/src/mbed/Servo.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList -I/Users/christophe/Documents/Arduino/libraries/Servo/src /Users/christophe/Documents/Arduino/libraries/Servo/src/megaavr/Servo.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList -I/Users/christophe/Documents/Arduino/libraries/Servo/src
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: bobyAndCo le avril 05, 2021, 03:25:41 pm
J'ai l'impression qu'il faut ajouter la librairie LinkedList. Effectivement, je l'avais fait, sans la mettre d
ans mes sources.

Non je l'ai bien téléchargée !
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: bobyAndCo le avril 05, 2021, 03:26:33 pm
/Users/christophe/Documents/Arduino/libraries/Servo/src/nrf52/Servo.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList -I/Users/christophe/Documents/Arduino/libraries/Servo/src /Users/christophe/Documents/Arduino/libraries/Servo/src/sam/Servo.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList -I/Users/christophe/Documents/Arduino/libraries/Servo/src /Users/christophe/Documents/Arduino/libraries/Servo/src/samd/Servo.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList -I/Users/christophe/Documents/Arduino/libraries/Servo/src /Users/christophe/Documents/Arduino/libraries/Servo/src/stm32f4/Servo.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Generating function prototypes...
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/christophe/Documents/Arduino/libraries/LinkedList -I/Users/christophe/Documents/Arduino/libraries/Servo/src /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/sketch/Alim_analogique.ino.cpp -o /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/preproc/ctags_target_for_gcc_minus_e.cpp -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /var/folders/wr/n541lv754tnb27lc3_w3pr7r0000gn/T/arduino_build_122676/preproc/ctags_target_for_gcc_minus_e.cpp
Compilation du croquis...

Erreur de compilation pour la carte Arduino Uno
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: Matou le avril 05, 2021, 03:29:02 pm
J'ai aussi Servo_MG qui utilise Servo. Servo_MG n'est pas utilisé dans ce projet, mais est présent dans les sources. Serait-ce la raison ?
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: bobyAndCo le avril 05, 2021, 03:31:27 pm
J'ai bien un problème avec LinkedList. L'exemple donné avec la biblio ne compile pas non plus !


In file included from /Users/christophe/Documents/Arduino/libraries/LinkedList/examples/ClassList/ClassList.pde:12:0:
/Users/christophe/Documents/Arduino/libraries/LinkedList/LinkedList.h: In instantiation of 'ListNode<T>* LinkedList<T>::getNode(int) [with T = Animal*]':
/Users/christophe/Documents/Arduino/libraries/LinkedList/LinkedList.h:314:28:   required from 'T LinkedList<T>::get(int) [with T = Animal*]'
/Users/christophe/Documents/Arduino/libraries/LinkedList/examples/ClassList/ClassList.pde:65:30:   required from here
/Users/christophe/Documents/Arduino/libraries/LinkedList/LinkedList.h:160:9: error: cannot convert 'bool' to 'ListNode<Animal*>*' in return
  return false;
         ^~~~~
Utilisation de la bibliothèque LinkedList version 1.2.3 dans le dossier: /Users/christophe/Documents/Arduino/libraries/LinkedList
exit status 1
Erreur de compilation pour la carte Arduino Uno
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: bobyAndCo le avril 05, 2021, 03:37:47 pm
Cette librairie n'a eu aucun update depuis 2 ans ! le problème a été reporté sur le Git en février 2020 mais aucun correctif depuis !
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: Matou le avril 05, 2021, 03:42:58 pm
Effectivement, j'ai une note dans un fichier :
LinkedList modification : remplacement de false par NULL en ligne 160 de LinkedList.h
J'ai donc dû avoir cette erreur au tout début, te je l'ai contournée avec ce changement.
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: AmadeusHF le avril 05, 2021, 03:49:00 pm
Le code compile en corrigeant l'erreur de la lib : return NULL; au lieu de return false;
Il y a une autre erreur dans votre code :

Votre fonction setup() appelle DebutEtatInit() à la dernière ligne.

Or dans votre source, la fonction DebutEtatInit() est définie APRES le code de setup()

Au moment de compiler setup() le compilateur ne connait pas le symbole DebutEtatInit() et ça pose probleme.
L'ordre d'écriture des fonctions dans un source, en compilation stricte, a une importance, aussi je vous invite à corriger cette erreur.

Une fois ces deux points réglés j'arrive à compiler de mon coté (mais il reste beaucoup de warnings inquiétants....)

5:43:06 Build Finished. 0 errors, 32 warnings. (took 2s.519ms)
Au délà de ces remarques, prenez en compte que l'utilisation dynamique de la mémoire n'est pas spécialement une bonne idée sur un "petit arduino". Avec ses 2 Ko de RAM, un NANO / UNO ne dispose que de très peu d'espace, qu'il doit consacrer à la pile et au "heap".

La fragmentation de ce dernier intervient rapidement et sans un peu d'air, le heap manager n'est pas capable de gérer.

L'utilisation de structures complexes utilisant beaucoup de pointeurs amène à une consommation de mémoire supplémentaire pour les liaisons inter-objets qui vient rapidement à bout de ce faible espace mémoire.

J'ai moi-même éprouvé cette limite récemment : une partie de code que j'avais écrite, qui utilisait des structures très dynamiques, fonctionnait bien sur MEGA (8 Ko de RAM) mais venait rapidement à bout d'un UNO, non parce que je consommais trop de données, mais parce que les allocations / suppression d'objets aboutissaient rapidement à un heap fragmenté saturé. Je n'avais pas ce problème sur le MEGA, et pourtant mon usage global de la RAM restait sous la barre des 1.5 Ko.

A voir si l'usage de structures telles que des listes chaînées est opportune pour votre code...S'il s'agit de stocker peu d'objets, un tableau a peu près bien dimensionné est peut-être préférable.
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: Matou le avril 05, 2021, 03:55:03 pm
Ce code compile avec l'IDE Arduino chez moi (je suis sous Linux). Il y a peut-être des options de compilations différentes, je suis d'accord que la référence en avant, ce n'est pas bon.
Pour la liste chaînée, oui, la remplacer par un bon vieux tableau ne serait pas un problème, sa souplesse n'a rien d'indispensable.
Je ne fais pas d'allocation-libération dans le fonctionnement, seulement à l'init. Je suis d'accord que ce serait une mauvaise chose en général pour ce type de code.

Je vais donc revoir ces points. Je republierai l'ensemble, mais je ne sais pas quand, car j'ai en ce moment d'autres occupations que je ne devrais pas négliger, même pour un projet qui me passionne... La récréation ne doit pas être plus longue que les cours !
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: Matou le avril 05, 2021, 03:57:39 pm
Point important que je n'ai pas écrit dans ma réponse précédente : MERCI pour cette relecture, cela fait toujours du bien au code d'être relu par quelqu'un d'autre.
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: AmadeusHF le avril 05, 2021, 04:03:06 pm
Pas de problème pour un coup d'oeil (quand je peux).

Gardez simplement en tete que les "réflexes" de la programmation moderne ne sont pas nécessairement les bons en programmation embarquée, qui plus est sur un CPU aussi limité que celui d'un Arduino.

L'informatique "actuelle" a une (très facheuse) tendance à être sur-consommatrice de ressources : je rencontre tous les jours de jeunes développeurs qui incriminent systématiquement le matériel lorsqu'un programme est "trop lent", sans même se demander si leur code est ne serais-ce qu'acceptable.

Un environnement contraint comme l'Arduino nous ramène quelques (bonnes dizaines) d'années en arrière de ce point de vue. La programmation Objet est, en ce qui me concerne, un "must have" par rapport à une approche structurée de 3ème génération (C,....) Mais il reste vrai que le coup en mémoire des VTABLES d'une hiérarchie d'objets coutent cher, à l'échelle des 2Ko de notre pauvre Atmega 328 ;)
Titre: Re : Une alimentation analogique de base et une proposition de structure de classes
Posté par: Matou le avril 05, 2021, 07:39:27 pm
J'ai remplacé la liste chaînée par un tableau statique de 20 éléments. Il n'est même pas dimensionné dynamiquement.
Donc il y a environ 1500 octets de programme en moins, et les liens de la liste ne se créeront pas lors de l'initialisation.
J'ai supprimé les raisons des warnings (des const qui manquaient et un unsigned inutile)
J'ai renommé les méthodes update() en loop() dans les classes dérivées d'EntreeSortie, puisqu'elles sont appelées lors de l'appel à loop().
J'ai mis dans la méthode print_config') d'EntreesSorties (le fameux gestionnaire du tableau des EntreeSortie's) l'impression du nombre d'éléments. Comme cela, on peut écrire le programme, puis redimensionner à ce qui est nécessaire. De même, s'il est sous-dimensionné, on verra ce nombre apparaître avant le crash inévitable. Je n'ai pas mis de test de débordement, mais si c'était utile, ce serait facile.

Donc encore une fois merci pour les commentaires, c'est aussi le plaisir de partager.