summaryrefslogtreecommitdiff
path: root/glcddrivers/futabaMDM166A.h
blob: ca1783d4f3e2760d24296ae06655508d48bc69fc (plain)
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
/*
 * GraphLCD driver library
 *
 * (C) 2010 Andreas Brachold <vdr07 AT deltab de>
 *
 * This file is released under the GNU General Public License. 
 *
 * See the files README and COPYING for details.
 *
 */

#ifndef _GLCDDRIVERS_FutabaMDM166A_H_
#define _GLCDDRIVERS_FutabaMDM166A_H_

#include "driver.h"

#define HAVE_STDBOOL_H
#include <hid.h>
#include <queue>

namespace GLCD
{
	class cDriverConfig;

	class cHIDQueue : public std::queue<byte> {
			HIDInterface* hid;
			bool bInit;
		public:
			cHIDQueue();
			virtual ~cHIDQueue();
			virtual bool open();
			virtual void close();
			virtual bool isopen() const { return hid != 0; }
			void Cmd(const byte & cmd);
			void Data(const byte & data);
			bool Flush();
		private:
			const char *hiderror(hid_return ret) const;
	};

	class cDriverFutabaMDM166A : public cDriver, cHIDQueue 
	{
		cDriverConfig * config;
		cDriverConfig * oldConfig;
		unsigned char *m_pDrawMem; // the draw "memory"
		unsigned char *m_pVFDMem;  // the double buffed display "memory"
		unsigned int m_iSizeYb;
		unsigned int m_nRefreshCounter;
		unsigned int lastIconState;
		int CheckSetup();
	protected:
		void ClearVFDMem();
		void SetPixel(int x, int y);
		void icons(unsigned int state);
		bool SendCmdClock();
		bool SendCmdShutdown();

	public:
		cDriverFutabaMDM166A(cDriverConfig * config);
		virtual ~cDriverFutabaMDM166A();

		virtual int Init();
		virtual int DeInit();

		virtual void Clear();
		virtual void Set8Pixels(int x, int y, byte data);
		virtual void Refresh(bool refreshAll = false);

		virtual void SetBrightness(unsigned int percent);
	};
};
#endif