inc/MainWindow.h
author sl
Thu, 22 May 2014 09:31:23 +0200
changeset 18 14662967f913
parent 15 e5b84f315be7
child 21 7d89d719583e
permissions -rw-r--r--
Implementing Futaba GP1212A01A brightness support.
Test application now using Futaba class to send some of our commands.
     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_SELECT_FONT,
    44         ID_LAST
    45     };
    46 
    47     size_t getDataFromTextField(FXTextField *tf, char *buf, size_t len);
    48     int getLengthFromTextField(FXTextField *tf);
    49 
    50 protected:
    51     MainWindow() {};
    52 public:
    53     MainWindow(FXApp *a);
    54     ~MainWindow();
    55     virtual void create();
    56 
    57     long onConnect(FXObject *sender, FXSelector sel, void *ptr);
    58     long onDisconnect(FXObject *sender, FXSelector sel, void *ptr);
    59     long onScan(FXObject *sender, FXSelector sel, void *ptr);
    60     long onSendOutputReport(FXObject *sender, FXSelector sel, void *ptr);
    61     long onSendFeatureReport(FXObject *sender, FXSelector sel, void *ptr);
    62     long onGetFeatureReport(FXObject *sender, FXSelector sel, void *ptr);
    63     long onClear(FXObject *sender, FXSelector sel, void *ptr);
    64     //
    65     long onFutabaClearDisplay(FXObject *sender, FXSelector sel, void *ptr);
    66     long onFutabaDimming(FXObject *sender, FXSelector sel, void *ptr);
    67     long onFutabaDisplayDataInput(FXObject *sender, FXSelector sel, void *ptr);
    68     long onFutabaReadId(FXObject *sender, FXSelector sel, void *ptr);
    69     long onFutabaReadFirmwareRevision(FXObject *sender, FXSelector sel, void *ptr);
    70     long onFutabaPowerSupplyMonitor(FXObject *sender, FXSelector sel, void *ptr);
    71     long onFutabaSetAllPixels(FXObject *sender, FXSelector sel, void *ptr);
    72     long onFutabaSetPixel(FXObject *sender, FXSelector sel, void *ptr);
    73     long onFutabaResetPixel(FXObject *sender, FXSelector sel, void *ptr);
    74     //
    75     long onSelectFont(FXObject *sender, FXSelector sel, void *ptr);
    76     //
    77     long onTimeout(FXObject *sender, FXSelector sel, void *ptr);
    78     long onMacTimeout(FXObject *sender, FXSelector sel, void *ptr);
    79     //
    80     void SetPixel(int aX, int aY, unsigned char aValue);
    81     void SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue);
    82 
    83 private:
    84     void SetConnectedStates();
    85     bool IsConnected();
    86 
    87 private:
    88     FXList *device_list;
    89     FXButton *connect_button;
    90     FXButton *disconnect_button;
    91     FXButton *rescan_button;
    92     FXButton *output_button;
    93     FXLabel *connected_label;
    94     FXTextField *output_text;
    95     FXTextField *output_len;
    96     FXButton *feature_button;
    97     FXButton *get_feature_button;
    98     FXTextField *feature_text;
    99     FXTextField *feature_len;
   100     FXTextField *get_feature_text;
   101     FXText *input_text;
   102     FXFont *title_font;
   103     //Futaba VFD control
   104     FXButton *iButtonClearDisplay;
   105     FXButton *iButtonDimming;
   106     FXButton *iButtonDisplayDataInput;
   107     FXButton *iButtonReadId;
   108     FXButton *iButtonReadFirmwareRevision;
   109     FXButton *iButtonPowerSupplyMonitor;
   110     FXTextField *iTextFieldX;
   111     FXTextField *iTextFieldY;
   112     FXButton *iButtonSetPixel;
   113     FXButton *iButtonResetPixel;
   114     FXButton *iButtonSetAllPixels;
   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 //