Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //- -----------------------------------------------------------------------------------------------------------------------
- // AskSin++
- // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
- //- -----------------------------------------------------------------------------------------------------------------------
- // define this to read the device id, serial and device type from bootloader section
- // #define USE_OTA_BOOTLOADER
- #define EI_NOTEXTERNAL
- #include <EnableInterrupt.h>
- #include <AskSinPP.h>
- #include <LowPower.h>
- #include <Dimmer.h>
- // we use a Pro Mini
- // Arduino pin for the LED
- // D4 == PIN 4 on Pro Mini
- #define LED_PIN 4
- // Arduino pin for the config button
- // B0 == PIN 8 on Pro Mini
- #define CONFIG_BUTTON_PIN 8
- #define DIMMER_PIN 5
- #define BTN1 7
- #define BTN2 9
- // number of available peers per channel
- #define PEERS_PER_CHANNEL 4
- // all library classes are placed in the namespace 'as'
- using namespace as;
- // define all device properties
- const struct DeviceInfo PROGMEM devinfo = {
- {0x11, 0x12, 0x22}, // Device ID
- "papa111222", // Device Serial
- {0x00, 0x59}, // Device Model
- 0x25, // Firmware Version
- as::DeviceType::Dimmer, // Device Type
- {0x01, 0x00} // Info Bytes
- };
- /**
- Configure the used hardware
- */
- typedef AvrSPI<10, 11, 12, 13> SPIType;
- typedef Radio<SPIType, 2> RadioType;
- typedef StatusLed<LED_PIN> LedType;
- typedef AskSin<LedType, NoBattery, RadioType> HalType;
- typedef DimmerChannel<HalType, PEERS_PER_CHANNEL> ChannelType;
- typedef DimmerDevice<HalType, ChannelType, 1, 1, PWM8<> > DimmerType;
- HalType hal;
- DimmerType sdev(devinfo, 0x20);
- ConfigButton<DimmerType> cfgBtn(sdev);
- InternalButton<DimmerType> btn1(sdev,2);
- InternalButton<DimmerType> btn2(sdev,3);
- void setup () {
- buttonISR(btn1, BTN1);
- buttonISR(btn2, BTN2);
- DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
- if ( sdev.init(hal, DIMMER_PIN) ) {
- HMID devid;
- sdev.getDeviceID(devid);
- sdev.channel(1).peer(Peer(devid,2), Peer(devid, 3));
- }
- buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
- sdev.initDone();
- }
- void loop() {
- bool worked = hal.runready();
- bool poll = sdev.pollRadio();
- if ( worked == false && poll == false ) {
- // hal.activity.savePower<Idle<true> >(hal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement