Sorting out and testing our display position command.
To avoid refresh artefact we will indeed need to use this feature.
It will go like that:
* Setup off screen buffer
* Swap frame buffer
1.1 --- a/inc/FutabaVfd.h Thu May 22 14:57:11 2014 +0200
1.2 +++ b/inc/FutabaVfd.h Thu May 22 16:46:50 2014 +0200
1.3 @@ -110,12 +110,6 @@
1.4 class GP1212A01A : public GP1212XXXX
1.5 {
1.6 public:
1.7 - enum DW
1.8 - {
1.9 - DW1=12,
1.10 - DW2=13
1.11 - };
1.12 -
1.13 int Open();
1.14 //From FutabaGraphicVfd
1.15 virtual int WidthInPixels(){return 256;};
1.16 @@ -130,11 +124,21 @@
1.17 void SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue);
1.18 void SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char* aPixels);
1.19 //
1.20 - void SetDisplayPosition(DW aDw,int aX, int aY);
1.21 + void SetDisplayPosition(int aX, int aY);
1.22 //
1.23 void RequestId();
1.24 void RequestFirmwareRevision();
1.25 void RequestPowerSupplyStatus();
1.26 +
1.27 +private:
1.28 + enum DW
1.29 + {
1.30 + DW1=0xC0,
1.31 + DW2=0xD0
1.32 + };
1.33 +
1.34 + void SetDisplayPosition(DW aDw,int aX, int aY);
1.35 +
1.36 private:
1.37 ///
1.38 //FutabaVfdReport iReport;
2.1 --- a/inc/MainWindow.h Thu May 22 14:57:11 2014 +0200
2.2 +++ b/inc/MainWindow.h Thu May 22 16:46:50 2014 +0200
2.3 @@ -78,10 +78,7 @@
2.4 //
2.5 long onTimeout(FXObject *sender, FXSelector sel, void *ptr);
2.6 long onMacTimeout(FXObject *sender, FXSelector sel, void *ptr);
2.7 - //
2.8 - void SetPixel(int aX, int aY, unsigned char aValue);
2.9 - void SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue);
2.10 -
2.11 +
2.12 private:
2.13 void SetConnectedStates();
2.14 bool IsConnected();
2.15 @@ -104,7 +101,7 @@
2.16 FXFont *title_font;
2.17 //Futaba VFD control
2.18 FXButton *iButtonClearDisplay;
2.19 - FXButton *iButtonDimming;
2.20 + FXButton *iButtonBrightness;
2.21 FXButton *iButtonDisplayDataInput;
2.22 FXButton *iButtonReadId;
2.23 FXButton *iButtonReadFirmwareRevision;
3.1 --- a/src/FutabaVfd.cpp Thu May 22 14:57:11 2014 +0200
3.2 +++ b/src/FutabaVfd.cpp Thu May 22 16:46:50 2014 +0200
3.3 @@ -239,11 +239,21 @@
3.4 report[3]=0x5B; //Command ID
3.5 report[4]=aDw; //Specify our DW
3.6 report[5]=aX; //X coordinate of our DW top-left corner
3.7 - report[5]=aY; //Y coordinate of our DW top-left corner
3.8 + report[6]=aY; //Y coordinate of our DW top-left corner
3.9 Write(report);
3.10 }
3.11
3.12 /**
3.13 +Change our display position within our buffer.
3.14 +*/
3.15 +void GP1212A01A::SetDisplayPosition(int aX, int aY)
3.16 + {
3.17 + //Specs apparently says both DW should remain the same
3.18 + //Just don't ask
3.19 + SetDisplayPosition(GP1212A01A::DW1,aX,aY);
3.20 + SetDisplayPosition(GP1212A01A::DW2,aX,aY);
3.21 + }
3.22 +/**
3.23 */
3.24 void GP1212A01A::RequestId()
3.25 {
4.1 --- a/src/test.cpp Thu May 22 14:57:11 2014 +0200
4.2 +++ b/src/test.cpp Thu May 22 16:46:50 2014 +0200
4.3 @@ -43,6 +43,7 @@
4.4 FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FUTABA_SET_PIXEL, MainWindow::onFutabaSetPixel ),
4.5 FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FUTABA_RESET_PIXEL, MainWindow::onFutabaResetPixel ),
4.6 FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FUTABA_SET_ALL_PIXELS, MainWindow::onFutabaSetAllPixels ),
4.7 + FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FUTABA_SET_DISPLAY_POSITION, MainWindow::onFutabaSetDisplayPosition ),
4.8 FXMAPFUNC(SEL_COMMAND, MainWindow::ID_SELECT_FONT, MainWindow::onSelectFont ),
4.9 FXMAPFUNC(SEL_TIMEOUT, MainWindow::ID_TIMER, MainWindow::onTimeout ),
4.10 FXMAPFUNC(SEL_TIMEOUT, MainWindow::ID_MAC_TIMER, MainWindow::onMacTimeout ),
4.11 @@ -106,7 +107,7 @@
4.12 gb = new FXGroupBox(vf, "Futaba GP1212A01A", FRAME_GROOVE|LAYOUT_FILL_X);
4.13 matrix = new FXMatrix(gb, 3, MATRIX_BY_COLUMNS|LAYOUT_FILL_X);
4.14 iButtonClearDisplay = new FXButton(matrix, "Clear Display", NULL, this, ID_FUTABA_CLEAR_DISPLAY, BUTTON_NORMAL|LAYOUT_FILL_X);
4.15 - iButtonDimming = new FXButton(matrix, "Dimming", NULL, this, ID_FUTABA_DIMMING, BUTTON_NORMAL|LAYOUT_FILL_X);
4.16 + iButtonBrightness = new FXButton(matrix, "Brightness", NULL, this, ID_FUTABA_DIMMING, BUTTON_NORMAL|LAYOUT_FILL_X);
4.17 iButtonDisplayDataInput = new FXButton(matrix, "Display Data Input", NULL, this, ID_FUTABA_DISPLAY_DATA_INPUT, BUTTON_NORMAL|LAYOUT_FILL_X);
4.18 iButtonReadId = new FXButton(matrix, "Read Id", NULL, this, ID_FUTABA_READ_ID, BUTTON_NORMAL|LAYOUT_FILL_X);
4.19 iButtonReadFirmwareRevision = new FXButton(matrix, "Read Firmware Revision", NULL, this, ID_FUTABA_READ_FIRMWARE_REVISION, BUTTON_NORMAL|LAYOUT_FILL_X);
4.20 @@ -120,7 +121,7 @@
4.21 iButtonResetPixel = new FXButton(matrix, "Reset Pixel", NULL, this, ID_FUTABA_RESET_PIXEL, BUTTON_NORMAL|LAYOUT_FILL_X);
4.22 //
4.23 iButtonSetAllPixels = new FXButton(matrix, "Set All Pixels", NULL, this, ID_FUTABA_SET_ALL_PIXELS, BUTTON_NORMAL|LAYOUT_FILL_X);
4.24 - iButtonSetDisplayPosition = new FXButton(matrix, "Set Display Position", NULL, this, ID_FUTABA_SET_ALL_PIXELS, BUTTON_NORMAL|LAYOUT_FILL_X);
4.25 + iButtonSetDisplayPosition = new FXButton(matrix, "Set Display Position", NULL, this, ID_FUTABA_SET_DISPLAY_POSITION, BUTTON_NORMAL|LAYOUT_FILL_X);
4.26 //
4.27
4.28 // Output Group Box
4.29 @@ -187,8 +188,8 @@
4.30 //Try to connect to our VFD from start-up
4.31 if (iVfd01.Open())
4.32 {
4.33 - iVfd01.SetAllPixels(true);
4.34 - iVfd01.Close();
4.35 + //iVfd01.SetAllPixels(true);
4.36 + //iVfd01.Close();
4.37 SetConnectedStates();
4.38 }
4.39
4.40 @@ -264,7 +265,9 @@
4.41 }
4.42 else
4.43 {
4.44 - //TODO: Missing function on our HidDevice class
4.45 + s += iVfd01.Vendor();
4.46 + s += iVfd01.Product();
4.47 + s += iVfd01.SerialNumber();
4.48 }
4.49 connected_label->setText(s);
4.50 output_button->enable();
4.51 @@ -278,7 +281,7 @@
4.52 {
4.53 //Those widgets are specific to our VFD
4.54 iButtonClearDisplay->enable();
4.55 - iButtonDimming->enable();
4.56 + iButtonBrightness->enable();
4.57 iButtonDisplayDataInput->enable();
4.58 iButtonReadId->enable();
4.59 iButtonReadFirmwareRevision->enable();
4.60 @@ -304,7 +307,7 @@
4.61 disconnect_button->disable();
4.62
4.63 iButtonClearDisplay->disable();
4.64 - iButtonDimming->disable();
4.65 + iButtonBrightness->disable();
4.66 iButtonDisplayDataInput->disable();
4.67 iButtonReadId->disable();
4.68 iButtonReadFirmwareRevision->disable();
4.69 @@ -541,41 +544,15 @@
4.70 long
4.71 MainWindow::onFutabaClearDisplay(FXObject *sender, FXSelector sel, void *ptr)
4.72 {
4.73 - /*
4.74 - memset(iOutputReportBuffer, 0x0, KFutabaMaxHidReportSize);
4.75 - iOutputReportBuffer[0]=0x00; //Report ID
4.76 - iOutputReportBuffer[1]=0x04; //Report length
4.77 - iOutputReportBuffer[2]=0x1B; //
4.78 - iOutputReportBuffer[3]=0x5B; //
4.79 - iOutputReportBuffer[4]=0x32; //
4.80 - iOutputReportBuffer[5]=0x4A; //
4.81 - int res = hid_write(connected_device, iOutputReportBuffer, KFutabaMaxHidReportSize);
4.82 - */
4.83 iVfd01.Clear();
4.84 -
4.85 return 1;
4.86 }
4.87
4.88 long
4.89 MainWindow::onFutabaDimming(FXObject *sender, FXSelector sel, void *ptr)
4.90 {
4.91 - /*
4.92 - memset(iOutputReportBuffer, 0x0, KFutabaMaxHidReportSize);
4.93 - iOutputReportBuffer[0]=0x00; //Report ID
4.94 - iOutputReportBuffer[1]=0x06; //Report length
4.95 - iOutputReportBuffer[2]=0x1B; //
4.96 - iOutputReportBuffer[3]=0x5C; //
4.97 - iOutputReportBuffer[4]=0x3F; //
4.98 - iOutputReportBuffer[5]=0x4C; //
4.99 - iOutputReportBuffer[6]=0x44; //
4.100 - iDimming = (iDimming==0x35?0x30:++iDimming);
4.101 - iOutputReportBuffer[7]=iDimming;
4.102 - int res = hid_write(connected_device, iOutputReportBuffer, KFutabaMaxHidReportSize);
4.103 - */
4.104 -
4.105 iBrightness = (iBrightness==iVfd01.MaxBrightness()?iVfd01.MinBrightness():++iBrightness);
4.106 iVfd01.SetBrightness(iBrightness);
4.107 -
4.108 return 1;
4.109 }
4.110
4.111 @@ -602,73 +579,6 @@
4.112 return 1;
4.113 }
4.114
4.115 -
4.116 -
4.117 -
4.118 -/**
4.119 -Set a single pixel to the specified value.
4.120 -@param X coordinate of our pixel.
4.121 -@param Y coordinate of our pixel.
4.122 -@param The LSB defines our pixel value.
4.123 -*/
4.124 -void MainWindow::SetPixel(int aX, int aY, unsigned char aValue)
4.125 - {
4.126 - //Just specify a one pixel block
4.127 - SetPixelBlock(aX,aY,0x00,0x01,aValue);
4.128 - }
4.129 -
4.130 -/**
4.131 -Set the defined pixel block to the given value.
4.132 -@param X coordinate of our pixel block starting point.
4.133 -@param Y coordinate of our pixel block starting point.
4.134 -@param The height of our pixel block.
4.135 -@param The size of our pixel data. Number of pixels divided by 8.
4.136 -@param The value set to 8 pixels.
4.137 -*/
4.138 -void MainWindow::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue)
4.139 - {
4.140 - //Size must be 63 or below
4.141 - memset(iOutputReportBuffer, 0x0, KFutabaMaxHidReportSize);
4.142 - iOutputReportBuffer[0]=0x00; //Report ID
4.143 - iOutputReportBuffer[1]=0x08+aSize; //Report length
4.144 - iOutputReportBuffer[2]=0x1B; //
4.145 - iOutputReportBuffer[3]=0x5B; //
4.146 - iOutputReportBuffer[4]=0xF0; //
4.147 - iOutputReportBuffer[5]=aX; //X
4.148 - iOutputReportBuffer[6]=aY; //Y
4.149 - 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.
4.150 - iOutputReportBuffer[8]=0x00; //Size of pixel data in bytes (MSB)
4.151 - iOutputReportBuffer[9]=aSize; //Size of pixel data in bytes (LSB)
4.152 - memset(iOutputReportBuffer+10, aValue, KFutabaMaxHidReportSize);
4.153 - //iOutputReportBuffer[10]=aValue; //Pixel data
4.154 - int res = hid_write(connected_device, iOutputReportBuffer, KFutabaMaxHidReportSize);
4.155 - }
4.156 -
4.157 -/**
4.158 -Send an output report to a Futaba VFD device.
4.159 -*/
4.160 -/*
4.161 -void MainWindow::SendFutabaOutputReport(unsigned char* aReportData, unsigned char aSize)
4.162 - {
4.163 - //
4.164 - memset(iOutputReportBuffer, 0x0, KFutabaMaxHidReportSize);
4.165 - iOutputReportBuffer[0]=0x00; //Report ID is always null
4.166 - iOutputReportBuffer[1]=0x08+aSize; //Report length
4.167 - iOutputReportBuffer[2]=0x1B; //
4.168 - iOutputReportBuffer[3]=0x5B; //
4.169 - iOutputReportBuffer[4]=0xF0; //
4.170 - iOutputReportBuffer[5]=aX; //X
4.171 - iOutputReportBuffer[6]=aY; //Y
4.172 - 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.
4.173 - iOutputReportBuffer[8]=0x00; //Size of pixel data in bytes (MSB)
4.174 - iOutputReportBuffer[9]=aSize; //Size of pixel data in bytes (LSB)
4.175 - memset(iOutputReportBuffer+10, aValue, KFutabaMaxHidReportSize);
4.176 - //iOutputReportBuffer[10]=aValue; //Pixel data
4.177 - int res = hid_write(connected_device, iOutputReportBuffer, KFutabaMaxHidReportSize);
4.178 - }
4.179 -*/
4.180 -
4.181 -
4.182 /**
4.183 */
4.184 long MainWindow::onFutabaSetPixel(FXObject *sender, FXSelector sel, void *ptr)
4.185 @@ -698,29 +608,6 @@
4.186 long MainWindow::onFutabaSetAllPixels(FXObject *sender, FXSelector sel, void *ptr)
4.187 {
4.188 iVfd01.SetAllPixels(true);
4.189 -
4.190 - //One pixel at a time
4.191 - /*
4.192 - for (int i=0;i<256;i++)
4.193 - {
4.194 - for (int j=0;j<64;j++)
4.195 - {
4.196 - SetPixel(i,j,0x01);
4.197 - }
4.198 - }
4.199 - */
4.200 - //16x16=256 pixels at a time goes much faster
4.201 - /*
4.202 - for (int i=0;i<256;i+=16)
4.203 - {
4.204 - for (int j=0;j<64;j+=16)
4.205 - {
4.206 - SetPixelBlock(i,j,15,32,0xFF);
4.207 - //FXThread::sleep(1000000000);
4.208 - }
4.209 - }
4.210 - */
4.211 -
4.212 return 1;
4.213 }
4.214
4.215 @@ -734,9 +621,7 @@
4.216 int y=0;
4.217 iTextFieldX->getText().scan("%d",&x);
4.218 iTextFieldY->getText().scan("%d",&y);
4.219 - //Set both positions for now until we understand how to use that stuff
4.220 - iVfd01.SetDisplayPosition(GP1212A01A::DW1,x,y);
4.221 - iVfd01.SetDisplayPosition(GP1212A01A::DW2,x,y);
4.222 + iVfd01.SetDisplayPosition(x,y);
4.223 return 1;
4.224 }
4.225
4.226 @@ -744,62 +629,21 @@
4.227 long
4.228 MainWindow::onFutabaReadId(FXObject *sender, FXSelector sel, void *ptr)
4.229 {
4.230 - //1BH,5BH,63H,49H,44H
4.231 - /*
4.232 - memset(iOutputReportBuffer, 0x0, KFutabaMaxHidReportSize);
4.233 - iOutputReportBuffer[0]=0x00; //Report ID
4.234 - iOutputReportBuffer[1]=0x05; //Report length
4.235 - iOutputReportBuffer[2]=0x1B; //
4.236 - iOutputReportBuffer[3]=0x5B; //
4.237 - iOutputReportBuffer[4]=0x63; //
4.238 - iOutputReportBuffer[5]=0x49; //
4.239 - iOutputReportBuffer[6]=0x44; //
4.240 - int res = hid_write(connected_device, iOutputReportBuffer, KFutabaMaxHidReportSize);
4.241 - */
4.242 -
4.243 iVfd01.RequestId();
4.244 -
4.245 return 1;
4.246 }
4.247
4.248 long
4.249 MainWindow::onFutabaReadFirmwareRevision(FXObject *sender, FXSelector sel, void *ptr)
4.250 {
4.251 - //1BH,5BH,63H,46H,52H
4.252 - /*
4.253 - memset(iOutputReportBuffer, 0x0, KFutabaMaxHidReportSize);
4.254 - iOutputReportBuffer[0]=0x00; //Report ID
4.255 - iOutputReportBuffer[1]=0x05; //Report length
4.256 - iOutputReportBuffer[2]=0x1B; //
4.257 - iOutputReportBuffer[3]=0x5B; //
4.258 - iOutputReportBuffer[4]=0x63; //
4.259 - iOutputReportBuffer[5]=0x46; //
4.260 - iOutputReportBuffer[6]=0x52; //
4.261 - int res = hid_write(connected_device, iOutputReportBuffer, KFutabaMaxHidReportSize);
4.262 - */
4.263 iVfd01.RequestFirmwareRevision();
4.264 -
4.265 return 1;
4.266 }
4.267
4.268 long
4.269 MainWindow::onFutabaPowerSupplyMonitor(FXObject *sender, FXSelector sel, void *ptr)
4.270 {
4.271 - //1BH,5BH,63H,50H,4DH
4.272 - /*
4.273 - memset(iOutputReportBuffer, 0x0, KFutabaMaxHidReportSize);
4.274 - iOutputReportBuffer[0]=0x00; //Report ID
4.275 - iOutputReportBuffer[1]=0x05; //Report length
4.276 - iOutputReportBuffer[2]=0x1B; //
4.277 - iOutputReportBuffer[3]=0x5B; //
4.278 - iOutputReportBuffer[4]=0x63; //
4.279 - iOutputReportBuffer[5]=0x50; //
4.280 - iOutputReportBuffer[6]=0x4D; //
4.281 - int res = hid_write(connected_device, iOutputReportBuffer, KFutabaMaxHidReportSize);
4.282 - */
4.283 -
4.284 iVfd01.RequestPowerSupplyStatus();
4.285 -
4.286 return 1;
4.287 }
4.288