sl@9
|
1 |
|
sl@9
|
2 |
#include "FutabaVfd.h"
|
sl@9
|
3 |
//#include <stdlib.h>
|
sl@9
|
4 |
#include <string.h>
|
sl@9
|
5 |
|
sl@10
|
6 |
|
sl@10
|
7 |
//
|
sl@10
|
8 |
//
|
sl@10
|
9 |
//
|
sl@10
|
10 |
|
sl@10
|
11 |
|
sl@10
|
12 |
|
sl@10
|
13 |
|
sl@10
|
14 |
|
sl@10
|
15 |
//
|
sl@10
|
16 |
//
|
sl@10
|
17 |
//
|
sl@10
|
18 |
|
sl@9
|
19 |
FutabaVfdCommand::FutabaVfdCommand():/*iBuffer(NULL),*/iSize(0),iMaxSize(0)
|
sl@9
|
20 |
{
|
sl@9
|
21 |
}
|
sl@9
|
22 |
|
sl@9
|
23 |
FutabaVfdCommand::~FutabaVfdCommand()
|
sl@9
|
24 |
{
|
sl@9
|
25 |
//Delete();
|
sl@9
|
26 |
}
|
sl@9
|
27 |
|
sl@9
|
28 |
|
sl@9
|
29 |
/**
|
sl@9
|
30 |
|
sl@9
|
31 |
*/
|
sl@9
|
32 |
void FutabaVfdCommand::Reset()
|
sl@9
|
33 |
{
|
sl@9
|
34 |
memset(iReports,0,sizeof(iReports));
|
sl@9
|
35 |
}
|
sl@9
|
36 |
|
sl@9
|
37 |
|
sl@9
|
38 |
|
sl@9
|
39 |
/**
|
sl@9
|
40 |
|
sl@9
|
41 |
*/
|
sl@9
|
42 |
/*
|
sl@9
|
43 |
void FutabaVfdCommand::Create(int aMaxSize)
|
sl@9
|
44 |
{
|
sl@9
|
45 |
iBuffer=new unsigned char[aMaxSize];
|
sl@9
|
46 |
if (iBuffer)
|
sl@9
|
47 |
{
|
sl@9
|
48 |
iMaxSize = aMaxSize;
|
sl@9
|
49 |
iSize = 0;
|
sl@9
|
50 |
}
|
sl@9
|
51 |
}
|
sl@9
|
52 |
*/
|
sl@9
|
53 |
|
sl@9
|
54 |
/**
|
sl@9
|
55 |
|
sl@9
|
56 |
*/
|
sl@9
|
57 |
/*
|
sl@9
|
58 |
void FutabaVfdCommand::Delete()
|
sl@9
|
59 |
{
|
sl@9
|
60 |
delete[] iBuffer;
|
sl@9
|
61 |
iBuffer = NULL;
|
sl@9
|
62 |
iMaxSize = 0;
|
sl@9
|
63 |
iSize = 0;
|
sl@9
|
64 |
}
|
sl@9
|
65 |
*/
|
sl@9
|
66 |
|
sl@9
|
67 |
|
sl@10
|
68 |
|
sl@10
|
69 |
|
sl@10
|
70 |
//
|
sl@10
|
71 |
// class GP1212A01A
|
sl@10
|
72 |
//
|
sl@10
|
73 |
|
sl@10
|
74 |
int GP1212A01A::Open()
|
sl@10
|
75 |
{
|
sl@10
|
76 |
int success = HidDevice::Open(KFutabaVendorId,KFutabaProductIdGP1212A01A,NULL);
|
sl@10
|
77 |
if (success)
|
sl@10
|
78 |
{
|
sl@10
|
79 |
SetNonBlocking(1);
|
sl@10
|
80 |
}
|
sl@10
|
81 |
return success;
|
sl@10
|
82 |
}
|
sl@10
|
83 |
|
sl@10
|
84 |
/**
|
sl@10
|
85 |
*/
|
sl@10
|
86 |
void GP1212A01A::SetPixel(int aX, int aY, bool aOn)
|
sl@10
|
87 |
{
|
sl@10
|
88 |
//Just specify a one pixel block
|
sl@10
|
89 |
SetPixelBlock(aX,aY,0x00,0x01,aOn);
|
sl@10
|
90 |
}
|
sl@10
|
91 |
|
sl@10
|
92 |
/**
|
sl@10
|
93 |
*/
|
sl@10
|
94 |
void GP1212A01A::SetAllPixels(bool aOn)
|
sl@10
|
95 |
{
|
sl@10
|
96 |
//One pixel at a time
|
sl@10
|
97 |
/*
|
sl@10
|
98 |
for (int i=0;i<256;i++)
|
sl@10
|
99 |
{
|
sl@10
|
100 |
for (int j=0;j<64;j++)
|
sl@10
|
101 |
{
|
sl@10
|
102 |
SetPixel(i,j,0x01);
|
sl@10
|
103 |
}
|
sl@10
|
104 |
}
|
sl@10
|
105 |
*/
|
sl@10
|
106 |
|
sl@10
|
107 |
//16x16=256 pixels at a time goes much faster
|
sl@10
|
108 |
//TODO: use even larger blocks
|
sl@10
|
109 |
for (int i=0;i<256;i+=16)
|
sl@10
|
110 |
{
|
sl@10
|
111 |
for (int j=0;j<64;j+=16)
|
sl@10
|
112 |
{
|
sl@10
|
113 |
SetPixelBlock(i,j,15,32,(aOn?0xFF:0x00));
|
sl@10
|
114 |
//FXThread::sleep(1000000000);
|
sl@10
|
115 |
}
|
sl@10
|
116 |
}
|
sl@10
|
117 |
|
sl@10
|
118 |
}
|
sl@10
|
119 |
|
sl@10
|
120 |
/**
|
sl@10
|
121 |
*/
|
sl@10
|
122 |
void GP1212A01A::SetBrightness(int aBrightness)
|
sl@10
|
123 |
{
|
sl@10
|
124 |
}
|
sl@10
|
125 |
|
sl@10
|
126 |
/**
|
sl@10
|
127 |
Set the defined pixel block to the given value.
|
sl@10
|
128 |
@param X coordinate of our pixel block starting point.
|
sl@10
|
129 |
@param Y coordinate of our pixel block starting point.
|
sl@10
|
130 |
@param The height of our pixel block.
|
sl@10
|
131 |
@param The size of our pixel data. Number of pixels divided by 8.
|
sl@10
|
132 |
@param The value set to 8 pixels.
|
sl@10
|
133 |
*/
|
sl@10
|
134 |
void GP1212A01A::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue)
|
sl@10
|
135 |
{
|
sl@10
|
136 |
//Size must be 63 or below
|
sl@10
|
137 |
FutabaVfdReport report;
|
sl@10
|
138 |
report[0]=0x00; //Report ID
|
sl@10
|
139 |
report[1]=0x08+aSize; //Report length
|
sl@10
|
140 |
report[2]=0x1B; //
|
sl@10
|
141 |
report[3]=0x5B; //
|
sl@10
|
142 |
report[4]=0xF0; //
|
sl@10
|
143 |
report[5]=aX; //X
|
sl@10
|
144 |
report[6]=aY; //Y
|
sl@10
|
145 |
report[7]=aHeight; //Y length before return. Though outside the specs, setting this to zero apparently allows us to modify a single pixel without touching any other.
|
sl@10
|
146 |
report[8]=0x00; //Size of pixel data in bytes (MSB)
|
sl@10
|
147 |
report[9]=aSize; //Size of pixel data in bytes (LSB)
|
sl@11
|
148 |
memset(report.Buffer()+10, aValue, aSize);
|
sl@10
|
149 |
//iOutputReportBuffer[10]=aValue; //Pixel data
|
sl@10
|
150 |
Write(report);
|
sl@10
|
151 |
}
|
sl@10
|
152 |
|
sl@10
|
153 |
|
sl@10
|
154 |
/**
|
sl@10
|
155 |
*/
|
sl@10
|
156 |
void GP1212A01A::Clear()
|
sl@10
|
157 |
{
|
sl@10
|
158 |
FutabaVfdReport report;
|
sl@10
|
159 |
report[0]=0x00; //Report ID
|
sl@10
|
160 |
report[1]=0x04; //Report length
|
sl@10
|
161 |
report[2]=0x1B; //
|
sl@10
|
162 |
report[3]=0x5B; //
|
sl@10
|
163 |
report[4]=0x32; //
|
sl@10
|
164 |
report[5]=0x4A; //
|
sl@10
|
165 |
Write(report);
|
sl@10
|
166 |
} |