This library is for the control of NJE-105/106. (which is the digital signage device made by Nagano Japan Radio Co., Ltd.)

Dependents:   NJE10XCtrlSample TrainInfoSample

Committer:
rinosh2
Date:
Tue Nov 16 16:56:04 2010 +0000
Revision:
1:fb1109a73ce9
Parent:
0:3aa62049d1de
Delete debug print at the message sending.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rinosh2 1:fb1109a73ce9 1 ///////////////////////////////////////////////////////////////////////////////
rinosh2 1:fb1109a73ce9 2 // NJE10XCtrl: NJE-105/106 control lib by rinos 2010
rinosh2 1:fb1109a73ce9 3 ///////////////////////////////////////////////////////////////////////////////
rinosh2 1:fb1109a73ce9 4
rinosh2 1:fb1109a73ce9 5 #ifndef __NJE10XCTRL_H__
rinosh2 1:fb1109a73ce9 6 #define __NJE10XCTRL_H__
rinosh2 1:fb1109a73ce9 7
rinosh2 0:3aa62049d1de 8 #include "mbed.h"
rinosh2 0:3aa62049d1de 9
rinosh2 0:3aa62049d1de 10 ////////////////////////////////////////////////////////////////////////////////
rinosh2 0:3aa62049d1de 11 // NJE10XCtrl Lib
rinosh2 0:3aa62049d1de 12
rinosh2 0:3aa62049d1de 13 class NJE10XCtrl {
rinosh2 1:fb1109a73ce9 14 // defines /////////////////////////////////////////////////////////////////
rinosh2 0:3aa62049d1de 15 public:
rinosh2 1:fb1109a73ce9 16 // Attributes
rinosh2 1:fb1109a73ce9 17 typedef enum {
rinosh2 1:fb1109a73ce9 18 ATTR_GREEN,
rinosh2 1:fb1109a73ce9 19 ATTR_RED,
rinosh2 1:fb1109a73ce9 20 ATTR_YELLOW,
rinosh2 1:fb1109a73ce9 21 } Attr1;
rinosh2 0:3aa62049d1de 22
rinosh2 1:fb1109a73ce9 23 typedef enum {
rinosh2 1:fb1109a73ce9 24 ATTR_SCROLL,
rinosh2 1:fb1109a73ce9 25 ATTR_SCROLL_R,
rinosh2 1:fb1109a73ce9 26 ATTR_STOP,
rinosh2 1:fb1109a73ce9 27 ATTR_FIX,
rinosh2 1:fb1109a73ce9 28 } Attr2;
rinosh2 0:3aa62049d1de 29
rinosh2 1:fb1109a73ce9 30 typedef enum {
rinosh2 1:fb1109a73ce9 31 ATTR_NORMAL,
rinosh2 1:fb1109a73ce9 32 ATTR_BLINK,
rinosh2 1:fb1109a73ce9 33 ATTR_REVERSE,
rinosh2 1:fb1109a73ce9 34 ATTR_BLINK_REVERSE,
rinosh2 1:fb1109a73ce9 35 } Attr3;
rinosh2 1:fb1109a73ce9 36
rinosh2 1:fb1109a73ce9 37 // NJE command parameter
rinosh2 1:fb1109a73ce9 38 typedef enum {
rinosh2 1:fb1109a73ce9 39 OP_NORMAL,
rinosh2 1:fb1109a73ce9 40 OP_AUTO,
rinosh2 1:fb1109a73ce9 41 OP_POWERSAVE,
rinosh2 1:fb1109a73ce9 42 } OpMode;
rinosh2 0:3aa62049d1de 43
rinosh2 1:fb1109a73ce9 44 typedef enum {
rinosh2 1:fb1109a73ce9 45 FREEMODE_ON,
rinosh2 1:fb1109a73ce9 46 FREEMODE_OFF,
rinosh2 1:fb1109a73ce9 47 } FreeMode;
rinosh2 0:3aa62049d1de 48
rinosh2 1:fb1109a73ce9 49 typedef enum {
rinosh2 1:fb1109a73ce9 50 SCROLL_SLOW,
rinosh2 1:fb1109a73ce9 51 SCROLL_MIDDLE,
rinosh2 1:fb1109a73ce9 52 SCROLL_FAST,
rinosh2 1:fb1109a73ce9 53 } ScrollSpeed;
rinosh2 0:3aa62049d1de 54
rinosh2 1:fb1109a73ce9 55 typedef enum {
rinosh2 1:fb1109a73ce9 56 BLINK_OFF,
rinosh2 1:fb1109a73ce9 57 BLINK_SLOW,
rinosh2 1:fb1109a73ce9 58 BLINK_MIDDLE,
rinosh2 1:fb1109a73ce9 59 BLINK_FAST,
rinosh2 1:fb1109a73ce9 60 } BlinkSpeed;
rinosh2 0:3aa62049d1de 61
rinosh2 1:fb1109a73ce9 62 // error code
rinosh2 1:fb1109a73ce9 63 typedef enum {
rinosh2 1:fb1109a73ce9 64 S_OK,
rinosh2 1:fb1109a73ce9 65 S_WRITE_FAILED,
rinosh2 1:fb1109a73ce9 66 S_BUFFER_OVERFLOW,
rinosh2 1:fb1109a73ce9 67 S_INVALID_ID,
rinosh2 1:fb1109a73ce9 68 S_INVALID_PARAM,
rinosh2 1:fb1109a73ce9 69
rinosh2 1:fb1109a73ce9 70 S_NOT_SUPPORT, // not yet...
rinosh2 1:fb1109a73ce9 71 } Status;
rinosh2 0:3aa62049d1de 72
rinosh2 0:3aa62049d1de 73 private:
rinosh2 1:fb1109a73ce9 74 static const int MAX_DATA_BUF = 128;
rinosh2 1:fb1109a73ce9 75
rinosh2 1:fb1109a73ce9 76 Serial m_port;
rinosh2 1:fb1109a73ce9 77 char m_buf[MAX_DATA_BUF + 1];
rinosh2 1:fb1109a73ce9 78 int m_size;
rinosh2 1:fb1109a73ce9 79
rinosh2 0:3aa62049d1de 80
rinosh2 1:fb1109a73ce9 81 // internal funcs
rinosh2 1:fb1109a73ce9 82 Status sendCmd(const char* str);
rinosh2 1:fb1109a73ce9 83 Status sendCmd(const char* str, int len);
rinosh2 0:3aa62049d1de 84
rinosh2 1:fb1109a73ce9 85 // Invalid method
rinosh2 1:fb1109a73ce9 86 protected:
rinosh2 1:fb1109a73ce9 87 NJE10XCtrl(const NJE10XCtrl& v);
rinosh2 1:fb1109a73ce9 88 const NJE10XCtrl& operator =(const NJE10XCtrl& v);
rinosh2 0:3aa62049d1de 89
rinosh2 0:3aa62049d1de 90 public:
rinosh2 1:fb1109a73ce9 91 NJE10XCtrl(PinName tx_pin = p9, PinName rx_pin = p10);
rinosh2 1:fb1109a73ce9 92 ~NJE10XCtrl();
rinosh2 1:fb1109a73ce9 93
rinosh2 1:fb1109a73ce9 94 // Append Str/Attr to the internal buffer //////////////////////////////////
rinosh2 1:fb1109a73ce9 95 Status add(char ch); // append char to the internal buffer
rinosh2 1:fb1109a73ce9 96 Status add(const char* str); // append string to the internal buffer
rinosh2 1:fb1109a73ce9 97 Status addAttr(Attr1 a1 = ATTR_GREEN, Attr2 a2 = ATTR_SCROLL, Attr3 a3 = ATTR_NORMAL);
rinosh2 1:fb1109a73ce9 98 Status clear(); // clear internal buffer
rinosh2 1:fb1109a73ce9 99 int size() const { return m_size; }
rinosh2 1:fb1109a73ce9 100 int left() const { return MAX_DATA_BUF - m_size; }
rinosh2 1:fb1109a73ce9 101
rinosh2 1:fb1109a73ce9 102 // Set/Del Normal message (01-99) //////////////////////////////////////////
rinosh2 1:fb1109a73ce9 103 Status setMessage(int id, const char* msg = 0, // use internal buffer if msg is NULL
rinosh2 1:fb1109a73ce9 104 Attr1 a1 = ATTR_GREEN, Attr2 a2 = ATTR_SCROLL, Attr3 a3 = ATTR_NORMAL);
rinosh2 1:fb1109a73ce9 105 Status delMessage(int id); // del message (1 to 99)
rinosh2 1:fb1109a73ce9 106 Status setTitle(const char* msg = 0); // use internal buffer if msg is NULL
rinosh2 1:fb1109a73ce9 107 Status delTitle(); // del message title
rinosh2 0:3aa62049d1de 108
rinosh2 1:fb1109a73ce9 109 // Add/Clear free message (Max 20) /////////////////////////////////////////
rinosh2 1:fb1109a73ce9 110 Status addFreeMessage(const char* msg = 0); // use internal buffer if msg is NULL
rinosh2 1:fb1109a73ce9 111 Status clearFreeMessage(); // clear all free message
rinosh2 1:fb1109a73ce9 112 Status addFreeCredit(const char* msg = 0); // use internal buffer if msg is NULL
rinosh2 1:fb1109a73ce9 113 Status clearFreeCredit(); // clear all free credit
rinosh2 0:3aa62049d1de 114
rinosh2 1:fb1109a73ce9 115 // NJE control commands ////////////////////////////////////////////////////
rinosh2 1:fb1109a73ce9 116 Status reset();
rinosh2 1:fb1109a73ce9 117
rinosh2 1:fb1109a73ce9 118 // NJE show status /////////////////////////////////////////////////////////
rinosh2 1:fb1109a73ce9 119 Status showTime();
rinosh2 1:fb1109a73ce9 120 Status showContactCredit();
rinosh2 1:fb1109a73ce9 121 Status showNewsCredit();
rinosh2 1:fb1109a73ce9 122 Status showFreeCredit();
rinosh2 0:3aa62049d1de 123
rinosh2 1:fb1109a73ce9 124 // NJES commands ///////////////////////////////////////////////////////////
rinosh2 1:fb1109a73ce9 125 Status setOpMode(OpMode mode = OP_NORMAL);
rinosh2 1:fb1109a73ce9 126 Status setFreeMode(FreeMode mode = FREEMODE_ON);
rinosh2 1:fb1109a73ce9 127 Status setScrollSpeed(ScrollSpeed speed = SCROLL_MIDDLE);
rinosh2 1:fb1109a73ce9 128 Status setBlinkSpeed(BlinkSpeed speed = BLINK_FAST);
rinosh2 1:fb1109a73ce9 129 Status setStopTime(int sec = 5);
rinosh2 0:3aa62049d1de 130 };
rinosh2 1:fb1109a73ce9 131
rinosh2 1:fb1109a73ce9 132 #endif