Skip to content

Commit 7691f08

Browse files
authored
Merge pull request #82 from adafruit/develop
fix #76 and clean up
2 parents fc00e2b + 5b6488c commit 7691f08

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

src/boards.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,20 @@
4242
//------------- IMPLEMENTATION -------------//
4343
void button_init(uint32_t pin)
4444
{
45-
if (BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN) {
45+
if ( BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN )
46+
{
4647
nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_HIGH);
47-
} else {
48+
}
49+
else
50+
{
4851
nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_LOW);
4952
}
5053
}
5154

5255
bool button_pressed(uint32_t pin)
5356
{
54-
return (nrf_gpio_pin_read(pin) == BUTTON_DIR) ? true : false;
57+
uint32_t const active_state = (BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN ? 1 : 0);
58+
return nrf_gpio_pin_read(pin) == active_state;
5559
}
5660

5761
void board_init(void)

src/boards.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,10 @@
3535
#ifndef BUTTON_DFU
3636
#define BUTTON_DFU BUTTON_1
3737
#endif
38+
3839
#ifndef BUTTON_FRESET
3940
#define BUTTON_FRESET BUTTON_2
4041
#endif
41-
#ifndef BUTTON_DIR
42-
#if BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN
43-
#define BUTTON_DIR 1
44-
#elif BUTTON_PULL == NRF_GPIO_PIN_PULLUP
45-
#define BUTTON_DIR 0
46-
#endif
47-
#endif
4842

4943
// The primary LED is usually Red but not in all cases.
5044
#define LED_PRIMARY 0

tools/build_all.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@
1111
if "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true":
1212
travis = True
1313

14+
success_count = 0
15+
fail_count = 0
1416
exit_status = 0
1517

18+
build_format = '| {:30} | {:9} '
19+
build_separator = '-' * 54
20+
1621
all_boards = []
1722
for entry in os.scandir("src/boards"):
1823
all_boards.append(entry.name)
@@ -21,17 +26,25 @@
2126

2227
total_time = time.monotonic()
2328

29+
print(build_separator)
30+
print((build_format + '| {:5} |').format('Board', 'Result', 'Time'))
31+
print(build_separator)
32+
2433
for board in all_boards:
2534
bin_directory = "bin/{}/".format(board)
2635
os.makedirs(bin_directory, exist_ok=True)
2736

2837
start_time = time.monotonic()
2938
make_result = subprocess.run("make -j 4 BOARD={} combinehex genpkg".format(board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
3039
build_duration = time.monotonic() - start_time
31-
success = "\033[32msucceeded\033[0m"
32-
if make_result.returncode != 0:
40+
41+
if make_result.returncode == 0:
42+
success = "\033[32msucceeded\033[0m"
43+
success_count += 1
44+
else:
3345
exit_status = make_result.returncode
34-
success = "\033[31mfailed\033[0m"
46+
success = "\033[31mfailed\033[0m "
47+
fail_count += 1
3548

3649
for entry in os.scandir("_build-{}".format(board)):
3750
for extension in ["zip", "hex"]:
@@ -40,15 +53,18 @@
4053

4154
if travis:
4255
print('travis_fold:start:build-{}\\r'.format(board))
43-
print("Build {} took {:.2f}s and {}".format(board, build_duration, success))
56+
57+
print((build_format + '| {:.2f}s |').format(board, success, build_duration))
58+
4459
if make_result.returncode != 0:
4560
print(make_result.stdout.decode("utf-8"))
4661
if travis:
4762
print('travis_fold:end:build-{}\\r'.format(board))
4863

49-
print()
50-
64+
# Build Summary
5165
total_time = time.monotonic() - total_time
52-
print("Total build time took {:.2f}s".format(total_time))
66+
print(build_separator)
67+
print("Build Sumamary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m and took {:.2f}s".format(success_count, fail_count, total_time))
68+
print(build_separator)
5369

5470
sys.exit(exit_status)

0 commit comments

Comments
 (0)