sl@9: sl@9: #include "FutabaVfd.h" sl@9: //#include sl@9: #include sl@9: sl@10: sl@10: // sl@10: // sl@10: // sl@10: sl@10: sl@10: sl@10: sl@10: sl@10: // sl@10: // sl@10: // sl@10: sl@9: FutabaVfdCommand::FutabaVfdCommand():/*iBuffer(NULL),*/iSize(0),iMaxSize(0) sl@9: { sl@9: } sl@9: sl@9: FutabaVfdCommand::~FutabaVfdCommand() sl@9: { sl@9: //Delete(); sl@9: } sl@9: sl@9: sl@9: /** sl@9: sl@9: */ sl@9: void FutabaVfdCommand::Reset() sl@9: { sl@9: memset(iReports,0,sizeof(iReports)); sl@9: } sl@9: sl@9: sl@9: sl@9: /** sl@9: sl@9: */ sl@9: /* sl@9: void FutabaVfdCommand::Create(int aMaxSize) sl@9: { sl@9: iBuffer=new unsigned char[aMaxSize]; sl@9: if (iBuffer) sl@9: { sl@9: iMaxSize = aMaxSize; sl@9: iSize = 0; sl@9: } sl@9: } sl@9: */ sl@9: sl@9: /** sl@9: sl@9: */ sl@9: /* sl@9: void FutabaVfdCommand::Delete() sl@9: { sl@9: delete[] iBuffer; sl@9: iBuffer = NULL; sl@9: iMaxSize = 0; sl@9: iSize = 0; sl@9: } sl@9: */ sl@9: sl@9: sl@10: sl@10: sl@10: // sl@10: // class GP1212A01A sl@10: // sl@10: sl@10: int GP1212A01A::Open() sl@10: { sl@10: int success = HidDevice::Open(KFutabaVendorId,KFutabaProductIdGP1212A01A,NULL); sl@10: if (success) sl@10: { sl@10: SetNonBlocking(1); sl@10: } sl@10: return success; sl@10: } sl@10: sl@10: /** sl@10: */ sl@10: void GP1212A01A::SetPixel(int aX, int aY, bool aOn) sl@10: { sl@10: //Just specify a one pixel block sl@10: SetPixelBlock(aX,aY,0x00,0x01,aOn); sl@10: } sl@10: sl@10: /** sl@10: */ sl@10: void GP1212A01A::SetAllPixels(bool aOn) sl@10: { sl@10: //One pixel at a time sl@10: /* sl@10: for (int i=0;i<256;i++) sl@10: { sl@10: for (int j=0;j<64;j++) sl@10: { sl@10: SetPixel(i,j,0x01); sl@10: } sl@10: } sl@10: */ sl@10: sl@10: //16x16=256 pixels at a time goes much faster sl@10: //TODO: use even larger blocks sl@10: for (int i=0;i<256;i+=16) sl@10: { sl@10: for (int j=0;j<64;j+=16) sl@10: { sl@10: SetPixelBlock(i,j,15,32,(aOn?0xFF:0x00)); sl@10: //FXThread::sleep(1000000000); sl@10: } sl@10: } sl@10: sl@10: } sl@10: sl@10: /** sl@10: */ sl@10: void GP1212A01A::SetBrightness(int aBrightness) sl@10: { sl@10: } sl@10: sl@10: /** sl@10: Set the defined pixel block to the given value. sl@10: @param X coordinate of our pixel block starting point. sl@10: @param Y coordinate of our pixel block starting point. sl@10: @param The height of our pixel block. sl@10: @param The size of our pixel data. Number of pixels divided by 8. sl@10: @param The value set to 8 pixels. sl@10: */ sl@10: void GP1212A01A::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue) sl@10: { sl@10: //Size must be 63 or below sl@10: FutabaVfdReport report; sl@10: report[0]=0x00; //Report ID sl@10: report[1]=0x08+aSize; //Report length sl@10: report[2]=0x1B; // sl@10: report[3]=0x5B; // sl@10: report[4]=0xF0; // sl@10: report[5]=aX; //X sl@10: report[6]=aY; //Y sl@10: 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: report[8]=0x00; //Size of pixel data in bytes (MSB) sl@10: report[9]=aSize; //Size of pixel data in bytes (LSB) sl@11: memset(report.Buffer()+10, aValue, aSize); sl@10: //iOutputReportBuffer[10]=aValue; //Pixel data sl@10: Write(report); sl@10: } sl@10: sl@10: sl@10: /** sl@10: */ sl@10: void GP1212A01A::Clear() sl@10: { sl@10: FutabaVfdReport report; sl@10: report[0]=0x00; //Report ID sl@10: report[1]=0x04; //Report length sl@10: report[2]=0x1B; // sl@10: report[3]=0x5B; // sl@10: report[4]=0x32; // sl@10: report[5]=0x4A; // sl@10: Write(report); sl@10: }