NexObject.h 1.88 KB
Newer Older
MagoKimbra's avatar
MagoKimbra committed
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
/**
 * @file NexObject.h
 *
 * The definition 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.
 */
#ifndef __NEXOBJECT_H__
#define __NEXOBJECT_H__

#include <Arduino.h>
#include "NexConfig.h"

/**
 * @addtogroup CoreAPI 
 * @{ 
 */

/**
 * Root class of all Nextion components. 
 *
 * Provides the essential attributes of a Nextion component and the methods accessing
 * them. At least, Page ID(pid), Component ID(pid) and an unique name are needed for
 * creating a component in Nexiton library. 
 */
class NexObject 
{
public: /* methods */

    /**
     * Constructor. 
     *
     * @param pid - page id. 
     * @param cid - component id.    
     * @param name - pointer to an unique name in range of all components. 
     */
    NexObject(uint8_t pid, uint8_t cid, const char *name);

    /**
     * Print current object'address, page id, component id and name. 
     *
     * @warning this method does nothing, unless debug message enabled. 
     */
    void printObjInfo(void);

protected: /* methods */

    /*
     * Get page id.
     *
MagoKimbra's avatar
MagoKimbra committed
59
     * @return the id of page.
MagoKimbra's avatar
MagoKimbra committed
60
     */
MagoKimbra's avatar
MagoKimbra committed
61
    uint8_t getObjPid(void);
MagoKimbra's avatar
MagoKimbra committed
62 63 64 65

    /*
     * Get component id.
     *
MagoKimbra's avatar
MagoKimbra committed
66
     * @return the id of component.
MagoKimbra's avatar
MagoKimbra committed
67 68 69 70 71 72
     */
    uint8_t getObjCid(void);

    /*
     * Get component name.
     *
MagoKimbra's avatar
MagoKimbra committed
73
     * @return the name of component.
MagoKimbra's avatar
MagoKimbra committed
74
     */
MagoKimbra's avatar
MagoKimbra committed
75 76 77
    const char *getObjName(void);

private: /* data */
MagoKimbra's avatar
MagoKimbra committed
78 79 80 81 82 83 84 85 86
    uint8_t __pid; /* Page ID */
    uint8_t __cid; /* Component ID */
    const char *__name; /* An unique name */
};
/**
 * @}
 */

#endif /* #ifndef __NEXOBJECT_H__ */