# HG changeset patch
# User sl
# Date 1400681469 -7200
# Node ID e6c42e1e2a967d3c7b8175cdec442f9a4de52f52
# Parent  631f53604811127521cff0a9958c3866b91d5473
Drafting new Futaba class.

diff -r 631f53604811 -r e6c42e1e2a96 FutabaVfd.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FutabaVfd.cpp	Wed May 21 16:11:09 2014 +0200
@@ -0,0 +1,54 @@
+
+#include "FutabaVfd.h"
+//#include <stdlib.h>
+#include <string.h>
+
+FutabaVfdCommand::FutabaVfdCommand():/*iBuffer(NULL),*/iSize(0),iMaxSize(0)
+    {
+    }
+
+FutabaVfdCommand::~FutabaVfdCommand()
+    {
+    //Delete();
+    }
+
+
+/**
+
+*/
+void FutabaVfdCommand::Reset()
+    {
+    memset(iReports,0,sizeof(iReports));
+    }
+
+
+
+/**
+
+*/
+/*
+void FutabaVfdCommand::Create(int aMaxSize)
+    {
+    iBuffer=new unsigned char[aMaxSize];
+    if (iBuffer)
+        {
+        iMaxSize = aMaxSize;
+        iSize = 0;
+        }
+    }
+*/
+
+/**
+
+*/
+/*
+void FutabaVfdCommand::Delete()
+{
+    delete[] iBuffer;
+    iBuffer = NULL;
+    iMaxSize = 0;
+    iSize = 0;
+}
+*/
+
+
diff -r 631f53604811 -r e6c42e1e2a96 FutabaVfd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FutabaVfd.h	Wed May 21 16:11:09 2014 +0200
@@ -0,0 +1,39 @@
+
+
+#ifndef FUTABA_VFD_H
+#define FUTABA_VFD_H
+
+#include "hidapi.h"
+
+//This was computed from our number of pixels as follow 256x64/8/64 = 32 + 1 = 33
+//+1 was added for our header
+const int KFutabaMaxCommandOutputReport = 33;
+//TODO: Get ride of that constant once we figure out a way to get it from hidapi
+const int KFutabaOutputReportLength = 65;
+
+
+/**
+Define a generic Futaba VFD command.
+*/
+class FutabaVfdCommand
+    {
+public:
+    FutabaVfdCommand();
+    ~FutabaVfdCommand();
+    //
+    //void Create(int aMaxSize);
+    //void Delete();
+
+    //inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];}
+
+    void Reset();
+
+private:
+    //unsigned char* iBuffer;
+    unsigned char iReports[KFutabaMaxCommandOutputReport][KFutabaOutputReportLength];
+    int iSize;
+    int iMaxSize;
+    };
+
+
+#endif
\ No newline at end of file
diff -r 631f53604811 -r e6c42e1e2a96 FutabaVfd.vcxproj
--- a/FutabaVfd.vcxproj	Wed May 21 10:19:22 2014 +0200
+++ b/FutabaVfd.vcxproj	Wed May 21 16:11:09 2014 +0200
@@ -104,11 +104,12 @@
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="..\hidapi\windows\hid.c" />
+    <ClCompile Include="FutabaVfd.cpp" />
     <ClCompile Include="Main.cpp" />
     <ClCompile Include="test.cpp" />
   </ItemGroup>
   <ItemGroup>
-    <ClInclude Include="..\hidapi\hidapi.h" />
+    <ClInclude Include="FutabaVfd.h" />
     <ClInclude Include="MainWindow.h" />
   </ItemGroup>
   <ItemGroup>
diff -r 631f53604811 -r e6c42e1e2a96 MainWindow.h
--- a/MainWindow.h	Wed May 21 10:19:22 2014 +0200
+++ b/MainWindow.h	Wed May 21 16:11:09 2014 +0200
@@ -9,10 +9,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <limits.h>
-
-
-//TODO: Get ride of that constant once we figure out a way to get it from hidapi
-const int KFutabaOutputReportLength = 65;
+#include "FutabaVfd.h"
 
 #ifdef _WIN32
 // Thanks Microsoft, but I know how to use strncpy().
diff -r 631f53604811 -r e6c42e1e2a96 test.cpp
--- a/test.cpp	Wed May 21 10:19:22 2014 +0200
+++ b/test.cpp	Wed May 21 16:11:09 2014 +0200
@@ -574,6 +574,12 @@
 	}
 
 /**
+Set the defined pixel block to the given value.
+@param X coordinate of our pixel block starting point.
+@param Y coordinate of our pixel block starting point.
+@param The height of our pixel block.
+@param The size of our pixel data. Number of pixels divided by 8.
+@param The value set to 8 pixels.
 */
 void MainWindow::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue)
 	{
@@ -594,6 +600,30 @@
 	int res = hid_write(connected_device, iOutputReportBuffer, KFutabaOutputReportLength);
 	}
 
+/**
+Send an output report to a Futaba VFD device.
+*/
+/*
+void MainWindow::SendFutabaOutputReport(unsigned char* aReportData, unsigned char aSize)
+    {
+    //
+    memset(iOutputReportBuffer, 0x0, KFutabaOutputReportLength);
+    iOutputReportBuffer[0]=0x00; //Report ID is always null
+    iOutputReportBuffer[1]=0x08+aSize; //Report length
+    iOutputReportBuffer[2]=0x1B; //
+    iOutputReportBuffer[3]=0x5B; //
+    iOutputReportBuffer[4]=0xF0; //
+    iOutputReportBuffer[5]=aX; //X
+    iOutputReportBuffer[6]=aY; //Y
+    iOutputReportBuffer[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.
+    iOutputReportBuffer[8]=0x00; //Size of pixel data in bytes (MSB)
+    iOutputReportBuffer[9]=aSize; //Size of pixel data in bytes (LSB)
+    memset(iOutputReportBuffer+10, aValue, KFutabaOutputReportLength);
+    //iOutputReportBuffer[10]=aValue; //Pixel data
+    int res = hid_write(connected_device, iOutputReportBuffer, KFutabaOutputReportLength);
+    }
+*/
+
 
 /**
 */