32 Commits
Author SHA1 Message Date
Jurica 005466b4a1 Small fixes 2019-04-03 16:41:21 +02:00
Jurica a0ecd4a5c6 Doxy changes 2019-04-03 15:32:18 +02:00
Jurica b189fe7c2d Merge branch 'menuStatesDoxy' 2019-04-03 12:14:29 +02:00
Jurica 556df3a0b9 Small changes in make 2019-04-03 12:02:25 +02:00
Dominik Kotarski 54509ab5f0 Cosmetic changes 2019-04-03 09:15:53 +02:00
Dominik Kotarski e0340f436e Minor cosmetic changes 2019-04-02 09:38:46 +02:00
Dominik Kotarski aa346a065d Config standardisation 2019-04-02 09:17:14 +02:00
Dominik Kotarski a01ae82cb2 aconnoTasks standardisation 2019-04-02 09:05:40 +02:00
Dominik Kotarski 00ae5d55e8 Doxygen on main 2019-04-02 08:45:38 +02:00
Dominik Kotarski 39cfac95f8 Doxygen WIP 2019-04-01 16:16:14 +02:00
Dominik Kotarski 9371a70e6a Renaming and refactoring 2019-04-01 16:10:15 +02:00
Dominik Kotarski 87b727efb0 menuStates renamed into states and moved into a separate directory 2019-04-01 15:26:01 +02:00
Dominik Kotarski 9a079840fb IOEXP_INT_SOURCE TO INT_SOURCE and menuStates doxygen 2019-04-01 15:15:00 +02:00
Dominik Kotarski 8e36e238a0 WIP menuStatesDoxy 2019-03-28 10:27:25 +01:00
odri@aconno.de a4d93aeb91 Adding comments for DoxyGen 2019-03-28 09:21:56 +01:00
Jurica Rešetar 128d9c54ce Merge branch 'epdWriteFix' into 'master'
Epd write fix

See merge request ACD52832_MasterExample/ACD52832_MasterExampleFW!21
2019-03-26 13:30:28 +01:00
Odri Tomas b49b33579e Removed unwanted NRF_LOG 2019-03-26 13:29:31 +01:00
Dominik Kotarski 7e7382f7cd Latest hex 2019-03-26 12:55:04 +01:00
Dominik Kotarski d520adcde6 Submodule update 2019-03-26 12:53:52 +01:00
Dominik Kotarski 5799593dfb Fixed parallel epd write bug 2019-03-26 12:53:11 +01:00
Odri Tomas e758428c53 Submodule update and fix for joystick 2019-03-22 14:21:22 +01:00
Odri Tomas eff5ba5ad5 Interrupt fix 2019-03-22 13:41:22 +01:00
Odri Tomas 93fe5f5b14 Temp flag 2019-03-21 13:57:23 +01:00
Jurica Rešetar 7ec6eaebc6 Merge branch 'servoIssue' into 'master'
Servo issue #12

See merge request ACD52832_MasterExample/ACD52832_MasterExampleFW!20
2019-03-21 12:50:58 +01:00
Odri Tomas a0fccd2c56 deleted commented 2019-03-21 12:46:11 +01:00
Odri Tomas 7e0198b6cf Servo issue
Enable and disable pwm  before write
2019-03-21 12:44:33 +01:00
Jurica Rešetar 20b955696e Merge branch 'issueFix' into 'master'
Issue #13 & #14

See merge request ACD52832_MasterExample/ACD52832_MasterExampleFW!19
2019-03-21 11:00:13 +01:00
odri@aconno.de 4f3fe6428a Issue #13 & #14 2019-03-21 10:52:21 +01:00
Jurica Rešetar 815643255d Merge branch 'bugFix2' into 'master'
Fixed tardy joystick bug

