Skip to content

Commit 5d37a7a

Browse files
author
jenkie
committed
Renamed SUPPORT_SEMPU to SUPPORT_SEMPU_V1
1 parent c6f1491 commit 5d37a7a

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Time now;
8888
#error Soft poti is incompatible with throttle auto cruise
8989
#endif
9090

91-
#if defined(SUPPORT_LIGHTS_SWITCH) && (defined(SUPPORT_XCELL_RT)||defined(SUPPORT_SEMPU)) && HARDWARE_REV < 20
91+
#if defined(SUPPORT_LIGHTS_SWITCH) && (defined(SUPPORT_XCELL_RT)||defined(SUPPORT_SEMPU_V1)) && HARDWARE_REV < 20
9292
#error Software controlled lights switch is not compatible with torque sensor support on FC < 2.0
9393
#endif
9494

@@ -133,7 +133,7 @@ struct savings //add variables if you want to store additional values to the e
133133
#ifdef SUPPORT_BATTERY_CHARGE_COUNTER
134134
unsigned int charge_count;//battery charge count
135135
#endif
136-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
136+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
137137
float wh_human; //human watthours
138138
#endif
139139
};
@@ -254,7 +254,7 @@ int last_throttle_write=0; //last throttle write value
254254
#endif
255255
volatile byte wheel_counter=0; //counter for events that should happen once per wheel revolution. only needed if wheel_magnets>1
256256
volatile unsigned long last_pas_event = millis(); //last change-time of PAS sensor status
257-
#ifdef SUPPORT_SEMPU
257+
#ifdef SUPPORT_SEMPU_V1
258258
#define pas_time 1875 //conversion factor for pas_time to rpm (cadence)
259259
#else
260260
#define pas_time 60000/pas_magnets //conversion factor for pas_time to rpm (cadence)
@@ -271,7 +271,7 @@ double torque=0.0; //cyclist's torque in Nm (averaged over one pedal r
271271
double torque_instant=0.0; //cyclist's torque in Nm (live)
272272
double power_human=0.0; //cyclist's power
273273
double wh_human=0;
274-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
274+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
275275
int torque_zero=TORQUE_ZERO; //Offset of torque sensor. Adjusted at startup if TORQUE_AUTOZERO option is set
276276
static volatile boolean analogRead_in_use = false; //read torque values in interrupt only if no analogRead in process
277277
static volatile boolean torque_want_calculation = false; //read torque values in interrupt only if no analogRead in process
@@ -524,7 +524,7 @@ digitalWrite(option_pin,HIGH);
524524
poti_stat = map(poti_value_on_startup_in_watts, 0, curr_power_poti_max, 0, 1023);
525525
#endif
526526

527-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
527+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
528528
#ifdef TORQUE_AUTOZERO
529529
torque_rezero();
530530
#endif
@@ -662,7 +662,7 @@ if (loadcell.is_ready()) //new conversion result from load cell available
662662
current_display = 0.99*current_display + 0.01*current; //averaged current for display
663663
power=current*voltage;
664664

665-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
665+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
666666
#ifdef SUPPORT_XCELL_RT
667667
torque_instant=0.49*(analogRead(option_pin)-torque_zero); //multiplication constant for THUN X-CELL RT is approx. 0.49Nm/count
668668
#else //SEMPU
@@ -721,7 +721,7 @@ if (loadcell.is_ready()) //new conversion result from load cell available
721721
wh=variable.wh;
722722
km=variable.kilometers;
723723
mah=variable.mah;
724-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
724+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
725725
wh_human=variable.wh_human;
726726
#endif
727727
}
@@ -785,7 +785,7 @@ if (loadcell.is_ready()) //new conversion result from load cell available
785785
power_throttle = throttle_stat / 1023.0 * curr_power_max; //power currently set by throttle
786786

787787
#if CONTROL_MODE == CONTROL_MODE_TORQUE //human power control mode
788-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
788+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
789789
power_poti = poti_stat/102300.0* curr_power_poti_max*power_human*(1+spd/20.0); //power_poti_max is in this control mode interpreted as percentage. Example: power_poti_max=200 means; motor power = 200% of human power
790790
#ifdef SUPPORT_TORQUE_THROTTLE //we want to trigger throttle just by pedal torque
791791
if (abs(torque_instant)>torque_throttle_min) //we are above the threshold to trigger throttle
@@ -1113,7 +1113,7 @@ void pas_change_dual(boolean signal)
11131113
#endif
11141114
#endif
11151115

