1.1 --- a/FutabaVfd.h Wed May 21 22:55:14 2014 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,177 +0,0 @@
1.4 -
1.5 -
1.6 -#ifndef FUTABA_VFD_H
1.7 -#define FUTABA_VFD_H
1.8 -
1.9 -#include "hidapi.h"
1.10 -
1.11 -//This was computed from our number of pixels as follow 256x64/8/64 = 32 + 1 = 33
1.12 -//+1 was added for our header
1.13 -const int KFutabaMaxCommandOutputReport = 33;
1.14 -//TODO: Get ride of that constant once we figure out a way to get it from hidapi
1.15 -const int KFutabaMaxHidReportSize = 65;
1.16 -
1.17 -const int KHidReportIdIndex=0;
1.18 -const int KFutabaHidReportSizeIndex=1;
1.19 -//Define Futaba vendor ID to filter our list of device
1.20 -const unsigned short KFutabaVendorId = 0x1008;
1.21 -const unsigned short KFutabaProductIdGP1212A01A = 0x100C;
1.22 -const unsigned short KFutabaProductIdGP1212A02A = 0x1013; //Or is it 0x1015
1.23 -
1.24 -
1.25 -//typedef struct hid_device_info HidDeviceInfo;
1.26 -
1.27 -/**
1.28 -TODO: move to another header
1.29 -*/
1.30 -template <int S>
1.31 -class HidReport
1.32 - {
1.33 -public:
1.34 - HidReport(){Reset();};
1.35 - void Reset();
1.36 - inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];}
1.37 - const unsigned char* Buffer() const {return iBuffer;};
1.38 - unsigned char* Buffer() {return iBuffer;};
1.39 -protected:
1.40 - unsigned char iBuffer[S];
1.41 - };
1.42 -
1.43 -template <int S>
1.44 -void HidReport<S>::Reset()
1.45 - {
1.46 - memset(iBuffer,0,sizeof(iBuffer));
1.47 - }
1.48 -
1.49 -/**
1.50 -TODO: move to another header
1.51 -*/
1.52 -class HidDevice
1.53 - {
1.54 -public:
1.55 - int Open(const char* aPath);
1.56 - int Open(unsigned short aVendorId, unsigned short aProductId, const wchar_t* aSerialNumber);
1.57 - void Close();
1.58 - //
1.59 - int SetNonBlocking(int aNonBlocking);
1.60 - //
1.61 - template<int S>
1.62 - int Write(const HidReport<S>& aOutputReport);
1.63 - //
1.64 - const wchar_t* Error();
1.65 -
1.66 -
1.67 -
1.68 -private:
1.69 - ///Our USB HID device
1.70 - hid_device* iHidDevice;
1.71 - };
1.72 -
1.73 -
1.74 -/**
1.75 -*/
1.76 -template<int S>
1.77 -int HidDevice::Write(const HidReport<S>& aOutputReport)
1.78 - {
1.79 - return hid_write(iHidDevice,aOutputReport.Buffer(),S);
1.80 - }
1.81 -
1.82 -
1.83 -/**
1.84 -*/
1.85 -class FutabaVfdReport: public HidReport<KFutabaMaxHidReportSize>
1.86 - {
1.87 -
1.88 -private:
1.89 -
1.90 - };
1.91 -
1.92 -
1.93 -
1.94 -/**
1.95 -Define a generic Futaba VFD command.
1.96 -*/
1.97 -class FutabaVfdCommand
1.98 - {
1.99 -public:
1.100 - FutabaVfdCommand();
1.101 - ~FutabaVfdCommand();
1.102 - //
1.103 - //void Create(int aMaxSize);
1.104 - //void Delete();
1.105 -
1.106 - //inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];}
1.107 -
1.108 - void Reset();
1.109 -
1.110 -private:
1.111 - //unsigned char* iBuffer;
1.112 - FutabaVfdReport iReports[KFutabaMaxCommandOutputReport];
1.113 - int iSize;
1.114 - int iMaxSize;
1.115 - };
1.116 -
1.117 -/**
1.118 -*/
1.119 -class FutabaVfd : public HidDevice
1.120 - {
1.121 -public:
1.122 - virtual int MinBrightness()=0;
1.123 - virtual int MaxBrightness()=0;
1.124 - virtual void SetBrightness(int aBrightness)=0;
1.125 - virtual void Clear()=0;
1.126 - };
1.127 -
1.128 -
1.129 -/**
1.130 -*/
1.131 -class FutabaGraphicVfd : public FutabaVfd
1.132 - {
1.133 -public:
1.134 - virtual int WidthInPixels()=0;
1.135 - virtual int HeightInPixels()=0;
1.136 - virtual void SetPixel(int aX, int aY, bool aOn)=0;
1.137 - virtual void SetAllPixels(bool aOn)=0;
1.138 -
1.139 - };
1.140 -
1.141 -/**
1.142 -Common functionality between GP1212A01A and GP1212A02A
1.143 -*/
1.144 -class GP1212XXXX : public FutabaGraphicVfd
1.145 - {
1.146 -public:
1.147 - //From FutabaVfd
1.148 - virtual int MinBrightness(){return 0;};
1.149 - virtual int MaxBrightness(){return 5;};
1.150 - };
1.151 -
1.152 -/**
1.153 -GP1212A01A is a graphic display module using a FUTABA 256x64dots VFD.
1.154 -The module do not include character ROM, the customer will compile the character
1.155 -by themselves (from main system).
1.156 -*/
1.157 -class GP1212A01A : public GP1212XXXX
1.158 - {
1.159 -public:
1.160 - int Open();
1.161 - //From FutabaGraphicVfd
1.162 - virtual int WidthInPixels(){return 256;};
1.163 - virtual int HeightInPixels(){return 64;};
1.164 - virtual void SetPixel(int aX, int aY, bool aOn);
1.165 - virtual void SetAllPixels(bool aOn);
1.166 - //From FutabaVfd
1.167 - virtual void SetBrightness(int aBrightness);
1.168 - virtual void Clear();
1.169 - //
1.170 - void SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue);
1.171 -
1.172 -private:
1.173 - ///
1.174 - //FutabaVfdReport iReport;
1.175 - ///
1.176 - unsigned char iPixelBuffer[256][128];
1.177 - };
1.178 -
1.179 -
1.180 -#endif
1.181 \ No newline at end of file