/* Programmed and tested with: Arduino IDE 1.8.19 & avr-gcc 13.2.0 30.10.2023 License: GNU GPLv3 https://www.mikrocontroller.net/topic/560008#7519958 https://www.mikrocontroller.net/topic/560008#7520003 */ #pragma once #include #include "MyFRAM_I2C.h" namespace MY_FRAMCONTROL { consteval uint32_t sizeofObject (const auto &data) { return sizeof(data); } consteval uint32_t lengthStructure (const auto &data, const size_t N) { return sizeofObject(data)/N; } constinit uint8_t TWI_BUFFER_SIZE {BUFFER_LENGTH-2}; // 'BUFFER_LENGTH' in twi.h abzüglich 2 Bytes Speicherzellenadressierung } /* I2C Addr | wire0/wire1 | | Capacity in kBit | | | Object for length determination etc. | | | | initial address of object in FRAM | | | | | */ template class MyFramControl { }; // allg. Template template class MyFramControl // array Template Spezialisierung { static_assert((10<=BUFFER_LENGTH), "TWI buffer size smaller than 10 is possible but not practical, Wire src twi.h" ); static_assert(((initObjAddr+sizeof(myObj)) < (1024UL*memorySize/8)), "Object to large or Addr to high" ); private: MyFRAM_I2C fram; public: MyFramControl() = default; uint8_t isConnected (void) { return fram.isConnected(); } void readTo (T(&otherObj)[N]) { fram.read(initObjAddr, otherObj); } }; // --- Programmcode: --------------------------------------------------------------------------------------- #include #include TwoWire &wire0 {Wire}; struct Daten { uint16_t left {}; uint16_t right {}; uint16_t last {}; const char name [12] {'\0'}; }; Daten obj0 { 1311, 1611, 1501, "Weiche.A" }; constexpr uint16_t FRAM_INITIAL_ADDR {500}; /* I2C Addr | wire0/wire1 | | Capacity in kBit | | | Object for the data processing | | | | initial address of object in FRAM | | | | | */ MyFramControl <0x57, wire0, 64, obj0, FRAM_INITIAL_ADDR> controlObj0; void setup() { Wire.begin(); controlObj0.isConnected(); } void loop (void) { } // --- Fehlermeldung: --------------------------------------------------------------------------------------- \Example_FramControl_Lib_Error.ino: In function 'void setup()': Example_FramControl_Lib_Error:35:15: error: 'class MyFramControl<87, Wire, 64, obj0, 500>' has no member named 'isConnected' 35 | controlObj0.isConnected(); | ^~~~~~~~~~~ exit status 1 'class MyFramControl<87, Wire, 64, obj0, 500>' has no member named 'isConnected'