Skip to content

Commit

Permalink
Add first Rx paramters
Browse files Browse the repository at this point in the history
  • Loading branch information
stancecoke committed Oct 27, 2024
1 parent a8cb792 commit 1f3ee89
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
23 changes: 5 additions & 18 deletions Inc/display_No_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if (DISPLAY_TYPE & DISPLAY_TYPE_NO2)


typedef struct
{
// Parameters received from display in setting mode:
uint16_t WheelSize_mm; // Unit: 1mm
uint8_t PAS_RUN_Direction; // KM_PASDIR_FORWARD / KM_PASDIR_BACKWARD
uint8_t PAS_SCN_Tolerance; // Number of PAS signals to start the motor
uint8_t PAS_N_Ratio; // 0..255 PAS ratio
uint8_t HND_HL_ThrParam; // KM_HND_HL_NO / KM_HND_HL_YES
uint8_t HND_HF_ThrParam; // KM_HND_HF_NO / KM_HND_HF_YES
uint8_t SYS_SSP_SlowStart; // 1..4 Level of soft ramping at start
uint8_t SPS_SpdMagnets; // Number of magnets of speedsensor
uint16_t VOL_1_UnderVolt_x10; // Unit: 0.1V

}RX_SETTINGS_t;

typedef struct
{
// Parameters received from display in operation mode:
uint8_t AssistLevel; // 0..255 Power Assist Level
uint8_t AssistLevel; // Byte 4, Level in Display
uint8_t NumberOfPasMagnets; // Byte 18, same Number as in display setting
uint8_t Headlight; // KM_HEADLIGHT_OFF / KM_HEADLIGHT_ON / KM_HEADLIGHT_LOW / KM_HEADLIGHT_HIGH
uint8_t Battery; // KM_BATTERY_NORMAL / KM_BATTERY_LOW
uint8_t PushAssist; // KM_PUSHASSIST_OFF / KM_PUSHASSIST_ON
uint8_t PowerAssist; // KM_POWERASSIST_OFF / KM_POWERASSIST_ON
uint8_t Throttle; // KM_THROTTLE_OFF / KM_THROTTLE_ON
uint8_t Throttle_mode; // Byte 3, numbers not read out yet
uint8_t CruiseControl; // KM_CRUISE_OFF / KM_CRUISE_ON
uint8_t OverSpeed; // KM_OVERSPEED_OFF / KM_OVERSPEED_ON
uint16_t SPEEDMAX_Limit; // Unit: km/h
uint16_t CUR_Limit_mA; // Unit: mA
uint16_t Voltage_min_x10; // HiByte 14, LowByte 15
uint8_t CUR_Limit_A; // Byte 13, same Number as in display setting

}RX_PARAM_t;

Expand Down
6 changes: 5 additions & 1 deletion Src/display_No_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ void No2_Service(No2_t* No2_ctx)

if(No2_Message[19]==calculate_checksum(No2_Message, 20)){
//to do

No2_ctx->Rx.AssistLevel = No2_Message[4];
No2_ctx->Rx.NumberOfPasMagnets = No2_Message[18];
No2_ctx->Rx.CUR_Limit_A = No2_Message[13];
No2_ctx->Rx.Voltage_min_x10 = (No2_Message[14]<<8)+No2_Message[15];
No2_ctx->Rx.Throttle_mode = No2_Message[3];
TxBuffer[13]=calculate_checksum(TxBuffer, 14);
HAL_UART_Transmit(&huart1, (uint8_t *)&TxBuffer,14,50);
}
Expand Down
2 changes: 1 addition & 1 deletion Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ int main(void)

huart1.Instance = USART1;

#if ((DISPLAY_TYPE & DISPLAY_TYPE_KINGMETER) ||DISPLAY_TYPE==DISPLAY_TYPE_KUNTENG||DISPLAY_TYPE==DISPLAY_TYPE_EBiCS)
#if ((DISPLAY_TYPE & DISPLAY_TYPE_KINGMETER) ||DISPLAY_TYPE==DISPLAY_TYPE_KUNTENG||DISPLAY_TYPE==DISPLAY_TYPE_EBiCS||DISPLAY_TYPE==DISPLAY_TYPE_NO2)
huart1.Init.BaudRate = 9600;
#elif (DISPLAY_TYPE == DISPLAY_TYPE_BAFANG)
huart1.Init.BaudRate = 1200;
Expand Down
2 changes: 2 additions & 0 deletions Src/subdir.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Src/FOC.c \
Src/display_bafang.c \
Src/display_kingmeter.c \
Src/display_kunteng.c \
build/display_No_2.c \
Src/eeprom.c \
Src/main.c \
Src/print.c \
Expand All @@ -20,6 +21,7 @@ build/FOC.o \
build/display_bafang.o \
build/display_kingmeter.o \
build/display_kunteng.o \
build/display_No_2.o \
build/eeprom.o \
build/main.o \
build/print.o \
Expand Down

0 comments on commit 1f3ee89

Please sign in to comment.