See merge request ACD52832_MasterExample/ACD52832_MasterExampleFW!18
2019-03-21 09:31:44 +01:00
Dominik Kotarski 4582bdf1eb Fixed tardy joystick bug 2019-03-21 08:19:13 +01:00
Jurica b9c9417c19 Submodules updated 2019-03-20 17:24:18 +01:00
Jurica 3e67ff2e61 Temp lib updated 2019-03-20 16:39:58 +01:00
31 changed files with 17649 additions and 31533 deletions
+1
View File
@@ -4,3 +4,4 @@ build/_build/*
.directory*
.DS_Store
cscope.out
Docs
+16 -18
View File
@@ -9,6 +9,8 @@
*
*/
//------------------------------ INCLUDES -------------------------------------
#include "aconnoHelpers.h"
#include "sdk_config.h"
#include "app_error.h"
@@ -21,7 +23,11 @@
#include "MCP23017.h"
#include "acd52832Bsp.h"
//-------------------------------- MACROS -------------------------------------
//----------------------------- DATA TYPES ------------------------------------
//--------------------- PRIVATE FUNCTION PROTOTYPES ---------------------------
//----------------------- STATIC DATA & CONSTANTS -----------------------------
//------------------------------ GLOBAL DATA ----------------------------------
extern bool getInterruptSourceFlag;
extern AconnoI2C i2c;
extern AconnoGPIO ledRed;
@@ -29,10 +35,9 @@ extern AconnoGPIO ledBlue;
extern AconnoGPIO ledGreen;
extern MCP23017 expdr;
extern AconnoGPIO ld1;
/**@brief Function for the Timer initialization.
*
* @details Initializes the timer module. This creates and starts application timers.
*/
//--------------------- PUBLIC FUNCTIONS AND OBJECTS --------------------------
void timersInit(void)
{
// Initialize timer module.
@@ -40,20 +45,15 @@ void timersInit(void)
APP_ERROR_CHECK(err_code);
}
/**@brief Function for starting application timers.
* @details Timers are run after the scheduler has started.
*/
void applicationTimerStart(void)
{
}
/**@brief Clear bond information /*/
void deleteBonds(void)
{
NRF_LOG_INFO("Erase bonds!");
}
/**@brief Function for initializing the nrf log module. */
void logInit(void)
{
ret_code_t err_code = NRF_LOG_INIT(NULL);
@@ -62,8 +62,6 @@ void logInit(void)
NRF_LOG_DEFAULT_BACKENDS_INIT();
}
/**@brief Function for initializing the clock.
*/
void clockInit(void)
{
ret_code_t err_code = nrf_drv_clock_init();
@@ -117,7 +115,7 @@ BaseType_t xTaskCreateOrResume(TaskFunction_t pvTaskCode,
void logState(TaskHandle_t xCreatedTask)
{
eTaskState taskState =eTaskGetState( xCreatedTask );
eTaskState taskState = eTaskGetState(xCreatedTask);
switch (taskState)
{
case eRunning:
@@ -146,7 +144,7 @@ void initIoExpander(MCP23017 *expdr)
expdr->reset();
expdr->config(0x01F8, 0xFFFF, 0x0000);
for(uint8_t x=3; x<10; x++) // Init values on Expander pins
for(uint8_t x = 3; x < 10; x++) // Init values on Expander pins
{
expdr->writeGPIOBit(1, x);
}
@@ -157,15 +155,15 @@ void initIoExpander(MCP23017 *expdr)
uint8_t checkState(MCP23017 *expdr, AconnoGPIO *sw1)
{
uint8_t result = 0x00; // 0: pressed, 1: released
#define _(x) result |= (expdr->readGPIOBit(IOEXP_INT_SOURCE:: JOY_##x) << x##_BIT)
#define _(x) result |= (expdr->readGPIOBit(INT_SOURCE:: JOY_##x) << x##_BIT)
_(UP);
_(DOWN);
_(LEFT);
_(RIGHT);
_(CENTER);
#undef _
result |= (expdr->readGPIOBit(IOEXP_INT_SOURCE:: SW2) << SW2_BIT);
result |= ((uint8_t)sw1->read() << SW1_BIT);
result |= (expdr->readGPIOBit(INT_SOURCE::SW2) << SW2_BIT);
result |= ((uint8_t) sw1->read() << SW1_BIT);
result ^= 0xff;
return result;
@@ -195,4 +193,4 @@ void bspInit()
ledBlue.set();
ledGreen.set();
ld1.set();
}
}
+56 -37
View File
@@ -11,19 +11,19 @@
#ifndef __ACONNO_HELPERS_H__
#define __ACONNO_HELPERS_H__
//------------------------------ INCLUDES -------------------------------------
#include <stdint.h>
#include "FreeRTOS.h"
#include "task.h"
#include "MCP23017.h"
#include "aconnoConfig.h"
#include "timers.h"
//----------------------------- DATA TYPES ------------------------------------
/**
* @brief Enumeration for the interrupt source pressed
*
*/
enum IOEXP_INT_SOURCE : uint8_t
enum INT_SOURCE : uint8_t
{
NOTHING = 0,
JOY_UP = 6,
@@ -37,6 +37,37 @@ enum IOEXP_INT_SOURCE : uint8_t
REL2 = 10
};
/**
* @brief BLE Beacon advertisement packet
*
*/
struct __attribute__((packed, aligned(1))) advertisementPacket_t
{
uint8_t size = sizeof(advertisementPacket_t)-1;
uint8_t msdID = MSD_ID;
uint16_t nordicUUID = NORDIC_UUID;
uint8_t aconnoUUID = ACONNO_UUID;;
uint8_t productID = PRODUCT_ID;
uint8_t settingsFlag : 1, versionNumber : 7;
int8_t advType = FIRST_ADV_TYPE_ID;
union
{
struct __attribute__((packed, aligned(4)))
{
int16_t gyroscope[3];
int16_t accelerometer[3];
int16_t magnetometer[3];
};
struct __attribute__((packed, aligned(4)))
{
float temp;
float light;
uint8_t joy;
uint8_t pot;
};
};
};
//-------------------------- CONSTANTS & MACROS -------------------------------
/**
* @defgroup GROUP_BIT
* @brief IoExpander gpio input read bit position
@@ -50,11 +81,33 @@ enum IOEXP_INT_SOURCE : uint8_t
#define SW2_BIT (1)
#define SW1_BIT (0)
/** @} */
//----------------------------PUBLIC PROTOTYPES -------------------------------
/**
* @brief Function for the Timer initialization.
* @details Initializes the timer module. This creates and starts application timers.
*/
void timersInit(void);
/**
* @brief Function for starting application timers.
* @details Timers are run after the scheduler has started.
*/
void applicationTimerStart(void);
/**
* @brief Clear bond information
*/
void deleteBonds(void);
/**
* @brief Function for initializing the nrf log module.
*/
void logInit(void);
/**
* @brief Function for initializing the clock.
*/
void clockInit(void);
/**
@@ -89,37 +142,6 @@ void initIoExpander(MCP23017 *expdr);
*/
uint8_t checkState(MCP23017 *expdr, AconnoGPIO *sw1);
/**
* @brief BLE Beacon advertisement packet
*
*/
struct __attribute__((packed, aligned(1))) advertisementPacket_t
{
uint8_t size = sizeof(advertisementPacket_t)-1;
uint8_t msdID = MSD_ID;
uint16_t nordicUUID = NORDIC_UUID;
uint8_t aconnoUUID = ACONNO_UUID;;
uint8_t productID = PRODUCT_ID;
uint8_t settingsFlag : 1, versionNumber : 7;
int8_t advType = FIRST_ADV_TYPE_ID;
union
{
struct __attribute__((packed, aligned(4)))
{
int16_t gyroscope[3];
int16_t accelerometer[3];
int16_t magnetometer[3];
};
struct __attribute__((packed, aligned(4)))
{
float temp;
float light;
uint8_t joy;
uint8_t pot;
};
};
};
/**
* @brief Timer callback to set the flag which prevents too many interrupt
* events from ioexpander from occuring
@@ -134,7 +156,4 @@ void intFlagTimerCallback(TimerHandle_t xTimer);
*/
void bspInit();
#endif // __ACONNO_HELPERS_H__
-361
View File
@@ -1,361 +0,0 @@
/**
* @file menuStates.h
* @author Dominik Kotarski (d.kotarski@aconno.de)
* @brief
* @version 0.1
* @date 2019-02-18
*
* @copyright Copyright (c) 2019
*
*/
#ifndef __MENU_STATES_H__
#define __MENU_STATES_H__
#include "FreeRTOS.h"
#include "task.h"
#include "aconnoHelpers.h"
#include "aconnoTasks.h"
/**
* @brief Abstract state.
*
*/
class State
{
public:
enum class EPD_WRITE_METHOD
{
FULL,
PARTIAL
};
State();
State(EPD_WRITE_METHOD writeMethod);
virtual ~State();
/**
* @brief Function to handle an interrupt (a button press) in a context
* of the current state
*
* @param intSource Id of the interrupt that occured,
* see IOEXP_INT_SOURCE
* @return State* Returns the next state object (can be itself if the
* state is not supposed to change)
*/
virtual State *handleEvent(IOEXP_INT_SOURCE intSource) = 0;
/**
* @brief Function which handles displaying the state on epd.
*
* This function can also be used to start a task, which will then
* handle drawing on the epd. However, user should take care of
* suspending the mentioned task while exiting the state.
*/
virtual void displayOnEpd() = 0;
/**
* @brief Function to perform epd.write() or epd.fullWrite()
* depending on the writeMethod variable which is given in
* constructor
*
* @see writeMethod
*
* @return uint8_t
*/
uint8_t writeToEpd();
private:
EPD_WRITE_METHOD _writeMethod;
};
class UnimplementedState : public State
{
public:
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class Intro1State : public State
{
public:
Intro1State(EPD_WRITE_METHOD writeMethod);
Intro1State();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class Intro2State : public State
{
public:
Intro2State(EPD_WRITE_METHOD writeMethod);
Intro2State();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class Intro3State : public State
{
public:
Intro3State(EPD_WRITE_METHOD writeMethod);
Intro3State();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class JoystickMenuState : public State
{
public:
JoystickMenuState(EPD_WRITE_METHOD writeMethod);
JoystickMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class JoystickExampleState : public State
{
public:
JoystickExampleState(EPD_WRITE_METHOD writeMethod);
JoystickExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class SoundMenuState : public State
{
public:
SoundMenuState(EPD_WRITE_METHOD writeMethod);
SoundMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class SoundExampleState : public State
{
public:
SoundExampleState(EPD_WRITE_METHOD writeMethod);
SoundExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class RgbLedMenuState : public State
{
public:
RgbLedMenuState(EPD_WRITE_METHOD writeMethod);
RgbLedMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class RgbLedExampleState : public State
{
public:
RgbLedExampleState(EPD_WRITE_METHOD writeMethod);
RgbLedExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class ServoMenuState : public State
{
public:
ServoMenuState(EPD_WRITE_METHOD writeMethod);
ServoMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class ServoExampleState : public State
{
public:
ServoExampleState(EPD_WRITE_METHOD writeMethod);
ServoExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class ServoInstructionState : public State
{
public:
ServoInstructionState(EPD_WRITE_METHOD writeMethod);
ServoInstructionState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class LdrMenuState : public State
{
public:
LdrMenuState(EPD_WRITE_METHOD writeMethod);
LdrMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class LdrExampleState : public State
{
public:
LdrExampleState(EPD_WRITE_METHOD writeMethod);
LdrExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class PotentiometerMenuState : public State
{
public:
PotentiometerMenuState(EPD_WRITE_METHOD writeMethod);
PotentiometerMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class PotentiometerExampleState : public State
{
public:
PotentiometerExampleState(EPD_WRITE_METHOD writeMethod);
PotentiometerExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class TempProbeMenuState : public State
{
public:
TempProbeMenuState(EPD_WRITE_METHOD writeMethod);
TempProbeMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class TempProbeExampleState : public State
{
public:
TempProbeExampleState(EPD_WRITE_METHOD writeMethod);
TempProbeExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class RelayMenuState : public State
{
public:
RelayMenuState(EPD_WRITE_METHOD writeMethod);
RelayMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class RelayExampleState : public State
{
public:
RelayExampleState(EPD_WRITE_METHOD writeMethod);
RelayExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class LedMenuState : public State
{
public:
LedMenuState(EPD_WRITE_METHOD writeMethod);
LedMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class LedExampleState : public State
{
public:
LedExampleState(EPD_WRITE_METHOD writeMethod);
LedExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class InfraredMenuState : public State
{
public:
InfraredMenuState(EPD_WRITE_METHOD writeMethod);
InfraredMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class InfraredExampleState : public State
{
public:
InfraredExampleState(EPD_WRITE_METHOD writeMethod);
InfraredExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class GyroMenuState : public State
{
public:
GyroMenuState(EPD_WRITE_METHOD writeMethod);
GyroMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class GyroExampleState : public State
{
public:
GyroExampleState(EPD_WRITE_METHOD writeMethod);
GyroExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class BleMenuState : public State
{
public:
BleMenuState(EPD_WRITE_METHOD writeMethod);
BleMenuState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
class BleExampleState : public State
{
public:
BleExampleState(EPD_WRITE_METHOD writeMethod);
BleExampleState();
State *handleEvent(IOEXP_INT_SOURCE intSource);
void displayOnEpd();
};
#endif //__MENU_STATES_H__
+151 -1
View File
@@ -1,3 +1,19 @@
/**
* @file pictures.h
* @author Odri Tomas (odri@aconno.de)
* @brief
* @version 0.1
* @date 2019-03-27
*
* @copyright Copyright (c) 2019
*/
//----------------------------- DATA TYPES ------------------------------------
//-------------------------- CONSTANTS & MACROS -------------------------------
/**
* @brief Intro 1 image data
*
*/
const unsigned char intro1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -201,6 +217,10 @@ const unsigned char intro1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for introduction EPD image 2
*
*/
const unsigned char intro2[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -404,6 +424,10 @@ const unsigned char intro2[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for introduction EPD image 3
*
*/
const unsigned char intro3[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -607,6 +631,10 @@ const unsigned char intro3[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for joystick menu EPD image
*
*/
const unsigned char joystick0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -810,6 +838,10 @@ const unsigned char joystick0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for sound menu EPD image
*
*/
const unsigned char sound0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -1013,6 +1045,10 @@ const unsigned char sound0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for RGB Led menu EPD image
*
*/
const unsigned char rgb0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -1216,6 +1252,10 @@ const unsigned char rgb0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for servo menu EPD image
*
*/
const unsigned char servo0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -1419,6 +1459,10 @@ const unsigned char servo0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for LDR menu image
*
*/
const unsigned char ldr0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -1622,6 +1666,10 @@ const unsigned char ldr0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for potentiometer menu image
*
*/
const unsigned char pot0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -1825,6 +1873,10 @@ const unsigned char pot0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for temperature menu image
*
*/
const unsigned char temp0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -2028,6 +2080,10 @@ const unsigned char temp0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for relay menu image
*
*/
const unsigned char relay0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -2231,6 +2287,10 @@ const unsigned char relay0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for LED menu image
*
*/
const unsigned char led0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -2434,6 +2494,10 @@ const unsigned char led0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for Infrared LED menu image
*
*/
const unsigned char ir0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -2637,6 +2701,10 @@ const unsigned char ir0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for gyroscope menu image
*
*/
const unsigned char gyro0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -2840,6 +2908,10 @@ const unsigned char gyro0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for compass image
*
*/
const unsigned char compass0[] = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80
,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0
@@ -3043,6 +3115,10 @@ const unsigned char compass0[] = {
,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
/**
* @brief Data for joystick task image
*
*/
const unsigned char joystick1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -3246,6 +3322,10 @@ const unsigned char joystick1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for sound task image
*
*/
const unsigned char sound1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -3449,6 +3529,10 @@ const unsigned char sound1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for RGB task image
*
*/
const unsigned char rgb1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -3652,6 +3736,10 @@ const unsigned char rgb1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data with servo instructions image
*
*/
const unsigned char servo1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -3855,6 +3943,10 @@ const unsigned char servo1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for servo task image
*
*/
const unsigned char servo2[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -4058,6 +4150,10 @@ const unsigned char servo2[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for LDR task
*
*/
const unsigned char ldr1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -4261,6 +4357,10 @@ const unsigned char ldr1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for potentiometer task image
*
*/
const unsigned char pot1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -4464,6 +4564,10 @@ const unsigned char pot1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for potentiometer clockwise spin
*
*/
const unsigned char potCW[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -4667,6 +4771,10 @@ const unsigned char potCW[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for counter clockwise potentiometer spin
*
*/
const unsigned char potCCW[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -4870,6 +4978,10 @@ const unsigned char potCCW[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for temperature task image
*
*/
const unsigned char temp1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -5073,6 +5185,10 @@ const unsigned char temp1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for relay task image
*
*/
const unsigned char relay1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -5276,6 +5392,10 @@ const unsigned char relay1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for LED task image
*
*/
const unsigned char led1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -5479,6 +5599,10 @@ const unsigned char led1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for infrared task image
*
*/
const unsigned char ir1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -5682,6 +5806,10 @@ const unsigned char ir1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for gyroscope task image
*
*/
const unsigned char gyro1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -5885,6 +6013,11 @@ const unsigned char gyro1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for compass task
* @note Currently not used
*
*/
const unsigned char compass1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -6088,6 +6221,10 @@ const unsigned char compass1[] = {
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for BLE advertisement menu image
*
*/
const unsigned char BleBeacon[]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
@@ -6291,6 +6428,10 @@ const unsigned char BleBeacon[]={
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for BLE task image
*
*/
const unsigned char BleBeaconInMeni[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -6494,6 +6635,10 @@ const unsigned char BleBeaconInMeni[]={
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for BLE EPD image menu
*
*/
const unsigned char BleImgEPD[]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
@@ -6697,6 +6842,10 @@ const unsigned char BleImgEPD[]={
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**
* @brief Data for BLE Image EPD task image
*
*/
const unsigned char BleImgEPDInMeni[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
@@ -6898,4 +7047,5 @@ const unsigned char BleImgEPDInMeni[]={
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
};
//----------------------------PUBLIC PROTOTYPES -------------------------------
+44 -40
View File
@@ -5,48 +5,42 @@ OUTPUT_DIRECTORY := _build
SDK_ROOT := ../../nRF5_SDK_15.2.0
PROJ_DIR := ../
# edit toolchain path
# GNU_INSTALL_ROOT ?= /usr/local/gcc_arm/gcc-arm-none-eabi-8-2018-q4-major/bin/
# GNU_VERSION ?= 8.2.1
# GNU_PREFIX ?= arm-none-eabi
$(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \
LINKER_SCRIPT := ble_app_hrs_freertos_gcc_nrf52.ld
PROJ_SRC += \
$(PROJ_DIR)/source/main.cpp \
$(PROJ_DIR)/aconnoHelpers/aconnoHelpers.cpp \
$(PROJ_DIR)/tasks/aconnoTasks.cpp \
$(PROJ_DIR)/aconnoBLE/aconnoBLE.cpp \
$(PROJ_DIR)/aconnoBLE/aconnoGAP.cpp \
$(PROJ_DIR)/aconnoBLE/aconnoGATT.cpp \
$(PROJ_DIR)/aconnoBLE/aconnoBLEChar.cpp \
$(PROJ_DIR)/aconnoBLE/aconnoBLEService.cpp \
$(PROJ_DIR)/libs/aconnoGPIO/aconnoGPIO.cpp \
PROJ_SRC += \
$(PROJ_DIR)/source/main.cpp \
$(PROJ_DIR)/aconnoHelpers/aconnoHelpers.cpp \
$(PROJ_DIR)/tasks/aconnoTasks.cpp \
$(PROJ_DIR)/aconnoBLE/aconnoBLE.cpp \
$(PROJ_DIR)/aconnoBLE/aconnoGAP.cpp \
$(PROJ_DIR)/aconnoBLE/aconnoGATT.cpp \
$(PROJ_DIR)/aconnoBLE/aconnoBLEChar.cpp \
$(PROJ_DIR)/aconnoBLE/aconnoBLEService.cpp \
$(PROJ_DIR)/aconnoBLE/advPayload.cpp \
$(PROJ_DIR)/libs/aconnoGPIO/aconnoGPIO.cpp \
$(PROJ_DIR)/libs/aconnoNordicPAL/aconnoNordicPAL.cpp \
$(PROJ_DIR)/aconnoHelpers/menuStates.cpp \
$(PROJ_DIR)/libs/aconnoI2C/aconnoI2C.cpp \
$(PROJ_DIR)/libs/aconnoSPI/aconnoSPI.cpp \
$(PROJ_DIR)/libs/aconnoPWM/aconnoPWM.cpp \
$(PROJ_DIR)/libs/GDEP015OC1/GDEP015OC1.cpp \
$(PROJ_DIR)/libs/MCP23017/MCP23017.cpp \
$(PROJ_DIR)/libs/LDR/LDR.cpp \
$(PROJ_DIR)/libs/potentiometer/potentiometer.cpp \
$(PROJ_DIR)/libs/MCP9700/MCP9700.cpp \
$(PROJ_DIR)/libs/aconnoSensor/aconnoSensor.cpp \
$(PROJ_DIR)/libs/aconnoSAADC/aconnoSAADC.cpp \
$(PROJ_DIR)/libs/LSM9DS1/LSM9DS1.cpp \
$(PROJ_DIR)/libs/servo/servo.cpp \
$(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_twi.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_twi.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_twim.c \
$(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_spi.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_spi.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_spim.c \
$(PROJ_DIR)/libs/aconnoBeeper/aconnoBeeper.cpp \
$(PROJ_DIR)/libs/aconnoPWM/aconnoPWM.cpp \
$(PROJ_DIR)/states/states.cpp \
$(PROJ_DIR)/libs/aconnoI2C/aconnoI2C.cpp \
$(PROJ_DIR)/libs/aconnoSPI/aconnoSPI.cpp \
$(PROJ_DIR)/libs/aconnoPWM/aconnoPWM.cpp \
$(PROJ_DIR)/libs/GDEP015OC1/GDEP015OC1.cpp \
$(PROJ_DIR)/libs/MCP23017/MCP23017.cpp \
$(PROJ_DIR)/libs/LDR/LDR.cpp \
$(PROJ_DIR)/libs/potentiometer/potentiometer.cpp \
$(PROJ_DIR)/libs/MCP9700/MCP9700.cpp \
$(PROJ_DIR)/libs/aconnoSensor/aconnoSensor.cpp \
$(PROJ_DIR)/libs/aconnoSAADC/aconnoSAADC.cpp \
$(PROJ_DIR)/libs/LSM9DS1/LSM9DS1.cpp \
$(PROJ_DIR)/libs/servo/servo.cpp \
$(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_twi.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_twi.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_twim.c \
$(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_spi.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_spi.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_spim.c \
$(PROJ_DIR)/libs/aconnoBeeper/aconnoBeeper.cpp \
$(PROJ_DIR)/libs/aconnoPWM/aconnoPWM.cpp \
PROJ_INC += \
@@ -56,6 +50,7 @@ PROJ_INC += \
$(PROJ_DIR)/aconnoHelpers/ \
$(PROJ_DIR)/tasks/ \
$(PROJ_DIR)/aconnoBLE/ \
$(PROJ_DIR)/states/ \
$(PROJ_DIR)/libs/aconnoI2C \
$(PROJ_DIR)/libs/aconnoSPI \
$(PROJ_DIR)/libs/aconnoPWM \
@@ -70,9 +65,7 @@ PROJ_INC += \
$(PROJ_DIR)/libs/servo/ \
$(PROJ_DIR)/libs/aconnoBeeper \
$(PROJ_DIR)/libs/aconnoPWM \
#$(PROJ_DIR)/BLE/nordicBLE/ \
# Source files common to all targets
SRC_FILES += \
$(PROJ_SRC) \
@@ -400,6 +393,17 @@ flash: default
nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex --sectorerase
nrfjprog -f nrf52 --reset
# Merge the program and softdevice
merge_soft:
@echo Merging: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex and s132_nrf52_6.1.0_softdevice.hex
mergehex -m $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_6.1.0_softdevice.hex $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex -o $(OUTPUT_DIRECTORY)/nrf52832_xxaa_and_soft.hex
# Flash the program and softdevice
flash_merged:
@echo Flashing: $(OUTPUT_DIRECTORY)/nrf52832_xxaa_and_soft.hex
nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/nrf52832_xxaa_and_soft.hex --sectorerase
nrfjprog -f nrf52 --reset
# Flash softdevice
flash_softdevice:
@echo Flashing: s132_nrf52_6.1.0_softdevice.hex
+15583 -30506
View File
File diff suppressed because it is too large Load Diff
+66 -73
View File
@@ -8,7 +8,9 @@
* @copyright Copyright (c) 2019
*
*/
#ifndef __ACD_52832_BSP_H__
#define __ACD_52832_BSP_H__
//------------------------------ INCLUDES -------------------------------------
/** Communication headers */
#include "aconnoSPI.h"
#include "aconnoI2C.h"
@@ -27,75 +29,71 @@
/** Ambient temperature header */
#include "MCP9700.h"
/** Menu states header */
#include "menuStates.h"
#include "states.h"
/** iNEMO inertial module header*/
#include "LSM9DS1.h"
/** Servo header */
#include "servo.h"
/**
* @defgroup PIN_GROUP
* @note General IO pins
* @{
*/
#define PIN_BUTTON (25) /**< SW1 gpio number (Active low) */
#define PIN_LED (26) /**< LD1 gpio number (Active low) */
#define PIN_IRLED (27) /**< LD4 gpio number (Active high) */
#define PIN_BUZZER (31) /**< LS1 gpio number (Active high) */
#define PIN_LED_RED (22) /**< Module red LED */
#define PIN_LED_BLUE (23) /**< Module blue LED */
#define PIN_LED_GREEN (24) /**< Module green LED */
//----------------------------- DATA TYPES ------------------------------------
//-------------------------- CONSTANTS & MACROS -------------------------------
/**< SW1 gpio number (Active low) */
#define PIN_BUTTON (25)
/**< LD1 gpio number (Active low) */
#define PIN_LED (26)
/**< LD4 gpio number (Active high) */
#define PIN_IRLED (27)
/**< LS1 gpio number (Active high) */
#define PIN_BUZZER (31)
/**< Module red LED */
#define PIN_LED_RED (22)
/**< Module blue LED */
#define PIN_LED_BLUE (23)
/**< Module green LED */
#define PIN_LED_GREEN (24)
/** Alternate General IO pins */
#define PIN_SERVO1 (25) /**< Servo1 gpio number */
#define PIN_SERVO2 (26) /**< Servo2 gpio number */
/** @} */
/**< Servo1 gpio number */
#define PIN_SERVO1 (25)
/**< Servo2 gpio number */
#define PIN_SERVO2 (26)
/**
* @defgroup ADC_GROUP
* @note Analog to Digital Conversion (ADC) pins
* @{
*/
#define ADC_BAT (2) /**< Battery */
#define ADC_POT (5) /**< Potentiometer */
#define ADC_LIGHT (6) /**< Light Dependant Resistor */
#define ADC_TEMP (7) /**< Temperature Dependant Resistor */
/** @} */
/**< Battery */
#define ADC_BAT (2)
/**< Potentiometer */
#define ADC_POT (5)
/**< Light Dependant Resistor */
#define ADC_LIGHT (6)
/**< Temperature Dependant Resistor */
#define ADC_TEMP (7)
/**
* @defgroup PIN_EPD_GROUP
* @note Electronic Paper Display (EPD) pins
* @{
*/
#define PIN_EPD_CS (5) /**< EPD Chip select pin (Active low) */
#define PIN_EPD_DC (6) /**< EPD Data/Command pin (Data active high) */
#define PIN_EPD_RST (7) /**< EPD Reset pin (Active low) */
#define PIN_EPD_BUSY (8) /**< EPD Busy pin (Active low) */
#define PIN_EPD_SCK (4) /**< EPD SCK pin */
#define PIN_EPD_MOSI (3) /**< EPD MOSI pin */
#define PIN_EPD_MISO (0xFF) /**< EPD MISO pin not used */
/** @} */
/**< EPD Chip select pin (Active low) */
#define PIN_EPD_CS (5)
/**< EPD Data/Command pin (Data active high) */
#define PIN_EPD_DC (6)
/**< EPD Reset pin (Active low) */
#define PIN_EPD_RST (7)
/**< EPD Busy pin (Active low) */
#define PIN_EPD_BUSY (8)
/**< EPD SCK pin */
#define PIN_EPD_SCK (4)
/**< EPD MOSI pin */
#define PIN_EPD_MOSI (3)
/**< EPD MISO pin not used */
#define PIN_EPD_MISO (0xFF)
/**
* @defgroup PIN_EXP_GROUP
* @note IO Expander pins
* @{
*/
#define PIN_EXP_RST (19) /**< IO Expander reset pin */
#define EXPDR_A_INT (11) /**< IO Expander */
#define PIN_EXP_INT_A (11) /**< IO Expander interrupt for PORTA */
#define PIN_EXP_INT_B (12) /**< IO Expander interrupt for PORTB */
#define PIN_EXP_SDA (20) /**< TWI SCK pin */
#define PIN_EXP_SCL (21) /**< TWI SCL pin */
/** @} */
/**< IO Expander reset pin */
#define PIN_EXP_RST (19)
/**< IO Expander */
#define EXPDR_A_INT (11)
/**< IO Expander interrupt for PORTA */
#define PIN_EXP_INT_A (11)
/**< IO Expander interrupt for PORTB */
#define PIN_EXP_INT_B (12)
/**< TWI SCK pin */
#define PIN_EXP_SDA (20)
/**< TWI SCL pin */
#define PIN_EXP_SCL (21)
/**
* @defgroup MCP23017_GROUP
* @brief GPIO Pin configuration on IO Expander
* @{
*/
#define MCP23017_CENTER (7)
#define MCP23017_LEFT (5)
#define MCP23017_RIGHT (3)
@@ -105,17 +103,12 @@
#define MCP23017_LED2 (9)
#define MCP23017_REL1 (11)
#define MCP23017_REL2 (10)
/** @} */
/**
* @defgroup TWI_GROUP
* @note Pins concerning TWI Addresses
* Control bits are added by nrf_drv_twi
* @{
*/
#define TWI_EXPANDER_ADDR (0x40) /**< Port expander address */
#define TWI_AG_ADDR (0x6A << 1) /**< Accelerometer/Gyroscope address */
#define TWI_MAG_ADDR (0x1C << 1) /**< Magnetometer address */
/** @} */
/**< Port expander address */
#define TWI_EXPANDER_ADDR (0x40)
/**< Accelerometer/Gyroscope address */
#define TWI_AG_ADDR (0x6A << 1)
/**< Magnetometer address */
#define TWI_MAG_ADDR (0x1C << 1)
//----------------------------PUBLIC PROTOTYPES -------------------------------
#endif // __ACD_52832_BSP_H__
+14 -12
View File
@@ -8,10 +8,12 @@
* @copyright Copyright (c) 2019
*
*/
#ifndef __ACONNO_CONFIG_H__
#define __ACONNO_CONFIG_H__
//------------------------------ INCLUDES -------------------------------------
//----------------------------- DATA TYPES ------------------------------------
//-------------------------- CONSTANTS & MACROS -------------------------------
/**< BLE advertisement packet information */
#define MSD_ID (0xFF)
#define NORDIC_UUID (0x0059)
#define ACONNO_UUID (0x69)
@@ -19,14 +21,10 @@
#define SETTINGS_SUPPORT_FLAG (0b0)
#define PRODUCT_VERSION (0x00)
#define FIRST_ADV_TYPE_ID (0x00)
/**< Application's BLE observer priority. You shouldn't need to modify this value. */
#define APP_BLE_OBSERVER_PRIO 3
/**< A tag identifying the SoftDevice BLE configuration. */
#define APP_BLE_CONN_CFG_TAG 1
/**< The advertising interval (in units of 0.625 ms). */
#define APP_ADV_INTERVAL 100
/**< The advertising duration in units of 10 milliseconds. */
@@ -35,7 +33,6 @@
#define BLE_EX_CHAR_UUID (0xA000)
/**< BLE example characteristic size in B. */
#define BLE_EX_CHAR_SIZE_B (500)
/**< Time from initiating event (connect or start of notification)
* to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define FIRST_CONN_PARAMS_UPDATE_DELAY 5000
@@ -44,7 +41,6 @@
#define NEXT_CONN_PARAMS_UPDATE_DELAY 30000
/**< Number of attempts before giving up the connection parameter negotiation.*/
#define MAX_CONN_PARAMS_UPDATE_COUNT 3
/**< Perform bonding. */
#define SEC_PARAM_BOND 1
/**< Man In The Middle protection not required. */
@@ -61,15 +57,21 @@
#define SEC_PARAM_MIN_KEY_SIZE 7
/**< Maximum encryption key size. */
#define SEC_PARAM_MAX_KEY_SIZE 16
/**< Value used as error code on stack dump, can be used to identify
* stack location on stack unwind. */
#define DEAD_BEEF 0xDEADBEEF
/**< BLE Beacon packet information */
#define APPLICATION_ID (0xCF170059)
#define FIRST_PACKET_ID (0x00)
#define SECOND_PACKET_ID (0x01)
#define MAX_ADV_PACKET_LENGTH (31)
#endif // __ACONNO_CONFIG_H__
/**< Stack depth for freeRtos tasks in words, not bytes*/
#define TASK_STACK_DEPTH(A) (A)
/**< Task priority for freeRtos tasks, higher number means higher priority */
#define TASK_PRIORITY(A) (A)
/**< Default parametres to a freertos task */
#define DEFAULT_TASK_PARAMETERS NULL
/**< Pwm instance id. Instance number should be supported by PAL */
#define PWM_INSTANCE_ID(A) (A)
//----------------------------PUBLIC PROTOTYPES -------------------------------
#endif // __ACONNO_CONFIG_H__
+5 -5
View File
@@ -11,9 +11,9 @@
#ifndef __ACONNO_PAL_CONFIG_H__
#define __ACONNO_PAL_CONFIG_H__
//------------------------------ INCLUDES -------------------------------------
#include "aconnoNordicPAL.h"
#endif // __ACONNO_PAL_CONFIG_H__
//----------------------------- DATA TYPES ------------------------------------
//-------------------------- CONSTANTS & MACROS -------------------------------
//----------------------------PUBLIC PROTOTYPES -------------------------------
#endif // __ACONNO_PAL_CONFIG_H__
Submodule libs/KDT00030 updated: 281ec099b7...a704e9598b
-10
View File
@@ -1,10 +0,0 @@
/**
* @file aconnoLog.cpp
* @author Jurica Resetar (Jurica@aconno.de)
* @brief
* @version 0.1
* @date 2019-01-22
*
* @copyright Copyright (c) 2019
*
*/
-17
View File
@@ -1,17 +0,0 @@
/**
* @file aconnoLog.h
* @author Jurica Resetar (Jurica@aconno.de)
* @brief
* @version 0.1
* @date 2019-01-22
*
* @copyright Copyright (c) 2019
*
*/
#ifndef __ACONNO_LOG_H__
#define __ACONNO_LOG_H__
#endif // __ACONNO_LOG_H__
Submodule libs/aconnoPWM updated: 9b6bd8c468...5023863a50
Submodule libs/aconnoSAADC updated: d2ddb76505...1bda1716fa
Submodule libs/aconnoSensor updated: 571db82eb8...f3259fa9dc
+250 -87
View File
@@ -8,7 +8,7 @@
* @copyright Copyright (c) 2019
*
*/
//------------------------------ INCLUDES -------------------------------------
#include <stdint.h>
#include <string.h>
@@ -29,109 +29,196 @@
#include "aconnoBLE.h"
#include "aconnoTasks.h"
#include "aconnoBeeper.h"
//-------------------------------- MACROS -------------------------------------
//----------------------------- DATA TYPES ------------------------------------
//--------------------- PRIVATE FUNCTION PROTOTYPES ---------------------------
//----------------------- STATIC DATA & CONSTANTS -----------------------------
//------------------------------ GLOBAL DATA ----------------------------------
/**
* @brief loger task handler
*
*/
TaskHandle_t initTask;
/**
* @brief State Machine menu task handler
*
*/
TaskHandle_t menuStateMachineTask;
/**
* @brief LDR example task
*
* @brief LDR example task handler
*/
TaskHandle_t LDRTask;
TaskHandle_t ldrTask;
/**
* @brief Joystick example task
*
* @brief Joystick example task handler
*/
TaskHandle_t joystickExampleTask;
TaskHandle_t joyTask;
/**
* @brief rgbLedExampleTask
*
* @brief Rgb led example task handler
*/
TaskHandle_t rgbLedExampleTask;
TaskHandle_t rgbTask;
/**
* @brief Handle of a task taking care of reading ioexpander over i2c in
* order to dertermine a source of the interrupt
*
* @brief Interrupt source pooler task
*/
TaskHandle_t getInterruptSourceTask;
/**
* @brief Sound example task
*
* @brief Sound example task handler
*/
TaskHandle_t soundExampleTask;
TaskHandle_t soundTask;
/**
* @brief Potentiometer example task handler
*/
TaskHandle_t potTask;
/**
* @brief Temperature example task handler
*/
TaskHandle_t tempTask;
/**
* @brief Gyroscope example task handler
*/
TaskHandle_t gyroTask;
/**
* @brief Ble beacon example task handler
*/
TaskHandle_t bleTask;
/**
* @brief Ble image example task handler
*/
TaskHandle_t bleImageTask;
/**
* @brief Infrared example task handler
*/
TaskHandle_t irTask;
/**
* @brief LEDs example task handler
*/
TaskHandle_t ledsTask;
/**
* @brief Relay example task handler
*/
TaskHandle_t relayTask;
/**
* @brief Servomotor example task handler
*/
TaskHandle_t servoTask;
#if NRF_LOG_ENABLED
extern TaskHandle_t mLoggerThread;
#endif
TaskHandle_t potTask;
TaskHandle_t tempTask;
TaskHandle_t gyroTask;
TaskHandle_t bleTask;
TaskHandle_t bleImageTask;
TaskHandle_t irTask;
TaskHandle_t ledsTask;
TaskHandle_t relayTask;
TaskHandle_t servoTask;
/**
* @brief Semaphore to control the interrupt source task
*/
SemaphoreHandle_t getInterruptSourceSemaphore;
/**
* @brief A queue which buffers interrupt events
*/
QueueHandle_t interruptSourceQueue;
/**
* @brief secondary interrupt Source queue. To be used by examples that
* require interrupts
*/
QueueHandle_t interruptSourceQueueSecondary;
TimerHandle_t intFlagTimer;
/**
* @brief Mutex to protect writing on the e-paper display
*/
SemaphoreHandle_t epdWriteMutex;
/**
* @brief Object defining current state of the Master Example
*/
State *pMenuState;
/**
* @brief AconnoI2C instance which is used for i2c communication
*/
AconnoI2C i2c(PIN_EXP_SDA, PIN_EXP_SCL);
/**
* @brief AconnoSPI instance which is used for SPI communication
*/
AconnoSPI spi(PIN_EPD_MISO, PIN_EPD_MOSI, PIN_EPD_SCK);
AconnoSAADC adc;
AconnoGPIO ledRed(PIN_LED_RED, GPIO_DIR::GPIO_OUTPUT);
AconnoGPIO ledBlue(PIN_LED_BLUE, GPIO_DIR::GPIO_OUTPUT);
AconnoGPIO ledGreen(PIN_LED_GREEN, GPIO_DIR::GPIO_OUTPUT);
AconnoGPIO irLed(PIN_IRLED, GPIO_DIR::GPIO_OUTPUT);
AconnoGPIO sw1(PIN_BUTTON, GPIO_DIR::GPIO_INPUT);
AconnoGPIO ld1(PIN_LED, GPIO_DIR::GPIO_OUTPUT);
/**
* @brief E-paper display driver class instance
*/
GDEP015OC1 epd(spi, PIN_EPD_CS, PIN_EPD_DC, PIN_EPD_RST, PIN_EPD_BUSY);
MCP23017 expdr(i2c, TWI_EXPANDER_ADDR, EXPDR_A_INT, GPIO_DIR::GPIO_INTERRUPT,
GPIO_PULL::OFF, GPIO_EDGE::FALLING, interruptCallback);
/**
* @brief IO-expander driver class instance. Ioexpander is connected
* to the joystick, button2 and relays
*/
MCP23017 expdr(i2c,
TWI_EXPANDER_ADDR,
EXPDR_A_INT,
GPIO_DIR::GPIO_INTERRUPT,
GPIO_PULL::OFF,
GPIO_EDGE::FALLING,
interruptCallback);
/**
* @brief Gyro, acceleration and magnetometer sensor driver class instance
*/
LSM9DS1 mems(i2c);
/**
* @brief Successive approximation adc instance. Used by sensors whose
* analog outputs are connected directly to the chip
*/
AconnoSAADC adc;
/**
* @brief Light dependent resisor driver class instance
*/
LDR light(adc, ADC_LIGHT);
/**
* @brief Potentiometer driver class instance
*/
Potentiometer pot(adc, ADC_POT);
/**
* @brief Temperature sensor driver class instance
*/
MCP9700 ambientTemperature(adc, ADC_TEMP);
Servo servo(PIN_SERVO2, 2);
AconnoBeeper beeper(1, PIN_BUZZER);
// Must be global
/**
* @brief Servo driver class instance
*/
Servo servo(PIN_SERVO2, PWM_INSTANCE_ID(2));
/**
* @brief Beeper helper class instance
*/
AconnoBeeper beeper(PWM_INSTANCE_ID(1), PIN_BUZZER);
/**
* @brief GPIO driver class for the red led
*/
AconnoGPIO ledRed(PIN_LED_RED, GPIO_DIR::GPIO_OUTPUT);
/**
* @brief GPIO driver class for the blue led
*/
AconnoGPIO ledBlue(PIN_LED_BLUE, GPIO_DIR::GPIO_OUTPUT);
/**
* @brief GPIO driver class for the green led
*/
AconnoGPIO ledGreen(PIN_LED_GREEN, GPIO_DIR::GPIO_OUTPUT);
/**
* @brief GPIO driver class for the Infrared led
*/
AconnoGPIO irLed(PIN_IRLED, GPIO_DIR::GPIO_OUTPUT);
/**
* @brief GPIO driver class for button1
*/
AconnoGPIO sw1(PIN_BUTTON, GPIO_DIR::GPIO_INPUT);
/**
* @brief GPIO driver class for led1
*/
AconnoGPIO ld1(PIN_LED, GPIO_DIR::GPIO_OUTPUT);
/**
* @brief Aconno BLE service class instance.
*/
AconnoBLEService myService;
/**
* @brief Aconno BLE characteristic class instance
*/
AconnoBLEChar myChar;
//--------------------- PUBLIC FUNCTIONS AND OBJECTS --------------------------
/**
* @brief Function called at bluetooth disconnect event
*/
void disconnectionCallback(void)
{
// Nothing
NRF_LOG_INFO("APP disconnection callback.");
AconnoBLE &myBLE = *getAconnoBLEInstance();
myBLE.startAdvertising(APP_ADV_INTERVAL, APP_ADV_DURATION);
}
/** @brief Function for application main entry.
/**
* @brief Function for application main entry.
*/
int main(void)
{
@@ -157,51 +244,126 @@ int main(void)
{
NRF_LOG_ERROR("ERROR, not enough space available to create semaphore!");
}
epdWriteMutex = xSemaphoreCreateMutex();
// Create all tasks that will be used
// getInterruptSource task needs higher priority to ensure prompt interrupt
// handling
xTaskCreate(getInterruptSourceFunction, "GetInterruptSourceTask", 256, NULL,
2, &getInterruptSourceTask);
xTaskCreate(menuStateMachineTaskFunction, "MenuStateMachine", 256, NULL, 1,
xTaskCreate(getInterruptSourceFunction,
"GetInterruptSourceTask",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(2),
&getInterruptSourceTask);
xTaskCreate(menuStateMachineTaskFunction,
"MenuStateMachine",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&menuStateMachineTask);
xTaskCreate(ldrFunction, "LDR", 256, NULL, 1, &LDRTask);
xTaskCreate(potentiometerFunction, "POT", 256, NULL, 1, &potTask);
xTaskCreate(temperatureFunction, "TEMP", 256, NULL, 1, &tempTask);
xTaskCreate(gyroFunction, "GYRO", 256, NULL, 1, &gyroTask);
xTaskCreate(bleBeaconFunction, "BEACON", 256, NULL, 1, &bleTask);
xTaskCreate(infraredFunction, "INFRARED", 256, NULL, 1, &irTask);
xTaskCreate(ledsFunction, "LEDS", 256, NULL, 1, &ledsTask);
xTaskCreate(relayFunction, "RELAYS", 256, NULL, 1, &relayTask);
xTaskCreate(joystickTaskFunction, "JoystickTask", 256, NULL, 1,
&joystickExampleTask);
xTaskCreate(rgbLedTaskFunction, "rgbTask", 256, NULL, 1, &rgbLedExampleTask);
xTaskCreate(servoFunction, "SERVO", 256, NULL, 1, &servoTask);
xTaskCreate(soundFunction, "SoundTask", 256, NULL, 1, &soundExampleTask);
xTaskCreate(ldrFunction,
"LDR",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&ldrTask);
// Todo: Consider creating a static instead queue via xQueueCreateStatic()
xTaskCreate(potentiometerFunction,
"POT",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&potTask);
xTaskCreate(temperatureFunction,
"TEMP",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&tempTask);
xTaskCreate(gyroFunction,
"GYRO",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&gyroTask);
xTaskCreate(bleBeaconFunction,
"BEACON",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&bleTask);
xTaskCreate(infraredFunction,
"INFRARED",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&irTask);
xTaskCreate(ledsFunction,
"LEDS",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&ledsTask);
xTaskCreate(relayFunction,
"RELAYS",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&relayTask);
xTaskCreate(joyFunction,
"JOYSTICK",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&joyTask);
xTaskCreate(rgbFunction,
"RGB",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&rgbTask);
xTaskCreate(servoFunction,
"SERVO",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&servoTask);
xTaskCreate(soundFunction,
"SOUND",
TASK_STACK_DEPTH(256),
DEFAULT_TASK_PARAMETERS,
TASK_PRIORITY(1),
&soundTask);
// Create the queues which will be used
interruptSourceQueue = xQueueCreate(QUEUE_DEFAULT_SIZE,
sizeof(IOEXP_INT_SOURCE));
sizeof(INT_SOURCE));
interruptSourceQueueSecondary = xQueueCreate(QUEUE_DEFAULT_SIZE,
sizeof(IOEXP_INT_SOURCE));
sizeof(INT_SOURCE));
if(interruptSourceQueue == NULL ||interruptSourceQueueSecondary == NULL)
{
NRF_LOG_ERROR("ERROR, not enough space available to create queues!");
}
// TODO: This part of the code still needs to be done!
// Note by Jurica
//intFlagTimer = xTimerCreate("IoexpanderInterruptTimer",
// IOEXP_INTERRUPT_TIMER_PERIOD,
// pdFALSE, // do not loop infinitely
// (void *) 0, // timer id
// intFlagTimerCallback); //timer callback
// Initialize state machine
pMenuState = new Intro1State(State::EPD_WRITE_METHOD::FULL);
pMenuState->displayOnEpd();
// Activate deep sleep mode.
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
@@ -271,3 +433,4 @@ extern "C"
}
}
#endif
//--------------------------- INTERRUPT HANDLERS ------------------------------
+258 -142
View File
@@ -1,5 +1,5 @@
/**
* @file menuStates.cpp
* @file states.cpp
* @author Dominik Kotarski (d.kotarski@aconno.de)
* @brief
* @version 0.1
@@ -8,13 +8,17 @@
* @copyright Copyright (c) 2019
*
*/
#include "menuStates.h"
#include "aconnoHelpers.h"
//------------------------------ INCLUDES -------------------------------------
#include "states.h"
#include "GDEP015OC1.h"
#include "aconnoBeeper.h"
extern TaskHandle_t LDRTask;
#include "semphr.h"
//-------------------------------- MACROS -------------------------------------
//----------------------------- DATA TYPES ------------------------------------
//--------------------- PRIVATE FUNCTION PROTOTYPES ---------------------------
//----------------------- STATIC DATA & CONSTANTS -----------------------------
//------------------------------ GLOBAL DATA ----------------------------------
extern TaskHandle_t ldrTask;
extern TaskHandle_t potTask;
extern TaskHandle_t tempTask;
extern TaskHandle_t gyroTask;
@@ -22,9 +26,9 @@ extern TaskHandle_t bleTask;
extern TaskHandle_t irTask;
extern TaskHandle_t ledsTask;
extern TaskHandle_t relayTask;
extern TaskHandle_t joystickExampleTask;
extern TaskHandle_t soundExampleTask;
extern TaskHandle_t rgbLedExampleTask;
extern TaskHandle_t joyTask;
extern TaskHandle_t soundTask;
extern TaskHandle_t rgbTask;
extern TaskHandle_t servoTask;
extern AconnoGPIO irLed;
@@ -32,30 +36,43 @@ extern AconnoGPIO ld1;
extern MCP23017 expdr;
extern GDEP015OC1 epd;
extern Servo servo;
extern AconnoGPIO ledRed;
extern AconnoGPIO ledGreen;
extern AconnoGPIO ledBlue;
extern QueueHandle_t interruptSourceQueueSecondary;
extern AconnoBeeper beeper;
uint8_t irFlag;
uint8_t joyFlag;
extern QueueHandle_t interruptSourceQueueSecondary;
extern SemaphoreHandle_t epdWriteMutex;
/**
* @brief A flag for initializing infrared task if reentered
*/
uint8_t gIrFlag;
/**
* @brief A flag to help with initial drawing of the joystick example
*/
uint8_t gJoyFlag;
/**
* @brief A flag for initializing LDR task if reentered
*/
uint8_t gLdrFlag;
/**
* @brief A flag for initializing temperature task if reentered
*/
uint8_t gTempFlag;
/**
* @brief
*/
bool gBleTaskSuspend = false;
//--------------------- PUBLIC FUNCTIONS AND OBJECTS --------------------------
State::State()
{
_writeMethod = EPD_WRITE_METHOD::PARTIAL;
}
State::State(EPD_WRITE_METHOD writeMethod)
{
_writeMethod = writeMethod;
}
uint8_t State::writeToEpd()
{
if(_writeMethod == EPD_WRITE_METHOD::PARTIAL)
@@ -66,28 +83,20 @@ uint8_t State::writeToEpd()
{
epd.writeFull();
}
return true;
}
State::~State(){}
State *UnimplementedState::handleEvent(IOEXP_INT_SOURCE intSource)
{
return new Intro1State();
}
void UnimplementedState::displayOnEpd()
{
epd.empty();
epd.writeString("UNIMPLEMENTED", 60, 100, COLOR_BLACK);
writeToEpd();
}
Intro1State::Intro1State(){}
Intro1State::Intro1State(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *Intro1State::handleEvent(IOEXP_INT_SOURCE intSource)
State *Intro1State::handleEvent(INT_SOURCE intSource)
{
return new Intro2State();
}
void Intro1State::displayOnEpd()
{
epd.drawImage(intro1);
@@ -95,11 +104,14 @@ void Intro1State::displayOnEpd()
}
Intro2State::Intro2State(){}
Intro2State::Intro2State(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *Intro2State::handleEvent(IOEXP_INT_SOURCE intSource)
State *Intro2State::handleEvent(INT_SOURCE intSource)
{
return new Intro3State();
}
void Intro2State::displayOnEpd()
{
epd.drawImage(intro2);
@@ -107,11 +119,14 @@ void Intro2State::displayOnEpd()
}
Intro3State::Intro3State(){}
Intro3State::Intro3State(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *Intro3State::handleEvent(IOEXP_INT_SOURCE intSource)
State *Intro3State::handleEvent(INT_SOURCE intSource)
{
return new JoystickMenuState();
}
void Intro3State::displayOnEpd()
{
epd.drawImage(intro3);
@@ -119,23 +134,26 @@ void Intro3State::displayOnEpd()
}
JoystickMenuState::JoystickMenuState(){}
JoystickMenuState::JoystickMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *JoystickMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
JoystickMenuState::JoystickMenuState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *JoystickMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new BleMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new SoundMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new JoystickExampleState();
break;
@@ -148,6 +166,7 @@ State *JoystickMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void JoystickMenuState::displayOnEpd()
{
epd.drawImage(joystick0);
@@ -155,15 +174,18 @@ void JoystickMenuState::displayOnEpd()
}
JoystickExampleState::JoystickExampleState(){}
JoystickExampleState::JoystickExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State* JoystickExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
JoystickExampleState::JoystickExampleState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State* JoystickExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch (intSource)
{
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
vTaskSuspend(joystickExampleTask);
vTaskSuspend(joyTask);
returnStatep = new JoystickMenuState(EPD_WRITE_METHOD::FULL);
break;
}
@@ -175,35 +197,39 @@ State* JoystickExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void JoystickExampleState::displayOnEpd()
{
IOEXP_INT_SOURCE helperSendSecondary = IOEXP_INT_SOURCE::JOY_CENTER;
INT_SOURCE helperSendSecondary = INT_SOURCE::JOY_CENTER;
xQueueReset(interruptSourceQueueSecondary);
xQueueSendToBack(interruptSourceQueueSecondary,
(void *) &helperSendSecondary,
((TickType_t)10) != pdPASS);
joyFlag = 1;
vTaskResume(joystickExampleTask);
gJoyFlag = 1;
vTaskResume(joyTask);
}
SoundMenuState::SoundMenuState(){}
SoundMenuState::SoundMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State* SoundMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
SoundMenuState::SoundMenuState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State* SoundMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new JoystickMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new RgbLedMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new SoundExampleState();
break;
@@ -216,6 +242,7 @@ State* SoundMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void SoundMenuState::displayOnEpd()
{
epd.drawImage(sound0);
@@ -223,15 +250,18 @@ void SoundMenuState::displayOnEpd()
}
SoundExampleState::SoundExampleState(){}
SoundExampleState::SoundExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *SoundExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
SoundExampleState::SoundExampleState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *SoundExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
vTaskSuspend(soundExampleTask);
vTaskSuspend(soundTask);
beeper.nobeep();
beeper.resetRttl();
returnStatep = new SoundMenuState(EPD_WRITE_METHOD::FULL);
@@ -245,31 +275,35 @@ State *SoundExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void SoundExampleState::displayOnEpd()
{
epd.drawImage(sound1);
writeToEpd();
vTaskResume(soundExampleTask);
vTaskResume(soundTask);
}
RgbLedMenuState::RgbLedMenuState(){}
RgbLedMenuState::RgbLedMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *RgbLedMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
RgbLedMenuState::RgbLedMenuState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *RgbLedMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new SoundMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new ServoMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new RgbLedExampleState();
break;
@@ -282,6 +316,7 @@ State *RgbLedMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void RgbLedMenuState::displayOnEpd()
{
epd.drawImage(rgb0);
@@ -289,15 +324,18 @@ void RgbLedMenuState::displayOnEpd()
}
RgbLedExampleState::RgbLedExampleState(){}
RgbLedExampleState::RgbLedExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *RgbLedExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
RgbLedExampleState::RgbLedExampleState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *RgbLedExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
vTaskSuspend(rgbLedExampleTask);
vTaskSuspend(rgbTask);
returnStatep = new RgbLedMenuState(EPD_WRITE_METHOD::FULL);
ledRed.set();
ledGreen.set();
@@ -312,31 +350,34 @@ State *RgbLedExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void RgbLedExampleState::displayOnEpd()
{
epd.drawImage(rgb1);
writeToEpd();
vTaskResume(rgbLedExampleTask);
vTaskResume(rgbTask);
}
ServoMenuState::ServoMenuState(){}
ServoMenuState::ServoMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *ServoMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
ServoMenuState::ServoMenuState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *ServoMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new RgbLedMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new LdrMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new ServoInstructionState();
break;
@@ -349,6 +390,7 @@ State *ServoMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void ServoMenuState::displayOnEpd()
{
epd.drawImage(servo0);
@@ -356,15 +398,17 @@ void ServoMenuState::displayOnEpd()
}
ServoInstructionState::ServoInstructionState(){}
ServoInstructionState::ServoInstructionState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *ServoInstructionState::handleEvent(IOEXP_INT_SOURCE intSource)
ServoInstructionState::ServoInstructionState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *ServoInstructionState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
if(intSource == IOEXP_INT_SOURCE::JOY_CENTER)
if(intSource == INT_SOURCE::JOY_CENTER)
{
vTaskSuspend(servoTask);
servo.write(0.5f);
returnStatep = new ServoExampleState();
}
else
@@ -373,6 +417,7 @@ State *ServoInstructionState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void ServoInstructionState::displayOnEpd()
{
epd.drawImage(servo1);
@@ -380,15 +425,21 @@ void ServoInstructionState::displayOnEpd()
}
ServoExampleState::ServoExampleState(){}
ServoExampleState::ServoExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *ServoExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
ServoExampleState::ServoExampleState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *ServoExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
if(intSource == IOEXP_INT_SOURCE::JOY_CENTER)
if(intSource == INT_SOURCE::JOY_CENTER)
{
vTaskSuspend(servoTask);
servo.enable();
servo.write(0.5f);
waitMs(150);
servo.disable();
returnStatep = new ServoMenuState(EPD_WRITE_METHOD::FULL);
}
@@ -398,6 +449,7 @@ State *ServoExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void ServoExampleState::displayOnEpd()
{
epd.drawImage(servo2);
@@ -406,25 +458,27 @@ void ServoExampleState::displayOnEpd()
}
LdrMenuState::LdrMenuState(){}
LdrMenuState::LdrMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *LdrMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
State *LdrMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new ServoMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new PotentiometerMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new LdrExampleState();
break;
@@ -438,6 +492,7 @@ State *LdrMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void LdrMenuState::displayOnEpd()
{
epd.drawImage(ldr0);
@@ -445,18 +500,22 @@ void LdrMenuState::displayOnEpd()
}
LdrExampleState::LdrExampleState(){}
LdrExampleState::LdrExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State* LdrExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
LdrExampleState::LdrExampleState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State* LdrExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
if(intSource == IOEXP_INT_SOURCE::JOY_CENTER)
if(intSource == INT_SOURCE::JOY_CENTER)
{
vTaskSuspend(LDRTask);
vTaskSuspend(ldrTask);
gLdrFlag = 1;
returnStatep = new LdrMenuState(EPD_WRITE_METHOD::FULL);
}
else
{
//vTaskSuspend(LDRTask);
//vTaskSuspend(ldrTask);
returnStatep = new LdrExampleState();
}
return returnStatep;
@@ -466,27 +525,30 @@ void LdrExampleState::displayOnEpd()
{
epd.drawImage(ldr1);
writeToEpd();
vTaskResume(LDRTask);
vTaskResume(ldrTask);
}
PotentiometerMenuState::PotentiometerMenuState(){}
PotentiometerMenuState::PotentiometerMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *PotentiometerMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
PotentiometerMenuState::PotentiometerMenuState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *PotentiometerMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new LdrMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new TempProbeMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new PotentiometerExampleState();
break;
@@ -499,6 +561,7 @@ State *PotentiometerMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void PotentiometerMenuState::displayOnEpd()
{
epd.drawImage(pot0);
@@ -506,11 +569,15 @@ void PotentiometerMenuState::displayOnEpd()
}
PotentiometerExampleState::PotentiometerExampleState(){}
PotentiometerExampleState::PotentiometerExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *PotentiometerExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
PotentiometerExampleState::PotentiometerExampleState(
EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *PotentiometerExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
if(intSource == IOEXP_INT_SOURCE::JOY_CENTER)
if(intSource == INT_SOURCE::JOY_CENTER)
{
vTaskSuspend(potTask);
returnStatep = new PotentiometerMenuState(EPD_WRITE_METHOD::FULL);
@@ -521,6 +588,7 @@ State *PotentiometerExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void PotentiometerExampleState::displayOnEpd()
{
epd.drawImage(pot1);
@@ -529,23 +597,26 @@ void PotentiometerExampleState::displayOnEpd()
}
TempProbeMenuState::TempProbeMenuState(){}
TempProbeMenuState::TempProbeMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *TempProbeMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
TempProbeMenuState::TempProbeMenuState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *TempProbeMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new PotentiometerMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new RelayMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new TempProbeExampleState();
break;
@@ -558,6 +629,7 @@ State *TempProbeMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void TempProbeMenuState::displayOnEpd()
{
epd.drawImage(temp0);
@@ -565,13 +637,17 @@ void TempProbeMenuState::displayOnEpd()
}
TempProbeExampleState::TempProbeExampleState(){}
TempProbeExampleState::TempProbeExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *TempProbeExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
TempProbeExampleState::TempProbeExampleState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *TempProbeExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
if(intSource == IOEXP_INT_SOURCE::JOY_CENTER)
if(intSource == INT_SOURCE::JOY_CENTER)
{
vTaskSuspend(tempTask);
gTempFlag = 1;
returnStatep = new TempProbeMenuState(EPD_WRITE_METHOD::FULL);
}
else
@@ -580,6 +656,7 @@ State *TempProbeExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void TempProbeExampleState::displayOnEpd()
{
epd.drawImage(temp1);
@@ -588,23 +665,26 @@ void TempProbeExampleState::displayOnEpd()
}
RelayMenuState::RelayMenuState(){}
RelayMenuState::RelayMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *RelayMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
RelayMenuState::RelayMenuState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *RelayMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new TempProbeMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new LedMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new RelayExampleState();
break;
@@ -617,6 +697,7 @@ State *RelayMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void RelayMenuState::displayOnEpd()
{
epd.drawImage(relay0);
@@ -624,12 +705,15 @@ void RelayMenuState::displayOnEpd()
}
RelayExampleState::RelayExampleState(){}
RelayExampleState::RelayExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *RelayExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
RelayExampleState::RelayExampleState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *RelayExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
if(intSource == IOEXP_INT_SOURCE::JOY_CENTER)
if(intSource == INT_SOURCE::JOY_CENTER)
{
vTaskSuspend(relayTask);
//turn relay off
@@ -643,6 +727,7 @@ State *RelayExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void RelayExampleState::displayOnEpd()
{
epd.drawImage(relay1);
@@ -651,23 +736,25 @@ void RelayExampleState::displayOnEpd()
}
LedMenuState::LedMenuState(){}
LedMenuState::LedMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *LedMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
State *LedMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new RelayMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new InfraredMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new LedExampleState();
break;
@@ -680,6 +767,7 @@ State *LedMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void LedMenuState::displayOnEpd()
{
epd.drawImage(led0);
@@ -687,12 +775,15 @@ void LedMenuState::displayOnEpd()
}
LedExampleState::LedExampleState(){}
LedExampleState::LedExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *LedExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
LedExampleState::LedExampleState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *LedExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
if(intSource == IOEXP_INT_SOURCE::JOY_CENTER)
if(intSource == INT_SOURCE::JOY_CENTER)
{
vTaskSuspend(ledsTask);
//turn off leds
@@ -707,6 +798,7 @@ State *LedExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void LedExampleState::displayOnEpd()
{
epd.drawImage(led1);
@@ -715,23 +807,26 @@ void LedExampleState::displayOnEpd()
}
InfraredMenuState::InfraredMenuState(){}
InfraredMenuState::InfraredMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *InfraredMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
InfraredMenuState::InfraredMenuState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *InfraredMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new LedMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new GyroMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new InfraredExampleState();
break;
@@ -744,6 +839,7 @@ State *InfraredMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void InfraredMenuState::displayOnEpd()
{
epd.drawImage(ir0);
@@ -751,15 +847,18 @@ void InfraredMenuState::displayOnEpd()
}
InfraredExampleState::InfraredExampleState(){}
InfraredExampleState::InfraredExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *InfraredExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
InfraredExampleState::InfraredExampleState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *InfraredExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
if(intSource == IOEXP_INT_SOURCE::JOY_CENTER)
if(intSource == INT_SOURCE::JOY_CENTER)
{
vTaskSuspend(irTask);
irFlag = 1;
gIrFlag = 1;
irLed.write(GPIO_STATE::LOW);
returnStatep = new InfraredMenuState(EPD_WRITE_METHOD::FULL);
}
@@ -769,6 +868,7 @@ State *InfraredExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void InfraredExampleState::displayOnEpd()
{
epd.drawImage(ir1);
@@ -777,23 +877,25 @@ void InfraredExampleState::displayOnEpd()
}
GyroMenuState::GyroMenuState(){}
GyroMenuState::GyroMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *GyroMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
State *GyroMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new InfraredMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new BleMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new GyroExampleState();
break;
@@ -806,6 +908,7 @@ State *GyroMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void GyroMenuState::displayOnEpd()
{
epd.drawImage(gyro0);
@@ -813,11 +916,14 @@ void GyroMenuState::displayOnEpd()
}
GyroExampleState::GyroExampleState(){}
GyroExampleState::GyroExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *GyroExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
GyroExampleState::GyroExampleState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *GyroExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
if(intSource == IOEXP_INT_SOURCE::JOY_CENTER)
if(intSource == INT_SOURCE::JOY_CENTER)
{
vTaskSuspend(gyroTask);
returnStatep = new GyroMenuState(EPD_WRITE_METHOD::FULL);
@@ -828,6 +934,7 @@ State *GyroExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void GyroExampleState::displayOnEpd()
{
epd.drawImage(gyro1);
@@ -836,23 +943,25 @@ void GyroExampleState::displayOnEpd()
}
BleMenuState::BleMenuState(){}
BleMenuState::BleMenuState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *BleMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
State *BleMenuState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
switch(intSource)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
returnStatep = new GyroMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
returnStatep = new JoystickMenuState();
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
returnStatep = new BleExampleState();
break;
@@ -865,6 +974,7 @@ State *BleMenuState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void BleMenuState::displayOnEpd()
{
epd.drawImage(BleBeacon);
@@ -872,11 +982,14 @@ void BleMenuState::displayOnEpd()
}
BleExampleState::BleExampleState(){}
BleExampleState::BleExampleState(EPD_WRITE_METHOD writeMethod):State(writeMethod){}
State *BleExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
BleExampleState::BleExampleState(EPD_WRITE_METHOD writeMethod):
State(writeMethod){}
State *BleExampleState::handleEvent(INT_SOURCE intSource)
{
State *returnStatep;
if(intSource == IOEXP_INT_SOURCE::JOY_CENTER)
if(intSource == INT_SOURCE::JOY_CENTER)
{
//vTaskSuspend(bleTask);
gBleTaskSuspend = true;
@@ -888,9 +1001,12 @@ State *BleExampleState::handleEvent(IOEXP_INT_SOURCE intSource)
}
return returnStatep;
}
void BleExampleState::displayOnEpd()
{
epd.drawImage(BleBeaconInMeni);
writeToEpd();
vTaskResume(bleTask);
}
}
//--------------------------- PRIVATE FUNCTIONS -------------------------------
//--------------------------- INTERRUPT HANDLERS ------------------------------
+988
View File
@@ -0,0 +1,988 @@
/**
* @file states.h
* @author Dominik Kotarski (d.kotarski@aconno.de)
* @brief
* @version 0.1
* @date 2019-02-18
*
* @copyright Copyright (c) 2019
*
*/
#ifndef __MENU_STATES_H__
#define __MENU_STATES_H__
//----------------------------- DATA TYPES ------------------------------------
//-------------------------- CONSTANTS & MACROS -------------------------------
#include "FreeRTOS.h"
#include "task.h"
#include "aconnoHelpers.h"
#include "aconnoTasks.h"
//----------------------------PUBLIC PROTOTYPES -------------------------------
/**
* @brief Abstract state class. Represents a state of menu displayed on
* e-paper display
*/
class State
{
public:
/**
* @brief Enum type for the epd write method.
* @see GDEP015OC1::writeFull()
* @see GDEP015OC1::write()
*/
enum class EPD_WRITE_METHOD
{
FULL,
PARTIAL
};
/**
* @brief Construct a new State object with write Method implied as
* partial
*/
State();
/**
* @brief Construct a new State object with a provided write Method
*
* @param writeMethod Write method to use when refreshing the e-paper
* display. Full write guarantees a full refresh, but is significantly
* slower than a partial write.
*
* @see State::EPD_WRITE_METHOD
* @see GDEP015OC1::writeFull()
* @see GDEP015OC1::write()
*/
State(EPD_WRITE_METHOD writeMethod);
/**
* @brief Destroy the State object
*/
virtual ~State();
/**
* @brief Function to handle an interrupt (a button press) in a context
* of the current state
*
* @param intSource Id of the interrupt that occured,
* @see INT_SOURCE
* @return State* Returns the next state object (can be itself if the
* state is not supposed to change)
*/
virtual State *handleEvent(INT_SOURCE intSource) = 0;
/**
* @brief Function which handles displaying the state on epd.
*
* This function can also be used to start a task, which will then
* handle drawing on the epd. However, user should take care of
* suspending the mentioned task while exiting the state.
*/
virtual void displayOnEpd() = 0;
/**
* @brief Function to perform SPI write on the e-paper display.
* Initiates a full or partial write, determined by the write Method
* provided during the object creation.
*
* @see State::EPD_WRITE_METHOD
* @see GDEP015OC1::writeFull()
* @see GDEP015OC1::write()
* @return uint8_t Status code
*/
uint8_t writeToEpd();
private:
EPD_WRITE_METHOD _writeMethod;
};
/**
* @brief State for the Welcome screen displayed upon board boot
* @see State
*/
class Intro1State : public State
{
public:
/**
* @brief Construct a new Intro 1 State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
Intro1State(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Intro 1 State object with write method implied
* as partial
* @see State::State()
*/
Intro1State();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief State for the second screen, extending the welcome to the user
* @see State
*
*/
class Intro2State : public State
{
public:
/**
* @brief Construct a new Intro 2 State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
Intro2State(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Intro 2 State object
* @see State::State()
*/
Intro2State();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief State for the screen which displays a jumper setup prompt
* @see State
*
*/
class Intro3State : public State
{
public:
/**
* @brief Construct a new Intro 3 State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
Intro3State(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Intro 3 State object
* @see State::State()
*/
Intro3State();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief State for the menu item with the joystick example
* @see State
*
*/
class JoystickMenuState : public State
{
public:
/**
* @brief Construct a new Joystick Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
JoystickMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Joystick Menu State object
* @see State::State()
*/
JoystickMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief State for the
* @see State
*
*/
class JoystickExampleState : public State
{
public:
/**
* @brief Construct a new Joystick Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
JoystickExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Joystick Example State object
* @see State::State()
*/
JoystickExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Menu sound state class
* @see State
*
*/
class SoundMenuState : public State
{
public:
/**
* @brief Construct a new Sound Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
SoundMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Sound Menu State object
* @see State::State()
*/
SoundMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Sound task state class
* @see State
*
*/
class SoundExampleState : public State
{
public:
/**
* @brief Construct a new Sound Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
SoundExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Sound Example State object
* @see State::State()
*/
SoundExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Menu RGB (red, green, blue) LED state class
* @see State
*
*/
class RgbLedMenuState : public State
{
public:
/**
* @brief Construct a new Rgb Led Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
RgbLedMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Rgb Led Menu State object
* @see State::State()
*/
RgbLedMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief RGB task state class
* @see State
*
*/
class RgbLedExampleState : public State
{
public:
/**
* @brief Construct a new Rgb Led Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
RgbLedExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Rgb Led Example State object
* @see State::State()
*/
RgbLedExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Menu servo state class
* @see State
*
*/
class ServoMenuState : public State
{
public:
/**
* @brief Construct a new Servo Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
ServoMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Servo Menu State object
* @see State::State()
*/
ServoMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Servo task state class
* @see State
*
*/
class ServoExampleState : public State
{
public:
/**
* @brief Construct a new Servo Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
ServoExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Servo Example State object
* @see State::State()
*/
ServoExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Servo jumper instructions state class
* @see State
*
*/
class ServoInstructionState : public State
{
public:
/**
* @brief Construct a new Servo Instruction State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
ServoInstructionState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Servo Instruction State object
* @see State::State()
*/
ServoInstructionState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Light detection resistor menu state class
* @see State
*
*/
class LdrMenuState : public State
{
public:
/**
* @brief Construct a new Ldr Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
LdrMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Ldr Menu State object
* @see State::State()
*/
LdrMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Light detection resistor task state class
* @see State
*
*/
class LdrExampleState : public State
{
public:
/**
* @brief Construct a new Ldr Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
LdrExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Ldr Example State object
* @see State::State()
*/
LdrExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Potentiometer menu state class
* @see State
*
*/
class PotentiometerMenuState : public State
{
public:
/**
* @brief Construct a new Potentiometer Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
PotentiometerMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Potentiometer Menu State object
* @see State::State()
*/
PotentiometerMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Potentiometer task state class
* @see State
*
*/
class PotentiometerExampleState : public State
{
public:
/**
* @brief Construct a new Potentiometer Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
PotentiometerExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Potentiometer Example State object
* @see State::State()
*/
PotentiometerExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Ambient temperature menu state class
* @see State
*
*/
class TempProbeMenuState : public State
{
public:
/**
* @brief Construct a new Temp Probe Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
TempProbeMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Temp Probe Menu State object
* @see State::State()
*/
TempProbeMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Ambient temeprature task state class
* @see State
*
*/
class TempProbeExampleState : public State
{
public:
/**
* @brief Construct a new Temp Probe Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
TempProbeExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Temp Probe Example State object
* @see State::State()
*/
TempProbeExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Relay menu state class
* @see State
*
*/
class RelayMenuState : public State
{
public:
/**
* @brief Construct a new Relay Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
RelayMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Relay Menu State object
* @see State::State()
*/
RelayMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Relay task state class
* @see State
*
*/
class RelayExampleState : public State
{
public:
/**
* @brief Construct a new Relay Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
RelayExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Relay Example State object
* @see State::State()
*/
RelayExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief LED menu state class
* @see State
*
*/
class LedMenuState : public State
{
public:
/**
* @brief Construct a new Led Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
LedMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Led Menu State object
* @see State::State()
*/
LedMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief LED task state class
* @see State
*
*/
class LedExampleState : public State
{
public:
/**
* @brief Construct a new Led Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
LedExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Led Example State object
* @see State::State()
*/
LedExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Infrared menu state class
* @see State
*
*/
class InfraredMenuState : public State
{
public:
/**
* @brief Construct a new Infrared Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
InfraredMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Infrared Menu State object
* @see State::State()
*/
InfraredMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Infrared task state class
* @see State
*
*/
class InfraredExampleState : public State
{
public:
/**
* @brief Construct a new Infrared Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
InfraredExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Infrared Example State object
* @see State::State()
*/
InfraredExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Gyroscope menu state class
* @see State
*
*/
class GyroMenuState : public State
{
public:
/**
* @brief Construct a new Gyro Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
GyroMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Gyro Menu State object
* @see State::State()
*/
GyroMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Gyroscope task state class
* @see State
*
*/
class GyroExampleState : public State
{
public:
/**
* @brief Construct a new Gyro Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
GyroExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Gyro Example State object
* @see State::State()
*/
GyroExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Bluetooth beacon and image upload menu state class
* @see State
*
*/
class BleMenuState : public State
{
public:
/**
* @brief Construct a new Ble Menu State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
BleMenuState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Ble Menu State object
* @see State::State()
*/
BleMenuState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
/**
* @brief Bluetooth beacon and image upload task state class
* @see State
*
*/
class BleExampleState : public State
{
public:
/**
* @brief Construct a new Ble Example State object
* @param writeMethod epd write method to be used
* @see State::State()
*/
BleExampleState(EPD_WRITE_METHOD writeMethod);
/**
* @brief Construct a new Ble Example State object
* @see State::State()
*/
BleExampleState();
/**
* @brief Handle an interrupt event
* @param intSource Type of event
* @return State* Next state to be entered into after the event handlin
* @see State::handleEvent()
*/
State *handleEvent(INT_SOURCE intSource);
/**
* @brief Display the state on epd
* @see State::displayOnEpd()
*/
void displayOnEpd();
};
#endif //__MENU_STATES_H__
+189 -196
View File
@@ -8,12 +8,27 @@
* @copyright Copyright (c) 2019
*
*/
//------------------------------ INCLUDES -------------------------------------
#include "aconnoTasks.h"
#include <typeinfo>
#include "timers.h"
#include "aconnoBeeper.h"
//-------------------------------- MACROS -------------------------------------
//----------------------------- DATA TYPES ------------------------------------
//--------------------- PRIVATE FUNCTION PROTOTYPES ---------------------------
//----------------------- STATIC DATA & CONSTANTS -----------------------------
//------------------------------ GLOBAL DATA ----------------------------------
extern TaskHandle_t menuStateMachineTask;
extern SemaphoreHandle_t getInterruptSourceSemaphore;
extern SemaphoreHandle_t epdWriteMutex;
extern State *pMenuState;
extern QueueHandle_t interruptSourceQueue;
extern QueueHandle_t interruptSourceQueueSecondary;
uint8_t intSrcPin;
INT_SOURCE intSourceSend = INT_SOURCE::NOTHING;
INT_SOURCE intSourceRecv = INT_SOURCE::NOTHING;
INT_SOURCE intSourceRecvSecondary = INT_SOURCE::NOTHING;
extern AconnoSPI spi;
extern AconnoI2C i2c;
@@ -31,42 +46,20 @@ extern LDR light;
extern Potentiometer pot;
extern MCP9700 ambientTemperature;
extern Servo servo;
extern SemaphoreHandle_t getInterruptSourceSemaphore;
extern State *pMenuState;
extern uint8_t irFlag;
extern QueueHandle_t interruptSourceQueue;
IOEXP_INT_SOURCE intSourceSend = IOEXP_INT_SOURCE::NOTHING;
IOEXP_INT_SOURCE intSourceRecv = IOEXP_INT_SOURCE::NOTHING;
IOEXP_INT_SOURCE intSourceRecvSecondary = IOEXP_INT_SOURCE::NOTHING;
extern AconnoBeeper beeper;
extern bool gBleTaskSuspend;
/**
* @brief A flag to help with initial drawing of the joystick example
*
*/
extern uint8_t joyFlag;
/**
* @brief secondary interrupt Source queue meant to be used by tasks that
* require interrupts from ioexpander
*/
extern QueueHandle_t interruptSourceQueueSecondary;
/**
* @brief Flag which is used to prevent interrupts that are sent by ioexpander
* while a button is continuously pressed
*/
bool getInterruptSourceFlag = true;
extern TimerHandle_t intFlagTimer;
extern uint8_t gJoyFlag;
extern uint8_t gIrFlag;
extern uint8_t gLdrFlag;
extern uint8_t gTempFlag;
/**< Definition of Logger thread. */
#if NRF_LOG_ENABLED
TaskHandle_t mLoggerThread;
void loggerThread(void *arg);
#endif
//--------------------- PUBLIC FUNCTIONS AND OBJECTS --------------------------
void logTaskFunction(void *arg)
{
#if NRF_LOG_ENABLED
@@ -83,49 +76,32 @@ void logTaskFunction(void *arg)
}
}
void interruptCallback()
{
// resume task to get button
xSemaphoreGive(getInterruptSourceSemaphore);
}
void getInterruptSourceFunction(void *arg)
{
while(1)
{
if(xSemaphoreTake(getInterruptSourceSemaphore, portMAX_DELAY) == pdTRUE)
{
expdr.interruptPinDisable();
uint8_t intSrcPin = expdr.getLastInterruptPin();
if(expdr.readGPIOBit(intSrcPin))
{
// last interrupt reads nothing pressed
intSourceSend = IOEXP_INT_SOURCE::NOTHING;
getInterruptSourceFlag = true;
}
// only send a message if this is the first interrupt after a while
else if(getInterruptSourceFlag)
{
getInterruptSourceFlag=false;
intSourceSend = (IOEXP_INT_SOURCE)intSrcPin;
intSourceSend = (INT_SOURCE)intSrcPin;
xQueueSendToBack(interruptSourceQueue,
(void *) &intSourceSend,
((TickType_t)TICKS_TO_BLOCK_DEFAULT) != pdPASS);
xQueueSendToBack(interruptSourceQueueSecondary,
(void *) &intSourceSend,
((TickType_t)TICKS_TO_BLOCK_DEFAULT) != pdPASS);
// TODO: This part of the code still needs to be done!
//xTimerReset(intFlagTimer, TICKS_TO_BLOCK_DEFAULT);
}
// give other code a chance to execute since we have a higher
// priority
vTaskDelay(GET_INTERRUPT_DELAY_MS);
xQueueSendToBack(interruptSourceQueue,
(void *) &intSourceSend,
((TickType_t)TICKS_TO_BLOCK_DEFAULT) != pdPASS);
//todo: Consider enclosing epd writing in a critical section
// as is done in the joystick example
xQueueSendToBack(interruptSourceQueueSecondary,
(void *) &intSourceSend,
((TickType_t)TICKS_TO_BLOCK_DEFAULT) != pdPASS);
// Wait until the button is not being pressed
while(expdr.readGPIOBit(intSrcPin) == 0)
{
}
expdr.interruptPinEnable();
expdr.readRegister(MCP23017_INTCAP);
}
}
}
void menuStateMachineTaskFunction(void *arg)
@@ -136,8 +112,7 @@ void menuStateMachineTaskFunction(void *arg)
&(intSourceRecv),
portMAX_DELAY))
{
/* Todo: delete could make problems if the same state is returned */
xSemaphoreTake(epdWriteMutex, portMAX_DELAY);
State *newMenuState = pMenuState->handleEvent(intSourceRecv);
if(typeid(*pMenuState) != typeid(*newMenuState))
{
@@ -145,20 +120,18 @@ void menuStateMachineTaskFunction(void *arg)
pMenuState = newMenuState;
pMenuState->displayOnEpd();
}
else
else
{
delete pMenuState;
delete pMenuState;
pMenuState = newMenuState;
}
xSemaphoreGive(epdWriteMutex);
}
/* todo: consider pre-creating all state objects instead of
dinamically creating and destroying objects */
/* todo: consider dynamically deleting tasks after a certain treshold
in case memory becomes a problem */
}
}
void ldrFunction(void *arg)
@@ -166,18 +139,20 @@ void ldrFunction(void *arg)
vTaskSuspend(NULL);
aconnoSensorData_t data;
//Leave this zero so the next if statement must be executed at the begining
float voltage = 0;
uint16_t x_coord;
uint16_t y_coord;
gLdrFlag = 0;
adc.calibrate();
vTaskDelay(25); // Small delay required by adc to calibrate
while(1)
{
{
light.updateData(&data);
if(data.light<voltage-0.05f || data.light>voltage+0.05f)
if(data.light < voltage - 0.05f || data.light > voltage + 0.05f || gLdrFlag == 1 )
{
gLdrFlag = 0;
voltage = data.light;
if (voltage<0.10f) { x_coord = 40; y_coord = 135; }
else if(voltage<0.20f) { x_coord = 43; y_coord = 130; }
@@ -190,9 +165,11 @@ void ldrFunction(void *arg)
else if(voltage<0.90f) { x_coord = 141; y_coord = 95; }
else { x_coord = 100; y_coord = 85; }
xSemaphoreTake(epdWriteMutex, portMAX_DELAY);
epd.drawImage(ldr1);
epd.drawLine(100,135,x_coord,y_coord,0);
epd.write();
xSemaphoreGive(epdWriteMutex);
}
vTaskDelay(EXAMPLE_DELAY_MS);
}
@@ -201,29 +178,32 @@ void ldrFunction(void *arg)
void potentiometerFunction(void *arg)
{
vTaskSuspend(NULL);
aconnoSensorData_t data;
static float voltage;
adc.calibrate();
vTaskDelay(25); // Small delay required by adc to calibrate
pot.updateData(&data);
voltage = data.voltage;
while(1)
{
xSemaphoreTake(epdWriteMutex, portMAX_DELAY);
pot.updateData(&data);
if(data.voltage>voltage+0.05f)
if(data.voltage > voltage + 0.02f)
{
epd.drawImage(potCW);
epd.write();
}
else if(data.voltage<voltage-0.05f)
else if(data.voltage < voltage - 0.02f)
{
epd.drawImage(potCCW);
epd.write();
}
voltage = data.voltage;
vTaskDelay(EXAMPLE_DELAY_MS);
xSemaphoreGive(epdWriteMutex);
vTaskDelay(POT_DELAY_MS);
}
}
@@ -232,20 +212,20 @@ void temperatureFunction(void *arg)
vTaskSuspend(NULL);
aconnoSensorData_t data;
float temperature=0;
float temperature = 0;
char buffer[10];
int n;
gTempFlag = 0;
adc.calibrate();
adc.updateData(); //to clear the ADC buffer
vTaskDelay(25); // Small delay required by adc to calibrate
while(1)
{
ambientTemperature.updateData(&data);
if(data.temperature>temperature+0.5f ||
data.temperature<temperature-0.5f)
if(data.temperature > temperature + 0.5f ||
data.temperature < temperature - 0.5f || gTempFlag == 1)
{
xSemaphoreTake(epdWriteMutex, portMAX_DELAY);
gTempFlag = 0;
// Erase previous data from the buffer
epd.writeString(buffer,110,100,1);
@@ -257,10 +237,11 @@ void temperatureFunction(void *arg)
int tmpInt1 = tmpVal; // Get the integer
float tmpFrac = tmpVal - tmpInt1; // Get fraction
int tmpInt2 = trunc(tmpFrac * 100); // Turn fraction into integer
n = sprintf(buffer, "%c%d.%d", tmpSign, tmpInt1, tmpInt2); //Create a string
sprintf(buffer, "%c%d.%d", tmpSign, tmpInt1, tmpInt2); //Create a string
epd.writeString(buffer,110,100,0); // Write new data to the buffer
epd.write();
epd.writeString(buffer, 110, 100, 0); // Write new data to the buffer
epd.write();
xSemaphoreGive(epdWriteMutex);
}
vTaskDelay(EXAMPLE_DELAY_MS);
}
@@ -269,7 +250,7 @@ void temperatureFunction(void *arg)
void gyroFunction(void *arg)
{
vTaskSuspend(NULL);
aconnoSensorData_t data;
aconnoSensorVec_t gyroVal;
i2c.enable();
@@ -283,10 +264,11 @@ void gyroFunction(void *arg)
gyroVal.y = data.gyro.y * (245.0f/32768.0f);
gyroVal.z = data.gyro.z * (245.0f/32768.0f);
if((gyroVal.x>50.0f) || (gyroVal.x<(-50.0f)) ||
(gyroVal.y>50.0f) || (gyroVal.y<(-50.0f)) ||
(gyroVal.z>50.0f) || (gyroVal.z<(-50.0f)))
if((gyroVal.x > 50.0f) || (gyroVal.x < (-50.0f)) ||
(gyroVal.y > 50.0f) || (gyroVal.y < (-50.0f)) ||
(gyroVal.z > 50.0f) || (gyroVal.z < (-50.0f)))
{
xSemaphoreTake(epdWriteMutex, portMAX_DELAY);
switch(rand()%6+1)
{
#define C(x) epd.fillCircle(100,100,10,x)
@@ -335,8 +317,9 @@ void gyroFunction(void *arg)
#undef CR
#undef CL
#undef C
}
}
}
xSemaphoreGive(epdWriteMutex);
}
vTaskDelay(EXAMPLE_DELAY_MS);
}
}
@@ -352,7 +335,7 @@ void bleBeaconFunction(void *arg)
static aconnoSensorData_t data;
advertisementPacket.settingsFlag = SETTINGS_SUPPORT_FLAG;
advertisementPacket.versionNumber = PRODUCT_VERSION;
adc.calibrate();
vTaskDelay(25); // Small delay required by adc to calibrate
while(1)
@@ -398,7 +381,6 @@ void bleBeaconFunction(void *arg)
pot.updateData(&data);
advertisementPacket.pot = (uint8_t)(data.voltage*255);
}
myBLE.advRawUpdate((uint8_t*)&advertisementPacket,
sizeof(advertisementPacket_t));
advertisementPacket.advType = (advertisementPacket.advType+1)%2;
@@ -416,23 +398,24 @@ void imageUpdate(uint8_t const *data, size_t dataLen)
{
static uint16_t epdPointer = 0;
xSemaphoreTake(epdWriteMutex, portMAX_DELAY);
for(uint16_t x = 0; x < dataLen; x++)
{
epd.fill(data[x], epdPointer);
epdPointer++;
}
if(epdPointer == EPD_BUFFER_SIZE)
{
epdPointer = 0;
epd.writeFull();
NRF_LOG_INFO("Image updated.");
}
xSemaphoreGive(epdWriteMutex);
}
void infraredFunction(void *arg)
{
irFlag = 0;
gIrFlag = 0;
vTaskSuspend(NULL);
uint8_t SOS[] = {
0, 1, 0, 1, 0, 1, // S
@@ -445,13 +428,12 @@ void infraredFunction(void *arg)
while(1)
{
if(irFlag==1)
if(gIrFlag == 1)
{
irIndex = 0;
irFlag = 0;
gIrFlag = 0;
}
if(SOS[irIndex]==0)
if(SOS[irIndex] == 0)
{
irLed.write(GPIO_STATE::LOW);
}
@@ -460,7 +442,7 @@ void infraredFunction(void *arg)
irLed.write(GPIO_STATE::HIGH);
}
vTaskDelay(INFRARED_DELAY_MS);
irIndex = (irIndex+1)%sosSize;
irIndex = (irIndex + 1) % sosSize;
}
}
@@ -470,9 +452,9 @@ void ledsFunction(void *arg)
while(1)
{
if(expdr.readGPIOBit(MCP23017_SW2)==0)
if(expdr.readGPIOBit(MCP23017_SW2) == 0)
{
if(expdr.readGPIOBit(MCP23017_LED2)==0)
if(expdr.readGPIOBit(MCP23017_LED2) == 0)
{
expdr.writeGPIOBit(1, MCP23017_LED2);
}
@@ -481,7 +463,7 @@ void ledsFunction(void *arg)
expdr.writeGPIOBit(0, MCP23017_LED2);
}
}
else if(sw1.read()==GPIO_STATE::LOW)
else if(sw1.read() == GPIO_STATE::LOW)
{
ld1.toggle();
}
@@ -497,7 +479,7 @@ void relayFunction(void *arg)
{
if(expdr.readGPIOBit(MCP23017_SW2) == 0)
{
if(expdr.readGPIOBit(MCP23017_REL2)==0)
if(expdr.readGPIOBit(MCP23017_REL2) == 0)
{
expdr.writeGPIOBit(1, MCP23017_REL2);
}
@@ -506,9 +488,9 @@ void relayFunction(void *arg)
expdr.writeGPIOBit(0, MCP23017_REL2);
}
}
else if(sw1.read()==GPIO_STATE::LOW)
else if(sw1.read() == GPIO_STATE::LOW)
{
if(expdr.readGPIOBit(MCP23017_REL1)==0)
if(expdr.readGPIOBit(MCP23017_REL1) == 0)
{
expdr.writeGPIOBit(1, MCP23017_REL1);
}
@@ -521,7 +503,7 @@ void relayFunction(void *arg)
}
}
void joystickTaskFunction(void *arg)
void joyFunction(void *arg)
{
//center coordinates
uint16_t xCoordCenter = 100;
@@ -540,36 +522,34 @@ void joystickTaskFunction(void *arg)
};
BALL_POSITION ballPosition = BALL_POSITION::CENTER;
BALL_POSITION ballPositionPrev = BALL_POSITION::CENTER;
vTaskSuspend(NULL);
while(1)
{
if(xQueueReceive(interruptSourceQueueSecondary,
&(intSourceRecvSecondary),
(TickType_t) 10))
{
if (joyFlag)
if (gJoyFlag)
{
joyFlag = 0;
xSemaphoreTake(epdWriteMutex, portMAX_DELAY);
gJoyFlag = 0;
epd.drawImage(joystick1);
epd.fillCircle(xCoordCenter,
yCoordCenter,
ballRadius,
color);
// do not allow task suspending while epd writing
vTaskSuspendAll();
epd.write();
xTaskResumeAll();
xSemaphoreGive(epdWriteMutex);
}
epd.drawImage(joystick1);
switch (intSourceRecvSecondary)
ballPositionPrev = ballPosition;
switch(intSourceRecvSecondary)
{
case IOEXP_INT_SOURCE::JOY_UP:
case INT_SOURCE::JOY_UP:
{
switch (ballPosition)
switch(ballPosition)
{
case BALL_POSITION::CENTER:
{
@@ -588,9 +568,9 @@ void joystickTaskFunction(void *arg)
}
break;
}
case IOEXP_INT_SOURCE::JOY_DOWN:
case INT_SOURCE::JOY_DOWN:
{
switch (ballPosition)
switch(ballPosition)
{
case BALL_POSITION::CENTER:
{
@@ -609,22 +589,20 @@ void joystickTaskFunction(void *arg)
}
break;
}
case IOEXP_INT_SOURCE::JOY_LEFT:
case INT_SOURCE::JOY_LEFT:
{
switch (ballPosition)
switch(ballPosition)
{
case BALL_POSITION::CENTER:
{
ballPosition = BALL_POSITION::LEFT;
break;
}
case BALL_POSITION::RIGHT:
{
ballPosition = BALL_POSITION::CENTER;
break;
}
default:
{
break;
@@ -632,9 +610,9 @@ void joystickTaskFunction(void *arg)
}
break;
}
case IOEXP_INT_SOURCE::JOY_RIGHT:
case INT_SOURCE::JOY_RIGHT:
{
switch (ballPosition)
switch(ballPosition)
{
case BALL_POSITION::CENTER:
{
@@ -653,7 +631,7 @@ void joystickTaskFunction(void *arg)
}
break;
}
case IOEXP_INT_SOURCE::JOY_CENTER:
case INT_SOURCE::JOY_CENTER:
{
ballPosition = BALL_POSITION::CENTER;
break;
@@ -663,75 +641,79 @@ void joystickTaskFunction(void *arg)
break;
}
}
vTaskSuspend(menuStateMachineTask);
switch (ballPosition)
if(ballPositionPrev != ballPosition)
{
case BALL_POSITION::UP:
xSemaphoreTake(epdWriteMutex, portMAX_DELAY);
epd.drawImage(joystick1);
switch(ballPosition)
{
epd.fillCircle(xCoordCenter,
yCoordCenter-centerOffset,
ballRadius,
color);
epd.write();
break;
}
case BALL_POSITION::DOWN:
{
epd.fillCircle(xCoordCenter,
yCoordCenter+centerOffset,
ballRadius,
color);
epd.write();
break;
}
case BALL_POSITION::LEFT:
{
epd.fillCircle(xCoordCenter-centerOffset,
yCoordCenter,
ballRadius,
color);
epd.write();
break;
}
case BALL_POSITION::RIGHT:
{
epd.fillCircle(xCoordCenter+centerOffset,
yCoordCenter,
ballRadius,
color);
epd.write();
break;
}
case BALL_POSITION::CENTER:
{
epd.fillCircle(xCoordCenter,
yCoordCenter,
ballRadius,
color);
epd.write();
break;
}
default:
{
break;
case BALL_POSITION::UP:
{
epd.fillCircle(xCoordCenter,
yCoordCenter-centerOffset,
ballRadius,
color);
epd.write();
break;
}
case BALL_POSITION::DOWN:
{
epd.fillCircle(xCoordCenter,
yCoordCenter+centerOffset,
ballRadius,
color);
epd.write();
break;
}
case BALL_POSITION::LEFT:
{
epd.fillCircle(xCoordCenter-centerOffset,
yCoordCenter,
ballRadius,
color);
epd.write();
break;
}
case BALL_POSITION::RIGHT:
{
epd.fillCircle(xCoordCenter+centerOffset,
yCoordCenter,
ballRadius,
color);
epd.write();
break;
}
case BALL_POSITION::CENTER:
{
epd.fillCircle(xCoordCenter,
yCoordCenter,
ballRadius,
color);
epd.write();
break;
}
default:
{
break;
}
}
xSemaphoreGive(epdWriteMutex);
}
vTaskResume(menuStateMachineTask);
}
}
}
void rgbLedTaskFunction(void *arg)
void rgbFunction(void *arg)
{
vTaskSuspend(NULL);
while(1)
{
uint8_t x = rand()%7;
ledRed.write((GPIO_STATE)((x>>2)&1));
ledGreen.write((GPIO_STATE)((x>>1)&1));
ledBlue.write((GPIO_STATE)((x>>0)&1));
vTaskDelay(rand()%250); // Wait some random time
// Randomly generate a state for the rgb leds to be in
uint8_t x = rand() % 7;
ledRed.write((GPIO_STATE)((x >> 2) & 1));
ledGreen.write((GPIO_STATE)((x >> 1) & 1));
ledBlue.write((GPIO_STATE)((x >> 0) & 1));
vTaskDelay(rand() % 250);
}
}
@@ -742,40 +724,46 @@ void servoFunction(void *arg)
servo.init();
servo.calibrate(0.00095, 90);
servo.enable();
servo.write(0.5f);
waitMs(SERVO_DELAY_MS);
servo.disable();
while(1)
{
switch (intSourceSend)
switch(intSourceSend)
{
case IOEXP_INT_SOURCE::JOY_LEFT:
case INT_SOURCE::JOY_LEFT:
{
if(servo.read()>0.1)
if(servo.read() > 0.1)
{
intSourceSend = INT_SOURCE::NOTHING;
servo.enable();
percentage = servo.read() - 0.1f;
servo.write(percentage);
waitMs(SERVO_DELAY_MS);
servo.disable();
}
break;
}
case IOEXP_INT_SOURCE::JOY_RIGHT:
}
case INT_SOURCE::JOY_RIGHT:
{
if(servo.read()<0.90)
if(servo.read() < 0.90)
{
intSourceSend = INT_SOURCE::NOTHING;
servo.enable();
percentage = servo.read() + 0.1f;
servo.write(percentage);
waitMs(SERVO_DELAY_MS);
servo.disable();
}
break;
}
default:
{
servo.write(servo.read());
waitMs(SERVO_DELAY_MS);
break;
break;
}
}
NRF_LOG_INFO("Percentage is" NRF_LOG_FLOAT_MARKER "\r\n", NRF_LOG_FLOAT(percentage));
vTaskDelay(EXAMPLE_DELAY_MS);
}
}
@@ -789,3 +777,8 @@ void soundFunction(void *arg)
beeper.playRttl(song);
}
}
//--------------------------- INTERRUPT HANDLERS ------------------------------
void interruptCallback()
{
xSemaphoreGiveFromISR(getInterruptSourceSemaphore, NULL);
}
+14 -14
View File
@@ -8,10 +8,11 @@
* @copyright Copyright (c) 2019
*
*/
#ifndef __ACONNO_TASKS_H__
#define __ACONNO_TASKS_H__
//------------------------------ INCLUDES -------------------------------------
//----------------------------- DATA TYPES ------------------------------------
//-------------------------- CONSTANTS & MACROS -------------------------------
#include "FreeRTOS.h"
#include "aconnoBLE.h"
#include "aconnoConfig.h"
@@ -21,7 +22,6 @@
#include "acd52832Bsp.h"
#include "pictures.h"
#include <math.h>
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
@@ -35,8 +35,9 @@
#define QUEUE_DEFAULT_SIZE (10)
#define TICKS_TO_BLOCK_DEFAULT (10)
#define GET_INTERRUPT_DELAY_MS (1)
#define SERVO_DELAY_MS (50)
#define SERVO_DELAY_MS (100)
#define POT_DELAY_MS (500)
//----------------------------PUBLIC PROTOTYPES -------------------------------
/**
* @brief Function logger
*
@@ -72,13 +73,7 @@ void jumperTaskFunction(void *arg);
*
* @param arg
*/
void joystickTaskFunction(void *arg);
/**
* @brief A callback for mainMenu button joystick press
*
*/
void interruptCallback();
void joyFunction(void *arg);
/**
* @brief
@@ -152,7 +147,7 @@ void relayFunction(void *arg);
*
* @param arg
*/
void rgbLedTaskFunction(void *arg);
void rgbFunction(void *arg);
/**
* @brief Servo example task
*
@@ -167,5 +162,10 @@ void servoFunction(void *arg);
*/
void soundFunction(void *arg);
/**
* @brief A callback for mainMenu button joystick press
*
*/
void interruptCallback();
#endif // __ACONNO_TASKS_H__
#endif // __ACONNO_TASKS_H__