Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
genemars committed Feb 23, 2019
1 parent bdcf3be commit 0fb92f3
Show file tree
Hide file tree
Showing 43 changed files with 271 additions and 98 deletions.
31 changes: 28 additions & 3 deletions src/Config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
//
// Created by gene on 16/02/19.
//
/*
* HomeGenie-Mini (c) 2018-2019 G-Labs
*
*
* This file is part of HomeGenie-Mini (HGM).
*
* HomeGenie-Mini is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HomeGenie-Mini 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HomeGenie-Mini. If not, see <http://www.gnu.org/licenses/>.
*
*
* Authors:
* - Generoso Martello <[email protected]>
*
*
* Releases:
* - 2019-02-16 Initial release
*
*/

#ifndef HOMEGENIE_MINI_CONFIG_H
#define HOMEGENIE_MINI_CONFIG_H
Expand Down
7 changes: 3 additions & 4 deletions src/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
*
*
* Releases:
* - 2019-13-01 Initial release
* - 2019-01-13 Initial release
*
*/

#include "Task.h"
#include "TaskManager.h"
#include "io/Logger.h"
#include <Task.h>
#include <TaskManager.h>

Task::Task() {
creationTs = millis();
Expand Down
4 changes: 3 additions & 1 deletion src/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
*
* Releases:
* - 2019-13-01 Initial release
* - 2019-01-13 Initial release
*
*/

Expand All @@ -32,6 +32,8 @@

#include <Arduino.h>

#include <io/Logger.h>

// Task interface

class Task {
Expand Down
2 changes: 1 addition & 1 deletion src/TaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
*
* Releases:
* - 2019-13-01 Initial release
* - 2019-01-13 Initial release
*
*/

Expand Down
6 changes: 3 additions & 3 deletions src/TaskManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
*
*
* Releases:
* - 2019-13-01 Initial release
* - 2019-01-13 Initial release
*
*/

#ifndef HOMEGENIE_MINI_TASKMANAGER_H
#define HOMEGENIE_MINI_TASKMANAGER_H


#include "Task.h"
#include "io/Logger.h"
#include <Task.h>
#include <io/Logger.h>

#define TASKMANAGER_LOG_PREFIX "@ROOT::TaskManager"

Expand Down
32 changes: 28 additions & 4 deletions src/Utility.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
//
// Created by gene on 28/01/19.
//
/*
* HomeGenie-Mini (c) 2018-2019 G-Labs
*
*
* This file is part of HomeGenie-Mini (HGM).
*
* HomeGenie-Mini is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HomeGenie-Mini 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HomeGenie-Mini. If not, see <http://www.gnu.org/licenses/>.
*
*
* Authors:
* - Generoso Martello <[email protected]>
*
*
* Releases:
* - 2019-01-28 Initial release
*
*/

#include "Utility.h"

// TODO: move to an utility class (maybe static)
/// Convert byte to hex string taking care of leading-zero
/// \param b
void Utility::getBytes(const String &rawBytes, uint8_t *data) {
Expand Down
31 changes: 28 additions & 3 deletions src/Utility.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
//
// Created by gene on 28/01/19.
//
/*
* HomeGenie-Mini (c) 2018-2019 G-Labs
*
*
* This file is part of HomeGenie-Mini (HGM).
*
* HomeGenie-Mini is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HomeGenie-Mini 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HomeGenie-Mini. If not, see <http://www.gnu.org/licenses/>.
*
*
* Authors:
* - Generoso Martello <[email protected]>
*
*
* Releases:
* - 2019-01-28 Initial release
*
*/

#ifndef HOMEGENIE_MINI_UTILITY_H
#define HOMEGENIE_MINI_UTILITY_H
Expand Down
3 changes: 1 addition & 2 deletions src/io/IOManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
*
*/

#include "IOManager.h"
#include "IOEventPaths.h"
#include <io/IOManager.h>

namespace IO {

Expand Down
18 changes: 7 additions & 11 deletions src/io/IOManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,23 @@
#define HOMEGENIE_MINI_IOMANAGER_H

#include <Arduino.h>
#include <io/sys/Diagnostics.h>

#include "Logger.h"

#include <service/api/APIRequest.h>

#include <io/IOEvent.h>
#include <io/IOEventDomains.h>
#include <io/rf/x10/RFReceiver.h>
#include <io/rf/x10/RFTransmitter.h>
#include <io/rf/x10/X10Message.h>
#include <io/IOEventPaths.h>
#include <io/env/DS18B20.h>
#include <io/env/LightSensor.h>
#include <io/gpio/P1Port.h>
#include <io/rf/x10/RFReceiver.h>
#include <io/rf/x10/RFTransmitter.h>
#include <io/rf/x10/X10Message.h>
#include <io/sys/Diagnostics.h>
#include <service/api/APIRequest.h>

#define IOMANAGER_LOG_PREFIX "@IO::IOManager"

#define CONFIG_RF_TX_PIN D2 // 4
#define CONFIG_RF_RX_PIN D1 // 5
#define CONFIG_RF_TX_PIN D2 // 4

namespace IO {

Expand Down Expand Up @@ -80,7 +78,6 @@ namespace IO {
System::Diagnostics *systemDiagnostics;
//class X10ApiHandler;
IIOEventReceiver *ioEventCallback;
String byteToHex(byte b);
// Instantiate the X10 RFReceiver Class
RFReceiverConfig *x10ReceiverConfig;
RFReceiver *x10Receiver;
Expand All @@ -97,5 +94,4 @@ namespace IO {

}


#endif //HOMEGENIE_MINI_IOMANAGER_H
1 change: 1 addition & 0 deletions src/io/IOModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define HOMEGENIE_MINI_IOMODULE_H

#include <Arduino.h>

#include <net/NetManager.h>

namespace IO {
Expand Down
3 changes: 2 additions & 1 deletion src/io/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
*
*/

#include <net/NetManager.h>
#include "Logger.h"

#include <net/NetManager.h>

namespace IO {

static int logLevel;
Expand Down
2 changes: 1 addition & 1 deletion src/io/env/DS18B20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
*
* Releases:
* - 2019-12-01 Initial release
* - 2019-01-12 Initial release
*
*/

Expand Down
2 changes: 1 addition & 1 deletion src/io/env/DS18B20.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
*
* Releases:
* - 2019-12-01 Initial release
* - 2019-01-12 Initial release
*
*/

Expand Down
2 changes: 1 addition & 1 deletion src/io/env/LightSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
*
* Releases:
* - 2019-12-01 Initial release
* - 2019-01-12 Initial release
*
*/

Expand Down
2 changes: 1 addition & 1 deletion src/io/env/LightSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
*
* Releases:
* - 2019-12-01 Initial release
* - 2019-01-12 Initial release
*
*/

Expand Down
31 changes: 28 additions & 3 deletions src/io/gpio/P1Port.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
//
// Created by gene on 03/02/19.
//
/*
* HomeGenie-Mini (c) 2018-2019 G-Labs
*
*
* This file is part of HomeGenie-Mini (HGM).
*
* HomeGenie-Mini is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HomeGenie-Mini 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HomeGenie-Mini. If not, see <http://www.gnu.org/licenses/>.
*
*
* Authors:
* - Generoso Martello <[email protected]>
*
*
* Releases:
* - 2019-02-03 Initial release
*
*/

#include "P1Port.h"

Expand Down
31 changes: 28 additions & 3 deletions src/io/gpio/P1Port.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
//
// Created by gene on 03/02/19.
//
/*
* HomeGenie-Mini (c) 2018-2019 G-Labs
*
*
* This file is part of HomeGenie-Mini (HGM).
*
* HomeGenie-Mini is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HomeGenie-Mini 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HomeGenie-Mini. If not, see <http://www.gnu.org/licenses/>.
*
*
* Authors:
* - Generoso Martello <[email protected]>
*
*
* Releases:
* - 2019-02-03 Initial release
*
*/

#ifndef HOMEGENIE_MINI_P1PORT_H
#define HOMEGENIE_MINI_P1PORT_H
Expand Down
9 changes: 3 additions & 6 deletions src/io/rf/x10/RFReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
*
*/

#include <service/defs.h>
#include <Config.h>
#include "RFReceiver.h"

namespace IO { namespace X10 {
Expand Down Expand Up @@ -65,10 +63,9 @@ namespace IO { namespace X10 {
}

void RFReceiver::receive() {
//if (!isEnabled()) return;

uint32_t lengthUs = micros() - riseUs;
riseUs = micros();
uint32_t currentTs = micros();
uint32_t lengthUs = currentTs - riseUs;
riseUs = currentTs;

if (lengthUs >= configuration->getStartBustRepeat() && lengthUs <= configuration->getStartBustMax()) {
receiveBuffer = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/io/rf/x10/RFReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@

#include "Arduino.h"

#include <Config.h>
#include <Utility.h>
#include <io/Logger.h>
#include <io/IOEvent.h>
#include <io/IOEventPaths.h>
#include <io/IOEventDomains.h>
#include <Utility.h>
#include <service/defs.h>

#include "RFReceiverConfig.h"

Expand Down
Loading

0 comments on commit 0fb92f3

Please sign in to comment.