├── .gitmodules
├── Images
├── arduino_bottom.jpg
├── arduino_settings_board.png
├── arduino_sketch_open.png
├── arduino_top.jpg
├── ftdi_flash.jpg
├── hm-rc-p1.jpg
├── hm_anlernen1.png
├── hm_config1.png
├── sketch_aes.png
├── sketch_pins.png
├── sketch_serial.png
├── wiring.fzz
├── wiring_arduino_cc1101.png
└── wiring_arduino_cc1101_00.png
├── README.md
└── examples
├── HB-LC-Bl1PBU-FM
├── HB-LC-Bl1PBU-FM.ino
└── README.md
├── HB-LC-SW12-FM
└── HB-LC-SW12-FM.ino
├── HB-LC-Sw1PBU-FM
├── HB-LC-Sw1PBU-FM.ino
└── README.md
├── HB-LC-Sw2PBU-FM
├── HB-LC-Sw2PBU-FM.ino
└── README.md
├── HB-LC-Sw3-LIDL
├── HB-LC-Sw3-LIDL.ino
└── README.md
├── HB-UW-Sen-THPL
├── HB-UW-Sen-THPL.h
├── HB-UW-Sen-THPL.ino
├── Libraries
│ ├── AskSin
│ │ ├── AskSinMain.cpp
│ │ ├── AskSinMain.h
│ │ ├── Buttons.cpp
│ │ ├── Buttons.h
│ │ ├── Dummy.cpp
│ │ ├── Dummy.h
│ │ ├── Relay.cpp
│ │ ├── Relay.h
│ │ └── utility
│ │ │ ├── Battery.cpp
│ │ │ ├── Battery.h
│ │ │ ├── Fastdelegate.h
│ │ │ ├── Helpers.cpp
│ │ │ ├── Helpers.h
│ │ │ ├── PinChangeIntHandler.cpp
│ │ │ ├── PinChangeIntHandler.h
│ │ │ ├── Serial.cpp
│ │ │ ├── Serial.h
│ │ │ ├── StatusLed.cpp
│ │ │ ├── StatusLed.h
│ │ │ ├── cc110x.cpp
│ │ │ └── cc110x.h
│ ├── BH1750
│ │ ├── BH1750.cpp
│ │ ├── BH1750.h
│ │ ├── README.md
│ │ ├── examples
│ │ │ ├── BH1750advanced
│ │ │ │ └── BH1750advanced.ino
│ │ │ └── BH1750test
│ │ │ │ └── BH1750test.ino
│ │ ├── keywords.txt
│ │ ├── library.json
│ │ └── library.properties
│ ├── BMP085
│ │ ├── BMP085.cpp
│ │ ├── BMP085.h
│ │ ├── BMP085.jpg
│ │ ├── README.txt
│ │ └── example
│ │ │ ├── BMP085test - Kopie.html
│ │ │ └── BMP085test.pde
│ └── Wire
│ │ ├── Wire.cpp
│ │ ├── Wire.h
│ │ ├── examples
│ │ ├── SFRRanger_reader
│ │ │ └── SFRRanger_reader.ino
│ │ ├── digital_potentiometer
│ │ │ └── digital_potentiometer.ino
│ │ ├── master_reader
│ │ │ └── master_reader.ino
│ │ ├── master_writer
│ │ │ └── master_writer.ino
│ │ ├── slave_receiver
│ │ │ └── slave_receiver.ino
│ │ └── slave_sender
│ │ │ └── slave_sender.ino
│ │ ├── keywords.txt
│ │ └── utility
│ │ ├── twi.c
│ │ └── twi.h
├── Register.h
├── Sensor_BMP180_BH1750.cpp
├── Sensor_BMP180_BH1750.h
└── ccu-changelog.txt
├── HB-WDS40-THP-I
├── HB-WDS40-THP-I.ino
└── Sens_BMP180.h
├── HB-WDS40-THP-O-BME280
├── HB-WDS40-THP-O-BME280.ino
└── Sens_BME280.h
├── HM-CC-SCD
└── HM-CC-SCD.ino
├── HM-Dis-TD-T
└── HM-Dis-TD-T.ino
├── HM-Dis-WM55
├── FreeMono9pt7bMod.h
├── HM-Dis-WM55.ino
└── Icons.h
├── HM-ES-PMSw1-Pl
├── HM-ES-PMSw1-Pl.ino
├── POW_Pinout.jpg
└── README.md
├── HM-ES-PMSw1-Pl_GosundSP1
├── Calibration
│ └── Calibration.ino
├── HM-ES-PMSw1-Pl_GosundSP1.ino
└── README.md
├── HM-ES-TX-WM_CCU
└── HM-ES-TX-WM_CCU.ino
├── HM-LC-SW1-FM_Shelly1
├── 1_Shelly_Open.jpeg
├── 2_Shelly_RemoveESP.jpg
├── 3_Shelly_RemovedESP.jpg
├── 4_ProMiniWithCC1101.jpg
├── 5_ShellyWithoutESP.jpg
├── 6_ShellyAssembled.jpeg
├── 7_ShellyCase.jpg
├── Deckel.stl
├── HM-LC-SW1-FM_Shelly1.ino
└── README.md
├── HM-LC-SW1-SM_SONOFF_BASIC
└── HM-LC-SW1-SM_SONOFF_BASIC.ino
├── HM-LC-Sw1-Pl-CT-R1
└── HM-LC-Sw1-Pl-CT-R1.ino
├── HM-LC-Sw1-Pl-DN-R1
└── HM-LC-Sw1-Pl-DN-R1.ino
├── HM-LC-Sw1-Pl-DN-R1_OBI
├── HM-LC-Sw1-Pl-DN-R1_OBI.ino
├── README.md
└── SwitchObi.h
├── HM-LC-Sw2-FM
└── HM-LC-Sw2-FM.ino
├── HM-MOD-Re-8
└── HM-MOD-Re-8.ino
├── HM-PB-2-FM
└── HM-PB-2-FM.ino
├── HM-PB-2-WM55
└── HM-PB-2-WM55.ino
├── HM-PB-6-WM55
└── HM-PB-6-WM55.ino
├── HM-PB-MP-WM
├── ButtonMP.h
└── HM-PB-MP-WM.ino
├── HM-PBI-4-FM
└── HM-PBI-4-FM.ino
├── HM-RC-2-PBU-FM
└── HM-RC-2-PBU-FM.ino
├── HM-SCI-3-FM
└── HM-SCI-3-FM.ino
├── HM-SEC-SC
└── HM-SEC-SC.ino
├── HM-SEC-SCO
└── HM-SEC-SCO.ino
├── HM-SWI-3-FM
└── HM-SWI-3-FM.ino
├── HM-Sec-TiS
└── HM-Sec-TiS.ino
├── HM-Sen-DB-PCB
└── HM-Sen-DB-PCB.ino
├── HM-Sen-LI-O
└── HM-Sen-LI-O.ino
├── HM-Sen-WA-OD
└── HM-Sen-WA-OD.ino
├── HM-Sys-sRP-Pl
├── HM-Sys-sRP-Pl.ino
└── README.md
├── HM-WDS30-OT2-DS18B20
└── HM-WDS30-OT2-DS18B20.ino
├── HM-WDS30-OT2-NTC
└── HM-WDS30-OT2-NTC.ino
├── HM-WDS30-T-O-NTC
└── HM-WDS30-T-O-NTC.ino
├── HM-WDS40-TH-I-BME280
└── HM-WDS40-TH-I-BME280.ino
├── HM-WDS40-TH-I-DHT22
└── HM-WDS40-TH-I-DHT22.ino
├── HM-WDS40-TH-I-DS18B20
└── HM-WDS40-TH-I-DS18B20.ino
├── HM-WDS40-TH-I-SHT10
├── HM-WDS40-TH-I-SHT10.ino
├── Images
│ ├── Aufgehaengt.jpg
│ ├── Deckel_und_Boden.jpg
│ ├── Innen_Disp.jpg
│ ├── Innen_Elektronik.jpg
│ └── Temperaturanzeige.jpg
├── README.md
├── lcd.cpp
└── lcd.h
├── HM-WDS40-TH-I-SHT31
└── HM-WDS40-TH-I-SHT31.ino
├── HM-WDS40-TH-I-SI7021
└── HM-WDS40-TH-I-SI7021.ino
├── RWE
├── HB-LC-Bl1PBU-FM_ISR2
│ └── HB-LC-Bl1PBU-FM_ISR2.ino
├── HM-LC-Bl1PBU-FM_ISR2.0
│ └── HM-LC-Bl1PBU-FM_ISR2.0.ino
├── HM-LC-Dim1TPBU-FM_ISD2
│ └── HM-LC-Dim1TPBU-FM_ISD2.ino
├── HM-LC-Sw1-Pl-DN-R1_PSS
│ └── HM-LC-Sw1-Pl-DN-R1_PSS.ino
├── HM-LC-Sw1PBU-FM_ISS2
│ └── HM-LC-Sw1PBU-FM_ISS2.ino
├── HM-PB-2-FM_ISC2
│ └── HM-PB-2-FM_ISC2.ino
├── HM-PB-2-FM_WSC2
│ ├── HM-PB-2-FM_WSC2.ino
│ └── schematic
│ │ ├── schematic.png
│ │ ├── wsc2-cache.lib
│ │ ├── wsc2.kicad_pcb
│ │ ├── wsc2.kicad_prl
│ │ ├── wsc2.kicad_pro
│ │ ├── wsc2.pro
│ │ ├── wsc2.sch
│ │ └── wsc2.sch-bak
├── HM-RC-8_BRC8
│ ├── HM-RC-8_BRC8.ino
│ └── README.txt
├── HM-SEC-SC_WDS
│ └── HM-SEC-SC_WDS.ino
├── HM-SEC-SC_WDSo2.0
│ └── HM-SEC-SC_WDSo2.0.ino
└── HM-Sen-MDIR-O_WMD_O
│ └── HM-Sen-MDIR-O_WMD_O.ino
├── _wip_HM-MOD-EM-8
└── _wip_HM-MOD-EM-8.ino
└── _wip_HM-MOD-EM-8Bit
└── _wip_HM-MOD-EM-8Bit.ino
/.gitmodules:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/.gitmodules
--------------------------------------------------------------------------------
/Images/arduino_bottom.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/arduino_bottom.jpg
--------------------------------------------------------------------------------
/Images/arduino_settings_board.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/arduino_settings_board.png
--------------------------------------------------------------------------------
/Images/arduino_sketch_open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/arduino_sketch_open.png
--------------------------------------------------------------------------------
/Images/arduino_top.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/arduino_top.jpg
--------------------------------------------------------------------------------
/Images/ftdi_flash.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/ftdi_flash.jpg
--------------------------------------------------------------------------------
/Images/hm-rc-p1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/hm-rc-p1.jpg
--------------------------------------------------------------------------------
/Images/hm_anlernen1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/hm_anlernen1.png
--------------------------------------------------------------------------------
/Images/hm_config1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/hm_config1.png
--------------------------------------------------------------------------------
/Images/sketch_aes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/sketch_aes.png
--------------------------------------------------------------------------------
/Images/sketch_pins.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/sketch_pins.png
--------------------------------------------------------------------------------
/Images/sketch_serial.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/sketch_serial.png
--------------------------------------------------------------------------------
/Images/wiring.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/wiring.fzz
--------------------------------------------------------------------------------
/Images/wiring_arduino_cc1101.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/wiring_arduino_cc1101.png
--------------------------------------------------------------------------------
/Images/wiring_arduino_cc1101_00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/wiring_arduino_cc1101_00.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Beispiel für die Verwendung der [AskSinPP](https://github.com/pa-pa/AskSinPP) Bibliothek
2 | ## zum Nachbau eines HM-[1-Kanal Senders](https://github.com/pa-pa/AskSinPP/tree/master/examples/HM-RC-P1) mittels Arduino Pro mini, CC1101 und [AskSinPP](https://github.com/pa-pa/AskSinPP) Arduino-Bibliothek.
3 | ### Mithilfe dieser Bibliothek lässt sich sehr preiswert eine Vielzahl von HomeMatic[-Sensoren, -Aktoren und -Sendern](https://github.com/pa-pa/AskSinPP/tree/master/examples) nachbauen!
Eine Übersicht, welche Geräte es gibt, findet ihr [hier](https://github.com/jp112sdl/AskSinPPCollection).
4 |
5 |
6 | 
7 |
8 |
9 | ## Hardwaresektion
10 | ### Bauteile
11 | - 1x Arduino Pro Mini (3.3V 8MHz) (ca. 2,20 EUR bei [eBay](https://www.ebay.de/itm/272812248667))
12 | - 1x CC1101 Funkmodul 868MHz (ca. 2,60 EUR bei [eBay](https://www.ebay.de/itm/272455136087))
13 | - 1x Batteriehalter 2x AA (ca. 2,30 EUR bei [eBay](http://www.ebay.de/itm/200988520956))
14 | - 1x FTDI Adapter (falls nicht schon vorhanden, gibts bei [Amazon](https://www.amazon.de/FT232RL-FTDI-USB-auf-TTL-Serienadapter-Arduino/dp/B00HSXDGOE))
15 | - 2x Taster (beliebig, z.B. [Kurzhubtaster](https://www.ebay.de/itm/112592788992))
16 | - 2x AA Batterien
17 |
18 | ### Gehäuse
19 | - bei Thingiverse ([Link](https://www.thingiverse.com/thing:2840228)) gibt es für den Temp-/Feuchtesensor HM-WDS10-TH-I-DHT22 ein super praktisches Gehäuse!
20 |
21 | ### Verdrahtung
22 | _allgemeingültige Verdrahtung (Anschluss CC1101 an Arduino Pro Mini) auch für andere AskSinPP-Projekte_
23 | 
24 |
25 | **Der Anschluss des Sende-Tasters**
26 | - **erfolgt an A0 / GND!**
27 |
28 | **Der Anschluss der Batterien**
29 | - **+ an VCC**
30 | - **- an GND**
31 |
32 | **Stromverbrauch: Um den Stromverbrauch zu reduzieren, sind die beiden Bauteile (LDO und LED; rotes X) von der Arduino Pro Mini Platine zu entfernen.**
33 |
34 | **_Mithilfe von Kupferlackdraht kann das Funkmodul platzspared "huckepack" am Arduino Pro Mini angeschlossen werden:_**
35 | 
36 |
37 | Unterseite:
38 | 
39 |
40 | ## Universalplatine
41 | Wer eine eigene Platine herstellen möchte, kann auf eine Auswahl verschiedener vorgefertigter Layouts zurückgreifen.
42 | z.B.:
43 | - [PCB](https://github.com/alexreinert/PCB) von alexreinert
44 | - [HMSensor](https://github.com/pa-pa/HMSensor) von pa-pa
45 |
46 | ### Anschluss des FTDI Adapters zum Flashen
47 | - Um die Schaltung sehr kompakt zu halten, verzichte ich auf das Anlöten eines Steckverbinders. Es reicht aus, wenn man die Pins des FTDI Adapters durch die Lötbohrungen steckt. Während des Flash-Vorgangs verkantet man beide Platinen leicht, damit die Kontaktierung gegeben ist.
48 |
49 | 
50 |
51 | ## Softwareabteilung
52 | ### Arduino IDE
53 | - Arduino IDE [herunterladen](https://www.arduino.cc/en/Main/Software) und installieren
54 | - AskSinPP Bibliothek als [ZIP herunterladen](https://github.com/pa-pa/AskSinPP/archive/master.zip)
55 | - notwendige Bibliotheken in der Arduino IDE hinzufügen:
56 | - Sketch -> Bibliothek einbinden -> .ZIP-Bibliothek hinzufügen
57 | - heruntergeladene AskSinPP Bibliothek ZIP-Datei auswählen
58 | - Sketch -> Bibliothek einbinden -> Bibliotheken verwalten
59 | - im Suchfeld folgende Bibliotheken suchen und installieren:
60 | - EnableInterrupt
61 | - Low-Power
62 | - Board einstellen:
63 | - Board: `Arduino Pro or Pro Mini`
64 | - Prozessor: `ATmega328P (3.3V, 8 MHz)`
65 | - Port: `COM-Port` des FTDI Adapters
66 |
67 | - Sketch öffnen:
68 | - Datei
69 | - Beispiele
70 | - AskSinPP
71 | - HM-RC-P1
72 |
73 | - Anpassungen:
74 | - gerade wenn man mehrere Geräte des selben Typs verwenden will, muss man für jedes Gerät eine eigene Seriennummer vergeben! Es sind dabei sowohl die `Device ID` (Hexadezimal) als auch die `Device Serial` (Freitext) zu ändern!
75 |
76 |
77 |
78 | - Sketch hochladen:
79 | - Sketch
80 | - Hochladen
81 |
82 | Die Pinbelegungen des Arduino stehen in den jeweiligen Sketchen der Projektdateien.
83 | Beim 1-Kanal Paniksender z.B.: Config-Taster an Pin **8** und Button1 an **A0**:
84 |
85 |
86 |
87 | ### Anlernen an HomeMatic
88 | - Geräte anlernen -> HM-Gerät anlernen klicken
89 | - **Config-Taster** am Arduino Pro Mini **kurz** drücken
90 | - das neue Gerät erscheint anschließend im Posteingang
91 |
92 |
93 | - Einstellungen -> Geräte -> "+" anklicken, anschließend den Kanal anklicken
94 | - "gesicherte" Übertragung deaktivieren
95 |
96 |
97 | **AES Verschlüsselung für die gesicherte Übertragung ist prinzipiell auch möglich, ist aber etwas kompliziert zu beschreiben (auch wenn die Sache selbst relativ unkompliziert ist**
98 |
--------------------------------------------------------------------------------
/examples/HB-LC-Bl1PBU-FM/README.md:
--------------------------------------------------------------------------------
1 | # alternative Firmware für den HM-LC-Bl1PBU-FM
2 |
3 | Mit dieser Firmware lassen sich die beiden Taster (oben / unten) und die Rollladenrelais getrennt voneinander benutzen.
4 | (Es wird mind. Version 1.23 des [JP-HB-Devices Addon](https://github.com/jp112sdl/JP-HB-Devices-addon) benötigt)
5 |
6 | Anschluss des ISP an die Controller-Platine des HM-LC-Bl1PBU-FM:
7 | https://github.com/jabdoa2/Asksin_HM_LC_Sw1PBU_FM
8 |
--------------------------------------------------------------------------------
/examples/HB-LC-SW12-FM/HB-LC-SW12-FM.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | // 2018-02-17 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 | //- -----------------------------------------------------------------------------------------------------------------------
6 | // ci-test=yes board=328p aes=no
7 |
8 | // define this to read the device id, serial and device type from bootloader section
9 | // #define USE_OTA_BOOTLOADER
10 |
11 | #define EI_NOTEXTERNAL
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 |
18 | #define CONFIG_BUTTON_PIN 8
19 | #define RELAY1_PIN 3
20 | #define RELAY2_PIN 4
21 | #define RELAY3_PIN 5
22 | #define RELAY4_PIN 6
23 | #define RELAY5_PIN 7
24 | #define RELAY6_PIN 9
25 | #define RELAY7_PIN 14
26 | #define RELAY8_PIN 15
27 | #define RELAY9_PIN 16
28 | #define RELAY10_PIN 17
29 | #define RELAY11_PIN 18
30 | #define RELAY12_PIN 19
31 |
32 | // number of available peers per channel
33 | #define PEERS_PER_CHANNEL 2
34 |
35 | // all library classes are placed in the namespace 'as'
36 | using namespace as;
37 |
38 | // define all device properties
39 | const struct DeviceInfo PROGMEM devinfo = {
40 | {0xf3,0x20,0x00}, // Device ID
41 | "JPSW120001", // Device Serial
42 | {0xf3,0x20}, // Device Model
43 | 0x10, // Firmware Version
44 | as::DeviceType::Switch, // Device Type
45 | {0x01,0x00} // Info Bytes
46 | };
47 |
48 | /**
49 | * Configure the used hardware
50 | */
51 | typedef AvrSPI<10,11,12,13> RadioSPI;
52 | typedef AskSin > Hal;
53 |
54 | typedef MultiChannelDevice,12> SwitchType;
55 | Hal hal;
56 | SwitchType sdev(devinfo,0x20);
57 | ConfigButton cfgBtn(sdev);
58 |
59 | void initPeerings (bool first) {
60 | // create internal peerings - CCU2 needs this
61 | if( first == true ) {
62 | HMID devid;
63 | sdev.getDeviceID(devid);
64 | for( uint8_t i=1; i<=sdev.channels(); ++i ) {
65 | Peer ipeer(devid,i);
66 | sdev.channel(i).peer(ipeer);
67 | }
68 | }
69 | }
70 |
71 | void setup () {
72 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
73 | bool first = sdev.init(hal);
74 | sdev.channel(1).init(RELAY1_PIN);
75 | sdev.channel(2).init(RELAY2_PIN);
76 | sdev.channel(3).init(RELAY3_PIN);
77 | sdev.channel(4).init(RELAY4_PIN);
78 | sdev.channel(5).init(RELAY5_PIN);
79 | sdev.channel(6).init(RELAY6_PIN);
80 | sdev.channel(7).init(RELAY7_PIN);
81 | sdev.channel(8).init(RELAY8_PIN);
82 | sdev.channel(9).init(RELAY9_PIN);
83 | sdev.channel(10).init(RELAY10_PIN);
84 | sdev.channel(11).init(RELAY11_PIN);
85 | sdev.channel(12).init(RELAY12_PIN);
86 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
87 | initPeerings(first);
88 | sdev.initDone();
89 | }
90 |
91 | void loop() {
92 | bool worked = hal.runready();
93 | bool poll = sdev.pollRadio();
94 | if( worked == false && poll == false ) {
95 | hal.activity.savePower >(hal);
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/examples/HB-LC-Sw1PBU-FM/HB-LC-Sw1PBU-FM.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | // 2018-10-07 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 | //- -----------------------------------------------------------------------------------------------------------------------
6 | // ci-test=yes board=644p aes=no
7 |
8 | // define this to read the device id, serial and device type from bootloader section
9 | // #define USE_OTA_BOOTLOADER
10 |
11 | // Arduino IDE Settings
12 | // use support for 644PA from MightyCore: https://github.com/MCUdude/MightyCore
13 | // settings:
14 | // Board: ATMega644
15 | // Pinout: Standard
16 | // Clock: 8MHz external
17 | // Variant: 644P / 644PA
18 | // BOD: 2.7V
19 | // Compiler LTO: Enabled
20 |
21 | #define NDEBUG
22 |
23 | #define EI_NOTEXTERNAL
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | #define RELAY_PIN 12 //PD4
33 | #define BTN_PIN_1 14 //PD6
34 | #define BTN_PIN_2 8 //PD0
35 | #define LED_PIN 0 //PB0
36 | #define CONFIG_BUTTON_PIN 15 //PD7
37 | #define CS_PIN 4 //PB4
38 | #define GDO0_PIN 10 //PD2
39 |
40 |
41 | // number of available peers per channel
42 | #define PEERS_PER_SwitchChannel 8
43 | #define PEERS_PER_RemoteChannel 12
44 |
45 | // all library classes are placed in the namespace 'as'
46 | using namespace as;
47 |
48 | // define all device properties
49 | const struct DeviceInfo PROGMEM devinfo = {
50 | {0xf3, 0x35, 0x01},// Device ID
51 | "HBSw1PBU01", // Device Serial
52 | {0xf3, 0x35}, // Device Model
53 | 0x10, // Firmware Version
54 | as::DeviceType::Switch, // Device Type
55 | {0x01, 0x00} // Info Bytes
56 | };
57 | /**
58 | Configure the used hardware
59 | */
60 | typedef LibSPI SPIType;
61 | typedef Radio RadioType;
62 | typedef StatusLed LedType;
63 | typedef AskSin Hal;
64 | Hal hal;
65 |
66 | DEFREGISTER(Reg0, MASTERID_REGS, DREG_INTKEY, DREG_CYCLICINFOMSG)
67 | class SwList0 : public RegList0 {
68 | public:
69 | SwList0(uint16_t addr) : RegList0(addr) {}
70 | void defaults() {
71 | clear();
72 | intKeyVisible(true);
73 | }
74 | };
75 |
76 | typedef SwitchChannel SwChannel;
77 | typedef RemoteChannel BtnChannel;
78 |
79 | class MixDevice : public ChannelDevice, 3, SwList0> {
80 | public:
81 | VirtChannel swc1;
82 | VirtChannel btc1, btc2;
83 |
84 | public:
85 | typedef ChannelDevice, 3, SwList0> DeviceType;
86 | MixDevice (const DeviceInfo& info, uint16_t addr) : DeviceType(info, addr) {
87 | DeviceType::registerChannel(swc1, 1);
88 | DeviceType::registerChannel(btc1, 2);
89 | DeviceType::registerChannel(btc2, 3);
90 | }
91 | virtual ~MixDevice () {}
92 |
93 | SwChannel& sw1Channel () {
94 | return swc1;
95 | }
96 |
97 | BtnChannel& btn1Channel () {
98 | return btc1;
99 | }
100 | BtnChannel& btn2Channel () {
101 | return btc2;
102 | }
103 | };
104 | MixDevice sdev(devinfo, 0x20);
105 | ConfigButton cfgBtn(sdev);
106 |
107 | void initPeerings (bool first) {
108 | if ( first == true ) {
109 | HMID devid;
110 | sdev.getDeviceID(devid);
111 | sdev.sw1Channel().peer(Peer(devid, 2), Peer(devid, 3));
112 | sdev.btn1Channel().peer(Peer(devid, 1));
113 | sdev.btn2Channel().peer(Peer(devid, 1));
114 | }
115 | }
116 |
117 | void setup () {
118 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
119 | bool first = sdev.init(hal);
120 | sdev.sw1Channel().init(RELAY_PIN, false);
121 | remoteChannelISR(sdev.btn1Channel(), BTN_PIN_1);
122 | remoteChannelISR(sdev.btn2Channel(), BTN_PIN_2);
123 |
124 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
125 |
126 | initPeerings(first);
127 | storage().store();
128 |
129 | sdev.initDone();
130 | }
131 |
132 | void loop() {
133 | bool worked = hal.runready();
134 | bool poll = sdev.pollRadio();
135 | if ( worked == false && poll == false ) {
136 | hal.activity.savePower >(hal);
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/examples/HB-LC-Sw1PBU-FM/README.md:
--------------------------------------------------------------------------------
1 | # alternative Firmware für den HM-LC-Sw1PBU-FM
2 |
3 | Mit dieser Firmware lassen sich die beiden Taster (oben / unten) und das Relais getrennt voneinander benutzen.
4 | (Es wird mind. Version 1.21 des [JP-HB-Devices Addon](https://github.com/jp112sdl/JP-HB-Devices-addon) benötigt)
5 |
6 | Anschluss des ISP an die Controller-Platine des HM-LC-Sw1PBU-FM:
7 | https://github.com/jabdoa2/Asksin_HM_LC_Sw1PBU_FM
8 |
--------------------------------------------------------------------------------
/examples/HB-LC-Sw2PBU-FM/HB-LC-Sw2PBU-FM.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | // 2018-10-07 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 | //- -----------------------------------------------------------------------------------------------------------------------
6 | // ci-test=yes board=644p aes=no
7 |
8 | // define this to read the device id, serial and device type from bootloader section
9 | // #define USE_OTA_BOOTLOADER
10 |
11 | // Arduino IDE Settings
12 | // use support for 644PA from MightyCore: https://github.com/MCUdude/MightyCore
13 | // settings:
14 | // Board: ATMega644
15 | // Pinout: Standard
16 | // Clock: 8MHz external
17 | // Variant: 644P / 644PA
18 | // BOD: 2.7V
19 | // Compiler LTO: Enabled
20 |
21 | #define NDEBUG
22 |
23 | #define EI_NOTEXTERNAL
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | #define RELAY_1_PIN 12 //PD4
33 | #define RELAY_2_PIN 13 //PD5
34 | #define BTN_1_PIN 14 //PD6
35 | #define BTN_2_PIN 8 //PD0
36 | #define LED_PIN 0 //PB0
37 | #define CONFIG_BUTTON_PIN 15 //PD7
38 | #define CS_PIN 4 //PB4
39 | #define GDO0_PIN 10 //PD2
40 |
41 |
42 | // number of available peers per channel
43 | #define PEERS_PER_SwitchChannel 8
44 | #define PEERS_PER_RemoteChannel 12
45 |
46 | // all library classes are placed in the namespace 'as'
47 | using namespace as;
48 |
49 | // define all device properties
50 | const struct DeviceInfo PROGMEM devinfo = {
51 | {0xf3, 0x36, 0x01},// Device ID
52 | "HBSw2PBU01", // Device Serial
53 | {0xf3, 0x36}, // Device Model
54 | 0x10, // Firmware Version
55 | as::DeviceType::Switch, // Device Type
56 | {0x01, 0x00} // Info Bytes
57 | };
58 | /**
59 | Configure the used hardware
60 | */
61 | typedef LibSPI SPIType;
62 | typedef Radio RadioType;
63 | typedef StatusLed LedType;
64 | typedef AskSin Hal;
65 | Hal hal;
66 |
67 | DEFREGISTER(Reg0, MASTERID_REGS, DREG_INTKEY, DREG_CYCLICINFOMSG)
68 | class SwList0 : public RegList0 {
69 | public:
70 | SwList0(uint16_t addr) : RegList0(addr) {}
71 | void defaults() {
72 | clear();
73 | intKeyVisible(true);
74 | }
75 | };
76 |
77 | typedef SwitchChannel SwChannel;
78 | typedef RemoteChannel BtnChannel;
79 |
80 | class MixDevice : public ChannelDevice, 4, SwList0> {
81 | public:
82 | VirtChannel swc1, swc2;
83 | VirtChannel btc1, btc2;
84 | public:
85 | typedef ChannelDevice, 4, SwList0> DeviceType;
86 | MixDevice (const DeviceInfo& info, uint16_t addr) : DeviceType(info, addr) {
87 | DeviceType::registerChannel(swc1, 1);
88 | DeviceType::registerChannel(swc2, 2);
89 | DeviceType::registerChannel(btc1, 3);
90 | DeviceType::registerChannel(btc2, 4);
91 | }
92 | virtual ~MixDevice () {}
93 |
94 | SwChannel& sw1Channel () {
95 | return swc1;
96 | }
97 | SwChannel& sw2Channel () {
98 | return swc2;
99 | }
100 | BtnChannel& btn1Channel () {
101 | return btc1;
102 | }
103 | BtnChannel& btn2Channel () {
104 | return btc2;
105 | }
106 | };
107 | MixDevice sdev(devinfo, 0x20);
108 | ConfigButton cfgBtn(sdev);
109 |
110 | void initPeerings (bool first) {
111 | if ( first == true ) {
112 | HMID devid;
113 | sdev.getDeviceID(devid);
114 | sdev.sw1Channel().peer(Peer(devid, 3));
115 | sdev.sw2Channel().peer(Peer(devid, 4));
116 | sdev.btn1Channel().peer(Peer(devid, 1));
117 | sdev.btn2Channel().peer(Peer(devid, 2));
118 | }
119 | }
120 |
121 | void setup () {
122 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
123 | bool first = sdev.init(hal);
124 | sdev.sw1Channel().init(RELAY_1_PIN, false);
125 | sdev.sw2Channel().init(RELAY_2_PIN, false);
126 | remoteChannelISR(sdev.btn1Channel(), BTN_1_PIN);
127 | remoteChannelISR(sdev.btn2Channel(), BTN_2_PIN);
128 |
129 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
130 |
131 | initPeerings(first);
132 | storage().store();
133 |
134 | sdev.initDone();
135 | }
136 |
137 | void loop() {
138 | bool worked = hal.runready();
139 | bool poll = sdev.pollRadio();
140 | if ( worked == false && poll == false ) {
141 | hal.activity.savePower >(hal);
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/examples/HB-LC-Sw2PBU-FM/README.md:
--------------------------------------------------------------------------------
1 | # alternative Firmware für den HM-LC-Sw2PBU-FM
2 |
3 | Mit dieser Firmware lassen sich die beiden Taster (oben / unten) und die Relais getrennt voneinander benutzen.
4 | (Es wird mind. Version 1.22 des [JP-HB-Devices Addon](https://github.com/jp112sdl/JP-HB-Devices-addon) benötigt)
5 |
6 | Anschluss des ISP an die Controller-Platine des HM-LC-Sw2PBU-FM:
7 | https://github.com/jabdoa2/Asksin_HM_LC_Sw1PBU_FM
8 |
--------------------------------------------------------------------------------
/examples/HB-LC-Sw3-LIDL/HB-LC-Sw3-LIDL.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | // 2021-09-26 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 | //- -----------------------------------------------------------------------------------------------------------------------
6 |
7 | #define EI_NOTEXTERNAL
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #define LED_PIN 4 //LED
14 | #define RELAY1_PIN 5 //K1
15 | #define RELAY2_PIN 6 //K2
16 | #define RELAY3_PIN 7 //K3
17 | #define CONFIG_BUTTON_PIN 8 //Switch
18 |
19 | #define RELAY_ACTIVE_LOW false
20 |
21 | #define PEERS_PER_CHANNEL 8
22 |
23 | using namespace as;
24 | const struct DeviceInfo PROGMEM devinfo = {
25 | {0xf3,0x26,0x01}, // Device ID
26 | "JHLCSW3L01", // Device Serial
27 | {0xf3,0x26}, // Device Model
28 | 0x16, // Firmware Version
29 | as::DeviceType::Switch, // Device Type
30 | {0x01,0x00} // Info Bytes
31 | };
32 | typedef AvrSPI<10,11,12,13> RadioSPI;
33 | typedef AskSin,NoBattery,Radio > Hal;
34 | typedef MultiChannelDevice,3> SwitchType;
35 | Hal hal;
36 | SwitchType sdev(devinfo,0x20);
37 | ConfigButton cfgBtn(sdev);
38 |
39 | void setup () {
40 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
41 | sdev.init(hal);
42 | sdev.channel(1).init(RELAY1_PIN,RELAY_ACTIVE_LOW);
43 | sdev.channel(2).init(RELAY2_PIN,RELAY_ACTIVE_LOW);
44 | sdev.channel(3).init(RELAY3_PIN,RELAY_ACTIVE_LOW);
45 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
46 | sdev.led().invert(true);
47 | sdev.initDone();
48 | }
49 |
50 | void loop() {
51 | bool worked = hal.runready();
52 | bool poll = sdev.pollRadio();
53 | if( worked == false && poll == false ) {
54 | hal.activity.savePower >(hal);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/examples/HB-LC-Sw3-LIDL/README.md:
--------------------------------------------------------------------------------
1 | weitere Informationen im Homematic-Forum:
2 | https://homematic-forum.de/forum/viewtopic.php?f=76&t=69743
3 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/HB-UW-Sen-THPL.h:
--------------------------------------------------------------------------------
1 | #if defined(ARDUINO) && ARDUINO >= 100
2 | #include "Arduino.h"
3 | #else
4 | #include "WProgram.h"
5 | #endif
6 |
7 | /**
8 | * Must set in AskSinMain.h to !!!
9 | *
10 | * Set to 1 to read address data from end of bootloader section
11 | * Set to 0 to read address data from program space
12 | */
13 | #define USE_ADRESS_SECTION 0
14 |
15 | #define ADDRESS_SECTION_START 0x7FF0 // Start address of data in adress section at and of bootloader
16 |
17 | /**
18 | * Activate for serial debug infos
19 | */
20 | #define SER_DBG
21 |
22 | #define FIRMWARE_VERSION 0x0F // 0.15
23 |
24 | /*
25 | * Address data if we don't read them from bootloader section
26 | */
27 | #if USE_ADRESS_SECTION == 0
28 | //#define DEVICE_TYPE 0xF1, 0x01 // The model-ID 0xF1 0x01 = DIY (HB-UW-Sen-THPL-I)
29 | #define DEVICE_TYPE 0xF1, 0x02 // The model-ID 0xF1 0x02 = DIY (HB-UW-Sen-THPL-O)
30 | #define DEVICE_SERIAL 'U','W','S','0','0','0','0','0','0','1' // The serial 10 bytes, needed for pairing (Default for serial flash tool)
31 | #define DEVICE_ADDRESS 0x19, 0x15, 0x17 // The HM-ID 3 bytes, needed for pairing (Default for flash tool)
32 | #endif
33 |
34 | #define BATTERY_MEASSUREMENT_FACTOR 17 // Faktor Spannungsteiler externe Batteriemessung
35 | #define BATTERY_MIN_VOLTAGE 10 // minimal configuable low battery voltage level
36 | #define BATTERY_MAX_VOLTAGE 50 // maximal configuable low battery voltage level
37 |
38 | void getPgmSpaceData(uint8_t *buffer, uint16_t address, uint8_t len);
39 | void getDataFromAddressSection(uint8_t *buffer, uint8_t bufferStartAddress, uint16_t sectionAddress, uint8_t dataLen);
40 |
41 | void cmdConfigChanged(uint8_t *data, uint8_t len);
42 | void cmdReset(uint8_t *data, uint8_t len);
43 | void cmdStatusRequest(uint8_t *data, uint8_t len);
44 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/AskSin/Dummy.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- Dummy class for own developments --------------------------------------------------------------------------------------
6 | //- -----------------------------------------------------------------------------------------------------------------------
7 | #include "Dummy.h"
8 |
9 |
10 |
11 | //- mandatory functions for every new module to communicate within HM protocol stack --------------------------------------
12 | void Dummy::configCngEvent(void) {
13 | // it's only for information purpose while something in the channel config was changed (List0/1 or List3/4)
14 | #ifdef DM_DBG
15 | Serial << F("configCngEvent\n");
16 | #endif
17 | }
18 | void Dummy::pairSetEvent(uint8_t *data, uint8_t len) {
19 | // we received a message from master to set a new value, typical you will find three bytes in data
20 | // 1st byte = value; 2nd byte = ramp time; 3rd byte = duration time;
21 | // after setting the new value we have to send an enhanced ACK (<- 0E E7 80 02 1F B7 4A 63 19 63 01 01 C8 00 54)
22 | #ifdef DM_DBG
23 | Serial << F("pairSetEvent, value:"); pHexB(data[0]);
24 | if (len > 1) Serial << F(", rampTime: "); pHexB(data[1]);
25 | if (len > 2) Serial << F(", duraTime: "); pHexB(data[2]);
26 | Serial << F("\n");
27 | #endif
28 |
29 | hm->sendACKStatus(regCnl,modStat,0);
30 | }
31 | void Dummy::pairStatusReq(void) {
32 | // we received a status request, appropriate answer is an InfoActuatorStatus message
33 | #ifdef DM_DBG
34 | Serial << F("pairStatusReq\n");
35 | #endif
36 |
37 | hm->sendInfoActuatorStatus(regCnl, modStat, 0);
38 | }
39 | void Dummy::peerMsgEvent(uint8_t type, uint8_t *data, uint8_t len) {
40 | // we received a peer event, in type you will find the marker if it was a switch(3E), remote(40) or sensor(41) event
41 | // appropriate answer is an ACK
42 | #ifdef DM_DBG
43 | Serial << F("peerMsgEvent, type: "); pHexB(type);
44 | Serial << F(", data: "); pHex(data,len, SERIAL_DBG_PHEX_MODE_LF);
45 | #endif
46 |
47 | hm->send_ACK();
48 | }
49 |
50 | void Dummy::poll(void) {
51 | // just polling, as the function name said
52 | }
53 |
54 | //- predefined, no reason to touch ----------------------------------------------------------------------------------------
55 | void Dummy::regInHM(uint8_t cnl, HM *instPtr) {
56 | hm = instPtr; // set pointer to the HM module
57 | hm->regCnlModule(cnl,s_mod_dlgt(this,&Dummy::hmEventCol),(uint16_t*)&ptrMainList,(uint16_t*)&ptrPeerList);
58 | regCnl = cnl; // stores the channel we are responsible fore
59 | }
60 | void Dummy::hmEventCol(uint8_t by3, uint8_t by10, uint8_t by11, uint8_t *data, uint8_t len) {
61 | if (by3 == 0x00) poll();
62 | else if ((by3 == 0x01) && (by11 == 0x06)) configCngEvent();
63 | else if ((by3 == 0x11) && (by10 == 0x02)) pairSetEvent(data, len);
64 | else if ((by3 == 0x01) && (by11 == 0x0E)) pairStatusReq();
65 | else if ((by3 == 0x01) && (by11 == 0x01)) peerAddEvent(data, len);
66 | else if (by3 >= 0x3E) peerMsgEvent(by3, data, len);
67 | else return;
68 | }
69 | void Dummy::peerAddEvent(uint8_t *data, uint8_t len) {
70 | // we received an peer add event, which means, there was a peer added in this respective channel
71 | // 1st byte and 2nd byte shows the peer channel, 3rd and 4th byte gives the peer index
72 | // no need for sending an answer, but we could set default data to the respective list3/4
73 | #ifdef DM_DBG
74 | Serial << F("peerAddEvent: pCnl1: "); pHexB(data[0]);
75 | Serial << F(", pCnl2: "); pHexB(data[1]);
76 | Serial << F(", pIdx1: "); pHexB(data[2]);
77 | Serial << F(", pIdx2: "); pHexB(data[3]);
78 | Serial << F("\n");
79 | #endif
80 |
81 | if ((data[0]) && (data[1])) { // dual peer add
82 | if (data[0]%2) { // odd
83 | hm->setListFromModule(regCnl,data[2],(uint8_t*)peerOdd,sizeof(peerOdd));
84 | hm->setListFromModule(regCnl,data[3],(uint8_t*)peerEven,sizeof(peerEven));
85 | } else { // even
86 | hm->setListFromModule(regCnl,data[2],(uint8_t*)peerEven,sizeof(peerEven));
87 | hm->setListFromModule(regCnl,data[3],(uint8_t*)peerOdd,sizeof(peerOdd));
88 | }
89 | } else { // single peer add
90 | if (data[0]) hm->setListFromModule(regCnl,data[2],(uint8_t*)peerSingle,sizeof(peerSingle));
91 | if (data[1]) hm->setListFromModule(regCnl,data[3],(uint8_t*)peerSingle,sizeof(peerSingle));
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/AskSin/Dummy.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- Dummy class for own developments --------------------------------------------------------------------------------------
6 | //- -----------------------------------------------------------------------------------------------------------------------
7 | #ifndef DUMMY_H
8 | #define DUMMY_H
9 |
10 | #if defined(ARDUINO) && ARDUINO >= 100
11 | #include "Arduino.h"
12 | #else
13 | #include "WProgram.h"
14 | #endif
15 |
16 | #include "AskSinMain.h"
17 | #include "utility/Serial.h"
18 | #include "utility/Fastdelegate.h"
19 |
20 | #define DM_DBG // debug message flag
21 |
22 | const uint8_t peerOdd[] = {}; // default settings for list3 or list4
23 | const uint8_t peerEven[] = {};
24 | const uint8_t peerSingle[] = {};
25 |
26 | class Dummy {
27 | //- user code here ------------------------------------------------------------------------------------------------------
28 | public://----------------------------------------------------------------------------------------------------------------
29 | protected://-------------------------------------------------------------------------------------------------------------
30 | private://---------------------------------------------------------------------------------------------------------------
31 |
32 |
33 | //- mandatory functions for every new module to communicate within HM protocol stack ------------------------------------
34 | public://----------------------------------------------------------------------------------------------------------------
35 | uint8_t modStat; // module status byte, needed for list3 modules to answer status requests
36 | uint8_t regCnl; // holds the channel for the module
37 |
38 | HM *hm; // pointer to HM class instance
39 | uint8_t *ptrPeerList; // pointer to list3/4 in regs struct
40 | uint8_t *ptrMainList; // pointer to list0/1 in regs struct
41 |
42 | void configCngEvent(void); // list1 on registered channel had changed
43 | void pairSetEvent(uint8_t *data, uint8_t len); // pair message to specific channel, handover information for value, ramp time and so on
44 | void pairStatusReq(void); // event on status request
45 | void peerMsgEvent(uint8_t type, uint8_t *data, uint8_t len); // peer message was received on the registered channel, handover the message bytes and length
46 |
47 | void poll(void); // poll function, driven by HM loop
48 |
49 | //- predefined, no reason to touch ------------------------------------------------------------------------------------
50 | void regInHM(uint8_t cnl, HM *instPtr); // register this module in HM on the specific channel
51 | void hmEventCol(uint8_t by3, uint8_t by10, uint8_t by11, uint8_t *data, uint8_t len); // call back address for HM for informing on events
52 | void peerAddEvent(uint8_t *data, uint8_t len); // peer was added to the specific channel, 1st and 2nd byte shows peer channel, third and fourth byte shows peer index
53 | };
54 |
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/Battery.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | // dirk@forum.fhem.de
5 | //- -----------------------------------------------------------------------------------------------------------------------
6 | //- Low battery alarm -----------------------------------------------------------------------------------------------------
7 | //- with a lot of contribution from Dirk at FHEM forum
8 | //- -----------------------------------------------------------------------------------------------------------------------
9 |
10 | #include "Battery.h"
11 |
12 | /**
13 | * Configure the battery measurement
14 | *
15 | * mode: Measurement mode BATTERY_MODE_BANDGAP_MESSUREMENT or BATTERY_MODE_EXTERNAL_MESSUREMENT
16 | * enablePin: The pin which enables the external measurement helper hardware. Set to 0 if not needed.
17 | * adcPin: The ADC pin for external measurement. Set to 0 if not needed.
18 | * time: interval to check the battery voltage
19 | */
20 | void Battery::config(uint8_t mode, uint8_t enablePin, uint8_t adcPin, uint8_t fact, uint16_t time) {
21 | tMode = mode;
22 | tEnablePin = enablePin;
23 | tAdcPin = adcPin;
24 | tFact = fact;
25 | tTime = time;
26 | nTime = time;
27 |
28 | if (tEnablePin > 0) {
29 | pinMode(tEnablePin, INPUT);
30 | }
31 | }
32 |
33 | /**
34 | * Set the minimal battery voltage in tenth volt
35 | *
36 | * tenthVolts: minimum voltage before battery warning occurs
37 | */
38 | void Battery::setMinVoltage(uint8_t tenthVolts) {
39 | tTenthVolts = tenthVolts;
40 | }
41 |
42 | /**
43 | * Cyclic battery measurement function.
44 | */
45 | void Battery::poll(void) {
46 | uint8_t batteryVoltage;
47 |
48 | if ((tMode == 0) || (millis() - nTime < tTime)) {
49 | return; // nothing to do, step out
50 |
51 | } else if (tMode == BATTERY_MODE_BANDGAP_MESSUREMENT) {
52 | voltage = getBatteryVoltageInternal();
53 |
54 | } else if (tMode == BATTERY_MODE_EXTERNAL_MESSUREMENT) {
55 | voltage = getBatteryVoltageExternal();
56 | }
57 |
58 | if ((voltage > oldVoltage && (voltage - oldVoltage) > BATTERY_STATE_HYSTERESIS) || voltage < oldVoltage) {
59 | oldVoltage = voltage;
60 | state = (voltage < tTenthVolts) ? 1 : 0; // set the battery status
61 | }
62 |
63 | nTime = millis();
64 |
65 | }
66 |
67 | /**
68 | * get battery voltage
69 | * Measure AVCC again the the internal band gap reference
70 | *
71 | * REFS1 REFS0 --> internal bandgap reference
72 | * MUX3 MUX2 MUX1 MUX0 --> 1110 1.1V (VBG) (for instance Atmega 328p)
73 | */
74 | uint8_t Battery::getBatteryVoltageInternal() {
75 | uint16_t adcValue = getAdcValue(
76 | (0 << REFS1) | (1 << REFS0), // Voltage Reference = AVCC with external capacitor at AREF pin
77 | (1 << MUX3) | (1 << MUX2) | (1 << MUX1) | (0 << MUX0) // Input Channel = 1.1V (V BG)
78 | );
79 | adcValue = AVR_BANDGAP_VOLTAGE * 1023 / adcValue / 100; // calculate battery voltage in 1/10 V
80 |
81 | return adcValue;
82 | }
83 |
84 | uint8_t Battery::getBatteryVoltageExternal() {
85 | pinMode(tEnablePin, OUTPUT);
86 | digitalWrite(tEnablePin, LOW);
87 |
88 | uint16_t adcValue = getAdcValue(
89 | (1 << REFS1) | (1 << REFS0), tAdcPin // Voltage Reference = Internal 1.1V Voltage Reference
90 | );
91 |
92 | adcValue = adcValue * AVR_BANDGAP_VOLTAGE / 1023 / tFact; // calculate battery voltage in 1/10 V
93 |
94 | pinMode(tEnablePin, INPUT);
95 |
96 | return adcValue;
97 | }
98 |
99 | uint16_t Battery::getAdcValue(uint8_t voltageReference, uint8_t inputChannel) {
100 | uint16_t adcValue = 0;
101 |
102 | ADMUX = (voltageReference | inputChannel);
103 |
104 | ADCSRA = (1 << ADEN) | (1 << ADPS2) | (1 << ADPS1); // Enable ADC and set ADC prescaler
105 | for(int i = 0; i < BATTERY_NUM_MESS_ADC + BATTERY_DUMMY_NUM_MESS_ADC; i++) {
106 | ADCSRA |= (1 << ADSC); // start conversion
107 | while (ADCSRA & (1 << ADSC)) {} // wait for conversion complete
108 |
109 | if (i >= BATTERY_DUMMY_NUM_MESS_ADC) { // we discard the first dummy measurements
110 | adcValue += ADCW;
111 | }
112 | }
113 |
114 | ADCSRA &= ~(1 << ADEN); // ADC disable
115 |
116 | adcValue = adcValue / BATTERY_NUM_MESS_ADC;
117 |
118 | return adcValue;
119 | }
120 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/Battery.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- Low battery alarm -----------------------------------------------------------------------------------------------------
6 | //- with a lot of contribution from Dirk at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | #ifndef BATTERY_H
10 | #define BATTERY_H
11 |
12 | #if defined(ARDUINO) && ARDUINO >= 100
13 | #include "Arduino.h"
14 | #else
15 | #include "WProgram.h"
16 | #endif
17 |
18 | #include
19 | #include
20 | #include "Serial.h"
21 |
22 | class Battery {
23 | public://----------------------------------------------------------------------------------------------------------------
24 |
25 | uint8_t state; // status byte for message handling
26 | uint16_t voltage; // last measured battery voltage
27 |
28 | void config(uint8_t mode, uint8_t enablePin, uint8_t adcPin, uint8_t fact, uint16_t time);
29 | void setMinVoltage(uint8_t tenthVolts); // set the reference voltage in 0.1 volts
30 |
31 | void poll(void); // poll for periodic check
32 |
33 | private://---------------------------------------------------------------------------------------------------------------
34 | uint8_t tMode; // remember the mode
35 | uint8_t tEnablePin;
36 | uint8_t tAdcPin;
37 | float tFact;
38 | uint16_t tTime; // remember the time for periodic check
39 | uint32_t nTime; // timer for periodic check
40 | uint8_t tTenthVolts; // remember the tenth volts set
41 | uint8_t oldVoltage; // old last measured battery voltage
42 |
43 | #define BATTERY_STATE_HYSTERESIS 1 // battery state should reset only if voltage rise greater than given value
44 | #define BATTERY_NUM_MESS_ADC 64
45 | #define BATTERY_DUMMY_NUM_MESS_ADC 10
46 | #define AVR_BANDGAP_VOLTAGE 1100UL // Band gap reference for Atmega328p
47 |
48 | #define BATTERY_MODE_BANDGAP_MESSUREMENT 1
49 | #define BATTERY_MODE_EXTERNAL_MESSUREMENT 2
50 |
51 |
52 | uint8_t getBatteryVoltageInternal();
53 | uint8_t getBatteryVoltageExternal();
54 |
55 | uint16_t getAdcValue(uint8_t voltageReference, uint8_t inputChannel);
56 | };
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/Helpers.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- helper functions ------------------------------------------------------------------------------------------------------
6 | //- -----------------------------------------------------------------------------------------------------------------------
7 |
8 | #include "Helpers.h"
9 |
10 | extern uint16_t __bss_end, _pHeap_start;
11 | extern void *__brkval;
12 | uint16_t freeMem() { // shows free memory
13 | uint16_t free_memory;
14 |
15 | if((uint16_t)__brkval == 0) {
16 | free_memory = ((uint16_t)&free_memory) - ((uint16_t)&__bss_end);
17 | } else {
18 | free_memory = ((uint16_t)&free_memory) - ((uint16_t)__brkval);
19 | }
20 |
21 | return free_memory;
22 | }
23 |
24 | uint16_t crc16(uint16_t crc, uint8_t a) {
25 | crc ^= a;
26 | for (uint8_t i = 0; i < 8; ++i) {
27 | if (crc & 1) {
28 | crc = (crc >> 1) ^ 0xA001;
29 | } else {
30 | crc = (crc >> 1);
31 | }
32 | }
33 |
34 | return crc;
35 | }
36 |
37 | uint32_t byteTimeCvt(uint8_t tTime) {
38 | const uint16_t c[8] = {1,10,50,100,600,3000,6000,36000};
39 | return (uint32_t)(tTime & 0x1f) * c[tTime >> 5] * 100;
40 | }
41 |
42 | uint32_t intTimeCvt(uint16_t iTime) {
43 | if (iTime == 0) {
44 | return 0;
45 | }
46 |
47 | uint8_t tByte;
48 | if ((iTime & 0x1F) != 0) {
49 | tByte = 2;
50 | for (uint8_t i = 1; i < (iTime & 0x1F); i++) {
51 | tByte *= 2;
52 | }
53 | } else {
54 | tByte = 1;
55 | }
56 |
57 | return (uint32_t)tByte * (iTime >> 5) * 100;
58 | }
59 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/Helpers.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- helper functions ------------------------------------------------------------------------------------------------------
6 | //- -----------------------------------------------------------------------------------------------------------------------
7 | #ifndef HELPERS_H
8 | #define HELPERS_H
9 |
10 | #if defined(ARDUINO) && ARDUINO >= 100
11 | #include "Arduino.h"
12 | #else
13 | #include "WProgram.h"
14 | #endif
15 |
16 | #include "utility/Serial.h"
17 |
18 | uint16_t freeMem(void);
19 | uint16_t crc16(uint16_t crc, uint8_t a);
20 |
21 | uint32_t byteTimeCvt(uint8_t tTime);
22 | uint32_t intTimeCvt(uint16_t iTime);
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/PinChangeIntHandler.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- Pin change interrupt handler ------------------------------------------------------------------------------------------
6 | //- -----------------------------------------------------------------------------------------------------------------------
7 | #include "PinChangeIntHandler.h"
8 |
9 | #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) // Arduino Mega
10 |
11 | #elif defined(__AVR_AT90USB162__) // Teensy 1.0
12 |
13 | #elif defined(__AVR_ATmega32U4__) // Teensy 2.0
14 |
15 | #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) // Teensy++ 1.0 & 2.0
16 |
17 | #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) // Sanguino
18 | #define pinToSlot(p) (((p) >= 0 && (p) <= 7) ? 1: ((p) >= 8 && (p) <= 14) ? 3: ((p) >= 15 && (p) <= 23) ? 2: ((p) >= 24 && (p) <= 31) ? 0: ((p) >= A0 && (p) <= A7) ? 0: 0xff)
19 | volatile uint8_t* pinPort[] = { &PINA, &PINB, &PINC, &PIND, };
20 | volatile uint8_t* intMask[] = { &PCMSK0, &PCMSK1, &PCMSK2, &PCMSK3, };
21 | volatile uint8_t portByte[4];
22 |
23 | #elif defined(__AVR_ATmega8P__) || defined(__AVR_ATmega8__) // Atmega8
24 |
25 | #else // Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc
26 | #define pinToSlot(p) (((p) >= 0 && (p) <= 7) ? 2: ((p) >= 8 && (p) <= 13) ? 0: ((p) >= A0 && (p) <= A5) ? 1: ((p) >= 14 && (p) <= 19) ? 1: 0xff)
27 | volatile uint8_t* intMask[] = { &PCMSK0, &PCMSK1, &PCMSK2, };
28 | volatile uint8_t* pinPort[] = { &PINB, &PINC, &PIND, };
29 | volatile uint8_t portByte[3];
30 |
31 | #endif
32 |
33 |
34 | s_pcIntH pcIntH[10];
35 | uint8_t pcIntNbr = 0;
36 |
37 | void registerInt(uint8_t tPin, s_dlgt tDelegate) {
38 | uint8_t pSlot = pinToSlot(tPin); // get the position in port or PCMSK array
39 |
40 | pcIntNbr++; // increase counter because we have to add a new pin
41 | //pcIntH = (s_pcIntH*) realloc (pcIntH, pcIntNbr * sizeof(s_pcIntH)); // size the table
42 |
43 | pcIntH[pcIntNbr-1].dlgt = tDelegate; // remember the address where we have to jump
44 | pcIntH[pcIntNbr-1].pcMask = pSlot; // remember the PCMSK
45 | pcIntH[pcIntNbr-1].byMask = digitalPinToBitMask(tPin); // remember the pin position
46 |
47 | pinMode(tPin,INPUT_PULLUP); // switch pin to input
48 |
49 | *intMask[pSlot] |= digitalPinToBitMask(tPin); // set the pin in the respective PCMSK
50 | //Serial << F("iM:") << *intMask[pSlot] << "\n";
51 | PCICR |= (1 << pSlot);
52 |
53 | //PCICR |= _BV(pSlot); // register PCMSK in interrupt change register
54 |
55 | portByte[pSlot] = *pinPort[pSlot] & *intMask[pSlot]; // remember the byte in the current port to figure out changes
56 |
57 | //Serial << F("pin:") << tPin << F(" pSlot:") << pSlot << F(" pB:") << portByte[pSlot] << F("\n");
58 | sei();
59 |
60 | }
61 |
62 | void collectPCINT(uint8_t vectInt) {
63 | cli();
64 |
65 | uint8_t intByte = *pinPort[vectInt] & *intMask[vectInt]; // get the input byte
66 |
67 | uint8_t msk = portByte[vectInt] ^ intByte; // mask out the changes
68 | portByte[vectInt] = intByte; // store pin byte for next time check
69 |
70 | if (msk == 0) { // seams to be a repeat, noting to do
71 | sei();
72 | return;
73 | }
74 |
75 | uint8_t bitStat = (intByte < *intMask[vectInt]) ? 0 : 1; // prepare the bit status for the pin
76 |
77 | for (uint8_t i = 0; i < pcIntNbr; i++) { // jump through the table and search for registered function
78 | if ((pcIntH[i].pcMask == vectInt) && (pcIntH[i].byMask == msk)) {
79 | pcIntH[i].dlgt(bitStat);
80 | }
81 | }
82 |
83 | sei();
84 | }
85 |
86 |
87 | ISR(PCINT0_vect) {
88 | collectPCINT(0);
89 | }
90 | ISR(PCINT1_vect) {
91 | collectPCINT(1);
92 | }
93 | ISR(PCINT2_vect) {
94 | collectPCINT(2);
95 | }
96 | ISR(PCINT3_vect) {
97 | collectPCINT(3);
98 | }
99 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/PinChangeIntHandler.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- Pin change interrupt handler ------------------------------------------------------------------------------------------
6 | //- -----------------------------------------------------------------------------------------------------------------------
7 | #ifndef _PINCHANGEINTHANDLER_H
8 | #define _PINCHANGEINTHANDLER_H
9 |
10 | #if defined(ARDUINO) && ARDUINO >= 100
11 | #include "Arduino.h"
12 | #else
13 | #include "WProgram.h"
14 | #endif
15 |
16 | #include "Serial.h"
17 | #include "Fastdelegate.h"
18 |
19 | using namespace fastdelegate;
20 | typedef FastDelegate1 s_dlgt;
21 |
22 | struct s_pcIntH {
23 | uint8_t pcMask;
24 | uint8_t byMask;
25 | s_dlgt dlgt;
26 | };
27 |
28 | void registerInt(uint8_t pin, s_dlgt Delegate);
29 | void collectPCINT(uint8_t vectInt);
30 |
31 | ISR(PCINT0_vect);
32 | ISR(PCINT1_vect);
33 | ISR(PCINT2_vect);
34 | ISR(PCINT3_vect);
35 |
36 |
37 |
38 | #endif
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/Serial.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- Serial interface functions --------------------------------------------------------------------------------------------
6 | //- Parser sketch from: http://jeelabs.org/2010/10/24/parsing-input-commands/
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 | #ifndef SERIAL_H
9 | #define SERIAL_H
10 |
11 | #if defined(ARDUINO) && ARDUINO >= 100
12 | #include "Arduino.h"
13 | #else
14 | #include "WProgram.h"
15 | #endif
16 |
17 | #include
18 |
19 |
20 | //- input parser class
21 | class InputParser {
22 | public:
23 | typedef struct {
24 | char code; // one-letter command code
25 | byte bytes; // number of bytes required as input
26 | void (*fun)(); // code to call for this command
27 | } Commands;
28 |
29 | InputParser (byte size, const Commands*, Stream& =Serial); // set up with a buffer of specified size
30 |
31 | byte count() { return fill; } // number of data bytes
32 | //byte *buffer; // holds the read data
33 | byte buffer[50]; // holds the read data
34 |
35 | void poll(); // call this frequently to check for incoming data
36 |
37 | InputParser& operator >> (char& v) { return get(&v, 1); }
38 | InputParser& operator >> (byte& v) { return get(&v, 1); }
39 | InputParser& operator >> (int& v) { return get(&v, 2); }
40 | InputParser& operator >> (word& v) { return get(&v, 2); }
41 | InputParser& operator >> (long& v) { return get(&v, 4); }
42 | InputParser& operator >> (uint32_t& v) { return get(&v, 4); }
43 | InputParser& operator >> (const char*& v);
44 |
45 | private:
46 | InputParser& get(void*, byte);
47 | void reset();
48 |
49 | byte limit, fill, top, next;
50 | byte instring, hexmode, hasvalue;
51 | uint32_t value;
52 | const Commands* cmds;
53 | Stream& io;
54 | };
55 | extern const InputParser::Commands cmdTab[];
56 |
57 | #define SERIAL_DBG_PHEX_MODE_NONE 0
58 | #define SERIAL_DBG_PHEX_MODE_LEN 1
59 | #define SERIAL_DBG_PHEX_MODE_LF 2
60 | #define SERIAL_DBG_PHEX_MODE_TIME 4
61 |
62 | //- some support for serial function
63 | template inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; }
64 |
65 | void pCharPGM(const uint8_t *buf); // print the content from PROGMEM
66 | void pHexPGM(const uint8_t *buf, uint8_t len); // print a couple of bytes in HEX format
67 | void pHexB(uint8_t val); // print one byte in HEX format
68 | void pHex(uint8_t *buf, uint8_t len, uint8_t mode); // print a couple of bytes in HEX format
69 | void pTime(void); // print a time stamp in brackets
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/StatusLed.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- Status led driver -----------------------------------------------------------------------------------------------------
6 | //- with a lot of contribution from Dirk at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | #include "StatusLed.h"
10 |
11 |
12 | void StatusLed::config(uint8_t pin1, uint8_t pin2) {
13 | pin[0] = pin1;
14 | pinMode(pin1, OUTPUT); // setting the pin1 to output mode
15 | off(0);
16 |
17 | pin[1] = pin2;
18 | pinMode(pin2, OUTPUT); // setting the pin2 to output mode
19 | off(1);
20 | }
21 |
22 |
23 | void StatusLed::poll() {
24 | for (uint8_t i = 0; i < 2; i++) {
25 |
26 | if (nTime[i] > 0 && (millis() - startTime[i] >= nTime[i])) {
27 | // Serial << F("LED:") < 3) {
47 | bCnt[i] = 0;
48 | }
49 | toggle_nTime = heartBeat[bCnt[i]++];
50 | }
51 |
52 | if (mode[i] > STATUSLED_MODE_ON) {
53 | toggle(i);
54 | nTime[i] = toggle_nTime;
55 | startTime[i] = millis();
56 |
57 | if (bCnt[i] > 0) {
58 | bCnt[i]--;
59 |
60 | if (bCnt[i] == 0) {
61 | off(i); // stop blinking next time
62 | }
63 | }
64 | }
65 | }
66 | }
67 | }
68 |
69 | void StatusLed::set(uint8_t leds, uint8_t tMode, uint8_t blinkCount) {
70 | unsigned long mills = millis();
71 |
72 | blinkCount = blinkCount * 2;
73 |
74 | if (leds & 0b01){
75 | mode[0] = tMode;
76 | bCnt[0] = blinkCount;
77 | nTime[0] = 1;
78 | startTime[0] = mills;
79 | }
80 |
81 | if (leds & 0b10){
82 | mode[1] = tMode;
83 | bCnt[1] = blinkCount;
84 | nTime[1] = 1;
85 | startTime[1] = mills;
86 | }
87 | }
88 |
89 | void StatusLed::stop(uint8_t leds) {
90 | if (leds & 0b01) off(0);
91 | if (leds & 0b10) off(1);
92 |
93 | for (uint8_t i = 0; i < 2; i++){
94 | mode[i] = STATUSLED_MODE_OFF;
95 | bCnt[i] = 0;
96 | state[i] = 0;
97 | }
98 | }
99 |
100 | void StatusLed::on(uint8_t ledNum) {
101 | onOff(STATUSLED_MODE_ON, ledNum); // switch led on
102 | }
103 |
104 | void StatusLed::off(uint8_t ledNum) {
105 | onOff(STATUSLED_MODE_OFF, ledNum); // switch led off
106 | }
107 |
108 | void StatusLed::onOff(uint8_t mode, uint8_t ledNum) {
109 | digitalWrite(pin[ledNum], mode);
110 | state[ledNum] = mode;
111 | nTime[ledNum] = 0;
112 | }
113 |
114 | void StatusLed::toggle(uint8_t ledNum) {
115 | if (state[ledNum]) {
116 | off(ledNum);
117 | } else {
118 | on(ledNum);
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/StatusLed.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- Status led driver -----------------------------------------------------------------------------------------------------
6 | //- with a lot of contribution from Dirk at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | #ifndef STATUSLED_H
10 | #define STATUSLED_H
11 |
12 | #if defined(ARDUINO) && ARDUINO >= 100
13 | #include "Arduino.h"
14 | #else
15 | #include "WProgram.h"
16 | #endif
17 |
18 | #include "Serial.h"
19 |
20 | const uint16_t heartBeat[] = { 50, 200, 50, 1000};
21 |
22 | /**
23 | * Class for status led control
24 | */
25 | class StatusLed {
26 | #define STATUSLED_BLINKRATE_SLOW 300
27 | #define STATUSLED_BLINKRATE_FAST 150
28 | #define STATUSLED_BLINKRATE_SFAST 50
29 |
30 | #define STATUSLED_1 1
31 | #define STATUSLED_2 2
32 | #define STATUSLED_BOTH 3
33 |
34 | #define STATUSLED_MODE_OFF 0
35 | #define STATUSLED_MODE_ON 1
36 | #define STATUSLED_MODE_BLINKSLOW 2
37 | #define STATUSLED_MODE_BLINKFAST 3
38 | #define STATUSLED_MODE_BLINKSFAST 4
39 | #define STATUSLED_MODE_HEARTBEAT 5
40 |
41 | public://---------------------------------------------------------------
42 |
43 | /**
44 | * Configure the led pins
45 | * If you use one led only, you must define the first pin only
46 | *
47 | * @param the pin of status led 1
48 | * @param the pin of status led 2
49 | * @param a callback function
50 | */
51 | void config(uint8_t pin1, uint8_t pin2);
52 |
53 | /**
54 | * Set mode for leds
55 | * 0 -> led1, 1 -> led2, 2 -> led1 and led2
56 | *
57 | * @param the leds
58 | * @param the mode
59 | */
60 | void set(uint8_t leds, uint8_t tMode, uint8_t blinkCount = 0);
61 |
62 | /**
63 | * Set leds off
64 | * 0 -> led1, 1 -> led2, 2 -> led1 and led2
65 | *
66 | * @param the leds
67 | */
68 | void stop(uint8_t leds);
69 |
70 | void poll(void);
71 | void on(uint8_t ledNum);
72 | void off(uint8_t ledNum);
73 |
74 | private://-------------------------------------------------------------------------------------------------------------
75 | uint8_t pin[2];
76 |
77 | /* 0 off, 1 -> on */
78 | uint8_t state[2];
79 | uint8_t mode[2];
80 |
81 | /* blink counter */
82 | uint8_t bCnt[2];
83 | uint32_t nTime[2];
84 | uint32_t startTime[2];
85 |
86 | void onOff(uint8_t mode, uint8_t ledNum);
87 | void toggle(uint8_t ledNum);
88 | };
89 |
90 | #endif
91 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/BH1750/BH1750.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This is a library for the BH1750FVI Digital Light Sensor
4 | breakout board.
5 |
6 | The board uses I2C for communication. 2 pins are required to
7 | interface to the device.
8 |
9 | Written by Christopher Laws, March, 2013.
10 |
11 | */
12 |
13 | #include "BH1750.h"
14 |
15 | // Define milliseconds delay for ESP8266 platform
16 | #if defined(ESP8266)
17 |
18 | #include
19 | #define _delay_ms(ms) delayMicroseconds((ms) * 1000)
20 |
21 | // Use _delay_ms from utils for AVR-based platforms
22 | #elif defined(__avr__)
23 | #include
24 |
25 | // Use Wiring's delay for compability with another platforms
26 | #else
27 | #define _delay_ms(ms) delay(ms)
28 | #endif
29 |
30 |
31 | // Legacy Wire.write() function fix
32 | #if (ARDUINO >= 100)
33 | #define __wire_write(d) Wire.write(d)
34 | #else
35 | #define __wire_write(d) Wire.send(d)
36 | #endif
37 |
38 |
39 | // Legacy Wire.read() function fix
40 | #if (ARDUINO >= 100)
41 | #define __wire_read() Wire.read()
42 | #else
43 | #define __wire_read() Wire.receive()
44 | #endif
45 |
46 |
47 | /**
48 | * Constructor
49 | * @params addr Sensor address (0x76 or 0x72, see datasheet)
50 | *
51 | * On most sensor boards, it was 0x76
52 | */
53 | BH1750::BH1750(byte addr) {
54 |
55 | BH1750_I2CADDR = addr;
56 |
57 | }
58 |
59 |
60 | /**
61 | * Begin I2C and configure sensor
62 | * @param mode Measurment mode
63 | */
64 | void BH1750::begin(uint8_t mode) {
65 |
66 | // Initialize I2C
67 | Wire.begin();
68 |
69 | // Configure sensor in specified mode
70 | configure(mode);
71 |
72 | }
73 |
74 |
75 | /**
76 | * Configurate BH1750 with specified working mode
77 | * @param mode Measurment mode
78 | */
79 | void BH1750::configure(uint8_t mode) {
80 |
81 | // Check, is measurment mode exist
82 | switch (mode) {
83 |
84 | case BH1750_CONTINUOUS_HIGH_RES_MODE:
85 | case BH1750_CONTINUOUS_HIGH_RES_MODE_2:
86 | case BH1750_CONTINUOUS_LOW_RES_MODE:
87 | case BH1750_ONE_TIME_HIGH_RES_MODE:
88 | case BH1750_ONE_TIME_HIGH_RES_MODE_2:
89 | case BH1750_ONE_TIME_LOW_RES_MODE:
90 |
91 | // Send mode to sensor
92 | Wire.beginTransmission(BH1750_I2CADDR);
93 | __wire_write((uint8_t)mode);
94 | Wire.endTransmission();
95 |
96 | // Wait few moments for waking up
97 | _delay_ms(10);
98 | break;
99 |
100 | default:
101 |
102 | // Invalid measurement mode
103 | #ifdef BH1750_DEBUG
104 | Serial.println(F("BH1750: Invalid measurment mode"));
105 | #endif
106 |
107 | break;
108 |
109 | }
110 |
111 | }
112 |
113 |
114 | /**
115 | * Read light level from sensor
116 | * @return Lightness in lux (0 ~ 65535)
117 | */
118 | uint16_t BH1750::readLightLevel(void) {
119 |
120 | // Measurment result will be stored here
121 | uint16_t level;
122 |
123 | // Read two bytes from sensor
124 | Wire.requestFrom(BH1750_I2CADDR, 2);
125 |
126 | // Read two bytes, which are low and high parts of sensor value
127 | level = __wire_read();
128 | level <<= 8;
129 | level |= __wire_read();
130 |
131 | // Send raw value if debug enabled
132 | #ifdef BH1750_DEBUG
133 | Serial.print(F("[BH1750] Raw value: "));
134 | Serial.println(level);
135 | #endif
136 |
137 | // Convert raw value to lux
138 | level /= 1.2;
139 |
140 | // Send converted value, if debug enabled
141 | #ifdef BH1750_DEBUG
142 | Serial.print(F("[BH1750] Converted value: "));
143 | Serial.println(level);
144 | #endif
145 |
146 | return level;
147 |
148 | }
149 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/BH1750/BH1750.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This is a library for the BH1750FVI Digital Light Sensor
4 | breakout board.
5 |
6 | The board uses I2C for communication. 2 pins are required to
7 | interface to the device.
8 |
9 | Datasheet: http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1750fvi-e.pdf
10 |
11 | Written by Christopher Laws, March, 2013.
12 |
13 | */
14 |
15 | #ifndef BH1750_h
16 | #define BH1750_h
17 |
18 | #if (ARDUINO >= 100)
19 | #include
20 | #else
21 | #include
22 | #endif
23 |
24 | #include "Wire.h"
25 |
26 | // Uncomment, to enable debug messages
27 | // #define BH1750_DEBUG
28 |
29 | // No active state
30 | #define BH1750_POWER_DOWN 0x00
31 |
32 | // Wating for measurment command
33 | #define BH1750_POWER_ON 0x01
34 |
35 | // Reset data register value - not accepted in POWER_DOWN mode
36 | #define BH1750_RESET 0x07
37 |
38 | // Start measurement at 1lx resolution. Measurement time is approx 120ms.
39 | #define BH1750_CONTINUOUS_HIGH_RES_MODE 0x10
40 |
41 | // Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
42 | #define BH1750_CONTINUOUS_HIGH_RES_MODE_2 0x11
43 |
44 | // Start measurement at 4lx resolution. Measurement time is approx 16ms.
45 | #define BH1750_CONTINUOUS_LOW_RES_MODE 0x13
46 |
47 | // Start measurement at 1lx resolution. Measurement time is approx 120ms.
48 | // Device is automatically set to Power Down after measurement.
49 | #define BH1750_ONE_TIME_HIGH_RES_MODE 0x20
50 |
51 | // Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
52 | // Device is automatically set to Power Down after measurement.
53 | #define BH1750_ONE_TIME_HIGH_RES_MODE_2 0x21
54 |
55 | // Start measurement at 1lx resolution. Measurement time is approx 120ms.
56 | // Device is automatically set to Power Down after measurement.
57 | #define BH1750_ONE_TIME_LOW_RES_MODE 0x23
58 |
59 | class BH1750 {
60 |
61 | public:
62 | BH1750 (byte addr = 0x23);
63 | void begin (uint8_t mode = BH1750_CONTINUOUS_HIGH_RES_MODE);
64 | void configure (uint8_t mode);
65 | uint16_t readLightLevel(void);
66 |
67 | private:
68 | int BH1750_I2CADDR;
69 |
70 | };
71 |
72 | #endif
73 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/BH1750/README.md:
--------------------------------------------------------------------------------
1 | BH1750
2 | ==========
3 |
4 | An Arduino library for digital light sensor breakout boards containing the BH1750FVI IC.
5 |
6 | The board uses I2C for communication, and two pins are required to interface to the device.
7 |
8 | Datasheet can be obtained [here](http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1750fvi-e.pdf)
9 |
10 | ## Installation
11 | Click "Clone or download" -> "Download ZIP" button.
12 |
13 | - **(For Arduino < 1.5.x)** Extract the archive to ``/My Documents/Arduino/libraries/`` folder and rename it to `BH1750`. Restart IDE.
14 | - **(For Arduino >= 1.5.x)** Use the way above, or Library Manager. Open Arduino IDE, click `Sketch -> Include library -> Add .ZIP library ` and select the downloaded archive.
15 |
16 | Additional info, about library installation process - https://www.arduino.cc/en/Guide/Libraries
17 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/BH1750/examples/BH1750advanced/BH1750advanced.ino:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Advanced BH1750 library usage example
4 |
5 | This example had some comments about advanced usage features.
6 |
7 | Connection:
8 |
9 | VCC -> 5V (3V3 on Arduino Due, Zero, MKR1000, etc)
10 | GND -> GND
11 | SCL -> SCL (A5 on Arduino Uno, Leonardo, etc or 21 on Mega and Due)
12 | SDA -> SDA (A4 on Arduino Uno, Leonardo, etc or 20 on Mega and Due)
13 | ADD -> GND or VCC (see below)
14 |
15 | ADD pin uses to set sensor I2C address. If it has voltage greater or equal to
16 | 0.7VCC voltage (as example, you've connected it to VCC) - sensor address will be
17 | 0x5C. In other case (if ADD voltage less than 0.7 * VCC) - sensor address will
18 | be 0x23 (by default).
19 |
20 | */
21 |
22 | #include
23 | #include
24 |
25 | /*
26 |
27 | BH1750 can be physically configured to use two I2C addresses:
28 | - 0x23 (most common) (if ADD pin had < 0.7VCC voltage)
29 | - 0x5C (if ADD pin had > 0.7VCC voltage)
30 |
31 | Library use 0x23 address as default, but you can define any other address.
32 | If you had troubles with default value - try to change it to 0x5C.
33 |
34 | */
35 | BH1750 lightMeter(0x23);
36 |
37 | void setup(){
38 |
39 | Serial.begin(9600);
40 |
41 | /*
42 |
43 | BH1750 had six different measurment modes. They are divided in two groups -
44 | continuous and one-time measurments. In continuous mode, sensor continuously
45 | measures lightness value. And in one-time mode, sensor makes only one
46 | measurment, and going to Power Down mode after this.
47 |
48 | Each mode, has three different precisions:
49 |
50 | - Low Resolution Mode - (4 lx precision, 16ms measurment time)
51 | - High Resolution Mode - (1 lx precision, 120ms measurment time)
52 | - High Resolution Mode 2 - (0.5 lx precision, 120ms measurment time)
53 |
54 | By default, library use Continuous High Resolution Mode, but you can set
55 | any other mode, by define it to BH1750.begin() or BH1750.configure() functions.
56 |
57 | [!] Remember, if you use One-Time mode, your sensor will go to Power Down mode
58 | each time, when it completes measurment and you've read it.
59 |
60 | Full mode list:
61 |
62 | BH1750_CONTINUOUS_LOW_RES_MODE
63 | BH1750_CONTINUOUS_HIGH_RES_MODE (default)
64 | BH1750_CONTINUOUS_HIGH_RES_MODE_2
65 |
66 | BH1750_ONE_TIME_LOW_RES_MODE
67 | BH1750_ONE_TIME_HIGH_RES_MODE
68 | BH1750_ONE_TIME_HIGH_RES_MODE_2
69 |
70 | */
71 |
72 | lightMeter.begin(BH1750_CONTINUOUS_HIGH_RES_MODE);
73 | Serial.println(F("BH1750 Test"));
74 |
75 | }
76 |
77 |
78 | void loop() {
79 |
80 | uint16_t lux = lightMeter.readLightLevel();
81 | Serial.print("Light: ");
82 | Serial.print(lux);
83 | Serial.println(" lx");
84 | delay(1000);
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/BH1750/examples/BH1750test/BH1750test.ino:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Example of BH1750 library usage.
4 |
5 | This example initalises the BH1750 object using the default
6 | high resolution mode and then makes a light level reading every second.
7 |
8 | Connection:
9 |
10 | VCC -> 5V (3V3 on Arduino Due, Zero, MKR1000, etc)
11 | GND -> GND
12 | SCL -> SCL (A5 on Arduino Uno, Leonardo, etc or 21 on Mega and Due)
13 | SDA -> SDA (A4 on Arduino Uno, Leonardo, etc or 20 on Mega and Due)
14 | ADD -> (not connected) or GND
15 |
16 | ADD pin uses to set sensor I2C address. If it has voltage greater or equal to
17 | 0.7VCC voltage (as example, you've connected it to VCC) - sensor address will be
18 | 0x5C. In other case (if ADD voltage less than 0.7 * VCC) - sensor address will
19 | be 0x23 (by default).
20 |
21 | */
22 |
23 | #include
24 | #include
25 |
26 | BH1750 lightMeter;
27 |
28 | void setup(){
29 |
30 | Serial.begin(9600);
31 | lightMeter.begin();
32 | Serial.println(F("BH1750 Test"));
33 |
34 | }
35 |
36 |
37 | void loop() {
38 |
39 | uint16_t lux = lightMeter.readLightLevel();
40 | Serial.print("Light: ");
41 | Serial.print(lux);
42 | Serial.println(" lx");
43 | delay(1000);
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/BH1750/keywords.txt:
--------------------------------------------------------------------------------
1 | #######################################
2 | # Syntax Coloring Map For BH1750
3 | #######################################
4 |
5 | #######################################
6 | # Datatypes (KEYWORD1)
7 | #######################################
8 |
9 | BH1750 KEYWORD1
10 |
11 | #######################################
12 | # Methods and Functions (KEYWORD2)
13 | #######################################
14 |
15 | begin KEYWORD2
16 | configure KEYWORD2
17 | readLightLevel KEYWORD2
18 |
19 |
20 | #######################################
21 | # Instances (KEYWORD2)
22 | #######################################
23 |
24 |
25 | #######################################
26 | # Constants (LITERAL1)
27 | #######################################
28 | BH1750_CONTINUOUS_HIGH_RES_MODE LITERAL1
29 | BH1750_CONTINUOUS_HIGH_RES_MODE_2 LITERAL1
30 | BH1750_CONTINUOUS_LOW_RES_MODE LITERAL1
31 | BH1750_ONE_TIME_HIGH_RES_MODE LITERAL1
32 | BH1750_ONE_TIME_HIGH_RES_MODE_2 LITERAL1
33 | BH1750_ONE_TIME_LOW_RES_MODE LITERAL1
34 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/BH1750/library.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "BH1750",
3 | "keywords": "light, sensor",
4 | "description": "Digital light sensor breakout boards containing the BH1750FVI IC",
5 | "repository": {
6 | "type": "git",
7 | "url": "https://github.com/claws/BH1750.git"
8 | },
9 | "frameworks": "arduino",
10 | "platforms": ["atmelavr", "atmelsam", "espressif8266"]
11 | }
12 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/BH1750/library.properties:
--------------------------------------------------------------------------------
1 | name=BH1750
2 | version=1.1.3
3 | author=Christopher Laws
4 | maintainer=Christopher Laws
5 | sentence=Digital light sensor breakout boards containing the BH1750FVI IC
6 | paragraph=Pretty simple and robust BH1750 library
7 | category=Sensors
8 | url=https://github.com/claws/BH1750
9 | architectures=*
10 | includes=BH1750.h
11 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/BMP085/BMP085.h:
--------------------------------------------------------------------------------
1 | // BMP085 Pressure/Temperature (Altimeter) sensor
2 |
3 | // MIT license
4 | #ifndef BMP085_H
5 | #define BMP085_H
6 |
7 |
8 | #if (ARDUINO >= 100)
9 | #include "Arduino.h"
10 | #else
11 | #include "WProgram.h"
12 | #endif
13 | #include
14 |
15 | #define BMP085_DEBUG 0
16 |
17 | #define BMP085_I2CADDR 0x77
18 |
19 | #define BMP085_ULTRALOWPOWER 0
20 | #define BMP085_STANDARD 1
21 | #define BMP085_HIGHRES 2
22 | #define BMP085_ULTRAHIGHRES 3
23 | #define BMP085_CAL_AC1 0xAA // R Calibration data (16 bits)
24 | #define BMP085_CAL_AC2 0xAC // R Calibration data (16 bits)
25 | #define BMP085_CAL_AC3 0xAE // R Calibration data (16 bits)
26 | #define BMP085_CAL_AC4 0xB0 // R Calibration data (16 bits)
27 | #define BMP085_CAL_AC5 0xB2 // R Calibration data (16 bits)
28 | #define BMP085_CAL_AC6 0xB4 // R Calibration data (16 bits)
29 | #define BMP085_CAL_B1 0xB6 // R Calibration data (16 bits)
30 | #define BMP085_CAL_B2 0xB8 // R Calibration data (16 bits)
31 | #define BMP085_CAL_MB 0xBA // R Calibration data (16 bits)
32 | #define BMP085_CAL_MC 0xBC // R Calibration data (16 bits)
33 | #define BMP085_CAL_MD 0xBE // R Calibration data (16 bits)
34 |
35 | #define BMP085_CONTROL 0xF4
36 | #define BMP085_TEMPDATA 0xF6
37 | #define BMP085_PRESSUREDATA 0xF6
38 | #define BMP085_READTEMPCMD 0x2E
39 | #define BMP085_READPRESSURECMD 0x34
40 |
41 |
42 | class BMP085 {
43 | public:
44 | void begin(uint8_t mode = BMP085_ULTRAHIGHRES); // by default go highres
45 | float readTemperature(void);
46 | int32_t readPressure(void);
47 | float readAltitude(float sealevelPressure = 101325); // std atmosphere
48 | uint16_t readRawTemperature(void);
49 | uint32_t readRawPressure(void);
50 |
51 | private:
52 | uint8_t read8(uint8_t addr);
53 | uint16_t read16(uint8_t addr);
54 | void write8(uint8_t addr, uint8_t data);
55 |
56 | uint8_t oversampling;
57 |
58 | int16_t ac1, ac2, ac3, b1, b2, mb, mc, md;
59 | uint16_t ac4, ac5, ac6;
60 | };
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/BMP085/BMP085.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HB-UW-Sen-THPL/Libraries/BMP085/BMP085.jpg
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/Wire/Wire.h:
--------------------------------------------------------------------------------
1 | /*
2 | TwoWire.h - TWI/I2C library for Arduino & Wiring
3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved.
4 |
5 | This library is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU Lesser General Public
7 | License as published by the Free Software Foundation; either
8 | version 2.1 of the License, or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public
16 | License along with this library; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 |
19 | Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
20 | */
21 |
22 | #ifndef TwoWire_h
23 | #define TwoWire_h
24 |
25 | #include
26 | #include "Stream.h"
27 |
28 | #define BUFFER_LENGTH 32
29 |
30 | class TwoWire : public Stream
31 | {
32 | private:
33 | static uint8_t rxBuffer[];
34 | static uint8_t rxBufferIndex;
35 | static uint8_t rxBufferLength;
36 |
37 | static uint8_t txAddress;
38 | static uint8_t txBuffer[];
39 | static uint8_t txBufferIndex;
40 | static uint8_t txBufferLength;
41 |
42 | static uint8_t transmitting;
43 | static void (*user_onRequest)(void);
44 | static void (*user_onReceive)(int);
45 | static void onRequestService(void);
46 | static void onReceiveService(uint8_t*, int);
47 | public:
48 | TwoWire();
49 | void begin();
50 | void begin(uint8_t);
51 | void begin(int);
52 | void beginTransmission(uint8_t);
53 | void beginTransmission(int);
54 | uint8_t endTransmission(void);
55 | uint8_t endTransmission(uint8_t);
56 | uint8_t requestFrom(uint8_t, uint8_t);
57 | uint8_t requestFrom(uint8_t, uint8_t, uint8_t);
58 | uint8_t requestFrom(int, int);
59 | uint8_t requestFrom(int, int, int);
60 | virtual size_t write(uint8_t);
61 | virtual size_t write(const uint8_t *, size_t);
62 | virtual int available(void);
63 | virtual int read(void);
64 | virtual int peek(void);
65 | virtual void flush(void);
66 | void onReceive( void (*)(int) );
67 | void onRequest( void (*)(void) );
68 |
69 | inline size_t write(unsigned long n) { return write((uint8_t)n); }
70 | inline size_t write(long n) { return write((uint8_t)n); }
71 | inline size_t write(unsigned int n) { return write((uint8_t)n); }
72 | inline size_t write(int n) { return write((uint8_t)n); }
73 | using Print::write;
74 | };
75 |
76 | extern TwoWire Wire;
77 |
78 | #endif
79 |
80 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino:
--------------------------------------------------------------------------------
1 | // I2C SRF10 or SRF08 Devantech Ultrasonic Ranger Finder
2 | // by Nicholas Zambetti
3 | // and James Tichenor
4 |
5 | // Demonstrates use of the Wire library reading data from the
6 | // Devantech Utrasonic Rangers SFR08 and SFR10
7 |
8 | // Created 29 April 2006
9 |
10 | // This example code is in the public domain.
11 |
12 |
13 | #include
14 |
15 | void setup()
16 | {
17 | Wire.begin(); // join i2c bus (address optional for master)
18 | Serial.begin(9600); // start serial communication at 9600bps
19 | }
20 |
21 | int reading = 0;
22 |
23 | void loop()
24 | {
25 | // step 1: instruct sensor to read echoes
26 | Wire.beginTransmission(112); // transmit to device #112 (0x70)
27 | // the address specified in the datasheet is 224 (0xE0)
28 | // but i2c adressing uses the high 7 bits so it's 112
29 | Wire.write(byte(0x00)); // sets register pointer to the command register (0x00)
30 | Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50)
31 | // use 0x51 for centimeters
32 | // use 0x52 for ping microseconds
33 | Wire.endTransmission(); // stop transmitting
34 |
35 | // step 2: wait for readings to happen
36 | delay(70); // datasheet suggests at least 65 milliseconds
37 |
38 | // step 3: instruct sensor to return a particular echo reading
39 | Wire.beginTransmission(112); // transmit to device #112
40 | Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02)
41 | Wire.endTransmission(); // stop transmitting
42 |
43 | // step 4: request reading from sensor
44 | Wire.requestFrom(112, 2); // request 2 bytes from slave device #112
45 |
46 | // step 5: receive reading from sensor
47 | if(2 <= Wire.available()) // if two bytes were received
48 | {
49 | reading = Wire.read(); // receive high byte (overwrites previous reading)
50 | reading = reading << 8; // shift high byte to be high 8 bits
51 | reading |= Wire.read(); // receive low byte as lower 8 bits
52 | Serial.println(reading); // print the reading
53 | }
54 |
55 | delay(250); // wait a bit since people have to read the output :)
56 | }
57 |
58 |
59 | /*
60 |
61 | // The following code changes the address of a Devantech Ultrasonic Range Finder (SRF10 or SRF08)
62 | // usage: changeAddress(0x70, 0xE6);
63 |
64 | void changeAddress(byte oldAddress, byte newAddress)
65 | {
66 | Wire.beginTransmission(oldAddress);
67 | Wire.write(byte(0x00));
68 | Wire.write(byte(0xA0));
69 | Wire.endTransmission();
70 |
71 | Wire.beginTransmission(oldAddress);
72 | Wire.write(byte(0x00));
73 | Wire.write(byte(0xAA));
74 | Wire.endTransmission();
75 |
76 | Wire.beginTransmission(oldAddress);
77 | Wire.write(byte(0x00));
78 | Wire.write(byte(0xA5));
79 | Wire.endTransmission();
80 |
81 | Wire.beginTransmission(oldAddress);
82 | Wire.write(byte(0x00));
83 | Wire.write(newAddress);
84 | Wire.endTransmission();
85 | }
86 |
87 | */
88 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino:
--------------------------------------------------------------------------------
1 | // I2C Digital Potentiometer
2 | // by Nicholas Zambetti
3 | // and Shawn Bonkowski
4 |
5 | // Demonstrates use of the Wire library
6 | // Controls AD5171 digital potentiometer via I2C/TWI
7 |
8 | // Created 31 March 2006
9 |
10 | // This example code is in the public domain.
11 |
12 | // This example code is in the public domain.
13 |
14 |
15 | #include
16 |
17 | void setup()
18 | {
19 | Wire.begin(); // join i2c bus (address optional for master)
20 | }
21 |
22 | byte val = 0;
23 |
24 | void loop()
25 | {
26 | Wire.beginTransmission(44); // transmit to device #44 (0x2c)
27 | // device address is specified in datasheet
28 | Wire.write(byte(0x00)); // sends instruction byte
29 | Wire.write(val); // sends potentiometer value byte
30 | Wire.endTransmission(); // stop transmitting
31 |
32 | val++; // increment value
33 | if(val == 64) // if reached 64th position (max)
34 | {
35 | val = 0; // start over from lowest value
36 | }
37 | delay(500);
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/Wire/examples/master_reader/master_reader.ino:
--------------------------------------------------------------------------------
1 | // Wire Master Reader
2 | // by Nicholas Zambetti
3 |
4 | // Demonstrates use of the Wire library
5 | // Reads data from an I2C/TWI slave device
6 | // Refer to the "Wire Slave Sender" example for use with this
7 |
8 | // Created 29 March 2006
9 |
10 | // This example code is in the public domain.
11 |
12 |
13 | #include
14 |
15 | void setup()
16 | {
17 | Wire.begin(); // join i2c bus (address optional for master)
18 | Serial.begin(9600); // start serial for output
19 | }
20 |
21 | void loop()
22 | {
23 | Wire.requestFrom(2, 6); // request 6 bytes from slave device #2
24 |
25 | while(Wire.available()) // slave may send less than requested
26 | {
27 | char c = Wire.read(); // receive a byte as character
28 | Serial.print(c); // print the character
29 | }
30 |
31 | delay(500);
32 | }
33 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/Wire/examples/master_writer/master_writer.ino:
--------------------------------------------------------------------------------
1 | // Wire Master Writer
2 | // by Nicholas Zambetti
3 |
4 | // Demonstrates use of the Wire library
5 | // Writes data to an I2C/TWI slave device
6 | // Refer to the "Wire Slave Receiver" example for use with this
7 |
8 | // Created 29 March 2006
9 |
10 | // This example code is in the public domain.
11 |
12 |
13 | #include
14 |
15 | void setup()
16 | {
17 | Wire.begin(); // join i2c bus (address optional for master)
18 | }
19 |
20 | byte x = 0;
21 |
22 | void loop()
23 | {
24 | Wire.beginTransmission(4); // transmit to device #4
25 | Wire.write("x is "); // sends five bytes
26 | Wire.write(x); // sends one byte
27 | Wire.endTransmission(); // stop transmitting
28 |
29 | x++;
30 | delay(500);
31 | }
32 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/Wire/examples/slave_receiver/slave_receiver.ino:
--------------------------------------------------------------------------------
1 | // Wire Slave Receiver
2 | // by Nicholas Zambetti
3 |
4 | // Demonstrates use of the Wire library
5 | // Receives data as an I2C/TWI slave device
6 | // Refer to the "Wire Master Writer" example for use with this
7 |
8 | // Created 29 March 2006
9 |
10 | // This example code is in the public domain.
11 |
12 |
13 | #include
14 |
15 | void setup()
16 | {
17 | Wire.begin(4); // join i2c bus with address #4
18 | Wire.onReceive(receiveEvent); // register event
19 | Serial.begin(9600); // start serial for output
20 | }
21 |
22 | void loop()
23 | {
24 | delay(100);
25 | }
26 |
27 | // function that executes whenever data is received from master
28 | // this function is registered as an event, see setup()
29 | void receiveEvent(int howMany)
30 | {
31 | while(1 < Wire.available()) // loop through all but the last
32 | {
33 | char c = Wire.read(); // receive byte as a character
34 | Serial.print(c); // print the character
35 | }
36 | int x = Wire.read(); // receive byte as an integer
37 | Serial.println(x); // print the integer
38 | }
39 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/Wire/examples/slave_sender/slave_sender.ino:
--------------------------------------------------------------------------------
1 | // Wire Slave Sender
2 | // by Nicholas Zambetti
3 |
4 | // Demonstrates use of the Wire library
5 | // Sends data as an I2C/TWI slave device
6 | // Refer to the "Wire Master Reader" example for use with this
7 |
8 | // Created 29 March 2006
9 |
10 | // This example code is in the public domain.
11 |
12 |
13 | #include
14 |
15 | void setup()
16 | {
17 | Wire.begin(2); // join i2c bus with address #2
18 | Wire.onRequest(requestEvent); // register event
19 | }
20 |
21 | void loop()
22 | {
23 | delay(100);
24 | }
25 |
26 | // function that executes whenever data is requested by master
27 | // this function is registered as an event, see setup()
28 | void requestEvent()
29 | {
30 | Wire.write("hello "); // respond with message of 6 bytes
31 | // as expected by master
32 | }
33 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/Wire/keywords.txt:
--------------------------------------------------------------------------------
1 | #######################################
2 | # Syntax Coloring Map For Wire
3 | #######################################
4 |
5 | #######################################
6 | # Datatypes (KEYWORD1)
7 | #######################################
8 |
9 | #######################################
10 | # Methods and Functions (KEYWORD2)
11 | #######################################
12 |
13 | begin KEYWORD2
14 | beginTransmission KEYWORD2
15 | endTransmission KEYWORD2
16 | requestFrom KEYWORD2
17 | send KEYWORD2
18 | receive KEYWORD2
19 | onReceive KEYWORD2
20 | onRequest KEYWORD2
21 |
22 | #######################################
23 | # Instances (KEYWORD2)
24 | #######################################
25 |
26 | Wire KEYWORD2
27 |
28 | #######################################
29 | # Constants (LITERAL1)
30 | #######################################
31 |
32 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Libraries/Wire/utility/twi.h:
--------------------------------------------------------------------------------
1 | /*
2 | twi.h - TWI/I2C library for Wiring & Arduino
3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved.
4 |
5 | This library is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU Lesser General Public
7 | License as published by the Free Software Foundation; either
8 | version 2.1 of the License, or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public
16 | License along with this library; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | #ifndef twi_h
21 | #define twi_h
22 |
23 | #include
24 |
25 | //#define ATMEGA8
26 |
27 | #ifndef TWI_FREQ
28 | #define TWI_FREQ 100000L
29 | #endif
30 |
31 | #ifndef TWI_BUFFER_LENGTH
32 | #define TWI_BUFFER_LENGTH 32
33 | #endif
34 |
35 | #define TWI_READY 0
36 | #define TWI_MRX 1
37 | #define TWI_MTX 2
38 | #define TWI_SRX 3
39 | #define TWI_STX 4
40 |
41 | void twi_init(void);
42 | void twi_setAddress(uint8_t);
43 | uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t);
44 | uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t);
45 | uint8_t twi_transmit(const uint8_t*, uint8_t);
46 | void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) );
47 | void twi_attachSlaveTxEvent( void (*)(void) );
48 | void twi_reply(uint8_t);
49 | void twi_stop(void);
50 | void twi_releaseBus(void);
51 |
52 | #endif
53 |
54 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Register.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #ifndef _REGISTER_h
4 | #define _REGISTER_h
5 |
6 | #define FRAME_TYPE 0x70 // Frame type 0x70 = WEATHER_EVENT
7 | #define DEVICE_INFO 0x01, 0x01, 0x00 // Device Info, 3 byte, describes device, not completely clear yet. includes amount of channels
8 |
9 | #if USE_ADRESS_SECTION == 1
10 | uint8_t devParam[] = {
11 | FIRMWARE_VERSION,
12 | 0xFF, 0xFF, // space for device type, assigned later
13 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // space for device serial, assigned later
14 | FRAME_TYPE,
15 | DEVICE_INFO,
16 | 0xFF, 0xFF, 0xFF // space for device address, assigned later
17 | };
18 | #else
19 | uint8_t devParam[] = {
20 | FIRMWARE_VERSION,
21 | DEVICE_TYPE,
22 | DEVICE_SERIAL,
23 | FRAME_TYPE,
24 | DEVICE_INFO,
25 | DEVICE_ADDRESS
26 | };
27 | #endif
28 |
29 | HM::s_devParm dParm = {
30 | 3, // send retries, 1 byte, how often a string should be send out until we get an answer
31 | 700, // send timeout, 2 byte, time out for ACK handling
32 | devParam // pointer to devParam, see above
33 | };
34 |
35 | //- channel device list table --------------------------------------------------------------------------------------------
36 | HM::s_modtable modTbl[] = {
37 | { 0, 0, (s_mod_dlgt) NULL }, // ???
38 | { 0, 0, (s_mod_dlgt) NULL }, // ???
39 | }; // 16 byte
40 |
41 | /**
42 | * channel slice definition
43 | * Each value represents a register index defined in s_regDevL0 below
44 | */
45 | uint8_t sliceStr[] = {
46 | 0x01, 0x05, 0x0A, 0x0B, 0x0C, 0x12, 0x14, 0x24, 0x25
47 | };
48 |
49 | /**
50 | * Register definition for List 0
51 | */
52 | struct s_regDevL0 {
53 | // 0x01, 0x05, 0x0A, 0x0B, 0x0C, 0x12, 0x14, 0x24, 0x25
54 | uint8_t burstRx; // 0x01, startBit:0, bits:8
55 | uint8_t :6; // 0x05 startBit:0, bits:6
56 | uint8_t ledMode :2; // 0x05, startBit:6, bits:2
57 | uint8_t pairCentral[3]; // 0x0A, 0x0B, 0x0C, startBit:0, bits:8 (3 mal)
58 | uint8_t lowBatLimit; // 0x12, startBit:0, bits:8
59 | uint8_t transmDevTryMax; // 0x14, startBit:0, bits:8
60 | uint8_t altitude[2]; // 0x24, 0x25 startBit:0, bits:8
61 | };
62 |
63 | // todo
64 | struct s_regChanL4 {
65 | // 0x01,
66 | uint8_t peerNeedsBurst:1; // 0x01, s:0, e:1
67 | uint8_t :7; //
68 | };
69 |
70 | struct s_regDev {
71 | s_regDevL0 l0;
72 | };
73 |
74 | struct s_regChan {
75 | s_regChanL4 l4;
76 | };
77 |
78 | struct s_regs {
79 | s_regDev ch0;
80 | s_regChan ch1;
81 | } regs; // 11 byte
82 |
83 | /**
84 | * channel device list table, 22 bytes
85 | */
86 | const s_cnlDefType cnlDefType[] PROGMEM = {
87 | // cnl, lst, peersMax, sIdx, sLen, pAddr, pPeer, *pRegs (pointer to regs structure)
88 | { 0, 0, 0, 0x00, 9, 0x0000, 0x0000, (void*)®s.ch0.l0}, // List 0
89 | { 1, 4, 6, 0x05, 1, 0x0005, 0x0000, (void*)®s.ch1.l4}, // List 4
90 | };
91 |
92 | // handover to AskSin lib, 6 bytes
93 | HM::s_devDef dDef = {
94 | 1, 2, sliceStr, cnlDefType,
95 | };
96 |
97 | /**
98 | * EEprom definition, 16 bytes
99 | * Define start address and size in eeprom for magicNumber, peerDB, regsDB, userSpace
100 | */
101 | HM::s_eeprom ee[] = {
102 | //magicNum, peerDB, regsDB, userSpace
103 | { 0x0000, 0x0002, 0x001a, 0x0025, }, // start address
104 | { 0x0002, 0x0030, 0x000b, 0x0000, }, // length
105 | };
106 |
107 | /**
108 | * Definitions for EEprom defaults.
109 | * Must enter in same order as e.g. defined in s_regDevL0
110 | */
111 | const uint8_t regs00[] PROGMEM = {0x00, 0x64, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00};
112 | const uint8_t regs04[] PROGMEM = {0x1f, 0xa6, 0x5c, 0x05};
113 |
114 | s_defaultRegsTbl defaultRegsTbl[] = {
115 | // peer(0) or regs(1), channel, list, peer index, len, pointer to payload
116 | { 1, 0, 0, 0, 9, regs00 },
117 | };
118 |
119 | HM::s_dtRegs dtRegs = {
120 | //amount of lines in defaultRegsTbl[], pointer to defaultRegsTbl[]
121 | 1, defaultRegsTbl
122 | };
123 |
124 | #endif
125 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/Sensor_BMP180_BH1750.h:
--------------------------------------------------------------------------------
1 | /**
2 | * SHT10, BMP085, TSL2561 Sensor class
3 | *
4 | * (c) 2014 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 | * Author: Horst Bittner
6 | * Dirk Hoffmann dirk@fhem.forum
7 | */
8 |
9 | #ifndef SENSOR_BMP180_BH1750_H
10 | #define SENSOR_BMP180_BH1750_H
11 |
12 | #if defined(ARDUINO) && ARDUINO >= 100
13 | #include "Arduino.h"
14 | #else
15 | #include "WProgram.h"
16 | #endif
17 |
18 | #include "AskSinMain.h"
19 | #include "utility/Serial.h"
20 | #include "utility/Fastdelegate.h"
21 | #include "utility/PinChangeIntHandler.h"
22 |
23 | #include
24 | #include
25 | #include
26 |
27 |
28 | #define BMP180_BH1750 Sensors_BMP180_BH1750 // module name as macro to overcome the problem of renaming functions all the time
29 | //#define DM_DBG // debug message flag
30 |
31 | #define BMP180_BH1750_nACTION_MEASURE_INIT 1
32 | #define BMP180_BH1750_nACTION_MEASURE_L 2
33 | #define BMP180_BH1750_nACTION_CALC_L 3
34 | #define BMP180_BH1750_nACTION_MEASURE_THP 4
35 | #define BMP180_BH1750_nACTION_TRANSMIT 5
36 |
37 | #define BMP180_BH1750_MAX_MEASURE_TIME 50
38 | #define BMP180_BH1750_MINIMAL_CYCLE_LENGTH 480 // minimal cycle length in 250ms units
39 |
40 | const uint8_t peerOdd[] = {}; // default settings for list3 or list4
41 | const uint8_t peerEven[] = {};
42 | const uint8_t peerSingle[] = {};
43 |
44 | class BMP180_BH1750 {
45 | // user code here
46 | public:
47 | void config(uint8_t data, uint8_t sck, uint16_t timing, BMP085 *pPtr, BH1750 *lPtr);
48 |
49 | // mandatory functions for every new module to communicate within HM protocol stack
50 | uint8_t modStat; // module status byte, needed for list3 modules to answer status requests
51 | uint8_t regCnl; // holds the channel for the module
52 |
53 | HM *hm; // pointer to HM class instance
54 | uint8_t *ptrPeerList; // pointer to list3/4 in regs struct
55 | uint8_t *ptrMainList; // pointer to list0/1 in regs struct
56 |
57 | long counter;
58 |
59 | void configCngEvent(void); // list1 on registered channel had changed
60 | void pairSetEvent(uint8_t *data, uint8_t len); // pair message to specific channel, handover information for value, ramp time and so on
61 | void pairStatusReq(void); // event on status request
62 | void peerMsgEvent(uint8_t type, uint8_t *data, uint8_t len); // peer message was received on the registered channel, handover the message bytes and length
63 | void poll(void); // poll function, driven by HM loop
64 |
65 | //- predefined, no reason to touch ------------------------------------------------------------------------------------
66 | void regInHM(uint8_t cnl, HM *instPtr); // register this module in HM on the specific channel
67 | void hmEventCol(uint8_t by3, uint8_t by10, uint8_t by11, uint8_t *data, uint8_t len); // call back address for HM for informing on events
68 | void peerAddEvent(uint8_t *data, uint8_t len); // peer was added to the specific channel, 1st and 2nd byte shows peer channel, third and fourth byte shows peer index
69 | void setAltitude(int16_t altitude);
70 |
71 | protected:
72 |
73 | private:
74 | BMP085 *bm180;
75 | BH1750 *bh1750;
76 |
77 | uint8_t nAction;
78 | uint32_t nTime;
79 | uint32_t startTime;
80 | uint16_t tTiming;
81 |
82 | int16_t tTemp;
83 | uint8_t tHum;
84 | uint16_t tPres;
85 | int16_t tAltitude; // altitude for calculating air pressure at sea level
86 |
87 | uint32_t tLux;
88 |
89 | uint8_t bh1750IntFlag;
90 |
91 | uint32_t calcSendSlot(void);
92 | void poll_measureCalcLight(void);
93 | void poll_measureTHP(void);
94 | void poll_transmit(void);
95 | };
96 |
97 |
98 | #endif
99 |
--------------------------------------------------------------------------------
/examples/HB-UW-Sen-THPL/ccu-changelog.txt:
--------------------------------------------------------------------------------
1 | For the firmware update, the Sensor must switched off and switched on again.
2 |
3 | 1. Take at least one battery out of the sensor.
4 | 2. Press the config button and insert the battery in the sensor.
5 | 3. Still holding the config button a few seconds after inserting the batteries.
6 | 4. Bootloader should starts.
7 |
8 | Changelog:
9 |
10 | Version Beta 0.14
11 | -------------
12 |
13 | ** Improvement
14 | * Add new register:
15 | - Fix millis() overflow bug. Now, the sensor stays in sleep mode after 49 days, so battery should not drained anymore
16 | - Battery voltage now measured with 1 digit only.
17 |
18 | Version Beta 0.13
19 | -------------
20 |
21 | ** Improvement
22 | * Add new register:
23 | - transmitTryMax: How often should the sensor try to send data without ack.
24 | - lowBatLimit: Defined the battery voltage used for low battery detection.
25 | - ledMode: Switch the device LED on or off while sent out data.
26 | - altitude: Define the sensor-altitude for calculating the air pressure at sea level.
27 |
--------------------------------------------------------------------------------
/examples/HB-WDS40-THP-I/Sens_BMP180.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _SENS_BMP180_H_
3 | #define _SENS_BMP180_H_
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | namespace as {
10 |
11 | class Sens_Bmp180 : public Sensor {
12 |
13 | int16_t _temperature;
14 | uint16_t _pressure;
15 | uint16_t _pressureNN;
16 |
17 | SFE_BMP180 bmp180;
18 |
19 | public:
20 |
21 | Sens_Bmp180 () : _temperature(0), _pressure(0), _pressureNN(0) {}
22 |
23 | void init () {
24 | Wire.begin(); //ToDo sync with further I2C sensor classes
25 | _present = bmp180.begin();
26 |
27 | DPRINT("BMP180 init ");DDECLN(_present);
28 | }
29 |
30 | void measure (uint16_t height) {
31 | if (_present == true) {
32 | double T,P,p0;
33 | char status = bmp180.startTemperature();
34 |
35 | if (status != 0) {
36 | // Wait for the measurement to complete:
37 | delay(status);
38 | status = bmp180.getTemperature(T);
39 | if (status != 0) {
40 | status = bmp180.startPressure(3);
41 | if (status != 0) {
42 | delay(status);
43 | status = bmp180.getPressure(P,T);
44 | if (status != 0) {
45 | p0 = bmp180.sealevel(P,height);
46 | }
47 | }
48 | }
49 | }
50 |
51 | _temperature = (int16_t)(T * 10);
52 | _pressure = (uint16_t)(P * 10);
53 | _pressureNN = (uint16_t)(p0 * 10);
54 |
55 | DPRINTLN(F("BMP180:"));
56 | DPRINT(F("-T : ")); DDECLN(_temperature);
57 | DPRINT(F("-P : ")); DDECLN(_pressure);
58 | DPRINT(F("-P(NN): ")); DDECLN(_pressureNN);
59 | }
60 | }
61 |
62 | int16_t temperature () { return _temperature; }
63 | uint16_t pressure () { return _pressure; }
64 | uint16_t pressureNN () { return _pressureNN; }
65 |
66 | };
67 |
68 | }
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/examples/HB-WDS40-THP-O-BME280/Sens_BME280.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _SENS_BME280_H_
3 | #define _SENS_BME280_H_
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | namespace as {
11 |
12 | BME280I2C::Settings settings(
13 | BME280::OSR_X1, // Temperature Oversampling Rate (tempOSR): OSR Enum, default = OSR_X1
14 | BME280::OSR_X1, // Humidity Oversampling Rate (humOSR): OSR Enum, default = OSR_X1
15 | BME280::OSR_X1, // Pressure Oversampling Rate (presOSR): OSR Enum, default = OSR_X1
16 | BME280::Mode_Forced, // Mode (mode): Mode Enum, default = Mode_Forced
17 | BME280::StandbyTime_1000ms, // Standby Time (standbyTime): StandbyTime Enum, default = StandbyTime_1000ms
18 | BME280::Filter_Off, // Filter (filter): Filter Enum, default = Filter_16
19 | BME280::SpiEnable_False // SPI Enable: SpiEnable Enum, default = false
20 | );
21 |
22 | class Sens_Bme280 : public Sensor {
23 |
24 | int16_t _temperature;
25 | uint16_t _pressure;
26 | uint16_t _pressureNN;
27 | uint8_t _humidity;
28 | uint16_t _dewPoint;
29 |
30 | BME280I2C _bme280; // Default : forced mode, standby time = 1000 ms, Oversampling = pressure ×1, temperature ×1, humidity ×1, filter off
31 |
32 | public:
33 |
34 | Sens_Bme280 () : _temperature(0), _pressure(0), _pressureNN(0), _humidity(0), _dewPoint(0) {}
35 |
36 | void init () {
37 |
38 | Wire.begin(); //ToDo sync with further I2C sensor classes
39 |
40 | uint8_t i = 10;
41 | while( (!_bme280.begin()) && (i > 0) ) {
42 | delay(100);
43 | i--;
44 | }
45 |
46 | switch(_bme280.chipModel()) {
47 | case BME280::ChipModel_BME280:
48 | _present = true;
49 | DPRINTLN(F("BME280 sensor OK"));
50 | break;
51 | default:
52 | DPRINTLN(F("BME280 sensor NOT OK"));
53 | }
54 |
55 | _bme280.setSettings(settings);
56 | }
57 |
58 | void measure (uint16_t height) {
59 | if (_present == true) {
60 | float temp(NAN), hum(NAN), pres(NAN);
61 | _bme280.read(pres, temp, hum, BME280::TempUnit_Celsius, BME280::PresUnit_hPa);
62 |
63 | _temperature = (int16_t)(temp * 10);
64 | _pressure = (uint16_t)(pres * 10);
65 | _pressureNN = (uint16_t)(EnvironmentCalculations::EquivalentSeaLevelPressure(float(height), temp, pres) * 10);
66 | _humidity = (uint8_t)hum;
67 | _dewPoint = (int16_t)(EnvironmentCalculations::DewPoint(temp, hum, EnvironmentCalculations::TempUnit_Celsius) * 10);
68 |
69 | DPRINTLN(F("BME280:"));
70 | DPRINT(F("-T : ")); DDECLN(_temperature);
71 | DPRINT(F("-P : ")); DDECLN(_pressure);
72 | DPRINT(F("-P(NN): ")); DDECLN(_pressureNN);
73 | DPRINT(F("-H : ")); DDECLN(_humidity);
74 | DPRINT(F("-DP : ")); DDECLN(_dewPoint);
75 | }
76 | }
77 |
78 | int16_t temperature () { return _temperature; }
79 | uint16_t pressure () { return _pressure; }
80 | uint16_t pressureNN () { return _pressureNN; }
81 | uint8_t humidity () { return _humidity; }
82 | int16_t dewPoint () { return _dewPoint; }
83 | };
84 |
85 | }
86 |
87 | #endif
88 |
--------------------------------------------------------------------------------
/examples/HM-Dis-TD-T/HM-Dis-TD-T.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | // 2018-10-07 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 | //- -----------------------------------------------------------------------------------------------------------------------
6 | // ci-test=yes board=328p aes=no
7 |
8 | // define this to read the device id, serial and device type from bootloader section
9 | // #define USE_OTA_BOOTLOADER
10 | #define USE_WOR
11 |
12 | #define EI_NOTEXTERNAL
13 | #include
14 | #include
15 | #include
16 |
17 | #include
18 |
19 | // we use a Pro Mini
20 | // Arduino pin for the LED
21 | // D4 == PIN 4 on Pro Mini
22 | #define LED_PIN 4
23 | // Arduino pin for the config button
24 | // B0 == PIN 8 on Pro Mini
25 | #define CONFIG_BUTTON_PIN 8
26 |
27 | #define RELAY1_PIN 17
28 |
29 | // number of available peers per channel
30 | #define PEERS_PER_CHANNEL 8
31 |
32 | // all library classes are placed in the namespace 'as'
33 | using namespace as;
34 |
35 | // define all device properties
36 | const struct DeviceInfo PROGMEM devinfo = {
37 | {0x00,0x78,0x01}, // Device ID
38 | "HMDISTDT01", // Device Serial
39 | {0x00,0x78}, // Device Model
40 | 0x10, // Firmware Version
41 | as::DeviceType::Switch, // Device Type
42 | {0x01,0x00} // Info Bytes
43 | };
44 |
45 | /**
46 | * Configure the used hardware
47 | */
48 | typedef AvrSPI<10,11,12,13> RadioSPI;
49 | typedef AskSin,BatterySensor,Radio > Hal;
50 |
51 | DEFREGISTER(Reg0,DREG_INTKEY,DREG_LEDMODE,MASTERID_REGS,DREG_LOWBATLIMIT)
52 | class SwList0 : public RegList0 {
53 | public:
54 | SwList0(uint16_t addr) : RegList0(addr) {}
55 | void defaults () {
56 | clear();
57 | lowBatLimit(22);
58 | }
59 | };
60 |
61 | // setup the device with channel type and number of channels
62 | class SwitchType : public MultiChannelDevice,1,SwList0> {
63 | public:
64 | typedef MultiChannelDevice,1,SwList0> DevType;
65 | SwitchType (const DeviceInfo& i,uint16_t addr) : DevType(i,addr) {}
66 | virtual ~SwitchType () {}
67 |
68 | virtual void configChanged () {
69 | DevType::configChanged();
70 | uint8_t lowbat = getList0().lowBatLimit();
71 | DDECLN(lowbat);
72 | if( lowbat > 0 ) {
73 | battery().low(lowbat);
74 | }
75 | }
76 | };
77 |
78 | Hal hal;
79 | SwitchType sdev(devinfo,0x20);
80 | ConfigToggleButton cfgBtn(sdev);
81 |
82 | void initPeerings (bool first) {
83 | // create internal peerings - CCU2 needs this
84 | if( first == true ) {
85 | HMID devid;
86 | sdev.getDeviceID(devid);
87 | for( uint8_t i=1; i<=sdev.channels(); ++i ) {
88 | Peer ipeer(devid,i);
89 | sdev.channel(i).peer(ipeer);
90 | }
91 | }
92 | }
93 |
94 |
95 | void setup () {
96 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
97 | bool first = sdev.init(hal);
98 | sdev.channel(1).init(RELAY1_PIN);
99 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
100 | initPeerings(first);
101 | // stay on for 15 seconds after start
102 | hal.activity.stayAwake(seconds2ticks(15));
103 | // measure battery every hour
104 | hal.battery.init(seconds2ticks(60UL*60),sysclock);
105 | sdev.initDone();
106 | }
107 |
108 | void loop() {
109 | bool worked = hal.runready();
110 | bool poll = sdev.pollRadio();
111 | if( worked == false && poll == false ) {
112 | hal.activity.savePower >(hal);
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/examples/HM-ES-PMSw1-Pl/POW_Pinout.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-ES-PMSw1-Pl/POW_Pinout.jpg
--------------------------------------------------------------------------------
/examples/HM-ES-PMSw1-Pl/README.md:
--------------------------------------------------------------------------------
1 | # Library
2 |
3 | Die Library [HLW8012](https://github.com/xoseperez/hlw8012) wird zum Kompilieren des Sketches benötigt.
4 |
5 | # Anschlüsse
6 |
7 | 
8 |
--------------------------------------------------------------------------------
/examples/HM-ES-PMSw1-Pl_GosundSP1/README.md:
--------------------------------------------------------------------------------
1 | # Library
2 |
3 | Die Library [HLW8012](https://github.com/xoseperez/hlw8012) wird zum Kompilieren des Sketches benötigt.
4 |
5 | # Adapterplatine
6 |
7 | https://github.com/stan23/HM-ES-PMSw1-Pl_GosundSP1
--------------------------------------------------------------------------------
/examples/HM-LC-SW1-FM_Shelly1/1_Shelly_Open.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/1_Shelly_Open.jpeg
--------------------------------------------------------------------------------
/examples/HM-LC-SW1-FM_Shelly1/2_Shelly_RemoveESP.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/2_Shelly_RemoveESP.jpg
--------------------------------------------------------------------------------
/examples/HM-LC-SW1-FM_Shelly1/3_Shelly_RemovedESP.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/3_Shelly_RemovedESP.jpg
--------------------------------------------------------------------------------
/examples/HM-LC-SW1-FM_Shelly1/4_ProMiniWithCC1101.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/4_ProMiniWithCC1101.jpg
--------------------------------------------------------------------------------
/examples/HM-LC-SW1-FM_Shelly1/5_ShellyWithoutESP.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/5_ShellyWithoutESP.jpg
--------------------------------------------------------------------------------
/examples/HM-LC-SW1-FM_Shelly1/6_ShellyAssembled.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/6_ShellyAssembled.jpeg
--------------------------------------------------------------------------------
/examples/HM-LC-SW1-FM_Shelly1/7_ShellyCase.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/7_ShellyCase.jpg
--------------------------------------------------------------------------------
/examples/HM-LC-SW1-FM_Shelly1/Deckel.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/Deckel.stl
--------------------------------------------------------------------------------
/examples/HM-LC-SW1-FM_Shelly1/HM-LC-SW1-FM_Shelly1.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | // 2018-10-21 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 | //- -----------------------------------------------------------------------------------------------------------------------
6 | // ci-test=yes board=328p aes=no
7 |
8 | // define this to read the device id, serial and device type from bootloader section
9 | // #define USE_OTA_BOOTLOADER
10 |
11 | #define EI_NOTEXTERNAL
12 | #include
13 | #include
14 | #include
15 |
16 | #include
17 |
18 | #define LED_PIN 4
19 | #define RELAY1_PIN 5
20 | #define CONFIG_BUTTON_PIN 8
21 | #define PEERS_PER_CHANNEL 12
22 |
23 |
24 | // all library classes are placed in the namespace 'as'
25 | using namespace as;
26 |
27 | // define all device properties
28 | const struct DeviceInfo PROGMEM devinfo = {
29 | {0x00, 0x04, 0x00}, // Device ID
30 | "JPSW1FM000", // Device Serial
31 | {0x00, 0x04}, // Device Model
32 | 0x16, // Firmware Version
33 | as::DeviceType::Switch, // Device Type
34 | {0x01, 0x00} // Info Bytes
35 | };
36 |
37 |
38 | typedef AskSin, NoBattery, Radio , 2> > Hal;
39 | typedef MultiChannelDevice, 1> SwitchType;
40 |
41 | Hal hal;
42 | SwitchType sdev(devinfo, 0x20);
43 | ConfigToggleButton cfgBtn(sdev);
44 |
45 | void setup () {
46 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
47 | sdev.init(hal);
48 |
49 | sdev.channel(1).init(RELAY1_PIN, false);
50 |
51 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
52 |
53 | HMID devid;
54 | sdev.getDeviceID(devid);
55 | Peer ipeer(devid, 1);
56 | sdev.channel(1).peer(ipeer);
57 | sdev.initDone();
58 | }
59 |
60 | void loop() {
61 | bool worked = hal.runready();
62 | bool poll = sdev.pollRadio();
63 | if ( worked == false && poll == false ) {
64 | hal.activity.savePower >(hal);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/examples/HM-LC-SW1-FM_Shelly1/README.md:
--------------------------------------------------------------------------------
1 | # Umbau Shelly1 auf AskSinPP
2 | - [Sketch](https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/master/examples/HM-LC-SW1-FM_Shelly1/HM-LC-SW1-FM_Shelly1.ino)
3 | - [Deckel](https://github.com/jp112sdl/Beispiel_AskSinPP/blob/master/examples/HM-LC-SW1-FM_Shelly1/Deckel.stl)
4 |
5 | #### 1. Gehäuse öffnen
6 | 
7 |
8 | #### 2. ESP entfernen
9 | _Geht wunderbar mit einem kleinen Lötbrenner. 3-4 Sekunden auf die Mitte des ESP halten und mit einer Pinzette abheben_
10 | 
11 |
12 | #### 3. Einen Pro Mini mit CC1101 "verheiraten" und den [Sketch](https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/master/examples/HM-LC-SW1-FM_Shelly1/HM-LC-SW1-FM_Shelly1.ino) flashen
13 | 
14 |
15 | #### 4. Die Pro Mini Pins Vcc (3.3V), GND, 5 und 8 mit den markierten Lötstellen verdrahten
16 | 
17 |
18 | #### 5. Eine Isolation zwischen Pro Mini und Shelly anbringen und das Ganze mit etwas Kleber fixieren
19 | 
20 |
21 | #### 6. [Deckel](https://github.com/jp112sdl/Beispiel_AskSinPP/blob/master/examples/HM-LC-SW1-FM_Shelly1/Deckel.stl) ausdrucken und am Shelly verkleben
22 | 
23 |
24 | **Zuletzt noch anlernen -> Das Gerät erscheint als HM-LC-Sw1-FM in der HomeMatic Zentrale.
25 | Zum Anlernen den Taster an "SW" lange (ca. 3 Sekunden) drücken.**
26 |
--------------------------------------------------------------------------------
/examples/HM-LC-SW1-SM_SONOFF_BASIC/HM-LC-SW1-SM_SONOFF_BASIC.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | // 2018-09-12 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 | //- -----------------------------------------------------------------------------------------------------------------------
6 | // ci-test=yes board=328p aes=no
7 |
8 | // define this to read the device id, serial and device type from bootloader section
9 | // #define USE_OTA_BOOTLOADER
10 |
11 | // number of relays by defining the device
12 | #define EI_NOTEXTERNAL
13 | #include
14 | #include
15 | #include
16 |
17 | #include
18 |
19 | #define LED_PIN A3
20 | #define CONFIG_BUTTON_PIN 8
21 | #define RELAY1_PIN 5
22 |
23 | // number of available peers per channel
24 | #define PEERS_PER_CHANNEL 8
25 |
26 | // all library classes are placed in the namespace 'as'
27 | using namespace as;
28 |
29 | // define all device properties
30 | const struct DeviceInfo PROGMEM devinfo = {
31 | {0x00, 0x02, 0x01}, // Device ID
32 | "SONOFF0001", // Device Serial
33 | {0x00, 0x02}, // Device Model
34 | 0x16, // Firmware Version
35 | as::DeviceType::Switch, // Device Type
36 | {0x01, 0x00} // Info Bytes
37 | };
38 |
39 | /**
40 | Configure the used hardware
41 | */
42 | typedef AvrSPI<10, 11, 12, 13> RadioSPI;
43 | typedef AskSin, NoBattery, Radio > Hal;
44 |
45 | // setup the device with channel type and number of channels
46 | typedef MultiChannelDevice, 1> SwitchType;
47 |
48 | Hal hal;
49 | SwitchType sdev(devinfo, 0x20);
50 |
51 | ConfigToggleButton cfgBtn(sdev);
52 |
53 | void initPeerings (bool first) {
54 | // create internal peerings - CCU2 needs this
55 | if ( first == true ) {
56 | HMID devid;
57 | sdev.getDeviceID(devid);
58 | for ( uint8_t i = 1; i <= sdev.channels(); ++i ) {
59 | Peer ipeer(devid, i);
60 | sdev.channel(i).peer(ipeer);
61 | }
62 | }
63 | }
64 |
65 | void setup () {
66 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
67 | bool first = sdev.init(hal);
68 | sdev.channel(1).init(RELAY1_PIN, false);
69 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
70 | sdev.channels(1);
71 | initPeerings(first);
72 | sdev.initDone();
73 | }
74 |
75 | void loop() {
76 | bool worked = hal.runready();
77 | bool poll = sdev.pollRadio();
78 | if ( worked == false && poll == false ) {
79 | hal.activity.savePower >(hal);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/examples/HM-LC-Sw1-Pl-CT-R1/HM-LC-Sw1-Pl-CT-R1.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | // ci-test=yes board=328p aes=no
6 |
7 | // define this to read the device id, serial and device type from bootloader section
8 | // #define USE_OTA_BOOTLOADER
9 |
10 | // number of relays by defining the device
11 | #define HM_LC_SW1_SM 0x00,0x02
12 |
13 |
14 | #define CFG_LOWACTIVE_BYTE 0x00
15 | #define CFG_LOWACTIVE_ON 0x01
16 | #define CFG_LOWACTIVE_OFF 0x00
17 |
18 | #define DEVICE_CONFIG CFG_LOWACTIVE_OFF
19 |
20 | #define EI_NOTEXTERNAL
21 | #include
22 | #include
23 | #include
24 |
25 | #include
26 |
27 | // we use a Pro Mini
28 | // Arduino pin for the LED
29 | // D4 == PIN 4 on Pro Mini
30 | #define LED_PIN 4
31 | // Arduino pin for the config button
32 | // B0 == PIN 8 on Pro Mini
33 | #define CONFIG_BUTTON_PIN 8
34 | #define RELAY1_PIN 5
35 |
36 | // number of available peers per channel
37 | #define PEERS_PER_CHANNEL 8
38 |
39 |
40 | // all library classes are placed in the namespace 'as'
41 | using namespace as;
42 |
43 | // define all device properties
44 | const struct DeviceInfo PROGMEM devinfo = {
45 | {0x00, 0xeb, 0x02}, // Device ID
46 | "JPSw1CT001", // Device Serial
47 | {0x00, 0xeb}, // Device Model
48 | 0x24, // Firmware Version
49 | as::DeviceType::Switch, // Device Type
50 | {0x01, 0x00} // Info Bytes
51 | };
52 |
53 | /**
54 | Configure the used hardware
55 | */
56 | typedef AvrSPI<10, 11, 12, 13> RadioSPI;
57 | typedef AskSin, NoBattery, Radio > Hal;
58 |
59 | // setup the device with channel type and number of channels
60 | typedef MultiChannelDevice, 4> SwitchType;
61 |
62 | Hal hal;
63 | SwitchType sdev(devinfo, 0x20);
64 |
65 | ConfigToggleButton cfgBtn(sdev);
66 |
67 | // if A0 and A1 connected
68 | // we use LOW for ON and HIGH for OFF
69 | bool checkLowActive () {
70 | pinMode(14, OUTPUT); // A0
71 | pinMode(15, INPUT_PULLUP); // A1
72 | digitalWrite(15, HIGH);
73 | digitalWrite(14, LOW);
74 | bool result = digitalRead(15) == LOW;
75 | digitalWrite(14, HIGH);
76 | return result;
77 | }
78 |
79 | void initPeerings (bool first) {
80 | // create internal peerings - CCU2 needs this
81 | if ( first == true ) {
82 | HMID devid;
83 | sdev.getDeviceID(devid);
84 | for ( uint8_t i = 1; i <= sdev.channels(); ++i ) {
85 | Peer ipeer(devid, i);
86 | sdev.channel(i).peer(ipeer);
87 | }
88 | }
89 | }
90 |
91 | void initModelType () {
92 | uint8_t model[2];
93 | sdev.getDeviceModel(model);
94 | sdev.channels(1);
95 | }
96 |
97 | void setup () {
98 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
99 | bool first = sdev.init(hal);
100 | bool low = (sdev.getConfigByte(CFG_LOWACTIVE_BYTE) == CFG_LOWACTIVE_ON) || checkLowActive();
101 | sdev.channel(1).init(RELAY1_PIN, low);
102 |
103 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
104 |
105 | initModelType();
106 | initPeerings(first);
107 | sdev.initDone();
108 | }
109 |
110 | void loop() {
111 | bool worked = hal.runready();
112 | bool poll = sdev.pollRadio();
113 | if ( worked == false && poll == false ) {
114 | hal.activity.savePower >(hal);
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/examples/HM-LC-Sw1-Pl-DN-R1/HM-LC-Sw1-Pl-DN-R1.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | // ci-test=yes board=328p aes=no
6 |
7 | // define this to read the device id, serial and device type from bootloader section
8 | // #define USE_OTA_BOOTLOADER
9 |
10 | // number of relays by defining the device
11 |
12 |
13 | #define CFG_LOWACTIVE_BYTE 0x00
14 | #define CFG_LOWACTIVE_ON 0x01
15 | #define CFG_LOWACTIVE_OFF 0x00
16 |
17 | #define DEVICE_CONFIG CFG_LOWACTIVE_OFF
18 |
19 | #define EI_NOTEXTERNAL
20 | #include
21 | #include
22 | #include
23 |
24 | #include
25 |
26 | // we use a Pro Mini
27 | // Arduino pin for the LED
28 | // D4 == PIN 4 on Pro Mini
29 | #define LED_PIN 4
30 | // Arduino pin for the config button
31 | // B0 == PIN 8 on Pro Mini
32 | #define CONFIG_BUTTON_PIN 8
33 | #define LED_PIN 4
34 | #define RELAY1_PIN 5
35 |
36 |
37 | // number of available peers per channel
38 | #define PEERS_PER_CHANNEL 8
39 |
40 |
41 | // all library classes are placed in the namespace 'as'
42 | using namespace as;
43 |
44 | // define all device properties
45 | const struct DeviceInfo PROGMEM devinfo = {
46 | {0x01, 0xd8, 0x09}, // Device ID
47 | "JPLCSw1002", // Device Serial
48 | {0x00,0xd8}, // Device Model
49 | 0x26, // Firmware Version
50 | as::DeviceType::Switch, // Device Type
51 | {0x01, 0x00} // Info Bytes
52 | };
53 |
54 | /**
55 | Configure the used hardware
56 | */
57 | typedef AvrSPI<10, 11, 12, 13> RadioSPI;
58 | typedef AskSin, NoBattery, Radio > Hal;
59 |
60 | // setup the device with channel type and number of channels
61 | typedef MultiChannelDevice, 1> SwitchType;
62 |
63 | Hal hal;
64 | SwitchType sdev(devinfo, 0x20);
65 | ConfigToggleButton cfgBtn(sdev);
66 |
67 | void initPeerings (bool first) {
68 | // create internal peerings - CCU2 needs this
69 | if ( first == true ) {
70 | HMID devid;
71 | sdev.getDeviceID(devid);
72 | for ( uint8_t i = 1; i <= sdev.channels(); ++i ) {
73 | Peer ipeer(devid, i);
74 | sdev.channel(i).peer(ipeer);
75 | }
76 | }
77 | }
78 |
79 | void initModelType () {
80 | uint8_t model[2];
81 | sdev.getDeviceModel(model);
82 | sdev.channels(1);
83 | }
84 |
85 | void setup () {
86 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
87 | bool first = sdev.init(hal);
88 | sdev.channel(1).init(RELAY1_PIN, false);
89 |
90 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
91 |
92 | initModelType();
93 | initPeerings(first);
94 | sdev.initDone();
95 | }
96 |
97 | void loop() {
98 | bool worked = hal.runready();
99 | bool poll = sdev.pollRadio();
100 | if ( worked == false && poll == false ) {
101 | hal.activity.savePower >(hal);
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/examples/HM-LC-Sw1-Pl-DN-R1_OBI/HM-LC-Sw1-Pl-DN-R1_OBI.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | // 2018-07-13 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 | //- -----------------------------------------------------------------------------------------------------------------------
6 | // ci-test=yes board=328p aes=no
7 |
8 | // define this to read the device id, serial and device type from bootloader section
9 | // #define USE_OTA_BOOTLOADER
10 |
11 | // number of relays by defining the device
12 |
13 |
14 | #define EI_NOTEXTERNAL
15 | #include
16 | #include
17 | #include
18 |
19 | #define USE_PIN_PULSE
20 | #define PIN_PULSE_MILLIS 100
21 | #define PIN_PULSE_STATE LOW
22 |
23 | #include "SwitchObi.h"
24 |
25 | // we use a Pro Mini
26 | // Arduino pin for the LED
27 | // D4 == PIN 4 on Pro Mini
28 | #define LED_PIN 4
29 | // Arduino pin for the config button
30 | // B0 == PIN 8 on Pro Mini
31 | #define CONFIG_BUTTON_PIN 8
32 |
33 | #define RELAY_ON_PIN 5
34 | #define RELAY_OFF_PIN 6
35 |
36 |
37 | // number of available peers per channel
38 | #define PEERS_PER_CHANNEL 8
39 |
40 |
41 | // all library classes are placed in the namespace 'as'
42 | using namespace as;
43 |
44 | // define all device properties
45 | const struct DeviceInfo PROGMEM devinfo = {
46 | {0x00, 0xd8, 0x99}, // Device ID
47 | "JPLCSw1099", // Device Serial
48 | {0x00,0xd8}, // Device Model
49 | 0x26, // Firmware Version
50 | as::DeviceType::Switch, // Device Type
51 | {0x01, 0x00} // Info Bytes
52 | };
53 |
54 | /**
55 | Configure the used hardware
56 | */
57 | typedef AvrSPI<10, 11, 12, 13> RadioSPI;
58 | typedef AskSin, NoBattery, Radio > Hal;
59 |
60 | // setup the device with channel type and number of channels
61 | typedef MultiChannelDevice, 1> SwitchType;
62 |
63 | Hal hal;
64 | SwitchType sdev(devinfo, 0x20);
65 | ConfigToggleButton cfgBtn(sdev);
66 |
67 | void initPeerings (bool first) {
68 | // create internal peerings - CCU2 needs this
69 | if ( first == true ) {
70 | HMID devid;
71 | sdev.getDeviceID(devid);
72 | for ( uint8_t i = 1; i <= sdev.channels(); ++i ) {
73 | Peer ipeer(devid, i);
74 | sdev.channel(i).peer(ipeer);
75 | }
76 | }
77 | }
78 |
79 | void initModelType () {
80 | uint8_t model[2];
81 | sdev.getDeviceModel(model);
82 | sdev.channels(1);
83 | }
84 |
85 | void setup () {
86 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
87 | bool first = sdev.init(hal);
88 | sdev.channel(1).init(RELAY_ON_PIN, RELAY_OFF_PIN, false);
89 |
90 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
91 |
92 | initModelType();
93 | initPeerings(first);
94 | sdev.initDone();
95 | }
96 |
97 | void loop() {
98 | bool worked = hal.runready();
99 | bool poll = sdev.pollRadio();
100 | if ( worked == false && poll == false ) {
101 | hal.activity.savePower >(hal);
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/examples/HM-LC-Sw1-Pl-DN-R1_OBI/README.md:
--------------------------------------------------------------------------------
1 | Sketch für den Umbau eines OBI WiFi Zwischensteckers
2 |
3 | Eine Platine gibts hier: https://github.com/stan23/HM-LC-Sw1-Pl-DN-R1_OBI
4 |
--------------------------------------------------------------------------------
/examples/HM-LC-Sw2-FM/HM-LC-Sw2-FM.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | // ci-test=yes board=328p aes=no
6 |
7 | // define this to read the device id, serial and device type from bootloader section
8 | // #define USE_OTA_BOOTLOADER
9 |
10 | #define EI_NOTEXTERNAL
11 | #include
12 | #include
13 | #include
14 |
15 | #include
16 |
17 | // we use a Pro Mini
18 | // Arduino pin for the LED
19 | // D4 == PIN 4 on Pro Mini
20 | #define LED_PIN 4
21 | // Arduino pin for the config button
22 | // B0 == PIN 8 on Pro Mini
23 | #define CONFIG_BUTTON_PIN 8
24 |
25 | //set to 0x01 if the RELAY should be switched on LOW level
26 | #define LOW_ACTIVE 0x00
27 | #define RELAY1_PIN 17 //A3
28 | #define RELAY2_PIN 16 //A2
29 |
30 | #define BUTTON1_PIN 6
31 | #define BUTTON2_PIN 3
32 |
33 | // number of available peers per channel
34 | #define PEERS_PER_CHANNEL 8
35 |
36 | // all library classes are placed in the namespace 'as'
37 | using namespace as;
38 |
39 | // define all device properties
40 | const struct DeviceInfo PROGMEM devinfo = {
41 | {0x12, 0x09, 0x00}, // Device ID
42 | "JPLCSw2001", // Device Serial
43 | {0x00, 0x09}, // Device Model
44 | 0x24, // Firmware Version
45 | as::DeviceType::Switch, // Device Type
46 | {0x01, 0x00} // Info Bytes
47 | };
48 |
49 | /**
50 | Configure the used hardware
51 | */
52 | typedef AvrSPI<10, 11, 12, 13> RadioSPI;
53 | typedef AskSin, NoBattery, Radio > Hal;
54 |
55 | // setup the device with channel type and number of channels
56 | typedef MultiChannelDevice, 2> SwitchType;
57 |
58 | Hal hal;
59 | SwitchType sdev(devinfo, 0x20);
60 | ConfigButton cfgBtn(sdev);
61 | InternalButton btn1(sdev, 1);
62 | InternalButton btn2(sdev, 2);
63 |
64 | void initPeerings (bool first) {
65 | // create internal peerings - CCU2 needs this
66 | if ( first == true ) {
67 | HMID devid;
68 | sdev.getDeviceID(devid);
69 | for ( uint8_t i = 1; i <= sdev.channels(); ++i ) {
70 | Peer ipeer(devid, i);
71 | sdev.channel(i).peer(ipeer);
72 | }
73 | }
74 | }
75 |
76 | void setup () {
77 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
78 | bool first = sdev.init(hal);
79 | sdev.channel(1).init(RELAY1_PIN, LOW_ACTIVE);
80 | sdev.channel(2).init(RELAY2_PIN, LOW_ACTIVE);
81 |
82 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
83 | buttonISR(btn1, BUTTON1_PIN);
84 | buttonISR(btn2, BUTTON2_PIN);
85 |
86 | sdev.channels(2);
87 | initPeerings(first);
88 | sdev.initDone();
89 | }
90 |
91 | void loop() {
92 | bool worked = hal.runready();
93 | bool poll = sdev.pollRadio();
94 | if ( worked == false && poll == false ) {
95 | hal.activity.savePower >(hal);
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/examples/HM-MOD-Re-8/HM-MOD-Re-8.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | // 2018-09-29 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
5 | //- -----------------------------------------------------------------------------------------------------------------------
6 | // ci-test=yes board=328p aes=no
7 |
8 | // define this to read the device id, serial and device type from bootloader section
9 | // #define USE_OTA_BOOTLOADER
10 | #define USE_WOR
11 |
12 | #define EI_NOTEXTERNAL
13 | #include
14 | #include
15 | #include
16 |
17 | #include
18 |
19 |
20 | // we use a Pro Mini
21 | // Arduino pin for the LED
22 | // D4 == PIN 4 on Pro Mini
23 | #define LED_PIN 4
24 | // Arduino pin for the config button
25 | // B0 == PIN 8 on Pro Mini
26 | #define CONFIG_BUTTON_PIN 8
27 |
28 | #define RELAY1_PIN 14
29 | #define RELAY2_PIN 15
30 | #define RELAY3_PIN 16
31 | #define RELAY4_PIN 17
32 | #define RELAY5_PIN 7
33 | #define RELAY6_PIN 9
34 | #define RELAY7_PIN 6
35 | #define RELAY8_PIN 5
36 |
37 | // number of available peers per channel
38 | #define PEERS_PER_CHANNEL 4
39 |
40 | // all library classes are placed in the namespace 'as'
41 | using namespace as;
42 |
43 | // define all device properties
44 | const struct DeviceInfo PROGMEM devinfo = {
45 | {0x00,0xBE,0x00}, // Device ID
46 | "JP00BE0000", // Device Serial
47 | {0x00,0xbe}, // Device Model
48 | 0x12, // Firmware Version
49 | as::DeviceType::Switch, // Device Type
50 | {0x01,0x00} // Info Bytes
51 | };
52 |
53 | /**
54 | * Configure the used hardware
55 | */
56 | typedef AvrSPI<10,11,12,13> RadioSPI;
57 | typedef AskSin,BatterySensor,Radio > Hal;
58 |
59 | DEFREGISTER(Reg0,DREG_INTKEY,DREG_LEDMODE,MASTERID_REGS,DREG_LOWBATLIMIT)
60 | class SwList0 : public RegList0 {
61 | public:
62 | SwList0(uint16_t addr) : RegList0(addr) {}
63 | void defaults () {
64 | clear();
65 | lowBatLimit(22);
66 | }
67 | };
68 |
69 | // setup the device with channel type and number of channels
70 | class SwitchType : public MultiChannelDevice,8,SwList0> {
71 | public:
72 | typedef MultiChannelDevice,8,SwList0> DevType;
73 | SwitchType (const DeviceInfo& i,uint16_t addr) : DevType(i,addr) {}
74 | virtual ~SwitchType () {}
75 |
76 | virtual void configChanged () {
77 | DevType::configChanged();
78 | uint8_t lowbat = getList0().lowBatLimit();
79 | DDECLN(lowbat);
80 | if( lowbat > 0 ) {
81 | battery().low(lowbat);
82 | }
83 | }
84 | };
85 |
86 | Hal hal;
87 | SwitchType sdev(devinfo,0x20);
88 | ConfigButton cfgBtn(sdev);
89 |
90 | void initPeerings (bool first) {
91 | // create internal peerings - CCU2 needs this
92 | if( first == true ) {
93 | HMID devid;
94 | sdev.getDeviceID(devid);
95 | for( uint8_t i=1; i<=sdev.channels(); ++i ) {
96 | Peer ipeer(devid,i);
97 | sdev.channel(i).peer(ipeer);
98 | }
99 | }
100 | }
101 |
102 |
103 | void setup () {
104 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
105 | bool first = sdev.init(hal);
106 | sdev.channel(1).init(RELAY1_PIN);
107 | sdev.channel(2).init(RELAY2_PIN);
108 | sdev.channel(3).init(RELAY3_PIN);
109 | sdev.channel(4).init(RELAY4_PIN);
110 | sdev.channel(5).init(RELAY5_PIN);
111 | sdev.channel(6).init(RELAY6_PIN);
112 | sdev.channel(7).init(RELAY7_PIN);
113 | sdev.channel(8).init(RELAY8_PIN);
114 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
115 | initPeerings(first);
116 | // stay on for 15 seconds after start
117 | hal.activity.stayAwake(seconds2ticks(15));
118 | // measure battery every hour
119 | hal.battery.init(seconds2ticks(60UL*60),sysclock);
120 | sdev.initDone();
121 | }
122 |
123 | void loop() {
124 | bool worked = hal.runready();
125 | bool poll = sdev.pollRadio();
126 | if( worked == false && poll == false ) {
127 | hal.activity.savePower >(hal);
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/examples/HM-PB-2-FM/HM-PB-2-FM.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | // ci-test=yes board=328p aes=no
6 |
7 | // define this to read the device id, serial and device type from bootloader section
8 | // #define USE_OTA_BOOTLOADER
9 |
10 | #define EI_NOTEXTERNAL
11 | #include
12 | #include // after including SPI Library - we can use LibSPI class
13 | #include
14 | #include
15 |
16 | #include
17 | #include
18 |
19 |
20 | // we use a Pro Mini
21 | // Arduino pin for the LED
22 | // D4 == PIN 4 on Pro Mini
23 | #define LED_PIN 4
24 | #define LED_PIN2 5
25 | // Arduino pin for the config button
26 | // B0 == PIN 8 on Pro Mini
27 | #define CONFIG_BUTTON_PIN 8
28 | // Arduino pins for the buttons
29 | // A0,A1,A2,A3 == PIN 14,15,16,17 on Pro Mini
30 | #define BTN1_PIN 14
31 | #define BTN2_PIN 15
32 |
33 |
34 | // number of available peers per channel
35 | #define PEERS_PER_CHANNEL 10
36 |
37 | // all library classes are placed in the namespace 'as'
38 | using namespace as;
39 |
40 | // define all device properties
41 | const struct DeviceInfo PROGMEM devinfo = {
42 | {0x02, 0xBF, 0x01}, // Device ID
43 | "JPPB2FM001", // Device Serial
44 | {0x00, 0xBF}, // Device Model
45 | 0x14, // Firmware Version
46 | as::DeviceType::Remote, // Device Type
47 | {0x00, 0x00} // Info Bytes
48 | };
49 |
50 | /**
51 | Configure the used hardware
52 | */
53 | typedef LibSPI<10> SPIType;
54 | typedef Radio RadioType;
55 | typedef DualStatusLed LedType;
56 | typedef AskSin HalType;
57 | class Hal : public HalType {
58 | // extra clock to count button press events
59 | AlarmClock btncounter;
60 | public:
61 | void init (const HMID& id) {
62 | HalType::init(id);
63 | // get new battery value after 50 key press
64 | battery.init(50, btncounter);
65 | battery.low(22);
66 | battery.critical(19);
67 | }
68 |
69 | void sendPeer () {
70 | --btncounter;
71 | }
72 |
73 | bool runready () {
74 | return HalType::runready() || btncounter.runready();
75 | }
76 | };
77 |
78 | typedef RemoteChannel ChannelType;
79 | typedef MultiChannelDevice RemoteType;
80 |
81 | Hal hal;
82 | RemoteType sdev(devinfo, 0x20);
83 | ConfigButton cfgBtn(sdev);
84 |
85 | void setup () {
86 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
87 | sdev.init(hal);
88 | remoteISR(sdev, 1, BTN1_PIN);
89 | remoteISR(sdev, 2, BTN2_PIN);
90 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
91 | sdev.initDone();
92 | }
93 |
94 | void loop() {
95 | bool worked = hal.runready();
96 | bool poll = sdev.pollRadio();
97 | if (worked == false && poll == false ) {
98 | hal.activity.savePower>(hal);
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/examples/HM-PB-2-WM55/HM-PB-2-WM55.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | // ci-test=yes board=328p aes=no
6 |
7 | // define this to read the device id, serial and device type from bootloader section
8 | // #define USE_OTA_BOOTLOADER
9 |
10 | #define EI_NOTEXTERNAL
11 | #include
12 | #include // after including SPI Library - we can use LibSPI class
13 | #include
14 | #include
15 |
16 | #include
17 | #include
18 |
19 |
20 | // we use a Pro Mini
21 | // Arduino pin for the LED
22 | // D4 == PIN 4 on Pro Mini
23 | #define LED_PIN 4
24 | #define LED_PIN2 5
25 | // Arduino pin for the config button
26 | // B0 == PIN 8 on Pro Mini
27 | #define CONFIG_BUTTON_PIN 8
28 | // Arduino pins for the buttons
29 | // A0,A1,A2,A3 == PIN 14,15,16,17 on Pro Mini
30 | #define BTN1_PIN 14
31 | #define BTN2_PIN 15
32 |
33 |
34 | // number of available peers per channel
35 | #define PEERS_PER_CHANNEL 10
36 |
37 | // all library classes are placed in the namespace 'as'
38 | using namespace as;
39 |
40 | // define all device properties
41 | const struct DeviceInfo PROGMEM devinfo = {
42 | {0x72,0x6B,0x12}, // Device ID
43 | "JPPB200001", // Device Serial
44 | {0x00,0x6B}, // Device Model
45 | 0x14, // Firmware Version
46 | as::DeviceType::Remote, // Device Type
47 | {0x00,0x00} // Info Bytes
48 | };
49 |
50 | /**
51 | * Configure the used hardware
52 | */
53 | typedef LibSPI<10> SPIType;
54 | typedef Radio RadioType;
55 | typedef DualStatusLed LedType;
56 | typedef AskSin HalType;
57 | class Hal : public HalType {
58 | // extra clock to count button press events
59 | AlarmClock btncounter;
60 | public:
61 | void init (const HMID& id) {
62 | HalType::init(id);
63 | // get new battery value after 50 key press
64 | battery.init(50,btncounter);
65 | battery.low(22);
66 | battery.critical(19);
67 | }
68 |
69 | void sendPeer () {
70 | --btncounter;
71 | }
72 |
73 | bool runready () {
74 | return HalType::runready() || btncounter.runready();
75 | }
76 | };
77 |
78 | typedef RemoteChannel ChannelType;
79 | typedef MultiChannelDevice RemoteType;
80 |
81 | Hal hal;
82 | RemoteType sdev(devinfo,0x20);
83 | ConfigButton cfgBtn(sdev);
84 |
85 | void setup () {
86 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
87 | sdev.init(hal);
88 | remoteISR(sdev,1,BTN1_PIN);
89 | remoteISR(sdev,2,BTN2_PIN);
90 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
91 | sdev.initDone();
92 | }
93 |
94 | void loop() {
95 | bool worked = hal.runready();
96 | bool poll = sdev.pollRadio();
97 | if( worked == false && poll == false ) {
98 | hal.activity.savePower>(hal);
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/examples/HM-PB-6-WM55/HM-PB-6-WM55.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | // ci-test=yes board=328p aes=no
6 |
7 | // define this to read the device id, serial and device type from bootloader section
8 | // #define USE_OTA_BOOTLOADER
9 |
10 | #define EI_NOTEXTERNAL
11 | #include
12 | #include
13 | #include
14 |
15 | #include
16 | #include
17 |
18 |
19 | // we use a Pro Mini
20 | // Arduino pin for the LED
21 | // D4/D5 == PIN 4/5
22 | #define LED_GREEN 4
23 | #define LED_RED 5
24 | // Arduino pin for the config button
25 | // B0 == PIN 8
26 | #define CONFIG_BUTTON_PIN 8
27 | // Arduino pins for the buttons
28 | #define BTN01_PIN 14 // PC0
29 | #define BTN02_PIN 3 // PD3
30 | #define BTN03_PIN 15 // PC1
31 | #define BTN04_PIN 7 // PD7
32 | #define BTN05_PIN 9 // PB1
33 | #define BTN06_PIN 6 // PD6
34 |
35 |
36 |
37 | // number of available peers per channel
38 | #define PEERS_PER_CHANNEL 10
39 |
40 | // all library classes are placed in the namespace 'as'
41 | using namespace as;
42 |
43 | // define all device properties
44 | const struct DeviceInfo PROGMEM devinfo = {
45 | {0x04,0xa9,0x00}, // Device ID
46 | "HMRC00da00", // Device Serial
47 | {0x00,0xA9}, // Device Model
48 | 0x01, // Firmware Version
49 | as::DeviceType::Remote, // Device Type
50 | {0x00,0x00} // Info Bytes
51 | };
52 |
53 | /**
54 | * Configure the used hardware
55 | */
56 | typedef AvrSPI<10,11,12,13> SPIType;
57 | typedef Radio RadioType;
58 | typedef DualStatusLed LedType;
59 | typedef AskSin HalType;
60 | class Hal : public HalType {
61 | // extra clock to count button press events
62 | AlarmClock btncounter;
63 | public:
64 | void init (const HMID& id) {
65 | HalType::init(id);
66 | // get new battery value after 50 key press
67 | battery.init(50,btncounter);
68 | battery.low(22);
69 | battery.critical(19);
70 | }
71 |
72 | void sendPeer () {
73 | --btncounter;
74 | }
75 |
76 | bool runready () {
77 | return HalType::runready() || btncounter.runready();
78 | }
79 | };
80 |
81 | typedef RemoteChannel ChannelType;
82 | typedef MultiChannelDevice RemoteType;
83 |
84 | Hal hal;
85 | RemoteType sdev(devinfo,0x20);
86 | ConfigButton cfgBtn(sdev);
87 |
88 | void setup () {
89 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
90 | sdev.init(hal);
91 |
92 | remoteISR(sdev,1,BTN01_PIN);
93 | remoteISR(sdev,2,BTN02_PIN);
94 | remoteISR(sdev,3,BTN03_PIN);
95 | remoteISR(sdev,4,BTN04_PIN);
96 | remoteISR(sdev,5,BTN05_PIN);
97 | remoteISR(sdev,6,BTN06_PIN);
98 |
99 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
100 |
101 | sdev.initDone();
102 | }
103 |
104 | void loop() {
105 | bool worked = hal.runready();
106 | bool poll = sdev.pollRadio();
107 | if(worked == false && poll == false ) {
108 | hal.activity.savePower>(hal);
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/examples/HM-PBI-4-FM/HM-PBI-4-FM.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | // ci-test=yes board=328p aes=no
6 |
7 | // define this to read the device id, serial and device type from bootloader section
8 | // #define USE_OTA_BOOTLOADER
9 | #define EI_NOTEXTERNAL
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 | #include
16 |
17 | // we use a Pro Mini
18 | // Arduino pin for the LED
19 | // D4 == PIN 4 on Pro Mini
20 | #define LED_PIN 4
21 | #define LED_PIN2 5
22 | // Arduino pin for the config button
23 | // B0 == PIN 8 on Pro Mini
24 | #define CONFIG_BUTTON_PIN 8
25 | // Arduino pins for the buttons
26 | // A0,A1,A2,A3 == PIN 14,15,16,17 on Pro Mini
27 | #define BTN1_PIN 14
28 | #define BTN2_PIN 15
29 | #define BTN3_PIN 16
30 | #define BTN4_PIN 17
31 |
32 | // number of available peers per channel
33 | #define PEERS_PER_CHANNEL 10
34 |
35 | // all library classes are placed in the namespace 'as'
36 | using namespace as;
37 |
38 | // define all device properties
39 | const struct DeviceInfo PROGMEM devinfo = {
40 | {0x78,0x90,0x12}, // Device ID
41 | "JPPBI4FM01", // Device Serial
42 | {0x00,0x34}, // Device Model
43 | 0x01, // Firmware Version
44 | as::DeviceType::Remote, // Device Type
45 | {0x00,0x00} // Info Bytes
46 | };
47 |
48 | /**
49 | * Configure the used hardware
50 | */
51 | typedef AvrSPI<10, 11, 12, 13> SPIType;
52 | typedef Radio RadioType;
53 | typedef DualStatusLed LedType;
54 | typedef AskSin HalType;
55 | class Hal : public HalType {
56 | // extra clock to count button press events
57 | AlarmClock btncounter;
58 | public:
59 | void init (const HMID& id) {
60 | HalType::init(id);
61 | // get new battery value after 50 key press
62 | battery.init(50,btncounter);
63 | battery.low(22);
64 | battery.critical(19);
65 | }
66 |
67 | void sendPeer () {
68 | --btncounter;
69 | }
70 |
71 | bool runready () {
72 | return HalType::runready() || btncounter.runready();
73 | }
74 | };
75 |
76 | typedef RemoteChannel ChannelType;
77 | typedef MultiChannelDevice RemoteType;
78 |
79 | Hal hal;
80 | RemoteType sdev(devinfo,0x20);
81 | ConfigButton cfgBtn(sdev);
82 |
83 | void setup () {
84 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
85 | sdev.init(hal);
86 | remoteISR(sdev,1,BTN1_PIN);
87 | remoteISR(sdev,2,BTN2_PIN);
88 | remoteISR(sdev,3,BTN3_PIN);
89 | remoteISR(sdev,4,BTN4_PIN);
90 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
91 | sdev.initDone();
92 | }
93 |
94 | void loop() {
95 | bool worked = hal.runready();
96 | bool poll = sdev.pollRadio();
97 | if(worked == false && poll == false ) {
98 | hal.activity.savePower>(hal);
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/examples/HM-RC-2-PBU-FM/HM-RC-2-PBU-FM.ino:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin++
3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | // ci-test=yes board=328p aes=no
6 |
7 | // define this to read the device id, serial and device type from bootloader section
8 | // #define USE_OTA_BOOTLOADER
9 |
10 | #define EI_NOTEXTERNAL
11 | #include
12 | #include // after including SPI Library - we can use LibSPI class
13 | #include
14 | #include
15 |
16 | #include
17 | #include
18 |
19 |
20 | // we use a Pro Mini
21 | // Arduino pin for the LED
22 | // D4 == PIN 4 on Pro Mini
23 | #define LED_PIN 4
24 | #define LED_PIN2 5
25 | // Arduino pin for the config button
26 | // B0 == PIN 8 on Pro Mini
27 | #define CONFIG_BUTTON_PIN 8
28 | // Arduino pins for the buttons
29 | // A0,A1,A2,A3 == PIN 14,15,16,17 on Pro Mini
30 | #define BTN1_PIN 14
31 | #define BTN2_PIN 15
32 |
33 |
34 | // number of available peers per channel
35 | #define PEERS_PER_CHANNEL 10
36 |
37 | // all library classes are placed in the namespace 'as'
38 | using namespace as;
39 |
40 | // define all device properties
41 | const struct DeviceInfo PROGMEM devinfo = {
42 | {0x02,0xE0,0x01}, // Device ID
43 | "JPRC2FM001", // Device Serial
44 | {0x00,0xE0}, // Device Model
45 | 0x14, // Firmware Version
46 | as::DeviceType::Remote, // Device Type
47 | {0x00,0x00} // Info Bytes
48 | };
49 |
50 | /**
51 | * Configure the used hardware
52 | */
53 | typedef LibSPI<10> SPIType;
54 | typedef Radio RadioType;
55 | typedef DualStatusLed LedType;
56 | typedef AskSin HalType;
57 | class Hal : public HalType {
58 | // extra clock to count button press events
59 | AlarmClock btncounter;
60 | public:
61 | void init (const HMID& id) {
62 | HalType::init(id);
63 | // get new battery value after 50 key press
64 | battery.init(50,btncounter);
65 | battery.low(22);
66 | battery.critical(19);
67 | }
68 |
69 | void sendPeer () {
70 | --btncounter;
71 | }
72 |
73 | bool runready () {
74 | return HalType::runready() || btncounter.runready();
75 | }
76 | };
77 |
78 | typedef RemoteChannel ChannelType;
79 | typedef MultiChannelDevice RemoteType;
80 |
81 | Hal hal;
82 | RemoteType sdev(devinfo,0x20);
83 | ConfigButton cfgBtn(sdev);
84 |
85 | void setup () {
86 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
87 | sdev.init(hal);
88 | remoteISR(sdev,1,BTN1_PIN);
89 | remoteISR(sdev,2,BTN2_PIN);
90 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
91 | sdev.initDone();
92 | }
93 |
94 | void loop() {
95 | bool worked = hal.runready();
96 | bool poll = sdev.pollRadio();
97 | if( worked == false && poll == false ) {
98 | hal.activity.savePower