File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed
Arduino_Pedelec_Controller Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 25
25
#define DISPLAY_TYPE_KINGMETER (DISPLAY_TYPE_KINGMETER_618U|DISPLAY_TYPE_KINGMETER_901U)
26
26
#define DISPLAY_TYPE_BAFANG_C961 (1<<9)
27
27
#define DISPLAY_TYPE_BAFANG_C965 (1<<10)
28
- #define DISPLAY_TYPE_BAFANG (DISPLAY_TYPE_BAFANG_C961|DISPLAY_TYPE_BAFANG_C965)
28
+ #define DISPLAY_TYPE_BAFANG_SW102 (1<<11)
29
+ #define DISPLAY_TYPE_BAFANG (DISPLAY_TYPE_BAFANG_C961|DISPLAY_TYPE_BAFANG_C965|DISPLAY_TYPE_BAFANG_SW102)
29
30
30
31
#define DISPLAY_TYPE DISPLAY_TYPE_NOKIA_4PIN // Set your display type here. CHANGES ONLY HERE!<-----------------------------
31
32
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ void Bafang_Service(BAFANG_t* BF_ctx)
129
129
case BF_CMD_GETSPEED:
130
130
#if (DISPLAY_TYPE==DISPLAY_TYPE_BAFANG_C961)
131
131
spd_tmp=BF_ctx->Rx .Wheeldiameter *0.02 *spd;
132
- #elif (DISPLAY_TYPE==DISPLAY_TYPE_BAFANG_C965)
132
+ #elif (DISPLAY_TYPE==DISPLAY_TYPE_BAFANG_C965 || DISPLAY_TYPE==DISPLAY_TYPE_BAFANG_SW102 )
133
133
spd_tmp=BF_ctx->Rx .Wheeldiameter *0.03887 *spd;
134
134
#endif
135
135
TxBuff[0 ]=(spd_tmp>>8 );
@@ -142,10 +142,43 @@ void Bafang_Service(BAFANG_t* BF_ctx)
142
142
TxBuff[0 ]=1 ;
143
143
BF_sendmessage (BF_ctx,1 );
144
144
break ;
145
-
145
+
146
146
case BF_CMD_GETBAT:
147
+ #if (DISPLAY_TYPE==DISPLAY_TYPE_BAFANG_SW102)
148
+ if (battery_percent_fromcapacity>90 )
149
+ {
150
+ TxBuff[0 ]=75 ;
151
+ TxBuff[1 ]=75 ;
152
+ }
153
+ else if (battery_percent_fromcapacity>70 )
154
+ {
155
+ TxBuff[0 ]=50 ;
156
+ TxBuff[1 ]=50 ;
157
+ }
158
+ else if (battery_percent_fromcapacity>50 )
159
+ {
160
+ TxBuff[0 ]=30 ;
161
+ TxBuff[1 ]=30 ;
162
+ }
163
+ else if (battery_percent_fromcapacity>30 )
164
+ {
165
+ TxBuff[0 ]=10 ;
166
+ TxBuff[1 ]=10 ;
167
+ }
168
+ else if (battery_percent_fromcapacity>10 )
169
+ {
170
+ TxBuff[0 ]=6 ;
171
+ TxBuff[1 ]=6 ;
172
+ }
173
+ else
174
+ {
175
+ TxBuff[0 ]=0 ;
176
+ TxBuff[1 ]=0 ;
177
+ }
178
+ #else
147
179
TxBuff[0 ]=battery_percent_fromcapacity;
148
180
TxBuff[1 ]=battery_percent_fromcapacity;
181
+ #endif
149
182
BF_sendmessage (BF_ctx,2 );
150
183
break ;
151
184
You can’t perform that action at this time.
0 commit comments