diff --git a/lib/PCA9685-Arduino b/lib/PCA9685-Arduino index a70be39..23e06c0 160000 --- a/lib/PCA9685-Arduino +++ b/lib/PCA9685-Arduino @@ -1 +1 @@ -Subproject commit a70be39257e317d35e9118b385006a1e030e6452 +Subproject commit 23e06c06a6026801a856141f64a6de54dd493b47 diff --git a/lib/treppe/FSMTreppe2/FSMTreppe2.cpp b/lib/treppe/FSMTreppe2/FSMTreppe2.cpp index c4eef07..11ae2c3 100644 --- a/lib/treppe/FSMTreppe2/FSMTreppe2.cpp +++ b/lib/treppe/FSMTreppe2/FSMTreppe2.cpp @@ -16,18 +16,19 @@ // Code generation objectives: Unspecified // Validation result: Not run // -#include "FSMTreppe.h" -#include "FSMTreppe_private.h" +#include "FSMTreppe2.h" +// #include "FSMTreppe_private.h" +#include // Named constants for Chart: '/FSMTreppe' -const uint8_T FSMTreppe_IN_abdimmen_hoch = 1U; -const uint8_T FSMTreppe_IN_abdimmen_runter = 2U; -const uint8_T FSMTreppe_IN_aufdimmen_hoch = 3U; -const uint8_T FSMTreppe_IN_aufdimmen_runter = 4U; -const uint8_T FSMTreppe_IN_inaktiv = 5U; -const uint8_T FSMTreppe_IN_ruhezustand = 6U; -const uint8_T FSMTreppe_IN_warten_hoch = 7U; -const uint8_T FSMTreppe_IN_warten_runter = 8U; +const uint8_t FSMTreppe_IN_abdimmen_hoch = 1U; +const uint8_t FSMTreppe_IN_abdimmen_runter = 2U; +const uint8_t FSMTreppe_IN_aufdimmen_hoch = 3U; +const uint8_t FSMTreppe_IN_aufdimmen_runter = 4U; +const uint8_t FSMTreppe_IN_inaktiv = 5U; +const uint8_t FSMTreppe_IN_ruhezustand = 6U; +const uint8_t FSMTreppe_IN_warten_hoch = 7U; +const uint8_t FSMTreppe_IN_warten_runter = 8U; // Model step function void FSMTreppeModelClass::step() @@ -39,7 +40,7 @@ void FSMTreppeModelClass::step() // Inport: '/sensor_unten' if (FSMTreppe_DW.temporalCounter_i1 < 511U) { - FSMTreppe_DW.temporalCounter_i1 = static_cast + FSMTreppe_DW.temporalCounter_i1 = static_cast (FSMTreppe_DW.temporalCounter_i1 + 1U); } diff --git a/lib/treppe/FSMTreppe2/FSMTreppe2.h b/lib/treppe/FSMTreppe2/FSMTreppe2.h index 33af230..17eb042 100644 --- a/lib/treppe/FSMTreppe2/FSMTreppe2.h +++ b/lib/treppe/FSMTreppe2/FSMTreppe2.h @@ -18,8 +18,8 @@ // #ifndef RTW_HEADER_FSMTreppe_h_ #define RTW_HEADER_FSMTreppe_h_ -#include "rtwtypes.h" -#include "FSMTreppe_types.h" + +#include // Macros for accessing real-time model data structure #ifndef rtmGetErrorStatus @@ -36,29 +36,29 @@ class FSMTreppeModelClass { public: // Block states (default storage) for system '' struct DW_FSMTreppe_T { - uint16_T temporalCounter_i1; // '/FSMTreppe' - uint8_T is_active_c3_FSMTreppe; // '/FSMTreppe' - uint8_T is_c3_FSMTreppe; // '/FSMTreppe' + uint16_t temporalCounter_i1; // '/FSMTreppe' + uint8_t is_active_c3_FSMTreppe; // '/FSMTreppe' + uint8_t is_c3_FSMTreppe; // '/FSMTreppe' }; // External inputs (root inport signals with default storage) struct ExtU_FSMTreppe_T { - boolean_T sensor_unten; // '/sensor_unten' - boolean_T sensor_oben; // '/sensor_oben' - boolean_T anim_beendet; // '/anim_beendet' - real_T ldr_schwelle; // '/ldr_schwelle' + bool sensor_unten; // '/sensor_unten' + bool sensor_oben; // '/sensor_oben' + bool anim_beendet; // '/anim_beendet' + double ldr_schwelle; // '/ldr_schwelle' }; // External outputs (root outports fed by signals with default storage) struct ExtY_FSMTreppe_T { - uint8_T laufrichtung; // '/laufrichtung' - uint8_T status; // '/status' - uint8_T dimmrichtung; // '/dimmrichtung' + uint8_t laufrichtung; // '/laufrichtung' + uint8_t status; // '/status' + uint8_t dimmrichtung; // '/dimmrichtung' }; // Real-time Model Data Structure struct RT_MODEL_FSMTreppe_T { - const char_T * volatile errorStatus; + const char * volatile errorStatus; }; // model initialize function diff --git a/lib/treppe/treppe.cpp b/lib/treppe/treppe.cpp index 4d7b858..46de158 100644 --- a/lib/treppe/treppe.cpp +++ b/lib/treppe/treppe.cpp @@ -158,20 +158,18 @@ void Treppe::print_state_on_change() { static FSMTreppeModelClass::ExtU_FSMTreppe_T last_in; static FSMTreppeModelClass::ExtY_FSMTreppe_T last_out; if( - fsm_inputs.anim_finished != last_in.anim_finished || + fsm_inputs.anim_beendet != last_in.anim_beendet || fsm_inputs.sensor_oben != last_in.sensor_oben || - fsm_inputs.sensor_unten != last_in.sensor_unten || - fsm_outputs.anim_active != last_out.anim_active + fsm_inputs.sensor_unten != last_in.sensor_unten ) { - last_in.anim_finished = fsm_inputs.anim_finished; + last_in.anim_beendet = fsm_inputs.anim_beendet; last_in.sensor_oben = fsm_inputs.sensor_oben; last_in.sensor_unten = fsm_inputs.sensor_unten; - last_out.anim_active = fsm_outputs.anim_active; Serial.printf("FSM inputs: s_u: %d, s_o: %d, an_fin: %d =>", - fsm_inputs.sensor_oben, fsm_inputs.sensor_unten, fsm_inputs.anim_finished); + fsm_inputs.sensor_oben, fsm_inputs.sensor_unten, fsm_inputs.anim_beendet); Serial.print(" step => "); - Serial.printf("FSM outputs: an_act: %d\n", fsm_outputs.anim_active); + Serial.printf("FSM outputs: LR: %d DR: %d ST: %d\n", fsm_outputs.laufrichtung, fsm_outputs.dimmrichtung, fsm_outputs.status); } } @@ -185,13 +183,16 @@ void Treppe::task(){ fsm_inputs.sensor_oben = read_sensor(SENSOR_OBEN); fsm_inputs.sensor_unten = read_sensor(SENSOR_UNTEN); - fsm_inputs.anim_finished = static_cast(finish); + fsm_inputs.anim_beendet = static_cast(finish); FSMTreppe_Obj.setExternalInputs(&fsm_inputs); FSMTreppe_Obj.step(); fsm_outputs = FSMTreppe_Obj.getExternalOutputs(); print_state_on_change(); + direction = fsm_outputs.laufrichtung; + state = fsm_outputs.dimmrichtung; + // setTick(ticks_treppe); // setAnAus(1); // setDirection(0); diff --git a/lib/treppe/treppe.h b/lib/treppe/treppe.h index 448bb15..83895d3 100644 --- a/lib/treppe/treppe.h +++ b/lib/treppe/treppe.h @@ -1,6 +1,6 @@ #pragma once -#include "FSMTreppe/FSMTreppe.h" +#include "FSMTreppe2/FSMTreppe2.h" #include "PCA9685.h" #define SENSOR_OBEN 2 @@ -21,7 +21,7 @@ private: uint8_t switch_direction = 0; uint8_t state = 0; uint8_t switch_state = 0; - uint8_t finish = 1; + bool finish = 1; // alternative uint32_t tick = 0;