# HG changeset patch
# User sl
# Date 1400743883 -7200
# Node ID 14662967f9132270fb1614c497af8ad8d3b1cc98
# Parent  63972dc163503e6e859c510817742345862b6f4f
Implementing Futaba GP1212A01A brightness support.
Test application now using Futaba class to send some of our commands.

diff -r 63972dc16350 -r 14662967f913 inc/MainWindow.h
--- a/inc/MainWindow.h	Thu May 22 09:12:31 2014 +0200
+++ b/inc/MainWindow.h	Thu May 22 09:31:23 2014 +0200
@@ -116,7 +116,7 @@
     FXButton *iButtonSelectFont;
 
     unsigned char* iOutputReportBuffer;
-    unsigned char iDimming; //Current VFD dimming
+    unsigned char iBrightness; //Current VFD dimming
     FXFontDesc iCurrentFontDesc;
     FXFont* iCurrentFont;
     FXTGAImage* iFontImage;
diff -r 63972dc16350 -r 14662967f913 src/FutabaVfd.cpp
--- a/src/FutabaVfd.cpp	Thu May 22 09:12:31 2014 +0200
+++ b/src/FutabaVfd.cpp	Thu May 22 09:31:23 2014 +0200
@@ -120,7 +120,25 @@
 /**
 */
 void GP1212A01A::SetBrightness(int aBrightness)
-	{
+    {
+	if (aBrightness<MinBrightness()||aBrightness>MaxBrightness())
+        {
+        //Brightness out of range.
+        //Just ignore that request.
+        return;
+        }
+
+    FutabaVfdReport report;
+    report[0]=0x00; //Report ID
+    report[1]=0x06; //Report size
+    report[2]=0x1B; //Command ID
+    report[3]=0x5C; //Command ID
+    report[4]=0x3F; //Command ID
+    report[5]=0x4C; //Command ID
+    report[6]=0x44; //Command ID
+    report[7]=0x30+aBrightness; //Brightness level
+    Write(report);
+
 	}
 
 /**
diff -r 63972dc16350 -r 14662967f913 src/test.cpp
--- a/src/test.cpp	Thu May 22 09:12:31 2014 +0200
+++ b/src/test.cpp	Thu May 22 09:31:23 2014 +0200
@@ -55,7 +55,7 @@
     iCurrentFont(NULL),
     iFontImage(NULL)
 {
-	iDimming=0x35;
+	iBrightness=iVfd01.MaxBrightness();
 	devices = NULL;
 	connected_device = NULL;
 
@@ -538,6 +538,7 @@
 long
 MainWindow::onFutabaClearDisplay(FXObject *sender, FXSelector sel, void *ptr)
 {
+    /*
 	memset(iOutputReportBuffer, 0x0, KFutabaMaxHidReportSize);
 	iOutputReportBuffer[0]=0x00; //Report ID
 	iOutputReportBuffer[1]=0x04; //Report length
@@ -546,6 +547,8 @@
 	iOutputReportBuffer[4]=0x32; //
 	iOutputReportBuffer[5]=0x4A; //
 	int res = hid_write(connected_device, iOutputReportBuffer, KFutabaMaxHidReportSize);
+    */
+    iVfd01.Clear();
 
 	return 1;
 }
@@ -553,6 +556,7 @@
 long
 MainWindow::onFutabaDimming(FXObject *sender, FXSelector sel, void *ptr)
 {
+    /*
 	memset(iOutputReportBuffer, 0x0, KFutabaMaxHidReportSize);
 	iOutputReportBuffer[0]=0x00; //Report ID
 	iOutputReportBuffer[1]=0x06; //Report length
@@ -564,6 +568,10 @@
 	iDimming = (iDimming==0x35?0x30:++iDimming);
 	iOutputReportBuffer[7]=iDimming;
 	int res = hid_write(connected_device, iOutputReportBuffer, KFutabaMaxHidReportSize);
+    */
+
+    iBrightness = (iBrightness==iVfd01.MaxBrightness()?iVfd01.MinBrightness():++iBrightness);
+    iVfd01.SetBrightness(iBrightness);
 
 	return 1;
 }
@@ -666,7 +674,8 @@
 	int y=0;
 	iTextFieldX->getText().scan("%d",&x);
 	iTextFieldY->getText().scan("%d",&y);
-    SetPixel(x,y,0x01);
+    //SetPixel(x,y,0x01);
+    iVfd01.SetPixel(x,y,true);
 	return 1;
 }
 
@@ -678,12 +687,15 @@
 	int y=0;
 	iTextFieldX->getText().scan("%d",&x);
 	iTextFieldY->getText().scan("%d",&y);
-    SetPixel(x,y,0x00);
+    //SetPixel(x,y,0x00);
+    iVfd01.SetPixel(x,y,false);
     return 1;
 }
 
 long MainWindow::onFutabaSetAllPixels(FXObject *sender, FXSelector sel, void *ptr)
 	{
+    iVfd01.SetAllPixels(true);
+
 	//One pixel at a time
 	/*
 	for (int i=0;i<256;i++)
@@ -695,6 +707,7 @@
 		}
 	*/
 	//16x16=256 pixels at a time goes much faster
+    /*
 	for (int i=0;i<256;i+=16)
 		{
 		for (int j=0;j<64;j+=16)
@@ -703,6 +716,7 @@
 			//FXThread::sleep(1000000000);
 			}
 		}
+    */
 
     return 1;
 	}