This repository has been archived by the owner on Apr 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
OXOcard.h
92 lines (80 loc) · 3.46 KB
/
OXOcard.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef _OXOCARD_H_
#define _OXOCARD_H_
/*******************************************************************************
* \file OXOcard.h
********************************************************************************
* \author Jascha Haldemann [email protected]
* \author Thomas Garaio [email protected]
* \date 01.02.2017
* \version 1.0
*
* \brief The OXOcard is a board to learn programming with Arduino
*
* \license LGPL-V2.1
* Copyright (c) 2017 OXON AG. All rights reserved.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see 'http://www.gnu.org/licenses/'
********************************************************************************
* OXOcard
*******************************************************************************/
/* ============================== Global imports ============================ */
#include <Arduino.h>
#include <avr/sleep.h>
#include <Wire.h>
#include <MMA7660FC.h>
#include <IS31FL3731.h>
#include <SoftwareSerial0.h>
#include <HM11_SoftwareSerial0.h>
#include "globals.h"
#include "pitches.h"
/* ==================== Global module constant declaration ================== */
// #define DEBUG_OXOCARD // define to activate Debug prints
#define DEBUG_BAUDRATE_OXOCARD 115200
#define DEFAULT_AUTO_TURN_OFF 120 // in seconds
#define BAUDRATE_BLE 9600 // in baud
#define BLE_NAME F("OXOcard")
#define BLE_DEFAULT_UUID F("4F584F63617264111111111111111111") // "OXOcard"
#define BLE_DEFAULT_MARJOR 4
/* ========================= Global macro declaration ======================= */
/* ============================ Class declaration =========================== */
class OXOcard
{
public:
/* Public member data */
MMA7660FC *accel;
IS31FL3731 *matrix;
SoftwareSerial0 *bleSerial;
HM11_SoftwareSerial0 *ble;
/* Constructor(s) and Destructor */
OXOcard() {};
~OXOcard() {};
/* Public member functions */
void begin();
void turnOff(bool leftButton = false, bool middleButton = false, bool rightButton = false);
void handleAutoTurnOff(uint16_t seconds = DEFAULT_AUTO_TURN_OFF, bool leftButton = false, bool middleButton = false, bool rightButton = false);
void resetAutoTurnOffCounter();
bool isLeftButtonPressed();
bool isMiddleButtonPressed();
bool isRightButtonPressed();
void setupAsIBeacon(String beaconName, HM11::advertInterval_t interv = HM11::INTERV_550MS);
void setupAsIBeacon(uint16_t beaconNr, HM11::advertInterval_t interv = HM11::INTERV_550MS);
int16_t findIBeacon(String beaconName);
int16_t findIBeacon(uint16_t beaconNr);
private:
/* Private member functions */
void initPins();
void disableUnusedCpuFunctions();
void initTimerIRQ(uint8_t timerNr, uint16_t prescaler, uint16_t divisor);
inline bool getLEDBlue() {return !getBit(PIN_LED_BLUE, LED_BLUE);}
/* Private class functions (static) */
static void iBeaconNameToIBeaconUUID(String beaconName, HM11::iBeaconData_t *iBeacon);
};
#endif