Draft implementation of multiple report pixel command.
19 FutabaVfdCommand::FutabaVfdCommand():/*iBuffer(NULL),*/iSize(0),iMaxSize(0)
23 FutabaVfdCommand::~FutabaVfdCommand()
32 void FutabaVfdCommand::Reset()
34 memset(iReports,0,sizeof(iReports));
43 void FutabaVfdCommand::Create(int aMaxSize)
45 iBuffer=new unsigned char[aMaxSize];
58 void FutabaVfdCommand::Delete()
74 int GP1212A01A::Open()
76 int success = HidDevice::Open(KFutabaVendorId,KFutabaProductIdGP1212A01A,NULL);
86 void GP1212A01A::SetPixel(int aX, int aY, bool aOn)
88 //Just specify a one pixel block
89 SetPixelBlock(aX,aY,0x00,0x01,aOn);
94 void GP1212A01A::SetAllPixels(bool aOn)
98 for (int i=0;i<256;i++)
100 for (int j=0;j<64;j++)
107 //16x16=256 pixels at a time goes much faster
108 //TODO: use even larger blocks
109 for (int i=0;i<256;i+=16)
111 for (int j=0;j<64;j+=16)
113 SetPixelBlock(i,j,15,32,(aOn?0xFF:0x00));
114 //FXThread::sleep(1000000000);
122 void GP1212A01A::SetBrightness(int aBrightness)
124 if (aBrightness<MinBrightness()||aBrightness>MaxBrightness())
126 //Brightness out of range.
127 //Just ignore that request.
131 FutabaVfdReport report;
132 report[0]=0x00; //Report ID
133 report[1]=0x06; //Report size
134 report[2]=0x1B; //Command ID
135 report[3]=0x5C; //Command ID
136 report[4]=0x3F; //Command ID
137 report[5]=0x4C; //Command ID
138 report[6]=0x44; //Command ID
139 report[7]=0x30+aBrightness; //Brightness level
145 Set the defined pixel block to the given value.
146 @param X coordinate of our pixel block starting point.
147 @param Y coordinate of our pixel block starting point.
148 @param The height of our pixel block.
149 @param The size of our pixel data. Number of pixels divided by 8.
150 @param The value set to 8 pixels used as a pattern.
152 void GP1212A01A::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue)
154 //Size must be 63 or below
155 FutabaVfdReport report;
156 report[0]=0x00; //Report ID
157 report[1]=0x08+aSize; //Report length
163 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.
164 report[8]=0x00; //Size of pixel data in bytes (MSB)
165 report[9]=aSize; //Size of pixel data in bytes (LSB)
166 memset(report.Buffer()+10, aValue, aSize);
167 //iOutputReportBuffer[10]=aValue; //Pixel data
172 Set the defined pixel block to the given value.
173 @param X coordinate of our pixel block starting point.
174 @param Y coordinate of our pixel block starting point.
175 @param The height of our pixel block.
176 @param The size of our pixel data. Number of pixels divided by 8.
177 @param Pointer to our pixel data.
179 void GP1212A01A::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char* aPixels)
181 FutabaVfdReport report;
182 report[0]=0x00; //Report ID
183 report[1]=0x08+(aSize<=report.Size()-10?aSize:64); //Report length. -10 is for our header first 10 bytes
184 report[2]=0x1B; //Command ID
185 report[3]=0x5B; //Command ID
186 report[4]=0xF0; //Command ID
189 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.
190 unsigned short* sizePtr=(unsigned short*)report.Buffer()+8; //Size of pixel data in bytes (MSB)
191 *sizePtr=aSize; //Put our size over 2 bytes
192 int sizeWritten=MIN(aSize,report.Size()-10);
193 memcpy(report.Buffer()+10, aPixels, sizeWritten);
196 int remainingSize=aSize;
197 //We need to keep on sending our pixel data until we are done
198 while (report[1]==64)
201 remainingSize-=sizeWritten;
202 report[0]=0x00; //Report ID
203 report[1]=(remainingSize<=report.Size()-2?aSize:64); //Report length, should be 64 or the remaining size
204 sizeWritten=(report[1]==64?63:report[1]);
205 memcpy(report.Buffer()+2, aPixels+(aSize-remainingSize), sizeWritten);
212 Clear our display's screen.
214 void GP1212A01A::Clear()
216 //Send Clear display command
217 FutabaVfdReport report;
218 report[0]=0x00; //Report ID
219 report[1]=0x04; //Report length
220 report[2]=0x1B; //Command ID
221 report[3]=0x5B; //Command ID
222 report[4]=0x32; //Command ID
223 report[5]=0x4A; //Command ID
229 void GP1212A01A::RequestId()
231 //1BH,5BH,63H,49H,44H
232 //Send Read ID command
233 FutabaVfdReport report;
234 report[0]=0x00; //Report ID
235 report[1]=0x05; //Report length
236 report[2]=0x1B; //Command ID
237 report[3]=0x5B; //Command ID
238 report[4]=0x63; //Command ID
239 report[5]=0x49; //Command ID
240 report[6]=0x44; //Command ID
246 void GP1212A01A::RequestFirmwareRevision()
248 //1BH,5BH,63H,46H,52H
249 //Send Software Revision Read Command
250 FutabaVfdReport report;
251 report[0]=0x00; //Report ID
252 report[1]=0x05; //Report length
253 report[2]=0x1B; //Command ID
254 report[3]=0x5B; //Command ID
255 report[4]=0x63; //Command ID
256 report[5]=0x46; //Command ID
257 report[6]=0x52; //Command ID
263 void GP1212A01A::RequestPowerSupplyStatus()
265 //1BH,5BH,63H,50H,4DH
266 //Send Power Suppply Monitor Command
267 FutabaVfdReport report;
268 report[0]=0x00; //Report ID
269 report[1]=0x05; //Report length
270 report[2]=0x1B; //Command ID
271 report[3]=0x5B; //Command ID
272 report[4]=0x63; //Command ID
273 report[5]=0x50; //Command ID
274 report[6]=0x4D; //Command ID