inc/MainWindow.h
author sl
Thu, 22 May 2014 16:46:50 +0200
changeset 22 efa6ff02287c
parent 21 7d89d719583e
child 23 d4e164906a1b
permissions -rw-r--r--
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 
     2 
     3 #ifndef MAIN_WINDOW_H
     4 #define MAIN_WINDOW_H
     5 
     6 #include <fx.h>
     7 #include "hidapi.h"
     8 #include "mac_support.h"
     9 #include <string.h>
    10 #include <stdlib.h>
    11 #include <limits.h>
    12 #include "FutabaVfd.h"
    13 
    14 #ifdef _WIN32
    15 // Thanks Microsoft, but I know how to use strncpy().
    16 #pragma warning(disable:4996)
    17 #endif
    18 
    19 class MainWindow : public FXMainWindow {
    20     FXDECLARE(MainWindow)
    21 
    22 public:
    23     enum {
    24         ID_FIRST = FXMainWindow::ID_LAST,
    25         ID_CONNECT,
    26         ID_DISCONNECT,
    27         ID_RESCAN,
    28         ID_SEND_OUTPUT_REPORT,
    29         ID_SEND_FEATURE_REPORT,
    30         ID_GET_FEATURE_REPORT,
    31         ID_CLEAR,
    32         ID_TIMER,
    33         ID_MAC_TIMER,
    34         ID_FUTABA_CLEAR_DISPLAY,
    35         ID_FUTABA_DIMMING,
    36         ID_FUTABA_DISPLAY_DATA_INPUT,
    37         ID_FUTABA_READ_ID,
    38         ID_FUTABA_READ_FIRMWARE_REVISION,
    39         ID_FUTABA_POWER_SUPPLY_MONITOR,
    40         ID_FUTABA_SET_PIXEL,
    41         ID_FUTABA_RESET_PIXEL,
    42         ID_FUTABA_SET_ALL_PIXELS,
    43         ID_FUTABA_SET_DISPLAY_POSITION,
    44         ID_SELECT_FONT,
    45         ID_LAST
    46     };
    47 
    48     size_t getDataFromTextField(FXTextField *tf, char *buf, size_t len);
    49     int getLengthFromTextField(FXTextField *tf);
    50 
    51 protected:
    52     MainWindow() {};
    53 public:
    54     MainWindow(FXApp *a);
    55     ~MainWindow();
    56     virtual void create();
    57 
    58     long onConnect(FXObject *sender, FXSelector sel, void *ptr);
    59     long onDisconnect(FXObject *sender, FXSelector sel, void *ptr);
    60     long onScan(FXObject *sender, FXSelector sel, void *ptr);
    61     long onSendOutputReport(FXObject *sender, FXSelector sel, void *ptr);
    62     long onSendFeatureReport(FXObject *sender, FXSelector sel, void *ptr);
    63     long onGetFeatureReport(FXObject *sender, FXSelector sel, void *ptr);
    64     long onClear(FXObject *sender, FXSelector sel, void *ptr);
    65     //
    66     long onFutabaClearDisplay(FXObject *sender, FXSelector sel, void *ptr);
    67     long onFutabaDimming(FXObject *sender, FXSelector sel, void *ptr);
    68     long onFutabaDisplayDataInput(FXObject *sender, FXSelector sel, void *ptr);
    69     long onFutabaReadId(FXObject *sender, FXSelector sel, void *ptr);
    70     long onFutabaReadFirmwareRevision(FXObject *sender, FXSelector sel, void *ptr);
    71     long onFutabaPowerSupplyMonitor(FXObject *sender, FXSelector sel, void *ptr);
    72     long onFutabaSetAllPixels(FXObject *sender, FXSelector sel, void *ptr);
    73     long onFutabaSetPixel(FXObject *sender, FXSelector sel, void *ptr);
    74     long onFutabaResetPixel(FXObject *sender, FXSelector sel, void *ptr);
    75     long onFutabaSetDisplayPosition(FXObject *sender, FXSelector sel, void *ptr);
    76     //
    77     long onSelectFont(FXObject *sender, FXSelector sel, void *ptr);
    78     //
    79     long onTimeout(FXObject *sender, FXSelector sel, void *ptr);
    80     long onMacTimeout(FXObject *sender, FXSelector sel, void *ptr);
    81     
    82 private:
    83     void SetConnectedStates();
    84     bool IsConnected();
    85 
    86 private:
    87     FXList *device_list;
    88     FXButton *connect_button;
    89     FXButton *disconnect_button;
    90     FXButton *rescan_button;
    91     FXButton *output_button;
    92     FXLabel *connected_label;
    93     FXTextField *output_text;
    94     FXTextField *output_len;
    95     FXButton *feature_button;
    96     FXButton *get_feature_button;
    97     FXTextField *feature_text;
    98     FXTextField *feature_len;
    99     FXTextField *get_feature_text;
   100     FXText *input_text;
   101     FXFont *title_font;
   102     //Futaba VFD control
   103     FXButton *iButtonClearDisplay;
   104     FXButton *iButtonBrightness;
   105     FXButton *iButtonDisplayDataInput;
   106     FXButton *iButtonReadId;
   107     FXButton *iButtonReadFirmwareRevision;
   108     FXButton *iButtonPowerSupplyMonitor;
   109     FXTextField *iTextFieldX;
   110     FXTextField *iTextFieldY;
   111     FXButton *iButtonSetPixel;
   112     FXButton *iButtonResetPixel;
   113     FXButton *iButtonSetAllPixels;
   114     FXButton *iButtonSetDisplayPosition;
   115     //Font
   116     FXButton *iButtonSelectFont;
   117 
   118     unsigned char* iOutputReportBuffer;
   119     unsigned char iBrightness; //Current VFD dimming
   120     FXFontDesc iCurrentFontDesc;
   121     FXFont* iCurrentFont;
   122     FXTGAImage* iFontImage;
   123 
   124     struct hid_device_info *devices;
   125     hid_device *connected_device;
   126 
   127 	//Futaba
   128 	GP1212A01A iVfd01;
   129 
   130 };
   131 
   132 #endif //