Skip to content

Commit 8d77119

Browse files
committed
ExpanderPin: provide fallback method
1 parent 134cc70 commit 8d77119

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

Arduino_Nesso_N1.h

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,54 @@
1-
#include "Arduino.h"
1+
#ifndef Arduino_Nesso_N1_h
2+
#define Arduino_Nesso_N1_h
3+
4+
#if defined(__cplusplus)
5+
6+
#include <Arduino.h>
27
#include "Wire.h"
38
#include <M5GFX.h>
49
#include <lgfx/v1/panel/Panel_ST7789.hpp>
510
//#include "Arduino_BMI270_BMM150.h"
611

7-
#if defined(__cplusplus)
12+
#undef LORA_LNA_ENABLE
13+
#undef LORA_ANTENNA_SWITCH
14+
#undef LORA_ENABLE
15+
#undef POWEROFF
16+
#undef GROVE_POWER_EN
17+
#undef VIN_DETECT
18+
#undef LCD_RESET
19+
#undef LCD_BACKLIGHT
20+
#undef LED_BUILTIN
21+
#undef KEY1
22+
#undef KEY2
23+
24+
// address: 0x43/0x44
25+
class ExpanderPin {
26+
public:
27+
ExpanderPin(uint16_t _pin) : pin(_pin & 0xFF), address(_pin & 0x100 ? 0x44 : 0x43){};
28+
uint8_t pin;
29+
uint8_t address;
30+
bool initialized() {
31+
return _initialized[address - 0x43];
32+
}
33+
void initialize() {
34+
_initialized[address - 0x43] = true;
35+
}
36+
private:
37+
static bool _initialized[2];
38+
};
39+
40+
41+
extern ExpanderPin LORA_LNA_ENABLE;
42+
extern ExpanderPin LORA_ANTENNA_SWITCH;
43+
extern ExpanderPin LORA_ENABLE;
44+
extern ExpanderPin POWEROFF;
45+
extern ExpanderPin GROVE_POWER_EN;
46+
extern ExpanderPin VIN_DETECT;
47+
extern ExpanderPin LCD_RESET;
48+
extern ExpanderPin LCD_BACKLIGHT;
49+
extern ExpanderPin LED_BUILTIN;
50+
extern ExpanderPin KEY1;
51+
extern ExpanderPin KEY2;
852

953
void pinMode(ExpanderPin pin, uint8_t mode);
1054
void digitalWrite(ExpanderPin pin, uint8_t val);
@@ -206,4 +250,5 @@ class NessoTouch {
206250
}
207251
};
208252

253+
#endif
209254
#endif

0 commit comments

Comments
 (0)