change all did_ grammar to past tense instead

This commit is contained in:
Oskar Weigl
2020-11-05 21:48:36 -08:00
parent d5838e85d3
commit 2040447174
8 changed files with 29 additions and 29 deletions
+4 -4
View File
@@ -81,13 +81,13 @@ bool Drv8301::init() {
osDelay(20); // t_spi_ready, max = 10ms
// Write current configuration
bool did_write_regs = write_reg(kRegNameControl1, regs_.control_register_1)
bool wrote_regs = write_reg(kRegNameControl1, regs_.control_register_1)
&& write_reg(kRegNameControl1, regs_.control_register_1)
&& write_reg(kRegNameControl1, regs_.control_register_1)
&& write_reg(kRegNameControl1, regs_.control_register_1)
&& write_reg(kRegNameControl1, regs_.control_register_1) // the write operation tends to be ignored if only done once (not sure why)
&& write_reg(kRegNameControl2, regs_.control_register_2);
if (!did_write_regs) {
if (!wrote_regs) {
return false;
}
@@ -95,9 +95,9 @@ bool Drv8301::init() {
delay_us(100);
state_ = kStateStartupChecks;
bool did_read_regs = read_reg(kRegNameControl1, &val) && (val == regs_.control_register_1)
bool is_read_regs = read_reg(kRegNameControl1, &val) && (val == regs_.control_register_1)
&& read_reg(kRegNameControl2, &val) && (val == regs_.control_register_2);
if (!did_read_regs) {
if (!is_read_regs) {
return false;
}
+3 -3
View File
@@ -212,7 +212,7 @@ bool Axis::run_lockin_spin(const LockinConfig_t &lockin_config, bool remain_arme
motor_.arm(&motor_.current_control_);
bool did_subscribe_to_idx = false;
bool subscribed_to_idx = false;
bool success = false;
float dir = lockin_config.vel >= 0.0f ? 1.0f : -1.0f;
@@ -231,9 +231,9 @@ bool Axis::run_lockin_spin(const LockinConfig_t &lockin_config, bool remain_arme
// Activate index pin as soon as target velocity was reached. This is
// to avoid hitting the index from the wrong direction.
if (reached_target_vel && !encoder_.index_found_ && !did_subscribe_to_idx) {
if (reached_target_vel && !encoder_.index_found_ && !subscribed_to_idx) {
encoder_.set_idx_subscribe(true);
did_subscribe_to_idx = true;
subscribed_to_idx = true;
}
osDelay(1);
+7 -7
View File
@@ -48,7 +48,7 @@ def noprint(text):
pass
def find_all(path, serial_number,
did_discover_object_callback,
discovered_object_callback,
search_cancellation_token,
channel_termination_token,
logger):
@@ -58,9 +58,9 @@ def find_all(path, serial_number,
This function is non-blocking.
"""
def did_discover_channel(channel):
def discovered_channel(channel):
"""
Inits an object from a given channel and then calls did_discover_object_callback
Inits an object from a given channel and then calls discovered_object_callback
with the created object
This queries the endpoint 0 on that channel to gain information
about the interface, which is then used to init the corresponding object.
@@ -132,7 +132,7 @@ def find_all(path, serial_number,
logger.debug("Ignoring device with serial number {}".format(device_serial_number))
return
did_discover_object_callback(obj)
discovered_object_callback(obj)
except Exception:
@@ -144,7 +144,7 @@ def find_all(path, serial_number,
the_rest = ':'.join(search_spec.split(':')[1:])
if prefix in channel_types:
t = threading.Thread(target=channel_types[prefix],
args=(the_rest, serial_number, did_discover_channel, search_cancellation_token, channel_termination_token, logger))
args=(the_rest, serial_number, discovered_channel, search_cancellation_token, channel_termination_token, logger))
t.daemon = True
t.start()
else:
@@ -159,7 +159,7 @@ def find_any(path="usb", serial_number=None,
"""
result = []
done_signal = Event(search_cancellation_token)
def did_discover_object(obj):
def discovered_object(obj):
result.append(obj)
if find_multiple:
if len(result) >= int(find_multiple):
@@ -167,7 +167,7 @@ def find_any(path="usb", serial_number=None,
else:
done_signal.set()
find_all(path, serial_number, did_discover_object, done_signal, channel_termination_token, logger)
find_all(path, serial_number, discovered_object, done_signal, channel_termination_token, logger)
try:
done_signal.wait(timeout=timeout)
except TimeoutError:
@@ -81,7 +81,7 @@ def discover_channels(path, serial_number, callback, cancellation_token, channel
return False
return bool(re.match(regex, port_name))
def did_disconnect(port_name, device):
def disconnected(port_name, device):
device.close()
# TODO: yes there is a race condition here in case you wonder.
known_devices.pop(known_devices.index(port_name))
@@ -103,6 +103,6 @@ def discover_channels(path, serial_number, callback, cancellation_token, channel
known_devices.append(port_name)
else:
known_devices.append(port_name)
channel._channel_broken.subscribe(lambda: did_disconnect(port_name, serial_device))
channel._channel_broken.subscribe(lambda: disconnected(port_name, serial_device))
callback(channel)
time.sleep(1)
+4 -4
View File
@@ -4,7 +4,7 @@ import platform
import threading
import fibre
def did_discover_device(device,
def discovered_device(device,
interactive_variables, discovered_devices,
branding_short, branding_long,
logger, app_shutdown_token):
@@ -29,9 +29,9 @@ def did_discover_device(device,
logger.notify("{} to {} {} as {}".format(verb, branding_long, serial_number, interactive_name))
# Subscribe to disappearance of the device
device.__channel__._channel_broken.subscribe(lambda: did_lose_device(interactive_name, logger, app_shutdown_token))
device.__channel__._channel_broken.subscribe(lambda: lost_device(interactive_name, logger, app_shutdown_token))
def did_lose_device(interactive_name, logger, app_shutdown_token):
def lost_device(interactive_name, logger, app_shutdown_token):
"""
Handles the disappearance of a device by displaying
a message.
@@ -58,7 +58,7 @@ def launch_shell(args,
# Connect to device
logger.debug("Waiting for {}...".format(branding_long))
fibre.find_all(args.path, args.serial_number,
lambda dev: did_discover_device(dev, interactive_variables, discovered_devices, branding_short, branding_long, logger, app_shutdown_token),
lambda dev: discovered_device(dev, interactive_variables, discovered_devices, branding_short, branding_long, logger, app_shutdown_token),
app_shutdown_token,
app_shutdown_token,
logger=logger)
+3 -3
View File
@@ -41,7 +41,7 @@ interactive_variables = {}
discovered_devices = []
def did_discover_device(odrive, logger, app_shutdown_token):
def discovered_device(odrive, logger, app_shutdown_token):
"""
Handles the discovery of new devices by displaying a
message and making the device available to the interactive
@@ -63,9 +63,9 @@ def did_discover_device(odrive, logger, app_shutdown_token):
logger.notify("{} to ODrive {:012X} as {}".format(verb, serial_number, interactive_name))
# Subscribe to disappearance of the device
odrive.__channel__._channel_broken.subscribe(lambda: did_lose_device(interactive_name, logger, app_shutdown_token))
odrive.__channel__._channel_broken.subscribe(lambda: lost_device(interactive_name, logger, app_shutdown_token))
def did_lose_device(interactive_name, logger, app_shutdown_token):
def lost_device(interactive_name, logger, app_shutdown_token):
"""
Handles the disappearance of a device by displaying
a message.
+4 -4
View File
@@ -70,14 +70,14 @@ def test_assert_within(observed, lower_bound, upper_bound, accuracy=0.0):
def disjoint_sets(list_of_sets: list):
while len(list_of_sets):
current_set, list_of_sets = list_of_sets[0], list_of_sets[1:]
did_update = True
while did_update:
did_update = False
updated = True
while updated:
updated = False
for i, s in enumerate(list_of_sets):
if len(current_set.intersection(s)):
current_set = current_set.union(s)
list_of_sets = list_of_sets[:i] + list_of_sets[(i+1):]
did_update = True
updated = True
yield current_set
def is_list_like(arg):
+2 -2
View File
@@ -155,10 +155,10 @@ def start_liveplotter(get_var_callback):
plt.ion()
# Make sure the script terminates when the user closes the plotter
def did_close(evt):
def closed(evt):
cancellation_token.set()
fig = plt.figure()
fig.canvas.mpl_connect('close_event', did_close)
fig.canvas.mpl_connect('close_event', closed)
while not cancellation_token.is_set():
plt.clf()