Skip to content

Commit cc7de3d

Browse files
committed
fix ancs_oled button
1 parent a3beb00 commit cc7de3d

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

cores/nRF5/Arduino.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ void suspendLoop(void);
133133
#define bit(b) (1UL << (b))
134134

135135
#ifdef NRF_P1
136-
#define digitalPinToPort(P) ( (g_ADigitalPinMap[P] < 32) ? NRF_P0 : NRF_P1 )
136+
#define digitalPinToPort(P) ( (g_ADigitalPinMap[P] < 32) ? NRF_P0 : NRF_P1 )
137137
#else
138-
#define digitalPinToPort(P) ( NRF_P0 )
138+
#define digitalPinToPort(P) ( NRF_P0 )
139139
#endif
140140

141141
#define digitalPinToBitMask(P) ( 1UL << ( g_ADigitalPinMap[P] < 32 ? g_ADigitalPinMap[P] : (g_ADigitalPinMap[P]-32) ) )

libraries/Bluefruit52Lib/examples/Peripheral/ancs_oled/ancs_oled.ino

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@
3030
#if defined ARDUINO_NRF52832_FEATHER
3131
// Feather nRF52832
3232
#define BUTTON_A 31
33-
#define BUTTON_B 30
3433
#define BUTTON_C 27
3534

3635
#else
3736
// Default for others
3837
#define BUTTON_A 9
39-
#define BUTTON_B 6
4038
#define BUTTON_C 5
4139

4240
#endif
@@ -75,7 +73,6 @@ void setup()
7573
{
7674
// Button configured
7775
pinMode(BUTTON_A, INPUT_PULLUP);
78-
pinMode(BUTTON_B, INPUT_PULLUP);
7976
pinMode(BUTTON_C, INPUT_PULLUP);
8077

8178
// init with the I2C addr 0x3C (for the 128x32) and show splashscreen
@@ -92,7 +89,7 @@ void setup()
9289

9390
Bluefruit.begin();
9491
Bluefruit.setTxPower(4); // Check bluefruit.h for supported values
95-
Bluefruit.setName("Bluefruit52");
92+
9693
Bluefruit.Periph.setConnectCallback(connect_callback);
9794
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
9895

@@ -453,8 +450,7 @@ uint32_t readPressedButtons(void)
453450

454451
// Take current read and masked with BUTTONs
455452
// Note: Bitwise inverted since buttons are active (pressed) LOW
456-
uint32_t debounced = ~(*portInputRegister( digitalPinToPort(0) ));
457-
debounced &= (bit(BUTTON_A) | bit(BUTTON_B) | bit(BUTTON_C));
453+
uint32_t debounced = ~( (digitalRead(BUTTON_A) << BUTTON_A) | (digitalRead(BUTTON_C) << BUTTON_C) );
458454

459455
// Copy current state into array
460456
states[ (index & (MAX_CHECKS-1)) ] = debounced;

0 commit comments

Comments
 (0)