MAX6675 Wrapping Class-based Arduino Libraries

dear friends,
I try to Wrapping Class-based Arduino Libraries for max6675

the code I used is
///////////////////////////////////////////////////////////////////

    // Tell XOD where it could download the library:
    #pragma XOD require "https://github.com/adafruit/MAX6675-library"
    
    //Include C++ libraries
    {{#global}}
    #include <max6675.h>
    {{/global}}
    
    struct State {
       uint8_t mem[sizeof(MAX6675)];
    };
    
    
    using Type = MAX6675*;
    
    
    {{ GENERATED_CODE }}
     static_assert(isValidDigitalPort(constant_input_CS), "must be a valid digital port");
     static_assert(isValidDigitalPort(constant_input_DO), "must be a valid digital port");
     static_assert(isValidDigitalPort(constant_input_CLK), "must be a valid digital port");
    MAX6675 dev =MAX6675 (constant_input_CLK ,constant_input_CS,constant_input_DO);
    void evaluate(Context ctx) {
        auto state = getState(ctx);
    
      
        Type sensor = new (state->mem) MAX6675();
    
         if (!isInputDirty<input_UPD>(ctx))
            return;
    
        emitValue<output_Temp>(ctx, sensor->readCelsius());
        emitValue<output_DONE>(ctx, 1);
    
    }
`

///////////////////////////////////////////////////////////////////////

i got an error like 

> Begin compiling code for the board Arduino Mega or Mega 2560 📦
> 
> 
> C:\Users\dell\AppData\Local\Temp\xod_temp_sketchbookdHVhgn\xod_1603659694078_sketch\xod_1603659694078_sketch.ino:
> In instantiation of 'void
> xod::____max6675_device::Node<constant_input_DO, constant_input_CS,
> constant_input_CLK>::evaluate(xod::____max6675_device::Node<constant_input_DO, constant_input_CS, constant_input_CLK>::Context) [with unsigned char
> constant_input_DO = 4; unsigned char constant_input_CS = 5; unsigned
> char constant_input_CLK = 6;
> xod::____max6675_device::Node<constant_input_DO, constant_input_CS,
> constant_input_CLK>::Context = xod::____max6675_device::Node<4, 5,
> 6>::ContextObject*]':
> C:\Users\dell\AppData\Local\Temp\xod_temp_sketchbookdHVhgn\xod_1603659694078_sketch\xod_1603659694078_sketch.ino:1599:36:
> required from here
> C:\Users\dell\AppData\Local\Temp\xod_temp_sketchbookdHVhgn\xod_1603659694078_sketch\xod_1603659694078_sketch.ino:1214:23:
> error: no matching function for call to 'MAX6675::MAX6675()'
>          Type sensor = new (state->mem) MAX6675();
>                        ^~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from
> C:\Users\dell\AppData\Local\Temp\xod_temp_sketchbookdHVhgn\xod_1603659694078_sketch\xod_1603659694078_sketch.ino:1066:0:
> C:\Users\dell\AppData\Local\Temp\xod_temp_sketchbookdHVhgn\libraries\MAX6675_library/max6675.h:16:3:
> note: candidate: MAX6675::MAX6675(int8_t, int8_t, int8_t)   
> MAX6675(int8_t SCLK, int8_t CS, int8_t MISO);    ^~~~~~~
> C:\Users\dell\AppData\Local\Temp\xod_temp_sketchbookdHVhgn\libraries\MAX6675_library/max6675.h:16:3:
> note:   candidate expects 3 arguments, 0 provided
> C:\Users\dell\AppData\Local\Temp\xod_temp_sketchbookdHVhgn\libraries\MAX6675_library/max6675.h:14:7:
> note: candidate: constexpr MAX6675::MAX6675(const MAX6675&)  class
> MAX6675 {
>        ^~~~~~~ C:\Users\dell\AppData\Local\Temp\xod_temp_sketchbookdHVhgn\libraries\MAX6675_library/max6675.h:14:7:
> note:   candidate expects 1 argument, 0 provided
> C:\Users\dell\AppData\Local\Temp\xod_temp_sketchbookdHVhgn\libraries\MAX6675_library/max6675.h:14:7:
> note: candidate: constexpr MAX6675::MAX6675(MAX6675&&)
> C:\Users\dell\AppData\Local\Temp\xod_temp_sketchbookdHVhgn\libraries\MAX6675_library/max6675.h:14:7:
> note:   candidate expects 1 argument, 0 provided
> 
> Error during build: exit status 1 Compilation failed Command Process
> exited with code 1 The generated C++ code contains errors. It can be
> due to a bad node implementation or if your board is not compatible
> with XOD runtime code. The original compiler error message is above.
> Fix C++ errors to continue. If you believe it is a bug, report the
> problem to XOD developers.

It is saying the error is on this line

Type sensor = new (state->mem) MAX6675();

It wants an argument for the function call at the end.

hi, thanks for your reply, what do you suggest me to do?
I’m not good in c++

Fixing the problem is much harder than finding it in this case… I haven’t done a lot with C++, but that line looks odd to me with new in front of a function call. Sorry I can’t help much more than that.

Hi Ahmed,

Try your luck with this library:

I don’t have a MAX6675, so I haven’t been able to test my library, but it does compile.

I saw that you were using the old style C++ syntax, so I thought it was easier to make a fresh start.

1 Like

Thank you very much, it is working but have a very small problem in XOD when I use the watch to show the result.
in the serial monitor, there is no problem.

thank you again

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.