<PAL_NOTICE>
For NOTICE PAL
The following constants are defined:
static const uint8_t PIN_BTN = 12; // button (as SET)
static const uint8_t PIN_LED = 5; // LED
static const uint8_t PIN_WDT = 13; // WDT (shall tick every 60sec)
static const uint8_t PIN_D1 = 1; // DIP SW1
static const uint8_t PIN_D2 = 2; // DIP SW2
static const uint8_t PIN_D3 = 3; // DIP SW3
static const uint8_t PIN_D4 = 4; // DIP SW4
static const uint8_t PIN_SNS_EN = 16;
static const uint8_t PIN_SNS_INT = 17;
These can be accessed like PAL_AMB::PIN_BTN
.
pinMode(PIN_BTN, INPUT_PULLUP);
pinMode(PIN_LED, OUTPUT_INIT_HIGH);
pinMode(PIN_WDT, OUTPUT_INIT_HIGH);
pinMode(PIN_D1, INPUT_PULLUP);
pinMode(PIN_D2, INPUT_PULLUP);
pinMode(PIN_D3, INPUT_PULLUP);
pinMode(PIN_D4, INPUT_PULLUP);
Pins are initialized as shown in the code above.
The external watchdog timer is reset at startup, after waking from sleep, and after a certain amount of time has passed since startup.
void set_led(uint8_t mode, uint16_t tick)
Controls LED (D1).
mode
takes the following parameters. tick
specifies the ON duration [ms], but see the explanation of mode
for details.
Mode | Description |
---|---|
LED_TIMER::BLINK | Blinks the LED. Toggles ON/OFF every tick ms. After waking from sleep, it resets and starts ON. |
LED_TIMER::ON_RX | Turns on the LED for tick ms when a packet is received. |
LED_TIMER::ON_TX_COMP | Turns on the LED for tick ms when transmission completes. |
void led_one_shot(uint16_t tick)
Turns on the LED for a specified duration. Cannot be used simultaneously with set_led()
.
inline uint8_t get_D1()
inline uint8_t get_D2()
inline uint8_t get_D3()
inline uint8_t get_D4()
inline uint8_t get_DIPSW_BM()
get_D1()
through get_D4()
return 0
when the DIP switch is in the HIGH (up) position, and 1
when in the LOW (down) position.
get_DIPSW_BM()
returns the DIP switch setting as a value from 0
to 15
, calculated as: SW1==LOW
= 1, SW2==LOW
= 2, SW3==LOW
= 4, and SW4==LOW
= 8.
The logic here is inverted from the actual HIGH(1)/LOW(0) levels of D1–D4.
This is because a DIP switch in the LOW(0) position is considered “set” and assigned a value of 1
.
For NOTICE PAL
For Ambient Sensor PAL
For Open-Close Sensor PAL
For Motion Sensor PAL