1116-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
1116+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
11171117
void read_current_torque() //this reads the current torque value
11181118
{
11191119
torquevalues[torqueindex]=analogRead(option_pin)-torque_zero;
@@ -1137,7 +1137,7 @@ void pas_change() //Are we pedaling? PAS Sensor Change--------------------
11371137
if (pas_stat)
11381138
{
11391139
pas_off_time=millis()-last_pas_event;
1140-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
1140+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
11411141
if (analogRead_in_use)
11421142
torque_want_calculation = true;
11431143
else
@@ -1149,7 +1149,7 @@ void pas_change() //Are we pedaling? PAS Sensor Change--------------------
11491149
last_pas_event = millis();
11501150
cad=pas_time/(pas_on_time+pas_off_time);
11511151

1152-
#ifdef SUPPORT_SEMPU
1152+
#ifdef SUPPORT_SEMPU_V1
11531153
pedaling=bitRead(PINE,6); //read direction pin of pas sensor and set pedaling to true
11541154
#else
11551155
pas_failtime=pas_failtime+1;
@@ -1269,7 +1269,7 @@ void serial_debug(HardwareSerial* localSerial)
12691269
localSerial->print(current,1);
12701270
localSerial->print(MY_F(" Power"));
12711271
localSerial->print(power,0);
1272-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
1272+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
12731273
localSerial->print(MY_F(" Pedaling"));
12741274
localSerial->print(pedaling);
12751275
localSerial->print(MY_F(" Torque"));
@@ -1510,7 +1510,7 @@ void save_eeprom()
15101510
#ifdef SUPPORT_BATTERY_CHARGE_COUNTER
15111511
variable_new.charge_count=charge_count; //save charge counter
15121512
#endif
1513-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
1513+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
15141514
variable_new.wh_human=wh_human; //save human watthours
15151515
#endif
15161516
const byte* p_new = (const byte*)(const void*)&variable_new; //pointer to new variables to save
@@ -1581,7 +1581,7 @@ void handle_unused_pins()
15811581

15821582
int analogRead_noISR(uint8_t pin) //this function makes sure that analogRead is never used in interrupt. only important for X-Cell RT bottom brackets
15831583
{
1584-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
1584+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
15851585
analogRead_in_use = true; //this prevents analogReads in Interrupt from Thun bracket
15861586
if (torque_want_calculation)
15871587
{
@@ -1590,7 +1590,7 @@ int analogRead_noISR(uint8_t pin) //this function makes sure that analogRead is
15901590
}
15911591
#endif
15921592
int temp=analogRead(pin);
1593-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
1593+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
15941594
analogRead_in_use = false;
15951595
#endif
15961596
return temp;

Arduino_Pedelec_Controller/config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ const int fixed_throttle_in_watts = 250; //number of watts to set as thr
141141
// #define SUPPORT_BBS //uncomment if BBS02 PAS sensor is connected (2 wires analog to Thun)
142142
#define BBS_GEARCHANGEPAUSE 2000 //powerless time in milliseconds to allow gear change
143143
// #define SUPPORT_XCELL_RT //uncomment if X-CELL RT connected. FC1.4: pas_factor_min=0.2, pas_factor_max=0.5. FC1.5: pas_factor_min=0.5, pas_factor_max=1.5. pas_magnets=8
144-
// #define SUPPORT_SEMPU //uncomment if you have a Sempu torque sensor
144+
// #define SUPPORT_SEMPU_V1 //uncomment if you have a Sempu torque sensor, old type with one direction wire and one pas wire
145+
// #define SUPPORT_SEMPU //uncomment if you have a Sempu torque sensor, new type with two pas wires
145146
// #define SUPPORT_TORQUE_THROTTLE
146147
// #define SUPPORT_HRMI //uncomment if polar heart-rate monitor interface connected to i2c port
147148
#define SUPPORT_BRAKE //uncomment if brake switch connected

Arduino_Pedelec_Controller/display.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ static void display_nokia_view_human()
11291129
lcd.print(MY_F(" CAD "));
11301130
lcd.print(cad);
11311131
lcd.print(MY_F(" "));
1132-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU) //show left bar with human and battery wh
1132+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1) //show left bar with human and battery wh
11331133
lcd.setCursor(3,3); //print human power centered
11341134
lcd.print(MY_F(" W ")); lcd.print(power_human,0);
11351135
lcd.print(MY_F(" "));

Arduino_Pedelec_Controller/switches.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void action_set_soft_poti(int new_throttle_stat)
101101

102102
{
103103
#if CONTROL_MODE == CONTROL_MODE_TORQUE //human power control mode
104-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
104+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
105105
buffer[9]='%';
106106
power_poti = poti_stat/1023.0* curr_power_poti_max; //power_poti_max is in this control mode interpreted as percentage. Example: power_poti_max=200 means; motor power = 200% of human power
107107
#endif
@@ -337,7 +337,7 @@ static void execute_action(const sw_action action)
337337
action_toggle_gear(true);
338338
break;
339339
#endif
340-
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU)
340+
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1)
341341
case ACTION_TORQUE_ZERO:
342342
torque_rezero();
343343
display_show_important_info(FROM_FLASH(msg_torquezero), 2);

0 commit comments

Comments
 (0)