@@ -33,9 +33,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
33
33
#define RXSTATE_SENDTXMSG 1
34
34
#define RXSTATE_MSGBODY 2
35
35
#define RXSTATE_DONE 3
36
-
36
+ uint8_t FirstRunFlag = 0 ;
37
37
UART_HandleTypeDef huart1 ;
38
- UART_HandleTypeDef huart2 ;
38
+ UART_HandleTypeDef huart3 ;
39
39
40
40
41
41
#if (DISPLAY_TYPE == DISPLAY_TYPE_KINGMETER_618U )
@@ -456,8 +456,10 @@ static void KM_901U_Service(KINGMETER_t* KM_ctx)
456
456
// Decode Rx message
457
457
if (!CheckSum ) //low-byte and high-byte
458
458
{
459
- kingmeter_update ();
459
+
460
460
KM_ctx -> Settings .PAS_RUN_Direction = (KM_Message [4 ] & 0x80 ) >> 7 ; // KM_PASDIR_FORWARD / KM_PASDIR_BACKWARD
461
+ KM_ctx -> Settings .ExecAutodetect = (KM_Message [6 ]>>7 )& 0x01 ; // Execute Autodetect (with P18 of EN06 protocol)
462
+ KM_ctx -> Settings .Reverse = (KM_Message [6 ]>>6 )& 0x01 ; // set spinning direction (with P19 of EN06 protocol)
461
463
KM_ctx -> Settings .PAS_SCN_Tolerance = KM_Message [5 ]; // 2..9
462
464
KM_ctx -> Settings .PAS_N_Ratio = KM_Message [6 ]; // 0..255
463
465
KM_ctx -> Settings .HND_HL_ThrParam = (KM_Message [7 ] & 0x80 ) >> 7 ; // KM_HND_HL_NO / KM_HND_HL_YES
@@ -469,8 +471,13 @@ static void KM_901U_Service(KINGMETER_t* KM_ctx)
469
471
KM_ctx -> Rx .SPEEDMAX_Limit = KM_Message [11 ];
470
472
KM_ctx -> Rx .CUR_Limit_mA = (KM_Message [8 ]& 0x3F )* 500 ;
471
473
472
- if (KM_ctx -> Rx .CUR_Limit_mA == 21500 )autodetect ();
473
-
474
+ kingmeter_update ();
475
+ if (KM_ctx -> Settings .ExecAutodetect && !FirstRunFlag ){
476
+ autodetect ();
477
+ FirstRunFlag = 1 ;
478
+ }
479
+ //if(KM_ctx->Rx.CUR_Limit_mA==21500)autodetect();
480
+ //if(KM_ctx->Rx.CUR_Limit_mA==20500)get_internal_temp_offset();
474
481
}
475
482
476
483
// Prepare Tx message with handshake code
0 commit comments