aikopras / AP_DCC_library

Arduino library for (NMRA) Digital Command Control (DCC) messages. Primarily intended for accessory and function Decoders. Based on OpenDecoder 2 software. Source code includes many comments.
GNU General Public License v3.0
10 stars 4 forks source link

use AP_DCC_library under platformIO: some issue to fix? #2

Closed LaurentR59 closed 1 year ago

LaurentR59 commented 2 years ago

Hi now i m trying to use the lib under platformIO Get some troubles ( quite normal for newbie!)

You have define #include on sup_isr_MegaCoreX_DxCore.h file Anyway should probably add to the file/librarie too? or did i miss something?

trying to use this tools but s not easy to perform it!

I put as exemple Loco-Serial_monitor code into main.cpp file. AP_DCC_lib is under lib folder

Compile bug at this step ... Compiling .pio\build\ATmega4808\lib300\AP_DCC_Library\sup_loco.cpp.o Compiling .pio\build\ATmega4808\FrameworkArduino\CDC.cpp.o In file included from lib\AP_DCC_Library\src\sup_isr.cpp:44:0: lib\AP_DCC_Library\src\sup_isr_MegaCoreX_DxCore.h: In member function 'void DccMessage::initEventSystem(uint8_t)': lib\AP_DCC_Library\src\sup_isr_MegaCoreX_DxCore.h:182:27: error: 'assign_generator_pin' is not a member of 'Event' Event& myEvent = Event::assign_generator_pin(dccPin); ^~~~~~~~ lib\AP_DCC_Library\src\sup_isr_MegaCoreX_DxCore.h:193:28: error: 'tcb0_capt' is not a member of 'user' myEvent.set_user(user::tcb0_capt); ^~~~~ lib\AP_DCC_Library\src\sup_isr_MegaCoreX_DxCore.h:193:28: note: suggested alternative: In file included from lib\AP_DCC_Library\src\sup_isr_MegaCoreX_DxCore.h:54:0, from lib\AP_DCC_Library\src\sup_isr.cpp:44: C:\Users\laure.platformio\packages\framework-arduino-megaavr-megacorex\libraries\Event\src/Event.h:35:5: note: 'tcb0_capt' tcb0_capt = 0xA0, ^~~~~ *** [.pio\build\ATmega4808\lib300\AP_DCC_Library\sup_isr.cpp.o] Error 1

What did i miss?

Laurent

LaurentR59 commented 2 years ago

As add on I tried to use ATmega4808 cpu in platforio.ini ==>compile bug when i set board = nano_every that s OK it compiles sucessfully!

not yet identifed why and how to fix that.

Any idea?

aikopras commented 2 years ago

Dear Laurent

I have no experience with PlatformIO, but the 'assign_generator_pin' error sounds to me like the same error as you previously had: old (outdated) Event Lib code is being used. So please check which library files the compiler really use, and make sure that they are the correct (is latest) event libs.

Regarding your #include question and that your code runs when you chose 'board = nano_every', please take a look at the file "sup_isr.cpp". In that file you can see that, depending on the board and processor being used, different files are included so code is being executed. The goal of these different files is to capture individual bits from the input pin, by taking advantage of the different hardware features of different processors and boards.

For example, the __AVR_XMEGA__ preprocessor variable is set / defined by the MegaCoreX and DxCore boards. Therefore, if your processor is an 4809 and your board is MegaCoreX, the file 'sup_isr_MegaCoreX_DxCore.h' will be used. This file is able to take advantage of the Event Library that is included with the MegaCoreX (and DxCore) boards. But if your processor is an 4809 and your board is the Arduino standard Nano Every (megaAVR ) board, the file 'sup_isr_Nano_Every.h' is being used. That file can not use any events, since the necessary library is not included with the standard Arduino boards.

I hope this helps. Bye, Aiko

LaurentR59 commented 2 years ago

Hello Aiko

Seems to be fixed ( probably updating items + new projects build more focus on ATMEGA480X currently)