forked from itead/ITEADLIB_Arduino_Nextion
-
Notifications
You must be signed in to change notification settings - Fork 1
/
NexObject.cpp
97 lines (89 loc) · 2.19 KB
/
NexObject.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* @file NexObject.cpp
*
* The implementation of class NexObject.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexObject.h"
NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name, void *value)
{
this->__pid = pid;
this->__cid = cid;
this->__name = name;
this->__value = value;
}
void NexObject::setObjValue(uint8_t type, void *value)
{
uint8_t i = 0;
if (__value)
{
switch (type)
{
case NEX_EVENT_VALUE:
*((unsigned long *)__value) = (((uint8_t *)value)[0]) | (((unsigned long)((uint8_t *)value)[1]) << 8) | (((unsigned long)((uint8_t *)value)[2]) << 16) | (((unsigned long)((uint8_t *)value)[3]) << 24);
break;
case NEX_EVENT_STRING:
//while (*((unsigned char *)(value+i)) != 0)
//{
// *((unsigned char *)(__value+i)) = *((unsigned char *)(value+i));
// i++;
//}
break;
default:
//*(__value) = 0;
break;
}
}
}
uint8_t NexObject::getObjPid(void)
{
return __pid;
}
uint8_t NexObject::getObjCid(void)
{
return __cid;
}
const char* NexObject::getObjName(void)
{
return __name;
}
void * NexObject::getObjValue(void)
{
return __value;
}
void NexObject::printObjInfo(void)
{
dbSerialPrint("[");
dbSerialPrint((uint32_t)this);
dbSerialPrint(":");
dbSerialPrint(__pid);
dbSerialPrint(",");
dbSerialPrint(__cid);
dbSerialPrint(",");
if (__name)
{
dbSerialPrint(__name);
}
else
{
dbSerialPrint("(null)");
}
dbSerialPrint(",");
if (__value)
{
dbSerialPrint((uint32_t)__value);
}
else
{
dbSerialPrint("(null)");
}
dbSerialPrintln("]");
}