commit
2c2e2c2e39
@ -53,6 +53,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/threads/rotary}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/threads/rotary}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/threads/manager}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/threads/manager}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/threads/logging}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||||
</option>
|
</option>
|
||||||
<option id="com.crt.advproject.cpp.misc.dialect.4036734" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.cpp17" valueType="enumerated"/>
|
<option id="com.crt.advproject.cpp.misc.dialect.4036734" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.cpp17" valueType="enumerated"/>
|
||||||
@ -85,6 +86,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/logging}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||||
</option>
|
</option>
|
||||||
<option id="com.crt.advproject.c.misc.dialect.82852045" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c17" valueType="enumerated"/>
|
<option id="com.crt.advproject.c.misc.dialect.82852045" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c17" valueType="enumerated"/>
|
||||||
@ -105,6 +107,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/logging}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1836378919" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1836378919" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
@ -255,6 +258,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/FreeRTOSCPP}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/FreeRTOSCPP}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/logging}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1117166373" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1117166373" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
<inputType id="com.crt.advproject.assembler.input.2071009798" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
|
<inputType id="com.crt.advproject.assembler.input.2071009798" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
|
||||||
|
|||||||
@ -91,7 +91,8 @@
|
|||||||
#define configUSE_MALLOC_FAILED_HOOK 1
|
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||||
#define configUSE_APPLICATION_TASK_TAG 0
|
#define configUSE_APPLICATION_TASK_TAG 0
|
||||||
#define configUSE_COUNTING_SEMAPHORES 1
|
#define configUSE_COUNTING_SEMAPHORES 1
|
||||||
#define configGENERATE_RUN_TIME_STATS 0
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
|
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||||
#define configUSE_TICKLESS_IDLE 1
|
#define configUSE_TICKLESS_IDLE 1
|
||||||
|
|
||||||
|
|
||||||
@ -119,6 +120,16 @@ to exclude the API function. */
|
|||||||
#define INCLUDE_vTaskDelay 1
|
#define INCLUDE_vTaskDelay 1
|
||||||
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
||||||
|
|
||||||
|
/* NOTE: we need to provide implementation of vConfigureTimerForRunTimeStats()
|
||||||
|
* It is called to set up high resolution timer that is needed for accurate runtime
|
||||||
|
* measurement. I assume that we use LPC_SCT1 in unified mode so this function
|
||||||
|
* must set up LPC_SCT1.
|
||||||
|
*/
|
||||||
|
void vConfigureTimerForRunTimeStats(void);
|
||||||
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
|
||||||
|
/* The value is read directly from the counter register for efficiency and low overhead. */
|
||||||
|
#define portGET_RUN_TIME_COUNTER_VALUE() LPC_SCT1->COUNT_U
|
||||||
|
|
||||||
/* Cortex-M specific definitions. */
|
/* Cortex-M specific definitions. */
|
||||||
#ifdef __NVIC_PRIO_BITS
|
#ifdef __NVIC_PRIO_BITS
|
||||||
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
|
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
|
||||||
|
|||||||
@ -7,9 +7,8 @@
|
|||||||
|
|
||||||
#include "ThreadCommon.h"
|
#include "ThreadCommon.h"
|
||||||
#include "Master.h"
|
#include "Master.h"
|
||||||
#include "Rotary.h"
|
|
||||||
#include "Manager.h"
|
|
||||||
#include "UserInterface.h"
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@ -18,37 +17,28 @@ int main(void)
|
|||||||
|
|
||||||
retarget_init();
|
retarget_init();
|
||||||
|
|
||||||
printf("Hello there!\r\n");
|
ThreadCommon::ThreadManager *tm = new ThreadCommon::ThreadManager();
|
||||||
|
ThreadCommon::QueueManager *qm = new ThreadCommon::QueueManager();
|
||||||
ThreadCommon::ThreadManager* manager = new ThreadCommon::ThreadManager;
|
ThreadCommon::CommonManagers *manager = new ThreadCommon::CommonManagers;
|
||||||
ThreadCommon::QueueManager* qmanager = new ThreadCommon::QueueManager;
|
manager->tm = tm;
|
||||||
//Creating queues
|
manager->qm = qm;
|
||||||
qmanager->createQueue(100,
|
manager->tm->createTask(thread_master, "master",
|
||||||
sizeof(Event),
|
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
||||||
ThreadCommon::QueueManager::master_event_all);
|
static_cast<void*>(manager));
|
||||||
qmanager->createQueue(20,
|
|
||||||
sizeof(Event),
|
|
||||||
ThreadCommon::QueueManager::manager_event_master);
|
|
||||||
qmanager->createQueue(20,
|
|
||||||
sizeof(UserInterface::InterfaceWithData),
|
|
||||||
ThreadCommon::QueueManager::ui_event_manager);
|
|
||||||
|
|
||||||
//Creating tasks
|
|
||||||
manager->createTask(thread_master, "master",
|
|
||||||
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
|
||||||
static_cast<void*>(qmanager));
|
|
||||||
manager->createTask(thread_manager, "manager",
|
|
||||||
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
|
||||||
static_cast<void*>(qmanager));
|
|
||||||
manager->createTask(thread_rotary, "rotary",
|
|
||||||
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
|
||||||
static_cast<void*>(qmanager));
|
|
||||||
manager->createTask(thread_user_interface, "user_interface",
|
|
||||||
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
|
||||||
static_cast<void*>(qmanager));
|
|
||||||
|
|
||||||
// Start the real time kernel with preemption.
|
|
||||||
vTaskStartScheduler ();
|
vTaskStartScheduler ();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
void
|
||||||
|
vConfigureTimerForRunTimeStats (void)
|
||||||
|
{
|
||||||
|
Chip_SCT_Init (LPC_SCT1);
|
||||||
|
LPC_SCT1->CONFIG = SCT_CONFIG_32BIT_COUNTER;
|
||||||
|
LPC_SCT1->CTRL_U = SCT_CTRL_PRE_L (255)
|
||||||
|
| SCT_CTRL_CLRCTR_L; // set prescaler to 256 (255 +
|
||||||
|
// 1), and start timer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DigitalIoPin.h"
|
#include "DigitalIoPin.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
DigitalIoPin::DigitalIoPin (int port, int pin, bool input, bool pullup,
|
DigitalIoPin::DigitalIoPin (int port, int pin, bool input, bool pullup,
|
||||||
bool invert, bool isr, IRQn_Type isr_index)
|
bool invert, bool isr, IRQn_Type isr_index)
|
||||||
@ -39,6 +40,8 @@ DigitalIoPin::~DigitalIoPin ()
|
|||||||
void
|
void
|
||||||
DigitalIoPin::setIoPin ()
|
DigitalIoPin::setIoPin ()
|
||||||
{
|
{
|
||||||
|
LOG_DEBUG("P%d_%d set as %s", _io._port, _io._pin,
|
||||||
|
_io._input ? "input" : "output");
|
||||||
bool direction = true;
|
bool direction = true;
|
||||||
if (_io._input)
|
if (_io._input)
|
||||||
{
|
{
|
||||||
@ -62,6 +65,7 @@ DigitalIoPin::setIoPin ()
|
|||||||
void
|
void
|
||||||
DigitalIoPin::setIsr ()
|
DigitalIoPin::setIsr ()
|
||||||
{
|
{
|
||||||
|
LOG_DEBUG("P%d_%d set as ISR", _io._port, _io._pin);
|
||||||
bool direction = true;
|
bool direction = true;
|
||||||
if (_io._input)
|
if (_io._input)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <EEPROMio.h>
|
#include <EEPROMio.h>
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_memcpy (void *from, void *to, unsigned int n)
|
e_memcpy (void *from, void *to, unsigned int n)
|
||||||
@ -57,6 +58,7 @@ EEPROMio::write_to (uint32_t addr, std::string str)
|
|||||||
{
|
{
|
||||||
std::copy (str.begin (), str.end (), std::begin (buffer));
|
std::copy (str.begin (), str.end (), std::begin (buffer));
|
||||||
eeprom_use (buffer, addr, str.length (), WRITE);
|
eeprom_use (buffer, addr, str.length (), WRITE);
|
||||||
|
LOG_DEBUG("%dB written to EEPROM", str.length ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
@ -64,6 +66,7 @@ EEPROMio::read_from (uint32_t addr, uint32_t amount)
|
|||||||
{
|
{
|
||||||
eeprom_use (buffer, addr, amount, READ);
|
eeprom_use (buffer, addr, amount, READ);
|
||||||
void *data = (void *)buffer;
|
void *data = (void *)buffer;
|
||||||
|
LOG_DEBUG("%dB read from EEPROM", amount);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
@ -72,5 +75,6 @@ EEPROMio::write_to (uint32_t addr, void *data, uint32_t size_of_data)
|
|||||||
assert (size_of_data < EEPROM_MAX_BUFER_SIZE);
|
assert (size_of_data < EEPROM_MAX_BUFER_SIZE);
|
||||||
e_memcpy (data, buffer, size_of_data);
|
e_memcpy (data, buffer, size_of_data);
|
||||||
eeprom_use (buffer, addr, size_of_data, WRITE);
|
eeprom_use (buffer, addr, size_of_data, WRITE);
|
||||||
|
LOG_DEBUG("%dB written to EEPROM", size_of_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ static LpcDebugUart *dbgu;
|
|||||||
|
|
||||||
void retarget_init()
|
void retarget_init()
|
||||||
{
|
{
|
||||||
LpcPinMap none = {-1, -1}; // unused pin has negative values in it
|
//LpcPinMap none = {-1, -1}; // unused pin has negative values in it
|
||||||
//Sadly, it seems that only USART0 is redirected to USB.
|
//Sadly, it seems that only USART0 is redirected to USB.
|
||||||
//It means that those are pins PIO0_18 and PIO0_19
|
//It means that those are pins PIO0_18 and PIO0_19
|
||||||
LpcPinMap txpin = { 0, 19 }; // transmit pin that goes to debugger's UART->USB converter
|
LpcPinMap txpin = { 0, 19 }; // transmit pin that goes to debugger's UART->USB converter
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ThreadCommon.h"
|
#include "ThreadCommon.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
ThreadCommon::QueueManager::QueueManager() {}
|
ThreadCommon::QueueManager::QueueManager() {}
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
namespace ThreadCommon
|
namespace ThreadCommon
|
||||||
{
|
{
|
||||||
|
|
||||||
enum RotaryAction
|
enum RotaryAction
|
||||||
{
|
{
|
||||||
Right,
|
Right,
|
||||||
@ -45,7 +46,8 @@ namespace ThreadCommon
|
|||||||
master_event_all,
|
master_event_all,
|
||||||
relay_event_master,
|
relay_event_master,
|
||||||
manager_event_master,
|
manager_event_master,
|
||||||
ui_event_manager
|
ui_event_manager,
|
||||||
|
logging_message_all
|
||||||
};
|
};
|
||||||
QueueManager();
|
QueueManager();
|
||||||
~QueueManager() = default;
|
~QueueManager() = default;
|
||||||
@ -70,14 +72,11 @@ namespace ThreadCommon
|
|||||||
std::map <Queue_id, QueueHandle_t> queues;
|
std::map <Queue_id, QueueHandle_t> queues;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* global variables */
|
typedef struct _CommonManagers
|
||||||
/* 'receiver'_'what'_'sender'_q */
|
{
|
||||||
/*
|
ThreadManager * tm;
|
||||||
extern QueueHandle_t master_event_all_q;
|
QueueManager * qm;
|
||||||
extern QueueHandle_t relay_event_master_q;
|
} CommonManagers;
|
||||||
extern QueueHandle_t manager_event_master_q;
|
|
||||||
extern QueueHandle_t ui_event_manager_q;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /*__THREAD_COMMON_H_*/
|
#endif /*__THREAD_COMMON_H_*/
|
||||||
|
|||||||
88
source/shoh/src/threads/logging/Log.h
Normal file
88
source/shoh/src/threads/logging/Log.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#ifndef __THREAD_COMMON_LOG_H_
|
||||||
|
#define __THREAD_COMMON_LOG_H_
|
||||||
|
|
||||||
|
#include "chip.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "queue.h"
|
||||||
|
|
||||||
|
extern QueueHandle_t logging_queue;
|
||||||
|
|
||||||
|
/* ================= Settings ================== */
|
||||||
|
#define LOG_COLORED_OUTPUT
|
||||||
|
#define HIGH_PRIORITY_DEBUG
|
||||||
|
#define LOG_DEBUG_MESSAGES 1
|
||||||
|
/* ================= Settings ================== */
|
||||||
|
|
||||||
|
// internal debug defines
|
||||||
|
#ifdef HIGH_PRIORITY_DEBUG
|
||||||
|
#include <assert.h>
|
||||||
|
#define INT_ASSERT(statement) assert(statement)
|
||||||
|
#else
|
||||||
|
#define INT_ASSERT(statement)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOG_COLORED_OUTPUT
|
||||||
|
#define C_INFO "\x1b[34mINFO\x1b[0m"
|
||||||
|
#define C_DEBUG "\x1b[35mDEBUG\x1b[0m"
|
||||||
|
#define C_WARN "\x1b[33mWARNING\x1b[0m"
|
||||||
|
#define C_ERROR "\x1b[31mERROR\x1b[0m"
|
||||||
|
#else
|
||||||
|
#define C_INFO "INFO"
|
||||||
|
#define C_DEBUG "DEBUG"
|
||||||
|
#define C_WARN "WARNING"
|
||||||
|
#define C_ERROR "ERROR"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LOG_BUFFER_MAX_CAP 256
|
||||||
|
#define LOG_MESSAGE_MAX_CAP 150
|
||||||
|
|
||||||
|
#define _LOG_STREAMOUT(message, message_length) \
|
||||||
|
INT_ASSERT(message_length > 0); \
|
||||||
|
if (logging_queue) { \
|
||||||
|
xQueueSend(logging_queue, (void*)message, portMAX_DELAY); \
|
||||||
|
}
|
||||||
|
|
||||||
|
static void create_log_line(const char * _status,
|
||||||
|
const char * _location,
|
||||||
|
const size_t _line,
|
||||||
|
const char * _fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, _fmt);
|
||||||
|
char message [LOG_BUFFER_MAX_CAP] = {0};
|
||||||
|
int message_len = vsnprintf(message, LOG_BUFFER_MAX_CAP, _fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
char buffer [LOG_BUFFER_MAX_CAP] = {0};
|
||||||
|
int buffer_len = snprintf(buffer, LOG_BUFFER_MAX_CAP,
|
||||||
|
"[%s] [File: %s] [Line: %d] %.*s",
|
||||||
|
_status,
|
||||||
|
_location,
|
||||||
|
_line,
|
||||||
|
message_len,
|
||||||
|
message);
|
||||||
|
_LOG_STREAMOUT(buffer, buffer_len)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define LOG_INFO(fmt, ...) \
|
||||||
|
create_log_line(C_INFO, __FILE__, __LINE__, fmt, ##__VA_ARGS__);
|
||||||
|
|
||||||
|
#define LOG_WARNING(fmt, ...) \
|
||||||
|
create_log_line(C_WARN, __FILE__, __LINE__, fmt, ##__VA_ARGS__);
|
||||||
|
|
||||||
|
#define LOG_ERROR(fmt, ...) \
|
||||||
|
create_log_line(C_ERROR, __FILE__, __LINE__, fmt, ##__VA_ARGS__);
|
||||||
|
|
||||||
|
#if LOG_DEBUG_MESSAGES
|
||||||
|
#define LOG_DEBUG(fmt, ...) \
|
||||||
|
create_log_line(C_DEBUG, __FILE__, __LINE__, fmt, ##__VA_ARGS__);
|
||||||
|
#else
|
||||||
|
#define LOG_DEBUG(fmt, ...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __THREAD_COMMON_LOG_H_ */
|
||||||
38
source/shoh/src/threads/logging/Logging.cpp
Normal file
38
source/shoh/src/threads/logging/Logging.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Logging.cpp
|
||||||
|
*
|
||||||
|
* Created on: 12 May 2023
|
||||||
|
* Author: tylen
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Logging.h"
|
||||||
|
#include "ThreadCommon.h"
|
||||||
|
#include "Log.h"
|
||||||
|
#include "queue.h"
|
||||||
|
|
||||||
|
Logging::Logging(ThreadCommon::QueueManager * qm) : _qm(qm) {
|
||||||
|
q = _qm->getQueue(ThreadCommon::QueueManager::logging_message_all);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging::~Logging() {
|
||||||
|
// TODO Auto-generated destructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logging::taskFunction()
|
||||||
|
{
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
char data[LOG_BUFFER_MAX_CAP] = {0};
|
||||||
|
xQueueReceive(q, static_cast<char*>(data), portMAX_DELAY);
|
||||||
|
mutex.lock();
|
||||||
|
printf("%s\n", data);
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void thread_logging(void* pvParams)
|
||||||
|
{
|
||||||
|
ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams);
|
||||||
|
Logging log(manager->qm);
|
||||||
|
log.taskFunction();
|
||||||
|
}
|
||||||
27
source/shoh/src/threads/logging/Logging.h
Normal file
27
source/shoh/src/threads/logging/Logging.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Logging.h
|
||||||
|
*
|
||||||
|
* Created on: 12 May 2023
|
||||||
|
* Author: tylen
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef THREADS_LOGGING_LOGGING_H_
|
||||||
|
#define THREADS_LOGGING_LOGGING_H_
|
||||||
|
|
||||||
|
#include "Fmutex.h"
|
||||||
|
#include "ThreadCommon.h"
|
||||||
|
|
||||||
|
class Logging {
|
||||||
|
public:
|
||||||
|
Logging(ThreadCommon::QueueManager * qm);
|
||||||
|
virtual ~Logging();
|
||||||
|
void taskFunction();
|
||||||
|
private:
|
||||||
|
ThreadCommon::QueueManager * _qm;
|
||||||
|
QueueHandle_t q;
|
||||||
|
Fmutex mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
void thread_logging(void* pvParams);
|
||||||
|
|
||||||
|
#endif /* THREADS_LOGGING_LOGGING_H_ */
|
||||||
@ -7,15 +7,17 @@
|
|||||||
|
|
||||||
#include "Manager.h"
|
#include "Manager.h"
|
||||||
#include "ThreadCommon.h"
|
#include "ThreadCommon.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
Manager::Manager(ThreadCommon::QueueManager* qm)
|
Manager::Manager(ThreadCommon::QueueManager* qm)
|
||||||
: _qm(qm), _menu{qm}
|
: _qm(qm), _menu{qm}
|
||||||
{
|
{
|
||||||
|
LOG_DEBUG("Creating Manager");
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::~Manager()
|
Manager::~Manager()
|
||||||
{
|
{
|
||||||
// TODO Auto-generated destructor stub
|
LOG_ERROR("Deleting Manager");
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::EventPair Manager::parseEvent(Event* e)
|
Event::EventPair Manager::parseEvent(Event* e)
|
||||||
@ -32,6 +34,7 @@ Event::EventPair Manager::parseEvent(Event* e)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOG_WARNING("Event is empty");
|
||||||
return {ERROR_RETURN, Event::Null};
|
return {ERROR_RETURN, Event::Null};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +52,7 @@ void Manager::taskFunction()
|
|||||||
|
|
||||||
void thread_manager(void* pvParams)
|
void thread_manager(void* pvParams)
|
||||||
{
|
{
|
||||||
Manager m(static_cast<ThreadCommon::QueueManager*>(pvParams));
|
ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams);
|
||||||
|
Manager m(manager->qm);
|
||||||
m.taskFunction();
|
m.taskFunction();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,12 +8,14 @@
|
|||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
Menu::Menu(ThreadCommon::QueueManager* qm): _qm(qm),
|
Menu::Menu(ThreadCommon::QueueManager* qm): _qm(qm),
|
||||||
current(&Menu::sInitView), ext_temp(-99, 99, 1), set_point(-99, 99, 1),
|
current(&Menu::sInitView), ext_temp(-99, 99, 1), set_point(-99, 99, 1),
|
||||||
main_text ("CURRENT %3d DESIRED %3d "),
|
main_text ("CURRENT %3d DESIRED %3d "),
|
||||||
set_point_text("CURRENT %3d DESIRED[%3d] ")
|
set_point_text("CURRENT %3d DESIRED[%3d] ")
|
||||||
{
|
{
|
||||||
|
LOG_DEBUG("Creating Menu");
|
||||||
this->SetState(&Menu::sInitView);
|
this->SetState(&Menu::sInitView);
|
||||||
ext_temp.setCurrent(0);
|
ext_temp.setCurrent(0);
|
||||||
set_point.setCurrent(0);
|
set_point.setCurrent(0);
|
||||||
@ -21,6 +23,7 @@ set_point_text("CURRENT %3d DESIRED[%3d] ")
|
|||||||
|
|
||||||
Menu::~Menu()
|
Menu::~Menu()
|
||||||
{
|
{
|
||||||
|
LOG_DEBUG("Deleting Menu");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::HandleEventPair (Event::EventPair *ep)
|
void Menu::HandleEventPair (Event::EventPair *ep)
|
||||||
@ -71,10 +74,11 @@ void Menu::sInitView(const MenuObjEvent &e)
|
|||||||
switch (e.type)
|
switch (e.type)
|
||||||
{
|
{
|
||||||
case MenuObjEvent::eFocus:
|
case MenuObjEvent::eFocus:
|
||||||
|
LOG_DEBUG("enter sInitView");
|
||||||
this->NotifyAndRefreshUI("Loading...");
|
this->NotifyAndRefreshUI("Loading...");
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eUnFocus:
|
case MenuObjEvent::eUnFocus:
|
||||||
printf("NOTE: leave sInitView\n");
|
LOG_DEBUG("leave sInitView");
|
||||||
this->NotifyAndRefreshUI("");
|
this->NotifyAndRefreshUI("");
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eRollClockWise:
|
case MenuObjEvent::eRollClockWise:
|
||||||
@ -82,10 +86,11 @@ void Menu::sInitView(const MenuObjEvent &e)
|
|||||||
case MenuObjEvent::eRollCClockWise:
|
case MenuObjEvent::eRollCClockWise:
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eClick:
|
case MenuObjEvent::eClick:
|
||||||
|
LOG_DEBUG("click sInitView");
|
||||||
this->SetState(&Menu::sMainView);
|
this->SetState(&Menu::sMainView);
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eRefresh:
|
case MenuObjEvent::eRefresh:
|
||||||
printf("NOTE: sInitView handled eRefresh.\n");
|
LOG_DEBUG("refersh sInitView");
|
||||||
this->SetState(&Menu::sMainView);
|
this->SetState(&Menu::sMainView);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -99,11 +104,13 @@ void Menu::sMainView(const MenuObjEvent &e)
|
|||||||
switch (e.type)
|
switch (e.type)
|
||||||
{
|
{
|
||||||
case MenuObjEvent::eFocus:
|
case MenuObjEvent::eFocus:
|
||||||
|
LOG_DEBUG("enter sMainView");
|
||||||
sprintf(screen_text, main_text, this->ext_temp.getCurrent(),
|
sprintf(screen_text, main_text, this->ext_temp.getCurrent(),
|
||||||
this->set_point.getCurrent());
|
this->set_point.getCurrent());
|
||||||
this->NotifyAndRefreshUI(screen_text);
|
this->NotifyAndRefreshUI(screen_text);
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eUnFocus:
|
case MenuObjEvent::eUnFocus:
|
||||||
|
LOG_DEBUG("leave sMainView");
|
||||||
this->NotifyAndRefreshUI("");
|
this->NotifyAndRefreshUI("");
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eRollClockWise:
|
case MenuObjEvent::eRollClockWise:
|
||||||
@ -111,11 +118,13 @@ void Menu::sMainView(const MenuObjEvent &e)
|
|||||||
case MenuObjEvent::eRollCClockWise:
|
case MenuObjEvent::eRollCClockWise:
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eClick:
|
case MenuObjEvent::eClick:
|
||||||
|
LOG_DEBUG("click sMainView");
|
||||||
this->SetState(&Menu::sSetPointMod);
|
this->SetState(&Menu::sSetPointMod);
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eRefresh:
|
case MenuObjEvent::eRefresh:
|
||||||
sprintf(screen_text, main_text, this->ext_temp.getCurrent(),
|
sprintf(screen_text, main_text, this->ext_temp.getCurrent(),
|
||||||
this->set_point.getCurrent());
|
this->set_point.getCurrent());
|
||||||
|
LOG_DEBUG("refresh sMainView");
|
||||||
this->NotifyAndRefreshUI(screen_text);
|
this->NotifyAndRefreshUI(screen_text);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -129,11 +138,13 @@ void Menu::sSetPointMod(const MenuObjEvent &e)
|
|||||||
switch (e.type)
|
switch (e.type)
|
||||||
{
|
{
|
||||||
case MenuObjEvent::eFocus:
|
case MenuObjEvent::eFocus:
|
||||||
|
LOG_DEBUG("enter sSetPointMod");
|
||||||
sprintf(screen_text, set_point_text, this->ext_temp.getCurrent(),
|
sprintf(screen_text, set_point_text, this->ext_temp.getCurrent(),
|
||||||
this->set_point.getCurrent());
|
this->set_point.getCurrent());
|
||||||
this->NotifyAndRefreshUI(screen_text);
|
this->NotifyAndRefreshUI(screen_text);
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eUnFocus:
|
case MenuObjEvent::eUnFocus:
|
||||||
|
LOG_DEBUG("leave sSetPointMod");
|
||||||
this->NotifyAndRefreshUI("");
|
this->NotifyAndRefreshUI("");
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eRollClockWise:
|
case MenuObjEvent::eRollClockWise:
|
||||||
@ -149,9 +160,11 @@ void Menu::sSetPointMod(const MenuObjEvent &e)
|
|||||||
this->NotifyAndRefreshUI(screen_text);
|
this->NotifyAndRefreshUI(screen_text);
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eClick:
|
case MenuObjEvent::eClick:
|
||||||
|
LOG_DEBUG("click sSetPointMod");
|
||||||
this->SetState(&Menu::sMainView);
|
this->SetState(&Menu::sMainView);
|
||||||
break;
|
break;
|
||||||
case MenuObjEvent::eRefresh:
|
case MenuObjEvent::eRefresh:
|
||||||
|
LOG_DEBUG("refresh sSetPointMod");
|
||||||
sprintf(screen_text, set_point_text, this->ext_temp.getCurrent(),
|
sprintf(screen_text, set_point_text, this->ext_temp.getCurrent(),
|
||||||
this->set_point.getCurrent());
|
this->set_point.getCurrent());
|
||||||
this->NotifyAndRefreshUI(screen_text);
|
this->NotifyAndRefreshUI(screen_text);
|
||||||
|
|||||||
@ -6,6 +6,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Master.h"
|
#include "Master.h"
|
||||||
|
#include "Log.h"
|
||||||
|
#include "ThreadCommon.h"
|
||||||
|
#include "Rotary.h"
|
||||||
|
#include "Manager.h"
|
||||||
|
#include "Logging.h"
|
||||||
|
#include "UserInterface.h"
|
||||||
|
#include "queue.h"
|
||||||
|
#include "Logging.h"
|
||||||
|
|
||||||
static const char* rotary_direction[] =
|
static const char* rotary_direction[] =
|
||||||
{
|
{
|
||||||
@ -15,9 +23,11 @@ static const char* rotary_direction[] =
|
|||||||
"Idle"
|
"Idle"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QueueHandle_t logging_queue;
|
||||||
|
|
||||||
Master::Master(ThreadCommon::QueueManager* qm) : _qm(qm)
|
Master::Master(ThreadCommon::QueueManager* qm) : _qm(qm)
|
||||||
{
|
{
|
||||||
|
LOG_DEBUG("Creating Master");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Master::HandleEventType(Event* e, Event::EventType type)
|
void Master::HandleEventType(Event* e, Event::EventType type)
|
||||||
@ -29,6 +39,7 @@ void Master::HandleEventType(Event* e, Event::EventType type)
|
|||||||
case Event::Rotary:
|
case Event::Rotary:
|
||||||
//Comes from rotary, goes to manager
|
//Comes from rotary, goes to manager
|
||||||
_qm->send<Event>(ThreadCommon::QueueManager::manager_event_master, e, 0);
|
_qm->send<Event>(ThreadCommon::QueueManager::manager_event_master, e, 0);
|
||||||
|
LOG_DEBUG("Rotary: %s has been forwarded to manager", rotary_direction[e->getDataOf(type)]);
|
||||||
break;
|
break;
|
||||||
case Event::InternalTemp:
|
case Event::InternalTemp:
|
||||||
// TODO remove (deprecated)
|
// TODO remove (deprecated)
|
||||||
@ -37,10 +48,12 @@ void Master::HandleEventType(Event* e, Event::EventType type)
|
|||||||
//Comes from sensors, goes to relay & manager
|
//Comes from sensors, goes to relay & manager
|
||||||
_qm->send<Event>(ThreadCommon::QueueManager::relay_event_master, e, 0);
|
_qm->send<Event>(ThreadCommon::QueueManager::relay_event_master, e, 0);
|
||||||
_qm->send<Event>(ThreadCommon::QueueManager::manager_event_master, e, 0);
|
_qm->send<Event>(ThreadCommon::QueueManager::manager_event_master, e, 0);
|
||||||
|
LOG_DEBUG("ExtTemp: %d has been forwarded to manager and relay", e->getDataOf(type));
|
||||||
break;
|
break;
|
||||||
case Event::SetPoint:
|
case Event::SetPoint:
|
||||||
//Comes from manager, goes to relay
|
//Comes from manager, goes to relay
|
||||||
_qm->send<Event>(ThreadCommon::QueueManager::relay_event_master, e, 0);
|
_qm->send<Event>(ThreadCommon::QueueManager::relay_event_master, e, 0);
|
||||||
|
LOG_DEBUG("SetPoint: %d has been forwarded to relay", e->getDataOf(type));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
@ -71,6 +84,43 @@ void Master::taskFunction() {
|
|||||||
|
|
||||||
|
|
||||||
void thread_master(void* pvParams) {
|
void thread_master(void* pvParams) {
|
||||||
Master m(static_cast<ThreadCommon::QueueManager*>(pvParams));
|
ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams);
|
||||||
|
|
||||||
|
manager->qm->createQueue(5,
|
||||||
|
LOG_BUFFER_MAX_CAP,
|
||||||
|
ThreadCommon::QueueManager::logging_message_all);
|
||||||
|
logging_queue = manager->qm->getQueue(ThreadCommon::QueueManager::logging_message_all);
|
||||||
|
manager->tm->createTask(thread_logging, "logging",
|
||||||
|
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
||||||
|
static_cast<void*>(manager));
|
||||||
|
|
||||||
|
LOG_INFO("Logging Active");
|
||||||
|
LOG_INFO("Started the real time kernel with preemption");
|
||||||
|
LOG_INFO("Master Started");
|
||||||
|
Master m(manager->qm);
|
||||||
|
LOG_INFO("Master is creating queues");
|
||||||
|
manager->qm->createQueue(100,
|
||||||
|
sizeof(Event),
|
||||||
|
ThreadCommon::QueueManager::master_event_all);
|
||||||
|
manager->qm->createQueue(20,
|
||||||
|
sizeof(Event),
|
||||||
|
ThreadCommon::QueueManager::manager_event_master);
|
||||||
|
manager->qm->createQueue(20,
|
||||||
|
sizeof(UserInterface::InterfaceWithData),
|
||||||
|
ThreadCommon::QueueManager::ui_event_manager);
|
||||||
|
LOG_INFO("Master created queues");
|
||||||
|
|
||||||
|
|
||||||
|
LOG_INFO("Master is creating tasks");
|
||||||
|
manager->tm->createTask(thread_manager, "manager",
|
||||||
|
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
||||||
|
static_cast<void*>(manager));
|
||||||
|
manager->tm->createTask(thread_rotary, "rotary",
|
||||||
|
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
||||||
|
static_cast<void*>(manager));
|
||||||
|
manager->tm->createTask(thread_user_interface, "user_interface",
|
||||||
|
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
||||||
|
static_cast<void*>(manager));
|
||||||
|
LOG_INFO("Master created tasks");
|
||||||
m.taskFunction();
|
m.taskFunction();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
#include "ThreadCommon.h"
|
#include "ThreadCommon.h"
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
#include "Rotary.h"
|
#include "Rotary.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
static QueueHandle_t * p_rotary_isr_q;
|
static QueueHandle_t * p_rotary_isr_q;
|
||||||
|
|
||||||
@ -20,6 +21,10 @@ extern "C"
|
|||||||
portBASE_TYPE xHigherPriorityWoken = pdFALSE;
|
portBASE_TYPE xHigherPriorityWoken = pdFALSE;
|
||||||
uint8_t data = ThreadCommon::RotaryAction::Right;
|
uint8_t data = ThreadCommon::RotaryAction::Right;
|
||||||
xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken);
|
xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken);
|
||||||
|
if(!xHigherPriorityWoken)
|
||||||
|
{
|
||||||
|
LOG_WARNING("[PIN_INT0_IRQn] portEND_SWITCHING_ISR called with False value");
|
||||||
|
}
|
||||||
portEND_SWITCHING_ISR(xHigherPriorityWoken);
|
portEND_SWITCHING_ISR(xHigherPriorityWoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +35,10 @@ extern "C"
|
|||||||
portBASE_TYPE xHigherPriorityWoken = pdFALSE;
|
portBASE_TYPE xHigherPriorityWoken = pdFALSE;
|
||||||
uint8_t data = ThreadCommon::RotaryAction::Left;
|
uint8_t data = ThreadCommon::RotaryAction::Left;
|
||||||
xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken);
|
xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken);
|
||||||
|
if(!xHigherPriorityWoken)
|
||||||
|
{
|
||||||
|
LOG_WARNING("[PIN_INT1_IRQn] portEND_SWITCHING_ISR called with False value");
|
||||||
|
}
|
||||||
portEND_SWITCHING_ISR(xHigherPriorityWoken);
|
portEND_SWITCHING_ISR(xHigherPriorityWoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,16 +49,23 @@ extern "C"
|
|||||||
portBASE_TYPE xHigherPriorityWoken = pdFALSE;
|
portBASE_TYPE xHigherPriorityWoken = pdFALSE;
|
||||||
uint8_t data = ThreadCommon::RotaryAction::Press;
|
uint8_t data = ThreadCommon::RotaryAction::Press;
|
||||||
xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken);
|
xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken);
|
||||||
|
if(!xHigherPriorityWoken)
|
||||||
|
{
|
||||||
|
LOG_WARNING("[PIN_INT2_IRQn] portEND_SWITCHING_ISR called with False value");
|
||||||
|
}
|
||||||
portEND_SWITCHING_ISR(xHigherPriorityWoken);
|
portEND_SWITCHING_ISR(xHigherPriorityWoken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rotary::Rotary(ThreadCommon::QueueManager* qm) : _qm(qm)
|
Rotary::Rotary(ThreadCommon::QueueManager* qm) : _qm(qm)
|
||||||
{
|
{
|
||||||
|
LOG_DEBUG("Creating Rotary");
|
||||||
}
|
}
|
||||||
|
|
||||||
Rotary::~Rotary() {}
|
Rotary::~Rotary()
|
||||||
|
{
|
||||||
|
LOG_ERROR("Deleting Rotary");
|
||||||
|
}
|
||||||
|
|
||||||
void Rotary::taskFunction()
|
void Rotary::taskFunction()
|
||||||
{
|
{
|
||||||
@ -70,6 +86,7 @@ void thread_rotary(void* pvParams)
|
|||||||
QueueHandle_t rotary_isr_q = xQueueCreate(15, sizeof(char));
|
QueueHandle_t rotary_isr_q = xQueueCreate(15, sizeof(char));
|
||||||
p_rotary_isr_q = &rotary_isr_q;
|
p_rotary_isr_q = &rotary_isr_q;
|
||||||
|
|
||||||
Rotary r(static_cast<ThreadCommon::QueueManager*>(pvParams));
|
ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams);
|
||||||
|
Rotary r(manager->qm);
|
||||||
r.taskFunction();
|
r.taskFunction();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,16 +5,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
|
#include "Log.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
UserInterface::UserInterface(ThreadCommon::QueueManager* qm) :
|
UserInterface::UserInterface(ThreadCommon::QueueManager* qm) :
|
||||||
_qm(qm), lcd1(nullptr)
|
_qm(qm), lcd1(nullptr)
|
||||||
{
|
{
|
||||||
|
LOG_DEBUG("Creating UserInterface");
|
||||||
this->initLCD1();
|
this->initLCD1();
|
||||||
}
|
}
|
||||||
|
|
||||||
UserInterface::~UserInterface()
|
UserInterface::~UserInterface()
|
||||||
{
|
{
|
||||||
|
LOG_ERROR("Deleting UserInterface");
|
||||||
delete this->lcd1;
|
delete this->lcd1;
|
||||||
delete this->lcd1_rs;
|
delete this->lcd1_rs;
|
||||||
delete this->lcd1_en;
|
delete this->lcd1_en;
|
||||||
@ -45,7 +48,7 @@ void UserInterface::handleEvent(InterfaceWithData* ui_data)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//Should never happen.
|
//Should never happen.
|
||||||
printf("WARNING: [UserInterface::handleEvent] executed default case.\n");
|
LOG_ERROR("[UserInterface::handleEvent] executed default case");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,13 +60,16 @@ void UserInterface::handleEvent(InterfaceWithData* ui_data)
|
|||||||
void UserInterface::handleLCD(LiquidCrystal *lcd, const char *str)
|
void UserInterface::handleLCD(LiquidCrystal *lcd, const char *str)
|
||||||
{
|
{
|
||||||
//Interpret empty string as clear.
|
//Interpret empty string as clear.
|
||||||
if(!strlen(str))
|
if(!strlen(str)){
|
||||||
lcd->clear();
|
lcd->clear();
|
||||||
|
LOG_DEBUG("Clear up LCD");
|
||||||
//Print the text otherwise.
|
//Print the text otherwise.
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lcd->setCursor(0, 0);
|
lcd->setCursor(0, 0);
|
||||||
lcd->print(str);
|
lcd->print(str);
|
||||||
|
LOG_DEBUG("Printing [%s] on LCD", str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +98,7 @@ void UserInterface::initLCD1()
|
|||||||
|
|
||||||
void thread_user_interface(void* pvParams)
|
void thread_user_interface(void* pvParams)
|
||||||
{
|
{
|
||||||
UserInterface ui(static_cast<ThreadCommon::QueueManager*>(pvParams));
|
ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams);
|
||||||
|
UserInterface ui(manager->qm);
|
||||||
ui.taskFunction();
|
ui.taskFunction();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user